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=920e152fa29e19e122037483a15a810bcb05d50d;hp=12a07c02e70af39b9c8b119a04056e3656007edb;hb=9781441fa162e32e5796658d4169387a3ffb5d88;hpb=30f6ca1e541089b19f2b349a8a12d8a5bcaf2f9e diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp index 12a07c0..920e152 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp @@ -1,18 +1,19 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * Copyright (c) 2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #include #include @@ -22,7 +23,6 @@ // test harness headers before dali headers. #include -#include #include using namespace Dali; @@ -83,7 +83,7 @@ public: // From ItemFactory virtual Actor NewItem(unsigned int itemId) { // Create an image actor for this item - Image image = Image::New( TEST_IMAGE_FILE_NAME ); + Image image = ResourceImage::New( TEST_IMAGE_FILE_NAME ); Actor actor = ImageActor::New(image); return actor; @@ -143,15 +143,30 @@ int UtcDaliItemViewAddAndGetLayout(void) ItemView view = ItemView::New(factory); // Create a grid layout and add it to ItemView - GridLayoutPtr gridLayout = GridLayout::New(); + ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); view.AddLayout(*gridLayout); // As we have added one layout, check the number of layout is now 1 DALI_TEST_CHECK(view.GetLayoutCount() == 1); + // Create a depth layout and add it to ItemView + ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH ); + view.AddLayout(*depthLayout); + + // As we have added another layout, check the number of layout is now 2 + DALI_TEST_CHECK(view.GetLayoutCount() == 2); + + // Create a spiral layout and add it to ItemView + ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL ); + view.AddLayout(*spiralLayout); + + // As we have added another layout, check the number of layout is now 3 + DALI_TEST_CHECK(view.GetLayoutCount() == 3); // Check we are getting the correct layout from ItemView DALI_TEST_CHECK(view.GetLayout(0) == gridLayout); + DALI_TEST_CHECK(view.GetLayout(1) == depthLayout); + DALI_TEST_CHECK(view.GetLayout(2) == spiralLayout); END_TEST; } @@ -164,21 +179,37 @@ int UtcDaliItemViewAddAndRemoveLayout(void) ItemView view = ItemView::New(factory); // Create a grid layout and add it to ItemView - GridLayoutPtr gridLayout = GridLayout::New(); + ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); view.AddLayout(*gridLayout); // As we have added one layout, check the number of layout is now 1 DALI_TEST_CHECK(view.GetLayoutCount() == 1); + // Create a depth layout and add it to ItemView + ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH ); + view.AddLayout(*depthLayout); + + // As we have added another layout, check the number of layout is now 2 + DALI_TEST_CHECK(view.GetLayoutCount() == 2); + // Check we are getting the correct layout from ItemView DALI_TEST_CHECK(view.GetLayout(0) == gridLayout); + DALI_TEST_CHECK(view.GetLayout(1) == depthLayout); // Remove the grid layout view.RemoveLayout(0); - // As we have removed the grid layout, check the number of layout is now 0 - DALI_TEST_CHECK(view.GetLayoutCount() == 0); + // As we have removed the grid layout, check the number of layout is now 1 + DALI_TEST_CHECK(view.GetLayoutCount() == 1); + + // Check we are getting the correct layout from ItemView + DALI_TEST_CHECK(view.GetLayout(0) == depthLayout); + + // Remove the depth layout + view.RemoveLayout(0); + // As we also removed the depth layout, check the number of layout is now 0 + DALI_TEST_CHECK(view.GetLayoutCount() == 0); END_TEST; } @@ -191,21 +222,41 @@ int UtcDaliItemViewActivateLayoutAndGetActiveLayout(void) ItemView view = ItemView::New(factory); // Create a grid layout and add it to ItemView - GridLayoutPtr gridLayout = GridLayout::New(); + ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); view.AddLayout(*gridLayout); - DALI_TEST_CHECK(view.GetLayoutCount() == 1); + // Create a depth layout and add it to ItemView + ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH ); + view.AddLayout(*depthLayout); + + // Create a spiral layout and add it to ItemView + ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL ); + view.AddLayout(*spiralLayout); + + // As we have added three layouts, check the number of layout is now 3 + DALI_TEST_CHECK(view.GetLayoutCount() == 3); // Check there is no active layout at the moment DALI_TEST_CHECK(view.GetActiveLayout() == NULL); - // Activate the grid layout + // Activate the depth layout Vector3 stageSize(Dali::Stage::GetCurrent().GetSize()); + view.ActivateLayout(1, stageSize, 0.5f); + + // Check the current active layout is the depth layout + DALI_TEST_CHECK(view.GetActiveLayout() == depthLayout); + + // Activate the grid layout view.ActivateLayout(0, stageSize, 0.5f); // Check the current active layout is the grid layout DALI_TEST_CHECK(view.GetActiveLayout() == gridLayout); + // Activate the spiral layout + view.ActivateLayout(2, stageSize, 0.5f); + + // Check the current active layout is the spiral layout + DALI_TEST_CHECK(view.GetActiveLayout() == spiralLayout); END_TEST; } @@ -218,7 +269,7 @@ int UtcDaliItemViewDeactivateCurrentLayout(void) ItemView view = ItemView::New(factory); // Create a grid layout and add it to ItemView - GridLayoutPtr gridLayout = GridLayout::New(); + ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); view.AddLayout(*gridLayout); // Check there is no active layout at the moment @@ -248,7 +299,7 @@ int UtcDaliItemViewGetItemAndGetItemId(void) ItemView view = ItemView::New(factory); // Create a grid layout and add it to ItemView - GridLayoutPtr gridLayout = GridLayout::New(); + ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); view.AddLayout(*gridLayout); // Activate the grid layout so that the items will be created and added to ItemView @@ -272,7 +323,7 @@ int UtcDaliItemViewRemoveItem(void) ItemView view = ItemView::New(factory); // Create a grid layout and add it to ItemView - GridLayoutPtr gridLayout = GridLayout::New(); + ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); view.AddLayout(*gridLayout); // Activate the grid layout so that the items will be created and added to ItemView @@ -305,7 +356,7 @@ int UtcDaliItemViewGetCurrentLayoutPosition(void) ItemView view = ItemView::New(factory); // Create a grid layout and add it to ItemView - GridLayoutPtr gridLayout = GridLayout::New(); + ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); view.AddLayout(*gridLayout); // Activate the grid layout so that the items will be created and added to ItemView @@ -405,7 +456,7 @@ int UtcDaliItemViewScrollToItem(void) TestItemFactory factory; ItemView view = ItemView::New(factory); Vector3 vec(480.0f, 800.0f, 0.0f); - GridLayoutPtr layout = GridLayout::New(); + ItemLayoutPtr layout = DefaultItemLayout::New( DefaultItemLayout::GRID ); view.SetName("view actor"); view.AddLayout(*layout);