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 url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 200, 200 ) );
1667 imageView.SetImage( url );
1669 // Ensure layouting happenss
1670 application.SendNotification();
1671 application.Render();
1673 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1674 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1676 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1677 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1679 // Ensure layouting happenss
1680 application.SendNotification();
1681 application.Render();
1683 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1684 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1686 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1687 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1689 // Ensure layouting happenss
1690 application.SendNotification();
1691 application.Render();
1693 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1694 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1696 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1697 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1699 Image image = FrameBufferImage::New( 50, 50, Pixel::RGBA8888 );
1700 imageView.SetImage( image );
1702 // Ensure layouting happenss
1703 application.SendNotification();
1704 application.Render();
1706 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1707 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1709 Property::Map imagePropertyMap;
1710 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1711 imagePropertyMap[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
1712 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 150;
1713 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 150;
1714 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap );
1716 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1717 // Ensure layouting happenss
1718 application.SendNotification();
1719 application.Render();
1721 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 325.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1722 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1727 int UtcDaliLayouting_HboxLayout_TextLabel(void)
1729 ToolkitTestApplication application;
1730 tet_infoline(" UtcDaliLayouting_HboxLayout - Use text label for leaf");
1732 Stage stage = Stage::GetCurrent();
1734 auto hbox = Control::New();
1735 auto hboxLayout = LinearLayout::New();
1736 DevelControl::SetLayout( hbox, hboxLayout );
1737 hbox.SetName( "HBox" );
1738 hbox.SetParentOrigin( ParentOrigin::CENTER );
1739 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1741 std::vector< Control > controls;
1742 TextLabel textLabel = CreateTextLabel( "W" );
1743 controls.push_back( textLabel );
1744 hbox.Add( textLabel );
1747 // Ensure layouting happens
1748 application.SendNotification();
1749 application.Render();
1751 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1752 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 54.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1754 textLabel.SetProperty( TextLabel::Property::TEXT, "WWWW" );
1756 // Ensure layouting happens
1757 application.SendNotification();
1758 application.Render();
1760 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1761 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 216.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1763 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
1765 // Ensure layouting happens
1766 application.SendNotification();
1767 application.Render();
1769 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1770 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1772 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1773 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1775 // Ensure layouting happens
1776 application.SendNotification();
1777 application.Render();
1779 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1780 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1782 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1783 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1785 // Ensure layouting happens
1786 application.SendNotification();
1787 application.Render();
1789 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1790 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1797 int UtcDaliLayouting_HboxLayout_Padding01(void)
1799 ToolkitTestApplication application;
1800 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
1802 Stage stage = Stage::GetCurrent();
1803 auto hbox = Control::New();
1804 auto hboxLayout = LinearLayout::New();
1805 DevelControl::SetLayout( hbox, hboxLayout );
1806 hbox.SetName( "HBox");
1808 std::vector< Control > controls;
1809 controls.push_back( CreateLeafControl( 40, 40 ) );
1810 controls.push_back( CreateLeafControl( 60, 40 ) );
1811 controls.push_back( CreateLeafControl( 80, 40 ) );
1812 controls.push_back( CreateLeafControl( 100, 40 ) );
1814 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1815 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
1816 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1818 for( auto&& iter : controls )
1822 hbox.SetParentOrigin( ParentOrigin::CENTER );
1823 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1826 // Ensure layouting happens
1827 application.SendNotification();
1828 application.Render();
1830 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1831 // hbox left justifies elements
1832 tet_infoline("Test Child Actor Position");
1833 float xPositionOfControlBeingTested = 0.0f;
1834 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1836 0.0f ), 0.0001f, TEST_LOCATION );
1837 xPositionOfControlBeingTested += 40.0f;
1839 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1840 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1841 0.0001f, TEST_LOCATION );
1843 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1844 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1846 xPositionOfControlBeingTested += 80.0f;
1847 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1849 tet_infoline("Test Child Actor Size");
1850 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1852 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1853 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
1854 0.0001f, TEST_LOCATION );
1856 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1857 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1862 int UtcDaliLayouting_HboxLayout_Padding02(void)
1864 ToolkitTestApplication application;
1865 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
1867 Stage stage = Stage::GetCurrent();
1868 auto hbox = Control::New();
1869 auto hboxLayout = LinearLayout::New();
1870 DevelControl::SetLayout( hbox, hboxLayout );
1871 hbox.SetName( "HBox");
1873 std::vector< Control > controls;
1874 controls.push_back( CreateLeafControl( 40, 40 ) );
1875 controls.push_back( CreateLeafControl( 60, 40 ) );
1876 controls.push_back( CreateLeafControl( 80, 40 ) );
1877 controls.push_back( CreateLeafControl( 100, 40 ) );
1879 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1881 for( auto&& iter : controls )
1883 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1886 hbox.SetParentOrigin( ParentOrigin::CENTER );
1887 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1890 // Ensure layouting happens
1891 application.SendNotification();
1892 application.Render();
1894 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1895 // hbox left justifies elements
1896 tet_infoline("Test Child Actor Position");
1897 float xPositionOfControlBeingTested = 0.0f;
1898 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
1900 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1901 yPositionOfControlBeingTested,
1902 0.0f ), 0.0001f, TEST_LOCATION );
1903 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1905 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1906 yPositionOfControlBeingTested,
1908 0.0001f, TEST_LOCATION );
1910 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1911 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1912 yPositionOfControlBeingTested,
1913 0.0f ), 0.0001f, TEST_LOCATION );
1915 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1916 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1917 yPositionOfControlBeingTested,
1918 0.0f ), 0.0001f, TEST_LOCATION );
1920 tet_infoline("Test Child Actor Size");
1921 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1922 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1923 0.0f ), 0.0001f, TEST_LOCATION );
1925 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1926 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1927 0.0f ), 0.0001f, TEST_LOCATION );
1929 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
1930 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1931 0.0f ), 0.0001f, TEST_LOCATION );
1933 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1934 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1935 0.0f ), 0.0001f, TEST_LOCATION );
1941 int UtcDaliLayouting_HboxLayout_Padding03(void)
1943 ToolkitTestApplication application;
1944 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
1946 Stage stage = Stage::GetCurrent();
1947 auto hbox = Control::New();
1948 auto hboxLayout = LinearLayout::New();
1949 DevelControl::SetLayout( hbox, hboxLayout );
1950 hbox.SetName( "HBox");
1952 std::vector< Control > controls;
1953 controls.push_back( CreateLeafControl( 40, 40 ) );
1954 controls.push_back( CreateLeafControl( 40, 40 ) );
1955 controls.push_back( CreateLeafControl( 40, 40 ) );
1957 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1958 tet_printf( "\nAdding Padding to control at index 1 \n" );
1959 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1961 for( auto&& iter : controls )
1965 hbox.SetParentOrigin( ParentOrigin::CENTER );
1966 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1969 // Ensure layouting happens
1970 application.SendNotification();
1971 application.Render();
1973 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1974 // hbox left justifies elements
1975 tet_infoline("Test Child Actor Position");
1976 float xPositionOfControlBeingTested = 0.0f;
1977 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1979 0.0f ), 0.0001f, TEST_LOCATION );
1980 xPositionOfControlBeingTested += 40.0f;
1982 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1983 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1984 0.0001f, TEST_LOCATION );
1986 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1987 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1989 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
1990 tet_printf( "\nChanging Padding to control at index 1 \n" );
1991 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
1993 // Ensure layouting happens
1994 application.SendNotification();
1995 application.Render();
1997 xPositionOfControlBeingTested = 0.0f; // reset
1999 tet_infoline("Test Child Actor Position");
2000 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2002 0.0f ), 0.0001f, TEST_LOCATION );
2003 xPositionOfControlBeingTested += 40.0f;
2005 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2006 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
2007 0.0001f, TEST_LOCATION );
2009 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
2010 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
2011 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2013 tet_infoline("Test Child Actor Size");
2014 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2016 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
2017 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
2018 0.0001f, TEST_LOCATION );
2020 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2025 int UtcDaliLayouting_HboxLayout_Padding04(void)
2027 ToolkitTestApplication application;
2028 tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
2030 // Adding padding to the layout should offset the positioning of the children.
2032 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2033 const Size CONTROL_SIZE = Size( 40, 40 );
2035 Stage stage = Stage::GetCurrent();
2036 // Create a root layout, ideally Dali would have a default layout in the root layer.
2037 // Without this root layer the LinearLayout (or any other layout) will not
2038 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2039 // It uses the default stage size and ideally should have a layout added to it.
2040 auto rootLayoutControl = Control::New();
2041 rootLayoutControl.SetName( "AbsoluteLayout");
2042 auto rootLayout = AbsoluteLayout::New();
2043 DevelControl::SetLayout( rootLayoutControl, rootLayout );
2044 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2045 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2046 stage.Add( rootLayoutControl );
2048 auto hbox = Control::New();
2049 auto hboxLayout = LinearLayout::New();
2050 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2051 DevelControl::SetLayout( hbox, hboxLayout );
2052 hbox.SetName( "HBox");
2053 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2054 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2055 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2057 std::vector< Control > controls;
2058 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
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 ) );
2063 for( auto&& iter : controls )
2068 hbox.SetParentOrigin( ParentOrigin::CENTER );
2069 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2070 rootLayoutControl.Add( hbox );
2072 // Ensure layouting happens
2073 application.SendNotification();
2074 application.Render();
2076 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2077 application.SendNotification();
2079 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2080 // hbox left justifies elements
2081 tet_infoline("Test Child Actor Position");
2083 auto controlXPosition=0.0f;
2085 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
2086 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2088 0.0f ), 0.0001f, TEST_LOCATION );
2090 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
2091 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2094 0.0001f, TEST_LOCATION );
2096 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
2097 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2099 0.0f ), 0.0001f, TEST_LOCATION );
2101 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
2102 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2104 0.0f ), 0.0001f, TEST_LOCATION );
2106 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
2107 auto totalControlsHeight = CONTROL_SIZE.height;
2109 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2110 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2111 0.0f ), 0.0001f, TEST_LOCATION );
2117 int UtcDaliLayouting_HboxLayout_Padding05(void)
2119 ToolkitTestApplication application;
2120 tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
2122 // Adding padding to the layout should offset the positioning of the children.
2124 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2125 const Size CONTROL_SIZE = Size( 40, 40 );
2127 Stage stage = Stage::GetCurrent();
2128 // Create a root layout, ideally Dali would have a default layout in the root layer.
2129 // Without this root layer the LinearLayout (or any other layout) will not
2130 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2131 // It uses the default stage size and ideally should have a layout added to it.
2132 auto rootLayoutControl = Control::New();
2133 rootLayoutControl.SetName( "AbsoluteLayout");
2134 auto rootLayout = AbsoluteLayout::New();
2135 DevelControl::SetLayout( rootLayoutControl, rootLayout );
2136 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2137 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2138 stage.Add( rootLayoutControl );
2140 auto hbox = Control::New();
2141 auto hboxLayout = LinearLayout::New();
2142 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2143 DevelControl::SetLayout( hbox, hboxLayout );
2144 hbox.SetName( "HBox");
2145 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2146 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2147 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2149 std::vector< Control > controls;
2150 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
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 ) );
2155 for( auto&& iter : controls )
2160 hbox.SetParentOrigin( ParentOrigin::CENTER );
2161 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2162 rootLayoutControl.Add( hbox );
2164 // Ensure layouting happens
2165 application.SendNotification();
2166 application.Render();
2168 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2169 application.SendNotification();
2171 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2172 // hbox left justifies elements
2173 tet_infoline("Test Child Actor Position");
2175 auto controlXPosition=0.0f;
2177 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
2178 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2180 0.0f ), 0.0001f, TEST_LOCATION );
2182 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
2183 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2186 0.0001f, TEST_LOCATION );
2188 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
2189 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2191 0.0f ), 0.0001f, TEST_LOCATION );
2193 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
2194 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2196 0.0f ), 0.0001f, TEST_LOCATION );
2198 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
2199 auto totalControlsHeight = CONTROL_SIZE.height;
2201 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2202 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2203 0.0f ), 0.0001f, TEST_LOCATION );
2205 // Change layout padding
2206 const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
2207 tet_printf( "\nChanging Padding to control at index 1 \n" );
2208 hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
2210 // Ensure layouting happens
2211 application.SendNotification();
2212 application.Render();
2214 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2215 application.SendNotification();
2217 controlXPosition = NEW_LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
2218 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
2219 NEW_LAYOUT_PADDING.top,
2220 0.0f ), 0.0001f, TEST_LOCATION );
2222 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
2223 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2224 NEW_LAYOUT_PADDING.top,
2226 0.0001f, TEST_LOCATION );
2228 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
2229 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2230 NEW_LAYOUT_PADDING.top,
2231 0.0f ), 0.0001f, TEST_LOCATION );
2233 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
2234 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2235 NEW_LAYOUT_PADDING.top,
2236 0.0f ), 0.0001f, TEST_LOCATION );
2237 totalControlsWidth = CONTROL_SIZE.width * controls.size();
2238 totalControlsHeight = CONTROL_SIZE.height;
2240 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
2241 totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
2242 0.0f ), 0.0001f, TEST_LOCATION );
2248 int UtcDaliLayouting_HboxLayout_Margin01(void)
2250 ToolkitTestApplication application;
2251 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
2253 Stage stage = Stage::GetCurrent();
2254 auto hbox = Control::New();
2255 auto hboxLayout = LinearLayout::New();
2256 DevelControl::SetLayout( hbox, hboxLayout );
2257 hbox.SetName( "HBox");
2259 std::vector< Control > controls;
2260 controls.push_back( CreateLeafControl( 40, 40 ) );
2261 controls.push_back( CreateLeafControl( 60, 40 ) );
2262 controls.push_back( CreateLeafControl( 80, 40 ) );
2263 controls.push_back( CreateLeafControl( 100, 40 ) );
2265 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
2266 tet_printf( "\nAdding Margin to control at index 1 \n" );
2267 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
2269 for( auto&& iter : controls )
2273 hbox.SetParentOrigin( ParentOrigin::CENTER );
2274 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2277 // Ensure layouting happens
2278 application.SendNotification();
2279 application.Render();
2281 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2282 // hbox left justifies elements
2283 tet_infoline("Test Child Actor Position");
2284 auto xPositionOfControlBeingTested = 0.0f;
2285 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2287 0.0f ), 0.0001f, TEST_LOCATION );
2288 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
2290 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2291 380.0f + CONTROL_MARGIN.top, 0.0f ),
2292 0.0001f, TEST_LOCATION );
2294 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
2295 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2297 xPositionOfControlBeingTested += 80.0f;
2298 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2300 tet_infoline("Test Child Actor Size is the same after Margin added");
2301 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2302 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
2303 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2304 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2310 int UtcDaliLayouting_VboxLayout01(void)
2312 ToolkitTestApplication application;
2313 tet_infoline(" UtcDaliLayouting_VboxLayout01");
2315 Stage stage = Stage::GetCurrent();
2316 auto vbox = Control::New();
2317 auto vboxLayout = LinearLayout::New();
2318 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2319 vboxLayout.SetAlignment( LinearLayout::Alignment::TOP | LinearLayout::Alignment::CENTER_HORIZONTAL );
2320 DevelControl::SetLayout( vbox, vboxLayout );
2321 vbox.SetName( "Vbox");
2323 std::vector< Control > controls;
2324 controls.push_back( CreateLeafControl( 40, 40 ) );
2325 controls.push_back( CreateLeafControl( 60, 60 ) );
2326 controls.push_back( CreateLeafControl( 80, 80 ) );
2327 controls.push_back( CreateLeafControl( 100, 100 ) );
2329 for( auto&& iter : controls )
2333 vbox.SetParentOrigin( ParentOrigin::CENTER );
2334 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2337 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2340 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2342 // Ensure layouting happens
2343 application.SendNotification();
2344 application.Render();
2346 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
2347 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2348 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2349 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2350 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2352 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2353 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2354 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2355 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2360 int UtcDaliLayouting_VboxLayout02(void)
2362 ToolkitTestApplication application;
2363 tet_infoline(" UtcDaliLayouting_VboxLayout01");
2365 Stage stage = Stage::GetCurrent();
2367 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
2368 // LayoutGroup for this to happen automatically.
2370 // For this test, add an hbox instead
2371 auto rootControl = Control::New();
2372 auto absoluteLayout = AbsoluteLayout::New();
2373 DevelControl::SetLayout( rootControl, absoluteLayout );
2374 rootControl.SetName( "AbsoluteLayout");
2375 stage.Add( rootControl );
2377 auto vbox = Control::New();
2378 auto vboxLayout = LinearLayout::New();
2379 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2380 vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
2381 DevelControl::SetLayout( vbox, vboxLayout );
2382 vbox.SetName( "Vbox");
2383 rootControl.Add( vbox );
2385 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2386 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2388 std::vector< Control > controls;
2389 controls.push_back( CreateLeafControl( 40, 40 ) );
2390 controls.push_back( CreateLeafControl( 60, 60 ) );
2391 controls.push_back( CreateLeafControl( 80, 80 ) );
2392 controls.push_back( CreateLeafControl( 100, 100 ) );
2394 for( auto&& iter : controls )
2398 vbox.SetParentOrigin( ParentOrigin::CENTER );
2399 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2401 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2404 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2406 // Ensure layouting happens
2407 application.SendNotification();
2408 application.Render();
2410 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
2411 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
2413 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
2414 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2415 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2417 // 3rd control is set to match parent - this should also be 100 wide
2418 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2419 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2420 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2421 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2423 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2424 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2425 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2426 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2432 int UtcDaliLayouting_VboxLayout03(void)
2434 ToolkitTestApplication application;
2435 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
2437 Stage stage = Stage::GetCurrent();
2439 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
2440 // LayoutGroup for this to happen automatically.
2442 // For this test, add an hbox instead
2443 auto hbox = Control::New();
2444 auto hboxLayout = LinearLayout::New();
2445 DevelControl::SetLayout( hbox, hboxLayout );
2446 hbox.SetName( "Hbox");
2449 auto vbox = Control::New();
2450 auto vboxLayout = LinearLayout::New();
2451 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
2452 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2453 vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
2455 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
2457 DevelControl::SetLayout( vbox, vboxLayout );
2458 vbox.SetName( "Vbox");
2461 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2462 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2464 std::vector< Control > controls;
2465 controls.push_back( CreateLeafControl( 40, 40 ) );
2466 controls.push_back( CreateLeafControl( 60, 60 ) );
2467 controls.push_back( CreateLeafControl( 80, 80 ) );
2468 controls.push_back( CreateLeafControl( 100, 100 ) );
2470 for( auto&& iter : controls )
2474 vbox.SetParentOrigin( ParentOrigin::CENTER );
2475 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2477 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2480 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2482 // Ensure layouting happens
2483 application.SendNotification();
2484 application.Render();
2486 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
2487 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
2489 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
2490 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2491 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2493 // 3rd control is set to match parent - this should also be 100 wide
2494 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2495 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2496 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2497 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2499 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2500 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2501 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2502 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2507 int UtcDaliLayouting_VboxLayout_Padding(void)
2509 ToolkitTestApplication application;
2510 tet_infoline("UtcDaliLayouting_VboxLayout_Padding - Adding Padding to the vbox");
2512 // Adding padding to the layout should offset the positioning of the children.
2514 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2515 const Size CONTROL_SIZE = Size( 40, 40 );
2517 Stage stage = Stage::GetCurrent();
2518 // Create a root layout, ideally Dali would have a default layout in the root layer.
2519 // Without this root layer the LinearLayout (or any other layout) will not
2520 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2521 // It uses the default stage size and ideally should have a layout added to it.
2522 auto rootLayoutControl = Control::New();
2523 rootLayoutControl.SetName( "AbsoluteLayout");
2524 auto rootLayout = AbsoluteLayout::New();
2525 DevelControl::SetLayout( rootLayoutControl, rootLayout );
2526 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2527 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2528 stage.Add( rootLayoutControl );
2530 auto vbox = Control::New();
2531 auto vboxLayout = LinearLayout::New();
2532 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2533 DevelControl::SetLayout( vbox, vboxLayout );
2534 vbox.SetName( "VBox");
2535 vbox.SetProperty( Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2536 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2537 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2539 std::vector< Control > controls;
2540 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
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 ) );
2545 for( auto&& iter : controls )
2550 vbox.SetParentOrigin( ParentOrigin::CENTER );
2551 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2552 rootLayoutControl.Add( vbox );
2554 // Ensure layouting happens
2555 application.SendNotification();
2556 application.Render();
2558 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2559 application.SendNotification();
2561 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
2562 tet_infoline("Test Child Actor Position");
2564 auto controlYPosition = 0.0f;
2566 controlYPosition = LAYOUT_PADDING.top; // First child positioned at offset defined by the padding
2567 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2569 0.0f ), 0.0001f, TEST_LOCATION );
2571 controlYPosition += CONTROL_SIZE.height; // Second child positioned is the position of the first child + the first child's height.
2572 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2575 0.0001f, TEST_LOCATION );
2577 controlYPosition += CONTROL_SIZE.height; // Third child positioned adjacent to second
2578 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2580 0.0f ), 0.0001f, TEST_LOCATION );
2582 controlYPosition += CONTROL_SIZE.height; // Forth passed adjacent to the third
2583 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2585 0.0f ), 0.0001f, TEST_LOCATION );
2587 auto totalControlsWidth = CONTROL_SIZE.width;
2588 auto totalControlsHeight = CONTROL_SIZE.height * controls.size();
2590 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2591 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2592 0.0f ), 0.0001f, TEST_LOCATION );
2598 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
2600 ToolkitTestApplication application;
2601 tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
2602 tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
2604 Stage stage = Stage::GetCurrent();
2606 auto hbox = Control::New();
2607 auto hboxLayout = Test::CustomLayout::New();
2608 DevelControl::SetLayout( hbox, hboxLayout );
2609 hbox.SetName( "HBox");
2611 std::vector< Control > controls;
2612 controls.push_back( CreateLeafControl( 40, 40 ) );
2613 controls.push_back( CreateLeafControl( 60, 40 ) );
2614 controls.push_back( CreateLeafControl( 80, 40 ) );
2615 controls.push_back( CreateLeafControl( 100, 40 ) );
2617 for( auto&& iter : controls )
2621 hbox.SetParentOrigin( ParentOrigin::CENTER );
2622 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2625 // Ensure layouting happens
2626 application.SendNotification();
2627 application.Render();
2629 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2630 // hbox left justifies elements
2631 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2632 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2633 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2634 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2636 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2637 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2638 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2639 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2641 controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
2642 controls[2].Lower(); // 2->1; 2, 1, 3, 0
2644 application.SendNotification();
2645 application.Render();
2647 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2648 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2649 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2650 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2652 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2653 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2654 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2655 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2660 int UtcDaliLayouting_HboxLayout_TargetSize(void)
2662 ToolkitTestApplication application;
2663 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
2665 Stage stage = Stage::GetCurrent();
2666 auto hbox = Control::New();
2667 auto hboxLayout = LinearLayout::New();
2668 DevelControl::SetLayout( hbox, hboxLayout );
2669 hbox.SetName( "HBox");
2671 std::vector< Control > controls;
2672 controls.push_back( CreateLeafControl( 40, 40 ) );
2673 for( auto&& iter : controls )
2675 iter.SetSize( 100, 100 );
2678 hbox.SetParentOrigin( ParentOrigin::CENTER );
2679 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2682 // Ensure layouting happens
2683 application.SendNotification();
2684 application.Render();
2686 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
2687 // hbox left justifies elements
2688 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2689 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2694 int UtcDaliLayouting_RemoveLayout01(void)
2696 ToolkitTestApplication application;
2697 tet_infoline(" UtcDaliLayouting_RemoveLayout");
2699 Stage stage = Stage::GetCurrent();
2701 auto rootControl = Control::New();
2702 auto absoluteLayout = AbsoluteLayout::New();
2703 DevelControl::SetLayout( rootControl, absoluteLayout );
2704 rootControl.SetName( "AbsoluteLayout" );
2705 stage.Add( rootControl );
2707 auto hbox = Control::New();
2708 auto hboxLayout = LinearLayout::New();
2709 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2710 DevelControl::SetLayout( hbox, hboxLayout );
2711 hbox.SetName( "HBox" );
2713 std::vector< Control > controls;
2714 controls.push_back( CreateLeafControl( 40, 40 ) );
2715 controls.push_back( CreateLeafControl( 60, 40 ) );
2717 for( auto&& iter : controls )
2721 hbox.SetParentOrigin( ParentOrigin::CENTER );
2722 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2723 rootControl.Add( hbox );
2725 tet_infoline("Layout as normal");
2726 application.SendNotification();
2727 application.Render();
2729 tet_infoline("Set an empty layout on hbox container");
2730 LinearLayout emptyLayout;
2731 DevelControl::SetLayout( hbox, emptyLayout );
2733 tet_infoline("Run another layout");
2734 application.SendNotification();
2735 application.Render();
2737 tet_infoline("Check leaf controls haven't moved");
2739 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2740 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2742 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2743 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2748 int UtcDaliLayouting_LayoutChildren01(void)
2750 ToolkitTestApplication application;
2751 tet_infoline(" UtcDaliLayouting_LayoutChildren01");
2753 Stage stage = Stage::GetCurrent();
2755 auto rootControl = Control::New();
2756 auto absoluteLayout = AbsoluteLayout::New();
2757 DevelControl::SetLayout( rootControl, absoluteLayout );
2758 stage.Add( rootControl );
2760 auto hbox = Control::New();
2761 auto hboxLayout = LinearLayout::New();
2762 DevelControl::SetLayout( hbox, hboxLayout );
2763 rootControl.Add( hbox );
2765 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2767 tet_infoline("Test removal by setting empty layout to child container" );
2768 DevelControl::SetLayout( hbox, LayoutItem{} );
2770 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2772 auto& hboxImpl = GetImplementation( hboxLayout );
2774 DALI_TEST_EQUALS( hboxLayout.GetOwner(), empty, TEST_LOCATION );
2775 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2778 hboxImpl.SetLayoutRequested();
2783 int UtcDaliLayouting_LayoutChildren02(void)
2785 ToolkitTestApplication application;
2786 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2788 Stage stage = Stage::GetCurrent();
2790 auto rootControl = Control::New();
2791 auto absoluteLayout = AbsoluteLayout::New();
2792 DevelControl::SetLayout( rootControl, absoluteLayout );
2793 stage.Add( rootControl );
2795 auto hbox = Control::New();
2796 auto hboxLayout = LinearLayout::New();
2797 DevelControl::SetLayout( hbox, hboxLayout );
2798 rootControl.Add( hbox );
2800 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2802 tet_infoline("Test removal by removing child actor from parent container" );
2805 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2807 auto& hboxImpl = GetImplementation( hboxLayout );
2808 tet_infoline("Test child actor still has hbox layout " );
2809 DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
2811 tet_infoline("Test hbox layout has no parent " );
2812 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2817 int UtcDaliLayouting_LayoutChildren03(void)
2819 ToolkitTestApplication application;
2820 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2822 Stage stage = Stage::GetCurrent();
2824 auto rootControl = Control::New();
2825 auto absoluteLayout = AbsoluteLayout::New();
2826 DevelControl::SetLayout( rootControl, absoluteLayout );
2827 stage.Add( rootControl );
2829 auto hbox = Control::New();
2830 auto hboxLayout = LinearLayout::New();
2831 DevelControl::SetLayout( hbox, hboxLayout );
2832 rootControl.Add( hbox );
2834 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2836 tet_infoline("Test removal by removing child layout from parent layout" );
2837 absoluteLayout.Remove( hboxLayout );
2839 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2841 auto& hboxImpl = GetImplementation( hboxLayout );
2843 tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
2844 DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
2845 DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
2847 tet_infoline("Check orphaned layout has no parent");
2848 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2854 int UtcDaliLayouting_LayoutChildren04(void)
2856 ToolkitTestApplication application;
2857 tet_infoline(" UtcDaliLayouting_LayoutChildren03");
2859 Stage stage = Stage::GetCurrent();
2861 auto rootControl = Control::New();
2862 auto absoluteLayout = AbsoluteLayout::New();
2863 DevelControl::SetLayout( rootControl, absoluteLayout );
2864 stage.Add( rootControl );
2866 auto hbox = Control::New();
2867 tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
2868 auto hboxLayout = LinearLayout::New();
2869 rootControl.Add( hbox );
2871 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2873 tet_infoline("Then setting a layout on the child container");
2874 DevelControl::SetLayout( hbox, hboxLayout );
2876 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2878 auto& hboxImpl = GetImplementation( hboxLayout );
2879 auto& absImpl = GetImplementation( absoluteLayout );
2880 DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
2881 DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
2886 int UtcDaliLayouting_SetLayoutOrder01(void)
2888 ToolkitTestApplication application;
2889 tet_infoline(" UtcDaliLayouting_SetLayoutOrder01 - Call SetLayout after adding the control to the root layout");
2891 Stage stage = Stage::GetCurrent();
2893 auto rootControl = Control::New();
2894 auto absoluteLayout = AbsoluteLayout::New();
2895 DevelControl::SetLayout( rootControl, absoluteLayout );
2896 rootControl.SetName( "AbsoluteLayout" );
2897 stage.Add( rootControl );
2899 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
2900 auto hbox = Control::New();
2901 auto hboxLayout = LinearLayout::New();
2902 hbox.SetName( "HBox");
2904 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
2905 rootControl.Add( hbox );
2907 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
2908 DevelControl::SetLayout( hbox, hboxLayout );
2910 // Add a Child control
2911 std::vector< Control > controls;
2912 controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
2913 for( auto&& iter : controls )
2918 // Ensure layouting happens
2919 application.SendNotification();
2920 application.Render();
2922 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2927 int UtcDaliLayouting_SetLayoutOrder02(void)
2929 ToolkitTestApplication application;
2930 tet_infoline(" UtcDaliLayouting_SetLayoutOrder02 - Test the layout item order and the control order");
2932 Stage stage = Stage::GetCurrent();
2934 auto rootControl = Control::New();
2935 auto absoluteLayout = AbsoluteLayout::New();
2936 DevelControl::SetLayout( rootControl, absoluteLayout );
2937 rootControl.SetName( "AbsoluteLayout" );
2938 stage.Add( rootControl );
2940 auto hbox = Control::New();
2941 auto hboxLayout = LinearLayout::New();
2942 hbox.SetName( "HBox");
2944 rootControl.Add( hbox );
2946 DevelControl::SetLayout( hbox, hboxLayout );
2948 // Add child controls
2949 std::vector< Control > controls;
2950 controls.push_back( CreateLeafControl( 100, 100 ) ); // 0
2951 controls.push_back( CreateLeafControl( 100, 100 ) ); // 1
2952 controls.push_back( CreateLeafControl( 100, 100 ) ); // 2
2954 for( auto&& iter : controls )
2959 // Ensure layouting happens
2960 application.SendNotification();
2961 application.Render();
2963 TestLayoutItemOrder( controls, hboxLayout );
2965 tet_infoline("RaiseToTop");
2967 controls[0].RaiseToTop(); // 1 2 0
2969 TestLayoutItemOrder( controls, hboxLayout );
2971 tet_infoline("LowerToBottom");
2973 controls[2].LowerToBottom(); // 2 1 0
2975 TestLayoutItemOrder( controls, hboxLayout );
2977 tet_infoline("Remove / Add");
2979 hbox.Remove( controls[2] ); // 1 0
2980 hbox.Add( controls[2] ); // 1 0 2
2982 TestLayoutItemOrder( controls, hboxLayout );
2984 tet_infoline("SetLayout");
2986 auto vboxLayout = LinearLayout::New();
2987 DevelControl::SetLayout( controls[0], vboxLayout );
2989 TestLayoutItemOrder( controls, hboxLayout );
2991 tet_infoline("Raise");
2993 controls[0].Raise(); // 1 2 0
2995 TestLayoutItemOrder( controls, hboxLayout );
2997 tet_infoline("Lower");
2999 controls[2].Lower(); // 2 1 0
3001 TestLayoutItemOrder( controls, hboxLayout );
3003 tet_infoline("SetLayout again");
3005 auto vboxLayout1 = LinearLayout::New();
3006 DevelControl::SetLayout( controls[2], vboxLayout1 );
3008 TestLayoutItemOrder( controls, hboxLayout );
3010 DevelControl::SetLayout( controls[2], vboxLayout );
3015 int UtcDaliLayouting_LayoutGroup01(void)
3017 ToolkitTestApplication application;
3018 tet_infoline("UtcDaliLayouting_LayoutGroup01 - Test adding a control to a layout then adding a TextLabel to that control");
3020 Control rootControl;
3021 SetupRootLayoutControl( rootControl );
3023 // Create a parent layout
3024 auto hbox = Control::New();
3025 auto hboxLayout = LinearLayout::New();
3026 hbox.SetName( "HBox");
3027 rootControl.Add( hbox );
3028 DevelControl::SetLayout( hbox, hboxLayout );
3029 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3030 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3031 DevelControl::SetLayoutingRequired( hbox, true );
3032 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
3034 tet_infoline("Add a control without SetLayout being called but with layout required set true");
3036 auto control = Control::New();
3037 control.SetName("Control1");
3038 DevelControl::SetLayoutingRequired( control, true );
3039 hbox.Add( control );
3040 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3041 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3042 tet_infoline("Add a Textlabel to the control");
3043 auto textLabel = TextLabel::New("Test text");
3044 textLabel.SetName("TextLabel");
3046 control.Add( textLabel );
3048 // Ensure layouting happens
3049 application.SendNotification();
3050 application.Render();
3052 tet_infoline("Test text is it's natural size");
3053 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3054 tet_infoline("Test control is width of it's parent and height of it's child");
3055 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3060 int UtcDaliLayouting_LayoutGroup02(void)
3062 ToolkitTestApplication application;
3063 tet_infoline("UtcDaliLayouting_LayoutGroup02 - Test control is the size of it's largest child");
3065 Control rootControl;
3066 SetupRootLayoutControl( rootControl );
3068 // Create a parent layout
3069 auto hbox = Control::New();
3070 auto hboxLayout = LinearLayout::New();
3071 DevelControl::SetLayout( hbox, hboxLayout );
3072 hbox.SetName( "HBox");
3073 rootControl.Add( hbox );
3074 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3075 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3076 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
3078 tet_infoline("Add a control without SetLayout being called but with layout required set true");
3080 auto control = Control::New();
3081 control.SetName("Control1");
3082 DevelControl::SetLayoutingRequired( control, true );
3083 hbox.Add( control );
3084 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3085 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3087 tet_infoline("Add a Textlabel to the control");
3088 auto textLabel = TextLabel::New("Test text");
3089 textLabel.SetName("TextLabel");
3090 control.Add( textLabel );
3092 tet_infoline("Add another Textlabel to the control");
3093 auto largeTextLabel = TextLabel::New("Test large text");
3094 largeTextLabel.SetName("TextLabel-Large");
3095 control.Add( largeTextLabel );
3097 // Ensure layouting happens
3098 application.SendNotification();
3099 application.Render();
3101 tet_infoline("Test text is it's natural size");
3102 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3103 tet_infoline("Test text is centered in the control, the control is the size of the largest child");
3104 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3106 tet_infoline("Test large text is it's natural size");
3107 DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3108 tet_infoline("Test text is aligned to start as is the size of the control");
3109 DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3111 tet_infoline("Test control is width of it's parent and height of it's largest child");
3112 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3117 int UtcDaliLayouting_LayoutGroup03(void)
3119 ToolkitTestApplication application;
3120 tet_infoline("UtcDaliLayouting_LayoutGroup03 - Test control with a LayoutGroup as a leaf");
3122 Control rootControl;
3123 SetupRootLayoutControl( rootControl );
3125 // Create a parent layout
3126 auto hbox = Control::New();
3127 auto hboxLayout = LinearLayout::New();
3128 DevelControl::SetLayout( hbox, hboxLayout );
3129 hbox.SetName( "HBox");
3130 rootControl.Add( hbox );
3131 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3132 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3133 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
3135 tet_infoline("Add a control without SetLayout being called");
3137 auto control = Control::New();
3138 control.SetName("Control1");
3139 hbox.Add( control );
3140 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3141 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
3143 // Ensure layouting happens
3144 application.SendNotification();
3145 application.Render();
3147 tet_infoline("Test control is width of it's parent and exact given height");
3148 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3149 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3155 int UtcDaliLayouting_LayoutGroup04(void)
3157 ToolkitTestApplication application;
3158 tet_infoline("UtcDaliLayouting_LayoutGroup04 - Test control with a LayoutGroup as a leaf and with SetLayotRequired = true");
3160 Control rootControl;
3161 SetupRootLayoutControl( rootControl );
3163 // Create a parent layout
3164 auto hbox = Control::New();
3165 auto hboxLayout = LinearLayout::New();
3166 DevelControl::SetLayout( hbox, hboxLayout );
3167 hbox.SetName( "HBox");
3168 rootControl.Add( hbox );
3169 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3170 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3171 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
3173 tet_infoline("Add a control without SetLayout being called");
3175 auto control = Control::New();
3176 control.SetName("Control1");
3177 DevelControl::SetLayoutingRequired( control, true );
3178 hbox.Add( control );
3179 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3180 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
3182 // Ensure layouting happens
3183 application.SendNotification();
3184 application.Render();
3186 tet_infoline("Test control is width of it's parent and exact given height");
3187 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3188 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3193 int UtcDaliLayouting_IsLayoutingRequired(void)
3195 ToolkitTestApplication application;
3196 tet_infoline("UtcDaliLayouting_IsLayoutingRequired - Test setting the SetLayoutRequired and then check if flag was set");
3198 Control rootControl;
3199 SetupRootLayoutControl( rootControl );
3201 // Create a parent layout
3202 auto hbox = Control::New();
3203 auto hboxLayout = LinearLayout::New();
3204 DevelControl::SetLayout( hbox, hboxLayout );
3205 hbox.SetName( "HBox");
3206 rootControl.Add( hbox );
3207 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3208 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3209 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
3211 tet_infoline("Add a control without SetLayout being called");
3213 auto control = Control::New();
3214 control.SetName("Control1");
3215 DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), false, TEST_LOCATION );
3216 DevelControl::SetLayoutingRequired( control, true );
3217 hbox.Add( control );
3218 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3219 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
3221 // Ensure layouting happens
3222 application.SendNotification();
3223 application.Render();
3225 tet_infoline("Test control is width of it's parent and exact given height");
3226 DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), true, TEST_LOCATION );
3231 int UtcDaliLayouting_LayoutGroupWithPadding01(void)
3233 ToolkitTestApplication application;
3234 tet_infoline("UtcDaliLayouting_LayoutGroupWithPadding01 - Test adding a control to a layout that has padding");
3236 Control rootControl;
3237 SetupRootLayoutControl( rootControl );
3239 // Create a parent layout
3240 auto hbox = Control::New();
3241 auto hboxLayout = LinearLayout::New();
3242 hbox.SetName( "HBox");
3243 rootControl.Add( hbox );
3244 DevelControl::SetLayout( hbox, hboxLayout );
3245 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3246 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3247 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
3249 tet_infoline("Add a control without SetLayout being called");
3251 auto control = Control::New();
3252 control.SetName("Control1");
3253 DevelControl::SetLayoutingRequired( control, true );
3254 hbox.Add( control );
3255 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3256 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3258 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
3259 tet_printf( "Adding Padding to control");
3260 control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
3262 tet_infoline("Add a Textlabel to the control");
3263 auto textLabel = TextLabel::New("Test text");
3264 textLabel.SetName("TextLabel");
3265 control.Add( textLabel );
3267 // Ensure layouting happens
3268 application.SendNotification();
3269 application.Render();
3271 tet_infoline("Test text is it's natural size");
3272 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3273 tet_infoline("Test control is size of it's child and control it's own padding");
3274 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 245.0f, 86.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3279 int UtcDaliLayouting_LayoutGroupWithChildMargin01(void)
3281 ToolkitTestApplication application;
3282 tet_infoline("UtcDaliLayouting_LayoutGroupWithChildMargin01 - Test adding a control with padding to a layout that has padding");
3284 Control rootControl;
3285 SetupRootLayoutControl( rootControl );
3287 // Create a parent layout
3288 auto hbox = Control::New();
3289 auto hboxLayout = LinearLayout::New();
3290 hbox.SetName( "HBox");
3291 rootControl.Add( hbox );
3292 DevelControl::SetLayout( hbox, hboxLayout );
3293 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3294 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3295 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
3297 tet_infoline("Add a control without SetLayout being called");
3299 auto control = Control::New();
3300 control.SetName("Control1");
3301 DevelControl::SetLayoutingRequired( control, true );
3302 hbox.Add( control );
3303 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3304 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3306 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
3307 tet_printf( "Adding Padding to control");
3308 control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
3310 tet_infoline("Add a Textlabel to the control");
3311 auto textLabel = TextLabel::New("Test text");
3312 const Extents CHILD_MARGIN = Extents( 10, 0, 5, 0 );
3313 textLabel.SetProperty( Toolkit::Control::Property::MARGIN, CHILD_MARGIN );
3314 textLabel.SetName("TextLabel");
3315 control.Add( textLabel );
3317 // Ensure layouting happens
3318 application.SendNotification();
3319 application.Render();
3321 tet_infoline("Test text is it's natural size");
3322 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3323 tet_infoline("Test control is width of it's parent and height of it's child");
3324 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 255.0f, 91.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3329 int UtcDaliLayouting_SetLayout(void)
3331 ToolkitTestApplication application;
3332 tet_infoline(" UtcDaliLayouting_SetLayout - Test reusing layouts");
3334 Control rootControl;
3335 SetupRootLayoutControl( rootControl );
3337 auto container = Control::New();
3338 auto horizontalLayout = LinearLayout::New();
3339 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
3340 DevelControl::SetLayout( container, horizontalLayout );
3341 container.SetName( "Container" );
3342 rootControl.Add( container );
3344 std::vector< Control > controls;
3345 controls.push_back( CreateLeafControl( 40, 40 ) );
3346 controls.push_back( CreateLeafControl( 60, 60 ) );
3348 for( auto&& iter : controls )
3350 container.Add( iter );
3353 container.SetParentOrigin( ParentOrigin::CENTER );
3354 container.SetAnchorPoint( AnchorPoint::CENTER );
3356 // Ensure layouting happens
3357 application.SendNotification();
3358 application.Render();
3360 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3361 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3362 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3364 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3365 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3366 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3369 auto verticalLayout = LinearLayout::New();
3370 verticalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
3371 DevelControl::SetLayout( container, verticalLayout );
3373 application.SendNotification();
3374 application.Render();
3376 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3377 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3378 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3380 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3381 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3382 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3385 DevelControl::SetLayout( container, horizontalLayout );
3387 application.SendNotification();
3388 application.Render();
3390 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3391 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3392 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3394 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3395 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3396 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3399 DevelControl::SetLayout( container, verticalLayout );
3401 application.SendNotification();
3402 application.Render();
3404 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3405 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3406 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3408 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3409 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3410 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );