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>
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali-toolkit/devel-api/controls/control-devel.h>
24 #include <dali-toolkit/devel-api/layouting/hbox-layout.h>
25 #include <dali-toolkit/devel-api/layouting/vbox-layout.h>
27 #include <layout-utils.h>
30 using namespace Toolkit;
32 void utc_dali_toolkit_layouting_startup(void)
34 test_return_value = TET_UNDEF;
37 void utc_dali_toolkit_layouting_cleanup(void)
39 test_return_value = TET_PASS;
42 int UtcDaliLayouting_HboxLayout01(void)
44 ToolkitTestApplication application;
45 tet_infoline(" UtcDaliLayouting_HboxLayout01");
47 Stage stage = Stage::GetCurrent();
48 auto hbox = Control::New();
49 auto hboxLayout = HboxLayout::New();
50 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
51 DevelControl::SetLayout( hbox, hboxLayout );
52 hbox.SetName( "HBox");
54 std::vector< Control > controls;
55 controls.push_back( CreateLeafControl( 40, 40 ) );
56 controls.push_back( CreateLeafControl( 60, 40 ) );
57 controls.push_back( CreateLeafControl( 80, 40 ) );
58 controls.push_back( CreateLeafControl( 100, 40 ) );
60 for( auto&& iter : controls )
64 hbox.SetParentOrigin( ParentOrigin::CENTER );
65 hbox.SetAnchorPoint( AnchorPoint::CENTER );
68 // Ensure layouting happens
69 application.SendNotification();
72 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
73 // hbox left justifies elements
74 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
75 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
76 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
77 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
79 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
80 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
81 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
82 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
87 int UtcDaliLayouting_HboxLayout02(void)
89 ToolkitTestApplication application;
90 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
92 Stage stage = Stage::GetCurrent();
94 auto hbox1 = Control::New();
95 auto hboxLayout1 = HboxLayout::New();
96 DevelControl::SetLayout( hbox1, hboxLayout1 );
98 auto hbox2 = Control::New();
99 auto hboxLayout2 = HboxLayout::New();
100 DevelControl::SetLayout( hbox2, hboxLayout2 );
102 hbox1.SetName( "HBox1");
103 hbox2.SetName( "HBox2");
105 std::vector< Control > controls;
106 controls.push_back( CreateLeafControl( 20, 40 ) );
107 controls.push_back( CreateLeafControl( 30, 50 ) );
108 controls.push_back( CreateLeafControl( 40, 60 ) );
109 controls.push_back( CreateLeafControl( 50, 70 ) );
111 controls.push_back( CreateLeafControl( 25, 40 ) );
112 controls.push_back( CreateLeafControl( 35, 50 ) );
113 controls.push_back( CreateLeafControl( 45, 60 ) );
114 controls.push_back( CreateLeafControl( 55, 70 ) );
117 for( auto&& iter : controls )
129 hbox1.SetParentOrigin( ParentOrigin::CENTER );
130 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
131 hbox2.SetParentOrigin( ParentOrigin::CENTER );
132 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
134 auto hbox3 = Control::New();
135 auto hboxLayout3 = HboxLayout::New();
136 DevelControl::SetLayout( hbox3, hboxLayout3 );
138 hbox3.SetParentOrigin( ParentOrigin::CENTER );
139 hbox3.SetName( "HBox3");
145 // Ensure layouting happens
146 application.SendNotification();
147 application.Render();
150 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
151 // hbox left justifies elements
152 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
153 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
154 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
155 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
157 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
158 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
159 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
160 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
163 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
164 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
165 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
166 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
168 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
169 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
170 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
171 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
173 // Test hbox1 and 2 are sized to wrap their content
174 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
175 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
176 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
177 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
179 // Test hbox3 matches parent (root layer)
180 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
181 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
187 int UtcDaliLayouting_HboxLayout03(void)
189 ToolkitTestApplication application;
190 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
192 Stage stage = Stage::GetCurrent();
194 auto hbox1 = Control::New();
195 auto hboxLayout1 = HboxLayout::New();
196 DevelControl::SetLayout( hbox1, hboxLayout1 );
198 auto hbox2 = Control::New();
199 auto hboxLayout2 = HboxLayout::New();
200 DevelControl::SetLayout( hbox2, hboxLayout2 );
202 hbox1.SetName( "HBox1");
203 hbox2.SetName( "HBox2");
204 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
205 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
206 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
207 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
209 std::vector< Control > controls;
210 controls.push_back( CreateLeafControl( 20, 40 ) );
211 controls.push_back( CreateLeafControl( 30, 50 ) );
212 controls.push_back( CreateLeafControl( 40, 60 ) );
213 controls.push_back( CreateLeafControl( 50, 70 ) );
215 controls.push_back( CreateLeafControl( 25, 40 ) );
216 controls.push_back( CreateLeafControl( 35, 50 ) );
217 controls.push_back( CreateLeafControl( 45, 60 ) );
218 controls.push_back( CreateLeafControl( 55, 70 ) );
221 for( auto&& iter : controls )
233 hbox1.SetParentOrigin( ParentOrigin::CENTER );
234 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
235 hbox2.SetParentOrigin( ParentOrigin::CENTER );
236 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
238 auto hbox3 = Control::New();
239 auto hboxLayout3 = HboxLayout::New();
240 DevelControl::SetLayout( hbox3, hboxLayout3);
242 hbox3.SetParentOrigin( ParentOrigin::CENTER );
243 hbox3.SetName( "HBox3");
249 //std::ostringstream oss;
250 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
251 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
253 // Ensure layouting happens
254 application.SendNotification();
255 application.Render();
258 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
259 // hbox left justifies elements
260 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
261 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
262 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
263 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
265 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
266 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
267 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
268 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
270 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
271 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
272 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
273 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
275 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
276 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
277 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
278 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
280 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
281 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
282 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
283 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
285 // Test hbox3 matches parent (root layer)
286 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
287 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
292 int UtcDaliLayouting_HboxLayout04(void)
294 ToolkitTestApplication application;
295 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
297 Stage stage = Stage::GetCurrent();
299 auto hbox1 = Control::New();
300 auto hboxLayout1 = HboxLayout::New();
301 DevelControl::SetLayout( hbox1, hboxLayout1 );
303 auto hbox2 = Control::New();
304 auto hboxLayout2 = HboxLayout::New();
305 DevelControl::SetLayout( hbox2, hboxLayout2 );
307 hbox1.SetName( "HBox1"); // Default spec is to wrap content
308 hbox2.SetName( "HBox2");
309 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
310 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
311 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
312 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
314 std::vector< Control > controls;
315 controls.push_back( CreateLeafControl( 80, 40 ) );
316 controls.push_back( CreateLeafControl( 80, 50 ) );
317 controls.push_back( CreateLeafControl( 80, 60 ) );
318 controls.push_back( CreateLeafControl( 80, 70 ) );
320 controls.push_back( CreateLeafControl( 80, 40 ) );
321 controls.push_back( CreateLeafControl( 80, 50 ) );
322 controls.push_back( CreateLeafControl( 80, 60 ) );
323 controls.push_back( CreateLeafControl( 80, 70 ) );
326 for( auto&& iter : controls )
339 controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
340 auto hbox3 = Control::New();
341 auto hboxLayout3 = HboxLayout::New();
342 DevelControl::SetLayout( hbox3, hboxLayout3 );
344 hbox3.SetParentOrigin( ParentOrigin::CENTER );
345 hbox3.SetName( "HBox3");
350 //std::ostringstream oss;
351 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
352 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
354 // Ensure layouting happens
355 application.SendNotification();
356 application.Render();
359 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
360 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
361 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
362 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
364 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
365 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
366 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
367 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
369 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
370 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
371 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
372 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
374 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
375 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
376 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
377 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
379 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
380 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
381 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
382 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
385 // Test hbox3 matches parent (root layer)
386 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
387 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
394 int UtcDaliLayouting_HboxLayout_Padding01(void)
396 ToolkitTestApplication application;
397 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
399 Stage stage = Stage::GetCurrent();
400 auto hbox = Control::New();
401 auto hboxLayout = HboxLayout::New();
402 DevelControl::SetLayout( hbox, hboxLayout );
403 hbox.SetName( "HBox");
405 std::vector< Control > controls;
406 controls.push_back( CreateLeafControl( 40, 40 ) );
407 controls.push_back( CreateLeafControl( 60, 40 ) );
408 controls.push_back( CreateLeafControl( 80, 40 ) );
409 controls.push_back( CreateLeafControl( 100, 40 ) );
411 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
412 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
413 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
415 for( auto&& iter : controls )
419 hbox.SetParentOrigin( ParentOrigin::CENTER );
420 hbox.SetAnchorPoint( AnchorPoint::CENTER );
423 // Ensure layouting happens
424 application.SendNotification();
425 application.Render();
427 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
428 // hbox left justifies elements
429 tet_infoline("Test Child Actor Position");
430 float xPositionOfControlBeingTested = 0.0f;
431 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
433 0.0f ), 0.0001f, TEST_LOCATION );
434 xPositionOfControlBeingTested += 40.0f;
436 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
437 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
438 0.0001f, TEST_LOCATION );
440 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
441 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
443 xPositionOfControlBeingTested += 80.0f;
444 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
446 tet_infoline("Test Child Actor Size");
447 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
449 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
450 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
451 0.0001f, TEST_LOCATION );
453 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
454 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
459 int UtcDaliLayouting_HboxLayout_Padding02(void)
461 ToolkitTestApplication application;
462 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
464 Stage stage = Stage::GetCurrent();
465 auto hbox = Control::New();
466 auto hboxLayout = HboxLayout::New();
467 DevelControl::SetLayout( hbox, hboxLayout );
468 hbox.SetName( "HBox");
470 std::vector< Control > controls;
471 controls.push_back( CreateLeafControl( 40, 40 ) );
472 controls.push_back( CreateLeafControl( 60, 40 ) );
473 controls.push_back( CreateLeafControl( 80, 40 ) );
474 controls.push_back( CreateLeafControl( 100, 40 ) );
476 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
478 for( auto&& iter : controls )
480 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
483 hbox.SetParentOrigin( ParentOrigin::CENTER );
484 hbox.SetAnchorPoint( AnchorPoint::CENTER );
487 // Ensure layouting happens
488 application.SendNotification();
489 application.Render();
491 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
492 // hbox left justifies elements
493 tet_infoline("Test Child Actor Position");
494 float xPositionOfControlBeingTested = 0.0f;
495 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
497 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
498 yPositionOfControlBeingTested,
499 0.0f ), 0.0001f, TEST_LOCATION );
500 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
502 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
503 yPositionOfControlBeingTested,
505 0.0001f, TEST_LOCATION );
507 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
508 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
509 yPositionOfControlBeingTested,
510 0.0f ), 0.0001f, TEST_LOCATION );
512 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
513 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
514 yPositionOfControlBeingTested,
515 0.0f ), 0.0001f, TEST_LOCATION );
517 tet_infoline("Test Child Actor Size");
518 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
519 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
520 0.0f ), 0.0001f, TEST_LOCATION );
522 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
523 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
524 0.0f ), 0.0001f, TEST_LOCATION );
526 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
527 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
528 0.0f ), 0.0001f, TEST_LOCATION );
530 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
531 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
532 0.0f ), 0.0001f, TEST_LOCATION );
538 int UtcDaliLayouting_HboxLayout_Padding03(void)
540 ToolkitTestApplication application;
541 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Adding Changing padding on a single child");
543 Stage stage = Stage::GetCurrent();
544 auto hbox = Control::New();
545 auto hboxLayout = HboxLayout::New();
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( 40, 40 ) );
552 controls.push_back( CreateLeafControl( 40, 40 ) );
554 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
555 tet_printf( "\nAdding Padding to control at index 1 \n" );
556 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
558 for( auto&& iter : controls )
562 hbox.SetParentOrigin( ParentOrigin::CENTER );
563 hbox.SetAnchorPoint( AnchorPoint::CENTER );
566 // Ensure layouting happens
567 application.SendNotification();
568 application.Render();
570 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
571 // hbox left justifies elements
572 tet_infoline("Test Child Actor Position");
573 float xPositionOfControlBeingTested = 0.0f;
574 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
576 0.0f ), 0.0001f, TEST_LOCATION );
577 xPositionOfControlBeingTested += 40.0f;
579 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
580 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
581 0.0001f, TEST_LOCATION );
583 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
584 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
586 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
587 tet_printf( "\nChanging Padding to control at index 1 \n" );
588 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
590 // Ensure layouting happens
591 application.SendNotification();
592 application.Render();
594 xPositionOfControlBeingTested = 0.0f; // reset
596 tet_infoline("Test Child Actor Position");
597 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
599 0.0f ), 0.0001f, TEST_LOCATION );
600 xPositionOfControlBeingTested += 40.0f;
602 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
603 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
604 0.0001f, TEST_LOCATION );
606 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
607 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
608 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
610 tet_infoline("Test Child Actor Size");
611 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
613 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
614 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
615 0.0001f, TEST_LOCATION );
617 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
624 int UtcDaliLayouting_HboxLayout_Margin01(void)
626 ToolkitTestApplication application;
627 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
629 Stage stage = Stage::GetCurrent();
630 auto hbox = Control::New();
631 auto hboxLayout = HboxLayout::New();
632 DevelControl::SetLayout( hbox, hboxLayout );
633 hbox.SetName( "HBox");
635 std::vector< Control > controls;
636 controls.push_back( CreateLeafControl( 40, 40 ) );
637 controls.push_back( CreateLeafControl( 60, 40 ) );
638 controls.push_back( CreateLeafControl( 80, 40 ) );
639 controls.push_back( CreateLeafControl( 100, 40 ) );
641 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
642 tet_printf( "\nAdding Margin to control at index 1 \n" );
643 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
645 for( auto&& iter : controls )
649 hbox.SetParentOrigin( ParentOrigin::CENTER );
650 hbox.SetAnchorPoint( AnchorPoint::CENTER );
653 // Ensure layouting happens
654 application.SendNotification();
655 application.Render();
657 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
658 // hbox left justifies elements
659 tet_infoline("Test Child Actor Position");
660 auto xPositionOfControlBeingTested = 0.0f;
661 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
663 0.0f ), 0.0001f, TEST_LOCATION );
664 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
666 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
667 380.0f + CONTROL_MARGIN.top, 0.0f ),
668 0.0001f, TEST_LOCATION );
670 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
671 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
673 xPositionOfControlBeingTested += 80.0f;
674 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
676 tet_infoline("Test Child Actor Size is the same after Margin added");
677 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
678 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
679 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
680 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
686 int UtcDaliLayouting_VboxLayout01(void)
688 ToolkitTestApplication application;
689 tet_infoline(" UtcDaliLayouting_VboxLayout01");
691 Stage stage = Stage::GetCurrent();
692 auto vbox = Control::New();
693 auto vboxLayout = VboxLayout::New();
694 DevelControl::SetLayout( vbox, vboxLayout );
695 vbox.SetName( "Vbox");
697 std::vector< Control > controls;
698 controls.push_back( CreateLeafControl( 40, 40 ) );
699 controls.push_back( CreateLeafControl( 60, 60 ) );
700 controls.push_back( CreateLeafControl( 80, 80 ) );
701 controls.push_back( CreateLeafControl( 100, 100 ) );
703 for( auto&& iter : controls )
707 vbox.SetParentOrigin( ParentOrigin::CENTER );
708 vbox.SetAnchorPoint( AnchorPoint::CENTER );
711 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
714 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
716 // Ensure layouting happens
717 application.SendNotification();
718 application.Render();
720 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
721 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
722 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
723 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
724 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
726 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
727 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
728 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
729 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
734 int UtcDaliLayouting_VboxLayout02(void)
736 ToolkitTestApplication application;
737 tet_infoline(" UtcDaliLayouting_VboxLayout01");
739 Stage stage = Stage::GetCurrent();
741 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
742 // LayoutGroup for this to happen automatically.
744 // For this test, add an hbox instead
745 auto hbox = Control::New();
746 auto hboxLayout = HboxLayout::New();
747 DevelControl::SetLayout( hbox, hboxLayout );
748 hbox.SetName( "Hbox");
751 auto vbox = Control::New();
752 auto vboxLayout = VboxLayout::New();
753 DevelControl::SetLayout( vbox, vboxLayout );
754 vbox.SetName( "Vbox");
757 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
758 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
760 std::vector< Control > controls;
761 controls.push_back( CreateLeafControl( 40, 40 ) );
762 controls.push_back( CreateLeafControl( 60, 60 ) );
763 controls.push_back( CreateLeafControl( 80, 80 ) );
764 controls.push_back( CreateLeafControl( 100, 100 ) );
766 for( auto&& iter : controls )
770 vbox.SetParentOrigin( ParentOrigin::CENTER );
771 vbox.SetAnchorPoint( AnchorPoint::CENTER );
773 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
776 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
778 // Ensure layouting happens
779 application.SendNotification();
780 application.Render();
782 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
783 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
785 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
786 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
787 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
789 // 3rd control is set to match parent - this should also be 100 wide
790 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
791 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
792 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
793 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
795 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
796 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
797 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
798 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
804 int UtcDaliLayouting_VboxLayout03(void)
806 ToolkitTestApplication application;
807 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
809 Stage stage = Stage::GetCurrent();
811 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
812 // LayoutGroup for this to happen automatically.
814 // For this test, add an hbox instead
815 auto hbox = Control::New();
816 auto hboxLayout = HboxLayout::New();
817 DevelControl::SetLayout( hbox, hboxLayout );
818 hbox.SetName( "Hbox");
821 auto vbox = Control::New();
822 auto vboxLayout = VboxLayout::New();
823 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
825 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
827 DevelControl::SetLayout( vbox, vboxLayout );
828 vbox.SetName( "Vbox");
831 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
832 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
834 std::vector< Control > controls;
835 controls.push_back( CreateLeafControl( 40, 40 ) );
836 controls.push_back( CreateLeafControl( 60, 60 ) );
837 controls.push_back( CreateLeafControl( 80, 80 ) );
838 controls.push_back( CreateLeafControl( 100, 100 ) );
840 for( auto&& iter : controls )
844 vbox.SetParentOrigin( ParentOrigin::CENTER );
845 vbox.SetAnchorPoint( AnchorPoint::CENTER );
847 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
850 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
852 // Ensure layouting happens
853 application.SendNotification();
854 application.Render();
856 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
857 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
859 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
860 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
861 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
863 // 3rd control is set to match parent - this should also be 100 wide
864 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
865 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
866 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
867 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
869 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
870 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
871 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
872 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );