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_HboxLayout01(void)
75 ToolkitTestApplication application;
76 tet_infoline(" UtcDaliLayouting_HboxLayout01");
78 Stage stage = Stage::GetCurrent();
79 auto hbox = Control::New();
80 auto hboxLayout = LinearLayout::New();
81 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
82 DevelControl::SetLayout( hbox, hboxLayout );
83 hbox.SetName( "HBox");
85 std::vector< Control > controls;
86 controls.push_back( CreateLeafControl( 40, 40 ) );
87 controls.push_back( CreateLeafControl( 60, 40 ) );
88 controls.push_back( CreateLeafControl( 80, 40 ) );
89 controls.push_back( CreateLeafControl( 100, 40 ) );
91 for( auto&& iter : controls )
96 hbox.SetParentOrigin( ParentOrigin::CENTER );
97 hbox.SetAnchorPoint( AnchorPoint::CENTER );
100 // Ensure layouting happens
101 application.SendNotification();
102 application.Render();
104 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
105 // hbox left justifies elements
106 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
107 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
108 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
109 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
111 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
112 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
113 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
114 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
117 auto newHBoxLayout = LinearLayout::New();
118 newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
119 DevelControl::SetLayout( hbox, newHBoxLayout );
121 application.SendNotification();
122 application.Render();
124 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
125 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
126 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
127 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
132 int UtcDaliLayouting_HboxLayout02(void)
134 ToolkitTestApplication application;
135 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
137 Stage stage = Stage::GetCurrent();
139 auto hbox1 = Control::New();
140 auto hboxLayout1 = LinearLayout::New();
141 DevelControl::SetLayout( hbox1, hboxLayout1 );
143 auto hbox2 = Control::New();
144 auto hboxLayout2 = LinearLayout::New();
145 DevelControl::SetLayout( hbox2, hboxLayout2 );
147 hbox1.SetName( "HBox1");
148 hbox2.SetName( "HBox2");
150 std::vector< Control > controls;
151 controls.push_back( CreateLeafControl( 20, 40 ) );
152 controls.push_back( CreateLeafControl( 30, 50 ) );
153 controls.push_back( CreateLeafControl( 40, 60 ) );
154 controls.push_back( CreateLeafControl( 50, 70 ) );
156 controls.push_back( CreateLeafControl( 25, 40 ) );
157 controls.push_back( CreateLeafControl( 35, 50 ) );
158 controls.push_back( CreateLeafControl( 45, 60 ) );
159 controls.push_back( CreateLeafControl( 55, 70 ) );
162 for( auto&& iter : controls )
174 hbox1.SetParentOrigin( ParentOrigin::CENTER );
175 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
176 hbox2.SetParentOrigin( ParentOrigin::CENTER );
177 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
179 auto hbox3 = Control::New();
180 auto hboxLayout3 = LinearLayout::New();
181 DevelControl::SetLayout( hbox3, hboxLayout3 );
183 hbox3.SetParentOrigin( ParentOrigin::CENTER );
184 hbox3.SetName( "HBox3");
190 // Ensure layouting happens
191 application.SendNotification();
192 application.Render();
195 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
196 // hbox left justifies elements
197 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
198 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
199 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
200 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
202 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
203 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
204 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
205 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
208 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
209 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
210 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
211 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
213 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
214 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
215 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
216 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
218 // Test hbox1 and 2 are sized to wrap their content
219 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
220 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
221 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
222 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
224 // Test hbox3 matches parent (root layer)
225 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
226 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
232 int UtcDaliLayouting_HboxLayout03(void)
234 ToolkitTestApplication application;
235 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
237 Stage stage = Stage::GetCurrent();
239 auto hbox1 = Control::New();
240 auto hboxLayout1 = LinearLayout::New();
241 DevelControl::SetLayout( hbox1, hboxLayout1 );
243 auto hbox2 = Control::New();
244 auto hboxLayout2 = LinearLayout::New();
245 DevelControl::SetLayout( hbox2, hboxLayout2 );
247 hbox1.SetName( "HBox1");
248 hbox2.SetName( "HBox2");
249 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
250 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
251 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
252 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
254 std::vector< Control > controls;
255 controls.push_back( CreateLeafControl( 20, 40 ) );
256 controls.push_back( CreateLeafControl( 30, 50 ) );
257 controls.push_back( CreateLeafControl( 40, 60 ) );
258 controls.push_back( CreateLeafControl( 50, 70 ) );
260 controls.push_back( CreateLeafControl( 25, 40 ) );
261 controls.push_back( CreateLeafControl( 35, 50 ) );
262 controls.push_back( CreateLeafControl( 45, 60 ) );
263 controls.push_back( CreateLeafControl( 55, 70 ) );
266 for( auto&& iter : controls )
278 hbox1.SetParentOrigin( ParentOrigin::CENTER );
279 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
280 hbox2.SetParentOrigin( ParentOrigin::CENTER );
281 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
283 auto hbox3 = Control::New();
284 auto hboxLayout3 = LinearLayout::New();
285 DevelControl::SetLayout( hbox3, hboxLayout3);
287 hbox3.SetParentOrigin( ParentOrigin::CENTER );
288 hbox3.SetName( "HBox3");
294 //std::ostringstream oss;
295 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
296 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
298 // Ensure layouting happens
299 application.SendNotification();
300 application.Render();
303 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
304 // hbox left justifies elements
305 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
306 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
307 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
308 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
310 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
311 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
312 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
313 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
315 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
316 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
317 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
318 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
320 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
321 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
322 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
323 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
325 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
326 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
327 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
328 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
330 // Test hbox3 matches parent (root layer)
331 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
332 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
337 int UtcDaliLayouting_HboxLayout04(void)
339 ToolkitTestApplication application;
340 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
342 Stage stage = Stage::GetCurrent();
344 auto hbox1 = Control::New();
345 auto hboxLayout1 = LinearLayout::New();
346 DevelControl::SetLayout( hbox1, hboxLayout1 );
348 auto hbox2 = Control::New();
349 auto hboxLayout2 = LinearLayout::New();
350 DevelControl::SetLayout( hbox2, hboxLayout2 );
352 hbox1.SetName( "HBox1"); // Default spec is to wrap content
353 hbox2.SetName( "HBox2");
354 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
355 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
356 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
357 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
359 std::vector< Control > controls;
360 controls.push_back( CreateLeafControl( 80, 40 ) );
361 controls.push_back( CreateLeafControl( 80, 50 ) );
362 controls.push_back( CreateLeafControl( 80, 60 ) );
363 controls.push_back( CreateLeafControl( 80, 70 ) );
365 controls.push_back( CreateLeafControl( 80, 40 ) );
366 controls.push_back( CreateLeafControl( 80, 50 ) );
367 controls.push_back( CreateLeafControl( 80, 60 ) );
368 controls.push_back( CreateLeafControl( 80, 70 ) );
371 for( auto&& iter : controls )
384 controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
385 auto hbox3 = Control::New();
386 auto hboxLayout3 = LinearLayout::New();
387 DevelControl::SetLayout( hbox3, hboxLayout3 );
389 hbox3.SetParentOrigin( ParentOrigin::CENTER );
390 hbox3.SetName( "HBox3");
395 //std::ostringstream oss;
396 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
397 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
399 // Ensure layouting happens
400 application.SendNotification();
401 application.Render();
404 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
405 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
406 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
407 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
409 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
410 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
411 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
412 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
414 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
415 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
416 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
417 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
419 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
420 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
421 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
422 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
424 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
425 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
426 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
427 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
430 // Test hbox3 matches parent (root layer)
431 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
432 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
437 int UtcDaliLayouting_HboxLayout05(void)
439 ToolkitTestApplication application;
440 tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
442 Stage stage = Stage::GetCurrent();
443 auto hbox = Control::New();
444 auto hboxLayout = LinearLayout::New();
445 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
446 DevelControl::SetLayout( hbox, hboxLayout );
447 hbox.SetName( "HBox");
449 std::vector< Control > controls;
450 controls.push_back( CreateLeafControl( 40, 40 ) );
451 controls.push_back( CreateLeafControl( 60, 40 ) );
452 controls.push_back( CreateLeafControl( 80, 40 ) );
453 controls.push_back( CreateLeafControl( 100, 40 ) );
455 for( auto&& iter : controls )
458 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
459 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
462 hbox.SetParentOrigin( ParentOrigin::CENTER );
463 hbox.SetAnchorPoint( AnchorPoint::CENTER );
466 // Ensure layouting happens
467 application.SendNotification();
468 application.Render();
470 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
471 // hbox left justifies elements
472 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
473 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
474 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
475 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
477 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
478 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
479 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
480 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
485 int UtcDaliLayouting_HboxLayout06(void)
487 ToolkitTestApplication application;
488 tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
490 Stage stage = Stage::GetCurrent();
492 auto rootControl = Control::New();
493 auto absoluteLayout = AbsoluteLayout::New();
494 DevelControl::SetLayout( rootControl, absoluteLayout );
495 rootControl.SetName( "AbsoluteLayout" );
496 stage.Add( rootControl );
498 auto hbox = Control::New();
499 auto hboxLayout = LinearLayout::New();
500 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
501 DevelControl::SetLayout( hbox, hboxLayout );
502 hbox.SetName( "HBox" );
504 std::vector< Control > controls;
505 controls.push_back( CreateLeafControl( 40, 40 ) );
506 controls.push_back( CreateLeafControl( 60, 40 ) );
508 for( auto&& iter : controls )
512 hbox.SetParentOrigin( ParentOrigin::CENTER );
513 hbox.SetAnchorPoint( AnchorPoint::CENTER );
514 rootControl.Add( hbox );
516 // Ensure layouting happens
517 application.SendNotification();
518 application.Render();
520 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
521 // hbox left justifies elements
522 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
523 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
525 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
526 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
528 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
531 auto newHBoxLayout = LinearLayout::New();
532 newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
533 DevelControl::SetLayout( hbox, newHBoxLayout );
535 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
536 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
538 application.SendNotification();
539 application.Render();
541 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
543 // Change size specification
544 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
545 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
547 application.SendNotification();
548 application.Render();
550 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
552 // Use WRAP_CONTENT again
553 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
554 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
556 application.SendNotification();
557 application.Render();
559 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
564 int UtcDaliLayouting_HboxLayout07(void)
566 ToolkitTestApplication application;
567 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
569 Stage stage = Stage::GetCurrent();
570 auto hbox = Control::New();
571 auto hboxLayout = LinearLayout::New();
572 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
573 DevelControl::SetLayout( hbox, hboxLayout );
574 hbox.SetName( "HBox");
576 std::vector< Control > controls;
577 controls.push_back( CreateLeafControl( 40, 40 ) );
578 controls.push_back( CreateLeafControl( 60, 40 ) );
579 controls.push_back( CreateLeafControl( 80, 40 ) );
580 controls.push_back( CreateLeafControl( 100, 40 ) );
582 for( auto&& iter : controls )
586 hbox.SetParentOrigin( ParentOrigin::CENTER );
587 hbox.SetAnchorPoint( AnchorPoint::CENTER );
590 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
592 // Ensure layouting happens
593 application.SendNotification();
594 application.Render();
596 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
597 // hbox left justifies elements
598 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
599 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
600 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
601 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
603 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
604 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
605 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
606 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
608 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
610 // Ensure layouting happens
611 application.SendNotification();
612 application.Render();
614 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
615 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
616 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
617 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
619 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
620 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
621 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
622 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
627 int UtcDaliLayouting_HboxLayout08(void)
629 ToolkitTestApplication application;
630 tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation");
632 Stage stage = Stage::GetCurrent();
634 auto rootControl = Control::New();
635 auto absoluteLayout = AbsoluteLayout::New();
636 absoluteLayout.SetAnimateLayout( true );
637 DevelControl::SetLayout( rootControl, absoluteLayout );
638 rootControl.SetName( "AbsoluteLayout" );
639 stage.Add( rootControl );
641 Control control1 = CreateLeafControl( 40, 40 );
642 rootControl.Add( control1 );
644 auto hbox = Control::New();
645 auto hboxLayout = LinearLayout::New();
646 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
647 DevelControl::SetLayout( hbox, hboxLayout );
648 hbox.SetName( "HBox" );
650 Control control2 = CreateLeafControl( 40, 40 );
651 hbox.Add( control2 );
653 hbox.SetParentOrigin( ParentOrigin::CENTER );
654 hbox.SetAnchorPoint( AnchorPoint::CENTER );
655 rootControl.Add( hbox );
657 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION );
658 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION );
659 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION );
660 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION );
662 tet_infoline(" Set hBoxLayout to animate");
663 hboxLayout.SetAnimateLayout( true );
664 tet_infoline(" Set absoluteLayout not to animate");
665 absoluteLayout.SetAnimateLayout( false );
667 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION );
668 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION );
669 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION );
670 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION );
675 int UtcDaliLayouting_HboxLayout09(void)
677 ToolkitTestApplication application;
678 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set alignment");
680 Stage stage = Stage::GetCurrent();
681 auto hbox = Control::New();
682 auto hboxLayout = LinearLayout::New();
683 DevelControl::SetLayout( hbox, hboxLayout );
684 hbox.SetName( "HBox");
686 std::vector< Control > controls;
687 controls.push_back( CreateLeafControl( 40, 40 ) );
688 controls.push_back( CreateLeafControl( 60, 60 ) );
690 for( auto&& iter : controls )
694 hbox.SetParentOrigin( ParentOrigin::CENTER );
695 hbox.SetAnchorPoint( AnchorPoint::CENTER );
698 // Check default orientation
699 DALI_TEST_EQUALS( static_cast<unsigned int>( hboxLayout.GetOrientation() ), static_cast<unsigned int>( LinearLayout::Orientation::HORIZONTAL ), TEST_LOCATION );
700 // Check default alignment
701 DALI_TEST_EQUALS( hboxLayout.GetAlignment(), ( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL ), TEST_LOCATION );
703 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN );
705 // Ensure layouting happens
706 application.SendNotification();
707 application.Render();
709 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
710 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
712 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
713 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
715 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END );
717 // Ensure layouting happens
718 application.SendNotification();
719 application.Render();
721 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
722 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
724 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
725 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
727 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
729 // Ensure layouting happens
730 application.SendNotification();
731 application.Render();
733 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
734 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
736 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
737 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
739 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP );
741 // Ensure layouting happens
742 application.SendNotification();
743 application.Render();
745 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
746 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
748 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
749 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
751 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP );
753 // Ensure layouting happens
754 application.SendNotification();
755 application.Render();
757 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
758 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
760 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
761 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
763 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP );
765 // Ensure layouting happens
766 application.SendNotification();
767 application.Render();
769 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
770 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
772 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
773 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
775 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
777 // Ensure layouting happens
778 application.SendNotification();
779 application.Render();
781 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
782 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
784 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
785 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
787 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
789 // Ensure layouting happens
790 application.SendNotification();
791 application.Render();
793 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
794 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
796 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
797 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
799 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
801 // Ensure layouting happens
802 application.SendNotification();
803 application.Render();
805 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
806 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
808 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
809 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
811 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL );
813 // Ensure layouting happens
814 application.SendNotification();
815 application.Render();
817 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
818 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
820 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
821 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
823 hboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
824 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN );
826 // Ensure layouting happens
827 application.SendNotification();
828 application.Render();
830 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
831 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
833 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
834 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
836 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END );
838 // Ensure layouting happens
839 application.SendNotification();
840 application.Render();
842 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
843 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
845 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
846 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
848 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
850 // Ensure layouting happens
851 application.SendNotification();
852 application.Render();
854 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
855 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
857 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
858 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
860 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP );
862 // Ensure layouting happens
863 application.SendNotification();
864 application.Render();
866 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
867 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
869 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
870 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
872 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP );
874 // Ensure layouting happens
875 application.SendNotification();
876 application.Render();
878 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
879 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
881 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
882 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
884 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP );
886 // Ensure layouting happens
887 application.SendNotification();
888 application.Render();
890 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
891 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
893 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
894 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
896 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
898 // Ensure layouting happens
899 application.SendNotification();
900 application.Render();
902 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
903 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
905 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
906 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
908 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
910 // Ensure layouting happens
911 application.SendNotification();
912 application.Render();
914 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
915 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
917 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
918 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
920 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
922 // Ensure layouting happens
923 application.SendNotification();
924 application.Render();
926 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
927 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
929 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
930 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
932 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL );
934 // Ensure layouting happens
935 application.SendNotification();
936 application.Render();
938 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
939 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
941 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
942 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
947 int UtcDaliLayouting_HboxLayout_Weight(void)
949 ToolkitTestApplication application;
950 tet_infoline( " UtcDaliLayouting_HboxLayout_Weight - Test LinearLayout weight horizontally" );
952 Stage stage = Stage::GetCurrent();
953 auto hbox = Control::New();
954 auto hboxLayout = LinearLayout::New();
955 DevelControl::SetLayout( hbox, hboxLayout );
956 hbox.SetName( "HBox" );
958 std::vector<Control> controls;
959 controls.push_back( CreateLeafControl( 40, 40 ) );
960 controls.push_back( CreateLeafControl( 60, 40 ) );
961 controls.push_back( CreateLeafControl( 80, 40 ) );
962 controls.push_back( CreateLeafControl( 100, 40 ) );
964 // Set weight for each leaf to use quarter of available space
965 // 480 * 0.25, 480 * 0.25, 480 * 0.25, 480 * 0.25,
966 // width spec has to be set to 0 so not to consume any extra space.
967 for( auto&& iter : controls )
969 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
970 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
971 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
975 hbox.SetParentOrigin( ParentOrigin::CENTER );
976 hbox.SetAnchorPoint( AnchorPoint::CENTER );
979 // Ensure layouting happens
980 application.SendNotification();
981 application.Render();
983 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
984 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
985 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
986 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 360.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
988 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
989 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
990 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
991 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
993 // Set weight for 3, 4 leafs to use all remaining available space after 1, 2 content sized leafs.
994 // 40, 60, (480 - 40 - 60) * 0.5, (480 - 40 - 60) * 0.5
995 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
996 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
997 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
998 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
999 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1000 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1002 // Ensure layouting happens
1003 application.SendNotification();
1004 application.Render();
1006 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1007 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1008 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1009 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 290.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1011 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1012 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1013 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 190.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1014 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 190.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1016 // Add intrinsic width for 3rd leaf so now we should get
1017 // 40, 60, (480 - 40 - 60 - 80) * 0.5 + 80, (480 - 40 - 60 - 80) * 0.5
1018 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 80 );
1020 // Ensure layouting happens
1021 application.SendNotification();
1022 application.Render();
1024 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1025 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1026 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1027 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1029 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1030 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1031 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1032 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1034 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1035 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1036 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1037 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1038 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1039 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1040 controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 40 );
1041 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1043 // Ensure layouting happens
1044 application.SendNotification();
1045 application.Render();
1047 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1048 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1049 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1050 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1052 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 110.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1053 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 220.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1054 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 110.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1055 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1057 // WRAP_CONTENT doesn't affect weight
1058 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1059 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1060 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1061 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1062 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1063 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1064 controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1065 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1067 // Ensure layouting happens
1068 application.SendNotification();
1069 application.Render();
1071 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1072 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1073 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1074 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1076 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1077 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1078 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1079 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 300.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1081 // MATCH_PARENT doesn't affect weight
1082 for( auto&& iter : controls )
1084 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1085 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1086 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1089 // Ensure layouting happens
1090 application.SendNotification();
1091 application.Render();
1093 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1094 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1095 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1096 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 360.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1098 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1099 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1100 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1101 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1103 const Extents CONTROL_MARGIN = Extents( 10, 10, 0, 0 );
1104 for( auto&& iter : controls )
1106 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1107 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1108 iter.SetProperty( Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1111 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1112 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1113 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1114 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1116 application.SendNotification();
1117 application.Render();
1119 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 10.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1120 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 70.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1121 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 150.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1122 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 250.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1124 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1125 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1126 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1127 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 220.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1132 int UtcDaliLayouting_VboxLayout_Weight(void)
1134 ToolkitTestApplication application;
1135 tet_infoline( " UtcDaliLayouting_VboxLayout_Weight - Test LinearLayout weight vertically" );
1137 Stage stage = Stage::GetCurrent();
1138 auto vbox = Control::New();
1139 auto vboxLayout = LinearLayout::New();
1140 vboxLayout.SetOrientation( Dali::Toolkit::LinearLayout::Orientation::VERTICAL );
1141 DevelControl::SetLayout( vbox, vboxLayout );
1142 vbox.SetName( "VBox" );
1144 std::vector<Control> controls;
1145 controls.push_back( CreateLeafControl( 40, 40 ) );
1146 controls.push_back( CreateLeafControl( 60, 60 ) );
1147 controls.push_back( CreateLeafControl( 80, 80 ) );
1148 controls.push_back( CreateLeafControl( 100, 100 ) );
1150 // Set weight for each leaf to use quarter of available space
1151 // 800 * 0.25, 800 * 0.25, 800 * 0.25, 800 * 0.25,
1152 // width spec has to be set to 0 so not to consume any extra space.
1153 for( auto&& iter : controls )
1155 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1156 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1157 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1161 vbox.SetParentOrigin( ParentOrigin::CENTER );
1162 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1165 // Ensure layouting happens
1166 application.SendNotification();
1167 application.Render();
1169 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1170 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1171 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1172 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 600.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1174 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1175 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1176 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1177 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1179 // Set weight for 3, 4 leafs to use all remaining available space after 1, 2 content sized leafs.
1180 // 40, 60, (800 - 40 - 60) * 0.5, (800 - 40 - 60) * 0.5
1181 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1182 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1183 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1184 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1185 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1186 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1188 // Ensure layouting happens
1189 application.SendNotification();
1190 application.Render();
1192 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1193 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1194 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1195 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 450.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1197 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1198 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1199 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1200 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1202 // Add intrinsic width for 3rd leaf so now we should get
1203 // 40, 60, (800 - 40 - 60 - 100) * 0.5 + 100, (800 - 40 - 60 - 100) * 0.5
1204 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
1206 // Ensure layouting happens
1207 application.SendNotification();
1208 application.Render();
1210 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1211 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1212 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1213 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 500.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1215 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1216 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1217 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1218 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1220 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1221 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1222 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1223 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1224 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1225 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1226 controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
1227 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1229 // Ensure layouting happens
1230 application.SendNotification();
1231 application.Render();
1233 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1234 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1235 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 525.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1236 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1238 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1239 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1240 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1241 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1243 // WRAP_CONTENT doesn't affect weight
1244 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1245 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1246 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1247 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1248 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1249 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1250 controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1251 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1253 // Ensure layouting happens
1254 application.SendNotification();
1255 application.Render();
1257 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1258 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1259 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1260 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1262 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1263 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1264 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1265 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 620.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1267 // MATCH_PARENT doesn't affect weight
1268 for( auto&& iter : controls )
1270 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1271 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1272 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1275 // Ensure layouting happens
1276 application.SendNotification();
1277 application.Render();
1279 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1280 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1281 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1282 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 600.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1284 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1285 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1286 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1287 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1289 const Extents CONTROL_MARGIN = Extents( 0, 0, 10, 10 );
1290 for( auto&& iter : controls )
1292 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1293 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1294 iter.SetProperty( Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1297 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1298 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1299 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1300 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1302 application.SendNotification();
1303 application.Render();
1305 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1306 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1307 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1308 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 250.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1310 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1311 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1312 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1313 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 540.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1318 int UtcDaliLayouting_NestedLinearLayout_Weight(void)
1320 ToolkitTestApplication application;
1321 tet_infoline("UtcDaliLayouting_NestedLinearLayout_Weight - test weighted children with wrapped parent");
1323 Stage stage = Stage::GetCurrent();
1324 auto rootControl = Control::New();
1325 rootControl.SetName( "AbsoluteLayout");
1326 auto rootLayout = AbsoluteLayout::New();
1327 DevelControl::SetLayout( rootControl, rootLayout );
1328 rootControl.SetAnchorPoint( AnchorPoint::CENTER );
1329 rootControl.SetParentOrigin( ParentOrigin::CENTER );
1330 stage.Add( rootControl );
1332 auto hbox = Control::New();
1333 auto hboxLayout = LinearLayout::New();
1334 DevelControl::SetLayout( hbox, hboxLayout );
1335 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1336 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1338 std::vector< Control > controls;
1339 controls.push_back( CreateLeafControl( 40, 40 ) );
1340 controls.push_back( CreateLeafControl( 60, 60 ) );
1342 // set equal share of wrapped content width (40 + 60 = 100) for both children 100 * 0.5, 100 * 0.5
1343 for( auto&& iter : controls )
1345 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1346 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1347 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1351 hbox.SetParentOrigin( ParentOrigin::CENTER );
1352 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1353 rootControl.Add( hbox );
1355 // Ensure layouting happens
1356 application.SendNotification();
1357 application.Render();
1359 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1360 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1362 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1363 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1365 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1366 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1368 hboxLayout.SetOrientation(Dali::Toolkit::LinearLayout::Orientation::VERTICAL);
1370 // set equal share of wrapped content height (40 + 60 = 100) for both children 100 * 0.5, 100 * 0.5
1371 for( auto&& iter : controls )
1373 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1374 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1375 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1378 // Ensure layouting happens
1379 application.SendNotification();
1380 application.Render();
1382 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1383 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1385 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1386 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1388 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1389 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1397 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/broken.png";
1400 int UtcDaliLayouting_HboxLayout_ImageView(void)
1402 ToolkitTestApplication application;
1403 tet_infoline(" UtcDaliLayouting_HboxLayout - Use image view for leaf");
1405 Stage stage = Stage::GetCurrent();
1406 auto hbox = Control::New();
1407 auto hboxLayout = LinearLayout::New();
1408 DevelControl::SetLayout( hbox, hboxLayout );
1409 hbox.SetName( "HBox" );
1411 std::string url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 100, 100 ) );
1412 ImageView imageView = CreateImageView( url, ImageDimensions() );
1414 hbox.SetParentOrigin( ParentOrigin::CENTER );
1415 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1416 hbox.Add( imageView );
1419 // Ensure layouting happens
1420 application.SendNotification();
1421 application.Render();
1423 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1424 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1426 url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 200, 200 ) );
1427 imageView.SetImage( url );
1429 // Ensure layouting happenss
1430 application.SendNotification();
1431 application.Render();
1433 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1434 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1436 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1437 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1439 // Ensure layouting happenss
1440 application.SendNotification();
1441 application.Render();
1443 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1444 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1446 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1447 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1449 // Ensure layouting happenss
1450 application.SendNotification();
1451 application.Render();
1453 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1454 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1456 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1457 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1459 Image image = FrameBufferImage::New( 50, 50, Pixel::RGBA8888 );
1460 imageView.SetImage( image );
1462 // Ensure layouting happenss
1463 application.SendNotification();
1464 application.Render();
1466 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1467 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1469 Property::Map imagePropertyMap;
1470 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1471 imagePropertyMap[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
1472 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 150;
1473 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 150;
1474 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap );
1476 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1477 // Ensure layouting happenss
1478 application.SendNotification();
1479 application.Render();
1481 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 325.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1482 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1487 int UtcDaliLayouting_HboxLayout_TextLabel(void)
1489 ToolkitTestApplication application;
1490 tet_infoline(" UtcDaliLayouting_HboxLayout - Use text label for leaf");
1492 Stage stage = Stage::GetCurrent();
1494 auto hbox = Control::New();
1495 auto hboxLayout = LinearLayout::New();
1496 DevelControl::SetLayout( hbox, hboxLayout );
1497 hbox.SetName( "HBox" );
1498 hbox.SetParentOrigin( ParentOrigin::CENTER );
1499 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1501 std::vector< Control > controls;
1502 TextLabel textLabel = CreateTextLabel( "W" );
1503 controls.push_back( textLabel );
1504 hbox.Add( textLabel );
1507 // Ensure layouting happens
1508 application.SendNotification();
1509 application.Render();
1511 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1512 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 54.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1514 textLabel.SetProperty( TextLabel::Property::TEXT, "WWWW" );
1516 // Ensure layouting happens
1517 application.SendNotification();
1518 application.Render();
1520 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1521 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 216.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1523 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
1525 // Ensure layouting happens
1526 application.SendNotification();
1527 application.Render();
1529 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1530 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1532 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1533 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1535 // Ensure layouting happens
1536 application.SendNotification();
1537 application.Render();
1539 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1540 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1542 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1543 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1545 // Ensure layouting happens
1546 application.SendNotification();
1547 application.Render();
1549 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1550 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1557 int UtcDaliLayouting_HboxLayout_Padding01(void)
1559 ToolkitTestApplication application;
1560 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
1562 Stage stage = Stage::GetCurrent();
1563 auto hbox = Control::New();
1564 auto hboxLayout = LinearLayout::New();
1565 DevelControl::SetLayout( hbox, hboxLayout );
1566 hbox.SetName( "HBox");
1568 std::vector< Control > controls;
1569 controls.push_back( CreateLeafControl( 40, 40 ) );
1570 controls.push_back( CreateLeafControl( 60, 40 ) );
1571 controls.push_back( CreateLeafControl( 80, 40 ) );
1572 controls.push_back( CreateLeafControl( 100, 40 ) );
1574 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1575 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
1576 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1578 for( auto&& iter : controls )
1582 hbox.SetParentOrigin( ParentOrigin::CENTER );
1583 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1586 // Ensure layouting happens
1587 application.SendNotification();
1588 application.Render();
1590 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1591 // hbox left justifies elements
1592 tet_infoline("Test Child Actor Position");
1593 float xPositionOfControlBeingTested = 0.0f;
1594 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1596 0.0f ), 0.0001f, TEST_LOCATION );
1597 xPositionOfControlBeingTested += 40.0f;
1599 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1600 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1601 0.0001f, TEST_LOCATION );
1603 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1604 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1606 xPositionOfControlBeingTested += 80.0f;
1607 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1609 tet_infoline("Test Child Actor Size");
1610 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1612 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1613 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
1614 0.0001f, TEST_LOCATION );
1616 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1617 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1622 int UtcDaliLayouting_HboxLayout_Padding02(void)
1624 ToolkitTestApplication application;
1625 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
1627 Stage stage = Stage::GetCurrent();
1628 auto hbox = Control::New();
1629 auto hboxLayout = LinearLayout::New();
1630 DevelControl::SetLayout( hbox, hboxLayout );
1631 hbox.SetName( "HBox");
1633 std::vector< Control > controls;
1634 controls.push_back( CreateLeafControl( 40, 40 ) );
1635 controls.push_back( CreateLeafControl( 60, 40 ) );
1636 controls.push_back( CreateLeafControl( 80, 40 ) );
1637 controls.push_back( CreateLeafControl( 100, 40 ) );
1639 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1641 for( auto&& iter : controls )
1643 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1646 hbox.SetParentOrigin( ParentOrigin::CENTER );
1647 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1650 // Ensure layouting happens
1651 application.SendNotification();
1652 application.Render();
1654 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1655 // hbox left justifies elements
1656 tet_infoline("Test Child Actor Position");
1657 float xPositionOfControlBeingTested = 0.0f;
1658 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
1660 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1661 yPositionOfControlBeingTested,
1662 0.0f ), 0.0001f, TEST_LOCATION );
1663 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1665 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1666 yPositionOfControlBeingTested,
1668 0.0001f, TEST_LOCATION );
1670 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1671 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1672 yPositionOfControlBeingTested,
1673 0.0f ), 0.0001f, TEST_LOCATION );
1675 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1676 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1677 yPositionOfControlBeingTested,
1678 0.0f ), 0.0001f, TEST_LOCATION );
1680 tet_infoline("Test Child Actor Size");
1681 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1682 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1683 0.0f ), 0.0001f, TEST_LOCATION );
1685 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1686 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1687 0.0f ), 0.0001f, TEST_LOCATION );
1689 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
1690 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1691 0.0f ), 0.0001f, TEST_LOCATION );
1693 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1694 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1695 0.0f ), 0.0001f, TEST_LOCATION );
1701 int UtcDaliLayouting_HboxLayout_Padding03(void)
1703 ToolkitTestApplication application;
1704 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
1706 Stage stage = Stage::GetCurrent();
1707 auto hbox = Control::New();
1708 auto hboxLayout = LinearLayout::New();
1709 DevelControl::SetLayout( hbox, hboxLayout );
1710 hbox.SetName( "HBox");
1712 std::vector< Control > controls;
1713 controls.push_back( CreateLeafControl( 40, 40 ) );
1714 controls.push_back( CreateLeafControl( 40, 40 ) );
1715 controls.push_back( CreateLeafControl( 40, 40 ) );
1717 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1718 tet_printf( "\nAdding Padding to control at index 1 \n" );
1719 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1721 for( auto&& iter : controls )
1725 hbox.SetParentOrigin( ParentOrigin::CENTER );
1726 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1729 // Ensure layouting happens
1730 application.SendNotification();
1731 application.Render();
1733 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1734 // hbox left justifies elements
1735 tet_infoline("Test Child Actor Position");
1736 float xPositionOfControlBeingTested = 0.0f;
1737 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1739 0.0f ), 0.0001f, TEST_LOCATION );
1740 xPositionOfControlBeingTested += 40.0f;
1742 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1743 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1744 0.0001f, TEST_LOCATION );
1746 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1747 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1749 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
1750 tet_printf( "\nChanging Padding to control at index 1 \n" );
1751 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
1753 // Ensure layouting happens
1754 application.SendNotification();
1755 application.Render();
1757 xPositionOfControlBeingTested = 0.0f; // reset
1759 tet_infoline("Test Child Actor Position");
1760 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1762 0.0f ), 0.0001f, TEST_LOCATION );
1763 xPositionOfControlBeingTested += 40.0f;
1765 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1766 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1767 0.0001f, TEST_LOCATION );
1769 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
1770 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
1771 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1773 tet_infoline("Test Child Actor Size");
1774 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1776 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
1777 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
1778 0.0001f, TEST_LOCATION );
1780 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1785 int UtcDaliLayouting_HboxLayout_Padding04(void)
1787 ToolkitTestApplication application;
1788 tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
1790 // Adding padding to the layout should offset the positioning of the children.
1792 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1793 const Size CONTROL_SIZE = Size( 40, 40 );
1795 Stage stage = Stage::GetCurrent();
1796 // Create a root layout, ideally Dali would have a default layout in the root layer.
1797 // Without this root layer the LinearLayout (or any other layout) will not
1798 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1799 // It uses the default stage size and ideally should have a layout added to it.
1800 auto rootLayoutControl = Control::New();
1801 rootLayoutControl.SetName( "AbsoluteLayout");
1802 auto rootLayout = AbsoluteLayout::New();
1803 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1804 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1805 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1806 stage.Add( rootLayoutControl );
1808 auto hbox = Control::New();
1809 auto hboxLayout = LinearLayout::New();
1810 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1811 DevelControl::SetLayout( hbox, hboxLayout );
1812 hbox.SetName( "HBox");
1813 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1814 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1815 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1817 std::vector< Control > controls;
1818 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1819 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1820 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1821 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1823 for( auto&& iter : controls )
1828 hbox.SetParentOrigin( ParentOrigin::CENTER );
1829 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1830 rootLayoutControl.Add( hbox );
1832 // Ensure layouting happens
1833 application.SendNotification();
1834 application.Render();
1836 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1837 application.SendNotification();
1839 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1840 // hbox left justifies elements
1841 tet_infoline("Test Child Actor Position");
1843 auto controlXPosition=0.0f;
1845 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1846 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1848 0.0f ), 0.0001f, TEST_LOCATION );
1850 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1851 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1854 0.0001f, TEST_LOCATION );
1856 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1857 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1859 0.0f ), 0.0001f, TEST_LOCATION );
1861 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1862 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1864 0.0f ), 0.0001f, TEST_LOCATION );
1866 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1867 auto totalControlsHeight = CONTROL_SIZE.height;
1869 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1870 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1871 0.0f ), 0.0001f, TEST_LOCATION );
1877 int UtcDaliLayouting_HboxLayout_Padding05(void)
1879 ToolkitTestApplication application;
1880 tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
1882 // Adding padding to the layout should offset the positioning of the children.
1884 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1885 const Size CONTROL_SIZE = Size( 40, 40 );
1887 Stage stage = Stage::GetCurrent();
1888 // Create a root layout, ideally Dali would have a default layout in the root layer.
1889 // Without this root layer the LinearLayout (or any other layout) will not
1890 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1891 // It uses the default stage size and ideally should have a layout added to it.
1892 auto rootLayoutControl = Control::New();
1893 rootLayoutControl.SetName( "AbsoluteLayout");
1894 auto rootLayout = AbsoluteLayout::New();
1895 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1896 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1897 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1898 stage.Add( rootLayoutControl );
1900 auto hbox = Control::New();
1901 auto hboxLayout = LinearLayout::New();
1902 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1903 DevelControl::SetLayout( hbox, hboxLayout );
1904 hbox.SetName( "HBox");
1905 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1906 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1907 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1909 std::vector< Control > controls;
1910 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1911 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1912 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1913 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1915 for( auto&& iter : controls )
1920 hbox.SetParentOrigin( ParentOrigin::CENTER );
1921 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1922 rootLayoutControl.Add( hbox );
1924 // Ensure layouting happens
1925 application.SendNotification();
1926 application.Render();
1928 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1929 application.SendNotification();
1931 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1932 // hbox left justifies elements
1933 tet_infoline("Test Child Actor Position");
1935 auto controlXPosition=0.0f;
1937 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1938 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1940 0.0f ), 0.0001f, TEST_LOCATION );
1942 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1943 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1946 0.0001f, TEST_LOCATION );
1948 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1949 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1951 0.0f ), 0.0001f, TEST_LOCATION );
1953 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1954 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1956 0.0f ), 0.0001f, TEST_LOCATION );
1958 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1959 auto totalControlsHeight = CONTROL_SIZE.height;
1961 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1962 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1963 0.0f ), 0.0001f, TEST_LOCATION );
1965 // Change layout padding
1966 const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
1967 tet_printf( "\nChanging Padding to control at index 1 \n" );
1968 hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
1970 // Ensure layouting happens
1971 application.SendNotification();
1972 application.Render();
1974 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1975 application.SendNotification();
1977 controlXPosition = NEW_LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1978 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
1979 NEW_LAYOUT_PADDING.top,
1980 0.0f ), 0.0001f, TEST_LOCATION );
1982 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1983 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1984 NEW_LAYOUT_PADDING.top,
1986 0.0001f, TEST_LOCATION );
1988 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1989 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1990 NEW_LAYOUT_PADDING.top,
1991 0.0f ), 0.0001f, TEST_LOCATION );
1993 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1994 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1995 NEW_LAYOUT_PADDING.top,
1996 0.0f ), 0.0001f, TEST_LOCATION );
1997 totalControlsWidth = CONTROL_SIZE.width * controls.size();
1998 totalControlsHeight = CONTROL_SIZE.height;
2000 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
2001 totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
2002 0.0f ), 0.0001f, TEST_LOCATION );
2008 int UtcDaliLayouting_HboxLayout_Margin01(void)
2010 ToolkitTestApplication application;
2011 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
2013 Stage stage = Stage::GetCurrent();
2014 auto hbox = Control::New();
2015 auto hboxLayout = LinearLayout::New();
2016 DevelControl::SetLayout( hbox, hboxLayout );
2017 hbox.SetName( "HBox");
2019 std::vector< Control > controls;
2020 controls.push_back( CreateLeafControl( 40, 40 ) );
2021 controls.push_back( CreateLeafControl( 60, 40 ) );
2022 controls.push_back( CreateLeafControl( 80, 40 ) );
2023 controls.push_back( CreateLeafControl( 100, 40 ) );
2025 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
2026 tet_printf( "\nAdding Margin to control at index 1 \n" );
2027 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
2029 for( auto&& iter : controls )
2033 hbox.SetParentOrigin( ParentOrigin::CENTER );
2034 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2037 // Ensure layouting happens
2038 application.SendNotification();
2039 application.Render();
2041 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2042 // hbox left justifies elements
2043 tet_infoline("Test Child Actor Position");
2044 auto xPositionOfControlBeingTested = 0.0f;
2045 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2047 0.0f ), 0.0001f, TEST_LOCATION );
2048 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
2050 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2051 380.0f + CONTROL_MARGIN.top, 0.0f ),
2052 0.0001f, TEST_LOCATION );
2054 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
2055 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2057 xPositionOfControlBeingTested += 80.0f;
2058 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2060 tet_infoline("Test Child Actor Size is the same after Margin added");
2061 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2062 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
2063 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2064 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2070 int UtcDaliLayouting_VboxLayout01(void)
2072 ToolkitTestApplication application;
2073 tet_infoline(" UtcDaliLayouting_VboxLayout01");
2075 Stage stage = Stage::GetCurrent();
2076 auto vbox = Control::New();
2077 auto vboxLayout = LinearLayout::New();
2078 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2079 vboxLayout.SetAlignment( LinearLayout::Alignment::TOP | LinearLayout::Alignment::CENTER_HORIZONTAL );
2080 DevelControl::SetLayout( vbox, vboxLayout );
2081 vbox.SetName( "Vbox");
2083 std::vector< Control > controls;
2084 controls.push_back( CreateLeafControl( 40, 40 ) );
2085 controls.push_back( CreateLeafControl( 60, 60 ) );
2086 controls.push_back( CreateLeafControl( 80, 80 ) );
2087 controls.push_back( CreateLeafControl( 100, 100 ) );
2089 for( auto&& iter : controls )
2093 vbox.SetParentOrigin( ParentOrigin::CENTER );
2094 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2097 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2100 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2102 // Ensure layouting happens
2103 application.SendNotification();
2104 application.Render();
2106 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
2107 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2108 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2109 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2110 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2112 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2113 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2114 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2115 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2120 int UtcDaliLayouting_VboxLayout02(void)
2122 ToolkitTestApplication application;
2123 tet_infoline(" UtcDaliLayouting_VboxLayout01");
2125 Stage stage = Stage::GetCurrent();
2127 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
2128 // LayoutGroup for this to happen automatically.
2130 // For this test, add an hbox instead
2131 auto rootControl = Control::New();
2132 auto absoluteLayout = AbsoluteLayout::New();
2133 DevelControl::SetLayout( rootControl, absoluteLayout );
2134 rootControl.SetName( "AbsoluteLayout");
2135 stage.Add( rootControl );
2137 auto vbox = Control::New();
2138 auto vboxLayout = LinearLayout::New();
2139 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2140 vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
2141 DevelControl::SetLayout( vbox, vboxLayout );
2142 vbox.SetName( "Vbox");
2143 rootControl.Add( vbox );
2145 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2146 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2148 std::vector< Control > controls;
2149 controls.push_back( CreateLeafControl( 40, 40 ) );
2150 controls.push_back( CreateLeafControl( 60, 60 ) );
2151 controls.push_back( CreateLeafControl( 80, 80 ) );
2152 controls.push_back( CreateLeafControl( 100, 100 ) );
2154 for( auto&& iter : controls )
2158 vbox.SetParentOrigin( ParentOrigin::CENTER );
2159 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2161 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2164 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2166 // Ensure layouting happens
2167 application.SendNotification();
2168 application.Render();
2170 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
2171 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
2173 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
2174 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2175 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2177 // 3rd control is set to match parent - this should also be 100 wide
2178 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2179 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2180 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2181 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2183 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2184 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2185 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2186 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2192 int UtcDaliLayouting_VboxLayout03(void)
2194 ToolkitTestApplication application;
2195 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
2197 Stage stage = Stage::GetCurrent();
2199 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
2200 // LayoutGroup for this to happen automatically.
2202 // For this test, add an hbox instead
2203 auto hbox = Control::New();
2204 auto hboxLayout = LinearLayout::New();
2205 DevelControl::SetLayout( hbox, hboxLayout );
2206 hbox.SetName( "Hbox");
2209 auto vbox = Control::New();
2210 auto vboxLayout = LinearLayout::New();
2211 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
2212 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2213 vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
2215 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
2217 DevelControl::SetLayout( vbox, vboxLayout );
2218 vbox.SetName( "Vbox");
2221 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2222 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2224 std::vector< Control > controls;
2225 controls.push_back( CreateLeafControl( 40, 40 ) );
2226 controls.push_back( CreateLeafControl( 60, 60 ) );
2227 controls.push_back( CreateLeafControl( 80, 80 ) );
2228 controls.push_back( CreateLeafControl( 100, 100 ) );
2230 for( auto&& iter : controls )
2234 vbox.SetParentOrigin( ParentOrigin::CENTER );
2235 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2237 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2240 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2242 // Ensure layouting happens
2243 application.SendNotification();
2244 application.Render();
2246 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
2247 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
2249 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
2250 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2251 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2253 // 3rd control is set to match parent - this should also be 100 wide
2254 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2255 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2256 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2257 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2259 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2260 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2261 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2262 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2267 int UtcDaliLayouting_VboxLayout_Padding(void)
2269 ToolkitTestApplication application;
2270 tet_infoline("UtcDaliLayouting_VboxLayout_Padding - Adding Padding to the vbox");
2272 // Adding padding to the layout should offset the positioning of the children.
2274 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2275 const Size CONTROL_SIZE = Size( 40, 40 );
2277 Stage stage = Stage::GetCurrent();
2278 // Create a root layout, ideally Dali would have a default layout in the root layer.
2279 // Without this root layer the LinearLayout (or any other layout) will not
2280 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2281 // It uses the default stage size and ideally should have a layout added to it.
2282 auto rootLayoutControl = Control::New();
2283 rootLayoutControl.SetName( "AbsoluteLayout");
2284 auto rootLayout = AbsoluteLayout::New();
2285 DevelControl::SetLayout( rootLayoutControl, rootLayout );
2286 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2287 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2288 stage.Add( rootLayoutControl );
2290 auto vbox = Control::New();
2291 auto vboxLayout = LinearLayout::New();
2292 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2293 DevelControl::SetLayout( vbox, vboxLayout );
2294 vbox.SetName( "VBox");
2295 vbox.SetProperty( Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2296 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2297 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2299 std::vector< Control > controls;
2300 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2301 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2302 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2303 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2305 for( auto&& iter : controls )
2310 vbox.SetParentOrigin( ParentOrigin::CENTER );
2311 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2312 rootLayoutControl.Add( vbox );
2314 // Ensure layouting happens
2315 application.SendNotification();
2316 application.Render();
2318 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2319 application.SendNotification();
2321 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
2322 tet_infoline("Test Child Actor Position");
2324 auto controlYPosition = 0.0f;
2326 controlYPosition = LAYOUT_PADDING.top; // First child positioned at offset defined by the padding
2327 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2329 0.0f ), 0.0001f, TEST_LOCATION );
2331 controlYPosition += CONTROL_SIZE.height; // Second child positioned is the position of the first child + the first child's height.
2332 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2335 0.0001f, TEST_LOCATION );
2337 controlYPosition += CONTROL_SIZE.height; // Third child positioned adjacent to second
2338 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2340 0.0f ), 0.0001f, TEST_LOCATION );
2342 controlYPosition += CONTROL_SIZE.height; // Forth passed adjacent to the third
2343 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2345 0.0f ), 0.0001f, TEST_LOCATION );
2347 auto totalControlsWidth = CONTROL_SIZE.width;
2348 auto totalControlsHeight = CONTROL_SIZE.height * controls.size();
2350 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2351 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2352 0.0f ), 0.0001f, TEST_LOCATION );
2358 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
2360 ToolkitTestApplication application;
2361 tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
2362 tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
2364 Stage stage = Stage::GetCurrent();
2366 auto hbox = Control::New();
2367 auto hboxLayout = Test::CustomLayout::New();
2368 DevelControl::SetLayout( hbox, hboxLayout );
2369 hbox.SetName( "HBox");
2371 std::vector< Control > controls;
2372 controls.push_back( CreateLeafControl( 40, 40 ) );
2373 controls.push_back( CreateLeafControl( 60, 40 ) );
2374 controls.push_back( CreateLeafControl( 80, 40 ) );
2375 controls.push_back( CreateLeafControl( 100, 40 ) );
2377 for( auto&& iter : controls )
2381 hbox.SetParentOrigin( ParentOrigin::CENTER );
2382 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2385 // Ensure layouting happens
2386 application.SendNotification();
2387 application.Render();
2389 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2390 // hbox left justifies elements
2391 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2392 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2393 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2394 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2396 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2397 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2398 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2399 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2401 controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
2402 controls[2].Lower(); // 2->1; 2, 1, 3, 0
2404 application.SendNotification();
2405 application.Render();
2407 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2408 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2409 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2410 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2412 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2413 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2414 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2415 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2420 int UtcDaliLayouting_HboxLayout_TargetSize(void)
2422 ToolkitTestApplication application;
2423 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
2425 Stage stage = Stage::GetCurrent();
2426 auto hbox = Control::New();
2427 auto hboxLayout = LinearLayout::New();
2428 DevelControl::SetLayout( hbox, hboxLayout );
2429 hbox.SetName( "HBox");
2431 std::vector< Control > controls;
2432 controls.push_back( CreateLeafControl( 40, 40 ) );
2433 for( auto&& iter : controls )
2435 iter.SetSize( 100, 100 );
2438 hbox.SetParentOrigin( ParentOrigin::CENTER );
2439 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2442 // Ensure layouting happens
2443 application.SendNotification();
2444 application.Render();
2446 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
2447 // hbox left justifies elements
2448 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2449 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2454 int UtcDaliLayouting_RemoveLayout01(void)
2456 ToolkitTestApplication application;
2457 tet_infoline(" UtcDaliLayouting_RemoveLayout");
2459 Stage stage = Stage::GetCurrent();
2461 auto rootControl = Control::New();
2462 auto absoluteLayout = AbsoluteLayout::New();
2463 DevelControl::SetLayout( rootControl, absoluteLayout );
2464 rootControl.SetName( "AbsoluteLayout" );
2465 stage.Add( rootControl );
2467 auto hbox = Control::New();
2468 auto hboxLayout = LinearLayout::New();
2469 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2470 DevelControl::SetLayout( hbox, hboxLayout );
2471 hbox.SetName( "HBox" );
2473 std::vector< Control > controls;
2474 controls.push_back( CreateLeafControl( 40, 40 ) );
2475 controls.push_back( CreateLeafControl( 60, 40 ) );
2477 for( auto&& iter : controls )
2481 hbox.SetParentOrigin( ParentOrigin::CENTER );
2482 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2483 rootControl.Add( hbox );
2485 tet_infoline("Layout as normal");
2486 application.SendNotification();
2487 application.Render();
2489 tet_infoline("Set an empty layout on hbox container");
2490 LinearLayout emptyLayout;
2491 DevelControl::SetLayout( hbox, emptyLayout );
2493 tet_infoline("Run another layout");
2494 application.SendNotification();
2495 application.Render();
2497 tet_infoline("Check leaf controls haven't moved");
2499 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2500 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2502 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2503 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2508 int UtcDaliLayouting_LayoutChildren01(void)
2510 ToolkitTestApplication application;
2511 tet_infoline(" UtcDaliLayouting_LayoutChildren01");
2513 Stage stage = Stage::GetCurrent();
2515 auto rootControl = Control::New();
2516 auto absoluteLayout = AbsoluteLayout::New();
2517 DevelControl::SetLayout( rootControl, absoluteLayout );
2518 stage.Add( rootControl );
2520 auto hbox = Control::New();
2521 auto hboxLayout = LinearLayout::New();
2522 DevelControl::SetLayout( hbox, hboxLayout );
2523 rootControl.Add( hbox );
2525 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2527 tet_infoline("Test removal by setting empty layout to child container" );
2528 DevelControl::SetLayout( hbox, LayoutItem{} );
2530 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2532 auto& hboxImpl = GetImplementation( hboxLayout );
2534 DALI_TEST_EQUALS( hboxLayout.GetOwner(), empty, TEST_LOCATION );
2535 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2538 hboxImpl.SetLayoutRequested();
2543 int UtcDaliLayouting_LayoutChildren02(void)
2545 ToolkitTestApplication application;
2546 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2548 Stage stage = Stage::GetCurrent();
2550 auto rootControl = Control::New();
2551 auto absoluteLayout = AbsoluteLayout::New();
2552 DevelControl::SetLayout( rootControl, absoluteLayout );
2553 stage.Add( rootControl );
2555 auto hbox = Control::New();
2556 auto hboxLayout = LinearLayout::New();
2557 DevelControl::SetLayout( hbox, hboxLayout );
2558 rootControl.Add( hbox );
2560 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2562 tet_infoline("Test removal by removing child actor from parent container" );
2565 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2567 auto& hboxImpl = GetImplementation( hboxLayout );
2568 tet_infoline("Test child actor still has hbox layout " );
2569 DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
2571 tet_infoline("Test hbox layout has no parent " );
2572 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2577 int UtcDaliLayouting_LayoutChildren03(void)
2579 ToolkitTestApplication application;
2580 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2582 Stage stage = Stage::GetCurrent();
2584 auto rootControl = Control::New();
2585 auto absoluteLayout = AbsoluteLayout::New();
2586 DevelControl::SetLayout( rootControl, absoluteLayout );
2587 stage.Add( rootControl );
2589 auto hbox = Control::New();
2590 auto hboxLayout = LinearLayout::New();
2591 DevelControl::SetLayout( hbox, hboxLayout );
2592 rootControl.Add( hbox );
2594 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2596 tet_infoline("Test removal by removing child layout from parent layout" );
2597 absoluteLayout.Remove( hboxLayout );
2599 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2601 auto& hboxImpl = GetImplementation( hboxLayout );
2603 tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
2604 DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
2605 DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
2607 tet_infoline("Check orphaned layout has no parent");
2608 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2614 int UtcDaliLayouting_LayoutChildren04(void)
2616 ToolkitTestApplication application;
2617 tet_infoline(" UtcDaliLayouting_LayoutChildren03");
2619 Stage stage = Stage::GetCurrent();
2621 auto rootControl = Control::New();
2622 auto absoluteLayout = AbsoluteLayout::New();
2623 DevelControl::SetLayout( rootControl, absoluteLayout );
2624 stage.Add( rootControl );
2626 auto hbox = Control::New();
2627 tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
2628 auto hboxLayout = LinearLayout::New();
2629 rootControl.Add( hbox );
2631 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2633 tet_infoline("Then setting a layout on the child container");
2634 DevelControl::SetLayout( hbox, hboxLayout );
2636 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2638 auto& hboxImpl = GetImplementation( hboxLayout );
2639 auto& absImpl = GetImplementation( absoluteLayout );
2640 DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
2641 DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
2646 int UtcDaliLayouting_SetLayoutOrder01(void)
2648 ToolkitTestApplication application;
2649 tet_infoline(" UtcDaliLayouting_SetLayoutOrder01 - Call SetLayout after adding the control to the root layout");
2651 Stage stage = Stage::GetCurrent();
2653 auto rootControl = Control::New();
2654 auto absoluteLayout = AbsoluteLayout::New();
2655 DevelControl::SetLayout( rootControl, absoluteLayout );
2656 rootControl.SetName( "AbsoluteLayout" );
2657 stage.Add( rootControl );
2659 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
2660 auto hbox = Control::New();
2661 auto hboxLayout = LinearLayout::New();
2662 hbox.SetName( "HBox");
2664 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
2665 rootControl.Add( hbox );
2667 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
2668 DevelControl::SetLayout( hbox, hboxLayout );
2670 // Add a Child control
2671 std::vector< Control > controls;
2672 controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
2673 for( auto&& iter : controls )
2678 // Ensure layouting happens
2679 application.SendNotification();
2680 application.Render();
2682 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2687 int UtcDaliLayouting_SetLayoutOrder02(void)
2689 ToolkitTestApplication application;
2690 tet_infoline(" UtcDaliLayouting_SetLayoutOrder02 - Test the layout item order and the control order");
2692 Stage stage = Stage::GetCurrent();
2694 auto rootControl = Control::New();
2695 auto absoluteLayout = AbsoluteLayout::New();
2696 DevelControl::SetLayout( rootControl, absoluteLayout );
2697 rootControl.SetName( "AbsoluteLayout" );
2698 stage.Add( rootControl );
2700 auto hbox = Control::New();
2701 auto hboxLayout = LinearLayout::New();
2702 hbox.SetName( "HBox");
2704 rootControl.Add( hbox );
2706 DevelControl::SetLayout( hbox, hboxLayout );
2708 // Add child controls
2709 std::vector< Control > controls;
2710 controls.push_back( CreateLeafControl( 100, 100 ) ); // 0
2711 controls.push_back( CreateLeafControl( 100, 100 ) ); // 1
2712 controls.push_back( CreateLeafControl( 100, 100 ) ); // 2
2714 for( auto&& iter : controls )
2719 // Ensure layouting happens
2720 application.SendNotification();
2721 application.Render();
2723 TestLayoutItemOrder( controls, hboxLayout );
2725 tet_infoline("RaiseToTop");
2727 controls[0].RaiseToTop(); // 1 2 0
2729 TestLayoutItemOrder( controls, hboxLayout );
2731 tet_infoline("LowerToBottom");
2733 controls[2].LowerToBottom(); // 2 1 0
2735 TestLayoutItemOrder( controls, hboxLayout );
2737 tet_infoline("Remove / Add");
2739 hbox.Remove( controls[2] ); // 1 0
2740 hbox.Add( controls[2] ); // 1 0 2
2742 TestLayoutItemOrder( controls, hboxLayout );
2744 tet_infoline("SetLayout");
2746 auto vboxLayout = LinearLayout::New();
2747 DevelControl::SetLayout( controls[0], vboxLayout );
2749 TestLayoutItemOrder( controls, hboxLayout );
2751 tet_infoline("Raise");
2753 controls[0].Raise(); // 1 2 0
2755 TestLayoutItemOrder( controls, hboxLayout );
2757 tet_infoline("Lower");
2759 controls[2].Lower(); // 2 1 0
2761 TestLayoutItemOrder( controls, hboxLayout );
2763 tet_infoline("SetLayout again");
2765 auto vboxLayout1 = LinearLayout::New();
2766 DevelControl::SetLayout( controls[2], vboxLayout1 );
2768 TestLayoutItemOrder( controls, hboxLayout );
2770 DevelControl::SetLayout( controls[2], vboxLayout );
2775 int UtcDaliLayouting_LayoutGroup01(void)
2777 ToolkitTestApplication application;
2778 tet_infoline("UtcDaliLayouting_LayoutGroup01 - Test adding a control to a layout then adding a TextLabel to that control");
2780 Control rootControl;
2781 SetupRootLayoutControl( rootControl );
2783 // Create a parent layout
2784 auto hbox = Control::New();
2785 auto hboxLayout = LinearLayout::New();
2786 hbox.SetName( "HBox");
2787 rootControl.Add( hbox );
2788 DevelControl::SetLayout( hbox, hboxLayout );
2789 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2790 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2791 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2793 tet_infoline("Add a control without SetLayout being called");
2795 auto control = Control::New();
2796 control.SetName("Control1");
2797 hbox.Add( control );
2798 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2799 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2801 tet_infoline("Add a Textlabel to the control");
2802 auto textLabel = TextLabel::New("Test text");
2803 textLabel.SetName("TextLabel");
2804 control.Add( textLabel );
2806 // Ensure layouting happens
2807 application.SendNotification();
2808 application.Render();
2810 tet_infoline("Test text is it's natural size");
2811 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2812 tet_infoline("Test control is width of it's parent and height of it's child");
2813 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2818 int UtcDaliLayouting_LayoutGroup02(void)
2820 ToolkitTestApplication application;
2821 tet_infoline("UtcDaliLayouting_LayoutGroup02 - Test control is the size of it's largest child");
2823 Control rootControl;
2824 SetupRootLayoutControl( rootControl );
2826 // Create a parent layout
2827 auto hbox = Control::New();
2828 auto hboxLayout = LinearLayout::New();
2829 hbox.SetName( "HBox");
2830 rootControl.Add( hbox );
2831 DevelControl::SetLayout( hbox, hboxLayout );
2832 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2833 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2834 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2836 tet_infoline("Add a control without SetLayout being called");
2838 auto control = Control::New();
2839 control.SetName("Control1");
2840 hbox.Add( control );
2841 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2842 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2844 tet_infoline("Add a Textlabel to the control");
2845 auto textLabel = TextLabel::New("Test text");
2846 textLabel.SetName("TextLabel");
2847 control.Add( textLabel );
2849 tet_infoline("Add another Textlabel to the control");
2850 auto largeTextLabel = TextLabel::New("Test large text");
2851 largeTextLabel.SetName("TextLabel-Large");
2852 control.Add( largeTextLabel );
2854 // Ensure layouting happens
2855 application.SendNotification();
2856 application.Render();
2858 tet_infoline("Test text is it's natural size");
2859 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2860 tet_infoline("Test text is centered in the control, the control is the size of the largest child");
2861 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2863 tet_infoline("Test large text is it's natural size");
2864 DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2865 tet_infoline("Test text is aligned to start as is the size of the control");
2866 DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2868 tet_infoline("Test control is width of it's parent and height of it's largest child");
2869 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2874 int UtcDaliLayouting_LayoutGroup03(void)
2876 ToolkitTestApplication application;
2877 tet_infoline("UtcDaliLayouting_LayoutGroup03 - Test control witha LayoutGroup as a leaf");
2879 Control rootControl;
2880 SetupRootLayoutControl( rootControl );
2882 // Create a parent layout
2883 auto hbox = Control::New();
2884 auto hboxLayout = LinearLayout::New();
2885 hbox.SetName( "HBox");
2886 rootControl.Add( hbox );
2887 DevelControl::SetLayout( hbox, hboxLayout );
2888 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2889 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2890 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2892 tet_infoline("Add a control without SetLayout being called");
2894 auto control = Control::New();
2895 control.SetName("Control1");
2896 hbox.Add( control );
2897 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2898 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
2900 // Ensure layouting happens
2901 application.SendNotification();
2902 application.Render();
2904 tet_infoline("Test control is width of it's parent and exact given height");
2905 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2906 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2911 int UtcDaliLayouting_LayoutGroupWithPadding01(void)
2913 ToolkitTestApplication application;
2914 tet_infoline("UtcDaliLayouting_LayoutGroupWithPadding01 - Test adding a control to a layout that has padding");
2916 Control rootControl;
2917 SetupRootLayoutControl( rootControl );
2919 // Create a parent layout
2920 auto hbox = Control::New();
2921 auto hboxLayout = LinearLayout::New();
2922 hbox.SetName( "HBox");
2923 rootControl.Add( hbox );
2924 DevelControl::SetLayout( hbox, hboxLayout );
2925 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2926 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2927 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2929 tet_infoline("Add a control without SetLayout being called");
2931 auto control = Control::New();
2932 control.SetName("Control1");
2933 hbox.Add( control );
2934 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2935 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2937 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
2938 tet_printf( "Adding Padding to control");
2939 control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
2941 tet_infoline("Add a Textlabel to the control");
2942 auto textLabel = TextLabel::New("Test text");
2943 textLabel.SetName("TextLabel");
2944 control.Add( textLabel );
2946 // Ensure layouting happens
2947 application.SendNotification();
2948 application.Render();
2950 tet_infoline("Test text is it's natural size");
2951 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2952 tet_infoline("Test control is size of it's child and control it's own padding");
2953 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 245.0f, 86.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2958 int UtcDaliLayouting_LayoutGroupWithChildMargin01(void)
2960 ToolkitTestApplication application;
2961 tet_infoline("UtcDaliLayouting_LayoutGroupWithChildMargin01 - Test adding a control with padding to a layout that has padding");
2963 Control rootControl;
2964 SetupRootLayoutControl( rootControl );
2966 // Create a parent layout
2967 auto hbox = Control::New();
2968 auto hboxLayout = LinearLayout::New();
2969 hbox.SetName( "HBox");
2970 rootControl.Add( hbox );
2971 DevelControl::SetLayout( hbox, hboxLayout );
2972 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2973 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2974 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2976 tet_infoline("Add a control without SetLayout being called");
2978 auto control = Control::New();
2979 control.SetName("Control1");
2980 hbox.Add( control );
2981 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2982 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2984 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
2985 tet_printf( "Adding Padding to control");
2986 control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
2988 tet_infoline("Add a Textlabel to the control");
2989 auto textLabel = TextLabel::New("Test text");
2990 const Extents CHILD_MARGIN = Extents( 10, 0, 5, 0 );
2991 textLabel.SetProperty( Toolkit::Control::Property::MARGIN, CHILD_MARGIN );
2992 textLabel.SetName("TextLabel");
2993 control.Add( textLabel );
2995 // Ensure layouting happens
2996 application.SendNotification();
2997 application.Render();
2999 tet_infoline("Test text is it's natural size");
3000 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3001 tet_infoline("Test control is width of it's parent and height of it's child");
3002 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 255.0f, 91.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3007 int UtcDaliLayouting_SetLayout(void)
3009 ToolkitTestApplication application;
3010 tet_infoline(" UtcDaliLayouting_SetLayout - Test reusing layouts");
3012 Control rootControl;
3013 SetupRootLayoutControl( rootControl );
3015 auto container = Control::New();
3016 auto horizontalLayout = LinearLayout::New();
3017 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
3018 DevelControl::SetLayout( container, horizontalLayout );
3019 container.SetName( "Container" );
3020 rootControl.Add( container );
3022 std::vector< Control > controls;
3023 controls.push_back( CreateLeafControl( 40, 40 ) );
3024 controls.push_back( CreateLeafControl( 60, 60 ) );
3026 for( auto&& iter : controls )
3028 container.Add( iter );
3031 container.SetParentOrigin( ParentOrigin::CENTER );
3032 container.SetAnchorPoint( AnchorPoint::CENTER );
3034 // Ensure layouting happens
3035 application.SendNotification();
3036 application.Render();
3038 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3039 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3040 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3042 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3043 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3044 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3047 auto verticalLayout = LinearLayout::New();
3048 verticalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
3049 DevelControl::SetLayout( container, verticalLayout );
3051 application.SendNotification();
3052 application.Render();
3054 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3055 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3056 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3058 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3059 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3060 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3063 DevelControl::SetLayout( container, horizontalLayout );
3065 application.SendNotification();
3066 application.Render();
3068 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3069 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3070 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3072 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3073 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3074 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3077 DevelControl::SetLayout( container, verticalLayout );
3079 application.SendNotification();
3080 application.Render();
3082 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3083 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3084 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3086 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3087 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3088 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );