2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <toolkit-event-thread-callback.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/control-devel.h>
25 #include <dali-toolkit/devel-api/layouting/absolute-layout.h>
26 #include <dali-toolkit/devel-api/layouting/linear-layout.h>
27 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
28 #include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
29 #include <dali/devel-api/actors/actor-devel.h>
31 #include <../custom-layout.h>
33 #include <layout-utils.h>
36 using namespace Toolkit;
41 // Turns the given control into a Root layout control and adds it to the stage.
42 void SetupRootLayoutControl( Control& rootControl )
44 rootControl = Control::New();
45 auto absoluteLayout = AbsoluteLayout::New();
46 DevelControl::SetLayout( rootControl, absoluteLayout );
47 rootControl.SetName( "RootAbsoluteLayout" );
48 Stage stage = Stage::GetCurrent();
49 stage.Add( rootControl );
52 } // unnamed namespace
54 void utc_dali_toolkit_layouting_startup(void)
56 test_return_value = TET_UNDEF;
59 void utc_dali_toolkit_layouting_cleanup(void)
61 test_return_value = TET_PASS;
64 int UtcDaliLayouting_LayoutLength_Types(void)
66 tet_infoline("UtcDaliLayouting_LayoutLength Types");
68 // testing that operators return correct type
71 auto value = LayoutLength( 10 ) + LayoutLength();
72 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
75 auto value = LayoutLength( 10 ) + 20;
76 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
79 auto value = 22 + LayoutLength( 10 );
80 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
83 auto value = LayoutLength( 10 ) + 2.1f;
84 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
87 auto value = 2.2f + LayoutLength( 10 );
88 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
92 auto value = LayoutLength() - LayoutLength( 10 );
93 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
96 auto value = LayoutLength( 10 ) - 99;
97 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
100 auto value = 20 - LayoutLength( 10 );
101 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
104 auto value = LayoutLength( 10 ) - 9.9f;
105 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
108 auto value = 2.0f - LayoutLength( 10 );
109 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
114 auto value = LayoutLength() * LayoutLength( 10 );
115 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
118 auto value = LayoutLength( 10 ) * 2;
119 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
122 auto value = 10 * LayoutLength( 10 );
123 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
126 auto value = LayoutLength( 10 ) * 2.1f;
127 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
130 auto value = 1.0f * LayoutLength( 10 );
131 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
135 auto value = LayoutLength( 10 ) / 2.0f;
136 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
141 auto value = ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
142 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
145 auto value = 20 + ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
146 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
152 int UtcDaliLayouting_LayoutLength_Values(void)
154 tet_infoline("UtcDaliLayouting_LayoutLength Values");
158 LayoutLength value = LayoutLength( 10 ) + LayoutLength();
159 DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
162 LayoutLength value = LayoutLength( 10 ) + 20;
163 DALI_TEST_EQUALS( value.AsInteger(), 30.0f, 0.0001f, TEST_LOCATION );
166 LayoutLength value = 22 - LayoutLength( 10 );
167 DALI_TEST_EQUALS( value.AsInteger(), 12.0f, 0.0001f, TEST_LOCATION );
170 LayoutLength value = LayoutLength( 10 ) + 2.1f;
171 DALI_TEST_EQUALS( value.AsDecimal(), 12.1f, 0.0001f, TEST_LOCATION );
172 DALI_TEST_EQUALS( value.AsTruncated(), 12.0f, 0.0001f, TEST_LOCATION );
175 LayoutLength value = 2.3f - LayoutLength( 10 );
176 DALI_TEST_EQUALS( value.AsDecimal(), -7.7f, 0.0001f, TEST_LOCATION );
177 DALI_TEST_EQUALS( value.AsInteger(), -8.0f, 0.0001f, TEST_LOCATION );
178 DALI_TEST_EQUALS( value.AsTruncated(), -7.0f, 0.0001f, TEST_LOCATION );
182 LayoutLength value = LayoutLength() - LayoutLength( 10 );
183 DALI_TEST_EQUALS( value.AsInteger(), -10.0f, 0.0001f, TEST_LOCATION );
186 LayoutLength value = LayoutLength( 10 ) - 99;
187 DALI_TEST_EQUALS( value.AsInteger(), -89.0f, 0.0001f, TEST_LOCATION );
190 LayoutLength value = 20 - LayoutLength( 10 );
191 DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
192 DALI_TEST_EQUALS( value.AsTruncated(), 10.f, 0.0001f, TEST_LOCATION );
195 LayoutLength value = LayoutLength( 10 ) - 9.9f;
196 DALI_TEST_EQUALS( value.AsInteger(), 0.0f, 0.0001f, TEST_LOCATION );
197 DALI_TEST_EQUALS( value.AsDecimal(), 0.1f, 0.0001f, TEST_LOCATION );
198 DALI_TEST_EQUALS( value.AsTruncated(), 0.0f, 0.0001f, TEST_LOCATION );
201 LayoutLength value = 10.9f - LayoutLength( 10 );
202 DALI_TEST_EQUALS( value.AsInteger(), 1.0f, 0.0001f, TEST_LOCATION );
203 DALI_TEST_EQUALS( value.AsDecimal(), 0.9f, 0.0001f, TEST_LOCATION );
204 DALI_TEST_EQUALS( value.AsTruncated(), 0.0f, 0.0001f, TEST_LOCATION );
208 LayoutLength value = LayoutLength() * LayoutLength( 10 );
209 DALI_TEST_EQUALS( value.AsInteger(), 0.0f, 0.0001f, TEST_LOCATION );
212 LayoutLength value = LayoutLength(1) * 10;
213 DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
216 LayoutLength value = 11 * LayoutLength( 10 );
217 DALI_TEST_EQUALS( value.AsInteger(), 110.0f, 0.0001f, TEST_LOCATION );
220 LayoutLength value = LayoutLength( 10 ) * 2.12f;
221 DALI_TEST_EQUALS( value.AsDecimal(), 21.2f, 0.0001f, TEST_LOCATION );
222 DALI_TEST_EQUALS( value.AsInteger(), 21.0f, 0.0001f, TEST_LOCATION );
223 DALI_TEST_EQUALS( value.AsTruncated(), 21.0f, 0.0001f, TEST_LOCATION );
226 LayoutLength value = 2.189f * LayoutLength( 10 );
227 DALI_TEST_EQUALS( value.AsDecimal(), 21.89f, 0.0001f, TEST_LOCATION );
228 DALI_TEST_EQUALS( value.AsInteger(), 22.0f, 0.0001f, TEST_LOCATION );
229 DALI_TEST_EQUALS( value.AsTruncated(), 21.0f, 0.0001f, TEST_LOCATION );
233 LayoutLength value = LayoutLength( 11 ) / 2.0f;
234 DALI_TEST_EQUALS( value.AsDecimal(), 5.5f, 0.0001f, TEST_LOCATION );
235 DALI_TEST_EQUALS( value.AsInteger(), 6.0f, 0.0001f, TEST_LOCATION );
241 value = 20 + ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
242 DALI_TEST_EQUALS( value.AsInteger(), 33.0f, 0.0001f, TEST_LOCATION );
243 DALI_TEST_EQUALS( value.AsDecimal(), 33.3333f, 0.0001f, TEST_LOCATION );
246 uint16_t padding( 1 );
247 LayoutLength right(35), left(10), mTotalLength(2);
249 value = padding + ( right - left - mTotalLength ) / 2.0f;
250 // = 1 + ( 35 - 10 - 2 ) / 2
251 DALI_TEST_EQUALS( value.AsInteger(), 13.0f, 0.0001f, TEST_LOCATION );
252 DALI_TEST_EQUALS( value.AsDecimal(), 12.5f, 0.0001f, TEST_LOCATION );
255 uint16_t padding = 1, top = 2, bottom = 3;
256 LayoutLength childSpace( 44 ), childHeight( 23 );
258 value = padding + ( ( childSpace - childHeight ) / 2.0f ) + top - bottom;
259 // = 1 + ( ( 44 - 23 ) / 2 ) + 2 - 3
260 DALI_TEST_EQUALS( value.AsInteger(), 11.0f, 0.0001f, TEST_LOCATION );
261 DALI_TEST_EQUALS( value.AsDecimal(), 10.5f, 0.0001f, TEST_LOCATION );
267 int UtcDaliLayouting_LayoutLength_Operators(void)
269 tet_infoline("UtcDaliLayouting_LayoutLength operators");
272 LayoutLength value = 10;
273 DALI_TEST_EQUALS( (int)value.AsInteger(), 10, TEST_LOCATION );
275 DALI_TEST_EQUALS( (int)value.AsInteger(), 11, TEST_LOCATION );
277 DALI_TEST_EQUALS( (int)value.AsInteger(), -1, TEST_LOCATION );
278 LayoutLength value2 = value;
279 DALI_TEST_EQUALS( value == value2, true, TEST_LOCATION );
281 DALI_TEST_EQUALS( value != value2, true, TEST_LOCATION );
282 DALI_TEST_EQUALS( value < value2, true, TEST_LOCATION );
283 DALI_TEST_EQUALS( value <= value2, true, TEST_LOCATION );
285 DALI_TEST_EQUALS( value > value2, true, TEST_LOCATION );
286 DALI_TEST_EQUALS( value >= value2, true, TEST_LOCATION );
290 LayoutLength value( 123 );
291 std::stringstream ss;
293 DALI_TEST_EQUALS( ss.str(), "123", TEST_LOCATION );
296 LayoutLength value( 0.123f );
297 std::stringstream ss;
299 DALI_TEST_EQUALS( ss.str(), "0.123", TEST_LOCATION );
304 int UtcDaliLayouting_HboxLayout01(void)
306 ToolkitTestApplication application;
307 tet_infoline(" UtcDaliLayouting_HboxLayout01");
309 Stage stage = Stage::GetCurrent();
310 auto hbox = Control::New();
311 auto hboxLayout = LinearLayout::New();
312 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
313 DevelControl::SetLayout( hbox, hboxLayout );
314 hbox.SetName( "HBox");
316 std::vector< Control > controls;
317 controls.push_back( CreateLeafControl( 40, 40 ) );
318 controls.push_back( CreateLeafControl( 60, 40 ) );
319 controls.push_back( CreateLeafControl( 80, 40 ) );
320 controls.push_back( CreateLeafControl( 100, 40 ) );
322 for( auto&& iter : controls )
327 hbox.SetParentOrigin( ParentOrigin::CENTER );
328 hbox.SetAnchorPoint( AnchorPoint::CENTER );
331 // Ensure layouting happens
332 application.SendNotification();
333 application.Render();
335 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
336 // hbox left justifies elements
337 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
338 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
339 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
340 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
342 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
343 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
344 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
345 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
348 auto newHBoxLayout = LinearLayout::New();
349 newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
350 DevelControl::SetLayout( hbox, newHBoxLayout );
352 application.SendNotification();
353 application.Render();
355 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
356 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
357 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
358 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
363 int UtcDaliLayouting_HboxLayout02(void)
365 ToolkitTestApplication application;
366 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
368 Stage stage = Stage::GetCurrent();
370 auto hbox1 = Control::New();
371 auto hboxLayout1 = LinearLayout::New();
372 DevelControl::SetLayout( hbox1, hboxLayout1 );
374 auto hbox2 = Control::New();
375 auto hboxLayout2 = LinearLayout::New();
376 DevelControl::SetLayout( hbox2, hboxLayout2 );
378 hbox1.SetName( "HBox1");
379 hbox2.SetName( "HBox2");
381 std::vector< Control > controls;
382 controls.push_back( CreateLeafControl( 20, 40 ) );
383 controls.push_back( CreateLeafControl( 30, 50 ) );
384 controls.push_back( CreateLeafControl( 40, 60 ) );
385 controls.push_back( CreateLeafControl( 50, 70 ) );
387 controls.push_back( CreateLeafControl( 25, 40 ) );
388 controls.push_back( CreateLeafControl( 35, 50 ) );
389 controls.push_back( CreateLeafControl( 45, 60 ) );
390 controls.push_back( CreateLeafControl( 55, 70 ) );
393 for( auto&& iter : controls )
405 hbox1.SetParentOrigin( ParentOrigin::CENTER );
406 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
407 hbox2.SetParentOrigin( ParentOrigin::CENTER );
408 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
410 auto hbox3 = Control::New();
411 auto hboxLayout3 = LinearLayout::New();
412 DevelControl::SetLayout( hbox3, hboxLayout3 );
414 hbox3.SetParentOrigin( ParentOrigin::CENTER );
415 hbox3.SetName( "HBox3");
421 // Ensure layouting happens
422 application.SendNotification();
423 application.Render();
426 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
427 // hbox left justifies elements
428 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
429 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
430 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
431 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
433 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
434 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
435 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
436 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
439 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
440 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
441 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
442 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
444 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
445 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
446 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
447 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
449 // Test hbox1 and 2 are sized to wrap their content
450 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
451 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
452 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
453 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
455 // Test hbox3 matches parent (root layer)
456 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
457 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
463 int UtcDaliLayouting_HboxLayout03(void)
465 ToolkitTestApplication application;
466 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
468 Stage stage = Stage::GetCurrent();
470 auto hbox1 = Control::New();
471 auto hboxLayout1 = LinearLayout::New();
472 DevelControl::SetLayout( hbox1, hboxLayout1 );
474 auto hbox2 = Control::New();
475 auto hboxLayout2 = LinearLayout::New();
476 DevelControl::SetLayout( hbox2, hboxLayout2 );
478 hbox1.SetName( "HBox1");
479 hbox2.SetName( "HBox2");
480 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
481 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
482 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
483 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
485 std::vector< Control > controls;
486 controls.push_back( CreateLeafControl( 20, 40 ) );
487 controls.push_back( CreateLeafControl( 30, 50 ) );
488 controls.push_back( CreateLeafControl( 40, 60 ) );
489 controls.push_back( CreateLeafControl( 50, 70 ) );
491 controls.push_back( CreateLeafControl( 25, 40 ) );
492 controls.push_back( CreateLeafControl( 35, 50 ) );
493 controls.push_back( CreateLeafControl( 45, 60 ) );
494 controls.push_back( CreateLeafControl( 55, 70 ) );
497 for( auto&& iter : controls )
509 hbox1.SetParentOrigin( ParentOrigin::CENTER );
510 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
511 hbox2.SetParentOrigin( ParentOrigin::CENTER );
512 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
514 auto hbox3 = Control::New();
515 auto hboxLayout3 = LinearLayout::New();
516 DevelControl::SetLayout( hbox3, hboxLayout3);
518 hbox3.SetParentOrigin( ParentOrigin::CENTER );
519 hbox3.SetName( "HBox3");
525 //std::ostringstream oss;
526 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
527 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
529 // Ensure layouting happens
530 application.SendNotification();
531 application.Render();
534 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
535 // hbox left justifies elements
536 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
537 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
538 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
539 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
541 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
542 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
543 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
544 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
546 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
547 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
548 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
549 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
551 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
552 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
553 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
554 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
556 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
557 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
558 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
559 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
561 // Test hbox3 matches parent (root layer)
562 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
563 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
568 int UtcDaliLayouting_HboxLayout04(void)
570 ToolkitTestApplication application;
571 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
573 Stage stage = Stage::GetCurrent();
575 auto hbox1 = Control::New();
576 auto hboxLayout1 = LinearLayout::New();
577 DevelControl::SetLayout( hbox1, hboxLayout1 );
579 auto hbox2 = Control::New();
580 auto hboxLayout2 = LinearLayout::New();
581 DevelControl::SetLayout( hbox2, hboxLayout2 );
583 hbox1.SetName( "HBox1"); // Default spec is to wrap content
584 hbox2.SetName( "HBox2");
585 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
586 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
587 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
588 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
590 std::vector< Control > controls;
591 controls.push_back( CreateLeafControl( 80, 40 ) );
592 controls.push_back( CreateLeafControl( 80, 50 ) );
593 controls.push_back( CreateLeafControl( 80, 60 ) );
594 controls.push_back( CreateLeafControl( 80, 70 ) );
596 controls.push_back( CreateLeafControl( 80, 40 ) );
597 controls.push_back( CreateLeafControl( 80, 50 ) );
598 controls.push_back( CreateLeafControl( 80, 60 ) );
599 controls.push_back( CreateLeafControl( 80, 70 ) );
602 for( auto&& iter : controls )
615 controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
616 auto hbox3 = Control::New();
617 auto hboxLayout3 = LinearLayout::New();
618 DevelControl::SetLayout( hbox3, hboxLayout3 );
620 hbox3.SetParentOrigin( ParentOrigin::CENTER );
621 hbox3.SetName( "HBox3");
626 //std::ostringstream oss;
627 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
628 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
630 // Ensure layouting happens
631 application.SendNotification();
632 application.Render();
635 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
636 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
637 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
638 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
640 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
641 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
642 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
643 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
645 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
646 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
647 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
648 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
650 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
651 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
652 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
653 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
655 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
656 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
657 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
658 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
661 // Test hbox3 matches parent (root layer)
662 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
663 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
668 int UtcDaliLayouting_HboxLayout05(void)
670 ToolkitTestApplication application;
671 tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
673 Stage stage = Stage::GetCurrent();
674 auto hbox = Control::New();
675 auto hboxLayout = LinearLayout::New();
676 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
677 DevelControl::SetLayout( hbox, hboxLayout );
678 hbox.SetName( "HBox");
680 std::vector< Control > controls;
681 controls.push_back( CreateLeafControl( 40, 40 ) );
682 controls.push_back( CreateLeafControl( 60, 40 ) );
683 controls.push_back( CreateLeafControl( 80, 40 ) );
684 controls.push_back( CreateLeafControl( 100, 40 ) );
686 for( auto&& iter : controls )
689 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
690 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
693 hbox.SetParentOrigin( ParentOrigin::CENTER );
694 hbox.SetAnchorPoint( AnchorPoint::CENTER );
697 // Ensure layouting happens
698 application.SendNotification();
699 application.Render();
701 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
702 // hbox left justifies elements
703 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
704 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
705 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
706 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
708 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
709 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
710 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
711 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
716 int UtcDaliLayouting_HboxLayout06(void)
718 ToolkitTestApplication application;
719 tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
721 Stage stage = Stage::GetCurrent();
723 auto rootControl = Control::New();
724 auto absoluteLayout = AbsoluteLayout::New();
725 DevelControl::SetLayout( rootControl, absoluteLayout );
726 rootControl.SetName( "AbsoluteLayout" );
727 stage.Add( rootControl );
729 auto hbox = Control::New();
730 auto hboxLayout = LinearLayout::New();
731 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
732 DevelControl::SetLayout( hbox, hboxLayout );
733 hbox.SetName( "HBox" );
735 std::vector< Control > controls;
736 controls.push_back( CreateLeafControl( 40, 40 ) );
737 controls.push_back( CreateLeafControl( 60, 40 ) );
739 for( auto&& iter : controls )
743 hbox.SetParentOrigin( ParentOrigin::CENTER );
744 hbox.SetAnchorPoint( AnchorPoint::CENTER );
745 rootControl.Add( hbox );
747 // Ensure layouting happens
748 application.SendNotification();
749 application.Render();
751 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
752 // hbox left justifies elements
753 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
754 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
756 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
757 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
759 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
762 auto newHBoxLayout = LinearLayout::New();
763 newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
764 DevelControl::SetLayout( hbox, newHBoxLayout );
766 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
767 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
769 application.SendNotification();
770 application.Render();
772 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
774 // Change size specification
775 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
776 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
778 application.SendNotification();
779 application.Render();
781 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
783 // Use WRAP_CONTENT again
784 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
785 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
787 application.SendNotification();
788 application.Render();
790 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
795 int UtcDaliLayouting_HboxLayout07(void)
797 ToolkitTestApplication application;
798 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
800 Stage stage = Stage::GetCurrent();
801 auto hbox = Control::New();
802 auto hboxLayout = LinearLayout::New();
803 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
804 DevelControl::SetLayout( hbox, hboxLayout );
805 hbox.SetName( "HBox");
807 std::vector< Control > controls;
808 controls.push_back( CreateLeafControl( 40, 40 ) );
809 controls.push_back( CreateLeafControl( 60, 40 ) );
810 controls.push_back( CreateLeafControl( 80, 40 ) );
811 controls.push_back( CreateLeafControl( 100, 40 ) );
813 for( auto&& iter : controls )
817 hbox.SetParentOrigin( ParentOrigin::CENTER );
818 hbox.SetAnchorPoint( AnchorPoint::CENTER );
821 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
823 // Ensure layouting happens
824 application.SendNotification();
825 application.Render();
827 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
828 // hbox left justifies elements
829 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
830 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
831 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
832 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
834 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
835 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
836 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
837 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
839 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
841 // Ensure layouting happens
842 application.SendNotification();
843 application.Render();
845 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
846 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
847 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
848 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
850 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
851 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
852 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
853 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
858 int UtcDaliLayouting_HboxLayout08(void)
860 ToolkitTestApplication application;
861 tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation");
863 Stage stage = Stage::GetCurrent();
865 auto rootControl = Control::New();
866 auto absoluteLayout = AbsoluteLayout::New();
867 absoluteLayout.SetAnimateLayout( true );
868 DevelControl::SetLayout( rootControl, absoluteLayout );
869 rootControl.SetName( "AbsoluteLayout" );
870 stage.Add( rootControl );
872 Control control1 = CreateLeafControl( 40, 40 );
873 rootControl.Add( control1 );
875 auto hbox = Control::New();
876 auto hboxLayout = LinearLayout::New();
877 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
878 DevelControl::SetLayout( hbox, hboxLayout );
879 hbox.SetName( "HBox" );
881 Control control2 = CreateLeafControl( 40, 40 );
882 hbox.Add( control2 );
884 hbox.SetParentOrigin( ParentOrigin::CENTER );
885 hbox.SetAnchorPoint( AnchorPoint::CENTER );
886 rootControl.Add( hbox );
888 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION );
889 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION );
890 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION );
891 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION );
893 tet_infoline(" Set hBoxLayout to animate");
894 hboxLayout.SetAnimateLayout( true );
895 tet_infoline(" Set absoluteLayout not to animate");
896 absoluteLayout.SetAnimateLayout( false );
898 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION );
899 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION );
900 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION );
901 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION );
906 int UtcDaliLayouting_HboxLayout09(void)
908 ToolkitTestApplication application;
909 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set alignment");
911 Stage stage = Stage::GetCurrent();
912 auto hbox = Control::New();
913 auto hboxLayout = LinearLayout::New();
914 DevelControl::SetLayout( hbox, hboxLayout );
915 hbox.SetName( "HBox");
917 std::vector< Control > controls;
918 controls.push_back( CreateLeafControl( 40, 40 ) );
919 controls.push_back( CreateLeafControl( 60, 60 ) );
921 for( auto&& iter : controls )
925 hbox.SetParentOrigin( ParentOrigin::CENTER );
926 hbox.SetAnchorPoint( AnchorPoint::CENTER );
929 // Check default orientation
930 DALI_TEST_EQUALS( static_cast<unsigned int>( hboxLayout.GetOrientation() ), static_cast<unsigned int>( LinearLayout::Orientation::HORIZONTAL ), TEST_LOCATION );
931 // Check default alignment
932 DALI_TEST_EQUALS( hboxLayout.GetAlignment(), ( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL ), TEST_LOCATION );
934 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN );
936 // Ensure layouting happens
937 application.SendNotification();
938 application.Render();
940 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
941 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
943 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
944 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
946 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END );
948 // Ensure layouting happens
949 application.SendNotification();
950 application.Render();
952 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
953 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
955 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
956 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
958 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
960 // Ensure layouting happens
961 application.SendNotification();
962 application.Render();
964 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
965 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
967 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
968 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
970 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP );
972 // Ensure layouting happens
973 application.SendNotification();
974 application.Render();
976 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
977 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
979 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
980 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
982 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP );
984 // Ensure layouting happens
985 application.SendNotification();
986 application.Render();
988 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
989 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
991 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
992 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
994 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP );
996 // Ensure layouting happens
997 application.SendNotification();
998 application.Render();
1000 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1001 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1003 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1004 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1006 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1008 // Ensure layouting happens
1009 application.SendNotification();
1010 application.Render();
1012 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1013 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1015 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1016 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1018 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1020 // Ensure layouting happens
1021 application.SendNotification();
1022 application.Render();
1024 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1025 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1027 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1028 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1030 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1032 // Ensure layouting happens
1033 application.SendNotification();
1034 application.Render();
1036 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1037 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1039 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1040 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1042 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL );
1044 // Ensure layouting happens
1045 application.SendNotification();
1046 application.Render();
1048 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1049 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1051 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1052 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1054 hboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1055 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN );
1057 // Ensure layouting happens
1058 application.SendNotification();
1059 application.Render();
1061 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1062 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1064 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1065 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1067 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END );
1069 // Ensure layouting happens
1070 application.SendNotification();
1071 application.Render();
1073 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1074 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1076 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1077 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1079 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
1081 // Ensure layouting happens
1082 application.SendNotification();
1083 application.Render();
1085 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1086 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1088 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1089 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1091 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP );
1093 // Ensure layouting happens
1094 application.SendNotification();
1095 application.Render();
1097 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1098 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1100 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1101 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1103 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP );
1105 // Ensure layouting happens
1106 application.SendNotification();
1107 application.Render();
1109 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1110 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1112 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1113 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1115 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP );
1117 // Ensure layouting happens
1118 application.SendNotification();
1119 application.Render();
1121 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1122 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1124 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1125 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1127 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1129 // Ensure layouting happens
1130 application.SendNotification();
1131 application.Render();
1133 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1134 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1136 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1137 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1139 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1141 // Ensure layouting happens
1142 application.SendNotification();
1143 application.Render();
1145 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1146 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1148 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1149 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1151 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1153 // Ensure layouting happens
1154 application.SendNotification();
1155 application.Render();
1157 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1158 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1160 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1161 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1163 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL );
1165 // Ensure layouting happens
1166 application.SendNotification();
1167 application.Render();
1169 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1170 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1172 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1173 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1178 int UtcDaliLayouting_HboxLayout_Weight(void)
1180 ToolkitTestApplication application;
1181 tet_infoline( " UtcDaliLayouting_HboxLayout_Weight - Test LinearLayout weight horizontally" );
1183 Stage stage = Stage::GetCurrent();
1184 auto hbox = Control::New();
1185 auto hboxLayout = LinearLayout::New();
1186 DevelControl::SetLayout( hbox, hboxLayout );
1187 hbox.SetName( "HBox" );
1189 std::vector<Control> controls;
1190 controls.push_back( CreateLeafControl( 40, 40 ) );
1191 controls.push_back( CreateLeafControl( 60, 40 ) );
1192 controls.push_back( CreateLeafControl( 80, 40 ) );
1193 controls.push_back( CreateLeafControl( 100, 40 ) );
1195 // Set weight for each leaf to use quarter of available space
1196 // 480 * 0.25, 480 * 0.25, 480 * 0.25, 480 * 0.25,
1197 // width spec has to be set to 0 so not to consume any extra space.
1198 for( auto&& iter : controls )
1200 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1201 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1202 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1206 hbox.SetParentOrigin( ParentOrigin::CENTER );
1207 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1210 // Ensure layouting happens
1211 application.SendNotification();
1212 application.Render();
1214 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1215 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1216 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1217 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 360.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1219 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1220 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1221 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1222 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1224 // Set weight for 3, 4 leafs to use all remaining available space after 1, 2 content sized leafs.
1225 // 40, 60, (480 - 40 - 60) * 0.5, (480 - 40 - 60) * 0.5
1226 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1227 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1228 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1229 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1230 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1231 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1233 // Ensure layouting happens
1234 application.SendNotification();
1235 application.Render();
1237 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1238 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1239 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1240 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 290.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1242 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1243 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1244 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 190.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1245 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 190.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1247 // Add intrinsic width for 3rd leaf so now we should get
1248 // 40, 60, (480 - 40 - 60 - 80) * 0.5 + 80, (480 - 40 - 60 - 80) * 0.5
1249 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 80 );
1251 // Ensure layouting happens
1252 application.SendNotification();
1253 application.Render();
1255 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1256 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1257 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1258 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1260 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1261 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1262 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1263 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1265 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1266 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1267 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1268 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1269 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1270 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1271 controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 40 );
1272 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1274 // Ensure layouting happens
1275 application.SendNotification();
1276 application.Render();
1278 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1279 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1280 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1281 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1283 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 110.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1284 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 220.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1285 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 110.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1286 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1288 // WRAP_CONTENT doesn't affect weight
1289 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1290 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1291 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1292 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1293 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1294 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1295 controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1296 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1298 // Ensure layouting happens
1299 application.SendNotification();
1300 application.Render();
1302 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1303 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1304 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1305 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1307 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1308 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1309 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1310 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 300.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1312 // MATCH_PARENT doesn't affect weight
1313 for( auto&& iter : controls )
1315 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1316 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1317 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1320 // Ensure layouting happens
1321 application.SendNotification();
1322 application.Render();
1324 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1325 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1326 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1327 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 360.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1329 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1330 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1331 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1332 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1334 const Extents CONTROL_MARGIN = Extents( 10, 10, 0, 0 );
1335 for( auto&& iter : controls )
1337 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1338 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1339 iter.SetProperty( Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1342 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1343 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1344 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1345 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1347 application.SendNotification();
1348 application.Render();
1350 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 10.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1351 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 70.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1352 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 150.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1353 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 250.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1355 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1356 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1357 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1358 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 220.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1363 int UtcDaliLayouting_VboxLayout_Weight(void)
1365 ToolkitTestApplication application;
1366 tet_infoline( " UtcDaliLayouting_VboxLayout_Weight - Test LinearLayout weight vertically" );
1368 Stage stage = Stage::GetCurrent();
1369 auto vbox = Control::New();
1370 auto vboxLayout = LinearLayout::New();
1371 vboxLayout.SetOrientation( Dali::Toolkit::LinearLayout::Orientation::VERTICAL );
1372 DevelControl::SetLayout( vbox, vboxLayout );
1373 vbox.SetName( "VBox" );
1375 std::vector<Control> controls;
1376 controls.push_back( CreateLeafControl( 40, 40 ) );
1377 controls.push_back( CreateLeafControl( 60, 60 ) );
1378 controls.push_back( CreateLeafControl( 80, 80 ) );
1379 controls.push_back( CreateLeafControl( 100, 100 ) );
1381 // Set weight for each leaf to use quarter of available space
1382 // 800 * 0.25, 800 * 0.25, 800 * 0.25, 800 * 0.25,
1383 // width spec has to be set to 0 so not to consume any extra space.
1384 for( auto&& iter : controls )
1386 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1387 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1388 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1392 vbox.SetParentOrigin( ParentOrigin::CENTER );
1393 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1396 // Ensure layouting happens
1397 application.SendNotification();
1398 application.Render();
1400 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1401 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1402 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1403 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 600.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1405 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1406 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1407 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1408 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1410 // Set weight for 3, 4 leafs to use all remaining available space after 1, 2 content sized leafs.
1411 // 40, 60, (800 - 40 - 60) * 0.5, (800 - 40 - 60) * 0.5
1412 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1413 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1414 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1415 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1416 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1417 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1419 // Ensure layouting happens
1420 application.SendNotification();
1421 application.Render();
1423 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1424 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1425 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1426 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 450.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1428 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1429 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1430 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1431 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1433 // Add intrinsic width for 3rd leaf so now we should get
1434 // 40, 60, (800 - 40 - 60 - 100) * 0.5 + 100, (800 - 40 - 60 - 100) * 0.5
1435 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
1437 // Ensure layouting happens
1438 application.SendNotification();
1439 application.Render();
1441 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1442 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1443 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1444 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 500.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1446 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1447 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1448 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1449 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1451 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1452 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1453 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1454 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1455 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1456 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1457 controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
1458 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1460 // Ensure layouting happens
1461 application.SendNotification();
1462 application.Render();
1464 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1465 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1466 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 525.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1467 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1469 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1470 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1471 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1472 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1474 // WRAP_CONTENT doesn't affect weight
1475 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1476 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1477 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1478 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1479 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1480 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1481 controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1482 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1484 // Ensure layouting happens
1485 application.SendNotification();
1486 application.Render();
1488 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1489 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1490 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1491 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1493 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1494 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1495 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1496 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 620.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1498 // MATCH_PARENT doesn't affect weight
1499 for( auto&& iter : controls )
1501 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1502 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1503 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1506 // Ensure layouting happens
1507 application.SendNotification();
1508 application.Render();
1510 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1511 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1512 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1513 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 600.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1515 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1516 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1517 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1518 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1520 const Extents CONTROL_MARGIN = Extents( 0, 0, 10, 10 );
1521 for( auto&& iter : controls )
1523 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1524 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1525 iter.SetProperty( Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1528 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1529 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1530 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1531 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1533 application.SendNotification();
1534 application.Render();
1536 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1537 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1538 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1539 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 250.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1541 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1542 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1543 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1544 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 540.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1549 int UtcDaliLayouting_NestedLinearLayout_Weight(void)
1551 ToolkitTestApplication application;
1552 tet_infoline("UtcDaliLayouting_NestedLinearLayout_Weight - test weighted children with wrapped parent");
1554 Stage stage = Stage::GetCurrent();
1555 auto rootControl = Control::New();
1556 rootControl.SetName( "AbsoluteLayout");
1557 auto rootLayout = AbsoluteLayout::New();
1558 DevelControl::SetLayout( rootControl, rootLayout );
1559 rootControl.SetAnchorPoint( AnchorPoint::CENTER );
1560 rootControl.SetParentOrigin( ParentOrigin::CENTER );
1561 stage.Add( rootControl );
1563 auto hbox = Control::New();
1564 auto hboxLayout = LinearLayout::New();
1565 DevelControl::SetLayout( hbox, hboxLayout );
1566 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1567 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1569 std::vector< Control > controls;
1570 controls.push_back( CreateLeafControl( 40, 40 ) );
1571 controls.push_back( CreateLeafControl( 60, 60 ) );
1573 // set equal share of wrapped content width (40 + 60 = 100) for both children 100 * 0.5, 100 * 0.5
1574 for( auto&& iter : controls )
1576 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1577 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1578 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1582 hbox.SetParentOrigin( ParentOrigin::CENTER );
1583 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1584 rootControl.Add( hbox );
1586 // Ensure layouting happens
1587 application.SendNotification();
1588 application.Render();
1590 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1591 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1593 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1594 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1596 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1597 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1599 hboxLayout.SetOrientation(Dali::Toolkit::LinearLayout::Orientation::VERTICAL);
1601 // set equal share of wrapped content height (40 + 60 = 100) for both children 100 * 0.5, 100 * 0.5
1602 for( auto&& iter : controls )
1604 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1605 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1606 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1609 // Ensure layouting happens
1610 application.SendNotification();
1611 application.Render();
1613 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1614 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1616 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1617 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1619 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1620 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1628 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/broken.png";
1631 int UtcDaliLayouting_HboxLayout_ImageView(void)
1633 ToolkitTestApplication application;
1634 tet_infoline(" UtcDaliLayouting_HboxLayout - Use image view for leaf");
1636 Stage stage = Stage::GetCurrent();
1637 auto hbox = Control::New();
1638 auto hboxLayout = LinearLayout::New();
1639 DevelControl::SetLayout( hbox, hboxLayout );
1640 hbox.SetName( "HBox" );
1642 std::string url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 100, 100 ) );
1643 ImageView imageView = CreateImageView( url, ImageDimensions() );
1645 hbox.SetParentOrigin( ParentOrigin::CENTER );
1646 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1647 hbox.Add( imageView );
1650 // Ensure layouting happens
1651 application.SendNotification();
1652 application.Render();
1654 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1655 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1657 tet_infoline("UtcDaliLayouting_HboxLayout - Change image (new size)");
1658 url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 200, 200 ) );
1659 imageView.SetImage( url );
1661 // Ensure layouting happenss
1662 application.SendNotification();
1663 application.Render();
1665 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1666 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1668 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1669 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1671 // Ensure layouting happenss
1672 application.SendNotification();
1673 application.Render();
1675 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1676 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1678 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1679 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1681 // Ensure layouting happenss
1682 application.SendNotification();
1683 application.Render();
1685 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1686 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1688 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1689 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1691 Image image = FrameBufferImage::New( 50, 50, Pixel::RGBA8888 );
1692 imageView.SetImage( image );
1694 // Ensure layouting happenss
1695 application.SendNotification();
1696 application.Render();
1698 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1699 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1701 Property::Map imagePropertyMap;
1702 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1703 imagePropertyMap[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
1704 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 150;
1705 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 150;
1706 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap );
1708 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1709 // Ensure layouting happenss
1710 application.SendNotification();
1711 application.Render();
1713 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 325.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1714 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1719 int UtcDaliLayouting_HboxLayout_TextLabel(void)
1721 ToolkitTestApplication application;
1722 tet_infoline(" UtcDaliLayouting_HboxLayout - Use text label for leaf");
1724 Stage stage = Stage::GetCurrent();
1726 auto hbox = Control::New();
1727 auto hboxLayout = LinearLayout::New();
1728 DevelControl::SetLayout( hbox, hboxLayout );
1729 hbox.SetName( "HBox" );
1730 hbox.SetParentOrigin( ParentOrigin::CENTER );
1731 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1733 std::vector< Control > controls;
1734 TextLabel textLabel = CreateTextLabel( "W" );
1735 controls.push_back( textLabel );
1736 hbox.Add( textLabel );
1739 // Ensure layouting happens
1740 application.SendNotification();
1741 application.Render();
1743 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1744 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 54.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1746 textLabel.SetProperty( TextLabel::Property::TEXT, "WWWW" );
1748 // Ensure layouting happens
1749 application.SendNotification();
1750 application.Render();
1752 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1753 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 216.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1755 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
1757 // Ensure layouting happens
1758 application.SendNotification();
1759 application.Render();
1761 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1762 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1764 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1765 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1767 // Ensure layouting happens
1768 application.SendNotification();
1769 application.Render();
1771 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1772 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1774 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1775 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1777 // Ensure layouting happens
1778 application.SendNotification();
1779 application.Render();
1781 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1782 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1789 int UtcDaliLayouting_HboxLayout_Padding01(void)
1791 ToolkitTestApplication application;
1792 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
1794 Stage stage = Stage::GetCurrent();
1795 auto hbox = Control::New();
1796 auto hboxLayout = LinearLayout::New();
1797 DevelControl::SetLayout( hbox, hboxLayout );
1798 hbox.SetName( "HBox");
1800 std::vector< Control > controls;
1801 controls.push_back( CreateLeafControl( 40, 40 ) );
1802 controls.push_back( CreateLeafControl( 60, 40 ) );
1803 controls.push_back( CreateLeafControl( 80, 40 ) );
1804 controls.push_back( CreateLeafControl( 100, 40 ) );
1806 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1807 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
1808 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1810 for( auto&& iter : controls )
1814 hbox.SetParentOrigin( ParentOrigin::CENTER );
1815 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1818 // Ensure layouting happens
1819 application.SendNotification();
1820 application.Render();
1822 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1823 // hbox left justifies elements
1824 tet_infoline("Test Child Actor Position");
1825 float xPositionOfControlBeingTested = 0.0f;
1826 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1828 0.0f ), 0.0001f, TEST_LOCATION );
1829 xPositionOfControlBeingTested += 40.0f;
1831 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1832 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1833 0.0001f, TEST_LOCATION );
1835 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1836 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1838 xPositionOfControlBeingTested += 80.0f;
1839 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1841 tet_infoline("Test Child Actor Size");
1842 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1844 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1845 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
1846 0.0001f, TEST_LOCATION );
1848 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1849 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1854 int UtcDaliLayouting_HboxLayout_Padding02(void)
1856 ToolkitTestApplication application;
1857 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
1859 Stage stage = Stage::GetCurrent();
1860 auto hbox = Control::New();
1861 auto hboxLayout = LinearLayout::New();
1862 DevelControl::SetLayout( hbox, hboxLayout );
1863 hbox.SetName( "HBox");
1865 std::vector< Control > controls;
1866 controls.push_back( CreateLeafControl( 40, 40 ) );
1867 controls.push_back( CreateLeafControl( 60, 40 ) );
1868 controls.push_back( CreateLeafControl( 80, 40 ) );
1869 controls.push_back( CreateLeafControl( 100, 40 ) );
1871 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1873 for( auto&& iter : controls )
1875 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1878 hbox.SetParentOrigin( ParentOrigin::CENTER );
1879 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1882 // Ensure layouting happens
1883 application.SendNotification();
1884 application.Render();
1886 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1887 // hbox left justifies elements
1888 tet_infoline("Test Child Actor Position");
1889 float xPositionOfControlBeingTested = 0.0f;
1890 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
1892 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1893 yPositionOfControlBeingTested,
1894 0.0f ), 0.0001f, TEST_LOCATION );
1895 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1897 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1898 yPositionOfControlBeingTested,
1900 0.0001f, TEST_LOCATION );
1902 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1903 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1904 yPositionOfControlBeingTested,
1905 0.0f ), 0.0001f, TEST_LOCATION );
1907 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1908 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1909 yPositionOfControlBeingTested,
1910 0.0f ), 0.0001f, TEST_LOCATION );
1912 tet_infoline("Test Child Actor Size");
1913 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1914 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1915 0.0f ), 0.0001f, TEST_LOCATION );
1917 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1918 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1919 0.0f ), 0.0001f, TEST_LOCATION );
1921 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
1922 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1923 0.0f ), 0.0001f, TEST_LOCATION );
1925 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1926 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1927 0.0f ), 0.0001f, TEST_LOCATION );
1933 int UtcDaliLayouting_HboxLayout_Padding03(void)
1935 ToolkitTestApplication application;
1936 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
1938 Stage stage = Stage::GetCurrent();
1939 auto hbox = Control::New();
1940 auto hboxLayout = LinearLayout::New();
1941 DevelControl::SetLayout( hbox, hboxLayout );
1942 hbox.SetName( "HBox");
1944 std::vector< Control > controls;
1945 controls.push_back( CreateLeafControl( 40, 40 ) );
1946 controls.push_back( CreateLeafControl( 40, 40 ) );
1947 controls.push_back( CreateLeafControl( 40, 40 ) );
1949 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1950 tet_printf( "\nAdding Padding to control at index 1 \n" );
1951 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1953 for( auto&& iter : controls )
1957 hbox.SetParentOrigin( ParentOrigin::CENTER );
1958 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1961 // Ensure layouting happens
1962 application.SendNotification();
1963 application.Render();
1965 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1966 // hbox left justifies elements
1967 tet_infoline("Test Child Actor Position");
1968 float xPositionOfControlBeingTested = 0.0f;
1969 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1971 0.0f ), 0.0001f, TEST_LOCATION );
1972 xPositionOfControlBeingTested += 40.0f;
1974 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1975 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1976 0.0001f, TEST_LOCATION );
1978 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1979 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1981 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
1982 tet_printf( "\nChanging Padding to control at index 1 \n" );
1983 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
1985 // Ensure layouting happens
1986 application.SendNotification();
1987 application.Render();
1989 xPositionOfControlBeingTested = 0.0f; // reset
1991 tet_infoline("Test Child Actor Position");
1992 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1994 0.0f ), 0.0001f, TEST_LOCATION );
1995 xPositionOfControlBeingTested += 40.0f;
1997 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1998 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1999 0.0001f, TEST_LOCATION );
2001 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
2002 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
2003 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2005 tet_infoline("Test Child Actor Size");
2006 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2008 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
2009 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
2010 0.0001f, TEST_LOCATION );
2012 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2017 int UtcDaliLayouting_HboxLayout_Padding04(void)
2019 ToolkitTestApplication application;
2020 tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
2022 // Adding padding to the layout should offset the positioning of the children.
2024 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2025 const Size CONTROL_SIZE = Size( 40, 40 );
2027 Stage stage = Stage::GetCurrent();
2028 // Create a root layout, ideally Dali would have a default layout in the root layer.
2029 // Without this root layer the LinearLayout (or any other layout) will not
2030 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2031 // It uses the default stage size and ideally should have a layout added to it.
2032 auto rootLayoutControl = Control::New();
2033 rootLayoutControl.SetName( "AbsoluteLayout");
2034 auto rootLayout = AbsoluteLayout::New();
2035 DevelControl::SetLayout( rootLayoutControl, rootLayout );
2036 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2037 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2038 stage.Add( rootLayoutControl );
2040 auto hbox = Control::New();
2041 auto hboxLayout = LinearLayout::New();
2042 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2043 DevelControl::SetLayout( hbox, hboxLayout );
2044 hbox.SetName( "HBox");
2045 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2046 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2047 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2049 std::vector< Control > controls;
2050 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2051 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2052 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2053 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2055 for( auto&& iter : controls )
2060 hbox.SetParentOrigin( ParentOrigin::CENTER );
2061 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2062 rootLayoutControl.Add( hbox );
2064 // Ensure layouting happens
2065 application.SendNotification();
2066 application.Render();
2068 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2069 application.SendNotification();
2071 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2072 // hbox left justifies elements
2073 tet_infoline("Test Child Actor Position");
2075 auto controlXPosition=0.0f;
2077 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
2078 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2080 0.0f ), 0.0001f, TEST_LOCATION );
2082 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
2083 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2086 0.0001f, TEST_LOCATION );
2088 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
2089 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2091 0.0f ), 0.0001f, TEST_LOCATION );
2093 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
2094 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2096 0.0f ), 0.0001f, TEST_LOCATION );
2098 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
2099 auto totalControlsHeight = CONTROL_SIZE.height;
2101 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2102 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2103 0.0f ), 0.0001f, TEST_LOCATION );
2109 int UtcDaliLayouting_HboxLayout_Padding05(void)
2111 ToolkitTestApplication application;
2112 tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
2114 // Adding padding to the layout should offset the positioning of the children.
2116 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2117 const Size CONTROL_SIZE = Size( 40, 40 );
2119 Stage stage = Stage::GetCurrent();
2120 // Create a root layout, ideally Dali would have a default layout in the root layer.
2121 // Without this root layer the LinearLayout (or any other layout) will not
2122 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2123 // It uses the default stage size and ideally should have a layout added to it.
2124 auto rootLayoutControl = Control::New();
2125 rootLayoutControl.SetName( "AbsoluteLayout");
2126 auto rootLayout = AbsoluteLayout::New();
2127 DevelControl::SetLayout( rootLayoutControl, rootLayout );
2128 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2129 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2130 stage.Add( rootLayoutControl );
2132 auto hbox = Control::New();
2133 auto hboxLayout = LinearLayout::New();
2134 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2135 DevelControl::SetLayout( hbox, hboxLayout );
2136 hbox.SetName( "HBox");
2137 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2138 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2139 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2141 std::vector< Control > controls;
2142 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2143 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2144 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2145 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2147 for( auto&& iter : controls )
2152 hbox.SetParentOrigin( ParentOrigin::CENTER );
2153 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2154 rootLayoutControl.Add( hbox );
2156 // Ensure layouting happens
2157 application.SendNotification();
2158 application.Render();
2160 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2161 application.SendNotification();
2163 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2164 // hbox left justifies elements
2165 tet_infoline("Test Child Actor Position");
2167 auto controlXPosition=0.0f;
2169 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
2170 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2172 0.0f ), 0.0001f, TEST_LOCATION );
2174 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
2175 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2178 0.0001f, TEST_LOCATION );
2180 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
2181 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2183 0.0f ), 0.0001f, TEST_LOCATION );
2185 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
2186 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2188 0.0f ), 0.0001f, TEST_LOCATION );
2190 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
2191 auto totalControlsHeight = CONTROL_SIZE.height;
2193 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2194 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2195 0.0f ), 0.0001f, TEST_LOCATION );
2197 // Change layout padding
2198 const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
2199 tet_printf( "\nChanging Padding to control at index 1 \n" );
2200 hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
2202 // Ensure layouting happens
2203 application.SendNotification();
2204 application.Render();
2206 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2207 application.SendNotification();
2209 controlXPosition = NEW_LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
2210 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
2211 NEW_LAYOUT_PADDING.top,
2212 0.0f ), 0.0001f, TEST_LOCATION );
2214 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
2215 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2216 NEW_LAYOUT_PADDING.top,
2218 0.0001f, TEST_LOCATION );
2220 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
2221 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2222 NEW_LAYOUT_PADDING.top,
2223 0.0f ), 0.0001f, TEST_LOCATION );
2225 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
2226 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2227 NEW_LAYOUT_PADDING.top,
2228 0.0f ), 0.0001f, TEST_LOCATION );
2229 totalControlsWidth = CONTROL_SIZE.width * controls.size();
2230 totalControlsHeight = CONTROL_SIZE.height;
2232 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
2233 totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
2234 0.0f ), 0.0001f, TEST_LOCATION );
2240 int UtcDaliLayouting_HboxLayout_Margin01(void)
2242 ToolkitTestApplication application;
2243 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
2245 Stage stage = Stage::GetCurrent();
2246 auto hbox = Control::New();
2247 auto hboxLayout = LinearLayout::New();
2248 DevelControl::SetLayout( hbox, hboxLayout );
2249 hbox.SetName( "HBox");
2251 std::vector< Control > controls;
2252 controls.push_back( CreateLeafControl( 40, 40 ) );
2253 controls.push_back( CreateLeafControl( 60, 40 ) );
2254 controls.push_back( CreateLeafControl( 80, 40 ) );
2255 controls.push_back( CreateLeafControl( 100, 40 ) );
2257 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
2258 tet_printf( "\nAdding Margin to control at index 1 \n" );
2259 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
2261 for( auto&& iter : controls )
2265 hbox.SetParentOrigin( ParentOrigin::CENTER );
2266 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2269 // Ensure layouting happens
2270 application.SendNotification();
2271 application.Render();
2273 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2274 // hbox left justifies elements
2275 tet_infoline("Test Child Actor Position");
2276 auto xPositionOfControlBeingTested = 0.0f;
2277 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2279 0.0f ), 0.0001f, TEST_LOCATION );
2280 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
2282 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2283 380.0f + CONTROL_MARGIN.top, 0.0f ),
2284 0.0001f, TEST_LOCATION );
2286 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
2287 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2289 xPositionOfControlBeingTested += 80.0f;
2290 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2292 tet_infoline("Test Child Actor Size is the same after Margin added");
2293 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2294 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
2295 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2296 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2302 int UtcDaliLayouting_VboxLayout01(void)
2304 ToolkitTestApplication application;
2305 tet_infoline(" UtcDaliLayouting_VboxLayout01");
2307 Stage stage = Stage::GetCurrent();
2308 auto vbox = Control::New();
2309 auto vboxLayout = LinearLayout::New();
2310 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2311 vboxLayout.SetAlignment( LinearLayout::Alignment::TOP | LinearLayout::Alignment::CENTER_HORIZONTAL );
2312 DevelControl::SetLayout( vbox, vboxLayout );
2313 vbox.SetName( "Vbox");
2315 std::vector< Control > controls;
2316 controls.push_back( CreateLeafControl( 40, 40 ) );
2317 controls.push_back( CreateLeafControl( 60, 60 ) );
2318 controls.push_back( CreateLeafControl( 80, 80 ) );
2319 controls.push_back( CreateLeafControl( 100, 100 ) );
2321 for( auto&& iter : controls )
2325 vbox.SetParentOrigin( ParentOrigin::CENTER );
2326 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2329 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2332 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2334 // Ensure layouting happens
2335 application.SendNotification();
2336 application.Render();
2338 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
2339 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2340 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2341 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2342 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2344 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2345 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2346 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2347 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2352 int UtcDaliLayouting_VboxLayout02(void)
2354 ToolkitTestApplication application;
2355 tet_infoline(" UtcDaliLayouting_VboxLayout01");
2357 Stage stage = Stage::GetCurrent();
2359 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
2360 // LayoutGroup for this to happen automatically.
2362 // For this test, add an hbox instead
2363 auto rootControl = Control::New();
2364 auto absoluteLayout = AbsoluteLayout::New();
2365 DevelControl::SetLayout( rootControl, absoluteLayout );
2366 rootControl.SetName( "AbsoluteLayout");
2367 stage.Add( rootControl );
2369 auto vbox = Control::New();
2370 auto vboxLayout = LinearLayout::New();
2371 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2372 vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
2373 DevelControl::SetLayout( vbox, vboxLayout );
2374 vbox.SetName( "Vbox");
2375 rootControl.Add( vbox );
2377 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2378 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2380 std::vector< Control > controls;
2381 controls.push_back( CreateLeafControl( 40, 40 ) );
2382 controls.push_back( CreateLeafControl( 60, 60 ) );
2383 controls.push_back( CreateLeafControl( 80, 80 ) );
2384 controls.push_back( CreateLeafControl( 100, 100 ) );
2386 for( auto&& iter : controls )
2390 vbox.SetParentOrigin( ParentOrigin::CENTER );
2391 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2393 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2396 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2398 // Ensure layouting happens
2399 application.SendNotification();
2400 application.Render();
2402 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
2403 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
2405 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
2406 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2407 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2409 // 3rd control is set to match parent - this should also be 100 wide
2410 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2411 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2412 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2413 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2415 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2416 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2417 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2418 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2424 int UtcDaliLayouting_VboxLayout03(void)
2426 ToolkitTestApplication application;
2427 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
2429 Stage stage = Stage::GetCurrent();
2431 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
2432 // LayoutGroup for this to happen automatically.
2434 // For this test, add an hbox instead
2435 auto hbox = Control::New();
2436 auto hboxLayout = LinearLayout::New();
2437 DevelControl::SetLayout( hbox, hboxLayout );
2438 hbox.SetName( "Hbox");
2441 auto vbox = Control::New();
2442 auto vboxLayout = LinearLayout::New();
2443 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
2444 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2445 vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
2447 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
2449 DevelControl::SetLayout( vbox, vboxLayout );
2450 vbox.SetName( "Vbox");
2453 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2454 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2456 std::vector< Control > controls;
2457 controls.push_back( CreateLeafControl( 40, 40 ) );
2458 controls.push_back( CreateLeafControl( 60, 60 ) );
2459 controls.push_back( CreateLeafControl( 80, 80 ) );
2460 controls.push_back( CreateLeafControl( 100, 100 ) );
2462 for( auto&& iter : controls )
2466 vbox.SetParentOrigin( ParentOrigin::CENTER );
2467 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2469 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2472 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2474 // Ensure layouting happens
2475 application.SendNotification();
2476 application.Render();
2478 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
2479 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
2481 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
2482 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2483 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2485 // 3rd control is set to match parent - this should also be 100 wide
2486 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2487 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2488 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2489 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2491 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2492 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2493 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2494 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2499 int UtcDaliLayouting_VboxLayout_Padding(void)
2501 ToolkitTestApplication application;
2502 tet_infoline("UtcDaliLayouting_VboxLayout_Padding - Adding Padding to the vbox");
2504 // Adding padding to the layout should offset the positioning of the children.
2506 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2507 const Size CONTROL_SIZE = Size( 40, 40 );
2509 Stage stage = Stage::GetCurrent();
2510 // Create a root layout, ideally Dali would have a default layout in the root layer.
2511 // Without this root layer the LinearLayout (or any other layout) will not
2512 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2513 // It uses the default stage size and ideally should have a layout added to it.
2514 auto rootLayoutControl = Control::New();
2515 rootLayoutControl.SetName( "AbsoluteLayout");
2516 auto rootLayout = AbsoluteLayout::New();
2517 DevelControl::SetLayout( rootLayoutControl, rootLayout );
2518 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2519 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2520 stage.Add( rootLayoutControl );
2522 auto vbox = Control::New();
2523 auto vboxLayout = LinearLayout::New();
2524 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2525 DevelControl::SetLayout( vbox, vboxLayout );
2526 vbox.SetName( "VBox");
2527 vbox.SetProperty( Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2528 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2529 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2531 std::vector< Control > controls;
2532 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2533 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2534 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2535 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2537 for( auto&& iter : controls )
2542 vbox.SetParentOrigin( ParentOrigin::CENTER );
2543 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2544 rootLayoutControl.Add( vbox );
2546 // Ensure layouting happens
2547 application.SendNotification();
2548 application.Render();
2550 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2551 application.SendNotification();
2553 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
2554 tet_infoline("Test Child Actor Position");
2556 auto controlYPosition = 0.0f;
2558 controlYPosition = LAYOUT_PADDING.top; // First child positioned at offset defined by the padding
2559 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2561 0.0f ), 0.0001f, TEST_LOCATION );
2563 controlYPosition += CONTROL_SIZE.height; // Second child positioned is the position of the first child + the first child's height.
2564 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2567 0.0001f, TEST_LOCATION );
2569 controlYPosition += CONTROL_SIZE.height; // Third child positioned adjacent to second
2570 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2572 0.0f ), 0.0001f, TEST_LOCATION );
2574 controlYPosition += CONTROL_SIZE.height; // Forth passed adjacent to the third
2575 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2577 0.0f ), 0.0001f, TEST_LOCATION );
2579 auto totalControlsWidth = CONTROL_SIZE.width;
2580 auto totalControlsHeight = CONTROL_SIZE.height * controls.size();
2582 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2583 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2584 0.0f ), 0.0001f, TEST_LOCATION );
2590 int UtcDaliLayouting_HboxLayout_TargetSize(void)
2592 ToolkitTestApplication application;
2593 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
2595 Stage stage = Stage::GetCurrent();
2596 auto hbox = Control::New();
2597 auto hboxLayout = LinearLayout::New();
2598 DevelControl::SetLayout( hbox, hboxLayout );
2599 hbox.SetName( "HBox");
2601 std::vector< Control > controls;
2602 controls.push_back( CreateLeafControl( 40, 40 ) );
2603 for( auto&& iter : controls )
2605 iter.SetSize( 100, 100 );
2608 hbox.SetParentOrigin( ParentOrigin::CENTER );
2609 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2612 // Ensure layouting happens
2613 application.SendNotification();
2614 application.Render();
2616 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
2617 // hbox left justifies elements
2618 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2619 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2624 int UtcDaliLayouting_LayoutChildren01(void)
2626 ToolkitTestApplication application;
2627 tet_infoline(" UtcDaliLayouting_LayoutChildren01");
2629 Stage stage = Stage::GetCurrent();
2631 auto rootControl = Control::New();
2632 auto absoluteLayout = AbsoluteLayout::New();
2633 DevelControl::SetLayout( rootControl, absoluteLayout );
2634 stage.Add( rootControl );
2636 auto hbox = Control::New();
2637 auto hboxLayout = LinearLayout::New();
2638 DevelControl::SetLayout( hbox, hboxLayout );
2639 rootControl.Add( hbox );
2641 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2643 tet_infoline("Test removal by removing child actor from parent container" );
2646 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2648 auto& hboxImpl = GetImplementation( hboxLayout );
2649 tet_infoline("Test child actor still has hbox layout " );
2650 DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
2652 tet_infoline("Test hbox layout has no parent " );
2653 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2658 int UtcDaliLayouting_LayoutChildren02(void)
2660 ToolkitTestApplication application;
2661 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2663 Stage stage = Stage::GetCurrent();
2665 auto rootControl = Control::New();
2666 auto absoluteLayout = AbsoluteLayout::New();
2667 DevelControl::SetLayout( rootControl, absoluteLayout );
2668 stage.Add( rootControl );
2670 auto hbox = Control::New();
2671 auto hboxLayout = LinearLayout::New();
2672 DevelControl::SetLayout( hbox, hboxLayout );
2673 rootControl.Add( hbox );
2675 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2677 tet_infoline("Test removal by removing child layout from parent layout" );
2678 absoluteLayout.Remove( hboxLayout );
2680 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2682 auto& hboxImpl = GetImplementation( hboxLayout );
2684 tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
2685 DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
2686 DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
2688 tet_infoline("Check orphaned layout has no parent");
2689 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2695 int UtcDaliLayouting_LayoutChildren03(void)
2697 ToolkitTestApplication application;
2698 tet_infoline(" UtcDaliLayouting_LayoutChildren03");
2700 Stage stage = Stage::GetCurrent();
2702 auto rootControl = Control::New();
2703 auto absoluteLayout = AbsoluteLayout::New();
2704 DevelControl::SetLayout( rootControl, absoluteLayout );
2705 stage.Add( rootControl );
2707 auto hbox = Control::New();
2708 tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
2709 auto hboxLayout = LinearLayout::New();
2710 rootControl.Add( hbox );
2712 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2714 tet_infoline("Then setting a layout on the child container");
2715 DevelControl::SetLayout( hbox, hboxLayout );
2717 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2719 auto& hboxImpl = GetImplementation( hboxLayout );
2720 auto& absImpl = GetImplementation( absoluteLayout );
2721 DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
2722 DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
2727 int UtcDaliLayouting_SetLayoutOrder(void)
2729 ToolkitTestApplication application;
2730 tet_infoline(" UtcDaliLayouting_SetLayoutOrder01 - Call SetLayout after adding the control to the root layout");
2732 Stage stage = Stage::GetCurrent();
2734 auto rootControl = Control::New();
2735 auto absoluteLayout = AbsoluteLayout::New();
2736 DevelControl::SetLayout( rootControl, absoluteLayout );
2737 rootControl.SetName( "AbsoluteLayout" );
2738 stage.Add( rootControl );
2740 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
2741 auto hbox = Control::New();
2742 auto hboxLayout = LinearLayout::New();
2743 hbox.SetName( "HBox");
2745 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
2746 rootControl.Add( hbox );
2748 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
2749 DevelControl::SetLayout( hbox, hboxLayout );
2751 // Add a Child control
2752 std::vector< Control > controls;
2753 controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
2754 for( auto&& iter : controls )
2759 // Ensure layouting happens
2760 application.SendNotification();
2761 application.Render();
2763 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2769 int UtcDaliLayouting_LayoutGroup01(void)
2771 ToolkitTestApplication application;
2772 tet_infoline("UtcDaliLayouting_LayoutGroup01 - Test adding a control to a layout then adding a TextLabel to that control");
2774 Control rootControl;
2775 SetupRootLayoutControl( rootControl );
2777 // Create a parent layout
2778 auto hbox = Control::New();
2779 auto hboxLayout = LinearLayout::New();
2780 hbox.SetName( "HBox");
2781 rootControl.Add( hbox );
2782 DevelControl::SetLayout( hbox, hboxLayout );
2783 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2784 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2785 DevelControl::SetLayoutingRequired( hbox, true );
2786 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2788 tet_infoline("Add a control without SetLayout being called but with layout required set true");
2790 auto control = Control::New();
2791 control.SetName("Control1");
2792 DevelControl::SetLayoutingRequired( control, true );
2793 hbox.Add( control );
2794 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2795 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2796 tet_infoline("Add a Textlabel to the control");
2797 auto textLabel = TextLabel::New("Test text");
2798 textLabel.SetName("TextLabel");
2800 control.Add( textLabel );
2802 // Ensure layouting happens
2803 application.SendNotification();
2804 application.Render();
2806 tet_infoline("Test text is it's natural size");
2807 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2808 tet_infoline("Test control is width of it's parent and height of it's child");
2809 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2814 int UtcDaliLayouting_LayoutGroup02(void)
2816 ToolkitTestApplication application;
2817 tet_infoline("UtcDaliLayouting_LayoutGroup02 - Test control is the size of it's largest child");
2819 Control rootControl;
2820 SetupRootLayoutControl( rootControl );
2822 // Create a parent layout
2823 auto hbox = Control::New();
2824 auto hboxLayout = LinearLayout::New();
2825 DevelControl::SetLayout( hbox, hboxLayout );
2826 hbox.SetName( "HBox");
2827 rootControl.Add( hbox );
2828 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2829 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2830 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2832 tet_infoline("Add a control without SetLayout being called but with layout required set true");
2834 auto control = Control::New();
2835 control.SetName("Control1");
2836 DevelControl::SetLayoutingRequired( control, true );
2837 hbox.Add( control );
2838 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2839 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2841 tet_infoline("Add a Textlabel to the control");
2842 auto textLabel = TextLabel::New("Test text");
2843 textLabel.SetName("TextLabel");
2844 control.Add( textLabel );
2846 tet_infoline("Add another Textlabel to the control");
2847 auto largeTextLabel = TextLabel::New("Test large text");
2848 largeTextLabel.SetName("TextLabel-Large");
2849 control.Add( largeTextLabel );
2851 // Ensure layouting happens
2852 application.SendNotification();
2853 application.Render();
2855 tet_infoline("Test text is it's natural size");
2856 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2857 tet_infoline("Test text is centered in the control, the control is the size of the largest child");
2858 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2860 tet_infoline("Test large text is it's natural size");
2861 DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2862 tet_infoline("Test text is aligned to start as is the size of the control");
2863 DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2865 tet_infoline("Test control is width of it's parent and height of it's largest child");
2866 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2871 int UtcDaliLayouting_LayoutGroup03(void)
2873 ToolkitTestApplication application;
2874 tet_infoline("UtcDaliLayouting_LayoutGroup03 - Test control with a LayoutGroup as a leaf");
2876 Control rootControl;
2877 SetupRootLayoutControl( rootControl );
2879 // Create a parent layout
2880 auto hbox = Control::New();
2881 auto hboxLayout = LinearLayout::New();
2882 DevelControl::SetLayout( hbox, hboxLayout );
2883 hbox.SetName( "HBox");
2884 rootControl.Add( hbox );
2885 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2886 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2887 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2889 tet_infoline("Add a control without SetLayout being called");
2891 auto control = Control::New();
2892 control.SetName("Control1");
2893 hbox.Add( control );
2894 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2895 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
2897 // Ensure layouting happens
2898 application.SendNotification();
2899 application.Render();
2901 tet_infoline("Test control is width of it's parent and exact given height");
2902 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2903 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2909 int UtcDaliLayouting_LayoutGroup04(void)
2911 ToolkitTestApplication application;
2912 tet_infoline("UtcDaliLayouting_LayoutGroup04 - Test control with a LayoutGroup as a leaf and with SetLayotRequired = true");
2914 Control rootControl;
2915 SetupRootLayoutControl( rootControl );
2917 // Create a parent layout
2918 auto hbox = Control::New();
2919 auto hboxLayout = LinearLayout::New();
2920 DevelControl::SetLayout( hbox, hboxLayout );
2921 hbox.SetName( "HBox");
2922 rootControl.Add( hbox );
2923 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2924 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2925 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2927 tet_infoline("Add a control without SetLayout being called");
2929 auto control = Control::New();
2930 control.SetName("Control1");
2931 DevelControl::SetLayoutingRequired( control, true );
2932 hbox.Add( control );
2933 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2934 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
2936 // Ensure layouting happens
2937 application.SendNotification();
2938 application.Render();
2940 tet_infoline("Test control is width of it's parent and exact given height");
2941 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2942 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2947 int UtcDaliLayouting_IsLayoutingRequired(void)
2949 ToolkitTestApplication application;
2950 tet_infoline("UtcDaliLayouting_IsLayoutingRequired - Test setting the SetLayoutRequired and then check if flag was set");
2952 Control rootControl;
2953 SetupRootLayoutControl( rootControl );
2955 // Create a parent layout
2956 auto hbox = Control::New();
2957 auto hboxLayout = LinearLayout::New();
2958 DevelControl::SetLayout( hbox, hboxLayout );
2959 hbox.SetName( "HBox");
2960 rootControl.Add( hbox );
2961 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2962 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2963 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2965 tet_infoline("Add a control without SetLayout being called");
2967 auto control = Control::New();
2968 control.SetName("Control1");
2969 DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), false, TEST_LOCATION );
2970 DevelControl::SetLayoutingRequired( control, true );
2971 hbox.Add( control );
2972 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2973 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
2975 // Ensure layouting happens
2976 application.SendNotification();
2977 application.Render();
2979 tet_infoline("Test control is width of it's parent and exact given height");
2980 DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), true, TEST_LOCATION );
2985 int UtcDaliLayouting_LayoutGroupWithPadding01(void)
2987 ToolkitTestApplication application;
2988 tet_infoline("UtcDaliLayouting_LayoutGroupWithPadding01 - Test adding a control to a layout that has padding");
2990 Control rootControl;
2991 SetupRootLayoutControl( rootControl );
2993 // Create a parent layout
2994 auto hbox = Control::New();
2995 auto hboxLayout = LinearLayout::New();
2996 hbox.SetName( "HBox");
2997 rootControl.Add( hbox );
2998 DevelControl::SetLayout( hbox, hboxLayout );
2999 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3000 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3001 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
3003 tet_infoline("Add a control without SetLayout being called");
3005 auto control = Control::New();
3006 control.SetName("Control1");
3007 DevelControl::SetLayoutingRequired( control, true );
3008 hbox.Add( control );
3009 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3010 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3012 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
3013 tet_printf( "Adding Padding to control");
3014 control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
3016 tet_infoline("Add a Textlabel to the control");
3017 auto textLabel = TextLabel::New("Test text");
3018 textLabel.SetName("TextLabel");
3019 control.Add( textLabel );
3021 // Ensure layouting happens
3022 application.SendNotification();
3023 application.Render();
3025 tet_infoline("Test text is it's natural size");
3026 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3027 tet_infoline("Test control is size of it's child and control it's own padding");
3028 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 245.0f, 86.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3033 int UtcDaliLayouting_LayoutGroupWithChildMargin01(void)
3035 ToolkitTestApplication application;
3036 tet_infoline("UtcDaliLayouting_LayoutGroupWithChildMargin01 - Test adding a control with padding to a layout that has padding");
3038 Control rootControl;
3039 SetupRootLayoutControl( rootControl );
3041 // Create a parent layout
3042 auto hbox = Control::New();
3043 auto hboxLayout = LinearLayout::New();
3044 hbox.SetName( "HBox");
3045 rootControl.Add( hbox );
3046 DevelControl::SetLayout( hbox, hboxLayout );
3047 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3048 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3049 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
3051 tet_infoline("Add a control without SetLayout being called");
3053 auto control = Control::New();
3054 control.SetName("Control1");
3055 DevelControl::SetLayoutingRequired( control, true );
3056 hbox.Add( control );
3057 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3058 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3060 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
3061 tet_printf( "Adding Padding to control");
3062 control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
3064 tet_infoline("Add a Textlabel to the control");
3065 auto textLabel = TextLabel::New("Test text");
3066 const Extents CHILD_MARGIN = Extents( 10, 0, 5, 0 );
3067 textLabel.SetProperty( Toolkit::Control::Property::MARGIN, CHILD_MARGIN );
3068 textLabel.SetName("TextLabel");
3069 control.Add( textLabel );
3071 // Ensure layouting happens
3072 application.SendNotification();
3073 application.Render();
3075 tet_infoline("Test text is it's natural size");
3076 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3077 tet_infoline("Test control is width of it's parent and height of it's child");
3078 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 255.0f, 91.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3083 int UtcDaliLayouting_SetLayout(void)
3085 ToolkitTestApplication application;
3086 tet_infoline(" UtcDaliLayouting_SetLayout - Test reusing layouts");
3088 Control rootControl;
3089 SetupRootLayoutControl( rootControl );
3091 auto container = Control::New();
3092 auto horizontalLayout = LinearLayout::New();
3093 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
3094 DevelControl::SetLayout( container, horizontalLayout );
3095 container.SetName( "Container" );
3096 rootControl.Add( container );
3098 std::vector< Control > controls;
3099 controls.push_back( CreateLeafControl( 40, 40 ) );
3100 controls.push_back( CreateLeafControl( 60, 60 ) );
3102 for( auto&& iter : controls )
3104 container.Add( iter );
3107 container.SetParentOrigin( ParentOrigin::CENTER );
3108 container.SetAnchorPoint( AnchorPoint::CENTER );
3110 // Ensure layouting happens
3111 application.SendNotification();
3112 application.Render();
3114 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3115 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3116 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3118 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3119 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3120 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3123 auto verticalLayout = LinearLayout::New();
3124 verticalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
3125 DevelControl::SetLayout( container, verticalLayout );
3127 application.SendNotification();
3128 application.Render();
3130 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3131 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3132 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3134 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3135 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3136 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3139 DevelControl::SetLayout( container, horizontalLayout );
3141 application.SendNotification();
3142 application.Render();
3144 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3145 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3146 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3148 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3149 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3150 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3153 DevelControl::SetLayout( container, verticalLayout );
3155 application.SendNotification();
3156 application.Render();
3158 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3159 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3160 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3162 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3163 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3164 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3169 int UtcDaliLayouting_StageAdd(void)
3171 ToolkitTestApplication application;
3172 tet_infoline(" UtcDaliLayouting_StageAdd");
3174 Stage stage = Stage::GetCurrent();
3176 AbsoluteLayout absoluteLayout = AbsoluteLayout::New();
3177 Control container = Control::New();
3178 container.SetName( "Container" );
3179 DevelControl::SetLayout( container, absoluteLayout );
3180 container.SetAnchorPoint( Dali::AnchorPoint::CENTER );
3181 container.SetParentOrigin( Dali::ParentOrigin::CENTER );
3183 Control child = Control::New();
3184 child.SetAnchorPoint( Dali::AnchorPoint::TOP_LEFT );
3185 child.SetPosition( 0.0f, 0.0f );
3186 child.SetSize( 480.0f, 180.0f );
3187 child.SetName( "Child Control" );
3188 container.Add( child );
3190 // Ensure layouting happens
3191 application.SendNotification();
3192 application.Render();
3194 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3195 DALI_TEST_EQUALS( child.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3197 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); // Not re-laid out
3198 DALI_TEST_EQUALS( child.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3200 application.SendNotification();
3201 application.Render();
3203 // Add container to stage here
3204 // Should call RequestLayout() to measure and layout
3205 stage.Add( container );
3207 application.SendNotification();
3208 application.Render();
3210 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3211 DALI_TEST_EQUALS( child.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3213 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); // Stage Size
3214 DALI_TEST_EQUALS( child.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );