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 );
392 int UtcDaliLayouting_HboxLayout05(void)
394 ToolkitTestApplication application;
395 tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
397 Stage stage = Stage::GetCurrent();
398 auto hbox = Control::New();
399 auto hboxLayout = HboxLayout::New();
400 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
401 DevelControl::SetLayout( hbox, hboxLayout );
402 hbox.SetName( "HBox");
404 std::vector< Control > controls;
405 controls.push_back( CreateLeafControl( 40, 40 ) );
406 controls.push_back( CreateLeafControl( 60, 40 ) );
407 controls.push_back( CreateLeafControl( 80, 40 ) );
408 controls.push_back( CreateLeafControl( 100, 40 ) );
410 for( auto&& iter : controls )
413 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
414 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
417 hbox.SetParentOrigin( ParentOrigin::CENTER );
418 hbox.SetAnchorPoint( AnchorPoint::CENTER );
421 // Ensure layouting happens
422 application.SendNotification();
423 application.Render();
425 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
426 // hbox left justifies elements
427 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
428 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
429 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
430 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
432 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
433 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
434 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
435 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
442 int UtcDaliLayouting_HboxLayout_Padding01(void)
444 ToolkitTestApplication application;
445 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
447 Stage stage = Stage::GetCurrent();
448 auto hbox = Control::New();
449 auto hboxLayout = HboxLayout::New();
450 DevelControl::SetLayout( hbox, hboxLayout );
451 hbox.SetName( "HBox");
453 std::vector< Control > controls;
454 controls.push_back( CreateLeafControl( 40, 40 ) );
455 controls.push_back( CreateLeafControl( 60, 40 ) );
456 controls.push_back( CreateLeafControl( 80, 40 ) );
457 controls.push_back( CreateLeafControl( 100, 40 ) );
459 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
460 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
461 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
463 for( auto&& iter : controls )
467 hbox.SetParentOrigin( ParentOrigin::CENTER );
468 hbox.SetAnchorPoint( AnchorPoint::CENTER );
471 // Ensure layouting happens
472 application.SendNotification();
473 application.Render();
475 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
476 // hbox left justifies elements
477 tet_infoline("Test Child Actor Position");
478 float xPositionOfControlBeingTested = 0.0f;
479 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
481 0.0f ), 0.0001f, TEST_LOCATION );
482 xPositionOfControlBeingTested += 40.0f;
484 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
485 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
486 0.0001f, TEST_LOCATION );
488 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
489 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
491 xPositionOfControlBeingTested += 80.0f;
492 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
494 tet_infoline("Test Child Actor Size");
495 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
497 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
498 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
499 0.0001f, TEST_LOCATION );
501 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
502 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
507 int UtcDaliLayouting_HboxLayout_Padding02(void)
509 ToolkitTestApplication application;
510 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
512 Stage stage = Stage::GetCurrent();
513 auto hbox = Control::New();
514 auto hboxLayout = HboxLayout::New();
515 DevelControl::SetLayout( hbox, hboxLayout );
516 hbox.SetName( "HBox");
518 std::vector< Control > controls;
519 controls.push_back( CreateLeafControl( 40, 40 ) );
520 controls.push_back( CreateLeafControl( 60, 40 ) );
521 controls.push_back( CreateLeafControl( 80, 40 ) );
522 controls.push_back( CreateLeafControl( 100, 40 ) );
524 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
526 for( auto&& iter : controls )
528 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
531 hbox.SetParentOrigin( ParentOrigin::CENTER );
532 hbox.SetAnchorPoint( AnchorPoint::CENTER );
535 // Ensure layouting happens
536 application.SendNotification();
537 application.Render();
539 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
540 // hbox left justifies elements
541 tet_infoline("Test Child Actor Position");
542 float xPositionOfControlBeingTested = 0.0f;
543 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
545 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
546 yPositionOfControlBeingTested,
547 0.0f ), 0.0001f, TEST_LOCATION );
548 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
550 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
551 yPositionOfControlBeingTested,
553 0.0001f, TEST_LOCATION );
555 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
556 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
557 yPositionOfControlBeingTested,
558 0.0f ), 0.0001f, TEST_LOCATION );
560 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
561 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
562 yPositionOfControlBeingTested,
563 0.0f ), 0.0001f, TEST_LOCATION );
565 tet_infoline("Test Child Actor Size");
566 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
567 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
568 0.0f ), 0.0001f, TEST_LOCATION );
570 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
571 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
572 0.0f ), 0.0001f, TEST_LOCATION );
574 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
575 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
576 0.0f ), 0.0001f, TEST_LOCATION );
578 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
579 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
580 0.0f ), 0.0001f, TEST_LOCATION );
586 int UtcDaliLayouting_HboxLayout_Padding03(void)
588 ToolkitTestApplication application;
589 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Adding Changing padding on a single child");
591 Stage stage = Stage::GetCurrent();
592 auto hbox = Control::New();
593 auto hboxLayout = HboxLayout::New();
594 DevelControl::SetLayout( hbox, hboxLayout );
595 hbox.SetName( "HBox");
597 std::vector< Control > controls;
598 controls.push_back( CreateLeafControl( 40, 40 ) );
599 controls.push_back( CreateLeafControl( 40, 40 ) );
600 controls.push_back( CreateLeafControl( 40, 40 ) );
602 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
603 tet_printf( "\nAdding Padding to control at index 1 \n" );
604 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
606 for( auto&& iter : controls )
610 hbox.SetParentOrigin( ParentOrigin::CENTER );
611 hbox.SetAnchorPoint( AnchorPoint::CENTER );
614 // Ensure layouting happens
615 application.SendNotification();
616 application.Render();
618 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
619 // hbox left justifies elements
620 tet_infoline("Test Child Actor Position");
621 float xPositionOfControlBeingTested = 0.0f;
622 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
624 0.0f ), 0.0001f, TEST_LOCATION );
625 xPositionOfControlBeingTested += 40.0f;
627 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
628 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
629 0.0001f, TEST_LOCATION );
631 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
632 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
634 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
635 tet_printf( "\nChanging Padding to control at index 1 \n" );
636 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
638 // Ensure layouting happens
639 application.SendNotification();
640 application.Render();
642 xPositionOfControlBeingTested = 0.0f; // reset
644 tet_infoline("Test Child Actor Position");
645 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
647 0.0f ), 0.0001f, TEST_LOCATION );
648 xPositionOfControlBeingTested += 40.0f;
650 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
651 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
652 0.0001f, TEST_LOCATION );
654 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
655 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
656 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
658 tet_infoline("Test Child Actor Size");
659 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
661 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
662 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
663 0.0001f, TEST_LOCATION );
665 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
672 int UtcDaliLayouting_HboxLayout_Margin01(void)
674 ToolkitTestApplication application;
675 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
677 Stage stage = Stage::GetCurrent();
678 auto hbox = Control::New();
679 auto hboxLayout = HboxLayout::New();
680 DevelControl::SetLayout( hbox, hboxLayout );
681 hbox.SetName( "HBox");
683 std::vector< Control > controls;
684 controls.push_back( CreateLeafControl( 40, 40 ) );
685 controls.push_back( CreateLeafControl( 60, 40 ) );
686 controls.push_back( CreateLeafControl( 80, 40 ) );
687 controls.push_back( CreateLeafControl( 100, 40 ) );
689 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
690 tet_printf( "\nAdding Margin to control at index 1 \n" );
691 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
693 for( auto&& iter : controls )
697 hbox.SetParentOrigin( ParentOrigin::CENTER );
698 hbox.SetAnchorPoint( AnchorPoint::CENTER );
701 // Ensure layouting happens
702 application.SendNotification();
703 application.Render();
705 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
706 // hbox left justifies elements
707 tet_infoline("Test Child Actor Position");
708 auto xPositionOfControlBeingTested = 0.0f;
709 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
711 0.0f ), 0.0001f, TEST_LOCATION );
712 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
714 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
715 380.0f + CONTROL_MARGIN.top, 0.0f ),
716 0.0001f, TEST_LOCATION );
718 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
719 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
721 xPositionOfControlBeingTested += 80.0f;
722 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
724 tet_infoline("Test Child Actor Size is the same after Margin added");
725 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
726 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
727 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
728 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
734 int UtcDaliLayouting_VboxLayout01(void)
736 ToolkitTestApplication application;
737 tet_infoline(" UtcDaliLayouting_VboxLayout01");
739 Stage stage = Stage::GetCurrent();
740 auto vbox = Control::New();
741 auto vboxLayout = VboxLayout::New();
742 DevelControl::SetLayout( vbox, vboxLayout );
743 vbox.SetName( "Vbox");
745 std::vector< Control > controls;
746 controls.push_back( CreateLeafControl( 40, 40 ) );
747 controls.push_back( CreateLeafControl( 60, 60 ) );
748 controls.push_back( CreateLeafControl( 80, 80 ) );
749 controls.push_back( CreateLeafControl( 100, 100 ) );
751 for( auto&& iter : controls )
755 vbox.SetParentOrigin( ParentOrigin::CENTER );
756 vbox.SetAnchorPoint( AnchorPoint::CENTER );
759 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
762 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
764 // Ensure layouting happens
765 application.SendNotification();
766 application.Render();
768 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
769 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
770 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
771 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
772 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
774 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
775 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
776 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
777 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
782 int UtcDaliLayouting_VboxLayout02(void)
784 ToolkitTestApplication application;
785 tet_infoline(" UtcDaliLayouting_VboxLayout01");
787 Stage stage = Stage::GetCurrent();
789 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
790 // LayoutGroup for this to happen automatically.
792 // For this test, add an hbox instead
793 auto hbox = Control::New();
794 auto hboxLayout = HboxLayout::New();
795 DevelControl::SetLayout( hbox, hboxLayout );
796 hbox.SetName( "Hbox");
799 auto vbox = Control::New();
800 auto vboxLayout = VboxLayout::New();
801 DevelControl::SetLayout( vbox, vboxLayout );
802 vbox.SetName( "Vbox");
805 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
806 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
808 std::vector< Control > controls;
809 controls.push_back( CreateLeafControl( 40, 40 ) );
810 controls.push_back( CreateLeafControl( 60, 60 ) );
811 controls.push_back( CreateLeafControl( 80, 80 ) );
812 controls.push_back( CreateLeafControl( 100, 100 ) );
814 for( auto&& iter : controls )
818 vbox.SetParentOrigin( ParentOrigin::CENTER );
819 vbox.SetAnchorPoint( AnchorPoint::CENTER );
821 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
824 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
826 // Ensure layouting happens
827 application.SendNotification();
828 application.Render();
830 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
831 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
833 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
834 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
835 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
837 // 3rd control is set to match parent - this should also be 100 wide
838 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
839 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
840 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
841 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
843 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
844 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
845 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
846 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
852 int UtcDaliLayouting_VboxLayout03(void)
854 ToolkitTestApplication application;
855 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
857 Stage stage = Stage::GetCurrent();
859 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
860 // LayoutGroup for this to happen automatically.
862 // For this test, add an hbox instead
863 auto hbox = Control::New();
864 auto hboxLayout = HboxLayout::New();
865 DevelControl::SetLayout( hbox, hboxLayout );
866 hbox.SetName( "Hbox");
869 auto vbox = Control::New();
870 auto vboxLayout = VboxLayout::New();
871 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
873 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
875 DevelControl::SetLayout( vbox, vboxLayout );
876 vbox.SetName( "Vbox");
879 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
880 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
882 std::vector< Control > controls;
883 controls.push_back( CreateLeafControl( 40, 40 ) );
884 controls.push_back( CreateLeafControl( 60, 60 ) );
885 controls.push_back( CreateLeafControl( 80, 80 ) );
886 controls.push_back( CreateLeafControl( 100, 100 ) );
888 for( auto&& iter : controls )
892 vbox.SetParentOrigin( ParentOrigin::CENTER );
893 vbox.SetAnchorPoint( AnchorPoint::CENTER );
895 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
898 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
900 // Ensure layouting happens
901 application.SendNotification();
902 application.Render();
904 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
905 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
907 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
908 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
909 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
911 // 3rd control is set to match parent - this should also be 100 wide
912 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
913 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
914 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
915 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
917 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
918 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
919 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
920 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );