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/absolute-layout.h>
25 #include <dali-toolkit/devel-api/layouting/linear-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 = LinearLayout::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 );
85 auto newHBoxLayout = LinearLayout::New();
86 newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
87 DevelControl::SetLayout( hbox, newHBoxLayout );
89 application.SendNotification();
92 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
93 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
94 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
95 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
100 int UtcDaliLayouting_HboxLayout02(void)
102 ToolkitTestApplication application;
103 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
105 Stage stage = Stage::GetCurrent();
107 auto hbox1 = Control::New();
108 auto hboxLayout1 = LinearLayout::New();
109 DevelControl::SetLayout( hbox1, hboxLayout1 );
111 auto hbox2 = Control::New();
112 auto hboxLayout2 = LinearLayout::New();
113 DevelControl::SetLayout( hbox2, hboxLayout2 );
115 hbox1.SetName( "HBox1");
116 hbox2.SetName( "HBox2");
118 std::vector< Control > controls;
119 controls.push_back( CreateLeafControl( 20, 40 ) );
120 controls.push_back( CreateLeafControl( 30, 50 ) );
121 controls.push_back( CreateLeafControl( 40, 60 ) );
122 controls.push_back( CreateLeafControl( 50, 70 ) );
124 controls.push_back( CreateLeafControl( 25, 40 ) );
125 controls.push_back( CreateLeafControl( 35, 50 ) );
126 controls.push_back( CreateLeafControl( 45, 60 ) );
127 controls.push_back( CreateLeafControl( 55, 70 ) );
130 for( auto&& iter : controls )
142 hbox1.SetParentOrigin( ParentOrigin::CENTER );
143 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
144 hbox2.SetParentOrigin( ParentOrigin::CENTER );
145 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
147 auto hbox3 = Control::New();
148 auto hboxLayout3 = LinearLayout::New();
149 DevelControl::SetLayout( hbox3, hboxLayout3 );
151 hbox3.SetParentOrigin( ParentOrigin::CENTER );
152 hbox3.SetName( "HBox3");
158 // Ensure layouting happens
159 application.SendNotification();
160 application.Render();
163 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
164 // hbox left justifies elements
165 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
166 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
167 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
168 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
170 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
171 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
172 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
173 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
176 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
177 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
178 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
179 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
181 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
182 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
183 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
184 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
186 // Test hbox1 and 2 are sized to wrap their content
187 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
188 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
189 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
190 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
192 // Test hbox3 matches parent (root layer)
193 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
194 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
200 int UtcDaliLayouting_HboxLayout03(void)
202 ToolkitTestApplication application;
203 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
205 Stage stage = Stage::GetCurrent();
207 auto hbox1 = Control::New();
208 auto hboxLayout1 = LinearLayout::New();
209 DevelControl::SetLayout( hbox1, hboxLayout1 );
211 auto hbox2 = Control::New();
212 auto hboxLayout2 = LinearLayout::New();
213 DevelControl::SetLayout( hbox2, hboxLayout2 );
215 hbox1.SetName( "HBox1");
216 hbox2.SetName( "HBox2");
217 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
218 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
219 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
220 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
222 std::vector< Control > controls;
223 controls.push_back( CreateLeafControl( 20, 40 ) );
224 controls.push_back( CreateLeafControl( 30, 50 ) );
225 controls.push_back( CreateLeafControl( 40, 60 ) );
226 controls.push_back( CreateLeafControl( 50, 70 ) );
228 controls.push_back( CreateLeafControl( 25, 40 ) );
229 controls.push_back( CreateLeafControl( 35, 50 ) );
230 controls.push_back( CreateLeafControl( 45, 60 ) );
231 controls.push_back( CreateLeafControl( 55, 70 ) );
234 for( auto&& iter : controls )
246 hbox1.SetParentOrigin( ParentOrigin::CENTER );
247 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
248 hbox2.SetParentOrigin( ParentOrigin::CENTER );
249 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
251 auto hbox3 = Control::New();
252 auto hboxLayout3 = LinearLayout::New();
253 DevelControl::SetLayout( hbox3, hboxLayout3);
255 hbox3.SetParentOrigin( ParentOrigin::CENTER );
256 hbox3.SetName( "HBox3");
262 //std::ostringstream oss;
263 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
264 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
266 // Ensure layouting happens
267 application.SendNotification();
268 application.Render();
271 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
272 // hbox left justifies elements
273 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
274 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
275 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
276 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
278 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
279 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
280 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
281 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
283 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
284 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
285 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
286 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
288 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
289 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
290 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
291 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
293 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
294 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
295 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
296 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
298 // Test hbox3 matches parent (root layer)
299 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
300 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
305 int UtcDaliLayouting_HboxLayout04(void)
307 ToolkitTestApplication application;
308 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
310 Stage stage = Stage::GetCurrent();
312 auto hbox1 = Control::New();
313 auto hboxLayout1 = LinearLayout::New();
314 DevelControl::SetLayout( hbox1, hboxLayout1 );
316 auto hbox2 = Control::New();
317 auto hboxLayout2 = LinearLayout::New();
318 DevelControl::SetLayout( hbox2, hboxLayout2 );
320 hbox1.SetName( "HBox1"); // Default spec is to wrap content
321 hbox2.SetName( "HBox2");
322 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
323 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
324 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
325 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
327 std::vector< Control > controls;
328 controls.push_back( CreateLeafControl( 80, 40 ) );
329 controls.push_back( CreateLeafControl( 80, 50 ) );
330 controls.push_back( CreateLeafControl( 80, 60 ) );
331 controls.push_back( CreateLeafControl( 80, 70 ) );
333 controls.push_back( CreateLeafControl( 80, 40 ) );
334 controls.push_back( CreateLeafControl( 80, 50 ) );
335 controls.push_back( CreateLeafControl( 80, 60 ) );
336 controls.push_back( CreateLeafControl( 80, 70 ) );
339 for( auto&& iter : controls )
352 controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
353 auto hbox3 = Control::New();
354 auto hboxLayout3 = LinearLayout::New();
355 DevelControl::SetLayout( hbox3, hboxLayout3 );
357 hbox3.SetParentOrigin( ParentOrigin::CENTER );
358 hbox3.SetName( "HBox3");
363 //std::ostringstream oss;
364 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
365 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
367 // Ensure layouting happens
368 application.SendNotification();
369 application.Render();
372 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
373 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
374 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
375 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
377 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
378 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
379 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
380 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
382 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
383 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
384 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
385 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
387 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
388 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
389 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
390 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
392 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
393 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
394 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
395 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
398 // Test hbox3 matches parent (root layer)
399 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
400 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
405 int UtcDaliLayouting_HboxLayout05(void)
407 ToolkitTestApplication application;
408 tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
410 Stage stage = Stage::GetCurrent();
411 auto hbox = Control::New();
412 auto hboxLayout = LinearLayout::New();
413 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
414 DevelControl::SetLayout( hbox, hboxLayout );
415 hbox.SetName( "HBox");
417 std::vector< Control > controls;
418 controls.push_back( CreateLeafControl( 40, 40 ) );
419 controls.push_back( CreateLeafControl( 60, 40 ) );
420 controls.push_back( CreateLeafControl( 80, 40 ) );
421 controls.push_back( CreateLeafControl( 100, 40 ) );
423 for( auto&& iter : controls )
426 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
427 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
430 hbox.SetParentOrigin( ParentOrigin::CENTER );
431 hbox.SetAnchorPoint( AnchorPoint::CENTER );
434 // Ensure layouting happens
435 application.SendNotification();
436 application.Render();
438 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
439 // hbox left justifies elements
440 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
441 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
442 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
443 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
445 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
446 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
447 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
448 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
455 int UtcDaliLayouting_HboxLayout_Padding01(void)
457 ToolkitTestApplication application;
458 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
460 Stage stage = Stage::GetCurrent();
461 auto hbox = Control::New();
462 auto hboxLayout = LinearLayout::New();
463 DevelControl::SetLayout( hbox, hboxLayout );
464 hbox.SetName( "HBox");
466 std::vector< Control > controls;
467 controls.push_back( CreateLeafControl( 40, 40 ) );
468 controls.push_back( CreateLeafControl( 60, 40 ) );
469 controls.push_back( CreateLeafControl( 80, 40 ) );
470 controls.push_back( CreateLeafControl( 100, 40 ) );
472 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
473 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
474 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
476 for( auto&& iter : controls )
480 hbox.SetParentOrigin( ParentOrigin::CENTER );
481 hbox.SetAnchorPoint( AnchorPoint::CENTER );
484 // Ensure layouting happens
485 application.SendNotification();
486 application.Render();
488 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
489 // hbox left justifies elements
490 tet_infoline("Test Child Actor Position");
491 float xPositionOfControlBeingTested = 0.0f;
492 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
494 0.0f ), 0.0001f, TEST_LOCATION );
495 xPositionOfControlBeingTested += 40.0f;
497 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
498 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
499 0.0001f, TEST_LOCATION );
501 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
502 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
504 xPositionOfControlBeingTested += 80.0f;
505 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
507 tet_infoline("Test Child Actor Size");
508 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
510 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
511 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
512 0.0001f, TEST_LOCATION );
514 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
515 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
520 int UtcDaliLayouting_HboxLayout_Padding02(void)
522 ToolkitTestApplication application;
523 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
525 Stage stage = Stage::GetCurrent();
526 auto hbox = Control::New();
527 auto hboxLayout = LinearLayout::New();
528 DevelControl::SetLayout( hbox, hboxLayout );
529 hbox.SetName( "HBox");
531 std::vector< Control > controls;
532 controls.push_back( CreateLeafControl( 40, 40 ) );
533 controls.push_back( CreateLeafControl( 60, 40 ) );
534 controls.push_back( CreateLeafControl( 80, 40 ) );
535 controls.push_back( CreateLeafControl( 100, 40 ) );
537 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
539 for( auto&& iter : controls )
541 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
544 hbox.SetParentOrigin( ParentOrigin::CENTER );
545 hbox.SetAnchorPoint( AnchorPoint::CENTER );
548 // Ensure layouting happens
549 application.SendNotification();
550 application.Render();
552 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
553 // hbox left justifies elements
554 tet_infoline("Test Child Actor Position");
555 float xPositionOfControlBeingTested = 0.0f;
556 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
558 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
559 yPositionOfControlBeingTested,
560 0.0f ), 0.0001f, TEST_LOCATION );
561 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
563 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
564 yPositionOfControlBeingTested,
566 0.0001f, TEST_LOCATION );
568 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
569 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
570 yPositionOfControlBeingTested,
571 0.0f ), 0.0001f, TEST_LOCATION );
573 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
574 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
575 yPositionOfControlBeingTested,
576 0.0f ), 0.0001f, TEST_LOCATION );
578 tet_infoline("Test Child Actor Size");
579 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
580 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
581 0.0f ), 0.0001f, TEST_LOCATION );
583 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
584 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
585 0.0f ), 0.0001f, TEST_LOCATION );
587 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
588 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
589 0.0f ), 0.0001f, TEST_LOCATION );
591 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
592 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
593 0.0f ), 0.0001f, TEST_LOCATION );
599 int UtcDaliLayouting_HboxLayout_Padding03(void)
601 ToolkitTestApplication application;
602 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Adding Changing padding on a single child");
604 Stage stage = Stage::GetCurrent();
605 auto hbox = Control::New();
606 auto hboxLayout = LinearLayout::New();
607 DevelControl::SetLayout( hbox, hboxLayout );
608 hbox.SetName( "HBox");
610 std::vector< Control > controls;
611 controls.push_back( CreateLeafControl( 40, 40 ) );
612 controls.push_back( CreateLeafControl( 40, 40 ) );
613 controls.push_back( CreateLeafControl( 40, 40 ) );
615 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
616 tet_printf( "\nAdding Padding to control at index 1 \n" );
617 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
619 for( auto&& iter : controls )
623 hbox.SetParentOrigin( ParentOrigin::CENTER );
624 hbox.SetAnchorPoint( AnchorPoint::CENTER );
627 // Ensure layouting happens
628 application.SendNotification();
629 application.Render();
631 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
632 // hbox left justifies elements
633 tet_infoline("Test Child Actor Position");
634 float xPositionOfControlBeingTested = 0.0f;
635 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
637 0.0f ), 0.0001f, TEST_LOCATION );
638 xPositionOfControlBeingTested += 40.0f;
640 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
641 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
642 0.0001f, TEST_LOCATION );
644 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
645 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
647 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
648 tet_printf( "\nChanging Padding to control at index 1 \n" );
649 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
651 // Ensure layouting happens
652 application.SendNotification();
653 application.Render();
655 xPositionOfControlBeingTested = 0.0f; // reset
657 tet_infoline("Test Child Actor Position");
658 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
660 0.0f ), 0.0001f, TEST_LOCATION );
661 xPositionOfControlBeingTested += 40.0f;
663 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
664 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
665 0.0001f, TEST_LOCATION );
667 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
668 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
669 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
671 tet_infoline("Test Child Actor Size");
672 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
674 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
675 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
676 0.0001f, TEST_LOCATION );
678 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
685 int UtcDaliLayouting_HboxLayout_Margin01(void)
687 ToolkitTestApplication application;
688 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
690 Stage stage = Stage::GetCurrent();
691 auto hbox = Control::New();
692 auto hboxLayout = LinearLayout::New();
693 DevelControl::SetLayout( hbox, hboxLayout );
694 hbox.SetName( "HBox");
696 std::vector< Control > controls;
697 controls.push_back( CreateLeafControl( 40, 40 ) );
698 controls.push_back( CreateLeafControl( 60, 40 ) );
699 controls.push_back( CreateLeafControl( 80, 40 ) );
700 controls.push_back( CreateLeafControl( 100, 40 ) );
702 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
703 tet_printf( "\nAdding Margin to control at index 1 \n" );
704 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
706 for( auto&& iter : controls )
710 hbox.SetParentOrigin( ParentOrigin::CENTER );
711 hbox.SetAnchorPoint( AnchorPoint::CENTER );
714 // Ensure layouting happens
715 application.SendNotification();
716 application.Render();
718 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
719 // hbox left justifies elements
720 tet_infoline("Test Child Actor Position");
721 auto xPositionOfControlBeingTested = 0.0f;
722 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
724 0.0f ), 0.0001f, TEST_LOCATION );
725 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
727 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
728 380.0f + CONTROL_MARGIN.top, 0.0f ),
729 0.0001f, TEST_LOCATION );
731 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
732 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
734 xPositionOfControlBeingTested += 80.0f;
735 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
737 tet_infoline("Test Child Actor Size is the same after Margin added");
738 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
739 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
740 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
741 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
747 int UtcDaliLayouting_VboxLayout01(void)
749 ToolkitTestApplication application;
750 tet_infoline(" UtcDaliLayouting_VboxLayout01");
752 Stage stage = Stage::GetCurrent();
753 auto vbox = Control::New();
754 auto vboxLayout = LinearLayout::New();
755 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
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 = LinearLayout::New();
815 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
816 DevelControl::SetLayout( vbox, vboxLayout );
817 vbox.SetName( "Vbox");
818 rootControl.Add( vbox );
820 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
821 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
823 std::vector< Control > controls;
824 controls.push_back( CreateLeafControl( 40, 40 ) );
825 controls.push_back( CreateLeafControl( 60, 60 ) );
826 controls.push_back( CreateLeafControl( 80, 80 ) );
827 controls.push_back( CreateLeafControl( 100, 100 ) );
829 for( auto&& iter : controls )
833 vbox.SetParentOrigin( ParentOrigin::CENTER );
834 vbox.SetAnchorPoint( AnchorPoint::CENTER );
836 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
839 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
841 // Ensure layouting happens
842 application.SendNotification();
843 application.Render();
845 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
846 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
848 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
849 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
850 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
852 // 3rd control is set to match parent - this should also be 100 wide
853 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
854 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
855 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
856 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
858 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
859 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
860 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
861 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
867 int UtcDaliLayouting_VboxLayout03(void)
869 ToolkitTestApplication application;
870 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
872 Stage stage = Stage::GetCurrent();
874 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
875 // LayoutGroup for this to happen automatically.
877 // For this test, add an hbox instead
878 auto hbox = Control::New();
879 auto hboxLayout = LinearLayout::New();
880 DevelControl::SetLayout( hbox, hboxLayout );
881 hbox.SetName( "Hbox");
884 auto vbox = Control::New();
885 auto vboxLayout = LinearLayout::New();
886 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
887 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
889 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
891 DevelControl::SetLayout( vbox, vboxLayout );
892 vbox.SetName( "Vbox");
895 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
896 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
898 std::vector< Control > controls;
899 controls.push_back( CreateLeafControl( 40, 40 ) );
900 controls.push_back( CreateLeafControl( 60, 60 ) );
901 controls.push_back( CreateLeafControl( 80, 80 ) );
902 controls.push_back( CreateLeafControl( 100, 100 ) );
904 for( auto&& iter : controls )
908 vbox.SetParentOrigin( ParentOrigin::CENTER );
909 vbox.SetAnchorPoint( AnchorPoint::CENTER );
911 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
914 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
916 // Ensure layouting happens
917 application.SendNotification();
918 application.Render();
920 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
921 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
923 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
924 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
925 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
927 // 3rd control is set to match parent - this should also be 100 wide
928 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
929 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
930 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
931 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
933 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
934 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
935 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
936 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );