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=6af032c27980e15d8433c83dc0061d35596268ee;hb=6e79b1b333af799839c8e7b11a077f754132dc24;hpb=c01f2590ed7bb00d9b3600511d08dc420261ed46 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp old mode 100755 new mode 100644 index 6af032c..da5ce83 --- 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) 2019 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. @@ -24,7 +24,7 @@ #include #include #include - +#include using namespace Dali; using namespace Toolkit; @@ -50,6 +50,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 bool gOnWheelEventCalled; ///< Whether the WheelEventSignal signal was invoked. static void TestCallback(BaseHandle handle) { @@ -66,6 +67,12 @@ 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; @@ -135,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 ); } }; @@ -156,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; @@ -169,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; @@ -292,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 @@ -329,7 +402,7 @@ int UtcDaliItemViewDeactivateCurrentLayout(void) 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 @@ -357,7 +430,7 @@ int UtcDaliItemViewGetItemAndGetItemId(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); // Get the item given the item ID @@ -382,7 +455,7 @@ int UtcDaliItemViewRemoveItem(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); // Get the item given the item ID 2 and 3 @@ -437,7 +510,7 @@ int UtcDaliItemViewGetCurrentLayoutPosition(void) 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 @@ -539,9 +612,9 @@ int UtcDaliItemViewScrollToItem(void) view.SetProperty( Dali::Actor::Property::NAME,"view actor"); view.AddLayout(*layout); - view.SetSize(vec); + view.SetProperty( Actor::Property::SIZE, vec ); - Stage::GetCurrent().Add(view); + application.GetScene().Add(view); layout->SetOrientation(ControlOrientation::Down); view.ActivateLayout(0, vec, 0.0f); @@ -598,7 +671,7 @@ int UtcDaliItemViewScrollToItem(void) tet_result(TET_FAIL); } - Stage::GetCurrent().Remove(view); + application.GetScene().Remove(view); END_TEST; } @@ -632,7 +705,7 @@ int UtcDaliItemViewInsertItemP(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.0f); // Get the specified item where new item to be inserted before that @@ -689,7 +762,7 @@ int UtcDaliItemViewInsertItemsP(void) 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(); @@ -760,7 +833,7 @@ int UtcDaliItemViewReplaceItemP(void) 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(); @@ -786,7 +859,7 @@ int UtcDaliItemViewReplaceItemsP(void) 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; @@ -824,7 +897,7 @@ int UtcDaliItemViewGetItemsRangeP(void) 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); @@ -849,7 +922,7 @@ int UtcDaliItemViewSetItemsAnchorPointP(void) 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); @@ -874,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); @@ -906,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 ); @@ -918,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 @@ -1092,7 +1165,7 @@ int UtcDaliItemViewSetGetProperty(void) int UtcDaliItemViewOvershootVertical(void) { ToolkitTestApplication application; - Dali::Stage stage = Dali::Stage::GetCurrent(); + Dali::Integration::Scene stage = application.GetScene(); // Create the ItemView actor TestItemFactory factory; @@ -1158,7 +1231,7 @@ int UtcDaliItemViewOvershootVertical(void) int UtcDaliItemViewOvershootHorizontal(void) { ToolkitTestApplication application; - Dali::Stage stage = Dali::Stage::GetCurrent(); + Dali::Integration::Scene stage = application.GetScene(); // Create the ItemView actor TestItemFactory factory; @@ -1220,7 +1293,7 @@ int UtcDaliItemViewOvershootHorizontal(void) int UtcDaliItemEnableDisableRefresh(void) { ToolkitTestApplication application; - Dali::Stage stage = Dali::Stage::GetCurrent(); + Dali::Integration::Scene stage = application.GetScene(); // Create the ItemView actor TestItemFactory factory; @@ -1257,3 +1330,40 @@ int UtcDaliItemEnableDisableRefresh(void) 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; +}