2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
20 // Need to override adaptor classes for toolkit test harness, so include
21 // test harness headers before dali headers.
22 #include <dali-toolkit-test-suite-utils.h>
25 #include <dali-toolkit/dali-toolkit.h>
28 using namespace Toolkit;
32 const unsigned int TOTAL_ITEM_NUMBER = 200;
33 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
36 // Implementation of ItemFactory for providing actors to ItemView
37 class TestItemFactory : public ItemFactory
43 * @param application class, stored as reference
49 public: // From ItemFactory
52 * Query the number of items available from the factory.
53 * The maximum available item has an ID of GetNumberOfItems() - 1.
55 virtual unsigned int GetNumberOfItems()
57 return TOTAL_ITEM_NUMBER;
61 * Create an Actor to represent a visible item.
63 * @return the created actor.
65 virtual Actor NewItem(unsigned int itemId)
67 // Create an image actor for this item
68 Image image = Image::New( TEST_IMAGE_FILE_NAME );
69 Actor actor = ImageActor::New(image);
76 int UtcDaliItemLayoutSetAndGetOrientation(void)
78 ToolkitTestApplication application;
80 // Create the ItemView actor
81 TestItemFactory factory;
82 ItemView view = ItemView::New(factory);
84 // Create a grid layout and add it to ItemView
85 GridLayoutPtr gridLayout = GridLayout::New();
86 view.AddLayout(*gridLayout);
88 // Set the orientation of the layout to be horizontal from left to right
89 ItemLayoutPtr layout = view.GetLayout(0);
90 layout->SetOrientation(ControlOrientation::Left);
92 // Check the orientation of the layout is horizontal from left to right
93 DALI_TEST_CHECK(layout->GetOrientation() == ControlOrientation::Left);
97 int UtcDaliItemLayoutGetScrollHints(void)
99 ToolkitTestApplication application;
101 // Create the ItemView actor
102 TestItemFactory factory;
103 ItemView view = ItemView::New(factory);
105 // Create a grid layout and add it to ItemView
106 GridLayoutPtr gridLayout = GridLayout::New();
107 view.AddLayout(*gridLayout);
109 // Set the orientation of the layout to be horizontal from left to right
110 ItemLayoutPtr layout = view.GetLayout(0);
112 Vector2 axisScrollHint;
114 layout->SetOrientation(ControlOrientation::Up);
115 layout->GetXAxisScrollHint(axisScrollHint);
116 DALI_TEST_EQUALS(axisScrollHint, Vector2::ZERO, Math::MACHINE_EPSILON_1, TEST_LOCATION);
117 layout->GetYAxisScrollHint(axisScrollHint);
118 DALI_TEST_EQUALS(axisScrollHint, Vector2::YAXIS, Math::MACHINE_EPSILON_1, TEST_LOCATION);
120 layout->SetOrientation(ControlOrientation::Down);
121 layout->GetXAxisScrollHint(axisScrollHint);
122 DALI_TEST_EQUALS(axisScrollHint, Vector2::ZERO, Math::MACHINE_EPSILON_1, TEST_LOCATION);
123 layout->GetYAxisScrollHint(axisScrollHint);
124 DALI_TEST_EQUALS(axisScrollHint, Vector2::YAXIS, Math::MACHINE_EPSILON_1, TEST_LOCATION);
126 layout->SetOrientation(ControlOrientation::Left);
127 layout->GetXAxisScrollHint(axisScrollHint);
128 DALI_TEST_EQUALS(axisScrollHint, Vector2::XAXIS, Math::MACHINE_EPSILON_1, TEST_LOCATION);
129 layout->GetYAxisScrollHint(axisScrollHint);
130 DALI_TEST_EQUALS(axisScrollHint, Vector2::ZERO, Math::MACHINE_EPSILON_1, TEST_LOCATION);
132 layout->SetOrientation(ControlOrientation::Right);
133 layout->GetXAxisScrollHint(axisScrollHint);
134 DALI_TEST_EQUALS(axisScrollHint, Vector2::XAXIS, Math::MACHINE_EPSILON_1, TEST_LOCATION);
135 layout->GetYAxisScrollHint(axisScrollHint);
136 DALI_TEST_EQUALS(axisScrollHint, Vector2::ZERO, Math::MACHINE_EPSILON_1, TEST_LOCATION);