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 )
95 hbox.SetParentOrigin( ParentOrigin::CENTER );
96 hbox.SetAnchorPoint( AnchorPoint::CENTER );
99 // Ensure layouting happens
100 application.SendNotification();
101 application.Render();
103 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
104 // hbox left justifies elements
105 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
106 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
107 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
108 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
110 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
111 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
112 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
113 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
116 auto newHBoxLayout = LinearLayout::New();
117 newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
118 DevelControl::SetLayout( hbox, newHBoxLayout );
120 application.SendNotification();
121 application.Render();
123 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
124 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
125 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
126 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
131 int UtcDaliLayouting_HboxLayout02(void)
133 ToolkitTestApplication application;
134 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
136 Stage stage = Stage::GetCurrent();
138 auto hbox1 = Control::New();
139 auto hboxLayout1 = LinearLayout::New();
140 DevelControl::SetLayout( hbox1, hboxLayout1 );
142 auto hbox2 = Control::New();
143 auto hboxLayout2 = LinearLayout::New();
144 DevelControl::SetLayout( hbox2, hboxLayout2 );
146 hbox1.SetName( "HBox1");
147 hbox2.SetName( "HBox2");
149 std::vector< Control > controls;
150 controls.push_back( CreateLeafControl( 20, 40 ) );
151 controls.push_back( CreateLeafControl( 30, 50 ) );
152 controls.push_back( CreateLeafControl( 40, 60 ) );
153 controls.push_back( CreateLeafControl( 50, 70 ) );
155 controls.push_back( CreateLeafControl( 25, 40 ) );
156 controls.push_back( CreateLeafControl( 35, 50 ) );
157 controls.push_back( CreateLeafControl( 45, 60 ) );
158 controls.push_back( CreateLeafControl( 55, 70 ) );
161 for( auto&& iter : controls )
173 hbox1.SetParentOrigin( ParentOrigin::CENTER );
174 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
175 hbox2.SetParentOrigin( ParentOrigin::CENTER );
176 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
178 auto hbox3 = Control::New();
179 auto hboxLayout3 = LinearLayout::New();
180 DevelControl::SetLayout( hbox3, hboxLayout3 );
182 hbox3.SetParentOrigin( ParentOrigin::CENTER );
183 hbox3.SetName( "HBox3");
189 // Ensure layouting happens
190 application.SendNotification();
191 application.Render();
194 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
195 // hbox left justifies elements
196 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
197 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
198 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
199 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
201 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
202 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
203 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
204 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
207 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
208 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
209 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
210 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
212 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
213 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
214 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
215 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
217 // Test hbox1 and 2 are sized to wrap their content
218 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
219 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
220 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
221 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
223 // Test hbox3 matches parent (root layer)
224 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
225 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
231 int UtcDaliLayouting_HboxLayout03(void)
233 ToolkitTestApplication application;
234 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
236 Stage stage = Stage::GetCurrent();
238 auto hbox1 = Control::New();
239 auto hboxLayout1 = LinearLayout::New();
240 DevelControl::SetLayout( hbox1, hboxLayout1 );
242 auto hbox2 = Control::New();
243 auto hboxLayout2 = LinearLayout::New();
244 DevelControl::SetLayout( hbox2, hboxLayout2 );
246 hbox1.SetName( "HBox1");
247 hbox2.SetName( "HBox2");
248 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
249 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
250 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
251 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
253 std::vector< Control > controls;
254 controls.push_back( CreateLeafControl( 20, 40 ) );
255 controls.push_back( CreateLeafControl( 30, 50 ) );
256 controls.push_back( CreateLeafControl( 40, 60 ) );
257 controls.push_back( CreateLeafControl( 50, 70 ) );
259 controls.push_back( CreateLeafControl( 25, 40 ) );
260 controls.push_back( CreateLeafControl( 35, 50 ) );
261 controls.push_back( CreateLeafControl( 45, 60 ) );
262 controls.push_back( CreateLeafControl( 55, 70 ) );
265 for( auto&& iter : controls )
277 hbox1.SetParentOrigin( ParentOrigin::CENTER );
278 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
279 hbox2.SetParentOrigin( ParentOrigin::CENTER );
280 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
282 auto hbox3 = Control::New();
283 auto hboxLayout3 = LinearLayout::New();
284 DevelControl::SetLayout( hbox3, hboxLayout3);
286 hbox3.SetParentOrigin( ParentOrigin::CENTER );
287 hbox3.SetName( "HBox3");
293 //std::ostringstream oss;
294 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
295 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
297 // Ensure layouting happens
298 application.SendNotification();
299 application.Render();
302 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
303 // hbox left justifies elements
304 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
305 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
306 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
307 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
309 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
310 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
311 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
312 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
314 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
315 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
316 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
317 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
319 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
320 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
321 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
322 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
324 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
325 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
326 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
327 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
329 // Test hbox3 matches parent (root layer)
330 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
331 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
336 int UtcDaliLayouting_HboxLayout04(void)
338 ToolkitTestApplication application;
339 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
341 Stage stage = Stage::GetCurrent();
343 auto hbox1 = Control::New();
344 auto hboxLayout1 = LinearLayout::New();
345 DevelControl::SetLayout( hbox1, hboxLayout1 );
347 auto hbox2 = Control::New();
348 auto hboxLayout2 = LinearLayout::New();
349 DevelControl::SetLayout( hbox2, hboxLayout2 );
351 hbox1.SetName( "HBox1"); // Default spec is to wrap content
352 hbox2.SetName( "HBox2");
353 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
354 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
355 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
356 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
358 std::vector< Control > controls;
359 controls.push_back( CreateLeafControl( 80, 40 ) );
360 controls.push_back( CreateLeafControl( 80, 50 ) );
361 controls.push_back( CreateLeafControl( 80, 60 ) );
362 controls.push_back( CreateLeafControl( 80, 70 ) );
364 controls.push_back( CreateLeafControl( 80, 40 ) );
365 controls.push_back( CreateLeafControl( 80, 50 ) );
366 controls.push_back( CreateLeafControl( 80, 60 ) );
367 controls.push_back( CreateLeafControl( 80, 70 ) );
370 for( auto&& iter : controls )
383 controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
384 auto hbox3 = Control::New();
385 auto hboxLayout3 = LinearLayout::New();
386 DevelControl::SetLayout( hbox3, hboxLayout3 );
388 hbox3.SetParentOrigin( ParentOrigin::CENTER );
389 hbox3.SetName( "HBox3");
394 //std::ostringstream oss;
395 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
396 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
398 // Ensure layouting happens
399 application.SendNotification();
400 application.Render();
403 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
404 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
405 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
406 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
408 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
409 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
410 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
411 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
413 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
414 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
415 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
416 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
418 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
419 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
420 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
421 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
423 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
424 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
425 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
426 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
429 // Test hbox3 matches parent (root layer)
430 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
431 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
436 int UtcDaliLayouting_HboxLayout05(void)
438 ToolkitTestApplication application;
439 tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
441 Stage stage = Stage::GetCurrent();
442 auto hbox = Control::New();
443 auto hboxLayout = LinearLayout::New();
444 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
445 DevelControl::SetLayout( hbox, hboxLayout );
446 hbox.SetName( "HBox");
448 std::vector< Control > controls;
449 controls.push_back( CreateLeafControl( 40, 40 ) );
450 controls.push_back( CreateLeafControl( 60, 40 ) );
451 controls.push_back( CreateLeafControl( 80, 40 ) );
452 controls.push_back( CreateLeafControl( 100, 40 ) );
454 for( auto&& iter : controls )
457 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
458 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
461 hbox.SetParentOrigin( ParentOrigin::CENTER );
462 hbox.SetAnchorPoint( AnchorPoint::CENTER );
465 // Ensure layouting happens
466 application.SendNotification();
467 application.Render();
469 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
470 // hbox left justifies elements
471 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
472 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
473 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
474 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
476 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
477 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
478 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
479 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
484 int UtcDaliLayouting_HboxLayout06(void)
486 ToolkitTestApplication application;
487 tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
489 Stage stage = Stage::GetCurrent();
491 auto rootControl = Control::New();
492 auto absoluteLayout = AbsoluteLayout::New();
493 DevelControl::SetLayout( rootControl, absoluteLayout );
494 rootControl.SetName( "AbsoluteLayout" );
495 stage.Add( rootControl );
497 auto hbox = Control::New();
498 auto hboxLayout = LinearLayout::New();
499 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
500 DevelControl::SetLayout( hbox, hboxLayout );
501 hbox.SetName( "HBox" );
503 std::vector< Control > controls;
504 controls.push_back( CreateLeafControl( 40, 40 ) );
505 controls.push_back( CreateLeafControl( 60, 40 ) );
507 for( auto&& iter : controls )
511 hbox.SetParentOrigin( ParentOrigin::CENTER );
512 hbox.SetAnchorPoint( AnchorPoint::CENTER );
513 rootControl.Add( hbox );
515 // Ensure layouting happens
516 application.SendNotification();
517 application.Render();
519 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
520 // hbox left justifies elements
521 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
522 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
524 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
525 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
527 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
530 auto newHBoxLayout = LinearLayout::New();
531 newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
532 DevelControl::SetLayout( hbox, newHBoxLayout );
534 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
535 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
537 application.SendNotification();
538 application.Render();
540 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
542 // Change size specification
543 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
544 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
546 application.SendNotification();
547 application.Render();
549 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
551 // Use WRAP_CONTENT again
552 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
553 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
555 application.SendNotification();
556 application.Render();
558 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
563 int UtcDaliLayouting_HboxLayout07(void)
565 ToolkitTestApplication application;
566 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
568 Stage stage = Stage::GetCurrent();
569 auto hbox = Control::New();
570 auto hboxLayout = LinearLayout::New();
571 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
572 DevelControl::SetLayout( hbox, hboxLayout );
573 hbox.SetName( "HBox");
575 std::vector< Control > controls;
576 controls.push_back( CreateLeafControl( 40, 40 ) );
577 controls.push_back( CreateLeafControl( 60, 40 ) );
578 controls.push_back( CreateLeafControl( 80, 40 ) );
579 controls.push_back( CreateLeafControl( 100, 40 ) );
581 for( auto&& iter : controls )
585 hbox.SetParentOrigin( ParentOrigin::CENTER );
586 hbox.SetAnchorPoint( AnchorPoint::CENTER );
589 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
591 // Ensure layouting happens
592 application.SendNotification();
593 application.Render();
595 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
596 // hbox left justifies elements
597 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
598 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
599 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
600 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
602 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
603 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
604 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
605 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
607 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
609 // Ensure layouting happens
610 application.SendNotification();
611 application.Render();
613 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
614 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
615 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
616 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
618 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
619 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
620 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
621 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
626 int UtcDaliLayouting_HboxLayout08(void)
628 ToolkitTestApplication application;
629 tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation");
631 Stage stage = Stage::GetCurrent();
633 auto rootControl = Control::New();
634 auto absoluteLayout = AbsoluteLayout::New();
635 absoluteLayout.SetAnimateLayout( true );
636 DevelControl::SetLayout( rootControl, absoluteLayout );
637 rootControl.SetName( "AbsoluteLayout" );
638 stage.Add( rootControl );
640 Control control1 = CreateLeafControl( 40, 40 );
641 rootControl.Add( control1 );
643 auto hbox = Control::New();
644 auto hboxLayout = LinearLayout::New();
645 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
646 DevelControl::SetLayout( hbox, hboxLayout );
647 hbox.SetName( "HBox" );
649 Control control2 = CreateLeafControl( 40, 40 );
650 hbox.Add( control2 );
652 hbox.SetParentOrigin( ParentOrigin::CENTER );
653 hbox.SetAnchorPoint( AnchorPoint::CENTER );
654 rootControl.Add( hbox );
656 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION );
657 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION );
658 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION );
659 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION );
661 tet_infoline(" Set hBoxLayout to animate");
662 hboxLayout.SetAnimateLayout( true );
663 tet_infoline(" Set absoluteLayout not to animate");
664 absoluteLayout.SetAnimateLayout( false );
666 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION );
667 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION );
668 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION );
669 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION );
676 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/broken.png";
679 int UtcDaliLayouting_HboxLayout_ImageView(void)
681 ToolkitTestApplication application;
682 tet_infoline(" UtcDaliLayouting_HboxLayout - Use image view for leaf");
684 Stage stage = Stage::GetCurrent();
685 auto hbox = Control::New();
686 auto hboxLayout = LinearLayout::New();
687 DevelControl::SetLayout( hbox, hboxLayout );
688 hbox.SetName( "HBox" );
690 std::string url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 100, 100 ) );
691 ImageView imageView = CreateImageView( url, ImageDimensions() );
693 hbox.SetParentOrigin( ParentOrigin::CENTER );
694 hbox.SetAnchorPoint( AnchorPoint::CENTER );
695 hbox.Add( imageView );
698 // Ensure layouting happens
699 application.SendNotification();
700 application.Render();
702 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
703 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
705 url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 200, 200 ) );
706 imageView.SetImage( url );
708 // Ensure layouting happenss
709 application.SendNotification();
710 application.Render();
712 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
713 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
715 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
716 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
718 // Ensure layouting happenss
719 application.SendNotification();
720 application.Render();
722 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
723 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
725 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
726 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
728 // Ensure layouting happenss
729 application.SendNotification();
730 application.Render();
732 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
733 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
735 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
736 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
738 Image image = FrameBufferImage::New( 50, 50, Pixel::RGBA8888 );
739 imageView.SetImage( image );
741 // Ensure layouting happenss
742 application.SendNotification();
743 application.Render();
745 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
746 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
748 Property::Map imagePropertyMap;
749 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
750 imagePropertyMap[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
751 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 150;
752 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 150;
753 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap );
755 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
756 // Ensure layouting happenss
757 application.SendNotification();
758 application.Render();
760 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 325.0f, 0.0f ), 0.0001f, TEST_LOCATION );
761 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
766 int UtcDaliLayouting_HboxLayout_TextLabel(void)
768 ToolkitTestApplication application;
769 tet_infoline(" UtcDaliLayouting_HboxLayout - Use text label for leaf");
771 Stage stage = Stage::GetCurrent();
773 auto hbox = Control::New();
774 auto hboxLayout = LinearLayout::New();
775 DevelControl::SetLayout( hbox, hboxLayout );
776 hbox.SetName( "HBox" );
777 hbox.SetParentOrigin( ParentOrigin::CENTER );
778 hbox.SetAnchorPoint( AnchorPoint::CENTER );
780 std::vector< Control > controls;
781 TextLabel textLabel = CreateTextLabel( "W" );
782 controls.push_back( textLabel );
783 hbox.Add( textLabel );
786 // Ensure layouting happens
787 application.SendNotification();
788 application.Render();
790 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
791 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 54.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
793 textLabel.SetProperty( TextLabel::Property::TEXT, "WWWW" );
795 // Ensure layouting happens
796 application.SendNotification();
797 application.Render();
799 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
800 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 216.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
802 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
804 // Ensure layouting happens
805 application.SendNotification();
806 application.Render();
808 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
809 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
811 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
812 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
814 // Ensure layouting happens
815 application.SendNotification();
816 application.Render();
818 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
819 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
821 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
822 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
824 // Ensure layouting happens
825 application.SendNotification();
826 application.Render();
828 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
829 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
836 int UtcDaliLayouting_HboxLayout_Padding01(void)
838 ToolkitTestApplication application;
839 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
841 Stage stage = Stage::GetCurrent();
842 auto hbox = Control::New();
843 auto hboxLayout = LinearLayout::New();
844 DevelControl::SetLayout( hbox, hboxLayout );
845 hbox.SetName( "HBox");
847 std::vector< Control > controls;
848 controls.push_back( CreateLeafControl( 40, 40 ) );
849 controls.push_back( CreateLeafControl( 60, 40 ) );
850 controls.push_back( CreateLeafControl( 80, 40 ) );
851 controls.push_back( CreateLeafControl( 100, 40 ) );
853 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
854 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
855 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
857 for( auto&& iter : controls )
861 hbox.SetParentOrigin( ParentOrigin::CENTER );
862 hbox.SetAnchorPoint( AnchorPoint::CENTER );
865 // Ensure layouting happens
866 application.SendNotification();
867 application.Render();
869 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
870 // hbox left justifies elements
871 tet_infoline("Test Child Actor Position");
872 float xPositionOfControlBeingTested = 0.0f;
873 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
875 0.0f ), 0.0001f, TEST_LOCATION );
876 xPositionOfControlBeingTested += 40.0f;
878 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
879 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
880 0.0001f, TEST_LOCATION );
882 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
883 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
885 xPositionOfControlBeingTested += 80.0f;
886 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
888 tet_infoline("Test Child Actor Size");
889 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
891 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
892 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
893 0.0001f, TEST_LOCATION );
895 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
896 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
901 int UtcDaliLayouting_HboxLayout_Padding02(void)
903 ToolkitTestApplication application;
904 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
906 Stage stage = Stage::GetCurrent();
907 auto hbox = Control::New();
908 auto hboxLayout = LinearLayout::New();
909 DevelControl::SetLayout( hbox, hboxLayout );
910 hbox.SetName( "HBox");
912 std::vector< Control > controls;
913 controls.push_back( CreateLeafControl( 40, 40 ) );
914 controls.push_back( CreateLeafControl( 60, 40 ) );
915 controls.push_back( CreateLeafControl( 80, 40 ) );
916 controls.push_back( CreateLeafControl( 100, 40 ) );
918 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
920 for( auto&& iter : controls )
922 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
925 hbox.SetParentOrigin( ParentOrigin::CENTER );
926 hbox.SetAnchorPoint( AnchorPoint::CENTER );
929 // Ensure layouting happens
930 application.SendNotification();
931 application.Render();
933 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
934 // hbox left justifies elements
935 tet_infoline("Test Child Actor Position");
936 float xPositionOfControlBeingTested = 0.0f;
937 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
939 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
940 yPositionOfControlBeingTested,
941 0.0f ), 0.0001f, TEST_LOCATION );
942 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
944 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
945 yPositionOfControlBeingTested,
947 0.0001f, TEST_LOCATION );
949 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
950 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
951 yPositionOfControlBeingTested,
952 0.0f ), 0.0001f, TEST_LOCATION );
954 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
955 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
956 yPositionOfControlBeingTested,
957 0.0f ), 0.0001f, TEST_LOCATION );
959 tet_infoline("Test Child Actor Size");
960 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
961 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
962 0.0f ), 0.0001f, TEST_LOCATION );
964 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
965 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
966 0.0f ), 0.0001f, TEST_LOCATION );
968 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
969 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
970 0.0f ), 0.0001f, TEST_LOCATION );
972 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
973 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
974 0.0f ), 0.0001f, TEST_LOCATION );
980 int UtcDaliLayouting_HboxLayout_Padding03(void)
982 ToolkitTestApplication application;
983 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
985 Stage stage = Stage::GetCurrent();
986 auto hbox = Control::New();
987 auto hboxLayout = LinearLayout::New();
988 DevelControl::SetLayout( hbox, hboxLayout );
989 hbox.SetName( "HBox");
991 std::vector< Control > controls;
992 controls.push_back( CreateLeafControl( 40, 40 ) );
993 controls.push_back( CreateLeafControl( 40, 40 ) );
994 controls.push_back( CreateLeafControl( 40, 40 ) );
996 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
997 tet_printf( "\nAdding Padding to control at index 1 \n" );
998 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1000 for( auto&& iter : controls )
1004 hbox.SetParentOrigin( ParentOrigin::CENTER );
1005 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1008 // Ensure layouting happens
1009 application.SendNotification();
1010 application.Render();
1012 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1013 // hbox left justifies elements
1014 tet_infoline("Test Child Actor Position");
1015 float xPositionOfControlBeingTested = 0.0f;
1016 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1018 0.0f ), 0.0001f, TEST_LOCATION );
1019 xPositionOfControlBeingTested += 40.0f;
1021 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1022 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1023 0.0001f, TEST_LOCATION );
1025 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1026 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1028 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
1029 tet_printf( "\nChanging Padding to control at index 1 \n" );
1030 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
1032 // Ensure layouting happens
1033 application.SendNotification();
1034 application.Render();
1036 xPositionOfControlBeingTested = 0.0f; // reset
1038 tet_infoline("Test Child Actor Position");
1039 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1041 0.0f ), 0.0001f, TEST_LOCATION );
1042 xPositionOfControlBeingTested += 40.0f;
1044 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1045 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1046 0.0001f, TEST_LOCATION );
1048 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
1049 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
1050 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1052 tet_infoline("Test Child Actor Size");
1053 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1055 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
1056 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
1057 0.0001f, TEST_LOCATION );
1059 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1064 int UtcDaliLayouting_HboxLayout_Padding04(void)
1066 ToolkitTestApplication application;
1067 tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
1069 // Adding padding to the layout should offset the positioning of the children.
1071 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1072 const Size CONTROL_SIZE = Size( 40, 40 );
1074 Stage stage = Stage::GetCurrent();
1075 // Create a root layout, ideally Dali would have a default layout in the root layer.
1076 // Without this root layer the LinearLayout (or any other layout) will not
1077 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1078 // It uses the default stage size and ideally should have a layout added to it.
1079 auto rootLayoutControl = Control::New();
1080 rootLayoutControl.SetName( "AbsoluteLayout");
1081 auto rootLayout = AbsoluteLayout::New();
1082 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1083 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1084 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1085 stage.Add( rootLayoutControl );
1087 auto hbox = Control::New();
1088 auto hboxLayout = LinearLayout::New();
1089 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1090 DevelControl::SetLayout( hbox, hboxLayout );
1091 hbox.SetName( "HBox");
1092 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1093 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1094 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1096 std::vector< Control > controls;
1097 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1098 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1099 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1100 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1102 for( auto&& iter : controls )
1107 hbox.SetParentOrigin( ParentOrigin::CENTER );
1108 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1109 rootLayoutControl.Add( hbox );
1111 // Ensure layouting happens
1112 application.SendNotification();
1113 application.Render();
1115 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1116 application.SendNotification();
1118 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1119 // hbox left justifies elements
1120 tet_infoline("Test Child Actor Position");
1122 auto controlXPosition=0.0f;
1124 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1125 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1127 0.0f ), 0.0001f, TEST_LOCATION );
1129 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1130 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1133 0.0001f, TEST_LOCATION );
1135 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1136 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1138 0.0f ), 0.0001f, TEST_LOCATION );
1140 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1141 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1143 0.0f ), 0.0001f, TEST_LOCATION );
1145 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1146 auto totalControlsHeight = CONTROL_SIZE.height;
1148 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1149 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1150 0.0f ), 0.0001f, TEST_LOCATION );
1156 int UtcDaliLayouting_HboxLayout_Padding05(void)
1158 ToolkitTestApplication application;
1159 tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
1161 // Adding padding to the layout should offset the positioning of the children.
1163 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1164 const Size CONTROL_SIZE = Size( 40, 40 );
1166 Stage stage = Stage::GetCurrent();
1167 // Create a root layout, ideally Dali would have a default layout in the root layer.
1168 // Without this root layer the LinearLayout (or any other layout) will not
1169 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1170 // It uses the default stage size and ideally should have a layout added to it.
1171 auto rootLayoutControl = Control::New();
1172 rootLayoutControl.SetName( "AbsoluteLayout");
1173 auto rootLayout = AbsoluteLayout::New();
1174 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1175 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1176 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1177 stage.Add( rootLayoutControl );
1179 auto hbox = Control::New();
1180 auto hboxLayout = LinearLayout::New();
1181 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1182 DevelControl::SetLayout( hbox, hboxLayout );
1183 hbox.SetName( "HBox");
1184 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1185 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1186 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1188 std::vector< Control > controls;
1189 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1190 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1191 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1192 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1194 for( auto&& iter : controls )
1199 hbox.SetParentOrigin( ParentOrigin::CENTER );
1200 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1201 rootLayoutControl.Add( hbox );
1203 // Ensure layouting happens
1204 application.SendNotification();
1205 application.Render();
1207 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1208 application.SendNotification();
1210 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1211 // hbox left justifies elements
1212 tet_infoline("Test Child Actor Position");
1214 auto controlXPosition=0.0f;
1216 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1217 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1219 0.0f ), 0.0001f, TEST_LOCATION );
1221 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1222 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1225 0.0001f, TEST_LOCATION );
1227 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1228 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1230 0.0f ), 0.0001f, TEST_LOCATION );
1232 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1233 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1235 0.0f ), 0.0001f, TEST_LOCATION );
1237 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1238 auto totalControlsHeight = CONTROL_SIZE.height;
1240 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1241 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1242 0.0f ), 0.0001f, TEST_LOCATION );
1244 // Change layout padding
1245 const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
1246 tet_printf( "\nChanging Padding to control at index 1 \n" );
1247 hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
1249 // Ensure layouting happens
1250 application.SendNotification();
1251 application.Render();
1253 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1254 application.SendNotification();
1256 controlXPosition = NEW_LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1257 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
1258 NEW_LAYOUT_PADDING.top,
1259 0.0f ), 0.0001f, TEST_LOCATION );
1261 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1262 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1263 NEW_LAYOUT_PADDING.top,
1265 0.0001f, TEST_LOCATION );
1267 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1268 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1269 NEW_LAYOUT_PADDING.top,
1270 0.0f ), 0.0001f, TEST_LOCATION );
1272 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1273 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1274 NEW_LAYOUT_PADDING.top,
1275 0.0f ), 0.0001f, TEST_LOCATION );
1276 totalControlsWidth = CONTROL_SIZE.width * controls.size();
1277 totalControlsHeight = CONTROL_SIZE.height;
1279 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
1280 totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
1281 0.0f ), 0.0001f, TEST_LOCATION );
1287 int UtcDaliLayouting_HboxLayout_Margin01(void)
1289 ToolkitTestApplication application;
1290 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
1292 Stage stage = Stage::GetCurrent();
1293 auto hbox = Control::New();
1294 auto hboxLayout = LinearLayout::New();
1295 DevelControl::SetLayout( hbox, hboxLayout );
1296 hbox.SetName( "HBox");
1298 std::vector< Control > controls;
1299 controls.push_back( CreateLeafControl( 40, 40 ) );
1300 controls.push_back( CreateLeafControl( 60, 40 ) );
1301 controls.push_back( CreateLeafControl( 80, 40 ) );
1302 controls.push_back( CreateLeafControl( 100, 40 ) );
1304 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
1305 tet_printf( "\nAdding Margin to control at index 1 \n" );
1306 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1308 for( auto&& iter : controls )
1312 hbox.SetParentOrigin( ParentOrigin::CENTER );
1313 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1316 // Ensure layouting happens
1317 application.SendNotification();
1318 application.Render();
1320 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1321 // hbox left justifies elements
1322 tet_infoline("Test Child Actor Position");
1323 auto xPositionOfControlBeingTested = 0.0f;
1324 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1326 0.0f ), 0.0001f, TEST_LOCATION );
1327 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
1329 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1330 380.0f + CONTROL_MARGIN.top, 0.0f ),
1331 0.0001f, TEST_LOCATION );
1333 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
1334 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1336 xPositionOfControlBeingTested += 80.0f;
1337 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1339 tet_infoline("Test Child Actor Size is the same after Margin added");
1340 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1341 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
1342 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1343 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1349 int UtcDaliLayouting_VboxLayout01(void)
1351 ToolkitTestApplication application;
1352 tet_infoline(" UtcDaliLayouting_VboxLayout01");
1354 Stage stage = Stage::GetCurrent();
1355 auto vbox = Control::New();
1356 auto vboxLayout = LinearLayout::New();
1357 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1358 DevelControl::SetLayout( vbox, vboxLayout );
1359 vbox.SetName( "Vbox");
1361 std::vector< Control > controls;
1362 controls.push_back( CreateLeafControl( 40, 40 ) );
1363 controls.push_back( CreateLeafControl( 60, 60 ) );
1364 controls.push_back( CreateLeafControl( 80, 80 ) );
1365 controls.push_back( CreateLeafControl( 100, 100 ) );
1367 for( auto&& iter : controls )
1371 vbox.SetParentOrigin( ParentOrigin::CENTER );
1372 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1375 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1378 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1380 // Ensure layouting happens
1381 application.SendNotification();
1382 application.Render();
1384 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
1385 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1386 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1387 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1388 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1390 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1391 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1392 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1393 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1398 int UtcDaliLayouting_VboxLayout02(void)
1400 ToolkitTestApplication application;
1401 tet_infoline(" UtcDaliLayouting_VboxLayout01");
1403 Stage stage = Stage::GetCurrent();
1405 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1406 // LayoutGroup for this to happen automatically.
1408 // For this test, add an hbox instead
1409 auto rootControl = Control::New();
1410 auto absoluteLayout = AbsoluteLayout::New();
1411 DevelControl::SetLayout( rootControl, absoluteLayout );
1412 rootControl.SetName( "AbsoluteLayout");
1413 stage.Add( rootControl );
1415 auto vbox = Control::New();
1416 auto vboxLayout = LinearLayout::New();
1417 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1418 DevelControl::SetLayout( vbox, vboxLayout );
1419 vbox.SetName( "Vbox");
1420 rootControl.Add( vbox );
1422 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1423 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1425 std::vector< Control > controls;
1426 controls.push_back( CreateLeafControl( 40, 40 ) );
1427 controls.push_back( CreateLeafControl( 60, 60 ) );
1428 controls.push_back( CreateLeafControl( 80, 80 ) );
1429 controls.push_back( CreateLeafControl( 100, 100 ) );
1431 for( auto&& iter : controls )
1435 vbox.SetParentOrigin( ParentOrigin::CENTER );
1436 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1438 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1441 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1443 // Ensure layouting happens
1444 application.SendNotification();
1445 application.Render();
1447 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1448 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1450 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1451 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1452 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1454 // 3rd control is set to match parent - this should also be 100 wide
1455 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1456 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1457 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1458 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1460 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1461 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1462 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1463 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1469 int UtcDaliLayouting_VboxLayout03(void)
1471 ToolkitTestApplication application;
1472 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
1474 Stage stage = Stage::GetCurrent();
1476 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1477 // LayoutGroup for this to happen automatically.
1479 // For this test, add an hbox instead
1480 auto hbox = Control::New();
1481 auto hboxLayout = LinearLayout::New();
1482 DevelControl::SetLayout( hbox, hboxLayout );
1483 hbox.SetName( "Hbox");
1486 auto vbox = Control::New();
1487 auto vboxLayout = LinearLayout::New();
1488 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
1489 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1491 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
1493 DevelControl::SetLayout( vbox, vboxLayout );
1494 vbox.SetName( "Vbox");
1497 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1498 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1500 std::vector< Control > controls;
1501 controls.push_back( CreateLeafControl( 40, 40 ) );
1502 controls.push_back( CreateLeafControl( 60, 60 ) );
1503 controls.push_back( CreateLeafControl( 80, 80 ) );
1504 controls.push_back( CreateLeafControl( 100, 100 ) );
1506 for( auto&& iter : controls )
1510 vbox.SetParentOrigin( ParentOrigin::CENTER );
1511 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1513 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1516 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1518 // Ensure layouting happens
1519 application.SendNotification();
1520 application.Render();
1522 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1523 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1525 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1526 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1527 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1529 // 3rd control is set to match parent - this should also be 100 wide
1530 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1531 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1532 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1533 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1535 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1536 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1537 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1538 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1543 int UtcDaliLayouting_VboxLayout_Padding(void)
1545 ToolkitTestApplication application;
1546 tet_infoline("UtcDaliLayouting_VboxLayout_Padding - Adding Padding to the vbox");
1548 // Adding padding to the layout should offset the positioning of the children.
1550 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1551 const Size CONTROL_SIZE = Size( 40, 40 );
1553 Stage stage = Stage::GetCurrent();
1554 // Create a root layout, ideally Dali would have a default layout in the root layer.
1555 // Without this root layer the LinearLayout (or any other layout) will not
1556 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1557 // It uses the default stage size and ideally should have a layout added to it.
1558 auto rootLayoutControl = Control::New();
1559 rootLayoutControl.SetName( "AbsoluteLayout");
1560 auto rootLayout = AbsoluteLayout::New();
1561 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1562 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1563 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1564 stage.Add( rootLayoutControl );
1566 auto vbox = Control::New();
1567 auto vboxLayout = LinearLayout::New();
1568 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1569 DevelControl::SetLayout( vbox, vboxLayout );
1570 vbox.SetName( "VBox");
1571 vbox.SetProperty( Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1572 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1573 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1575 std::vector< Control > controls;
1576 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1577 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1578 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1579 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1581 for( auto&& iter : controls )
1586 vbox.SetParentOrigin( ParentOrigin::CENTER );
1587 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1588 rootLayoutControl.Add( vbox );
1590 // Ensure layouting happens
1591 application.SendNotification();
1592 application.Render();
1594 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1595 application.SendNotification();
1597 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
1598 tet_infoline("Test Child Actor Position");
1600 auto controlYPosition = 0.0f;
1602 controlYPosition = LAYOUT_PADDING.top; // First child positioned at offset defined by the padding
1603 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1605 0.0f ), 0.0001f, TEST_LOCATION );
1607 controlYPosition += CONTROL_SIZE.height; // Second child positioned is the position of the first child + the first child's height.
1608 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1611 0.0001f, TEST_LOCATION );
1613 controlYPosition += CONTROL_SIZE.height; // Third child positioned adjacent to second
1614 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1616 0.0f ), 0.0001f, TEST_LOCATION );
1618 controlYPosition += CONTROL_SIZE.height; // Forth passed adjacent to the third
1619 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1621 0.0f ), 0.0001f, TEST_LOCATION );
1623 auto totalControlsWidth = CONTROL_SIZE.width;
1624 auto totalControlsHeight = CONTROL_SIZE.height * controls.size();
1626 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1627 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1628 0.0f ), 0.0001f, TEST_LOCATION );
1634 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
1636 ToolkitTestApplication application;
1637 tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
1638 tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
1640 Stage stage = Stage::GetCurrent();
1642 auto hbox = Control::New();
1643 auto hboxLayout = Test::CustomLayout::New();
1644 DevelControl::SetLayout( hbox, hboxLayout );
1645 hbox.SetName( "HBox");
1647 std::vector< Control > controls;
1648 controls.push_back( CreateLeafControl( 40, 40 ) );
1649 controls.push_back( CreateLeafControl( 60, 40 ) );
1650 controls.push_back( CreateLeafControl( 80, 40 ) );
1651 controls.push_back( CreateLeafControl( 100, 40 ) );
1653 for( auto&& iter : controls )
1657 hbox.SetParentOrigin( ParentOrigin::CENTER );
1658 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1661 // Ensure layouting happens
1662 application.SendNotification();
1663 application.Render();
1665 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1666 // hbox left justifies elements
1667 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1668 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1669 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1670 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1672 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1673 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1674 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1675 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1677 controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
1678 controls[2].Lower(); // 2->1; 2, 1, 3, 0
1680 application.SendNotification();
1681 application.Render();
1683 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1684 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1685 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1686 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1688 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1689 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1690 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1691 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1696 int UtcDaliLayouting_HboxLayout_TargetSize(void)
1698 ToolkitTestApplication application;
1699 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
1701 Stage stage = Stage::GetCurrent();
1702 auto hbox = Control::New();
1703 auto hboxLayout = LinearLayout::New();
1704 DevelControl::SetLayout( hbox, hboxLayout );
1705 hbox.SetName( "HBox");
1707 std::vector< Control > controls;
1708 controls.push_back( CreateLeafControl( 40, 40 ) );
1709 for( auto&& iter : controls )
1711 iter.SetSize( 100, 100 );
1714 hbox.SetParentOrigin( ParentOrigin::CENTER );
1715 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1718 // Ensure layouting happens
1719 application.SendNotification();
1720 application.Render();
1722 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
1723 // hbox left justifies elements
1724 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1725 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1730 int UtcDaliLayouting_RemoveLayout01(void)
1732 ToolkitTestApplication application;
1733 tet_infoline(" UtcDaliLayouting_RemoveLayout");
1735 Stage stage = Stage::GetCurrent();
1737 auto rootControl = Control::New();
1738 auto absoluteLayout = AbsoluteLayout::New();
1739 DevelControl::SetLayout( rootControl, absoluteLayout );
1740 rootControl.SetName( "AbsoluteLayout" );
1741 stage.Add( rootControl );
1743 auto hbox = Control::New();
1744 auto hboxLayout = LinearLayout::New();
1745 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1746 DevelControl::SetLayout( hbox, hboxLayout );
1747 hbox.SetName( "HBox" );
1749 std::vector< Control > controls;
1750 controls.push_back( CreateLeafControl( 40, 40 ) );
1751 controls.push_back( CreateLeafControl( 60, 40 ) );
1753 for( auto&& iter : controls )
1757 hbox.SetParentOrigin( ParentOrigin::CENTER );
1758 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1759 rootControl.Add( hbox );
1761 tet_infoline("Layout as normal");
1762 application.SendNotification();
1763 application.Render();
1765 tet_infoline("Set an empty layout on hbox container");
1766 LinearLayout emptyLayout;
1767 DevelControl::SetLayout( hbox, emptyLayout );
1769 tet_infoline("Run another layout");
1770 application.SendNotification();
1771 application.Render();
1773 tet_infoline("Check leaf controls haven't moved");
1775 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1776 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1778 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1779 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1784 int UtcDaliLayouting_LayoutChildren01(void)
1786 ToolkitTestApplication application;
1787 tet_infoline(" UtcDaliLayouting_LayoutChildren01");
1789 Stage stage = Stage::GetCurrent();
1791 auto rootControl = Control::New();
1792 auto absoluteLayout = AbsoluteLayout::New();
1793 DevelControl::SetLayout( rootControl, absoluteLayout );
1794 stage.Add( rootControl );
1796 auto hbox = Control::New();
1797 auto hboxLayout = LinearLayout::New();
1798 DevelControl::SetLayout( hbox, hboxLayout );
1799 rootControl.Add( hbox );
1801 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1803 tet_infoline("Test removal by setting empty layout to child container" );
1804 DevelControl::SetLayout( hbox, LayoutItem{} );
1806 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
1808 auto& hboxImpl = GetImplementation( hboxLayout );
1810 DALI_TEST_EQUALS( hboxLayout.GetOwner(), empty, TEST_LOCATION );
1811 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
1814 hboxImpl.SetLayoutRequested();
1819 int UtcDaliLayouting_LayoutChildren02(void)
1821 ToolkitTestApplication application;
1822 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
1824 Stage stage = Stage::GetCurrent();
1826 auto rootControl = Control::New();
1827 auto absoluteLayout = AbsoluteLayout::New();
1828 DevelControl::SetLayout( rootControl, absoluteLayout );
1829 stage.Add( rootControl );
1831 auto hbox = Control::New();
1832 auto hboxLayout = LinearLayout::New();
1833 DevelControl::SetLayout( hbox, hboxLayout );
1834 rootControl.Add( hbox );
1836 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1838 tet_infoline("Test removal by removing child actor from parent container" );
1841 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
1843 auto& hboxImpl = GetImplementation( hboxLayout );
1844 tet_infoline("Test child actor still has hbox layout " );
1845 DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
1847 tet_infoline("Test hbox layout has no parent " );
1848 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
1853 int UtcDaliLayouting_LayoutChildren03(void)
1855 ToolkitTestApplication application;
1856 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
1858 Stage stage = Stage::GetCurrent();
1860 auto rootControl = Control::New();
1861 auto absoluteLayout = AbsoluteLayout::New();
1862 DevelControl::SetLayout( rootControl, absoluteLayout );
1863 stage.Add( rootControl );
1865 auto hbox = Control::New();
1866 auto hboxLayout = LinearLayout::New();
1867 DevelControl::SetLayout( hbox, hboxLayout );
1868 rootControl.Add( hbox );
1870 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1872 tet_infoline("Test removal by removing child layout from parent layout" );
1873 absoluteLayout.Remove( hboxLayout );
1875 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
1877 auto& hboxImpl = GetImplementation( hboxLayout );
1879 tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
1880 DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
1881 DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
1883 tet_infoline("Check orphaned layout has no parent");
1884 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
1890 int UtcDaliLayouting_LayoutChildren04(void)
1892 ToolkitTestApplication application;
1893 tet_infoline(" UtcDaliLayouting_LayoutChildren03");
1895 Stage stage = Stage::GetCurrent();
1897 auto rootControl = Control::New();
1898 auto absoluteLayout = AbsoluteLayout::New();
1899 DevelControl::SetLayout( rootControl, absoluteLayout );
1900 stage.Add( rootControl );
1902 auto hbox = Control::New();
1903 tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
1904 auto hboxLayout = LinearLayout::New();
1905 rootControl.Add( hbox );
1907 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1909 tet_infoline("Then setting a layout on the child container");
1910 DevelControl::SetLayout( hbox, hboxLayout );
1912 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1914 auto& hboxImpl = GetImplementation( hboxLayout );
1915 auto& absImpl = GetImplementation( absoluteLayout );
1916 DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
1917 DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
1922 int UtcDaliLayouting_SetLayoutOrder01(void)
1924 ToolkitTestApplication application;
1925 tet_infoline(" UtcDaliLayouting_SetLayoutOrder01 - Call SetLayout after adding the control to the root layout");
1927 Stage stage = Stage::GetCurrent();
1929 auto rootControl = Control::New();
1930 auto absoluteLayout = AbsoluteLayout::New();
1931 DevelControl::SetLayout( rootControl, absoluteLayout );
1932 rootControl.SetName( "AbsoluteLayout" );
1933 stage.Add( rootControl );
1935 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
1936 auto hbox = Control::New();
1937 auto hboxLayout = LinearLayout::New();
1938 hbox.SetName( "HBox");
1940 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
1941 rootControl.Add( hbox );
1943 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
1944 DevelControl::SetLayout( hbox, hboxLayout );
1946 // Add a Child control
1947 std::vector< Control > controls;
1948 controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
1949 for( auto&& iter : controls )
1954 // Ensure layouting happens
1955 application.SendNotification();
1956 application.Render();
1958 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1963 int UtcDaliLayouting_SetLayoutOrder02(void)
1965 ToolkitTestApplication application;
1966 tet_infoline(" UtcDaliLayouting_SetLayoutOrder02 - Test the layout item order and the control order");
1968 Stage stage = Stage::GetCurrent();
1970 auto rootControl = Control::New();
1971 auto absoluteLayout = AbsoluteLayout::New();
1972 DevelControl::SetLayout( rootControl, absoluteLayout );
1973 rootControl.SetName( "AbsoluteLayout" );
1974 stage.Add( rootControl );
1976 auto hbox = Control::New();
1977 auto hboxLayout = LinearLayout::New();
1978 hbox.SetName( "HBox");
1980 rootControl.Add( hbox );
1982 DevelControl::SetLayout( hbox, hboxLayout );
1984 // Add child controls
1985 std::vector< Control > controls;
1986 controls.push_back( CreateLeafControl( 100, 100 ) ); // 0
1987 controls.push_back( CreateLeafControl( 100, 100 ) ); // 1
1988 controls.push_back( CreateLeafControl( 100, 100 ) ); // 2
1990 for( auto&& iter : controls )
1995 // Ensure layouting happens
1996 application.SendNotification();
1997 application.Render();
1999 TestLayoutItemOrder( controls, hboxLayout );
2001 tet_infoline("RaiseToTop");
2003 controls[0].RaiseToTop(); // 1 2 0
2005 TestLayoutItemOrder( controls, hboxLayout );
2007 tet_infoline("LowerToBottom");
2009 controls[2].LowerToBottom(); // 2 1 0
2011 TestLayoutItemOrder( controls, hboxLayout );
2013 tet_infoline("Remove / Add");
2015 hbox.Remove( controls[2] ); // 1 0
2016 hbox.Add( controls[2] ); // 1 0 2
2018 TestLayoutItemOrder( controls, hboxLayout );
2020 tet_infoline("SetLayout");
2022 auto vboxLayout = LinearLayout::New();
2023 DevelControl::SetLayout( controls[0], vboxLayout );
2025 TestLayoutItemOrder( controls, hboxLayout );
2027 tet_infoline("Raise");
2029 controls[0].Raise(); // 1 2 0
2031 TestLayoutItemOrder( controls, hboxLayout );
2033 tet_infoline("Lower");
2035 controls[2].Lower(); // 2 1 0
2037 TestLayoutItemOrder( controls, hboxLayout );
2039 tet_infoline("SetLayout again");
2041 auto vboxLayout1 = LinearLayout::New();
2042 DevelControl::SetLayout( controls[2], vboxLayout1 );
2044 TestLayoutItemOrder( controls, hboxLayout );
2046 DevelControl::SetLayout( controls[2], vboxLayout );
2051 int UtcDaliLayouting_LayoutGroup01(void)
2053 ToolkitTestApplication application;
2054 tet_infoline("UtcDaliLayouting_LayoutGroup01 - Test adding a control to a layout then adding a TextLabel to that control");
2056 Control rootControl;
2057 SetupRootLayoutControl( rootControl );
2059 // Create a parent layout
2060 auto hbox = Control::New();
2061 auto hboxLayout = LinearLayout::New();
2062 hbox.SetName( "HBox");
2063 rootControl.Add( hbox );
2064 DevelControl::SetLayout( hbox, hboxLayout );
2065 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2066 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2067 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2069 tet_infoline("Add a control without SetLayout being called");
2071 auto control = Control::New();
2072 control.SetName("Control1");
2073 hbox.Add( control );
2074 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2075 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2077 tet_infoline("Add a Textlabel to the control");
2078 auto textLabel = TextLabel::New("Test text");
2079 textLabel.SetName("TextLabel");
2080 control.Add( textLabel );
2082 // Ensure layouting happens
2083 application.SendNotification();
2084 application.Render();
2086 tet_infoline("Test text is it's natural size");
2087 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2088 tet_infoline("Test control is width of it's parent and height of it's child");
2089 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2094 int UtcDaliLayouting_LayoutGroup02(void)
2096 ToolkitTestApplication application;
2097 tet_infoline("UtcDaliLayouting_LayoutGroup02 - Test control is the size of it's largest child");
2099 Control rootControl;
2100 SetupRootLayoutControl( rootControl );
2102 // Create a parent layout
2103 auto hbox = Control::New();
2104 auto hboxLayout = LinearLayout::New();
2105 hbox.SetName( "HBox");
2106 rootControl.Add( hbox );
2107 DevelControl::SetLayout( hbox, hboxLayout );
2108 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2109 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2110 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2112 tet_infoline("Add a control without SetLayout being called");
2114 auto control = Control::New();
2115 control.SetName("Control1");
2116 hbox.Add( control );
2117 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2118 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2120 tet_infoline("Add a Textlabel to the control");
2121 auto textLabel = TextLabel::New("Test text");
2122 textLabel.SetName("TextLabel");
2123 control.Add( textLabel );
2125 tet_infoline("Add another Textlabel to the control");
2126 auto largeTextLabel = TextLabel::New("Test large text");
2127 largeTextLabel.SetName("TextLabel-Large");
2128 control.Add( largeTextLabel );
2130 // Ensure layouting happens
2131 application.SendNotification();
2132 application.Render();
2134 tet_infoline("Test text is it's natural size");
2135 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2136 tet_infoline("Test text is centered in the control, the control is the size of the largest child");
2137 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2139 tet_infoline("Test large text is it's natural size");
2140 DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2141 tet_infoline("Test text is aligned to start as is the size of the control");
2142 DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2144 tet_infoline("Test control is width of it's parent and height of it's largest child");
2145 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2150 int UtcDaliLayouting_LayoutGroup03(void)
2152 ToolkitTestApplication application;
2153 tet_infoline("UtcDaliLayouting_LayoutGroup03 - Test control witha LayoutGroup as a leaf");
2155 Control rootControl;
2156 SetupRootLayoutControl( rootControl );
2158 // Create a parent layout
2159 auto hbox = Control::New();
2160 auto hboxLayout = LinearLayout::New();
2161 hbox.SetName( "HBox");
2162 rootControl.Add( hbox );
2163 DevelControl::SetLayout( hbox, hboxLayout );
2164 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2165 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2166 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2168 tet_infoline("Add a control without SetLayout being called");
2170 auto control = Control::New();
2171 control.SetName("Control1");
2172 hbox.Add( control );
2173 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2174 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
2176 // Ensure layouting happens
2177 application.SendNotification();
2178 application.Render();
2180 tet_infoline("Test control is width of it's parent and exact given height");
2181 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2182 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2187 int UtcDaliLayouting_LayoutGroupWithPadding01(void)
2189 ToolkitTestApplication application;
2190 tet_infoline("UtcDaliLayouting_LayoutGroupWithPadding01 - Test adding a control to a layout that has padding");
2192 Control rootControl;
2193 SetupRootLayoutControl( rootControl );
2195 // Create a parent layout
2196 auto hbox = Control::New();
2197 auto hboxLayout = LinearLayout::New();
2198 hbox.SetName( "HBox");
2199 rootControl.Add( hbox );
2200 DevelControl::SetLayout( hbox, hboxLayout );
2201 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2202 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2203 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2205 tet_infoline("Add a control without SetLayout being called");
2207 auto control = Control::New();
2208 control.SetName("Control1");
2209 hbox.Add( control );
2210 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2211 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2213 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
2214 tet_printf( "Adding Padding to control");
2215 control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
2217 tet_infoline("Add a Textlabel to the control");
2218 auto textLabel = TextLabel::New("Test text");
2219 textLabel.SetName("TextLabel");
2220 control.Add( textLabel );
2222 // Ensure layouting happens
2223 application.SendNotification();
2224 application.Render();
2226 tet_infoline("Test text is it's natural size");
2227 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2228 tet_infoline("Test control is size of it's child and control it's own padding");
2229 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 245.0f, 86.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2234 int UtcDaliLayouting_LayoutGroupWithChildMargin01(void)
2236 ToolkitTestApplication application;
2237 tet_infoline("UtcDaliLayouting_LayoutGroupWithChildMargin01 - Test adding a control with padding to a layout that has padding");
2239 Control rootControl;
2240 SetupRootLayoutControl( rootControl );
2242 // Create a parent layout
2243 auto hbox = Control::New();
2244 auto hboxLayout = LinearLayout::New();
2245 hbox.SetName( "HBox");
2246 rootControl.Add( hbox );
2247 DevelControl::SetLayout( hbox, hboxLayout );
2248 hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2249 hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2250 hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
2252 tet_infoline("Add a control without SetLayout being called");
2254 auto control = Control::New();
2255 control.SetName("Control1");
2256 hbox.Add( control );
2257 control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2258 control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2260 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
2261 tet_printf( "Adding Padding to control");
2262 control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
2264 tet_infoline("Add a Textlabel to the control");
2265 auto textLabel = TextLabel::New("Test text");
2266 const Extents CHILD_MARGIN = Extents( 10, 0, 5, 0 );
2267 textLabel.SetProperty( Toolkit::Control::Property::MARGIN, CHILD_MARGIN );
2268 textLabel.SetName("TextLabel");
2269 control.Add( textLabel );
2271 // Ensure layouting happens
2272 application.SendNotification();
2273 application.Render();
2275 tet_infoline("Test text is it's natural size");
2276 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2277 tet_infoline("Test control is width of it's parent and height of it's child");
2278 DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 255.0f, 91.0f, 0.0f ), 0.0001f, TEST_LOCATION );