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=82527f4c763b11f8f87d9fe3b4906c6d99f9e6b3;hp=920e152fa29e19e122037483a15a810bcb05d50d;hb=03c2c6f58b8812f93b2a396a22a26817aec2ad71;hpb=9781441fa162e32e5796658d4169387a3ffb5d88 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp index 920e152..82527f4 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp @@ -443,6 +443,8 @@ int UtcDaliItemViewSetAndGetRefreshInterval(void) // Set the interval between refreshes to be 20 view.SetRefreshInterval(20); + view.Refresh(); + // Check the interval between refreshes is 20 DALI_TEST_CHECK(view.GetRefreshInterval() == 20); END_TEST; @@ -523,7 +525,7 @@ int UtcDaliItemViewScrollToItem(void) END_TEST; } -int UtcDaliItemViewSetAndGetMouseWheelScrollDistanceStep(void) +int UtcDaliItemViewSetAndGetWheelScrollDistanceStep(void) { ToolkitTestApplication application; @@ -531,10 +533,241 @@ int UtcDaliItemViewSetAndGetMouseWheelScrollDistanceStep(void) TestItemFactory factory; ItemView view = ItemView::New(factory); - // Set the scroll distance step for the mouse wheel event to be 100.0f - view.SetMouseWheelScrollDistanceStep(100.0f); + // Set the scroll distance step for the wheel event to be 100.0f + view.SetWheelScrollDistanceStep(100.0f); // Check the scroll distance step is 100.0f - DALI_TEST_EQUALS(view.GetMouseWheelScrollDistanceStep(), 100.0f, TEST_LOCATION ); + DALI_TEST_EQUALS(view.GetWheelScrollDistanceStep(), 100.0f, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliItemViewInsertItemP(void) +{ + ToolkitTestApplication application; + + // 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); + + // Activate the grid layout so that the items will be created and added to ItemView + Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); + view.ActivateLayout(0, stageSize, 0.5f); + + // Get the item given the item ID + Actor itemActor = view.GetItem(2); + + ItemId id = view.GetItemId( itemActor ); + + // Check we are getting the correct Item ID given the specified actor + DALI_TEST_CHECK(view.GetItemId(itemActor) == 2); + + Actor newActor = Actor::New(); + + view.InsertItem(Item(id, newActor), 0.5f); + + DALI_TEST_CHECK(view.GetItem(2) == newActor); + END_TEST; +} + +int UtcDaliItemViewInsertItemsP(void) +{ + ToolkitTestApplication application; + + // 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); + + // Activate the grid layout so that the items will be created and added to ItemView + Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); + view.ActivateLayout(0, stageSize, 0.5f); + + unsigned int itemCount = view.GetChildCount(); + + ItemContainer insertList; + + for( unsigned int i = 0u; i < 10; ++i ) + { + Actor child = view.GetChildAt( i ); + Actor newActor = Actor::New(); + newActor.SetName("Inserted"); + insertList.push_back( Item( view.GetItemId(child), newActor ) ); + } + + if( !insertList.empty() ) + { + view.InsertItems( insertList, 0.5f ); + } + + DALI_TEST_CHECK(view.GetChildCount() == itemCount + 10); + + ItemIdContainer removeList; + + for( unsigned int i = 0u; i < view.GetChildCount(); ++i ) + { + Actor child = view.GetChildAt( i ); + + if( child.GetName() == "Inserted" ) + { + removeList.push_back( view.GetItemId(child) ); + } + } + + if( ! removeList.empty() ) + { + view.RemoveItems( removeList, 0.5f ); + } + + DALI_TEST_CHECK(view.GetChildCount() == itemCount); + END_TEST; +} + +int UtcDaliItemViewReplaceItemP(void) +{ + ToolkitTestApplication application; + + // 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); + + // Activate the grid layout so that the items will be created and added to ItemView + Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); + view.ActivateLayout(0, stageSize, 0.5f); + + Actor newActor = Actor::New(); + + view.ReplaceItem( Item( 0, newActor ), 0.5f ); + + DALI_TEST_CHECK(view.GetItem(0) == newActor); + END_TEST; +} + +int UtcDaliItemViewReplaceItemsP(void) +{ + ToolkitTestApplication application; + + // 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); + + // Activate the grid layout so that the items will be created and added to ItemView + Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); + view.ActivateLayout(0, stageSize, 0.5f); + + ItemContainer replaceList; + + for( unsigned int i = 0u; i < 10; ++i ) + { + Actor child = view.GetChildAt( i ); + Actor newActor = Actor::New(); + newActor.SetName("Replaced"); + + replaceList.push_back( Item( view.GetItemId(child), newActor ) ); + } + + if( !replaceList.empty() ) + { + view.ReplaceItems( replaceList, 0.5f ); + } + + DALI_TEST_CHECK(view.GetItem(0).GetName() == "Replaced"); + DALI_TEST_CHECK(view.GetItem(8).GetName() == "Replaced"); + END_TEST; +} + +int UtcDaliItemViewGetItemsRangeP(void) +{ + ToolkitTestApplication application; + + // 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); + + // Activate the grid layout so that the items will be created and added to ItemView + Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); + view.ActivateLayout(0, stageSize, 0.5f); + + ItemRange itemRange(0, 0); + + view.GetItemsRange(itemRange); + + DALI_TEST_CHECK(itemRange.Within(0)); + END_TEST; +} + +int UtcDaliItemViewSetItemsAnchorPointP(void) +{ + ToolkitTestApplication application; + + // 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); + + // Activate the grid layout so that the items will be created and added to ItemView + Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); + view.ActivateLayout(0, stageSize, 0.5f); + + Vector3 anchorPoint(10.0f, 10.0f, 0.0f); + + view.SetItemsAnchorPoint(anchorPoint); + + DALI_TEST_CHECK(view.GetItemsAnchorPoint() == anchorPoint); + DALI_TEST_CHECK(view.GetItem(0).GetCurrentAnchorPoint() == anchorPoint); + END_TEST; +} + +int UtcDaliItemViewSetItemsParentOriginP(void) +{ + ToolkitTestApplication application; + + // 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); + + // Activate the grid layout so that the items will be created and added to ItemView + Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); + view.ActivateLayout(0, stageSize, 0.5f); + + Vector3 parentOrigin(10.0f, 10.0f, 0.0f); + + view.SetItemsParentOrigin(parentOrigin); + + DALI_TEST_CHECK(view.GetItemsParentOrigin() == parentOrigin); + DALI_TEST_CHECK(view.GetItem(0).GetCurrentParentOrigin() == parentOrigin); + END_TEST; +} + +int UtcDaliItemFactoryGetExtention(void) +{ + ToolkitTestApplication application; + TestItemFactory factory; + DALI_TEST_CHECK( factory.GetExtension() == NULL ); END_TEST; }