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 );
949 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/broken.png";
952 int UtcDaliLayouting_HboxLayout_ImageView(void)
954 ToolkitTestApplication application;
955 tet_infoline(" UtcDaliLayouting_HboxLayout - Use image view for leaf");
957 Stage stage = Stage::GetCurrent();
958 auto hbox = Control::New();
959 auto hboxLayout = LinearLayout::New();
960 DevelControl::SetLayout( hbox, hboxLayout );
961 hbox.SetName( "HBox" );
963 std::string url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 100, 100 ) );
964 ImageView imageView = CreateImageView( url, ImageDimensions() );
966 hbox.SetParentOrigin( ParentOrigin::CENTER );
967 hbox.SetAnchorPoint( AnchorPoint::CENTER );
968 hbox.Add( imageView );
971 // Ensure layouting happens
972 application.SendNotification();
973 application.Render();
975 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
976 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
978 url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 200, 200 ) );
979 imageView.SetImage( url );
981 // Ensure layouting happenss
982 application.SendNotification();
983 application.Render();
985 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
986 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
988 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
989 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
991 // Ensure layouting happenss
992 application.SendNotification();
993 application.Render();
995 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
996 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
998 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
999 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1001 // Ensure layouting happenss
1002 application.SendNotification();
1003 application.Render();
1005 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1006 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1008 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1009 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1011 Image image = FrameBufferImage::New( 50, 50, Pixel::RGBA8888 );
1012 imageView.SetImage( image );
1014 // Ensure layouting happenss
1015 application.SendNotification();
1016 application.Render();
1018 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1019 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1021 Property::Map imagePropertyMap;
1022 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1023 imagePropertyMap[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
1024 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 150;
1025 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 150;
1026 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap );
1028 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1029 // Ensure layouting happenss
1030 application.SendNotification();
1031 application.Render();
1033 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 325.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1034 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1039 int UtcDaliLayouting_HboxLayout_TextLabel(void)
1041 ToolkitTestApplication application;
1042 tet_infoline(" UtcDaliLayouting_HboxLayout - Use text label for leaf");
1044 Stage stage = Stage::GetCurrent();
1046 auto hbox = Control::New();
1047 auto hboxLayout = LinearLayout::New();
1048 DevelControl::SetLayout( hbox, hboxLayout );
1049 hbox.SetName( "HBox" );
1050 hbox.SetParentOrigin( ParentOrigin::CENTER );
1051 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1053 std::vector< Control > controls;
1054 TextLabel textLabel = CreateTextLabel( "W" );
1055 controls.push_back( textLabel );
1056 hbox.Add( textLabel );
1059 // Ensure layouting happens
1060 application.SendNotification();
1061 application.Render();
1063 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1064 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 54.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1066 textLabel.SetProperty( TextLabel::Property::TEXT, "WWWW" );
1068 // Ensure layouting happens
1069 application.SendNotification();
1070 application.Render();
1072 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1073 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 216.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1075 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
1077 // Ensure layouting happens
1078 application.SendNotification();
1079 application.Render();
1081 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1082 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1084 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1085 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1087 // Ensure layouting happens
1088 application.SendNotification();
1089 application.Render();
1091 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1092 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1094 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1095 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1097 // Ensure layouting happens
1098 application.SendNotification();
1099 application.Render();
1101 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1102 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1109 int UtcDaliLayouting_HboxLayout_Padding01(void)
1111 ToolkitTestApplication application;
1112 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
1114 Stage stage = Stage::GetCurrent();
1115 auto hbox = Control::New();
1116 auto hboxLayout = LinearLayout::New();
1117 DevelControl::SetLayout( hbox, hboxLayout );
1118 hbox.SetName( "HBox");
1120 std::vector< Control > controls;
1121 controls.push_back( CreateLeafControl( 40, 40 ) );
1122 controls.push_back( CreateLeafControl( 60, 40 ) );
1123 controls.push_back( CreateLeafControl( 80, 40 ) );
1124 controls.push_back( CreateLeafControl( 100, 40 ) );
1126 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1127 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
1128 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1130 for( auto&& iter : controls )
1134 hbox.SetParentOrigin( ParentOrigin::CENTER );
1135 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1138 // Ensure layouting happens
1139 application.SendNotification();
1140 application.Render();
1142 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1143 // hbox left justifies elements
1144 tet_infoline("Test Child Actor Position");
1145 float xPositionOfControlBeingTested = 0.0f;
1146 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1148 0.0f ), 0.0001f, TEST_LOCATION );
1149 xPositionOfControlBeingTested += 40.0f;
1151 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1152 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1153 0.0001f, TEST_LOCATION );
1155 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1156 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1158 xPositionOfControlBeingTested += 80.0f;
1159 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1161 tet_infoline("Test Child Actor Size");
1162 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1164 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1165 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
1166 0.0001f, TEST_LOCATION );
1168 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1169 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1174 int UtcDaliLayouting_HboxLayout_Padding02(void)
1176 ToolkitTestApplication application;
1177 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
1179 Stage stage = Stage::GetCurrent();
1180 auto hbox = Control::New();
1181 auto hboxLayout = LinearLayout::New();
1182 DevelControl::SetLayout( hbox, hboxLayout );
1183 hbox.SetName( "HBox");
1185 std::vector< Control > controls;
1186 controls.push_back( CreateLeafControl( 40, 40 ) );
1187 controls.push_back( CreateLeafControl( 60, 40 ) );
1188 controls.push_back( CreateLeafControl( 80, 40 ) );
1189 controls.push_back( CreateLeafControl( 100, 40 ) );
1191 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1193 for( auto&& iter : controls )
1195 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1198 hbox.SetParentOrigin( ParentOrigin::CENTER );
1199 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1202 // Ensure layouting happens
1203 application.SendNotification();
1204 application.Render();
1206 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1207 // hbox left justifies elements
1208 tet_infoline("Test Child Actor Position");
1209 float xPositionOfControlBeingTested = 0.0f;
1210 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
1212 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1213 yPositionOfControlBeingTested,
1214 0.0f ), 0.0001f, TEST_LOCATION );
1215 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1217 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1218 yPositionOfControlBeingTested,
1220 0.0001f, TEST_LOCATION );
1222 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1223 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1224 yPositionOfControlBeingTested,
1225 0.0f ), 0.0001f, TEST_LOCATION );
1227 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1228 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1229 yPositionOfControlBeingTested,
1230 0.0f ), 0.0001f, TEST_LOCATION );
1232 tet_infoline("Test Child Actor Size");
1233 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1234 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1235 0.0f ), 0.0001f, TEST_LOCATION );
1237 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1238 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1239 0.0f ), 0.0001f, TEST_LOCATION );
1241 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
1242 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1243 0.0f ), 0.0001f, TEST_LOCATION );
1245 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1246 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1247 0.0f ), 0.0001f, TEST_LOCATION );
1253 int UtcDaliLayouting_HboxLayout_Padding03(void)
1255 ToolkitTestApplication application;
1256 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
1258 Stage stage = Stage::GetCurrent();
1259 auto hbox = Control::New();
1260 auto hboxLayout = LinearLayout::New();
1261 DevelControl::SetLayout( hbox, hboxLayout );
1262 hbox.SetName( "HBox");
1264 std::vector< Control > controls;
1265 controls.push_back( CreateLeafControl( 40, 40 ) );
1266 controls.push_back( CreateLeafControl( 40, 40 ) );
1267 controls.push_back( CreateLeafControl( 40, 40 ) );
1269 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1270 tet_printf( "\nAdding Padding to control at index 1 \n" );
1271 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1273 for( auto&& iter : controls )
1277 hbox.SetParentOrigin( ParentOrigin::CENTER );
1278 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1281 // Ensure layouting happens
1282 application.SendNotification();
1283 application.Render();
1285 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1286 // hbox left justifies elements
1287 tet_infoline("Test Child Actor Position");
1288 float xPositionOfControlBeingTested = 0.0f;
1289 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1291 0.0f ), 0.0001f, TEST_LOCATION );
1292 xPositionOfControlBeingTested += 40.0f;
1294 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1295 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1296 0.0001f, TEST_LOCATION );
1298 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1299 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1301 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
1302 tet_printf( "\nChanging Padding to control at index 1 \n" );
1303 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
1305 // Ensure layouting happens
1306 application.SendNotification();
1307 application.Render();
1309 xPositionOfControlBeingTested = 0.0f; // reset
1311 tet_infoline("Test Child Actor Position");
1312 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1314 0.0f ), 0.0001f, TEST_LOCATION );
1315 xPositionOfControlBeingTested += 40.0f;
1317 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1318 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1319 0.0001f, TEST_LOCATION );
1321 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
1322 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
1323 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1325 tet_infoline("Test Child Actor Size");
1326 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1328 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
1329 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
1330 0.0001f, TEST_LOCATION );
1332 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1337 int UtcDaliLayouting_HboxLayout_Padding04(void)
1339 ToolkitTestApplication application;
1340 tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
1342 // Adding padding to the layout should offset the positioning of the children.
1344 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1345 const Size CONTROL_SIZE = Size( 40, 40 );
1347 Stage stage = Stage::GetCurrent();
1348 // Create a root layout, ideally Dali would have a default layout in the root layer.
1349 // Without this root layer the LinearLayout (or any other layout) will not
1350 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1351 // It uses the default stage size and ideally should have a layout added to it.
1352 auto rootLayoutControl = Control::New();
1353 rootLayoutControl.SetName( "AbsoluteLayout");
1354 auto rootLayout = AbsoluteLayout::New();
1355 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1356 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1357 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1358 stage.Add( rootLayoutControl );
1360 auto hbox = Control::New();
1361 auto hboxLayout = LinearLayout::New();
1362 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1363 DevelControl::SetLayout( hbox, hboxLayout );
1364 hbox.SetName( "HBox");
1365 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1366 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1367 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1369 std::vector< Control > controls;
1370 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1371 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1372 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1373 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1375 for( auto&& iter : controls )
1380 hbox.SetParentOrigin( ParentOrigin::CENTER );
1381 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1382 rootLayoutControl.Add( hbox );
1384 // Ensure layouting happens
1385 application.SendNotification();
1386 application.Render();
1388 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1389 application.SendNotification();
1391 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1392 // hbox left justifies elements
1393 tet_infoline("Test Child Actor Position");
1395 auto controlXPosition=0.0f;
1397 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1398 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1400 0.0f ), 0.0001f, TEST_LOCATION );
1402 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1403 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1406 0.0001f, TEST_LOCATION );
1408 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1409 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1411 0.0f ), 0.0001f, TEST_LOCATION );
1413 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1414 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1416 0.0f ), 0.0001f, TEST_LOCATION );
1418 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1419 auto totalControlsHeight = CONTROL_SIZE.height;
1421 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1422 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1423 0.0f ), 0.0001f, TEST_LOCATION );
1429 int UtcDaliLayouting_HboxLayout_Padding05(void)
1431 ToolkitTestApplication application;
1432 tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
1434 // Adding padding to the layout should offset the positioning of the children.
1436 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1437 const Size CONTROL_SIZE = Size( 40, 40 );
1439 Stage stage = Stage::GetCurrent();
1440 // Create a root layout, ideally Dali would have a default layout in the root layer.
1441 // Without this root layer the LinearLayout (or any other layout) will not
1442 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1443 // It uses the default stage size and ideally should have a layout added to it.
1444 auto rootLayoutControl = Control::New();
1445 rootLayoutControl.SetName( "AbsoluteLayout");
1446 auto rootLayout = AbsoluteLayout::New();
1447 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1448 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1449 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1450 stage.Add( rootLayoutControl );
1452 auto hbox = Control::New();
1453 auto hboxLayout = LinearLayout::New();
1454 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1455 DevelControl::SetLayout( hbox, hboxLayout );
1456 hbox.SetName( "HBox");
1457 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1458 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1459 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1461 std::vector< Control > controls;
1462 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1463 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1464 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1465 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1467 for( auto&& iter : controls )
1472 hbox.SetParentOrigin( ParentOrigin::CENTER );
1473 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1474 rootLayoutControl.Add( hbox );
1476 // Ensure layouting happens
1477 application.SendNotification();
1478 application.Render();
1480 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1481 application.SendNotification();
1483 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1484 // hbox left justifies elements
1485 tet_infoline("Test Child Actor Position");
1487 auto controlXPosition=0.0f;
1489 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1490 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1492 0.0f ), 0.0001f, TEST_LOCATION );
1494 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1495 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1498 0.0001f, TEST_LOCATION );
1500 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1501 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1503 0.0f ), 0.0001f, TEST_LOCATION );
1505 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1506 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1508 0.0f ), 0.0001f, TEST_LOCATION );
1510 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1511 auto totalControlsHeight = CONTROL_SIZE.height;
1513 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1514 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1515 0.0f ), 0.0001f, TEST_LOCATION );
1517 // Change layout padding
1518 const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
1519 tet_printf( "\nChanging Padding to control at index 1 \n" );
1520 hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
1522 // Ensure layouting happens
1523 application.SendNotification();
1524 application.Render();
1526 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1527 application.SendNotification();
1529 controlXPosition = NEW_LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1530 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
1531 NEW_LAYOUT_PADDING.top,
1532 0.0f ), 0.0001f, TEST_LOCATION );
1534 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1535 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1536 NEW_LAYOUT_PADDING.top,
1538 0.0001f, TEST_LOCATION );
1540 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1541 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1542 NEW_LAYOUT_PADDING.top,
1543 0.0f ), 0.0001f, TEST_LOCATION );
1545 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1546 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1547 NEW_LAYOUT_PADDING.top,
1548 0.0f ), 0.0001f, TEST_LOCATION );
1549 totalControlsWidth = CONTROL_SIZE.width * controls.size();
1550 totalControlsHeight = CONTROL_SIZE.height;
1552 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
1553 totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
1554 0.0f ), 0.0001f, TEST_LOCATION );
1560 int UtcDaliLayouting_HboxLayout_Margin01(void)
1562 ToolkitTestApplication application;
1563 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
1565 Stage stage = Stage::GetCurrent();
1566 auto hbox = Control::New();
1567 auto hboxLayout = LinearLayout::New();
1568 DevelControl::SetLayout( hbox, hboxLayout );
1569 hbox.SetName( "HBox");
1571 std::vector< Control > controls;
1572 controls.push_back( CreateLeafControl( 40, 40 ) );
1573 controls.push_back( CreateLeafControl( 60, 40 ) );
1574 controls.push_back( CreateLeafControl( 80, 40 ) );
1575 controls.push_back( CreateLeafControl( 100, 40 ) );
1577 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
1578 tet_printf( "\nAdding Margin to control at index 1 \n" );
1579 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1581 for( auto&& iter : controls )
1585 hbox.SetParentOrigin( ParentOrigin::CENTER );
1586 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1589 // Ensure layouting happens
1590 application.SendNotification();
1591 application.Render();
1593 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1594 // hbox left justifies elements
1595 tet_infoline("Test Child Actor Position");
1596 auto xPositionOfControlBeingTested = 0.0f;
1597 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1599 0.0f ), 0.0001f, TEST_LOCATION );
1600 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
1602 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1603 380.0f + CONTROL_MARGIN.top, 0.0f ),
1604 0.0001f, TEST_LOCATION );
1606 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
1607 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1609 xPositionOfControlBeingTested += 80.0f;
1610 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1612 tet_infoline("Test Child Actor Size is the same after Margin added");
1613 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1614 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
1615 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1616 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1622 int UtcDaliLayouting_VboxLayout01(void)
1624 ToolkitTestApplication application;
1625 tet_infoline(" UtcDaliLayouting_VboxLayout01");
1627 Stage stage = Stage::GetCurrent();
1628 auto vbox = Control::New();
1629 auto vboxLayout = LinearLayout::New();
1630 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1631 vboxLayout.SetAlignment( LinearLayout::Alignment::TOP | LinearLayout::Alignment::CENTER_HORIZONTAL );
1632 DevelControl::SetLayout( vbox, vboxLayout );
1633 vbox.SetName( "Vbox");
1635 std::vector< Control > controls;
1636 controls.push_back( CreateLeafControl( 40, 40 ) );
1637 controls.push_back( CreateLeafControl( 60, 60 ) );
1638 controls.push_back( CreateLeafControl( 80, 80 ) );
1639 controls.push_back( CreateLeafControl( 100, 100 ) );
1641 for( auto&& iter : controls )
1645 vbox.SetParentOrigin( ParentOrigin::CENTER );
1646 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1649 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1652 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1654 // Ensure layouting happens
1655 application.SendNotification();
1656 application.Render();
1658 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
1659 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1660 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1661 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1662 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1664 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1665 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1666 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1667 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1672 int UtcDaliLayouting_VboxLayout02(void)
1674 ToolkitTestApplication application;
1675 tet_infoline(" UtcDaliLayouting_VboxLayout01");
1677 Stage stage = Stage::GetCurrent();
1679 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1680 // LayoutGroup for this to happen automatically.
1682 // For this test, add an hbox instead
1683 auto rootControl = Control::New();
1684 auto absoluteLayout = AbsoluteLayout::New();
1685 DevelControl::SetLayout( rootControl, absoluteLayout );
1686 rootControl.SetName( "AbsoluteLayout");
1687 stage.Add( rootControl );
1689 auto vbox = Control::New();
1690 auto vboxLayout = LinearLayout::New();
1691 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1692 vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
1693 DevelControl::SetLayout( vbox, vboxLayout );
1694 vbox.SetName( "Vbox");
1695 rootControl.Add( vbox );
1697 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1698 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1700 std::vector< Control > controls;
1701 controls.push_back( CreateLeafControl( 40, 40 ) );
1702 controls.push_back( CreateLeafControl( 60, 60 ) );
1703 controls.push_back( CreateLeafControl( 80, 80 ) );
1704 controls.push_back( CreateLeafControl( 100, 100 ) );
1706 for( auto&& iter : controls )
1710 vbox.SetParentOrigin( ParentOrigin::CENTER );
1711 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1713 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1716 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1718 // Ensure layouting happens
1719 application.SendNotification();
1720 application.Render();
1722 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1723 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1725 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1726 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1727 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1729 // 3rd control is set to match parent - this should also be 100 wide
1730 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1731 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1732 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1733 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1735 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1736 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1737 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1738 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1744 int UtcDaliLayouting_VboxLayout03(void)
1746 ToolkitTestApplication application;
1747 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
1749 Stage stage = Stage::GetCurrent();
1751 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1752 // LayoutGroup for this to happen automatically.
1754 // For this test, add an hbox instead
1755 auto hbox = Control::New();
1756 auto hboxLayout = LinearLayout::New();
1757 DevelControl::SetLayout( hbox, hboxLayout );
1758 hbox.SetName( "Hbox");
1761 auto vbox = Control::New();
1762 auto vboxLayout = LinearLayout::New();
1763 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
1764 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1765 vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
1767 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
1769 DevelControl::SetLayout( vbox, vboxLayout );
1770 vbox.SetName( "Vbox");
1773 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1774 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1776 std::vector< Control > controls;
1777 controls.push_back( CreateLeafControl( 40, 40 ) );
1778 controls.push_back( CreateLeafControl( 60, 60 ) );
1779 controls.push_back( CreateLeafControl( 80, 80 ) );
1780 controls.push_back( CreateLeafControl( 100, 100 ) );
1782 for( auto&& iter : controls )
1786 vbox.SetParentOrigin( ParentOrigin::CENTER );
1787 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1789 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1792 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1794 // Ensure layouting happens
1795 application.SendNotification();
1796 application.Render();
1798 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1799 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1801 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1802 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1803 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1805 // 3rd control is set to match parent - this should also be 100 wide
1806 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1807 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1808 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1809 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1811 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1812 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1813 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1814 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1819 int UtcDaliLayouting_VboxLayout_Padding(void)
1821 ToolkitTestApplication application;
1822 tet_infoline("UtcDaliLayouting_VboxLayout_Padding - Adding Padding to the vbox");
1824 // Adding padding to the layout should offset the positioning of the children.
1826 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1827 const Size CONTROL_SIZE = Size( 40, 40 );
1829 Stage stage = Stage::GetCurrent();
1830 // Create a root layout, ideally Dali would have a default layout in the root layer.
1831 // Without this root layer the LinearLayout (or any other layout) will not
1832 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1833 // It uses the default stage size and ideally should have a layout added to it.
1834 auto rootLayoutControl = Control::New();
1835 rootLayoutControl.SetName( "AbsoluteLayout");
1836 auto rootLayout = AbsoluteLayout::New();
1837 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1838 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1839 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1840 stage.Add( rootLayoutControl );
1842 auto vbox = Control::New();
1843 auto vboxLayout = LinearLayout::New();
1844 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1845 DevelControl::SetLayout( vbox, vboxLayout );
1846 vbox.SetName( "VBox");
1847 vbox.SetProperty( Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1848 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1849 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1851 std::vector< Control > controls;
1852 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1853 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1854 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1855 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1857 for( auto&& iter : controls )
1862 vbox.SetParentOrigin( ParentOrigin::CENTER );
1863 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1864 rootLayoutControl.Add( vbox );
1866 // Ensure layouting happens
1867 application.SendNotification();
1868 application.Render();
1870 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1871 application.SendNotification();
1873 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
1874 tet_infoline("Test Child Actor Position");
1876 auto controlYPosition = 0.0f;
1878 controlYPosition = LAYOUT_PADDING.top; // First child positioned at offset defined by the padding
1879 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1881 0.0f ), 0.0001f, TEST_LOCATION );
1883 controlYPosition += CONTROL_SIZE.height; // Second child positioned is the position of the first child + the first child's height.
1884 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1887 0.0001f, TEST_LOCATION );
1889 controlYPosition += CONTROL_SIZE.height; // Third child positioned adjacent to second
1890 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1892 0.0f ), 0.0001f, TEST_LOCATION );
1894 controlYPosition += CONTROL_SIZE.height; // Forth passed adjacent to the third
1895 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1897 0.0f ), 0.0001f, TEST_LOCATION );
1899 auto totalControlsWidth = CONTROL_SIZE.width;
1900 auto totalControlsHeight = CONTROL_SIZE.height * controls.size();
1902 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1903 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1904 0.0f ), 0.0001f, TEST_LOCATION );
1910 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
1912 ToolkitTestApplication application;
1913 tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
1914 tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
1916 Stage stage = Stage::GetCurrent();
1918 auto hbox = Control::New();
1919 auto hboxLayout = Test::CustomLayout::New();
1920 DevelControl::SetLayout( hbox, hboxLayout );
1921 hbox.SetName( "HBox");
1923 std::vector< Control > controls;
1924 controls.push_back( CreateLeafControl( 40, 40 ) );
1925 controls.push_back( CreateLeafControl( 60, 40 ) );
1926 controls.push_back( CreateLeafControl( 80, 40 ) );
1927 controls.push_back( CreateLeafControl( 100, 40 ) );
1929 for( auto&& iter : controls )
1933 hbox.SetParentOrigin( ParentOrigin::CENTER );
1934 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1937 // Ensure layouting happens
1938 application.SendNotification();
1939 application.Render();
1941 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1942 // hbox left justifies elements
1943 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1944 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1945 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1946 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1948 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1949 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1950 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1951 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1953 controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
1954 controls[2].Lower(); // 2->1; 2, 1, 3, 0
1956 application.SendNotification();
1957 application.Render();
1959 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1960 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1961 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1962 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1964 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1965 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1966 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1967 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1972 int UtcDaliLayouting_HboxLayout_TargetSize(void)
1974 ToolkitTestApplication application;
1975 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
1977 Stage stage = Stage::GetCurrent();
1978 auto hbox = Control::New();
1979 auto hboxLayout = LinearLayout::New();
1980 DevelControl::SetLayout( hbox, hboxLayout );
1981 hbox.SetName( "HBox");
1983 std::vector< Control > controls;
1984 controls.push_back( CreateLeafControl( 40, 40 ) );
1985 for( auto&& iter : controls )
1987 iter.SetSize( 100, 100 );
1990 hbox.SetParentOrigin( ParentOrigin::CENTER );
1991 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1994 // Ensure layouting happens
1995 application.SendNotification();
1996 application.Render();
1998 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
1999 // hbox left justifies elements
2000 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2001 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2006 int UtcDaliLayouting_RemoveLayout01(void)
2008 ToolkitTestApplication application;
2009 tet_infoline(" UtcDaliLayouting_RemoveLayout");
2011 Stage stage = Stage::GetCurrent();
2013 auto rootControl = Control::New();
2014 auto absoluteLayout = AbsoluteLayout::New();
2015 DevelControl::SetLayout( rootControl, absoluteLayout );
2016 rootControl.SetName( "AbsoluteLayout" );
2017 stage.Add( rootControl );
2019 auto hbox = Control::New();
2020 auto hboxLayout = LinearLayout::New();
2021 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2022 DevelControl::SetLayout( hbox, hboxLayout );
2023 hbox.SetName( "HBox" );
2025 std::vector< Control > controls;
2026 controls.push_back( CreateLeafControl( 40, 40 ) );
2027 controls.push_back( CreateLeafControl( 60, 40 ) );
2029 for( auto&& iter : controls )
2033 hbox.SetParentOrigin( ParentOrigin::CENTER );
2034 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2035 rootControl.Add( hbox );
2037 tet_infoline("Layout as normal");
2038 application.SendNotification();
2039 application.Render();
2041 tet_infoline("Set an empty layout on hbox container");
2042 LinearLayout emptyLayout;
2043 DevelControl::SetLayout( hbox, emptyLayout );
2045 tet_infoline("Run another layout");
2046 application.SendNotification();
2047 application.Render();
2049 tet_infoline("Check leaf controls haven't moved");
2051 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2052 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2054 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2055 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2060 int UtcDaliLayouting_LayoutChildren01(void)
2062 ToolkitTestApplication application;
2063 tet_infoline(" UtcDaliLayouting_LayoutChildren01");
2065 Stage stage = Stage::GetCurrent();
2067 auto rootControl = Control::New();
2068 auto absoluteLayout = AbsoluteLayout::New();
2069 DevelControl::SetLayout( rootControl, absoluteLayout );
2070 stage.Add( rootControl );
2072 auto hbox = Control::New();
2073 auto hboxLayout = LinearLayout::New();
2074 DevelControl::SetLayout( hbox, hboxLayout );
2075 rootControl.Add( hbox );
2077 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2079 tet_infoline("Test removal by setting empty layout to child container" );
2080 DevelControl::SetLayout( hbox, LayoutItem{} );
2082 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2084 auto& hboxImpl = GetImplementation( hboxLayout );
2086 DALI_TEST_EQUALS( hboxLayout.GetOwner(), empty, TEST_LOCATION );
2087 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2090 hboxImpl.SetLayoutRequested();
2095 int UtcDaliLayouting_LayoutChildren02(void)
2097 ToolkitTestApplication application;
2098 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2100 Stage stage = Stage::GetCurrent();
2102 auto rootControl = Control::New();
2103 auto absoluteLayout = AbsoluteLayout::New();
2104 DevelControl::SetLayout( rootControl, absoluteLayout );
2105 stage.Add( rootControl );
2107 auto hbox = Control::New();
2108 auto hboxLayout = LinearLayout::New();
2109 DevelControl::SetLayout( hbox, hboxLayout );
2110 rootControl.Add( hbox );
2112 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2114 tet_infoline("Test removal by removing child actor from parent container" );
2117 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2119 auto& hboxImpl = GetImplementation( hboxLayout );
2120 tet_infoline("Test child actor still has hbox layout " );
2121 DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
2123 tet_infoline("Test hbox layout has no parent " );
2124 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2129 int UtcDaliLayouting_LayoutChildren03(void)
2131 ToolkitTestApplication application;
2132 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2134 Stage stage = Stage::GetCurrent();
2136 auto rootControl = Control::New();
2137 auto absoluteLayout = AbsoluteLayout::New();
2138 DevelControl::SetLayout( rootControl, absoluteLayout );
2139 stage.Add( rootControl );
2141 auto hbox = Control::New();
2142 auto hboxLayout = LinearLayout::New();
2143 DevelControl::SetLayout( hbox, hboxLayout );
2144 rootControl.Add( hbox );
2146 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2148 tet_infoline("Test removal by removing child layout from parent layout" );
2149 absoluteLayout.Remove( hboxLayout );
2151 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2153 auto& hboxImpl = GetImplementation( hboxLayout );
2155 tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
2156 DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
2157 DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
2159 tet_infoline("Check orphaned layout has no parent");
2160 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2166 int UtcDaliLayouting_LayoutChildren04(void)
2168 ToolkitTestApplication application;
2169 tet_infoline(" UtcDaliLayouting_LayoutChildren03");
2171 Stage stage = Stage::GetCurrent();
2173 auto rootControl = Control::New();
2174 auto absoluteLayout = AbsoluteLayout::New();
2175 DevelControl::SetLayout( rootControl, absoluteLayout );
2176 stage.Add( rootControl );
2178 auto hbox = Control::New();
2179 tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
2180 auto hboxLayout = LinearLayout::New();
2181 rootControl.Add( hbox );
2183 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2185 tet_infoline("Then setting a layout on the child container");
2186 DevelControl::SetLayout( hbox, hboxLayout );
2188 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2190 auto& hboxImpl = GetImplementation( hboxLayout );
2191 auto& absImpl = GetImplementation( absoluteLayout );
2192 DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
2193 DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
2198 int UtcDaliLayouting_SetLayoutOrder01(void)
2200 ToolkitTestApplication application;
2201 tet_infoline(" UtcDaliLayouting_SetLayoutOrder01 - Call SetLayout after adding the control to the root layout");
2203 Stage stage = Stage::GetCurrent();
2205 auto rootControl = Control::New();
2206 auto absoluteLayout = AbsoluteLayout::New();
2207 DevelControl::SetLayout( rootControl, absoluteLayout );
2208 rootControl.SetName( "AbsoluteLayout" );
2209 stage.Add( rootControl );
2211 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
2212 auto hbox = Control::New();
2213 auto hboxLayout = LinearLayout::New();
2214 hbox.SetName( "HBox");
2216 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
2217 rootControl.Add( hbox );
2219 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
2220 DevelControl::SetLayout( hbox, hboxLayout );
2222 // Add a Child control
2223 std::vector< Control > controls;
2224 controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
2225 for( auto&& iter : controls )
2230 // Ensure layouting happens
2231 application.SendNotification();
2232 application.Render();
2234 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2239 int UtcDaliLayouting_SetLayoutOrder02(void)
2241 ToolkitTestApplication application;
2242 tet_infoline(" UtcDaliLayouting_SetLayoutOrder02 - Test the layout item order and the control order");
2244 Stage stage = Stage::GetCurrent();
2246 auto rootControl = Control::New();
2247 auto absoluteLayout = AbsoluteLayout::New();
2248 DevelControl::SetLayout( rootControl, absoluteLayout );
2249 rootControl.SetName( "AbsoluteLayout" );
2250 stage.Add( rootControl );
2252 auto hbox = Control::New();
2253 auto hboxLayout = LinearLayout::New();
2254 hbox.SetName( "HBox");
2256 rootControl.Add( hbox );
2258 DevelControl::SetLayout( hbox, hboxLayout );
2260 // Add child controls
2261 std::vector< Control > controls;
2262 controls.push_back( CreateLeafControl( 100, 100 ) ); // 0
2263 controls.push_back( CreateLeafControl( 100, 100 ) ); // 1
2264 controls.push_back( CreateLeafControl( 100, 100 ) ); // 2
2266 for( auto&& iter : controls )
2271 // Ensure layouting happens
2272 application.SendNotification();
2273 application.Render();
2275 TestLayoutItemOrder( controls, hboxLayout );
2277 tet_infoline("RaiseToTop");
2279 controls[0].RaiseToTop(); // 1 2 0
2281 TestLayoutItemOrder( controls, hboxLayout );
2283 tet_infoline("LowerToBottom");
2285 controls[2].LowerToBottom(); // 2 1 0
2287 TestLayoutItemOrder( controls, hboxLayout );
2289 tet_infoline("Remove / Add");
2291 hbox.Remove( controls[2] ); // 1 0
2292 hbox.Add( controls[2] ); // 1 0 2
2294 TestLayoutItemOrder( controls, hboxLayout );
2296 tet_infoline("SetLayout");
2298 auto vboxLayout = LinearLayout::New();
2299 DevelControl::SetLayout( controls[0], vboxLayout );
2301 TestLayoutItemOrder( controls, hboxLayout );
2303 tet_infoline("Raise");
2305 controls[0].Raise(); // 1 2 0
2307 TestLayoutItemOrder( controls, hboxLayout );
2309 tet_infoline("Lower");
2311 controls[2].Lower(); // 2 1 0
2313 TestLayoutItemOrder( controls, hboxLayout );
2315 tet_infoline("SetLayout again");
2317 auto vboxLayout1 = LinearLayout::New();
2318 DevelControl::SetLayout( controls[2], vboxLayout1 );
2320 TestLayoutItemOrder( controls, hboxLayout );
2322 DevelControl::SetLayout( controls[2], vboxLayout );
2327 int UtcDaliLayouting_LayoutGroup01(void)
2329 ToolkitTestApplication application;
2330 tet_infoline("UtcDaliLayouting_LayoutGroup01 - Test adding a control to a layout then adding a TextLabel to that control");
2332 Control rootControl;
2333 SetupRootLayoutControl( rootControl );
2335 // Create a parent layout
2336 auto hbox = Control::New();
2337 auto hboxLayout = LinearLayout::New();
2338 hbox.SetName( "HBox");
2339 rootControl.Add( hbox );
2340 DevelControl::SetLayout( hbox, hboxLayout );
2341 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2342 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2343 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2345 tet_infoline("Add a control without SetLayout being called");
2347 auto control = Control::New();
2348 control.SetName("Control1");
2349 hbox.Add( control );
2350 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2351 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2353 tet_infoline("Add a Textlabel to the control");
2354 auto textLabel = TextLabel::New("Test text");
2355 textLabel.SetName("TextLabel");
2356 control.Add( textLabel );
2358 // Ensure layouting happens
2359 application.SendNotification();
2360 application.Render();
2362 tet_infoline("Test text is it's natural size");
2363 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2364 tet_infoline("Test control is width of it's parent and height of it's child");
2365 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2370 int UtcDaliLayouting_LayoutGroup02(void)
2372 ToolkitTestApplication application;
2373 tet_infoline("UtcDaliLayouting_LayoutGroup02 - Test control is the size of it's largest child");
2375 Control rootControl;
2376 SetupRootLayoutControl( rootControl );
2378 // Create a parent layout
2379 auto hbox = Control::New();
2380 auto hboxLayout = LinearLayout::New();
2381 hbox.SetName( "HBox");
2382 rootControl.Add( hbox );
2383 DevelControl::SetLayout( hbox, hboxLayout );
2384 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2385 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2386 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2388 tet_infoline("Add a control without SetLayout being called");
2390 auto control = Control::New();
2391 control.SetName("Control1");
2392 hbox.Add( control );
2393 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2394 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2396 tet_infoline("Add a Textlabel to the control");
2397 auto textLabel = TextLabel::New("Test text");
2398 textLabel.SetName("TextLabel");
2399 control.Add( textLabel );
2401 tet_infoline("Add another Textlabel to the control");
2402 auto largeTextLabel = TextLabel::New("Test large text");
2403 largeTextLabel.SetName("TextLabel-Large");
2404 control.Add( largeTextLabel );
2406 // Ensure layouting happens
2407 application.SendNotification();
2408 application.Render();
2410 tet_infoline("Test text is it's natural size");
2411 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2412 tet_infoline("Test text is centered in the control, the control is the size of the largest child");
2413 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2415 tet_infoline("Test large text is it's natural size");
2416 DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2417 tet_infoline("Test text is aligned to start as is the size of the control");
2418 DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2420 tet_infoline("Test control is width of it's parent and height of it's largest child");
2421 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2426 int UtcDaliLayouting_LayoutGroup03(void)
2428 ToolkitTestApplication application;
2429 tet_infoline("UtcDaliLayouting_LayoutGroup03 - Test control witha LayoutGroup as a leaf");
2431 Control rootControl;
2432 SetupRootLayoutControl( rootControl );
2434 // Create a parent layout
2435 auto hbox = Control::New();
2436 auto hboxLayout = LinearLayout::New();
2437 hbox.SetName( "HBox");
2438 rootControl.Add( hbox );
2439 DevelControl::SetLayout( hbox, hboxLayout );
2440 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2441 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2442 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2444 tet_infoline("Add a control without SetLayout being called");
2446 auto control = Control::New();
2447 control.SetName("Control1");
2448 hbox.Add( control );
2449 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2450 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
2452 // Ensure layouting happens
2453 application.SendNotification();
2454 application.Render();
2456 tet_infoline("Test control is width of it's parent and exact given height");
2457 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2458 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2463 int UtcDaliLayouting_LayoutGroupWithPadding01(void)
2465 ToolkitTestApplication application;
2466 tet_infoline("UtcDaliLayouting_LayoutGroupWithPadding01 - Test adding a control to a layout that has padding");
2468 Control rootControl;
2469 SetupRootLayoutControl( rootControl );
2471 // Create a parent layout
2472 auto hbox = Control::New();
2473 auto hboxLayout = LinearLayout::New();
2474 hbox.SetName( "HBox");
2475 rootControl.Add( hbox );
2476 DevelControl::SetLayout( hbox, hboxLayout );
2477 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2478 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2479 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2481 tet_infoline("Add a control without SetLayout being called");
2483 auto control = Control::New();
2484 control.SetName("Control1");
2485 hbox.Add( control );
2486 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2487 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2489 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
2490 tet_printf( "Adding Padding to control");
2491 control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
2493 tet_infoline("Add a Textlabel to the control");
2494 auto textLabel = TextLabel::New("Test text");
2495 textLabel.SetName("TextLabel");
2496 control.Add( textLabel );
2498 // Ensure layouting happens
2499 application.SendNotification();
2500 application.Render();
2502 tet_infoline("Test text is it's natural size");
2503 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2504 tet_infoline("Test control is size of it's child and control it's own padding");
2505 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 245.0f, 86.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2510 int UtcDaliLayouting_LayoutGroupWithChildMargin01(void)
2512 ToolkitTestApplication application;
2513 tet_infoline("UtcDaliLayouting_LayoutGroupWithChildMargin01 - Test adding a control with padding to a layout that has padding");
2515 Control rootControl;
2516 SetupRootLayoutControl( rootControl );
2518 // Create a parent layout
2519 auto hbox = Control::New();
2520 auto hboxLayout = LinearLayout::New();
2521 hbox.SetName( "HBox");
2522 rootControl.Add( hbox );
2523 DevelControl::SetLayout( hbox, hboxLayout );
2524 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2525 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2526 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2528 tet_infoline("Add a control without SetLayout being called");
2530 auto control = Control::New();
2531 control.SetName("Control1");
2532 hbox.Add( control );
2533 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2534 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2536 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
2537 tet_printf( "Adding Padding to control");
2538 control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
2540 tet_infoline("Add a Textlabel to the control");
2541 auto textLabel = TextLabel::New("Test text");
2542 const Extents CHILD_MARGIN = Extents( 10, 0, 5, 0 );
2543 textLabel.SetProperty( Toolkit::Control::Property::MARGIN, CHILD_MARGIN );
2544 textLabel.SetName("TextLabel");
2545 control.Add( textLabel );
2547 // Ensure layouting happens
2548 application.SendNotification();
2549 application.Render();
2551 tet_infoline("Test text is it's natural size");
2552 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2553 tet_infoline("Test control is width of it's parent and height of it's child");
2554 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 255.0f, 91.0f, 0.0f ), 0.0001f, TEST_LOCATION );