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=da5ce83797ba1f559585c25e05794b7d8f0769f9;hp=b1fd832249b4c30016575d93eece2775fd3a1813;hb=be93fd772a1b1b09425ac0aaec1ea1b64e9a9e60;hpb=3ef357cc431d17b7be772f0f74acb080feab123e diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp index b1fd832..da5ce83 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,9 @@ // Need to override adaptor classes for toolkit test harness, so include // test harness headers before dali headers. #include - #include +#include +#include using namespace Dali; using namespace Toolkit; @@ -41,13 +42,15 @@ void utc_dali_toolkit_item_view_cleanup(void) namespace { -const unsigned int TOTAL_ITEM_NUMBER = 100; +const unsigned int TOTAL_ITEM_NUMBER = 400; const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg"; const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS) static bool gObjectCreatedCallBackCalled; static bool gOnLayoutActivatedCalled; ///< Whether the LayoutActivated signal was invoked. +static bool gOnScrollUpdateCalled; +static bool gOnWheelEventCalled; ///< Whether the WheelEventSignal signal was invoked. static void TestCallback(BaseHandle handle) { @@ -59,6 +62,31 @@ static void OnLayoutActivated() gOnLayoutActivatedCalled = true; } +static void OnScrollUpdate( const Vector2& position ) +{ + gOnScrollUpdateCalled = true; +} + +static bool OnWheelEvent( Actor actor, const Dali::WheelEvent& wheelEvent ) +{ + gOnWheelEventCalled = true; + return false; +} + +Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition, uint32_t time ) +{ + Integration::TouchEvent touchEvent; + Integration::Point point; + point.SetState( state ); + point.SetDeviceId(4); + point.SetScreenPosition( screenPosition ); + point.SetDeviceClass( Device::Class::TOUCH ); + point.SetDeviceSubclass( Device::Subclass::NONE ); + touchEvent.points.push_back( point ); + touchEvent.time = time; + return touchEvent; +} + /* * Simulate time passed by. * @@ -114,10 +142,7 @@ public: // From ItemFactory virtual Actor NewItem(unsigned int itemId) { // Create a renderable actor for this item - Image image = ResourceImage::New( TEST_IMAGE_FILE_NAME ); - Actor actor = CreateRenderableActor(image); - - return actor; + return ImageView::New( TEST_IMAGE_FILE_NAME ); } }; @@ -135,7 +160,7 @@ int UtcDaliItemViewNew(void) DALI_TEST_CHECK(view); //Additional check to ensure object is created by checking if it's registered - ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry(); + ObjectRegistry registry = application.GetCore().GetObjectRegistry(); DALI_TEST_CHECK( registry ); gObjectCreatedCallBackCalled = false; @@ -148,6 +173,75 @@ int UtcDaliItemViewNew(void) END_TEST; } +int UtcDaliItemViewCopyConstructor(void) +{ + ToolkitTestApplication application; + + TestItemFactory factory; + ItemView itemView = ItemView::New( factory ); + DALI_TEST_CHECK( itemView ); + + ItemView copy( itemView ); + DALI_TEST_CHECK( copy ); + + END_TEST; +} + +int UtcDaliItemViewCopyAssignment(void) +{ + ToolkitTestApplication application; + + TestItemFactory factory; + ItemView itemView = ItemView::New( factory ); + DALI_TEST_CHECK( itemView ); + + ItemView copy; + copy = itemView; + DALI_TEST_CHECK( copy ); + DALI_TEST_EQUALS( itemView, copy, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliItemViewMoveConstructor(void) +{ + ToolkitTestApplication application; + + TestItemFactory factory; + ItemView itemView = ItemView::New( factory ); + DALI_TEST_EQUALS( 1, itemView.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + itemView.SetProperty( Actor::Property::SENSITIVE, false ); + DALI_TEST_CHECK( false == itemView.GetProperty< bool >( Actor::Property::SENSITIVE ) ); + + ItemView moved = std::move( itemView ); + DALI_TEST_CHECK( moved ); + DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) ); + DALI_TEST_CHECK( !itemView ); + + END_TEST; +} + +int UtcDaliItemViewMoveAssignment(void) +{ + ToolkitTestApplication application; + + TestItemFactory factory; + ItemView itemView = ItemView::New( factory ); + DALI_TEST_EQUALS( 1, itemView.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + itemView.SetProperty( Actor::Property::SENSITIVE, false ); + DALI_TEST_CHECK( false == itemView.GetProperty< bool >( Actor::Property::SENSITIVE ) ); + + ItemView moved; + moved = std::move( itemView ); + DALI_TEST_CHECK( moved ); + DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) ); + DALI_TEST_CHECK( !itemView ); + + END_TEST; +} + int UtcDaliItemViewDownCast(void) { ToolkitTestApplication application; @@ -271,7 +365,7 @@ int UtcDaliItemViewActivateLayoutAndGetActiveLayout(void) DALI_TEST_CHECK(view.GetActiveLayout() == NULL); // Activate the depth layout - Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); + Vector3 stageSize(application.GetScene().GetSize()); view.ActivateLayout(1, stageSize, 0.5f); // Check the current active layout is the depth layout @@ -301,13 +395,14 @@ 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 DALI_TEST_CHECK(view.GetActiveLayout() == NULL); // Activate the grid layout - Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); + Vector3 stageSize(application.GetScene().GetSize()); view.ActivateLayout(0, stageSize, 0.5f); // Check the current active layout is the grid layout @@ -331,10 +426,11 @@ 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 - Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); + Vector3 stageSize(application.GetScene().GetSize()); view.ActivateLayout(0, stageSize, 0.5f); // Get the item given the item ID @@ -355,10 +451,11 @@ 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 - Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); + Vector3 stageSize(application.GetScene().GetSize()); view.ActivateLayout(0, stageSize, 0.5f); // Get the item given the item ID 2 and 3 @@ -368,13 +465,34 @@ int UtcDaliItemViewRemoveItem(void) // Remove the item with ID 2 view.RemoveItem(2, 0.0f); - // Get the new item given the item ID 2 + // Get the new item given the item ID 2 and 3 Actor newItemActorID2 = view.GetItem(2); + Actor newItemActorID3 = view.GetItem(3); // Check the original item with item ID 2 was deleted and now item ID 2 represents the original item with ID 3 DALI_TEST_CHECK(view.GetItemId(newItemActorID2) == 2); DALI_TEST_CHECK(oldItemActorID2 != newItemActorID2); - DALI_TEST_CHECK(newItemActorID2 = oldItemActorID3); + DALI_TEST_CHECK(newItemActorID2 == oldItemActorID3); + + // scroll to the end of item view + view.ScrollToItem(TOTAL_ITEM_NUMBER - 1, 0.00f); + + application.SendNotification(); + application.Render(0); + + // Refresh the item view + view.Refresh(); + + Actor itemActorID390 = view.GetItem(390); + DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 390); + + // Remove the item with ID 2 (which is now before the current item range) + view.RemoveItem(2, 0.0f); + + // Check the original item with item ID 2 was deleted and now item ID 389 represents the original item with ID 390 + DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 389); + DALI_TEST_CHECK(view.GetItem(389) == itemActorID390); + END_TEST; } @@ -386,12 +504,13 @@ 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()); + Vector3 stageSize(application.GetScene().GetSize()); view.ActivateLayout(0, stageSize, 0.0f); // Check the current layout position for the 10th items is 9.0f @@ -489,14 +608,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.SetProperty( Dali::Actor::Property::NAME,"view actor"); view.AddLayout(*layout); - view.SetSize(vec); + view.SetProperty( Actor::Property::SIZE, vec ); - Stage::GetCurrent().Add(view); - layout->SetOrientation(ControlOrientation::Up); + application.GetScene().Add(view); + layout->SetOrientation(ControlOrientation::Down); view.ActivateLayout(0, vec, 0.0f); application.SendNotification(); @@ -552,7 +671,7 @@ int UtcDaliItemViewScrollToItem(void) tet_result(TET_FAIL); } - Stage::GetCurrent().Remove(view); + application.GetScene().Remove(view); END_TEST; } @@ -581,14 +700,15 @@ int UtcDaliItemViewInsertItemP(void) ItemView view = ItemView::New(factory); // Create a grid layout and add it to ItemView - ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); + 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 - Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); - view.ActivateLayout(0, stageSize, 0.5f); + Vector3 stageSize(application.GetScene().GetSize()); + view.ActivateLayout(0, stageSize, 0.0f); - // Get the item given the item ID + // Get the specified item where new item to be inserted before that Actor itemActor = view.GetItem(2); ItemId id = view.GetItemId( itemActor ); @@ -598,9 +718,33 @@ int UtcDaliItemViewInsertItemP(void) Actor newActor = Actor::New(); - view.InsertItem(Item(id, newActor), 0.5f); + view.InsertItem(Item(id, newActor), 0.0f); DALI_TEST_CHECK(view.GetItem(2) == newActor); + + DALI_TEST_CHECK(view.GetItemId(itemActor) == 3); + DALI_TEST_CHECK(view.GetItem(3) == itemActor); + + // scroll to the end of item view + view.ScrollToItem(TOTAL_ITEM_NUMBER - 1, 0.00f); + + application.SendNotification(); + application.Render(0); + + // Refresh the item view + view.Refresh(); + + Actor itemActorID390 = view.GetItem(390); + DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 390); + + // Insert the item with ID 2 (which is now before the current item range) + Actor anotherNewActor = Actor::New(); + view.InsertItem(Item(id, anotherNewActor), 0.0f); + + // Check that item ID 391 now represents the original item with ID 390 + DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 391); + DALI_TEST_CHECK(view.GetItem(391) == itemActorID390); + END_TEST; } @@ -612,23 +756,30 @@ 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()); + Vector3 stageSize(application.GetScene().GetSize()); view.ActivateLayout(0, stageSize, 0.5f); unsigned int itemCount = view.GetChildCount(); + // Get the specified item where new items to be inserted before that + Actor itemActor = view.GetItem(1); + + // Check we are getting the correct Item ID given the specified item + DALI_TEST_CHECK(view.GetItemId(itemActor) == 1); + ItemContainer insertList; - for( unsigned int i = 0u; i < 10; ++i ) + for( unsigned int i = 1u; i < 11; ++i ) { Actor child = view.GetChildAt( i ); Actor newActor = Actor::New(); - newActor.SetName("Inserted"); + newActor.SetProperty( Dali::Actor::Property::NAME,"Inserted"); insertList.push_back( Item( view.GetItemId(child), newActor ) ); } @@ -639,13 +790,17 @@ int UtcDaliItemViewInsertItemsP(void) DALI_TEST_CHECK(view.GetChildCount() == itemCount + 10); + // Check that new items are inserted in the correct positions + DALI_TEST_CHECK(view.GetItemId(itemActor) == 11); + DALI_TEST_CHECK(view.GetItem(11) == itemActor); + ItemIdContainer removeList; for( unsigned int i = 0u; i < view.GetChildCount(); ++i ) { Actor child = view.GetChildAt( i ); - if( child.GetName() == "Inserted" ) + if( child.GetProperty< std::string >( Dali::Actor::Property::NAME ) == "Inserted" ) { removeList.push_back( view.GetItemId(child) ); } @@ -657,6 +812,11 @@ int UtcDaliItemViewInsertItemsP(void) } DALI_TEST_CHECK(view.GetChildCount() == itemCount); + + // Check that new items are removed correctly so that we are getting the correct Item ID given the specified item + DALI_TEST_CHECK(view.GetItemId(itemActor) == 1); + DALI_TEST_CHECK(view.GetItem(1) == itemActor); + END_TEST; } @@ -668,19 +828,20 @@ 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()); + Vector3 stageSize(application.GetScene().GetSize()); view.ActivateLayout(0, stageSize, 0.5f); Actor newActor = Actor::New(); - view.ReplaceItem( Item( 0, newActor ), 0.5f ); + view.ReplaceItem( Item( 5, newActor ), 0.5f ); + + DALI_TEST_CHECK(view.GetItem(5) == newActor); - DALI_TEST_CHECK(view.GetItem(0) == newActor); END_TEST; } @@ -692,12 +853,13 @@ 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()); + Vector3 stageSize(application.GetScene().GetSize()); view.ActivateLayout(0, stageSize, 0.5f); ItemContainer replaceList; @@ -706,7 +868,7 @@ int UtcDaliItemViewReplaceItemsP(void) { Actor child = view.GetItem( i ); Actor newActor = Actor::New(); - newActor.SetName("Replaced"); + newActor.SetProperty( Dali::Actor::Property::NAME,"Replaced"); replaceList.push_back( Item( i, newActor ) ); } @@ -716,8 +878,8 @@ int UtcDaliItemViewReplaceItemsP(void) view.ReplaceItems( replaceList, 0.5f ); } - DALI_TEST_CHECK(view.GetItem(0).GetName() == "Replaced"); - DALI_TEST_CHECK(view.GetItem(8).GetName() == "Replaced"); + DALI_TEST_CHECK(view.GetItem(0).GetProperty< std::string >( Dali::Actor::Property::NAME ) == "Replaced"); + DALI_TEST_CHECK(view.GetItem(8).GetProperty< std::string >( Dali::Actor::Property::NAME ) == "Replaced"); END_TEST; } @@ -729,12 +891,13 @@ 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()); + Vector3 stageSize(application.GetScene().GetSize()); view.ActivateLayout(0, stageSize, 0.5f); ItemRange itemRange(0, 0); @@ -753,12 +916,13 @@ 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()); + Vector3 stageSize(application.GetScene().GetSize()); view.ActivateLayout(0, stageSize, 0.5f); Vector3 anchorPoint(10.0f, 10.0f, 0.0f); @@ -766,7 +930,7 @@ int UtcDaliItemViewSetItemsAnchorPointP(void) view.SetItemsAnchorPoint(anchorPoint); DALI_TEST_CHECK(view.GetItemsAnchorPoint() == anchorPoint); - DALI_TEST_CHECK(view.GetItem(0).GetCurrentAnchorPoint() == anchorPoint); + DALI_TEST_CHECK(view.GetItem(0).GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ) == anchorPoint); END_TEST; } @@ -783,7 +947,7 @@ int UtcDaliItemViewSetItemsParentOriginP(void) view.AddLayout(*gridLayout); // Activate the grid layout so that the items will be created and added to ItemView - Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); + Vector3 stageSize(application.GetScene().GetSize()); view.ActivateLayout(0, stageSize, 0.5f); Vector3 parentOrigin(10.0f, 10.0f, 0.0f); @@ -791,7 +955,7 @@ int UtcDaliItemViewSetItemsParentOriginP(void) view.SetItemsParentOrigin(parentOrigin); DALI_TEST_CHECK(view.GetItemsParentOrigin() == parentOrigin); - DALI_TEST_CHECK(view.GetItem(0).GetCurrentParentOrigin() == parentOrigin); + DALI_TEST_CHECK(view.GetItem(0).GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ) == parentOrigin); END_TEST; } @@ -815,7 +979,7 @@ int UtcDaliItemViewLayoutActivatedSignalP(void) ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); view.AddLayout(*gridLayout); - Stage::GetCurrent().Add( view ); + application.GetScene().Add( view ); // Connect the layout activated signal view.LayoutActivatedSignal().Connect( &OnLayoutActivated ); @@ -827,7 +991,7 @@ int UtcDaliItemViewLayoutActivatedSignalP(void) application.Render(); // Activate the grid layout so that the items will be created and added to ItemView - Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); + Vector3 stageSize(application.GetScene().GetSize()); view.ActivateLayout(0, stageSize, 0.1f); // Wait for 0.1 second @@ -879,12 +1043,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") == ItemView::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( ItemView::Property::LAYOUT, layoutArray); + + Property::Array getLayoutArray; + DALI_TEST_CHECK( view.GetProperty( ItemView::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( ItemView::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 @@ -926,3 +1161,209 @@ int UtcDaliItemViewSetGetProperty(void) END_TEST; } + +int UtcDaliItemViewOvershootVertical(void) +{ + ToolkitTestApplication application; + Dali::Integration::Scene stage = application.GetScene(); + + // 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); + + view.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, true ); + DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get(), true, TEST_LOCATION ); + + view.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, Vector2(30, 30) ); + + Wait(application); + + // Do a pan starting from 100,100 and moving down + Vector2 pos(100.0f, 100.0f); + + application.ProcessEvent( GenerateSingleTouch(PointState::DOWN, pos, 100 ) ); + application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) ); + + pos.y += 5.0f; + Wait(application, 100); + + for(int i = 0;i<200;i++) + { + application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) ); + pos.y += 5.0f; + Wait(application); + } + + application.ProcessEvent( GenerateSingleTouch(PointState::UP, pos, 100 ) ); + + Wait(application, 100); + + // Do a pan starting from 100,100 and moving up + pos = Vector2(100.0f, 300.0f); + + application.ProcessEvent( GenerateSingleTouch(PointState::DOWN, pos, 100 ) ); + application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) ); + + pos.y -= 5.0f; + Wait(application, 100); + + for(int i = 0;i<200;i++) + { + application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) ); + pos.y -= 5.0f; + Wait(application); + } + + application.ProcessEvent( GenerateSingleTouch(PointState::UP, pos, 100 ) ); + Wait(application, 100); + END_TEST; +} + +int UtcDaliItemViewOvershootHorizontal(void) +{ + ToolkitTestApplication application; + Dali::Integration::Scene stage = application.GetScene(); + + // 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::SPIRAL ); + 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); + + view.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, true ); + DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get(), true, TEST_LOCATION ); + + view.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, Vector2(30, 30) ); + + Wait(application); + + // Do a pan starting from 100,100 and moving left + Vector2 pos(100.0f, 100.0f); + application.ProcessEvent( GenerateSingleTouch(PointState::DOWN, pos, 100 )); + application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 )); + pos.x -= 5.0f; + Wait(application, 100); + + for(int i = 0;i<200;i++) + { + application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) ); + pos.x -= 5.0f; + Wait(application); + } + + application.ProcessEvent( GenerateSingleTouch(PointState::UP, pos, 100 ) ); + Wait(application, 100); + + // Do a pan starting from 100,100 and moving right + pos = Vector2(100.0f, 100.0f); + application.ProcessEvent( GenerateSingleTouch(PointState::DOWN, pos, 100 ) ); + application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) ); + pos.x += 5.0f; + Wait(application, 100); + + for(int i = 0;i<200;i++) + { + application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) ); + pos.x += 5.0f; + Wait(application); + } + + application.ProcessEvent( GenerateSingleTouch(PointState::UP, pos, 100 ) ); + Wait(application, 100); + + END_TEST; +} + +int UtcDaliItemEnableDisableRefresh(void) +{ + ToolkitTestApplication application; + Dali::Integration::Scene stage = application.GetScene(); + + // 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; +} + +int UtcDaliItemViewWheelEvent(void) +{ + ToolkitTestApplication application; + Dali::Integration::Scene stage = application.GetScene(); + + // 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 wheel event signal + view.WheelEventSignal().Connect( &OnWheelEvent ); + + DALI_TEST_CHECK( !gOnWheelEventCalled ); + + // Render and notify + application.Render(); + application.SendNotification(); + application.Render(); + application.SendNotification(); + + // Perform a wheel event + Dali::Integration::WheelEvent wheelEvent( Dali::Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, Vector2( 10.0f, 10.0f ), 1, 1000u ); + application.ProcessEvent( wheelEvent ); + DALI_TEST_CHECK( gOnWheelEventCalled ); + + END_TEST; +}