2 * Copyright (c) 2018 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.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <toolkit-event-thread-callback.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/control-devel.h>
25 #include <dali-toolkit/devel-api/layouting/absolute-layout.h>
26 #include <dali-toolkit/devel-api/layouting/linear-layout.h>
27 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
28 #include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
30 #include <../custom-layout.h>
32 #include <layout-utils.h>
35 using namespace Toolkit;
37 void utc_dali_toolkit_layouting_startup(void)
39 test_return_value = TET_UNDEF;
42 void utc_dali_toolkit_layouting_cleanup(void)
44 test_return_value = TET_PASS;
47 int UtcDaliLayouting_HboxLayout01(void)
49 ToolkitTestApplication application;
50 tet_infoline(" UtcDaliLayouting_HboxLayout01");
52 Stage stage = Stage::GetCurrent();
53 auto hbox = Control::New();
54 auto hboxLayout = LinearLayout::New();
55 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
56 DevelControl::SetLayout( hbox, hboxLayout );
57 hbox.SetName( "HBox");
59 std::vector< Control > controls;
60 controls.push_back( CreateLeafControl( 40, 40 ) );
61 controls.push_back( CreateLeafControl( 60, 40 ) );
62 controls.push_back( CreateLeafControl( 80, 40 ) );
63 controls.push_back( CreateLeafControl( 100, 40 ) );
65 for( auto&& iter : controls )
69 hbox.SetParentOrigin( ParentOrigin::CENTER );
70 hbox.SetAnchorPoint( AnchorPoint::CENTER );
73 // Ensure layouting happens
74 application.SendNotification();
77 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
78 // hbox left justifies elements
79 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
80 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
81 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
82 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
84 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
85 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
86 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
87 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
90 auto newHBoxLayout = LinearLayout::New();
91 newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
92 DevelControl::SetLayout( hbox, newHBoxLayout );
94 application.SendNotification();
97 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
98 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
99 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
100 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
105 int UtcDaliLayouting_HboxLayout02(void)
107 ToolkitTestApplication application;
108 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
110 Stage stage = Stage::GetCurrent();
112 auto hbox1 = Control::New();
113 auto hboxLayout1 = LinearLayout::New();
114 DevelControl::SetLayout( hbox1, hboxLayout1 );
116 auto hbox2 = Control::New();
117 auto hboxLayout2 = LinearLayout::New();
118 DevelControl::SetLayout( hbox2, hboxLayout2 );
120 hbox1.SetName( "HBox1");
121 hbox2.SetName( "HBox2");
123 std::vector< Control > controls;
124 controls.push_back( CreateLeafControl( 20, 40 ) );
125 controls.push_back( CreateLeafControl( 30, 50 ) );
126 controls.push_back( CreateLeafControl( 40, 60 ) );
127 controls.push_back( CreateLeafControl( 50, 70 ) );
129 controls.push_back( CreateLeafControl( 25, 40 ) );
130 controls.push_back( CreateLeafControl( 35, 50 ) );
131 controls.push_back( CreateLeafControl( 45, 60 ) );
132 controls.push_back( CreateLeafControl( 55, 70 ) );
135 for( auto&& iter : controls )
147 hbox1.SetParentOrigin( ParentOrigin::CENTER );
148 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
149 hbox2.SetParentOrigin( ParentOrigin::CENTER );
150 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
152 auto hbox3 = Control::New();
153 auto hboxLayout3 = LinearLayout::New();
154 DevelControl::SetLayout( hbox3, hboxLayout3 );
156 hbox3.SetParentOrigin( ParentOrigin::CENTER );
157 hbox3.SetName( "HBox3");
163 // Ensure layouting happens
164 application.SendNotification();
165 application.Render();
168 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
169 // hbox left justifies elements
170 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
171 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
172 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
173 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
175 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
176 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
177 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
178 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
181 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
182 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
183 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
184 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
186 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
187 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
188 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
189 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
191 // Test hbox1 and 2 are sized to wrap their content
192 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
193 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
194 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
195 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
197 // Test hbox3 matches parent (root layer)
198 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
199 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
205 int UtcDaliLayouting_HboxLayout03(void)
207 ToolkitTestApplication application;
208 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
210 Stage stage = Stage::GetCurrent();
212 auto hbox1 = Control::New();
213 auto hboxLayout1 = LinearLayout::New();
214 DevelControl::SetLayout( hbox1, hboxLayout1 );
216 auto hbox2 = Control::New();
217 auto hboxLayout2 = LinearLayout::New();
218 DevelControl::SetLayout( hbox2, hboxLayout2 );
220 hbox1.SetName( "HBox1");
221 hbox2.SetName( "HBox2");
222 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
223 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
224 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
225 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
227 std::vector< Control > controls;
228 controls.push_back( CreateLeafControl( 20, 40 ) );
229 controls.push_back( CreateLeafControl( 30, 50 ) );
230 controls.push_back( CreateLeafControl( 40, 60 ) );
231 controls.push_back( CreateLeafControl( 50, 70 ) );
233 controls.push_back( CreateLeafControl( 25, 40 ) );
234 controls.push_back( CreateLeafControl( 35, 50 ) );
235 controls.push_back( CreateLeafControl( 45, 60 ) );
236 controls.push_back( CreateLeafControl( 55, 70 ) );
239 for( auto&& iter : controls )
251 hbox1.SetParentOrigin( ParentOrigin::CENTER );
252 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
253 hbox2.SetParentOrigin( ParentOrigin::CENTER );
254 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
256 auto hbox3 = Control::New();
257 auto hboxLayout3 = LinearLayout::New();
258 DevelControl::SetLayout( hbox3, hboxLayout3);
260 hbox3.SetParentOrigin( ParentOrigin::CENTER );
261 hbox3.SetName( "HBox3");
267 //std::ostringstream oss;
268 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
269 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
271 // Ensure layouting happens
272 application.SendNotification();
273 application.Render();
276 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
277 // hbox left justifies elements
278 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
279 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
280 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
281 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
283 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
284 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
285 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
286 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
288 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
289 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
290 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
291 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
293 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
294 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
295 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
296 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
298 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
299 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
300 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
301 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
303 // Test hbox3 matches parent (root layer)
304 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
305 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
310 int UtcDaliLayouting_HboxLayout04(void)
312 ToolkitTestApplication application;
313 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
315 Stage stage = Stage::GetCurrent();
317 auto hbox1 = Control::New();
318 auto hboxLayout1 = LinearLayout::New();
319 DevelControl::SetLayout( hbox1, hboxLayout1 );
321 auto hbox2 = Control::New();
322 auto hboxLayout2 = LinearLayout::New();
323 DevelControl::SetLayout( hbox2, hboxLayout2 );
325 hbox1.SetName( "HBox1"); // Default spec is to wrap content
326 hbox2.SetName( "HBox2");
327 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
328 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
329 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
330 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
332 std::vector< Control > controls;
333 controls.push_back( CreateLeafControl( 80, 40 ) );
334 controls.push_back( CreateLeafControl( 80, 50 ) );
335 controls.push_back( CreateLeafControl( 80, 60 ) );
336 controls.push_back( CreateLeafControl( 80, 70 ) );
338 controls.push_back( CreateLeafControl( 80, 40 ) );
339 controls.push_back( CreateLeafControl( 80, 50 ) );
340 controls.push_back( CreateLeafControl( 80, 60 ) );
341 controls.push_back( CreateLeafControl( 80, 70 ) );
344 for( auto&& iter : controls )
357 controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
358 auto hbox3 = Control::New();
359 auto hboxLayout3 = LinearLayout::New();
360 DevelControl::SetLayout( hbox3, hboxLayout3 );
362 hbox3.SetParentOrigin( ParentOrigin::CENTER );
363 hbox3.SetName( "HBox3");
368 //std::ostringstream oss;
369 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
370 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
372 // Ensure layouting happens
373 application.SendNotification();
374 application.Render();
377 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
378 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
379 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
380 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
382 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
383 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
384 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
385 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
387 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
388 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
389 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
390 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
392 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
393 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
394 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
395 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
397 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
398 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
399 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
400 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
403 // Test hbox3 matches parent (root layer)
404 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
405 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
410 int UtcDaliLayouting_HboxLayout05(void)
412 ToolkitTestApplication application;
413 tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
415 Stage stage = Stage::GetCurrent();
416 auto hbox = Control::New();
417 auto hboxLayout = LinearLayout::New();
418 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
419 DevelControl::SetLayout( hbox, hboxLayout );
420 hbox.SetName( "HBox");
422 std::vector< Control > controls;
423 controls.push_back( CreateLeafControl( 40, 40 ) );
424 controls.push_back( CreateLeafControl( 60, 40 ) );
425 controls.push_back( CreateLeafControl( 80, 40 ) );
426 controls.push_back( CreateLeafControl( 100, 40 ) );
428 for( auto&& iter : controls )
431 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
432 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
435 hbox.SetParentOrigin( ParentOrigin::CENTER );
436 hbox.SetAnchorPoint( AnchorPoint::CENTER );
439 // Ensure layouting happens
440 application.SendNotification();
441 application.Render();
443 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
444 // hbox left justifies elements
445 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
446 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
447 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
448 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
450 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
451 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
452 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
453 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
458 int UtcDaliLayouting_HboxLayout06(void)
460 ToolkitTestApplication application;
461 tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
463 Stage stage = Stage::GetCurrent();
465 auto rootControl = Control::New();
466 auto absoluteLayout = AbsoluteLayout::New();
467 DevelControl::SetLayout( rootControl, absoluteLayout );
468 rootControl.SetName( "AbsoluteLayout" );
469 stage.Add( rootControl );
471 auto hbox = Control::New();
472 auto hboxLayout = LinearLayout::New();
473 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
474 DevelControl::SetLayout( hbox, hboxLayout );
475 hbox.SetName( "HBox" );
477 std::vector< Control > controls;
478 controls.push_back( CreateLeafControl( 40, 40 ) );
479 controls.push_back( CreateLeafControl( 60, 40 ) );
481 for( auto&& iter : controls )
485 hbox.SetParentOrigin( ParentOrigin::CENTER );
486 hbox.SetAnchorPoint( AnchorPoint::CENTER );
487 rootControl.Add( hbox );
489 // Ensure layouting happens
490 application.SendNotification();
491 application.Render();
493 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
494 // hbox left justifies elements
495 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
496 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
498 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
499 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
501 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
504 auto newHBoxLayout = LinearLayout::New();
505 newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
506 DevelControl::SetLayout( hbox, newHBoxLayout );
508 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
509 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
511 application.SendNotification();
512 application.Render();
514 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
516 // Change size specification
517 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
518 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
520 application.SendNotification();
521 application.Render();
523 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
525 // Use WRAP_CONTENT again
526 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
527 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
529 application.SendNotification();
530 application.Render();
532 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
537 int UtcDaliLayouting_HboxLayout07(void)
539 ToolkitTestApplication application;
540 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
542 Stage stage = Stage::GetCurrent();
543 auto hbox = Control::New();
544 auto hboxLayout = LinearLayout::New();
545 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
546 DevelControl::SetLayout( hbox, hboxLayout );
547 hbox.SetName( "HBox");
549 std::vector< Control > controls;
550 controls.push_back( CreateLeafControl( 40, 40 ) );
551 controls.push_back( CreateLeafControl( 60, 40 ) );
552 controls.push_back( CreateLeafControl( 80, 40 ) );
553 controls.push_back( CreateLeafControl( 100, 40 ) );
555 for( auto&& iter : controls )
559 hbox.SetParentOrigin( ParentOrigin::CENTER );
560 hbox.SetAnchorPoint( AnchorPoint::CENTER );
563 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
565 // Ensure layouting happens
566 application.SendNotification();
567 application.Render();
569 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
570 // hbox left justifies elements
571 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
572 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
573 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
574 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
576 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
577 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
578 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
579 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
581 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
583 // Ensure layouting happens
584 application.SendNotification();
585 application.Render();
587 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
588 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
589 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
590 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
592 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
593 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
594 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
595 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
600 int UtcDaliLayouting_HboxLayout08(void)
602 ToolkitTestApplication application;
603 tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation");
605 Stage stage = Stage::GetCurrent();
607 auto rootControl = Control::New();
608 auto absoluteLayout = AbsoluteLayout::New();
609 absoluteLayout.SetAnimateLayout( true );
610 DevelControl::SetLayout( rootControl, absoluteLayout );
611 rootControl.SetName( "AbsoluteLayout" );
612 stage.Add( rootControl );
614 Control control1 = CreateLeafControl( 40, 40 );
615 rootControl.Add( control1 );
616 auto hbox = Control::New();
617 auto hboxLayout = LinearLayout::New();
618 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
619 DevelControl::SetLayout( hbox, hboxLayout );
620 hbox.SetName( "HBox" );
622 Control control2 = CreateLeafControl( 40, 40 );
623 hbox.Add( control2 );
625 hbox.SetParentOrigin( ParentOrigin::CENTER );
626 hbox.SetAnchorPoint( AnchorPoint::CENTER );
627 rootControl.Add( hbox );
629 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION );
630 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION );
631 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION );
632 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION );
634 hboxLayout.SetAnimateLayout( true );
635 absoluteLayout.SetAnimateLayout( false );
637 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION );
638 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION );
639 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION );
640 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION );
647 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/broken.png";
650 int UtcDaliLayouting_HboxLayout_ImageView(void)
652 ToolkitTestApplication application;
653 tet_infoline(" UtcDaliLayouting_HboxLayout - Use image view for leaf");
655 Stage stage = Stage::GetCurrent();
656 auto hbox = Control::New();
657 auto hboxLayout = LinearLayout::New();
658 DevelControl::SetLayout( hbox, hboxLayout );
659 hbox.SetName( "HBox" );
661 std::string url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 100, 100 ) );
662 ImageView imageView = CreateImageView( url, ImageDimensions() );
664 hbox.SetParentOrigin( ParentOrigin::CENTER );
665 hbox.SetAnchorPoint( AnchorPoint::CENTER );
666 hbox.Add( imageView );
669 // Ensure layouting happens
670 application.SendNotification();
671 application.Render();
673 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
674 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
676 url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 200, 200 ) );
677 imageView.SetImage( url );
679 // Ensure layouting happenss
680 application.SendNotification();
681 application.Render();
683 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
684 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
686 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
687 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
689 // Ensure layouting happenss
690 application.SendNotification();
691 application.Render();
693 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
694 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
696 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
697 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
699 // Ensure layouting happenss
700 application.SendNotification();
701 application.Render();
703 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
704 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
706 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
707 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
709 Image image = FrameBufferImage::New( 50, 50, Pixel::RGBA8888 );
710 imageView.SetImage( image );
712 // Ensure layouting happenss
713 application.SendNotification();
714 application.Render();
716 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
717 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
719 Property::Map imagePropertyMap;
720 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
721 imagePropertyMap[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
722 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 150;
723 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 150;
724 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap );
726 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
727 // Ensure layouting happenss
728 application.SendNotification();
729 application.Render();
731 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 325.0f, 0.0f ), 0.0001f, TEST_LOCATION );
732 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
737 int UtcDaliLayouting_HboxLayout_TextLabel(void)
739 ToolkitTestApplication application;
740 tet_infoline(" UtcDaliLayouting_HboxLayout - Use text label for leaf");
742 Stage stage = Stage::GetCurrent();
744 auto hbox = Control::New();
745 auto hboxLayout = LinearLayout::New();
746 DevelControl::SetLayout( hbox, hboxLayout );
747 hbox.SetName( "HBox" );
748 hbox.SetParentOrigin( ParentOrigin::CENTER );
749 hbox.SetAnchorPoint( AnchorPoint::CENTER );
751 std::vector< Control > controls;
752 TextLabel textLabel = CreateTextLabel( "W" );
753 controls.push_back( textLabel );
754 hbox.Add( textLabel );
757 // Ensure layouting happens
758 application.SendNotification();
759 application.Render();
761 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
762 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 54.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
764 textLabel.SetProperty( TextLabel::Property::TEXT, "WWWW" );
766 // Ensure layouting happens
767 application.SendNotification();
768 application.Render();
770 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
771 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 216.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
773 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
775 // Ensure layouting happens
776 application.SendNotification();
777 application.Render();
779 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
780 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
782 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
783 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
785 // Ensure layouting happens
786 application.SendNotification();
787 application.Render();
789 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
790 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
792 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
793 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
795 // Ensure layouting happens
796 application.SendNotification();
797 application.Render();
799 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
800 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
807 int UtcDaliLayouting_HboxLayout_Padding01(void)
809 ToolkitTestApplication application;
810 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
812 Stage stage = Stage::GetCurrent();
813 auto hbox = Control::New();
814 auto hboxLayout = LinearLayout::New();
815 DevelControl::SetLayout( hbox, hboxLayout );
816 hbox.SetName( "HBox");
818 std::vector< Control > controls;
819 controls.push_back( CreateLeafControl( 40, 40 ) );
820 controls.push_back( CreateLeafControl( 60, 40 ) );
821 controls.push_back( CreateLeafControl( 80, 40 ) );
822 controls.push_back( CreateLeafControl( 100, 40 ) );
824 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
825 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
826 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
828 for( auto&& iter : controls )
832 hbox.SetParentOrigin( ParentOrigin::CENTER );
833 hbox.SetAnchorPoint( AnchorPoint::CENTER );
836 // Ensure layouting happens
837 application.SendNotification();
838 application.Render();
840 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
841 // hbox left justifies elements
842 tet_infoline("Test Child Actor Position");
843 float xPositionOfControlBeingTested = 0.0f;
844 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
846 0.0f ), 0.0001f, TEST_LOCATION );
847 xPositionOfControlBeingTested += 40.0f;
849 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
850 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
851 0.0001f, TEST_LOCATION );
853 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
854 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
856 xPositionOfControlBeingTested += 80.0f;
857 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
859 tet_infoline("Test Child Actor Size");
860 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
862 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
863 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
864 0.0001f, TEST_LOCATION );
866 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
867 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
872 int UtcDaliLayouting_HboxLayout_Padding02(void)
874 ToolkitTestApplication application;
875 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
877 Stage stage = Stage::GetCurrent();
878 auto hbox = Control::New();
879 auto hboxLayout = LinearLayout::New();
880 DevelControl::SetLayout( hbox, hboxLayout );
881 hbox.SetName( "HBox");
883 std::vector< Control > controls;
884 controls.push_back( CreateLeafControl( 40, 40 ) );
885 controls.push_back( CreateLeafControl( 60, 40 ) );
886 controls.push_back( CreateLeafControl( 80, 40 ) );
887 controls.push_back( CreateLeafControl( 100, 40 ) );
889 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
891 for( auto&& iter : controls )
893 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
896 hbox.SetParentOrigin( ParentOrigin::CENTER );
897 hbox.SetAnchorPoint( AnchorPoint::CENTER );
900 // Ensure layouting happens
901 application.SendNotification();
902 application.Render();
904 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
905 // hbox left justifies elements
906 tet_infoline("Test Child Actor Position");
907 float xPositionOfControlBeingTested = 0.0f;
908 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
910 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
911 yPositionOfControlBeingTested,
912 0.0f ), 0.0001f, TEST_LOCATION );
913 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
915 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
916 yPositionOfControlBeingTested,
918 0.0001f, TEST_LOCATION );
920 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
921 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
922 yPositionOfControlBeingTested,
923 0.0f ), 0.0001f, TEST_LOCATION );
925 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
926 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
927 yPositionOfControlBeingTested,
928 0.0f ), 0.0001f, TEST_LOCATION );
930 tet_infoline("Test Child Actor Size");
931 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
932 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
933 0.0f ), 0.0001f, TEST_LOCATION );
935 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
936 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
937 0.0f ), 0.0001f, TEST_LOCATION );
939 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
940 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
941 0.0f ), 0.0001f, TEST_LOCATION );
943 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
944 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
945 0.0f ), 0.0001f, TEST_LOCATION );
951 int UtcDaliLayouting_HboxLayout_Padding03(void)
953 ToolkitTestApplication application;
954 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
956 Stage stage = Stage::GetCurrent();
957 auto hbox = Control::New();
958 auto hboxLayout = LinearLayout::New();
959 DevelControl::SetLayout( hbox, hboxLayout );
960 hbox.SetName( "HBox");
962 std::vector< Control > controls;
963 controls.push_back( CreateLeafControl( 40, 40 ) );
964 controls.push_back( CreateLeafControl( 40, 40 ) );
965 controls.push_back( CreateLeafControl( 40, 40 ) );
967 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
968 tet_printf( "\nAdding Padding to control at index 1 \n" );
969 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
971 for( auto&& iter : controls )
975 hbox.SetParentOrigin( ParentOrigin::CENTER );
976 hbox.SetAnchorPoint( AnchorPoint::CENTER );
979 // Ensure layouting happens
980 application.SendNotification();
981 application.Render();
983 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
984 // hbox left justifies elements
985 tet_infoline("Test Child Actor Position");
986 float xPositionOfControlBeingTested = 0.0f;
987 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
989 0.0f ), 0.0001f, TEST_LOCATION );
990 xPositionOfControlBeingTested += 40.0f;
992 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
993 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
994 0.0001f, TEST_LOCATION );
996 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
997 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
999 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
1000 tet_printf( "\nChanging Padding to control at index 1 \n" );
1001 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
1003 // Ensure layouting happens
1004 application.SendNotification();
1005 application.Render();
1007 xPositionOfControlBeingTested = 0.0f; // reset
1009 tet_infoline("Test Child Actor Position");
1010 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1012 0.0f ), 0.0001f, TEST_LOCATION );
1013 xPositionOfControlBeingTested += 40.0f;
1015 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1016 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1017 0.0001f, TEST_LOCATION );
1019 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
1020 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
1021 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1023 tet_infoline("Test Child Actor Size");
1024 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1026 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
1027 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
1028 0.0001f, TEST_LOCATION );
1030 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1035 int UtcDaliLayouting_HboxLayout_Padding04(void)
1037 ToolkitTestApplication application;
1038 tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
1040 // Adding padding to the layout should offset the positioning of the children.
1042 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1043 const Size CONTROL_SIZE = Size( 40, 40 );
1045 Stage stage = Stage::GetCurrent();
1046 // Create a root layout, ideally Dali would have a default layout in the root layer.
1047 // Without this root layer the LinearLayout (or any other layout) will not
1048 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1049 // It uses the default stage size and ideally should have a layout added to it.
1050 auto rootLayoutControl = Control::New();
1051 rootLayoutControl.SetName( "AbsoluteLayout");
1052 auto rootLayout = AbsoluteLayout::New();
1053 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1054 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1055 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1056 stage.Add( rootLayoutControl );
1058 auto hbox = Control::New();
1059 auto hboxLayout = LinearLayout::New();
1060 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1061 DevelControl::SetLayout( hbox, hboxLayout );
1062 hbox.SetName( "HBox");
1063 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1064 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1065 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1067 std::vector< Control > controls;
1068 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1069 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1070 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1071 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1073 for( auto&& iter : controls )
1078 hbox.SetParentOrigin( ParentOrigin::CENTER );
1079 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1080 rootLayoutControl.Add( hbox );
1082 // Ensure layouting happens
1083 application.SendNotification();
1084 application.Render();
1086 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1087 application.SendNotification();
1089 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1090 // hbox left justifies elements
1091 tet_infoline("Test Child Actor Position");
1093 auto controlXPosition=0.0f;
1095 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1096 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1098 0.0f ), 0.0001f, TEST_LOCATION );
1100 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1101 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1104 0.0001f, TEST_LOCATION );
1106 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1107 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1109 0.0f ), 0.0001f, TEST_LOCATION );
1111 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1112 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1114 0.0f ), 0.0001f, TEST_LOCATION );
1116 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1117 auto totalControlsHeight = CONTROL_SIZE.height;
1119 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1120 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1121 0.0f ), 0.0001f, TEST_LOCATION );
1127 int UtcDaliLayouting_HboxLayout_Padding05(void)
1129 ToolkitTestApplication application;
1130 tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
1132 // Adding padding to the layout should offset the positioning of the children.
1134 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1135 const Size CONTROL_SIZE = Size( 40, 40 );
1137 Stage stage = Stage::GetCurrent();
1138 // Create a root layout, ideally Dali would have a default layout in the root layer.
1139 // Without this root layer the LinearLayout (or any other layout) will not
1140 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1141 // It uses the default stage size and ideally should have a layout added to it.
1142 auto rootLayoutControl = Control::New();
1143 rootLayoutControl.SetName( "AbsoluteLayout");
1144 auto rootLayout = AbsoluteLayout::New();
1145 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1146 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1147 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1148 stage.Add( rootLayoutControl );
1150 auto hbox = Control::New();
1151 auto hboxLayout = LinearLayout::New();
1152 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1153 DevelControl::SetLayout( hbox, hboxLayout );
1154 hbox.SetName( "HBox");
1155 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1156 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1157 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1159 std::vector< Control > controls;
1160 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1161 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1162 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1163 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1165 for( auto&& iter : controls )
1170 hbox.SetParentOrigin( ParentOrigin::CENTER );
1171 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1172 rootLayoutControl.Add( hbox );
1174 // Ensure layouting happens
1175 application.SendNotification();
1176 application.Render();
1178 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1179 application.SendNotification();
1181 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1182 // hbox left justifies elements
1183 tet_infoline("Test Child Actor Position");
1185 auto controlXPosition=0.0f;
1187 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1188 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1190 0.0f ), 0.0001f, TEST_LOCATION );
1192 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1193 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1196 0.0001f, TEST_LOCATION );
1198 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1199 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1201 0.0f ), 0.0001f, TEST_LOCATION );
1203 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1204 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1206 0.0f ), 0.0001f, TEST_LOCATION );
1208 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1209 auto totalControlsHeight = CONTROL_SIZE.height;
1211 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1212 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1213 0.0f ), 0.0001f, TEST_LOCATION );
1215 // Change layout padding
1216 const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
1217 tet_printf( "\nChanging Padding to control at index 1 \n" );
1218 hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
1220 // Ensure layouting happens
1221 application.SendNotification();
1222 application.Render();
1224 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1225 application.SendNotification();
1227 controlXPosition = NEW_LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1228 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
1229 NEW_LAYOUT_PADDING.top,
1230 0.0f ), 0.0001f, TEST_LOCATION );
1232 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1233 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1234 NEW_LAYOUT_PADDING.top,
1236 0.0001f, TEST_LOCATION );
1238 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1239 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1240 NEW_LAYOUT_PADDING.top,
1241 0.0f ), 0.0001f, TEST_LOCATION );
1243 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1244 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1245 NEW_LAYOUT_PADDING.top,
1246 0.0f ), 0.0001f, TEST_LOCATION );
1247 totalControlsWidth = CONTROL_SIZE.width * controls.size();
1248 totalControlsHeight = CONTROL_SIZE.height;
1250 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
1251 totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
1252 0.0f ), 0.0001f, TEST_LOCATION );
1258 int UtcDaliLayouting_HboxLayout_Margin01(void)
1260 ToolkitTestApplication application;
1261 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
1263 Stage stage = Stage::GetCurrent();
1264 auto hbox = Control::New();
1265 auto hboxLayout = LinearLayout::New();
1266 DevelControl::SetLayout( hbox, hboxLayout );
1267 hbox.SetName( "HBox");
1269 std::vector< Control > controls;
1270 controls.push_back( CreateLeafControl( 40, 40 ) );
1271 controls.push_back( CreateLeafControl( 60, 40 ) );
1272 controls.push_back( CreateLeafControl( 80, 40 ) );
1273 controls.push_back( CreateLeafControl( 100, 40 ) );
1275 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
1276 tet_printf( "\nAdding Margin to control at index 1 \n" );
1277 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1279 for( auto&& iter : controls )
1283 hbox.SetParentOrigin( ParentOrigin::CENTER );
1284 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1287 // Ensure layouting happens
1288 application.SendNotification();
1289 application.Render();
1291 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1292 // hbox left justifies elements
1293 tet_infoline("Test Child Actor Position");
1294 auto xPositionOfControlBeingTested = 0.0f;
1295 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1297 0.0f ), 0.0001f, TEST_LOCATION );
1298 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
1300 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1301 380.0f + CONTROL_MARGIN.top, 0.0f ),
1302 0.0001f, TEST_LOCATION );
1304 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
1305 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1307 xPositionOfControlBeingTested += 80.0f;
1308 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1310 tet_infoline("Test Child Actor Size is the same after Margin added");
1311 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1312 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
1313 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1314 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1320 int UtcDaliLayouting_VboxLayout01(void)
1322 ToolkitTestApplication application;
1323 tet_infoline(" UtcDaliLayouting_VboxLayout01");
1325 Stage stage = Stage::GetCurrent();
1326 auto vbox = Control::New();
1327 auto vboxLayout = LinearLayout::New();
1328 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1329 DevelControl::SetLayout( vbox, vboxLayout );
1330 vbox.SetName( "Vbox");
1332 std::vector< Control > controls;
1333 controls.push_back( CreateLeafControl( 40, 40 ) );
1334 controls.push_back( CreateLeafControl( 60, 60 ) );
1335 controls.push_back( CreateLeafControl( 80, 80 ) );
1336 controls.push_back( CreateLeafControl( 100, 100 ) );
1338 for( auto&& iter : controls )
1342 vbox.SetParentOrigin( ParentOrigin::CENTER );
1343 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1346 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1349 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1351 // Ensure layouting happens
1352 application.SendNotification();
1353 application.Render();
1355 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
1356 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1357 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1358 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1359 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1361 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1362 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1363 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1364 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1369 int UtcDaliLayouting_VboxLayout02(void)
1371 ToolkitTestApplication application;
1372 tet_infoline(" UtcDaliLayouting_VboxLayout01");
1374 Stage stage = Stage::GetCurrent();
1376 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1377 // LayoutGroup for this to happen automatically.
1379 // For this test, add an hbox instead
1380 auto rootControl = Control::New();
1381 auto absoluteLayout = AbsoluteLayout::New();
1382 DevelControl::SetLayout( rootControl, absoluteLayout );
1383 rootControl.SetName( "AbsoluteLayout");
1384 stage.Add( rootControl );
1386 auto vbox = Control::New();
1387 auto vboxLayout = LinearLayout::New();
1388 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1389 DevelControl::SetLayout( vbox, vboxLayout );
1390 vbox.SetName( "Vbox");
1391 rootControl.Add( vbox );
1393 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1394 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1396 std::vector< Control > controls;
1397 controls.push_back( CreateLeafControl( 40, 40 ) );
1398 controls.push_back( CreateLeafControl( 60, 60 ) );
1399 controls.push_back( CreateLeafControl( 80, 80 ) );
1400 controls.push_back( CreateLeafControl( 100, 100 ) );
1402 for( auto&& iter : controls )
1406 vbox.SetParentOrigin( ParentOrigin::CENTER );
1407 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1409 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1412 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1414 // Ensure layouting happens
1415 application.SendNotification();
1416 application.Render();
1418 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1419 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1421 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1422 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1423 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1425 // 3rd control is set to match parent - this should also be 100 wide
1426 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1427 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1428 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1429 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1431 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1432 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1433 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1434 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1440 int UtcDaliLayouting_VboxLayout03(void)
1442 ToolkitTestApplication application;
1443 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
1445 Stage stage = Stage::GetCurrent();
1447 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1448 // LayoutGroup for this to happen automatically.
1450 // For this test, add an hbox instead
1451 auto hbox = Control::New();
1452 auto hboxLayout = LinearLayout::New();
1453 DevelControl::SetLayout( hbox, hboxLayout );
1454 hbox.SetName( "Hbox");
1457 auto vbox = Control::New();
1458 auto vboxLayout = LinearLayout::New();
1459 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
1460 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1462 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
1464 DevelControl::SetLayout( vbox, vboxLayout );
1465 vbox.SetName( "Vbox");
1468 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1469 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1471 std::vector< Control > controls;
1472 controls.push_back( CreateLeafControl( 40, 40 ) );
1473 controls.push_back( CreateLeafControl( 60, 60 ) );
1474 controls.push_back( CreateLeafControl( 80, 80 ) );
1475 controls.push_back( CreateLeafControl( 100, 100 ) );
1477 for( auto&& iter : controls )
1481 vbox.SetParentOrigin( ParentOrigin::CENTER );
1482 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1484 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1487 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1489 // Ensure layouting happens
1490 application.SendNotification();
1491 application.Render();
1493 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1494 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1496 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1497 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1498 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1500 // 3rd control is set to match parent - this should also be 100 wide
1501 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1502 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1503 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1504 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1506 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1507 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1508 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1509 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1516 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
1518 ToolkitTestApplication application;
1519 tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
1520 tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
1522 Stage stage = Stage::GetCurrent();
1524 auto hbox = Control::New();
1525 auto hboxLayout = Test::CustomLayout::New();
1526 DevelControl::SetLayout( hbox, hboxLayout );
1527 hbox.SetName( "HBox");
1529 std::vector< Control > controls;
1530 controls.push_back( CreateLeafControl( 40, 40 ) );
1531 controls.push_back( CreateLeafControl( 60, 40 ) );
1532 controls.push_back( CreateLeafControl( 80, 40 ) );
1533 controls.push_back( CreateLeafControl( 100, 40 ) );
1535 for( auto&& iter : controls )
1539 hbox.SetParentOrigin( ParentOrigin::CENTER );
1540 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1543 // Ensure layouting happens
1544 application.SendNotification();
1545 application.Render();
1547 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1548 // hbox left justifies elements
1549 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1550 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1551 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1552 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1554 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1555 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1556 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1557 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1559 controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
1560 controls[2].Lower(); // 2->1; 2, 1, 3, 0
1562 application.SendNotification();
1563 application.Render();
1565 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1566 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1567 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1568 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1570 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1571 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1572 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1573 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1578 int UtcDaliLayouting_HboxLayout_TargetSize(void)
1580 ToolkitTestApplication application;
1581 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
1583 Stage stage = Stage::GetCurrent();
1584 auto hbox = Control::New();
1585 auto hboxLayout = LinearLayout::New();
1586 DevelControl::SetLayout( hbox, hboxLayout );
1587 hbox.SetName( "HBox");
1589 std::vector< Control > controls;
1590 controls.push_back( CreateLeafControl( 40, 40 ) );
1591 for( auto&& iter : controls )
1593 iter.SetSize( 100, 100 );
1596 hbox.SetParentOrigin( ParentOrigin::CENTER );
1597 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1600 // Ensure layouting happens
1601 application.SendNotification();
1602 application.Render();
1604 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
1605 // hbox left justifies elements
1606 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1607 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1612 int UtcDaliLayouting_RemoveLayout01(void)
1614 ToolkitTestApplication application;
1615 tet_infoline(" UtcDaliLayouting_RemoveLayout");
1617 Stage stage = Stage::GetCurrent();
1619 auto rootControl = Control::New();
1620 auto absoluteLayout = AbsoluteLayout::New();
1621 DevelControl::SetLayout( rootControl, absoluteLayout );
1622 rootControl.SetName( "AbsoluteLayout" );
1623 stage.Add( rootControl );
1625 auto hbox = Control::New();
1626 auto hboxLayout = LinearLayout::New();
1627 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1628 DevelControl::SetLayout( hbox, hboxLayout );
1629 hbox.SetName( "HBox" );
1631 std::vector< Control > controls;
1632 controls.push_back( CreateLeafControl( 40, 40 ) );
1633 controls.push_back( CreateLeafControl( 60, 40 ) );
1635 for( auto&& iter : controls )
1639 hbox.SetParentOrigin( ParentOrigin::CENTER );
1640 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1641 rootControl.Add( hbox );
1643 tet_infoline("Layout as normal");
1644 application.SendNotification();
1645 application.Render();
1647 tet_infoline("Set an empty layout on hbox container");
1648 LinearLayout emptyLayout;
1649 DevelControl::SetLayout( hbox, emptyLayout );
1651 tet_infoline("Run another layout");
1652 application.SendNotification();
1653 application.Render();
1655 tet_infoline("Check leaf controls haven't moved");
1657 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1658 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1660 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1661 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1666 int UtcDaliLayouting_LayoutChildren01(void)
1668 ToolkitTestApplication application;
1669 tet_infoline(" UtcDaliLayouting_LayoutChildren01");
1671 Stage stage = Stage::GetCurrent();
1673 auto rootControl = Control::New();
1674 auto absoluteLayout = AbsoluteLayout::New();
1675 DevelControl::SetLayout( rootControl, absoluteLayout );
1676 stage.Add( rootControl );
1678 auto hbox = Control::New();
1679 auto hboxLayout = LinearLayout::New();
1680 DevelControl::SetLayout( hbox, hboxLayout );
1681 rootControl.Add( hbox );
1683 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1685 tet_infoline("Test removal by setting empty layout to child container" );
1686 DevelControl::SetLayout( hbox, LayoutItem{} );
1688 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
1690 auto& hboxImpl = GetImplementation( hboxLayout );
1692 DALI_TEST_EQUALS( hboxLayout.GetOwner(), empty, TEST_LOCATION );
1693 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
1698 int UtcDaliLayouting_LayoutChildren02(void)
1700 ToolkitTestApplication application;
1701 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
1703 Stage stage = Stage::GetCurrent();
1705 auto rootControl = Control::New();
1706 auto absoluteLayout = AbsoluteLayout::New();
1707 DevelControl::SetLayout( rootControl, absoluteLayout );
1708 stage.Add( rootControl );
1710 auto hbox = Control::New();
1711 auto hboxLayout = LinearLayout::New();
1712 DevelControl::SetLayout( hbox, hboxLayout );
1713 rootControl.Add( hbox );
1715 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1717 tet_infoline("Test removal by removing child actor from parent container" );
1720 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
1722 auto& hboxImpl = GetImplementation( hboxLayout );
1723 tet_infoline("Test child actor still has hbox layout " );
1724 DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
1726 tet_infoline("Test hbox layout has no parent " );
1727 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
1732 int UtcDaliLayouting_LayoutChildren03(void)
1734 ToolkitTestApplication application;
1735 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
1737 Stage stage = Stage::GetCurrent();
1739 auto rootControl = Control::New();
1740 auto absoluteLayout = AbsoluteLayout::New();
1741 DevelControl::SetLayout( rootControl, absoluteLayout );
1742 stage.Add( rootControl );
1744 auto hbox = Control::New();
1745 auto hboxLayout = LinearLayout::New();
1746 DevelControl::SetLayout( hbox, hboxLayout );
1747 rootControl.Add( hbox );
1749 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1751 tet_infoline("Test removal by removing child layout from parent layout" );
1752 absoluteLayout.Remove( hboxLayout );
1754 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
1756 auto& hboxImpl = GetImplementation( hboxLayout );
1758 tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
1759 DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
1760 DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
1762 tet_infoline("Check orphaned layout has no parent");
1763 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
1769 int UtcDaliLayouting_LayoutChildren04(void)
1771 ToolkitTestApplication application;
1772 tet_infoline(" UtcDaliLayouting_LayoutChildren03");
1774 Stage stage = Stage::GetCurrent();
1776 auto rootControl = Control::New();
1777 auto absoluteLayout = AbsoluteLayout::New();
1778 DevelControl::SetLayout( rootControl, absoluteLayout );
1779 stage.Add( rootControl );
1781 auto hbox = Control::New();
1782 tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
1783 auto hboxLayout = LinearLayout::New();
1784 rootControl.Add( hbox );
1786 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1788 tet_infoline("Then setting a layout on the child container");
1789 DevelControl::SetLayout( hbox, hboxLayout );
1791 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1793 auto& hboxImpl = GetImplementation( hboxLayout );
1794 auto& absImpl = GetImplementation( absoluteLayout );
1795 DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
1796 DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
1801 int UtcDaliLayouting_SetLayoutOrder(void)
1803 ToolkitTestApplication application;
1804 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Call SetLayout after adding the control to the root layout");
1806 Stage stage = Stage::GetCurrent();
1808 auto rootControl = Control::New();
1809 auto absoluteLayout = AbsoluteLayout::New();
1810 DevelControl::SetLayout( rootControl, absoluteLayout );
1811 rootControl.SetName( "AbsoluteLayout" );
1812 stage.Add( rootControl );
1814 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
1815 auto hbox = Control::New();
1816 auto hboxLayout = LinearLayout::New();
1817 hbox.SetName( "HBox");
1819 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
1820 rootControl.Add( hbox );
1822 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
1823 DevelControl::SetLayout( hbox, hboxLayout );
1825 // Add a Child control
1826 std::vector< Control > controls;
1827 controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
1828 for( auto&& iter : controls )
1833 // Ensure layouting happens
1834 application.SendNotification();
1835 application.Render();
1837 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );