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_RemoveLayout01(void)
1974 ToolkitTestApplication application;
1975 tet_infoline(" UtcDaliLayouting_RemoveLayout");
1977 Stage stage = Stage::GetCurrent();
1979 auto rootControl = Control::New();
1980 auto absoluteLayout = AbsoluteLayout::New();
1981 DevelControl::SetLayout( rootControl, absoluteLayout );
1982 rootControl.SetName( "AbsoluteLayout" );
1983 stage.Add( rootControl );
1985 auto hbox = Control::New();
1986 auto hboxLayout = LinearLayout::New();
1987 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1988 DevelControl::SetLayout( hbox, hboxLayout );
1989 hbox.SetName( "HBox" );
1991 std::vector< Control > controls;
1992 controls.push_back( CreateLeafControl( 40, 40 ) );
1993 controls.push_back( CreateLeafControl( 60, 40 ) );
1995 for( auto&& iter : controls )
1999 hbox.SetParentOrigin( ParentOrigin::CENTER );
2000 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2001 rootControl.Add( hbox );
2003 tet_infoline("Layout as normal");
2004 application.SendNotification();
2005 application.Render();
2007 tet_infoline("Set an empty layout on hbox container");
2008 LinearLayout emptyLayout;
2009 DevelControl::SetLayout( hbox, emptyLayout );
2011 tet_infoline("Run another layout");
2012 application.SendNotification();
2013 application.Render();
2015 tet_infoline("Check leaf controls haven't moved");
2017 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2018 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2020 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2021 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2026 int UtcDaliLayouting_HboxLayout_TargetSize(void)
2028 ToolkitTestApplication application;
2029 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
2031 Stage stage = Stage::GetCurrent();
2032 auto hbox = Control::New();
2033 auto hboxLayout = LinearLayout::New();
2034 DevelControl::SetLayout( hbox, hboxLayout );
2035 hbox.SetName( "HBox");
2037 std::vector< Control > controls;
2038 controls.push_back( CreateLeafControl( 40, 40 ) );
2039 for( auto&& iter : controls )
2041 iter.SetSize( 100, 100 );
2044 hbox.SetParentOrigin( ParentOrigin::CENTER );
2045 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2048 // Ensure layouting happens
2049 application.SendNotification();
2050 application.Render();
2052 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
2053 // hbox left justifies elements
2054 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2055 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2060 int UtcDaliLayouting_RemoveLayout01(void)
2062 ToolkitTestApplication application;
2063 tet_infoline(" UtcDaliLayouting_RemoveLayout");
2065 Stage stage = Stage::GetCurrent();
2067 auto rootControl = Control::New();
2068 auto absoluteLayout = AbsoluteLayout::New();
2069 DevelControl::SetLayout( rootControl, absoluteLayout );
2070 rootControl.SetName( "AbsoluteLayout" );
2071 stage.Add( rootControl );
2073 auto hbox = Control::New();
2074 auto hboxLayout = LinearLayout::New();
2075 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2076 DevelControl::SetLayout( hbox, hboxLayout );
2077 hbox.SetName( "HBox" );
2079 std::vector< Control > controls;
2080 controls.push_back( CreateLeafControl( 40, 40 ) );
2081 controls.push_back( CreateLeafControl( 60, 40 ) );
2083 for( auto&& iter : controls )
2087 hbox.SetParentOrigin( ParentOrigin::CENTER );
2088 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2089 rootControl.Add( hbox );
2091 tet_infoline("Layout as normal");
2092 application.SendNotification();
2093 application.Render();
2095 tet_infoline("Set an empty layout on hbox container");
2096 LinearLayout emptyLayout;
2097 DevelControl::SetLayout( hbox, emptyLayout );
2099 tet_infoline("Run another layout");
2100 application.SendNotification();
2101 application.Render();
2103 tet_infoline("Check leaf controls haven't moved");
2105 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2106 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2108 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2109 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2114 int UtcDaliLayouting_LayoutChildren01(void)
2116 ToolkitTestApplication application;
2117 tet_infoline(" UtcDaliLayouting_LayoutChildren01");
2119 Stage stage = Stage::GetCurrent();
2121 auto rootControl = Control::New();
2122 auto absoluteLayout = AbsoluteLayout::New();
2123 DevelControl::SetLayout( rootControl, absoluteLayout );
2124 stage.Add( rootControl );
2126 auto hbox = Control::New();
2127 auto hboxLayout = LinearLayout::New();
2128 DevelControl::SetLayout( hbox, hboxLayout );
2129 rootControl.Add( hbox );
2131 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2133 tet_infoline("Test removal by setting empty layout to child container" );
2134 DevelControl::SetLayout( hbox, LayoutItem{} );
2136 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2138 auto& hboxImpl = GetImplementation( hboxLayout );
2140 DALI_TEST_EQUALS( hboxLayout.GetOwner(), empty, TEST_LOCATION );
2141 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2144 hboxImpl.SetLayoutRequested();
2149 int UtcDaliLayouting_LayoutChildren02(void)
2151 ToolkitTestApplication application;
2152 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2154 Stage stage = Stage::GetCurrent();
2156 auto rootControl = Control::New();
2157 auto absoluteLayout = AbsoluteLayout::New();
2158 DevelControl::SetLayout( rootControl, absoluteLayout );
2159 stage.Add( rootControl );
2161 auto hbox = Control::New();
2162 auto hboxLayout = LinearLayout::New();
2163 DevelControl::SetLayout( hbox, hboxLayout );
2164 rootControl.Add( hbox );
2166 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2168 tet_infoline("Test removal by removing child actor from parent container" );
2171 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2173 auto& hboxImpl = GetImplementation( hboxLayout );
2174 tet_infoline("Test child actor still has hbox layout " );
2175 DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
2177 tet_infoline("Test hbox layout has no parent " );
2178 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2183 int UtcDaliLayouting_LayoutChildren03(void)
2185 ToolkitTestApplication application;
2186 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2188 Stage stage = Stage::GetCurrent();
2190 auto rootControl = Control::New();
2191 auto absoluteLayout = AbsoluteLayout::New();
2192 DevelControl::SetLayout( rootControl, absoluteLayout );
2193 stage.Add( rootControl );
2195 auto hbox = Control::New();
2196 auto hboxLayout = LinearLayout::New();
2197 DevelControl::SetLayout( hbox, hboxLayout );
2198 rootControl.Add( hbox );
2200 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2202 tet_infoline("Test removal by removing child layout from parent layout" );
2203 absoluteLayout.Remove( hboxLayout );
2205 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2207 auto& hboxImpl = GetImplementation( hboxLayout );
2209 tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
2210 DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
2211 DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
2213 tet_infoline("Check orphaned layout has no parent");
2214 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2220 int UtcDaliLayouting_LayoutChildren04(void)
2222 ToolkitTestApplication application;
2223 tet_infoline(" UtcDaliLayouting_LayoutChildren03");
2225 Stage stage = Stage::GetCurrent();
2227 auto rootControl = Control::New();
2228 auto absoluteLayout = AbsoluteLayout::New();
2229 DevelControl::SetLayout( rootControl, absoluteLayout );
2230 stage.Add( rootControl );
2232 auto hbox = Control::New();
2233 tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
2234 auto hboxLayout = LinearLayout::New();
2235 rootControl.Add( hbox );
2237 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2239 tet_infoline("Then setting a layout on the child container");
2240 DevelControl::SetLayout( hbox, hboxLayout );
2242 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2244 auto& hboxImpl = GetImplementation( hboxLayout );
2245 auto& absImpl = GetImplementation( absoluteLayout );
2246 DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
2247 DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
2252 int UtcDaliLayouting_SetLayoutOrder01(void)
2254 ToolkitTestApplication application;
2255 tet_infoline(" UtcDaliLayouting_SetLayoutOrder01 - Call SetLayout after adding the control to the root layout");
2257 Stage stage = Stage::GetCurrent();
2259 auto rootControl = Control::New();
2260 auto absoluteLayout = AbsoluteLayout::New();
2261 DevelControl::SetLayout( rootControl, absoluteLayout );
2262 rootControl.SetName( "AbsoluteLayout" );
2263 stage.Add( rootControl );
2265 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
2266 auto hbox = Control::New();
2267 auto hboxLayout = LinearLayout::New();
2268 hbox.SetName( "HBox");
2270 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
2271 rootControl.Add( hbox );
2273 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
2274 DevelControl::SetLayout( hbox, hboxLayout );
2276 // Add a Child control
2277 std::vector< Control > controls;
2278 controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
2279 for( auto&& iter : controls )
2284 // Ensure layouting happens
2285 application.SendNotification();
2286 application.Render();
2288 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2293 int UtcDaliLayouting_SetLayoutOrder02(void)
2295 ToolkitTestApplication application;
2296 tet_infoline(" UtcDaliLayouting_SetLayoutOrder02 - Test the layout item order and the control order");
2298 Stage stage = Stage::GetCurrent();
2300 auto rootControl = Control::New();
2301 auto absoluteLayout = AbsoluteLayout::New();
2302 DevelControl::SetLayout( rootControl, absoluteLayout );
2303 rootControl.SetName( "AbsoluteLayout" );
2304 stage.Add( rootControl );
2306 auto hbox = Control::New();
2307 auto hboxLayout = LinearLayout::New();
2308 hbox.SetName( "HBox");
2310 rootControl.Add( hbox );
2312 DevelControl::SetLayout( hbox, hboxLayout );
2314 // Add child controls
2315 std::vector< Control > controls;
2316 controls.push_back( CreateLeafControl( 100, 100 ) ); // 0
2317 controls.push_back( CreateLeafControl( 100, 100 ) ); // 1
2318 controls.push_back( CreateLeafControl( 100, 100 ) ); // 2
2320 for( auto&& iter : controls )
2325 // Ensure layouting happens
2326 application.SendNotification();
2327 application.Render();
2329 TestLayoutItemOrder( controls, hboxLayout );
2331 tet_infoline("RaiseToTop");
2333 controls[0].RaiseToTop(); // 1 2 0
2335 TestLayoutItemOrder( controls, hboxLayout );
2337 tet_infoline("LowerToBottom");
2339 controls[2].LowerToBottom(); // 2 1 0
2341 TestLayoutItemOrder( controls, hboxLayout );
2343 tet_infoline("Remove / Add");
2345 hbox.Remove( controls[2] ); // 1 0
2346 hbox.Add( controls[2] ); // 1 0 2
2348 TestLayoutItemOrder( controls, hboxLayout );
2350 tet_infoline("SetLayout");
2352 auto vboxLayout = LinearLayout::New();
2353 DevelControl::SetLayout( controls[0], vboxLayout );
2355 TestLayoutItemOrder( controls, hboxLayout );
2357 tet_infoline("Raise");
2359 controls[0].Raise(); // 1 2 0
2361 TestLayoutItemOrder( controls, hboxLayout );
2363 tet_infoline("Lower");
2365 controls[2].Lower(); // 2 1 0
2367 TestLayoutItemOrder( controls, hboxLayout );
2369 tet_infoline("SetLayout again");
2371 auto vboxLayout1 = LinearLayout::New();
2372 DevelControl::SetLayout( controls[2], vboxLayout1 );
2374 TestLayoutItemOrder( controls, hboxLayout );
2376 DevelControl::SetLayout( controls[2], vboxLayout );
2381 int UtcDaliLayouting_LayoutGroup01(void)
2383 ToolkitTestApplication application;
2384 tet_infoline("UtcDaliLayouting_LayoutGroup01 - Test adding a control to a layout then adding a TextLabel to that control");
2386 Control rootControl;
2387 SetupRootLayoutControl( rootControl );
2389 // Create a parent layout
2390 auto hbox = Control::New();
2391 auto hboxLayout = LinearLayout::New();
2392 hbox.SetName( "HBox");
2393 rootControl.Add( hbox );
2394 DevelControl::SetLayout( hbox, hboxLayout );
2395 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2396 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2397 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2399 tet_infoline("Add a control without SetLayout being called");
2401 auto control = Control::New();
2402 control.SetName("Control1");
2403 hbox.Add( control );
2404 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2405 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2407 tet_infoline("Add a Textlabel to the control");
2408 auto textLabel = TextLabel::New("Test text");
2409 textLabel.SetName("TextLabel");
2410 control.Add( textLabel );
2412 // Ensure layouting happens
2413 application.SendNotification();
2414 application.Render();
2416 tet_infoline("Test text is it's natural size");
2417 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2418 tet_infoline("Test control is width of it's parent and height of it's child");
2419 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2424 int UtcDaliLayouting_LayoutGroup02(void)
2426 ToolkitTestApplication application;
2427 tet_infoline("UtcDaliLayouting_LayoutGroup02 - Test control is the size of it's largest child");
2429 Control rootControl;
2430 SetupRootLayoutControl( rootControl );
2432 // Create a parent layout
2433 auto hbox = Control::New();
2434 auto hboxLayout = LinearLayout::New();
2435 hbox.SetName( "HBox");
2436 rootControl.Add( hbox );
2437 DevelControl::SetLayout( hbox, hboxLayout );
2438 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2439 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2440 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2442 tet_infoline("Add a control without SetLayout being called");
2444 auto control = Control::New();
2445 control.SetName("Control1");
2446 hbox.Add( control );
2447 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2448 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2450 tet_infoline("Add a Textlabel to the control");
2451 auto textLabel = TextLabel::New("Test text");
2452 textLabel.SetName("TextLabel");
2453 control.Add( textLabel );
2455 tet_infoline("Add another Textlabel to the control");
2456 auto largeTextLabel = TextLabel::New("Test large text");
2457 largeTextLabel.SetName("TextLabel-Large");
2458 control.Add( largeTextLabel );
2460 // Ensure layouting happens
2461 application.SendNotification();
2462 application.Render();
2464 tet_infoline("Test text is it's natural size");
2465 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2466 tet_infoline("Test text is centered in the control, the control is the size of the largest child");
2467 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2469 tet_infoline("Test large text is it's natural size");
2470 DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2471 tet_infoline("Test text is aligned to start as is the size of the control");
2472 DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2474 tet_infoline("Test control is width of it's parent and height of it's largest child");
2475 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2480 int UtcDaliLayouting_LayoutGroup03(void)
2482 ToolkitTestApplication application;
2483 tet_infoline("UtcDaliLayouting_LayoutGroup03 - Test control witha LayoutGroup as a leaf");
2485 Control rootControl;
2486 SetupRootLayoutControl( rootControl );
2488 // Create a parent layout
2489 auto hbox = Control::New();
2490 auto hboxLayout = LinearLayout::New();
2491 hbox.SetName( "HBox");
2492 rootControl.Add( hbox );
2493 DevelControl::SetLayout( hbox, hboxLayout );
2494 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2495 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2496 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2498 tet_infoline("Add a control without SetLayout being called");
2500 auto control = Control::New();
2501 control.SetName("Control1");
2502 hbox.Add( control );
2503 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2504 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
2506 // Ensure layouting happens
2507 application.SendNotification();
2508 application.Render();
2510 tet_infoline("Test control is width of it's parent and exact given height");
2511 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2512 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2517 int UtcDaliLayouting_LayoutGroupWithPadding01(void)
2519 ToolkitTestApplication application;
2520 tet_infoline("UtcDaliLayouting_LayoutGroupWithPadding01 - Test adding a control to a layout that has padding");
2522 Control rootControl;
2523 SetupRootLayoutControl( rootControl );
2525 // Create a parent layout
2526 auto hbox = Control::New();
2527 auto hboxLayout = LinearLayout::New();
2528 hbox.SetName( "HBox");
2529 rootControl.Add( hbox );
2530 DevelControl::SetLayout( hbox, hboxLayout );
2531 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2532 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2533 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2535 tet_infoline("Add a control without SetLayout being called");
2537 auto control = Control::New();
2538 control.SetName("Control1");
2539 hbox.Add( control );
2540 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2541 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2543 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
2544 tet_printf( "Adding Padding to control");
2545 control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
2547 tet_infoline("Add a Textlabel to the control");
2548 auto textLabel = TextLabel::New("Test text");
2549 textLabel.SetName("TextLabel");
2550 control.Add( textLabel );
2552 // Ensure layouting happens
2553 application.SendNotification();
2554 application.Render();
2556 tet_infoline("Test text is it's natural size");
2557 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2558 tet_infoline("Test control is size of it's child and control it's own padding");
2559 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 245.0f, 86.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2564 int UtcDaliLayouting_LayoutGroupWithChildMargin01(void)
2566 ToolkitTestApplication application;
2567 tet_infoline("UtcDaliLayouting_LayoutGroupWithChildMargin01 - Test adding a control with padding to a layout that has padding");
2569 Control rootControl;
2570 SetupRootLayoutControl( rootControl );
2572 // Create a parent layout
2573 auto hbox = Control::New();
2574 auto hboxLayout = LinearLayout::New();
2575 hbox.SetName( "HBox");
2576 rootControl.Add( hbox );
2577 DevelControl::SetLayout( hbox, hboxLayout );
2578 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2579 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2580 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2582 tet_infoline("Add a control without SetLayout being called");
2584 auto control = Control::New();
2585 control.SetName("Control1");
2586 hbox.Add( control );
2587 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2588 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2590 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
2591 tet_printf( "Adding Padding to control");
2592 control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
2594 tet_infoline("Add a Textlabel to the control");
2595 auto textLabel = TextLabel::New("Test text");
2596 const Extents CHILD_MARGIN = Extents( 10, 0, 5, 0 );
2597 textLabel.SetProperty( Toolkit::Control::Property::MARGIN, CHILD_MARGIN );
2598 textLabel.SetName("TextLabel");
2599 control.Add( textLabel );
2601 // Ensure layouting happens
2602 application.SendNotification();
2603 application.Render();
2605 tet_infoline("Test text is it's natural size");
2606 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2607 tet_infoline("Test control is width of it's parent and height of it's child");
2608 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 255.0f, 91.0f, 0.0f ), 0.0001f, TEST_LOCATION );