2 * Copyright (c) 2016 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>
27 #include <dali-toolkit/devel-api/controls/scrollable/item-view/default-item-layout-property.h>
29 #include <dali-toolkit/internal/controls/scrollable/item-view/grid-layout.h>
30 #include <dali-toolkit/devel-api/controls/scrollable/item-view/item-view-devel.h>
34 using namespace Toolkit;
38 const unsigned int TOTAL_ITEM_NUMBER = 200;
39 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
42 // Implementation of ItemFactory for providing actors to ItemView
43 class TestItemFactory : public ItemFactory
49 * @param application class, stored as reference
58 virtual ~TestItemFactory()
62 public: // From ItemFactory
65 * Query the number of items available from the factory.
66 * The maximum available item has an ID of GetNumberOfItems() - 1.
68 virtual unsigned int GetNumberOfItems()
70 return TOTAL_ITEM_NUMBER;
74 * Create an Actor to represent a visible item.
76 * @return the created actor.
78 virtual Actor NewItem(unsigned int itemId)
80 // Create a renderable actor for this item
81 Image image = ResourceImage::New( TEST_IMAGE_FILE_NAME );
82 Actor actor = CreateRenderableActor(image);
90 int UtcDaliItemLayoutCheckPropertiesSetBeforeActivateLayout(void)
92 ToolkitTestApplication application;
94 TestItemFactory factory;
95 ItemView view = ItemView::New(factory);
97 Property::Map gridLayoutProperty;
98 gridLayoutProperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::GRID) );
100 //Set the column of grid-layout.
101 gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_COLUMN_NUMBER, Dali::Property::Value(6) );
103 Property::Array layoutArray;
105 layoutArray.PushBack(gridLayoutProperty);
107 view.SetProperty( DevelItemView::Property::LAYOUT, layoutArray);
109 Dali::Toolkit::Internal::GridLayout* gridLayout = dynamic_cast<Dali::Toolkit::Internal::GridLayout*>(view.GetLayout(0).Get());
111 Dali::Stage stage = Dali::Stage::GetCurrent();
112 Vector3 stageSize(stage.GetSize());
114 //Check if the number of columns is equals to 6 which is set before.
115 DALI_TEST_EQUALS(gridLayout->GetNumberOfColumns(), 6, TEST_LOCATION );
116 view.ActivateLayout(0, stageSize, 0.0f);