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 void TestLayoutItemOrder( std::vector< Control >& controls, LayoutGroup& layoutGroup )
43 for( auto&& iter : controls )
45 unsigned int siblingOrder = static_cast< unsigned int>( iter.GetProperty< int >( DevelActor::Property::SIBLING_ORDER ) );
46 DALI_TEST_EQUALS( layoutGroup.GetChildAt( siblingOrder ), DevelControl::GetLayout( iter ), TEST_LOCATION );
50 // Turns the given control into a Root layout control and adds it to the stage.
51 void SetupRootLayoutControl( Control& rootControl )
53 rootControl = Control::New();
54 auto absoluteLayout = AbsoluteLayout::New();
55 DevelControl::SetLayout( rootControl, absoluteLayout );
56 rootControl.SetName( "RootAbsoluteLayout" );
57 Stage stage = Stage::GetCurrent();
58 stage.Add( rootControl );
61 } // unnamed namespace
63 void utc_dali_toolkit_layouting_startup(void)
65 test_return_value = TET_UNDEF;
68 void utc_dali_toolkit_layouting_cleanup(void)
70 test_return_value = TET_PASS;
73 int UtcDaliLayouting_LayoutLength_Types(void)
75 tet_infoline("UtcDaliLayouting_LayoutLength Types");
77 // testing that operators return correct type
80 auto value = LayoutLength( 10 ) + LayoutLength();
81 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
84 auto value = LayoutLength( 10 ) + 20;
85 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
88 auto value = 22 + LayoutLength( 10 );
89 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
92 auto value = LayoutLength( 10 ) + 2.1f;
93 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
96 auto value = 2.2f + LayoutLength( 10 );
97 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
101 auto value = LayoutLength() - LayoutLength( 10 );
102 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
105 auto value = LayoutLength( 10 ) - 99;
106 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
109 auto value = 20 - LayoutLength( 10 );
110 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
113 auto value = LayoutLength( 10 ) - 9.9f;
114 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
117 auto value = 2.0f - LayoutLength( 10 );
118 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
123 auto value = LayoutLength() * LayoutLength( 10 );
124 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
127 auto value = LayoutLength( 10 ) * 2;
128 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
131 auto value = 10 * LayoutLength( 10 );
132 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
135 auto value = LayoutLength( 10 ) * 2.1f;
136 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
139 auto value = 1.0f * LayoutLength( 10 );
140 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
144 auto value = LayoutLength( 10 ) / 2.0f;
145 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
150 auto value = ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
151 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
154 auto value = 20 + ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
155 DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
161 int UtcDaliLayouting_LayoutLength_Values(void)
163 tet_infoline("UtcDaliLayouting_LayoutLength Values");
167 LayoutLength value = LayoutLength( 10 ) + LayoutLength();
168 DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
171 LayoutLength value = LayoutLength( 10 ) + 20;
172 DALI_TEST_EQUALS( value.AsInteger(), 30.0f, 0.0001f, TEST_LOCATION );
175 LayoutLength value = 22 - LayoutLength( 10 );
176 DALI_TEST_EQUALS( value.AsInteger(), 12.0f, 0.0001f, TEST_LOCATION );
179 LayoutLength value = LayoutLength( 10 ) + 2.1f;
180 DALI_TEST_EQUALS( value.AsDecimal(), 12.1f, 0.0001f, TEST_LOCATION );
181 DALI_TEST_EQUALS( value.AsTruncated(), 12.0f, 0.0001f, TEST_LOCATION );
184 LayoutLength value = 2.3f - LayoutLength( 10 );
185 DALI_TEST_EQUALS( value.AsDecimal(), -7.7f, 0.0001f, TEST_LOCATION );
186 DALI_TEST_EQUALS( value.AsInteger(), -8.0f, 0.0001f, TEST_LOCATION );
187 DALI_TEST_EQUALS( value.AsTruncated(), -7.0f, 0.0001f, TEST_LOCATION );
191 LayoutLength value = LayoutLength() - LayoutLength( 10 );
192 DALI_TEST_EQUALS( value.AsInteger(), -10.0f, 0.0001f, TEST_LOCATION );
195 LayoutLength value = LayoutLength( 10 ) - 99;
196 DALI_TEST_EQUALS( value.AsInteger(), -89.0f, 0.0001f, TEST_LOCATION );
199 LayoutLength value = 20 - LayoutLength( 10 );
200 DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
201 DALI_TEST_EQUALS( value.AsTruncated(), 10.f, 0.0001f, TEST_LOCATION );
204 LayoutLength value = LayoutLength( 10 ) - 9.9f;
205 DALI_TEST_EQUALS( value.AsInteger(), 0.0f, 0.0001f, TEST_LOCATION );
206 DALI_TEST_EQUALS( value.AsDecimal(), 0.1f, 0.0001f, TEST_LOCATION );
207 DALI_TEST_EQUALS( value.AsTruncated(), 0.0f, 0.0001f, TEST_LOCATION );
210 LayoutLength value = 10.9f - LayoutLength( 10 );
211 DALI_TEST_EQUALS( value.AsInteger(), 1.0f, 0.0001f, TEST_LOCATION );
212 DALI_TEST_EQUALS( value.AsDecimal(), 0.9f, 0.0001f, TEST_LOCATION );
213 DALI_TEST_EQUALS( value.AsTruncated(), 0.0f, 0.0001f, TEST_LOCATION );
217 LayoutLength value = LayoutLength() * LayoutLength( 10 );
218 DALI_TEST_EQUALS( value.AsInteger(), 0.0f, 0.0001f, TEST_LOCATION );
221 LayoutLength value = LayoutLength(1) * 10;
222 DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
225 LayoutLength value = 11 * LayoutLength( 10 );
226 DALI_TEST_EQUALS( value.AsInteger(), 110.0f, 0.0001f, TEST_LOCATION );
229 LayoutLength value = LayoutLength( 10 ) * 2.12f;
230 DALI_TEST_EQUALS( value.AsDecimal(), 21.2f, 0.0001f, TEST_LOCATION );
231 DALI_TEST_EQUALS( value.AsInteger(), 21.0f, 0.0001f, TEST_LOCATION );
232 DALI_TEST_EQUALS( value.AsTruncated(), 21.0f, 0.0001f, TEST_LOCATION );
235 LayoutLength value = 2.189f * LayoutLength( 10 );
236 DALI_TEST_EQUALS( value.AsDecimal(), 21.89f, 0.0001f, TEST_LOCATION );
237 DALI_TEST_EQUALS( value.AsInteger(), 22.0f, 0.0001f, TEST_LOCATION );
238 DALI_TEST_EQUALS( value.AsTruncated(), 21.0f, 0.0001f, TEST_LOCATION );
242 LayoutLength value = LayoutLength( 11 ) / 2.0f;
243 DALI_TEST_EQUALS( value.AsDecimal(), 5.5f, 0.0001f, TEST_LOCATION );
244 DALI_TEST_EQUALS( value.AsInteger(), 6.0f, 0.0001f, TEST_LOCATION );
250 value = 20 + ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
251 DALI_TEST_EQUALS( value.AsInteger(), 33.0f, 0.0001f, TEST_LOCATION );
252 DALI_TEST_EQUALS( value.AsDecimal(), 33.3333f, 0.0001f, TEST_LOCATION );
255 uint16_t padding( 1 );
256 LayoutLength right(35), left(10), mTotalLength(2);
258 value = padding + ( right - left - mTotalLength ) / 2.0f;
259 // = 1 + ( 35 - 10 - 2 ) / 2
260 DALI_TEST_EQUALS( value.AsInteger(), 13.0f, 0.0001f, TEST_LOCATION );
261 DALI_TEST_EQUALS( value.AsDecimal(), 12.5f, 0.0001f, TEST_LOCATION );
264 uint16_t padding = 1, top = 2, bottom = 3;
265 LayoutLength childSpace( 44 ), childHeight( 23 );
267 value = padding + ( ( childSpace - childHeight ) / 2.0f ) + top - bottom;
268 // = 1 + ( ( 44 - 23 ) / 2 ) + 2 - 3
269 DALI_TEST_EQUALS( value.AsInteger(), 11.0f, 0.0001f, TEST_LOCATION );
270 DALI_TEST_EQUALS( value.AsDecimal(), 10.5f, 0.0001f, TEST_LOCATION );
276 int UtcDaliLayouting_LayoutLength_Operators(void)
278 tet_infoline("UtcDaliLayouting_LayoutLength operators");
281 LayoutLength value = 10;
282 DALI_TEST_EQUALS( (int)value.AsInteger(), 10, TEST_LOCATION );
284 DALI_TEST_EQUALS( (int)value.AsInteger(), 11, TEST_LOCATION );
286 DALI_TEST_EQUALS( (int)value.AsInteger(), -1, TEST_LOCATION );
287 LayoutLength value2 = value;
288 DALI_TEST_EQUALS( value == value2, true, TEST_LOCATION );
290 DALI_TEST_EQUALS( value != value2, true, TEST_LOCATION );
291 DALI_TEST_EQUALS( value < value2, true, TEST_LOCATION );
292 DALI_TEST_EQUALS( value <= value2, true, TEST_LOCATION );
294 DALI_TEST_EQUALS( value > value2, true, TEST_LOCATION );
295 DALI_TEST_EQUALS( value >= value2, true, TEST_LOCATION );
299 LayoutLength value( 123 );
300 std::stringstream ss;
302 DALI_TEST_EQUALS( ss.str(), "123", TEST_LOCATION );
305 LayoutLength value( 0.123f );
306 std::stringstream ss;
308 DALI_TEST_EQUALS( ss.str(), "0.123", TEST_LOCATION );
313 int UtcDaliLayouting_HboxLayout01(void)
315 ToolkitTestApplication application;
316 tet_infoline(" UtcDaliLayouting_HboxLayout01");
318 Stage stage = Stage::GetCurrent();
319 auto hbox = Control::New();
320 auto hboxLayout = LinearLayout::New();
321 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
322 DevelControl::SetLayout( hbox, hboxLayout );
323 hbox.SetName( "HBox");
325 std::vector< Control > controls;
326 controls.push_back( CreateLeafControl( 40, 40 ) );
327 controls.push_back( CreateLeafControl( 60, 40 ) );
328 controls.push_back( CreateLeafControl( 80, 40 ) );
329 controls.push_back( CreateLeafControl( 100, 40 ) );
331 for( auto&& iter : controls )
336 hbox.SetParentOrigin( ParentOrigin::CENTER );
337 hbox.SetAnchorPoint( AnchorPoint::CENTER );
340 // Ensure layouting happens
341 application.SendNotification();
342 application.Render();
344 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
345 // hbox left justifies elements
346 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
347 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
348 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
349 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
351 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
352 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
353 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
354 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
357 auto newHBoxLayout = LinearLayout::New();
358 newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
359 DevelControl::SetLayout( hbox, newHBoxLayout );
361 application.SendNotification();
362 application.Render();
364 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
365 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
366 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
367 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
372 int UtcDaliLayouting_HboxLayout02(void)
374 ToolkitTestApplication application;
375 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
377 Stage stage = Stage::GetCurrent();
379 auto hbox1 = Control::New();
380 auto hboxLayout1 = LinearLayout::New();
381 DevelControl::SetLayout( hbox1, hboxLayout1 );
383 auto hbox2 = Control::New();
384 auto hboxLayout2 = LinearLayout::New();
385 DevelControl::SetLayout( hbox2, hboxLayout2 );
387 hbox1.SetName( "HBox1");
388 hbox2.SetName( "HBox2");
390 std::vector< Control > controls;
391 controls.push_back( CreateLeafControl( 20, 40 ) );
392 controls.push_back( CreateLeafControl( 30, 50 ) );
393 controls.push_back( CreateLeafControl( 40, 60 ) );
394 controls.push_back( CreateLeafControl( 50, 70 ) );
396 controls.push_back( CreateLeafControl( 25, 40 ) );
397 controls.push_back( CreateLeafControl( 35, 50 ) );
398 controls.push_back( CreateLeafControl( 45, 60 ) );
399 controls.push_back( CreateLeafControl( 55, 70 ) );
402 for( auto&& iter : controls )
414 hbox1.SetParentOrigin( ParentOrigin::CENTER );
415 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
416 hbox2.SetParentOrigin( ParentOrigin::CENTER );
417 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
419 auto hbox3 = Control::New();
420 auto hboxLayout3 = LinearLayout::New();
421 DevelControl::SetLayout( hbox3, hboxLayout3 );
423 hbox3.SetParentOrigin( ParentOrigin::CENTER );
424 hbox3.SetName( "HBox3");
430 // Ensure layouting happens
431 application.SendNotification();
432 application.Render();
435 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
436 // hbox left justifies elements
437 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
438 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
439 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
440 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
442 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
443 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
444 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
445 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
448 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
449 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
450 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
451 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
453 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
454 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
455 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
456 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
458 // Test hbox1 and 2 are sized to wrap their content
459 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
460 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
461 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
462 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
464 // Test hbox3 matches parent (root layer)
465 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
466 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
472 int UtcDaliLayouting_HboxLayout03(void)
474 ToolkitTestApplication application;
475 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
477 Stage stage = Stage::GetCurrent();
479 auto hbox1 = Control::New();
480 auto hboxLayout1 = LinearLayout::New();
481 DevelControl::SetLayout( hbox1, hboxLayout1 );
483 auto hbox2 = Control::New();
484 auto hboxLayout2 = LinearLayout::New();
485 DevelControl::SetLayout( hbox2, hboxLayout2 );
487 hbox1.SetName( "HBox1");
488 hbox2.SetName( "HBox2");
489 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
490 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
491 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
492 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
494 std::vector< Control > controls;
495 controls.push_back( CreateLeafControl( 20, 40 ) );
496 controls.push_back( CreateLeafControl( 30, 50 ) );
497 controls.push_back( CreateLeafControl( 40, 60 ) );
498 controls.push_back( CreateLeafControl( 50, 70 ) );
500 controls.push_back( CreateLeafControl( 25, 40 ) );
501 controls.push_back( CreateLeafControl( 35, 50 ) );
502 controls.push_back( CreateLeafControl( 45, 60 ) );
503 controls.push_back( CreateLeafControl( 55, 70 ) );
506 for( auto&& iter : controls )
518 hbox1.SetParentOrigin( ParentOrigin::CENTER );
519 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
520 hbox2.SetParentOrigin( ParentOrigin::CENTER );
521 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
523 auto hbox3 = Control::New();
524 auto hboxLayout3 = LinearLayout::New();
525 DevelControl::SetLayout( hbox3, hboxLayout3);
527 hbox3.SetParentOrigin( ParentOrigin::CENTER );
528 hbox3.SetName( "HBox3");
534 //std::ostringstream oss;
535 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
536 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
538 // Ensure layouting happens
539 application.SendNotification();
540 application.Render();
543 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
544 // hbox left justifies elements
545 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
546 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
547 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
548 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
550 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
551 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
552 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
553 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
555 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
556 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
557 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
558 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
560 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
561 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
562 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
563 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
565 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
566 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
567 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
568 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
570 // Test hbox3 matches parent (root layer)
571 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
572 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
577 int UtcDaliLayouting_HboxLayout04(void)
579 ToolkitTestApplication application;
580 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
582 Stage stage = Stage::GetCurrent();
584 auto hbox1 = Control::New();
585 auto hboxLayout1 = LinearLayout::New();
586 DevelControl::SetLayout( hbox1, hboxLayout1 );
588 auto hbox2 = Control::New();
589 auto hboxLayout2 = LinearLayout::New();
590 DevelControl::SetLayout( hbox2, hboxLayout2 );
592 hbox1.SetName( "HBox1"); // Default spec is to wrap content
593 hbox2.SetName( "HBox2");
594 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
595 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
596 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
597 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
599 std::vector< Control > controls;
600 controls.push_back( CreateLeafControl( 80, 40 ) );
601 controls.push_back( CreateLeafControl( 80, 50 ) );
602 controls.push_back( CreateLeafControl( 80, 60 ) );
603 controls.push_back( CreateLeafControl( 80, 70 ) );
605 controls.push_back( CreateLeafControl( 80, 40 ) );
606 controls.push_back( CreateLeafControl( 80, 50 ) );
607 controls.push_back( CreateLeafControl( 80, 60 ) );
608 controls.push_back( CreateLeafControl( 80, 70 ) );
611 for( auto&& iter : controls )
624 controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
625 auto hbox3 = Control::New();
626 auto hboxLayout3 = LinearLayout::New();
627 DevelControl::SetLayout( hbox3, hboxLayout3 );
629 hbox3.SetParentOrigin( ParentOrigin::CENTER );
630 hbox3.SetName( "HBox3");
635 //std::ostringstream oss;
636 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
637 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
639 // Ensure layouting happens
640 application.SendNotification();
641 application.Render();
644 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
645 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
646 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
647 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
649 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
650 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
651 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
652 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
654 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
655 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
656 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
657 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
659 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
660 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
661 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
662 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
664 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
665 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
666 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
667 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
670 // Test hbox3 matches parent (root layer)
671 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
672 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
677 int UtcDaliLayouting_HboxLayout05(void)
679 ToolkitTestApplication application;
680 tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
682 Stage stage = Stage::GetCurrent();
683 auto hbox = Control::New();
684 auto hboxLayout = LinearLayout::New();
685 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
686 DevelControl::SetLayout( hbox, hboxLayout );
687 hbox.SetName( "HBox");
689 std::vector< Control > controls;
690 controls.push_back( CreateLeafControl( 40, 40 ) );
691 controls.push_back( CreateLeafControl( 60, 40 ) );
692 controls.push_back( CreateLeafControl( 80, 40 ) );
693 controls.push_back( CreateLeafControl( 100, 40 ) );
695 for( auto&& iter : controls )
698 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
699 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
702 hbox.SetParentOrigin( ParentOrigin::CENTER );
703 hbox.SetAnchorPoint( AnchorPoint::CENTER );
706 // Ensure layouting happens
707 application.SendNotification();
708 application.Render();
710 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
711 // hbox left justifies elements
712 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
713 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
714 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
715 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
717 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
718 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
719 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
720 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
725 int UtcDaliLayouting_HboxLayout06(void)
727 ToolkitTestApplication application;
728 tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
730 Stage stage = Stage::GetCurrent();
732 auto rootControl = Control::New();
733 auto absoluteLayout = AbsoluteLayout::New();
734 DevelControl::SetLayout( rootControl, absoluteLayout );
735 rootControl.SetName( "AbsoluteLayout" );
736 stage.Add( rootControl );
738 auto hbox = Control::New();
739 auto hboxLayout = LinearLayout::New();
740 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
741 DevelControl::SetLayout( hbox, hboxLayout );
742 hbox.SetName( "HBox" );
744 std::vector< Control > controls;
745 controls.push_back( CreateLeafControl( 40, 40 ) );
746 controls.push_back( CreateLeafControl( 60, 40 ) );
748 for( auto&& iter : controls )
752 hbox.SetParentOrigin( ParentOrigin::CENTER );
753 hbox.SetAnchorPoint( AnchorPoint::CENTER );
754 rootControl.Add( hbox );
756 // Ensure layouting happens
757 application.SendNotification();
758 application.Render();
760 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
761 // hbox left justifies elements
762 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
763 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
765 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
766 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
768 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
771 auto newHBoxLayout = LinearLayout::New();
772 newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
773 DevelControl::SetLayout( hbox, newHBoxLayout );
775 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
776 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
778 application.SendNotification();
779 application.Render();
781 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
783 // Change size specification
784 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
785 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
787 application.SendNotification();
788 application.Render();
790 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
792 // Use WRAP_CONTENT again
793 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
794 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
796 application.SendNotification();
797 application.Render();
799 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
804 int UtcDaliLayouting_HboxLayout07(void)
806 ToolkitTestApplication application;
807 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
809 Stage stage = Stage::GetCurrent();
810 auto hbox = Control::New();
811 auto hboxLayout = LinearLayout::New();
812 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
813 DevelControl::SetLayout( hbox, hboxLayout );
814 hbox.SetName( "HBox");
816 std::vector< Control > controls;
817 controls.push_back( CreateLeafControl( 40, 40 ) );
818 controls.push_back( CreateLeafControl( 60, 40 ) );
819 controls.push_back( CreateLeafControl( 80, 40 ) );
820 controls.push_back( CreateLeafControl( 100, 40 ) );
822 for( auto&& iter : controls )
826 hbox.SetParentOrigin( ParentOrigin::CENTER );
827 hbox.SetAnchorPoint( AnchorPoint::CENTER );
830 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
832 // Ensure layouting happens
833 application.SendNotification();
834 application.Render();
836 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
837 // hbox left justifies elements
838 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
839 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
840 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
841 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
843 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
844 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
845 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
846 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
848 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
850 // Ensure layouting happens
851 application.SendNotification();
852 application.Render();
854 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
855 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
856 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
857 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
859 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
860 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
861 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
862 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
867 int UtcDaliLayouting_HboxLayout08(void)
869 ToolkitTestApplication application;
870 tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation");
872 Stage stage = Stage::GetCurrent();
874 auto rootControl = Control::New();
875 auto absoluteLayout = AbsoluteLayout::New();
876 absoluteLayout.SetAnimateLayout( true );
877 DevelControl::SetLayout( rootControl, absoluteLayout );
878 rootControl.SetName( "AbsoluteLayout" );
879 stage.Add( rootControl );
881 Control control1 = CreateLeafControl( 40, 40 );
882 rootControl.Add( control1 );
884 auto hbox = Control::New();
885 auto hboxLayout = LinearLayout::New();
886 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
887 DevelControl::SetLayout( hbox, hboxLayout );
888 hbox.SetName( "HBox" );
890 Control control2 = CreateLeafControl( 40, 40 );
891 hbox.Add( control2 );
893 hbox.SetParentOrigin( ParentOrigin::CENTER );
894 hbox.SetAnchorPoint( AnchorPoint::CENTER );
895 rootControl.Add( hbox );
897 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION );
898 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION );
899 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION );
900 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION );
902 tet_infoline(" Set hBoxLayout to animate");
903 hboxLayout.SetAnimateLayout( true );
904 tet_infoline(" Set absoluteLayout not to animate");
905 absoluteLayout.SetAnimateLayout( false );
907 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION );
908 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION );
909 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION );
910 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION );
915 int UtcDaliLayouting_HboxLayout09(void)
917 ToolkitTestApplication application;
918 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set alignment");
920 Stage stage = Stage::GetCurrent();
921 auto hbox = Control::New();
922 auto hboxLayout = LinearLayout::New();
923 DevelControl::SetLayout( hbox, hboxLayout );
924 hbox.SetName( "HBox");
926 std::vector< Control > controls;
927 controls.push_back( CreateLeafControl( 40, 40 ) );
928 controls.push_back( CreateLeafControl( 60, 60 ) );
930 for( auto&& iter : controls )
934 hbox.SetParentOrigin( ParentOrigin::CENTER );
935 hbox.SetAnchorPoint( AnchorPoint::CENTER );
938 // Check default orientation
939 DALI_TEST_EQUALS( static_cast<unsigned int>( hboxLayout.GetOrientation() ), static_cast<unsigned int>( LinearLayout::Orientation::HORIZONTAL ), TEST_LOCATION );
940 // Check default alignment
941 DALI_TEST_EQUALS( hboxLayout.GetAlignment(), ( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL ), TEST_LOCATION );
943 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN );
945 // Ensure layouting happens
946 application.SendNotification();
947 application.Render();
949 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
950 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
952 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
953 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
955 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END );
957 // Ensure layouting happens
958 application.SendNotification();
959 application.Render();
961 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
962 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
964 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
965 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
967 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
969 // Ensure layouting happens
970 application.SendNotification();
971 application.Render();
973 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
974 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
976 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
977 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
979 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP );
981 // Ensure layouting happens
982 application.SendNotification();
983 application.Render();
985 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
986 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
988 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
989 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
991 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP );
993 // Ensure layouting happens
994 application.SendNotification();
995 application.Render();
997 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
998 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1000 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1001 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1003 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP );
1005 // Ensure layouting happens
1006 application.SendNotification();
1007 application.Render();
1009 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1010 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1012 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1013 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1015 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1017 // Ensure layouting happens
1018 application.SendNotification();
1019 application.Render();
1021 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1022 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1024 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1025 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1027 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1029 // Ensure layouting happens
1030 application.SendNotification();
1031 application.Render();
1033 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1034 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1036 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1037 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1039 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1041 // Ensure layouting happens
1042 application.SendNotification();
1043 application.Render();
1045 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1046 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1048 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1049 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1051 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL );
1053 // Ensure layouting happens
1054 application.SendNotification();
1055 application.Render();
1057 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1058 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1060 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1061 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1063 hboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1064 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN );
1066 // Ensure layouting happens
1067 application.SendNotification();
1068 application.Render();
1070 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1071 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1073 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1074 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1076 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END );
1078 // Ensure layouting happens
1079 application.SendNotification();
1080 application.Render();
1082 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1083 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1085 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1086 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1088 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
1090 // Ensure layouting happens
1091 application.SendNotification();
1092 application.Render();
1094 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1095 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1097 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1098 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1100 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP );
1102 // Ensure layouting happens
1103 application.SendNotification();
1104 application.Render();
1106 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1107 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1109 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1110 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1112 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP );
1114 // Ensure layouting happens
1115 application.SendNotification();
1116 application.Render();
1118 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1119 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1121 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1122 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1124 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP );
1126 // Ensure layouting happens
1127 application.SendNotification();
1128 application.Render();
1130 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1131 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1133 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1134 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1136 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1138 // Ensure layouting happens
1139 application.SendNotification();
1140 application.Render();
1142 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1143 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1145 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1146 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1148 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1150 // Ensure layouting happens
1151 application.SendNotification();
1152 application.Render();
1154 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1155 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1157 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1158 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1160 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1162 // Ensure layouting happens
1163 application.SendNotification();
1164 application.Render();
1166 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1167 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1169 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1170 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1172 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL );
1174 // Ensure layouting happens
1175 application.SendNotification();
1176 application.Render();
1178 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1179 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1181 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1182 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1187 int UtcDaliLayouting_HboxLayout_Weight(void)
1189 ToolkitTestApplication application;
1190 tet_infoline( " UtcDaliLayouting_HboxLayout_Weight - Test LinearLayout weight horizontally" );
1192 Stage stage = Stage::GetCurrent();
1193 auto hbox = Control::New();
1194 auto hboxLayout = LinearLayout::New();
1195 DevelControl::SetLayout( hbox, hboxLayout );
1196 hbox.SetName( "HBox" );
1198 std::vector<Control> controls;
1199 controls.push_back( CreateLeafControl( 40, 40 ) );
1200 controls.push_back( CreateLeafControl( 60, 40 ) );
1201 controls.push_back( CreateLeafControl( 80, 40 ) );
1202 controls.push_back( CreateLeafControl( 100, 40 ) );
1204 // Set weight for each leaf to use quarter of available space
1205 // 480 * 0.25, 480 * 0.25, 480 * 0.25, 480 * 0.25,
1206 // width spec has to be set to 0 so not to consume any extra space.
1207 for( auto&& iter : controls )
1209 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1210 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1211 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1215 hbox.SetParentOrigin( ParentOrigin::CENTER );
1216 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1219 // Ensure layouting happens
1220 application.SendNotification();
1221 application.Render();
1223 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1224 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1225 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1226 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 360.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1228 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1229 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1230 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1231 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1233 // Set weight for 3, 4 leafs to use all remaining available space after 1, 2 content sized leafs.
1234 // 40, 60, (480 - 40 - 60) * 0.5, (480 - 40 - 60) * 0.5
1235 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1236 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1237 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1238 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1239 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1240 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1242 // Ensure layouting happens
1243 application.SendNotification();
1244 application.Render();
1246 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1247 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1248 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1249 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 290.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1251 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1252 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1253 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 190.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1254 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 190.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1256 // Add intrinsic width for 3rd leaf so now we should get
1257 // 40, 60, (480 - 40 - 60 - 80) * 0.5 + 80, (480 - 40 - 60 - 80) * 0.5
1258 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 80 );
1260 // Ensure layouting happens
1261 application.SendNotification();
1262 application.Render();
1264 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1265 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1266 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1267 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1269 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1270 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1271 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1272 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1274 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1275 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1276 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1277 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1278 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1279 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1280 controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 40 );
1281 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1283 // Ensure layouting happens
1284 application.SendNotification();
1285 application.Render();
1287 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1288 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1289 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1290 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1292 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 110.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1293 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 220.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1294 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 110.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1295 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1297 // WRAP_CONTENT doesn't affect weight
1298 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1299 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1300 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1301 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1302 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1303 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1304 controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1305 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1307 // Ensure layouting happens
1308 application.SendNotification();
1309 application.Render();
1311 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1312 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1313 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1314 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1316 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1317 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1318 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1319 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 300.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1321 // MATCH_PARENT doesn't affect weight
1322 for( auto&& iter : controls )
1324 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1325 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1326 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1329 // Ensure layouting happens
1330 application.SendNotification();
1331 application.Render();
1333 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1334 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1335 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1336 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 360.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1338 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1339 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1340 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1341 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1343 const Extents CONTROL_MARGIN = Extents( 10, 10, 0, 0 );
1344 for( auto&& iter : controls )
1346 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1347 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1348 iter.SetProperty( Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1351 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1352 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1353 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1354 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1356 application.SendNotification();
1357 application.Render();
1359 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 10.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1360 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 70.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1361 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 150.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1362 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 250.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1364 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1365 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1366 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1367 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 220.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1372 int UtcDaliLayouting_VboxLayout_Weight(void)
1374 ToolkitTestApplication application;
1375 tet_infoline( " UtcDaliLayouting_VboxLayout_Weight - Test LinearLayout weight vertically" );
1377 Stage stage = Stage::GetCurrent();
1378 auto vbox = Control::New();
1379 auto vboxLayout = LinearLayout::New();
1380 vboxLayout.SetOrientation( Dali::Toolkit::LinearLayout::Orientation::VERTICAL );
1381 DevelControl::SetLayout( vbox, vboxLayout );
1382 vbox.SetName( "VBox" );
1384 std::vector<Control> controls;
1385 controls.push_back( CreateLeafControl( 40, 40 ) );
1386 controls.push_back( CreateLeafControl( 60, 60 ) );
1387 controls.push_back( CreateLeafControl( 80, 80 ) );
1388 controls.push_back( CreateLeafControl( 100, 100 ) );
1390 // Set weight for each leaf to use quarter of available space
1391 // 800 * 0.25, 800 * 0.25, 800 * 0.25, 800 * 0.25,
1392 // width spec has to be set to 0 so not to consume any extra space.
1393 for( auto&& iter : controls )
1395 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1396 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1397 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1401 vbox.SetParentOrigin( ParentOrigin::CENTER );
1402 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1405 // Ensure layouting happens
1406 application.SendNotification();
1407 application.Render();
1409 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1410 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1411 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1412 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 600.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1414 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1415 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1416 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1417 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1419 // Set weight for 3, 4 leafs to use all remaining available space after 1, 2 content sized leafs.
1420 // 40, 60, (800 - 40 - 60) * 0.5, (800 - 40 - 60) * 0.5
1421 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1422 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1423 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1424 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1425 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1426 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1428 // Ensure layouting happens
1429 application.SendNotification();
1430 application.Render();
1432 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1433 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1434 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1435 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 450.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1437 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1438 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1439 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1440 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1442 // Add intrinsic width for 3rd leaf so now we should get
1443 // 40, 60, (800 - 40 - 60 - 100) * 0.5 + 100, (800 - 40 - 60 - 100) * 0.5
1444 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
1446 // Ensure layouting happens
1447 application.SendNotification();
1448 application.Render();
1450 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1451 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1452 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1453 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 500.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1455 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1456 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1457 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1458 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1460 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1461 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1462 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1463 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1464 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1465 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1466 controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
1467 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1469 // Ensure layouting happens
1470 application.SendNotification();
1471 application.Render();
1473 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1474 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1475 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 525.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1476 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1478 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1479 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1480 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1481 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1483 // WRAP_CONTENT doesn't affect weight
1484 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1485 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1486 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1487 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1488 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1489 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1490 controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1491 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1493 // Ensure layouting happens
1494 application.SendNotification();
1495 application.Render();
1497 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1498 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1499 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1500 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1502 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1503 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1504 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1505 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 620.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1507 // MATCH_PARENT doesn't affect weight
1508 for( auto&& iter : controls )
1510 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1511 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1512 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1515 // Ensure layouting happens
1516 application.SendNotification();
1517 application.Render();
1519 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1520 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1521 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1522 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 600.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1524 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1525 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1526 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1527 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1529 const Extents CONTROL_MARGIN = Extents( 0, 0, 10, 10 );
1530 for( auto&& iter : controls )
1532 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1533 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1534 iter.SetProperty( Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1537 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1538 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1539 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1540 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1542 application.SendNotification();
1543 application.Render();
1545 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1546 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1547 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1548 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 250.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1550 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1551 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1552 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1553 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 540.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1558 int UtcDaliLayouting_NestedLinearLayout_Weight(void)
1560 ToolkitTestApplication application;
1561 tet_infoline("UtcDaliLayouting_NestedLinearLayout_Weight - test weighted children with wrapped parent");
1563 Stage stage = Stage::GetCurrent();
1564 auto rootControl = Control::New();
1565 rootControl.SetName( "AbsoluteLayout");
1566 auto rootLayout = AbsoluteLayout::New();
1567 DevelControl::SetLayout( rootControl, rootLayout );
1568 rootControl.SetAnchorPoint( AnchorPoint::CENTER );
1569 rootControl.SetParentOrigin( ParentOrigin::CENTER );
1570 stage.Add( rootControl );
1572 auto hbox = Control::New();
1573 auto hboxLayout = LinearLayout::New();
1574 DevelControl::SetLayout( hbox, hboxLayout );
1575 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1576 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1578 std::vector< Control > controls;
1579 controls.push_back( CreateLeafControl( 40, 40 ) );
1580 controls.push_back( CreateLeafControl( 60, 60 ) );
1582 // set equal share of wrapped content width (40 + 60 = 100) for both children 100 * 0.5, 100 * 0.5
1583 for( auto&& iter : controls )
1585 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1586 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1587 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1591 hbox.SetParentOrigin( ParentOrigin::CENTER );
1592 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1593 rootControl.Add( hbox );
1595 // Ensure layouting happens
1596 application.SendNotification();
1597 application.Render();
1599 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1600 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1602 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1603 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1605 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1606 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1608 hboxLayout.SetOrientation(Dali::Toolkit::LinearLayout::Orientation::VERTICAL);
1610 // set equal share of wrapped content height (40 + 60 = 100) for both children 100 * 0.5, 100 * 0.5
1611 for( auto&& iter : controls )
1613 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1614 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1615 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1618 // Ensure layouting happens
1619 application.SendNotification();
1620 application.Render();
1622 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1623 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1625 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1626 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1628 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1629 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1637 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/broken.png";
1640 int UtcDaliLayouting_HboxLayout_ImageView(void)
1642 ToolkitTestApplication application;
1643 tet_infoline(" UtcDaliLayouting_HboxLayout - Use image view for leaf");
1645 Stage stage = Stage::GetCurrent();
1646 auto hbox = Control::New();
1647 auto hboxLayout = LinearLayout::New();
1648 DevelControl::SetLayout( hbox, hboxLayout );
1649 hbox.SetName( "HBox" );
1651 std::string url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 100, 100 ) );
1652 ImageView imageView = CreateImageView( url, ImageDimensions() );
1654 hbox.SetParentOrigin( ParentOrigin::CENTER );
1655 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1656 hbox.Add( imageView );
1659 // Ensure layouting happens
1660 application.SendNotification();
1661 application.Render();
1663 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1664 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1666 tet_infoline("UtcDaliLayouting_HboxLayout - Change image (new size)");
1667 url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 200, 200 ) );
1668 imageView.SetImage( url );
1670 // Ensure layouting happenss
1671 application.SendNotification();
1672 application.Render();
1674 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1675 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1677 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1678 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1680 // Ensure layouting happenss
1681 application.SendNotification();
1682 application.Render();
1684 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1685 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1687 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1688 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1690 // Ensure layouting happenss
1691 application.SendNotification();
1692 application.Render();
1694 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1695 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1697 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1698 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1700 Image image = FrameBufferImage::New( 50, 50, Pixel::RGBA8888 );
1701 imageView.SetImage( image );
1703 // Ensure layouting happenss
1704 application.SendNotification();
1705 application.Render();
1707 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1708 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1710 Property::Map imagePropertyMap;
1711 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1712 imagePropertyMap[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
1713 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 150;
1714 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 150;
1715 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap );
1717 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1718 // Ensure layouting happenss
1719 application.SendNotification();
1720 application.Render();
1722 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 325.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1723 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1728 int UtcDaliLayouting_HboxLayout_TextLabel(void)
1730 ToolkitTestApplication application;
1731 tet_infoline(" UtcDaliLayouting_HboxLayout - Use text label for leaf");
1733 Stage stage = Stage::GetCurrent();
1735 auto hbox = Control::New();
1736 auto hboxLayout = LinearLayout::New();
1737 DevelControl::SetLayout( hbox, hboxLayout );
1738 hbox.SetName( "HBox" );
1739 hbox.SetParentOrigin( ParentOrigin::CENTER );
1740 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1742 std::vector< Control > controls;
1743 TextLabel textLabel = CreateTextLabel( "W" );
1744 controls.push_back( textLabel );
1745 hbox.Add( textLabel );
1748 // Ensure layouting happens
1749 application.SendNotification();
1750 application.Render();
1752 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1753 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 54.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1755 textLabel.SetProperty( TextLabel::Property::TEXT, "WWWW" );
1757 // Ensure layouting happens
1758 application.SendNotification();
1759 application.Render();
1761 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1762 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 216.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1764 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
1766 // Ensure layouting happens
1767 application.SendNotification();
1768 application.Render();
1770 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1771 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1773 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1774 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1776 // Ensure layouting happens
1777 application.SendNotification();
1778 application.Render();
1780 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1781 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1783 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1784 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1786 // Ensure layouting happens
1787 application.SendNotification();
1788 application.Render();
1790 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1791 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1798 int UtcDaliLayouting_HboxLayout_Padding01(void)
1800 ToolkitTestApplication application;
1801 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
1803 Stage stage = Stage::GetCurrent();
1804 auto hbox = Control::New();
1805 auto hboxLayout = LinearLayout::New();
1806 DevelControl::SetLayout( hbox, hboxLayout );
1807 hbox.SetName( "HBox");
1809 std::vector< Control > controls;
1810 controls.push_back( CreateLeafControl( 40, 40 ) );
1811 controls.push_back( CreateLeafControl( 60, 40 ) );
1812 controls.push_back( CreateLeafControl( 80, 40 ) );
1813 controls.push_back( CreateLeafControl( 100, 40 ) );
1815 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1816 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
1817 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1819 for( auto&& iter : controls )
1823 hbox.SetParentOrigin( ParentOrigin::CENTER );
1824 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1827 // Ensure layouting happens
1828 application.SendNotification();
1829 application.Render();
1831 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1832 // hbox left justifies elements
1833 tet_infoline("Test Child Actor Position");
1834 float xPositionOfControlBeingTested = 0.0f;
1835 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1837 0.0f ), 0.0001f, TEST_LOCATION );
1838 xPositionOfControlBeingTested += 40.0f;
1840 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1841 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1842 0.0001f, TEST_LOCATION );
1844 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1845 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1847 xPositionOfControlBeingTested += 80.0f;
1848 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1850 tet_infoline("Test Child Actor Size");
1851 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1853 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1854 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
1855 0.0001f, TEST_LOCATION );
1857 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1858 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1863 int UtcDaliLayouting_HboxLayout_Padding02(void)
1865 ToolkitTestApplication application;
1866 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
1868 Stage stage = Stage::GetCurrent();
1869 auto hbox = Control::New();
1870 auto hboxLayout = LinearLayout::New();
1871 DevelControl::SetLayout( hbox, hboxLayout );
1872 hbox.SetName( "HBox");
1874 std::vector< Control > controls;
1875 controls.push_back( CreateLeafControl( 40, 40 ) );
1876 controls.push_back( CreateLeafControl( 60, 40 ) );
1877 controls.push_back( CreateLeafControl( 80, 40 ) );
1878 controls.push_back( CreateLeafControl( 100, 40 ) );
1880 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1882 for( auto&& iter : controls )
1884 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1887 hbox.SetParentOrigin( ParentOrigin::CENTER );
1888 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1891 // Ensure layouting happens
1892 application.SendNotification();
1893 application.Render();
1895 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1896 // hbox left justifies elements
1897 tet_infoline("Test Child Actor Position");
1898 float xPositionOfControlBeingTested = 0.0f;
1899 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
1901 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1902 yPositionOfControlBeingTested,
1903 0.0f ), 0.0001f, TEST_LOCATION );
1904 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1906 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1907 yPositionOfControlBeingTested,
1909 0.0001f, TEST_LOCATION );
1911 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1912 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1913 yPositionOfControlBeingTested,
1914 0.0f ), 0.0001f, TEST_LOCATION );
1916 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1917 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1918 yPositionOfControlBeingTested,
1919 0.0f ), 0.0001f, TEST_LOCATION );
1921 tet_infoline("Test Child Actor Size");
1922 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1923 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1924 0.0f ), 0.0001f, TEST_LOCATION );
1926 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1927 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1928 0.0f ), 0.0001f, TEST_LOCATION );
1930 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
1931 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1932 0.0f ), 0.0001f, TEST_LOCATION );
1934 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1935 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1936 0.0f ), 0.0001f, TEST_LOCATION );
1942 int UtcDaliLayouting_HboxLayout_Padding03(void)
1944 ToolkitTestApplication application;
1945 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
1947 Stage stage = Stage::GetCurrent();
1948 auto hbox = Control::New();
1949 auto hboxLayout = LinearLayout::New();
1950 DevelControl::SetLayout( hbox, hboxLayout );
1951 hbox.SetName( "HBox");
1953 std::vector< Control > controls;
1954 controls.push_back( CreateLeafControl( 40, 40 ) );
1955 controls.push_back( CreateLeafControl( 40, 40 ) );
1956 controls.push_back( CreateLeafControl( 40, 40 ) );
1958 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1959 tet_printf( "\nAdding Padding to control at index 1 \n" );
1960 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1962 for( auto&& iter : controls )
1966 hbox.SetParentOrigin( ParentOrigin::CENTER );
1967 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1970 // Ensure layouting happens
1971 application.SendNotification();
1972 application.Render();
1974 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1975 // hbox left justifies elements
1976 tet_infoline("Test Child Actor Position");
1977 float xPositionOfControlBeingTested = 0.0f;
1978 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1980 0.0f ), 0.0001f, TEST_LOCATION );
1981 xPositionOfControlBeingTested += 40.0f;
1983 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1984 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1985 0.0001f, TEST_LOCATION );
1987 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1988 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1990 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
1991 tet_printf( "\nChanging Padding to control at index 1 \n" );
1992 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
1994 // Ensure layouting happens
1995 application.SendNotification();
1996 application.Render();
1998 xPositionOfControlBeingTested = 0.0f; // reset
2000 tet_infoline("Test Child Actor Position");
2001 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2003 0.0f ), 0.0001f, TEST_LOCATION );
2004 xPositionOfControlBeingTested += 40.0f;
2006 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2007 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
2008 0.0001f, TEST_LOCATION );
2010 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
2011 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
2012 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2014 tet_infoline("Test Child Actor Size");
2015 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2017 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
2018 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
2019 0.0001f, TEST_LOCATION );
2021 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2026 int UtcDaliLayouting_HboxLayout_Padding04(void)
2028 ToolkitTestApplication application;
2029 tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
2031 // Adding padding to the layout should offset the positioning of the children.
2033 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2034 const Size CONTROL_SIZE = Size( 40, 40 );
2036 Stage stage = Stage::GetCurrent();
2037 // Create a root layout, ideally Dali would have a default layout in the root layer.
2038 // Without this root layer the LinearLayout (or any other layout) will not
2039 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2040 // It uses the default stage size and ideally should have a layout added to it.
2041 auto rootLayoutControl = Control::New();
2042 rootLayoutControl.SetName( "AbsoluteLayout");
2043 auto rootLayout = AbsoluteLayout::New();
2044 DevelControl::SetLayout( rootLayoutControl, rootLayout );
2045 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2046 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2047 stage.Add( rootLayoutControl );
2049 auto hbox = Control::New();
2050 auto hboxLayout = LinearLayout::New();
2051 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2052 DevelControl::SetLayout( hbox, hboxLayout );
2053 hbox.SetName( "HBox");
2054 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2055 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2056 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2058 std::vector< Control > controls;
2059 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2060 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2061 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2062 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2064 for( auto&& iter : controls )
2069 hbox.SetParentOrigin( ParentOrigin::CENTER );
2070 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2071 rootLayoutControl.Add( hbox );
2073 // Ensure layouting happens
2074 application.SendNotification();
2075 application.Render();
2077 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2078 application.SendNotification();
2080 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2081 // hbox left justifies elements
2082 tet_infoline("Test Child Actor Position");
2084 auto controlXPosition=0.0f;
2086 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
2087 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2089 0.0f ), 0.0001f, TEST_LOCATION );
2091 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
2092 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2095 0.0001f, TEST_LOCATION );
2097 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
2098 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2100 0.0f ), 0.0001f, TEST_LOCATION );
2102 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
2103 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2105 0.0f ), 0.0001f, TEST_LOCATION );
2107 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
2108 auto totalControlsHeight = CONTROL_SIZE.height;
2110 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2111 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2112 0.0f ), 0.0001f, TEST_LOCATION );
2118 int UtcDaliLayouting_HboxLayout_Padding05(void)
2120 ToolkitTestApplication application;
2121 tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
2123 // Adding padding to the layout should offset the positioning of the children.
2125 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2126 const Size CONTROL_SIZE = Size( 40, 40 );
2128 Stage stage = Stage::GetCurrent();
2129 // Create a root layout, ideally Dali would have a default layout in the root layer.
2130 // Without this root layer the LinearLayout (or any other layout) will not
2131 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2132 // It uses the default stage size and ideally should have a layout added to it.
2133 auto rootLayoutControl = Control::New();
2134 rootLayoutControl.SetName( "AbsoluteLayout");
2135 auto rootLayout = AbsoluteLayout::New();
2136 DevelControl::SetLayout( rootLayoutControl, rootLayout );
2137 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2138 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2139 stage.Add( rootLayoutControl );
2141 auto hbox = Control::New();
2142 auto hboxLayout = LinearLayout::New();
2143 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2144 DevelControl::SetLayout( hbox, hboxLayout );
2145 hbox.SetName( "HBox");
2146 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2147 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2148 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2150 std::vector< Control > controls;
2151 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2152 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2153 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2154 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2156 for( auto&& iter : controls )
2161 hbox.SetParentOrigin( ParentOrigin::CENTER );
2162 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2163 rootLayoutControl.Add( hbox );
2165 // Ensure layouting happens
2166 application.SendNotification();
2167 application.Render();
2169 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2170 application.SendNotification();
2172 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2173 // hbox left justifies elements
2174 tet_infoline("Test Child Actor Position");
2176 auto controlXPosition=0.0f;
2178 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
2179 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2181 0.0f ), 0.0001f, TEST_LOCATION );
2183 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
2184 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2187 0.0001f, TEST_LOCATION );
2189 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
2190 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2192 0.0f ), 0.0001f, TEST_LOCATION );
2194 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
2195 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2197 0.0f ), 0.0001f, TEST_LOCATION );
2199 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
2200 auto totalControlsHeight = CONTROL_SIZE.height;
2202 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2203 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2204 0.0f ), 0.0001f, TEST_LOCATION );
2206 // Change layout padding
2207 const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
2208 tet_printf( "\nChanging Padding to control at index 1 \n" );
2209 hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
2211 // Ensure layouting happens
2212 application.SendNotification();
2213 application.Render();
2215 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2216 application.SendNotification();
2218 controlXPosition = NEW_LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
2219 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
2220 NEW_LAYOUT_PADDING.top,
2221 0.0f ), 0.0001f, TEST_LOCATION );
2223 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
2224 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2225 NEW_LAYOUT_PADDING.top,
2227 0.0001f, TEST_LOCATION );
2229 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
2230 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2231 NEW_LAYOUT_PADDING.top,
2232 0.0f ), 0.0001f, TEST_LOCATION );
2234 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
2235 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2236 NEW_LAYOUT_PADDING.top,
2237 0.0f ), 0.0001f, TEST_LOCATION );
2238 totalControlsWidth = CONTROL_SIZE.width * controls.size();
2239 totalControlsHeight = CONTROL_SIZE.height;
2241 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
2242 totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
2243 0.0f ), 0.0001f, TEST_LOCATION );
2249 int UtcDaliLayouting_HboxLayout_Margin01(void)
2251 ToolkitTestApplication application;
2252 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
2254 Stage stage = Stage::GetCurrent();
2255 auto hbox = Control::New();
2256 auto hboxLayout = LinearLayout::New();
2257 DevelControl::SetLayout( hbox, hboxLayout );
2258 hbox.SetName( "HBox");
2260 std::vector< Control > controls;
2261 controls.push_back( CreateLeafControl( 40, 40 ) );
2262 controls.push_back( CreateLeafControl( 60, 40 ) );
2263 controls.push_back( CreateLeafControl( 80, 40 ) );
2264 controls.push_back( CreateLeafControl( 100, 40 ) );
2266 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
2267 tet_printf( "\nAdding Margin to control at index 1 \n" );
2268 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
2270 for( auto&& iter : controls )
2274 hbox.SetParentOrigin( ParentOrigin::CENTER );
2275 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2278 // Ensure layouting happens
2279 application.SendNotification();
2280 application.Render();
2282 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2283 // hbox left justifies elements
2284 tet_infoline("Test Child Actor Position");
2285 auto xPositionOfControlBeingTested = 0.0f;
2286 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2288 0.0f ), 0.0001f, TEST_LOCATION );
2289 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
2291 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2292 380.0f + CONTROL_MARGIN.top, 0.0f ),
2293 0.0001f, TEST_LOCATION );
2295 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
2296 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2298 xPositionOfControlBeingTested += 80.0f;
2299 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2301 tet_infoline("Test Child Actor Size is the same after Margin added");
2302 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2303 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
2304 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2305 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2311 int UtcDaliLayouting_VboxLayout01(void)
2313 ToolkitTestApplication application;
2314 tet_infoline(" UtcDaliLayouting_VboxLayout01");
2316 Stage stage = Stage::GetCurrent();
2317 auto vbox = Control::New();
2318 auto vboxLayout = LinearLayout::New();
2319 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2320 vboxLayout.SetAlignment( LinearLayout::Alignment::TOP | LinearLayout::Alignment::CENTER_HORIZONTAL );
2321 DevelControl::SetLayout( vbox, vboxLayout );
2322 vbox.SetName( "Vbox");
2324 std::vector< Control > controls;
2325 controls.push_back( CreateLeafControl( 40, 40 ) );
2326 controls.push_back( CreateLeafControl( 60, 60 ) );
2327 controls.push_back( CreateLeafControl( 80, 80 ) );
2328 controls.push_back( CreateLeafControl( 100, 100 ) );
2330 for( auto&& iter : controls )
2334 vbox.SetParentOrigin( ParentOrigin::CENTER );
2335 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2338 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2341 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2343 // Ensure layouting happens
2344 application.SendNotification();
2345 application.Render();
2347 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
2348 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2349 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2350 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2351 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2353 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2354 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2355 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2356 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2361 int UtcDaliLayouting_VboxLayout02(void)
2363 ToolkitTestApplication application;
2364 tet_infoline(" UtcDaliLayouting_VboxLayout01");
2366 Stage stage = Stage::GetCurrent();
2368 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
2369 // LayoutGroup for this to happen automatically.
2371 // For this test, add an hbox instead
2372 auto rootControl = Control::New();
2373 auto absoluteLayout = AbsoluteLayout::New();
2374 DevelControl::SetLayout( rootControl, absoluteLayout );
2375 rootControl.SetName( "AbsoluteLayout");
2376 stage.Add( rootControl );
2378 auto vbox = Control::New();
2379 auto vboxLayout = LinearLayout::New();
2380 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2381 vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
2382 DevelControl::SetLayout( vbox, vboxLayout );
2383 vbox.SetName( "Vbox");
2384 rootControl.Add( vbox );
2386 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2387 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2389 std::vector< Control > controls;
2390 controls.push_back( CreateLeafControl( 40, 40 ) );
2391 controls.push_back( CreateLeafControl( 60, 60 ) );
2392 controls.push_back( CreateLeafControl( 80, 80 ) );
2393 controls.push_back( CreateLeafControl( 100, 100 ) );
2395 for( auto&& iter : controls )
2399 vbox.SetParentOrigin( ParentOrigin::CENTER );
2400 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2402 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2405 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2407 // Ensure layouting happens
2408 application.SendNotification();
2409 application.Render();
2411 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
2412 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
2414 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
2415 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2416 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2418 // 3rd control is set to match parent - this should also be 100 wide
2419 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2420 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2421 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2422 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2424 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2425 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2426 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2427 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2433 int UtcDaliLayouting_VboxLayout03(void)
2435 ToolkitTestApplication application;
2436 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
2438 Stage stage = Stage::GetCurrent();
2440 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
2441 // LayoutGroup for this to happen automatically.
2443 // For this test, add an hbox instead
2444 auto hbox = Control::New();
2445 auto hboxLayout = LinearLayout::New();
2446 DevelControl::SetLayout( hbox, hboxLayout );
2447 hbox.SetName( "Hbox");
2450 auto vbox = Control::New();
2451 auto vboxLayout = LinearLayout::New();
2452 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
2453 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2454 vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
2456 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
2458 DevelControl::SetLayout( vbox, vboxLayout );
2459 vbox.SetName( "Vbox");
2462 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2463 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2465 std::vector< Control > controls;
2466 controls.push_back( CreateLeafControl( 40, 40 ) );
2467 controls.push_back( CreateLeafControl( 60, 60 ) );
2468 controls.push_back( CreateLeafControl( 80, 80 ) );
2469 controls.push_back( CreateLeafControl( 100, 100 ) );
2471 for( auto&& iter : controls )
2475 vbox.SetParentOrigin( ParentOrigin::CENTER );
2476 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2478 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2481 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2483 // Ensure layouting happens
2484 application.SendNotification();
2485 application.Render();
2487 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
2488 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
2490 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
2491 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2492 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2494 // 3rd control is set to match parent - this should also be 100 wide
2495 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2496 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2497 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2498 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2500 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2501 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2502 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2503 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2508 int UtcDaliLayouting_VboxLayout_Padding(void)
2510 ToolkitTestApplication application;
2511 tet_infoline("UtcDaliLayouting_VboxLayout_Padding - Adding Padding to the vbox");
2513 // Adding padding to the layout should offset the positioning of the children.
2515 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2516 const Size CONTROL_SIZE = Size( 40, 40 );
2518 Stage stage = Stage::GetCurrent();
2519 // Create a root layout, ideally Dali would have a default layout in the root layer.
2520 // Without this root layer the LinearLayout (or any other layout) will not
2521 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2522 // It uses the default stage size and ideally should have a layout added to it.
2523 auto rootLayoutControl = Control::New();
2524 rootLayoutControl.SetName( "AbsoluteLayout");
2525 auto rootLayout = AbsoluteLayout::New();
2526 DevelControl::SetLayout( rootLayoutControl, rootLayout );
2527 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2528 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2529 stage.Add( rootLayoutControl );
2531 auto vbox = Control::New();
2532 auto vboxLayout = LinearLayout::New();
2533 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2534 DevelControl::SetLayout( vbox, vboxLayout );
2535 vbox.SetName( "VBox");
2536 vbox.SetProperty( Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2537 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2538 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2540 std::vector< Control > controls;
2541 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2542 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2543 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2544 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2546 for( auto&& iter : controls )
2551 vbox.SetParentOrigin( ParentOrigin::CENTER );
2552 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2553 rootLayoutControl.Add( vbox );
2555 // Ensure layouting happens
2556 application.SendNotification();
2557 application.Render();
2559 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2560 application.SendNotification();
2562 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
2563 tet_infoline("Test Child Actor Position");
2565 auto controlYPosition = 0.0f;
2567 controlYPosition = LAYOUT_PADDING.top; // First child positioned at offset defined by the padding
2568 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2570 0.0f ), 0.0001f, TEST_LOCATION );
2572 controlYPosition += CONTROL_SIZE.height; // Second child positioned is the position of the first child + the first child's height.
2573 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2576 0.0001f, TEST_LOCATION );
2578 controlYPosition += CONTROL_SIZE.height; // Third child positioned adjacent to second
2579 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2581 0.0f ), 0.0001f, TEST_LOCATION );
2583 controlYPosition += CONTROL_SIZE.height; // Forth passed adjacent to the third
2584 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2586 0.0f ), 0.0001f, TEST_LOCATION );
2588 auto totalControlsWidth = CONTROL_SIZE.width;
2589 auto totalControlsHeight = CONTROL_SIZE.height * controls.size();
2591 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2592 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2593 0.0f ), 0.0001f, TEST_LOCATION );
2599 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
2601 ToolkitTestApplication application;
2602 tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
2603 tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
2605 Stage stage = Stage::GetCurrent();
2607 auto hbox = Control::New();
2608 auto hboxLayout = Test::CustomLayout::New();
2609 DevelControl::SetLayout( hbox, hboxLayout );
2610 hbox.SetName( "HBox");
2612 std::vector< Control > controls;
2613 controls.push_back( CreateLeafControl( 40, 40 ) );
2614 controls.push_back( CreateLeafControl( 60, 40 ) );
2615 controls.push_back( CreateLeafControl( 80, 40 ) );
2616 controls.push_back( CreateLeafControl( 100, 40 ) );
2618 for( auto&& iter : controls )
2622 hbox.SetParentOrigin( ParentOrigin::CENTER );
2623 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2626 // Ensure layouting happens
2627 application.SendNotification();
2628 application.Render();
2630 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2631 // hbox left justifies elements
2632 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2633 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2634 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2635 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2637 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2638 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2639 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2640 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2642 controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
2643 controls[2].Lower(); // 2->1; 2, 1, 3, 0
2645 application.SendNotification();
2646 application.Render();
2648 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2649 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2650 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2651 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2653 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2654 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2655 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2656 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2661 int UtcDaliLayouting_HboxLayout_TargetSize(void)
2663 ToolkitTestApplication application;
2664 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
2666 Stage stage = Stage::GetCurrent();
2667 auto hbox = Control::New();
2668 auto hboxLayout = LinearLayout::New();
2669 DevelControl::SetLayout( hbox, hboxLayout );
2670 hbox.SetName( "HBox");
2672 std::vector< Control > controls;
2673 controls.push_back( CreateLeafControl( 40, 40 ) );
2674 for( auto&& iter : controls )
2676 iter.SetSize( 100, 100 );
2679 hbox.SetParentOrigin( ParentOrigin::CENTER );
2680 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2683 // Ensure layouting happens
2684 application.SendNotification();
2685 application.Render();
2687 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
2688 // hbox left justifies elements
2689 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2690 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2695 int UtcDaliLayouting_LayoutChildren01(void)
2697 ToolkitTestApplication application;
2698 tet_infoline(" UtcDaliLayouting_LayoutChildren01");
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 auto hboxLayout = LinearLayout::New();
2709 DevelControl::SetLayout( hbox, hboxLayout );
2710 rootControl.Add( hbox );
2712 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2714 tet_infoline("Test removal by removing child actor from parent container" );
2717 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2719 auto& hboxImpl = GetImplementation( hboxLayout );
2720 tet_infoline("Test child actor still has hbox layout " );
2721 DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
2723 tet_infoline("Test hbox layout has no parent " );
2724 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2729 int UtcDaliLayouting_LayoutChildren02(void)
2731 ToolkitTestApplication application;
2732 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2734 Stage stage = Stage::GetCurrent();
2736 auto rootControl = Control::New();
2737 auto absoluteLayout = AbsoluteLayout::New();
2738 DevelControl::SetLayout( rootControl, absoluteLayout );
2739 stage.Add( rootControl );
2741 auto hbox = Control::New();
2742 auto hboxLayout = LinearLayout::New();
2743 DevelControl::SetLayout( hbox, hboxLayout );
2744 rootControl.Add( hbox );
2746 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2748 tet_infoline("Test removal by removing child layout from parent layout" );
2749 absoluteLayout.Remove( hboxLayout );
2751 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2753 auto& hboxImpl = GetImplementation( hboxLayout );
2755 tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
2756 DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
2757 DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
2759 tet_infoline("Check orphaned layout has no parent");
2760 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2766 int UtcDaliLayouting_LayoutChildren03(void)
2768 ToolkitTestApplication application;
2769 tet_infoline(" UtcDaliLayouting_LayoutChildren03");
2771 Stage stage = Stage::GetCurrent();
2773 auto rootControl = Control::New();
2774 auto absoluteLayout = AbsoluteLayout::New();
2775 DevelControl::SetLayout( rootControl, absoluteLayout );
2776 stage.Add( rootControl );
2778 auto hbox = Control::New();
2779 tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
2780 auto hboxLayout = LinearLayout::New();
2781 rootControl.Add( hbox );
2783 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2785 tet_infoline("Then setting a layout on the child container");
2786 DevelControl::SetLayout( hbox, hboxLayout );
2788 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2790 auto& hboxImpl = GetImplementation( hboxLayout );
2791 auto& absImpl = GetImplementation( absoluteLayout );
2792 DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
2793 DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
2798 int UtcDaliLayouting_SetLayoutOrder01(void)
2800 ToolkitTestApplication application;
2801 tet_infoline(" UtcDaliLayouting_SetLayoutOrder01 - Call SetLayout after adding the control to the root layout");
2803 Stage stage = Stage::GetCurrent();
2805 auto rootControl = Control::New();
2806 auto absoluteLayout = AbsoluteLayout::New();
2807 DevelControl::SetLayout( rootControl, absoluteLayout );
2808 rootControl.SetName( "AbsoluteLayout" );
2809 stage.Add( rootControl );
2811 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
2812 auto hbox = Control::New();
2813 auto hboxLayout = LinearLayout::New();
2814 hbox.SetName( "HBox");
2816 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
2817 rootControl.Add( hbox );
2819 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
2820 DevelControl::SetLayout( hbox, hboxLayout );
2822 // Add a Child control
2823 std::vector< Control > controls;
2824 controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
2825 for( auto&& iter : controls )
2830 // Ensure layouting happens
2831 application.SendNotification();
2832 application.Render();
2834 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2839 int UtcDaliLayouting_SetLayoutOrder02(void)
2841 ToolkitTestApplication application;
2842 tet_infoline(" UtcDaliLayouting_SetLayoutOrder02 - Test the layout item order and the control order");
2844 Stage stage = Stage::GetCurrent();
2846 auto rootControl = Control::New();
2847 auto absoluteLayout = AbsoluteLayout::New();
2848 DevelControl::SetLayout( rootControl, absoluteLayout );
2849 rootControl.SetName( "AbsoluteLayout" );
2850 stage.Add( rootControl );
2852 auto hbox = Control::New();
2853 auto hboxLayout = LinearLayout::New();
2854 hbox.SetName( "HBox");
2856 rootControl.Add( hbox );
2858 DevelControl::SetLayout( hbox, hboxLayout );
2860 // Add child controls
2861 std::vector< Control > controls;
2862 controls.push_back( CreateLeafControl( 100, 100 ) ); // 0
2863 controls.push_back( CreateLeafControl( 100, 100 ) ); // 1
2864 controls.push_back( CreateLeafControl( 100, 100 ) ); // 2
2866 for( auto&& iter : controls )
2871 // Ensure layouting happens
2872 application.SendNotification();
2873 application.Render();
2875 TestLayoutItemOrder( controls, hboxLayout );
2877 tet_infoline("RaiseToTop");
2879 controls[0].RaiseToTop(); // 1 2 0
2881 TestLayoutItemOrder( controls, hboxLayout );
2883 tet_infoline("LowerToBottom");
2885 controls[2].LowerToBottom(); // 2 1 0
2887 TestLayoutItemOrder( controls, hboxLayout );
2889 tet_infoline("Remove / Add");
2891 hbox.Remove( controls[2] ); // 1 0
2892 hbox.Add( controls[2] ); // 1 0 2
2894 TestLayoutItemOrder( controls, hboxLayout );
2896 tet_infoline("SetLayout");
2898 auto vboxLayout = LinearLayout::New();
2899 DevelControl::SetLayout( controls[0], vboxLayout ); // 1 2 0(vbox)
2901 TestLayoutItemOrder( controls, hboxLayout );
2903 tet_infoline("Raise");
2905 controls[0].Raise(); // 1 2 0(vbox)
2907 TestLayoutItemOrder( controls, hboxLayout );
2909 tet_infoline("Lower");
2911 controls[2].Lower(); // 2 1 0(vbox)
2913 TestLayoutItemOrder( controls, hboxLayout );
2915 tet_infoline("SetLayout again");
2917 auto vboxLayout1 = LinearLayout::New();
2918 DevelControl::SetLayout( controls[2], vboxLayout1 ); // 2 1(vbox1) 0(vbox)
2920 TestLayoutItemOrder( controls, hboxLayout );
2922 tet_infoline("SetLayout with empty handle");
2924 DevelControl::SetLayout( controls[0], LayoutItem{} ); // 2 1(vbox1) 0
2926 TestLayoutItemOrder( controls, hboxLayout );
2928 tet_infoline("SetLayout to another control");
2930 DevelControl::SetLayout( controls[2], vboxLayout1 ); // 2(vbox1) 1 0
2932 TestLayoutItemOrder( controls, hboxLayout );
2934 tet_infoline("SetLayout to change layout");
2936 DevelControl::SetLayout( controls[2], vboxLayout1 ); // 2(vbox) 1 0
2938 TestLayoutItemOrder( controls, hboxLayout );
2944 int UtcDaliLayouting_LayoutGroup01(void)
2946 ToolkitTestApplication application;
2947 tet_infoline("UtcDaliLayouting_LayoutGroup01 - Test adding a control to a layout then adding a TextLabel to that control");
2949 Control rootControl;
2950 SetupRootLayoutControl( rootControl );
2952 // Create a parent layout
2953 auto hbox = Control::New();
2954 auto hboxLayout = LinearLayout::New();
2955 hbox.SetName( "HBox");
2956 rootControl.Add( hbox );
2957 DevelControl::SetLayout( hbox, hboxLayout );
2958 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2959 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2960 DevelControl::SetLayoutingRequired( hbox, true );
2961 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2963 tet_infoline("Add a control without SetLayout being called but with layout required set true");
2965 auto control = Control::New();
2966 control.SetName("Control1");
2967 DevelControl::SetLayoutingRequired( control, true );
2968 hbox.Add( control );
2969 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2970 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2971 tet_infoline("Add a Textlabel to the control");
2972 auto textLabel = TextLabel::New("Test text");
2973 textLabel.SetName("TextLabel");
2975 control.Add( textLabel );
2977 // Ensure layouting happens
2978 application.SendNotification();
2979 application.Render();
2981 tet_infoline("Test text is it's natural size");
2982 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2983 tet_infoline("Test control is width of it's parent and height of it's child");
2984 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2989 int UtcDaliLayouting_LayoutGroup02(void)
2991 ToolkitTestApplication application;
2992 tet_infoline("UtcDaliLayouting_LayoutGroup02 - Test control is the size of it's largest child");
2994 Control rootControl;
2995 SetupRootLayoutControl( rootControl );
2997 // Create a parent layout
2998 auto hbox = Control::New();
2999 auto hboxLayout = LinearLayout::New();
3000 DevelControl::SetLayout( hbox, hboxLayout );
3001 hbox.SetName( "HBox");
3002 rootControl.Add( hbox );
3003 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3004 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3005 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
3007 tet_infoline("Add a control without SetLayout being called but with layout required set true");
3009 auto control = Control::New();
3010 control.SetName("Control1");
3011 DevelControl::SetLayoutingRequired( control, true );
3012 hbox.Add( control );
3013 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3014 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
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 tet_infoline("Add another Textlabel to the control");
3022 auto largeTextLabel = TextLabel::New("Test large text");
3023 largeTextLabel.SetName("TextLabel-Large");
3024 control.Add( largeTextLabel );
3026 // Ensure layouting happens
3027 application.SendNotification();
3028 application.Render();
3030 tet_infoline("Test text is it's natural size");
3031 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3032 tet_infoline("Test text is centered in the control, the control is the size of the largest child");
3033 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3035 tet_infoline("Test large text is it's natural size");
3036 DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3037 tet_infoline("Test text is aligned to start as is the size of the control");
3038 DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3040 tet_infoline("Test control is width of it's parent and height of it's largest child");
3041 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3046 int UtcDaliLayouting_LayoutGroup03(void)
3048 ToolkitTestApplication application;
3049 tet_infoline("UtcDaliLayouting_LayoutGroup03 - Test control with a LayoutGroup as a leaf");
3051 Control rootControl;
3052 SetupRootLayoutControl( rootControl );
3054 // Create a parent layout
3055 auto hbox = Control::New();
3056 auto hboxLayout = LinearLayout::New();
3057 DevelControl::SetLayout( hbox, hboxLayout );
3058 hbox.SetName( "HBox");
3059 rootControl.Add( hbox );
3060 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3061 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3062 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
3064 tet_infoline("Add a control without SetLayout being called");
3066 auto control = Control::New();
3067 control.SetName("Control1");
3068 hbox.Add( control );
3069 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3070 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
3072 // Ensure layouting happens
3073 application.SendNotification();
3074 application.Render();
3076 tet_infoline("Test control is width of it's parent and exact given height");
3077 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3078 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3084 int UtcDaliLayouting_LayoutGroup04(void)
3086 ToolkitTestApplication application;
3087 tet_infoline("UtcDaliLayouting_LayoutGroup04 - Test control with a LayoutGroup as a leaf and with SetLayotRequired = true");
3089 Control rootControl;
3090 SetupRootLayoutControl( rootControl );
3092 // Create a parent layout
3093 auto hbox = Control::New();
3094 auto hboxLayout = LinearLayout::New();
3095 DevelControl::SetLayout( hbox, hboxLayout );
3096 hbox.SetName( "HBox");
3097 rootControl.Add( hbox );
3098 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3099 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3100 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
3102 tet_infoline("Add a control without SetLayout being called");
3104 auto control = Control::New();
3105 control.SetName("Control1");
3106 DevelControl::SetLayoutingRequired( control, true );
3107 hbox.Add( control );
3108 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3109 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
3111 // Ensure layouting happens
3112 application.SendNotification();
3113 application.Render();
3115 tet_infoline("Test control is width of it's parent and exact given height");
3116 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3117 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3122 int UtcDaliLayouting_IsLayoutingRequired(void)
3124 ToolkitTestApplication application;
3125 tet_infoline("UtcDaliLayouting_IsLayoutingRequired - Test setting the SetLayoutRequired and then check if flag was set");
3127 Control rootControl;
3128 SetupRootLayoutControl( rootControl );
3130 // Create a parent layout
3131 auto hbox = Control::New();
3132 auto hboxLayout = LinearLayout::New();
3133 DevelControl::SetLayout( hbox, hboxLayout );
3134 hbox.SetName( "HBox");
3135 rootControl.Add( hbox );
3136 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3137 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3138 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
3140 tet_infoline("Add a control without SetLayout being called");
3142 auto control = Control::New();
3143 control.SetName("Control1");
3144 DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), false, TEST_LOCATION );
3145 DevelControl::SetLayoutingRequired( control, true );
3146 hbox.Add( control );
3147 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3148 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
3150 // Ensure layouting happens
3151 application.SendNotification();
3152 application.Render();
3154 tet_infoline("Test control is width of it's parent and exact given height");
3155 DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), true, TEST_LOCATION );
3160 int UtcDaliLayouting_LayoutGroupWithPadding01(void)
3162 ToolkitTestApplication application;
3163 tet_infoline("UtcDaliLayouting_LayoutGroupWithPadding01 - Test adding a control to a layout that has padding");
3165 Control rootControl;
3166 SetupRootLayoutControl( rootControl );
3168 // Create a parent layout
3169 auto hbox = Control::New();
3170 auto hboxLayout = LinearLayout::New();
3171 hbox.SetName( "HBox");
3172 rootControl.Add( hbox );
3173 DevelControl::SetLayout( hbox, hboxLayout );
3174 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3175 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3176 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
3178 tet_infoline("Add a control without SetLayout being called");
3180 auto control = Control::New();
3181 control.SetName("Control1");
3182 DevelControl::SetLayoutingRequired( control, true );
3183 hbox.Add( control );
3184 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3185 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3187 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
3188 tet_printf( "Adding Padding to control");
3189 control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
3191 tet_infoline("Add a Textlabel to the control");
3192 auto textLabel = TextLabel::New("Test text");
3193 textLabel.SetName("TextLabel");
3194 control.Add( textLabel );
3196 // Ensure layouting happens
3197 application.SendNotification();
3198 application.Render();
3200 tet_infoline("Test text is it's natural size");
3201 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3202 tet_infoline("Test control is size of it's child and control it's own padding");
3203 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 245.0f, 86.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3208 int UtcDaliLayouting_LayoutGroupWithChildMargin01(void)
3210 ToolkitTestApplication application;
3211 tet_infoline("UtcDaliLayouting_LayoutGroupWithChildMargin01 - Test adding a control with padding to a layout that has padding");
3213 Control rootControl;
3214 SetupRootLayoutControl( rootControl );
3216 // Create a parent layout
3217 auto hbox = Control::New();
3218 auto hboxLayout = LinearLayout::New();
3219 hbox.SetName( "HBox");
3220 rootControl.Add( hbox );
3221 DevelControl::SetLayout( hbox, hboxLayout );
3222 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3223 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3224 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
3226 tet_infoline("Add a control without SetLayout being called");
3228 auto control = Control::New();
3229 control.SetName("Control1");
3230 DevelControl::SetLayoutingRequired( control, true );
3231 hbox.Add( control );
3232 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3233 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3235 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
3236 tet_printf( "Adding Padding to control");
3237 control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
3239 tet_infoline("Add a Textlabel to the control");
3240 auto textLabel = TextLabel::New("Test text");
3241 const Extents CHILD_MARGIN = Extents( 10, 0, 5, 0 );
3242 textLabel.SetProperty( Toolkit::Control::Property::MARGIN, CHILD_MARGIN );
3243 textLabel.SetName("TextLabel");
3244 control.Add( textLabel );
3246 // Ensure layouting happens
3247 application.SendNotification();
3248 application.Render();
3250 tet_infoline("Test text is it's natural size");
3251 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3252 tet_infoline("Test control is width of it's parent and height of it's child");
3253 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 255.0f, 91.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3258 int UtcDaliLayouting_SetLayout(void)
3260 ToolkitTestApplication application;
3261 tet_infoline(" UtcDaliLayouting_SetLayout - Test reusing layouts");
3263 Control rootControl;
3264 SetupRootLayoutControl( rootControl );
3266 auto container = Control::New();
3267 auto horizontalLayout = LinearLayout::New();
3268 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
3269 DevelControl::SetLayout( container, horizontalLayout );
3270 container.SetName( "Container" );
3271 rootControl.Add( container );
3273 std::vector< Control > controls;
3274 controls.push_back( CreateLeafControl( 40, 40 ) );
3275 controls.push_back( CreateLeafControl( 60, 60 ) );
3277 for( auto&& iter : controls )
3279 container.Add( iter );
3282 container.SetParentOrigin( ParentOrigin::CENTER );
3283 container.SetAnchorPoint( AnchorPoint::CENTER );
3285 // Ensure layouting happens
3286 application.SendNotification();
3287 application.Render();
3289 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3290 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3291 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3293 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3294 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3295 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3298 auto verticalLayout = LinearLayout::New();
3299 verticalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
3300 DevelControl::SetLayout( container, verticalLayout );
3302 application.SendNotification();
3303 application.Render();
3305 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3306 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3307 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3309 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3310 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3311 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3314 DevelControl::SetLayout( container, horizontalLayout );
3316 application.SendNotification();
3317 application.Render();
3319 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3320 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3321 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3323 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3324 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3325 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3328 DevelControl::SetLayout( container, verticalLayout );
3330 application.SendNotification();
3331 application.Render();
3333 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3334 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3335 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3337 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3338 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3339 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3344 int UtcDaliLayouting_StageAdd(void)
3346 ToolkitTestApplication application;
3347 tet_infoline(" UtcDaliLayouting_StageAdd");
3349 Stage stage = Stage::GetCurrent();
3351 AbsoluteLayout absoluteLayout = AbsoluteLayout::New();
3352 Control container = Control::New();
3353 container.SetName( "Container" );
3354 DevelControl::SetLayout( container, absoluteLayout );
3355 container.SetAnchorPoint( Dali::AnchorPoint::CENTER );
3356 container.SetParentOrigin( Dali::ParentOrigin::CENTER );
3358 Control child = Control::New();
3359 child.SetAnchorPoint( Dali::AnchorPoint::TOP_LEFT );
3360 child.SetPosition( 0.0f, 0.0f );
3361 child.SetSize( 480.0f, 180.0f );
3362 child.SetName( "Child Control" );
3363 container.Add( child );
3365 // Ensure layouting happens
3366 application.SendNotification();
3367 application.Render();
3369 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3370 DALI_TEST_EQUALS( child.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3372 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); // Not re-laid out
3373 DALI_TEST_EQUALS( child.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3375 application.SendNotification();
3376 application.Render();
3378 // Add container to stage here
3379 // Should call RequestLayout() to measure and layout
3380 stage.Add( container );
3382 application.SendNotification();
3383 application.Render();
3385 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3386 DALI_TEST_EQUALS( child.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3388 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); // Stage Size
3389 DALI_TEST_EQUALS( child.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );