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>
26 #include <dali-toolkit/devel-api/layouting/absolute-layout.h>
28 #include <layout-utils.h>
31 using namespace Toolkit;
33 void utc_dali_toolkit_layouting_startup(void)
35 test_return_value = TET_UNDEF;
38 void utc_dali_toolkit_layouting_cleanup(void)
40 test_return_value = TET_PASS;
43 int UtcDaliLayouting_HboxLayout01(void)
45 ToolkitTestApplication application;
46 tet_infoline(" UtcDaliLayouting_HboxLayout01");
48 Stage stage = Stage::GetCurrent();
49 auto hbox = Control::New();
50 auto hboxLayout = HboxLayout::New();
51 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
52 DevelControl::SetLayout( hbox, hboxLayout );
53 hbox.SetName( "HBox");
55 std::vector< Control > controls;
56 controls.push_back( CreateLeafControl( 40, 40 ) );
57 controls.push_back( CreateLeafControl( 60, 40 ) );
58 controls.push_back( CreateLeafControl( 80, 40 ) );
59 controls.push_back( CreateLeafControl( 100, 40 ) );
61 for( auto&& iter : controls )
65 hbox.SetParentOrigin( ParentOrigin::CENTER );
66 hbox.SetAnchorPoint( AnchorPoint::CENTER );
69 // Ensure layouting happens
70 application.SendNotification();
73 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
74 // hbox left justifies elements
75 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
76 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
77 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
78 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
80 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
81 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
82 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
83 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
86 auto newHBoxLayout = HboxLayout::New();
87 newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
88 DevelControl::SetLayout( hbox, newHBoxLayout );
90 application.SendNotification();
93 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
94 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
95 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
96 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
101 int UtcDaliLayouting_HboxLayout02(void)
103 ToolkitTestApplication application;
104 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
106 Stage stage = Stage::GetCurrent();
108 auto hbox1 = Control::New();
109 auto hboxLayout1 = HboxLayout::New();
110 DevelControl::SetLayout( hbox1, hboxLayout1 );
112 auto hbox2 = Control::New();
113 auto hboxLayout2 = HboxLayout::New();
114 DevelControl::SetLayout( hbox2, hboxLayout2 );
116 hbox1.SetName( "HBox1");
117 hbox2.SetName( "HBox2");
119 std::vector< Control > controls;
120 controls.push_back( CreateLeafControl( 20, 40 ) );
121 controls.push_back( CreateLeafControl( 30, 50 ) );
122 controls.push_back( CreateLeafControl( 40, 60 ) );
123 controls.push_back( CreateLeafControl( 50, 70 ) );
125 controls.push_back( CreateLeafControl( 25, 40 ) );
126 controls.push_back( CreateLeafControl( 35, 50 ) );
127 controls.push_back( CreateLeafControl( 45, 60 ) );
128 controls.push_back( CreateLeafControl( 55, 70 ) );
131 for( auto&& iter : controls )
143 hbox1.SetParentOrigin( ParentOrigin::CENTER );
144 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
145 hbox2.SetParentOrigin( ParentOrigin::CENTER );
146 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
148 auto hbox3 = Control::New();
149 auto hboxLayout3 = HboxLayout::New();
150 DevelControl::SetLayout( hbox3, hboxLayout3 );
152 hbox3.SetParentOrigin( ParentOrigin::CENTER );
153 hbox3.SetName( "HBox3");
159 // Ensure layouting happens
160 application.SendNotification();
161 application.Render();
164 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
165 // hbox left justifies elements
166 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
167 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
168 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
169 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
171 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
172 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
173 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
174 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
177 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
178 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
179 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
180 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
182 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
183 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
184 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
185 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
187 // Test hbox1 and 2 are sized to wrap their content
188 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
189 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
190 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
191 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
193 // Test hbox3 matches parent (root layer)
194 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
195 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
201 int UtcDaliLayouting_HboxLayout03(void)
203 ToolkitTestApplication application;
204 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
206 Stage stage = Stage::GetCurrent();
208 auto hbox1 = Control::New();
209 auto hboxLayout1 = HboxLayout::New();
210 DevelControl::SetLayout( hbox1, hboxLayout1 );
212 auto hbox2 = Control::New();
213 auto hboxLayout2 = HboxLayout::New();
214 DevelControl::SetLayout( hbox2, hboxLayout2 );
216 hbox1.SetName( "HBox1");
217 hbox2.SetName( "HBox2");
218 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
219 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
220 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
221 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
223 std::vector< Control > controls;
224 controls.push_back( CreateLeafControl( 20, 40 ) );
225 controls.push_back( CreateLeafControl( 30, 50 ) );
226 controls.push_back( CreateLeafControl( 40, 60 ) );
227 controls.push_back( CreateLeafControl( 50, 70 ) );
229 controls.push_back( CreateLeafControl( 25, 40 ) );
230 controls.push_back( CreateLeafControl( 35, 50 ) );
231 controls.push_back( CreateLeafControl( 45, 60 ) );
232 controls.push_back( CreateLeafControl( 55, 70 ) );
235 for( auto&& iter : controls )
247 hbox1.SetParentOrigin( ParentOrigin::CENTER );
248 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
249 hbox2.SetParentOrigin( ParentOrigin::CENTER );
250 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
252 auto hbox3 = Control::New();
253 auto hboxLayout3 = HboxLayout::New();
254 DevelControl::SetLayout( hbox3, hboxLayout3);
256 hbox3.SetParentOrigin( ParentOrigin::CENTER );
257 hbox3.SetName( "HBox3");
263 //std::ostringstream oss;
264 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
265 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
267 // Ensure layouting happens
268 application.SendNotification();
269 application.Render();
272 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
273 // hbox left justifies elements
274 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
275 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
276 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
277 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
279 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
280 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
281 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
282 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
284 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
285 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
286 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
287 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
289 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
290 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
291 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
292 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
294 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
295 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
296 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
297 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
299 // Test hbox3 matches parent (root layer)
300 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
301 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
306 int UtcDaliLayouting_HboxLayout04(void)
308 ToolkitTestApplication application;
309 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
311 Stage stage = Stage::GetCurrent();
313 auto hbox1 = Control::New();
314 auto hboxLayout1 = HboxLayout::New();
315 DevelControl::SetLayout( hbox1, hboxLayout1 );
317 auto hbox2 = Control::New();
318 auto hboxLayout2 = HboxLayout::New();
319 DevelControl::SetLayout( hbox2, hboxLayout2 );
321 hbox1.SetName( "HBox1"); // Default spec is to wrap content
322 hbox2.SetName( "HBox2");
323 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
324 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
325 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
326 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
328 std::vector< Control > controls;
329 controls.push_back( CreateLeafControl( 80, 40 ) );
330 controls.push_back( CreateLeafControl( 80, 50 ) );
331 controls.push_back( CreateLeafControl( 80, 60 ) );
332 controls.push_back( CreateLeafControl( 80, 70 ) );
334 controls.push_back( CreateLeafControl( 80, 40 ) );
335 controls.push_back( CreateLeafControl( 80, 50 ) );
336 controls.push_back( CreateLeafControl( 80, 60 ) );
337 controls.push_back( CreateLeafControl( 80, 70 ) );
340 for( auto&& iter : controls )
353 controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
354 auto hbox3 = Control::New();
355 auto hboxLayout3 = HboxLayout::New();
356 DevelControl::SetLayout( hbox3, hboxLayout3 );
358 hbox3.SetParentOrigin( ParentOrigin::CENTER );
359 hbox3.SetName( "HBox3");
364 //std::ostringstream oss;
365 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
366 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
368 // Ensure layouting happens
369 application.SendNotification();
370 application.Render();
373 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
374 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
375 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
376 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
378 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
379 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
380 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
381 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
383 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
384 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
385 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
386 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
388 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
389 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
390 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
391 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
393 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
394 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
395 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
396 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
399 // Test hbox3 matches parent (root layer)
400 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
401 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
406 int UtcDaliLayouting_HboxLayout05(void)
408 ToolkitTestApplication application;
409 tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
411 Stage stage = Stage::GetCurrent();
412 auto hbox = Control::New();
413 auto hboxLayout = HboxLayout::New();
414 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
415 DevelControl::SetLayout( hbox, hboxLayout );
416 hbox.SetName( "HBox");
418 std::vector< Control > controls;
419 controls.push_back( CreateLeafControl( 40, 40 ) );
420 controls.push_back( CreateLeafControl( 60, 40 ) );
421 controls.push_back( CreateLeafControl( 80, 40 ) );
422 controls.push_back( CreateLeafControl( 100, 40 ) );
424 for( auto&& iter : controls )
427 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
428 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
431 hbox.SetParentOrigin( ParentOrigin::CENTER );
432 hbox.SetAnchorPoint( AnchorPoint::CENTER );
435 // Ensure layouting happens
436 application.SendNotification();
437 application.Render();
439 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
440 // hbox left justifies elements
441 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
442 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
443 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
444 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
446 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
447 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
448 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
449 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
456 int UtcDaliLayouting_HboxLayout_Padding01(void)
458 ToolkitTestApplication application;
459 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
461 Stage stage = Stage::GetCurrent();
462 auto hbox = Control::New();
463 auto hboxLayout = HboxLayout::New();
464 DevelControl::SetLayout( hbox, hboxLayout );
465 hbox.SetName( "HBox");
467 std::vector< Control > controls;
468 controls.push_back( CreateLeafControl( 40, 40 ) );
469 controls.push_back( CreateLeafControl( 60, 40 ) );
470 controls.push_back( CreateLeafControl( 80, 40 ) );
471 controls.push_back( CreateLeafControl( 100, 40 ) );
473 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
474 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
475 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
477 for( auto&& iter : controls )
481 hbox.SetParentOrigin( ParentOrigin::CENTER );
482 hbox.SetAnchorPoint( AnchorPoint::CENTER );
485 // Ensure layouting happens
486 application.SendNotification();
487 application.Render();
489 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
490 // hbox left justifies elements
491 tet_infoline("Test Child Actor Position");
492 float xPositionOfControlBeingTested = 0.0f;
493 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
495 0.0f ), 0.0001f, TEST_LOCATION );
496 xPositionOfControlBeingTested += 40.0f;
498 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
499 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
500 0.0001f, TEST_LOCATION );
502 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
503 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
505 xPositionOfControlBeingTested += 80.0f;
506 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
508 tet_infoline("Test Child Actor Size");
509 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
511 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
512 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
513 0.0001f, TEST_LOCATION );
515 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
516 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
521 int UtcDaliLayouting_HboxLayout_Padding02(void)
523 ToolkitTestApplication application;
524 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
526 Stage stage = Stage::GetCurrent();
527 auto hbox = Control::New();
528 auto hboxLayout = HboxLayout::New();
529 DevelControl::SetLayout( hbox, hboxLayout );
530 hbox.SetName( "HBox");
532 std::vector< Control > controls;
533 controls.push_back( CreateLeafControl( 40, 40 ) );
534 controls.push_back( CreateLeafControl( 60, 40 ) );
535 controls.push_back( CreateLeafControl( 80, 40 ) );
536 controls.push_back( CreateLeafControl( 100, 40 ) );
538 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
540 for( auto&& iter : controls )
542 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
545 hbox.SetParentOrigin( ParentOrigin::CENTER );
546 hbox.SetAnchorPoint( AnchorPoint::CENTER );
549 // Ensure layouting happens
550 application.SendNotification();
551 application.Render();
553 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
554 // hbox left justifies elements
555 tet_infoline("Test Child Actor Position");
556 float xPositionOfControlBeingTested = 0.0f;
557 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
559 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
560 yPositionOfControlBeingTested,
561 0.0f ), 0.0001f, TEST_LOCATION );
562 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
564 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
565 yPositionOfControlBeingTested,
567 0.0001f, TEST_LOCATION );
569 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
570 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
571 yPositionOfControlBeingTested,
572 0.0f ), 0.0001f, TEST_LOCATION );
574 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
575 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
576 yPositionOfControlBeingTested,
577 0.0f ), 0.0001f, TEST_LOCATION );
579 tet_infoline("Test Child Actor Size");
580 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
581 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
582 0.0f ), 0.0001f, TEST_LOCATION );
584 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
585 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
586 0.0f ), 0.0001f, TEST_LOCATION );
588 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
589 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
590 0.0f ), 0.0001f, TEST_LOCATION );
592 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
593 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
594 0.0f ), 0.0001f, TEST_LOCATION );
600 int UtcDaliLayouting_HboxLayout_Padding03(void)
602 ToolkitTestApplication application;
603 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Adding Changing padding on a single child");
605 Stage stage = Stage::GetCurrent();
606 auto hbox = Control::New();
607 auto hboxLayout = HboxLayout::New();
608 DevelControl::SetLayout( hbox, hboxLayout );
609 hbox.SetName( "HBox");
611 std::vector< Control > controls;
612 controls.push_back( CreateLeafControl( 40, 40 ) );
613 controls.push_back( CreateLeafControl( 40, 40 ) );
614 controls.push_back( CreateLeafControl( 40, 40 ) );
616 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
617 tet_printf( "\nAdding Padding to control at index 1 \n" );
618 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
620 for( auto&& iter : controls )
624 hbox.SetParentOrigin( ParentOrigin::CENTER );
625 hbox.SetAnchorPoint( AnchorPoint::CENTER );
628 // Ensure layouting happens
629 application.SendNotification();
630 application.Render();
632 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
633 // hbox left justifies elements
634 tet_infoline("Test Child Actor Position");
635 float xPositionOfControlBeingTested = 0.0f;
636 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
638 0.0f ), 0.0001f, TEST_LOCATION );
639 xPositionOfControlBeingTested += 40.0f;
641 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
642 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
643 0.0001f, TEST_LOCATION );
645 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
646 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
648 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
649 tet_printf( "\nChanging Padding to control at index 1 \n" );
650 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
652 // Ensure layouting happens
653 application.SendNotification();
654 application.Render();
656 xPositionOfControlBeingTested = 0.0f; // reset
658 tet_infoline("Test Child Actor Position");
659 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
661 0.0f ), 0.0001f, TEST_LOCATION );
662 xPositionOfControlBeingTested += 40.0f;
664 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
665 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
666 0.0001f, TEST_LOCATION );
668 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
669 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
670 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
672 tet_infoline("Test Child Actor Size");
673 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
675 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
676 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
677 0.0001f, TEST_LOCATION );
679 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
686 int UtcDaliLayouting_HboxLayout_Margin01(void)
688 ToolkitTestApplication application;
689 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
691 Stage stage = Stage::GetCurrent();
692 auto hbox = Control::New();
693 auto hboxLayout = HboxLayout::New();
694 DevelControl::SetLayout( hbox, hboxLayout );
695 hbox.SetName( "HBox");
697 std::vector< Control > controls;
698 controls.push_back( CreateLeafControl( 40, 40 ) );
699 controls.push_back( CreateLeafControl( 60, 40 ) );
700 controls.push_back( CreateLeafControl( 80, 40 ) );
701 controls.push_back( CreateLeafControl( 100, 40 ) );
703 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
704 tet_printf( "\nAdding Margin to control at index 1 \n" );
705 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
707 for( auto&& iter : controls )
711 hbox.SetParentOrigin( ParentOrigin::CENTER );
712 hbox.SetAnchorPoint( AnchorPoint::CENTER );
715 // Ensure layouting happens
716 application.SendNotification();
717 application.Render();
719 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
720 // hbox left justifies elements
721 tet_infoline("Test Child Actor Position");
722 auto xPositionOfControlBeingTested = 0.0f;
723 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
725 0.0f ), 0.0001f, TEST_LOCATION );
726 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
728 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
729 380.0f + CONTROL_MARGIN.top, 0.0f ),
730 0.0001f, TEST_LOCATION );
732 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
733 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
735 xPositionOfControlBeingTested += 80.0f;
736 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
738 tet_infoline("Test Child Actor Size is the same after Margin added");
739 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
740 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
741 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
742 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
748 int UtcDaliLayouting_VboxLayout01(void)
750 ToolkitTestApplication application;
751 tet_infoline(" UtcDaliLayouting_VboxLayout01");
753 Stage stage = Stage::GetCurrent();
754 auto vbox = Control::New();
755 auto vboxLayout = VboxLayout::New();
756 DevelControl::SetLayout( vbox, vboxLayout );
757 vbox.SetName( "Vbox");
759 std::vector< Control > controls;
760 controls.push_back( CreateLeafControl( 40, 40 ) );
761 controls.push_back( CreateLeafControl( 60, 60 ) );
762 controls.push_back( CreateLeafControl( 80, 80 ) );
763 controls.push_back( CreateLeafControl( 100, 100 ) );
765 for( auto&& iter : controls )
769 vbox.SetParentOrigin( ParentOrigin::CENTER );
770 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 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
783 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
784 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
785 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
786 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
788 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
789 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
790 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
791 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
796 int UtcDaliLayouting_VboxLayout02(void)
798 ToolkitTestApplication application;
799 tet_infoline(" UtcDaliLayouting_VboxLayout01");
801 Stage stage = Stage::GetCurrent();
803 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
804 // LayoutGroup for this to happen automatically.
806 // For this test, add an hbox instead
807 auto rootControl = Control::New();
808 auto absoluteLayout = AbsoluteLayout::New();
809 DevelControl::SetLayout( rootControl, absoluteLayout );
810 rootControl.SetName( "AbsoluteLayout");
811 stage.Add( rootControl );
813 auto vbox = Control::New();
814 auto vboxLayout = VboxLayout::New();
815 DevelControl::SetLayout( vbox, vboxLayout );
816 vbox.SetName( "Vbox");
817 rootControl.Add( vbox );
819 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
820 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
822 std::vector< Control > controls;
823 controls.push_back( CreateLeafControl( 40, 40 ) );
824 controls.push_back( CreateLeafControl( 60, 60 ) );
825 controls.push_back( CreateLeafControl( 80, 80 ) );
826 controls.push_back( CreateLeafControl( 100, 100 ) );
828 for( auto&& iter : controls )
832 vbox.SetParentOrigin( ParentOrigin::CENTER );
833 vbox.SetAnchorPoint( AnchorPoint::CENTER );
835 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
838 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
840 // Ensure layouting happens
841 application.SendNotification();
842 application.Render();
844 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
845 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
847 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
848 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
849 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
851 // 3rd control is set to match parent - this should also be 100 wide
852 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
853 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
854 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
855 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
857 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
858 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
859 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
860 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
866 int UtcDaliLayouting_VboxLayout03(void)
868 ToolkitTestApplication application;
869 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
871 Stage stage = Stage::GetCurrent();
873 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
874 // LayoutGroup for this to happen automatically.
876 // For this test, add an hbox instead
877 auto hbox = Control::New();
878 auto hboxLayout = HboxLayout::New();
879 DevelControl::SetLayout( hbox, hboxLayout );
880 hbox.SetName( "Hbox");
883 auto vbox = Control::New();
884 auto vboxLayout = VboxLayout::New();
885 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
887 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
889 DevelControl::SetLayout( vbox, vboxLayout );
890 vbox.SetName( "Vbox");
893 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
894 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
896 std::vector< Control > controls;
897 controls.push_back( CreateLeafControl( 40, 40 ) );
898 controls.push_back( CreateLeafControl( 60, 60 ) );
899 controls.push_back( CreateLeafControl( 80, 80 ) );
900 controls.push_back( CreateLeafControl( 100, 100 ) );
902 for( auto&& iter : controls )
906 vbox.SetParentOrigin( ParentOrigin::CENTER );
907 vbox.SetAnchorPoint( AnchorPoint::CENTER );
909 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
912 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
914 // Ensure layouting happens
915 application.SendNotification();
916 application.Render();
918 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
919 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
921 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
922 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
923 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
925 // 3rd control is set to match parent - this should also be 100 wide
926 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
927 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
928 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
929 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
931 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
932 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
933 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
934 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );