X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-ItemView.cpp;h=040fb1ced0780faf0fc339bc9c43a1c7d6ed23af;hp=8be97fe288055033134ed46b78a6858d577aeb8b;hb=9ce1fa453940de2fb38552cc374cd54af660debf;hpb=71e9401257ac2b3612aef56b6b94303cb1d3a849 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp old mode 100644 new mode 100755 index 8be97fe..040fb1c --- a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include using namespace Dali; @@ -50,6 +52,7 @@ const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each static bool gObjectCreatedCallBackCalled; static bool gOnLayoutActivatedCalled; ///< Whether the LayoutActivated signal was invoked. +static bool gOnScrollUpdateCalled; static void TestCallback(BaseHandle handle) { @@ -61,6 +64,11 @@ static void OnLayoutActivated() gOnLayoutActivatedCalled = true; } +static void OnScrollUpdate( const Vector2& position ) +{ + gOnScrollUpdateCalled = true; +} + // Generate a PanGestureEvent to send to Core Integration::PanGestureEvent GeneratePan( Gesture::State state, @@ -345,6 +353,7 @@ int UtcDaliItemViewDeactivateCurrentLayout(void) // Create a grid layout and add it to ItemView ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); + gridLayout->SetOrientation(ControlOrientation::Down); view.AddLayout(*gridLayout); // Check there is no active layout at the moment @@ -375,6 +384,7 @@ int UtcDaliItemViewGetItemAndGetItemId(void) // Create a grid layout and add it to ItemView ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); + gridLayout->SetOrientation(ControlOrientation::Left); view.AddLayout(*gridLayout); // Activate the grid layout so that the items will be created and added to ItemView @@ -399,6 +409,7 @@ int UtcDaliItemViewRemoveItem(void) // Create a grid layout and add it to ItemView ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); + gridLayout->SetOrientation(ControlOrientation::Right); view.AddLayout(*gridLayout); // Activate the grid layout so that the items will be created and added to ItemView @@ -430,9 +441,10 @@ int UtcDaliItemViewGetCurrentLayoutPosition(void) TestItemFactory factory; ItemView view = ItemView::New(factory); - // Create a grid layout and add it to ItemView - ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); - view.AddLayout(*gridLayout); + // Create a depth layout and add it to ItemView + ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH ); + depthLayout->SetOrientation(ControlOrientation::Up); + view.AddLayout(*depthLayout); // Activate the grid layout so that the items will be created and added to ItemView Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); @@ -533,14 +545,14 @@ int UtcDaliItemViewScrollToItem(void) TestItemFactory factory; ItemView view = ItemView::New(factory); Vector3 vec(480.0f, 800.0f, 0.0f); - ItemLayoutPtr layout = DefaultItemLayout::New( DefaultItemLayout::GRID ); + ItemLayoutPtr layout = DefaultItemLayout::New( DefaultItemLayout::DEPTH ); view.SetName("view actor"); view.AddLayout(*layout); view.SetSize(vec); Stage::GetCurrent().Add(view); - layout->SetOrientation(ControlOrientation::Up); + layout->SetOrientation(ControlOrientation::Down); view.ActivateLayout(0, vec, 0.0f); application.SendNotification(); @@ -624,9 +636,10 @@ int UtcDaliItemViewInsertItemP(void) TestItemFactory factory; ItemView view = ItemView::New(factory); - // Create a grid layout and add it to ItemView - ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); - view.AddLayout(*gridLayout); + // Create a depth layout and add it to ItemView + ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH); + depthLayout->SetOrientation(ControlOrientation::Left); + view.AddLayout(*depthLayout); // Activate the grid layout so that the items will be created and added to ItemView Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); @@ -656,9 +669,10 @@ int UtcDaliItemViewInsertItemsP(void) TestItemFactory factory; ItemView view = ItemView::New(factory); - // Create a grid layout and add it to ItemView - ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); - view.AddLayout(*gridLayout); + // Create a depth layout and add it to ItemView + ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH); + depthLayout->SetOrientation(ControlOrientation::Right); + view.AddLayout(*depthLayout); // Activate the grid layout so that the items will be created and added to ItemView Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); @@ -712,9 +726,9 @@ int UtcDaliItemViewReplaceItemP(void) TestItemFactory factory; ItemView view = ItemView::New(factory); - // Create a grid layout and add it to ItemView - ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); - view.AddLayout(*gridLayout); + // Create a spiral layout and add it to ItemView + ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL ); + view.AddLayout(*spiralLayout); // Activate the grid layout so that the items will be created and added to ItemView Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); @@ -736,9 +750,10 @@ int UtcDaliItemViewReplaceItemsP(void) TestItemFactory factory; ItemView view = ItemView::New(factory); - // Create a grid layout and add it to ItemView - ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); - view.AddLayout(*gridLayout); + // Create a spiral layout and add it to ItemView + ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL ); + spiralLayout->SetOrientation( ControlOrientation::Down ); + view.AddLayout(*spiralLayout); // Activate the grid layout so that the items will be created and added to ItemView Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); @@ -773,9 +788,10 @@ int UtcDaliItemViewGetItemsRangeP(void) TestItemFactory factory; ItemView view = ItemView::New(factory); - // Create a grid layout and add it to ItemView - ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); - view.AddLayout(*gridLayout); + // Create a spiral layout and add it to ItemView + ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL ); + spiralLayout->SetOrientation( ControlOrientation::Left ); + view.AddLayout(*spiralLayout); // Activate the grid layout so that the items will be created and added to ItemView Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); @@ -797,9 +813,10 @@ int UtcDaliItemViewSetItemsAnchorPointP(void) TestItemFactory factory; ItemView view = ItemView::New(factory); - // Create a grid layout and add it to ItemView - ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); - view.AddLayout(*gridLayout); + // Create a spiral layout and add it to ItemView + ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL ); + spiralLayout->SetOrientation( ControlOrientation::Right ); + view.AddLayout(*spiralLayout); // Activate the grid layout so that the items will be created and added to ItemView Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); @@ -923,12 +940,83 @@ int UtcDaliItemViewSetGetProperty(void) view.SetProperty( ItemView::Property::REFRESH_INTERVAL, 11.0f ); DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::REFRESH_INTERVAL).Get(), 11.0f, TEST_LOCATION ); + // Test "layout" property + DALI_TEST_CHECK( view.GetPropertyIndex("layout") == DevelItemView::Property::LAYOUT ); + Property::Map gridLayoutProperty; + gridLayoutProperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::GRID) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::ITEM_SIZE, Dali::Property::Value(Vector3(200, 200,50)) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_ROW_SPACING, Dali::Property::Value(50.0f) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_COLUMN_NUMBER, Dali::Property::Value(4) ); + + Property::Map depthLayoutProperty; + depthLayoutProperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::DEPTH) ); + depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_COLUMN_NUMBER, Dali::Property::Value(3) ); + depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_ROW_NUMBER, Dali::Property::Value(26.0f) ); + + Property::Map spiralLayoutPrperty; + spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::SPIRAL) ); + spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_ITEM_SPACING, Dali::Property::Value((Math::PI*2.0f)/9.5f) ); + spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_TOP_ITEM_ALIGNMENT, Dali::Property::Value(-0.125f) ); + + Property::Map listLayoutPrperty; + listLayoutPrperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::LIST) ); + listLayoutPrperty.Insert( DefaultItemLayoutProperty::ITEM_SIZE, Dali::Property::Value(Vector3(100, 100,50)) ); + + + Property::Array layoutArray; + layoutArray.PushBack(gridLayoutProperty); + layoutArray.PushBack(depthLayoutProperty); + layoutArray.PushBack(spiralLayoutPrperty); + layoutArray.PushBack(listLayoutPrperty); + + view.SetProperty( DevelItemView::Property::LAYOUT, layoutArray); + + Property::Array getLayoutArray; + DALI_TEST_CHECK( view.GetProperty(DevelItemView::Property::LAYOUT ).Get( getLayoutArray ) ); + + //Check that the result is the same as + DALI_TEST_EQUALS( layoutArray.Count(), getLayoutArray.Count(), TEST_LOCATION ); + Property::Map firstLayout = *((getLayoutArray.GetElementAt( 0 )).GetMap()); + + for( unsigned int mapIdx = 0, mapCount = firstLayout.Count(); mapIdx < mapCount; ++mapIdx ) + { + KeyValuePair propertyPair( firstLayout.GetKeyValue( mapIdx ) ); + if(propertyPair.first == DefaultItemLayoutProperty::TYPE) + { + int layoutType = propertyPair.second.Get(); + DALI_TEST_EQUALS( layoutType, (int)DefaultItemLayout::GRID, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::ITEM_SIZE) + { + Vector3 size = propertyPair.second.Get(); + DALI_TEST_EQUALS( size, Vector3(200, 200,50), TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::GRID_ROW_SPACING) + { + float spacing = propertyPair.second.Get(); + DALI_TEST_EQUALS( spacing, 50.0f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::GRID_COLUMN_NUMBER) + { + int number = propertyPair.second.Get(); + DALI_TEST_EQUALS(number, 4, TEST_LOCATION ); + } + } + view.SetProperty( DevelItemView::Property::LAYOUT, layoutArray); + + // Test "overshootEnabled" property DALI_TEST_CHECK( view.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED ); DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get(), view.IsOvershootEnabled(), TEST_LOCATION ); view.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false ); DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get(), false, TEST_LOCATION ); + // Test "overshootSize" property + DALI_TEST_CHECK( view.GetPropertyIndex("overshootSize") == Scrollable::Property::OVERSHOOT_SIZE ); + Vector2 overshootSize = Vector2(100.0f,100.0f); + view.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize ); + DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get(), overshootSize, TEST_LOCATION ); + // Animatable properties // Test "layoutPosition" property @@ -1093,3 +1181,44 @@ int UtcDaliItemViewOvershootHorizontal(void) END_TEST; } + +int UtcDaliItemEnableDisableRefresh(void) +{ + ToolkitTestApplication application; + Dali::Stage stage = Dali::Stage::GetCurrent(); + + // Create the ItemView actor + TestItemFactory factory; + ItemView view = ItemView::New(factory); + + // Create a grid layout and add it to ItemView + ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); + view.AddLayout(*gridLayout); + stage.Add(view); + + // Activate the grid layout so that the items will be created and added to ItemView + Vector3 stageSize(stage.GetSize()); + view.ActivateLayout(0, stageSize, 0.5f); + + //Connect to signal scroll updated + view.ScrollUpdatedSignal().Connect( &OnScrollUpdate ); + + Property::Map attributes; + view.DoAction("enableRefresh", attributes ); + gOnScrollUpdateCalled = true; + view.SetProperty( ItemView::Property::LAYOUT_POSITION, 100.0f ); + application.SendNotification(); + application.Render(1000); + DALI_TEST_EQUALS( gOnScrollUpdateCalled, true, TEST_LOCATION ); + + + view.DoAction("disableRefresh", attributes ); + gOnScrollUpdateCalled = false; + view.SetProperty( ItemView::Property::LAYOUT_POSITION, 100.0f ); + application.SendNotification(); + application.Render(1000); + + DALI_TEST_EQUALS( gOnScrollUpdateCalled, false, TEST_LOCATION ); + + END_TEST; +}