2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
23 #include <dali-toolkit-test-suite-utils.h>
26 #include <dali-toolkit/dali-toolkit.h>
28 #include <dali-toolkit/internal/controls/scrollable/item-view/grid-layout.h>
31 using namespace Toolkit;
35 const unsigned int TOTAL_ITEM_NUMBER = 200;
36 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
39 // Implementation of ItemFactory for providing actors to ItemView
40 class TestItemFactory : public ItemFactory
46 * @param application class, stored as reference
55 virtual ~TestItemFactory()
59 public: // From ItemFactory
62 * Query the number of items available from the factory.
63 * The maximum available item has an ID of GetNumberOfItems() - 1.
65 virtual unsigned int GetNumberOfItems()
67 return TOTAL_ITEM_NUMBER;
71 * Create an Actor to represent a visible item.
73 * @return the created actor.
75 virtual Actor NewItem(unsigned int itemId)
77 // Create a renderable actor for this item
78 return ImageView::New( TEST_IMAGE_FILE_NAME );
84 int UtcDaliItemLayoutCheckPropertiesSetBeforeActivateLayout(void)
86 ToolkitTestApplication application;
88 TestItemFactory factory;
89 ItemView view = ItemView::New(factory);
91 Property::Map gridLayoutProperty;
92 gridLayoutProperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::GRID) );
94 //Set the column of grid-layout.
95 gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_COLUMN_NUMBER, Dali::Property::Value(6) );
97 Property::Array layoutArray;
99 layoutArray.PushBack(gridLayoutProperty);
101 view.SetProperty( ItemView::Property::LAYOUT, layoutArray );
103 Dali::Toolkit::Internal::GridLayout* gridLayout = dynamic_cast<Dali::Toolkit::Internal::GridLayout*>(view.GetLayout(0).Get());
105 Dali::Integration::Scene scene = application.GetScene();
106 Vector3 stageSize(scene.GetSize());
108 //Check if the number of columns is equals to 6 which is set before.
109 DALI_TEST_EQUALS(gridLayout->GetNumberOfColumns(), 6, TEST_LOCATION );
110 view.ActivateLayout(0, stageSize, 0.0f);