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;
38 void TestLayoutItemOrder( std::vector< Control >& controls, LayoutGroup& layoutGroup )
40 for( auto&& iter : controls )
42 unsigned int siblingOrder = static_cast< unsigned int>( iter.GetProperty< int >( DevelActor::Property::SIBLING_ORDER ) );
43 DALI_TEST_EQUALS( layoutGroup.GetChildAt( siblingOrder ), DevelControl::GetLayout( iter ), TEST_LOCATION );
47 void utc_dali_toolkit_layouting_startup(void)
49 test_return_value = TET_UNDEF;
52 void utc_dali_toolkit_layouting_cleanup(void)
54 test_return_value = TET_PASS;
57 int UtcDaliLayouting_HboxLayout01(void)
59 ToolkitTestApplication application;
60 tet_infoline(" UtcDaliLayouting_HboxLayout01");
62 Stage stage = Stage::GetCurrent();
63 auto hbox = Control::New();
64 auto hboxLayout = LinearLayout::New();
65 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
66 DevelControl::SetLayout( hbox, hboxLayout );
67 hbox.SetName( "HBox");
69 std::vector< Control > controls;
70 controls.push_back( CreateLeafControl( 40, 40 ) );
71 controls.push_back( CreateLeafControl( 60, 40 ) );
72 controls.push_back( CreateLeafControl( 80, 40 ) );
73 controls.push_back( CreateLeafControl( 100, 40 ) );
75 for( auto&& iter : controls )
80 hbox.SetParentOrigin( ParentOrigin::CENTER );
81 hbox.SetAnchorPoint( AnchorPoint::CENTER );
84 // Ensure layouting happens
85 application.SendNotification();
88 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
89 // hbox left justifies elements
90 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
91 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
92 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
93 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
95 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
96 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
97 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
98 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
101 auto newHBoxLayout = LinearLayout::New();
102 newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
103 DevelControl::SetLayout( hbox, newHBoxLayout );
105 application.SendNotification();
106 application.Render();
108 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
109 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
110 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
111 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
116 int UtcDaliLayouting_HboxLayout02(void)
118 ToolkitTestApplication application;
119 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
121 Stage stage = Stage::GetCurrent();
123 auto hbox1 = Control::New();
124 auto hboxLayout1 = LinearLayout::New();
125 DevelControl::SetLayout( hbox1, hboxLayout1 );
127 auto hbox2 = Control::New();
128 auto hboxLayout2 = LinearLayout::New();
129 DevelControl::SetLayout( hbox2, hboxLayout2 );
131 hbox1.SetName( "HBox1");
132 hbox2.SetName( "HBox2");
134 std::vector< Control > controls;
135 controls.push_back( CreateLeafControl( 20, 40 ) );
136 controls.push_back( CreateLeafControl( 30, 50 ) );
137 controls.push_back( CreateLeafControl( 40, 60 ) );
138 controls.push_back( CreateLeafControl( 50, 70 ) );
140 controls.push_back( CreateLeafControl( 25, 40 ) );
141 controls.push_back( CreateLeafControl( 35, 50 ) );
142 controls.push_back( CreateLeafControl( 45, 60 ) );
143 controls.push_back( CreateLeafControl( 55, 70 ) );
146 for( auto&& iter : controls )
158 hbox1.SetParentOrigin( ParentOrigin::CENTER );
159 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
160 hbox2.SetParentOrigin( ParentOrigin::CENTER );
161 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
163 auto hbox3 = Control::New();
164 auto hboxLayout3 = LinearLayout::New();
165 DevelControl::SetLayout( hbox3, hboxLayout3 );
167 hbox3.SetParentOrigin( ParentOrigin::CENTER );
168 hbox3.SetName( "HBox3");
174 // Ensure layouting happens
175 application.SendNotification();
176 application.Render();
179 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
180 // hbox left justifies elements
181 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
182 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
183 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
184 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
186 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
187 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
188 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
189 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
192 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
193 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
194 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
195 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
197 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
198 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
199 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
200 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
202 // Test hbox1 and 2 are sized to wrap their content
203 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
204 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
205 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
206 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
208 // Test hbox3 matches parent (root layer)
209 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
210 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
216 int UtcDaliLayouting_HboxLayout03(void)
218 ToolkitTestApplication application;
219 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
221 Stage stage = Stage::GetCurrent();
223 auto hbox1 = Control::New();
224 auto hboxLayout1 = LinearLayout::New();
225 DevelControl::SetLayout( hbox1, hboxLayout1 );
227 auto hbox2 = Control::New();
228 auto hboxLayout2 = LinearLayout::New();
229 DevelControl::SetLayout( hbox2, hboxLayout2 );
231 hbox1.SetName( "HBox1");
232 hbox2.SetName( "HBox2");
233 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
234 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
235 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
236 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
238 std::vector< Control > controls;
239 controls.push_back( CreateLeafControl( 20, 40 ) );
240 controls.push_back( CreateLeafControl( 30, 50 ) );
241 controls.push_back( CreateLeafControl( 40, 60 ) );
242 controls.push_back( CreateLeafControl( 50, 70 ) );
244 controls.push_back( CreateLeafControl( 25, 40 ) );
245 controls.push_back( CreateLeafControl( 35, 50 ) );
246 controls.push_back( CreateLeafControl( 45, 60 ) );
247 controls.push_back( CreateLeafControl( 55, 70 ) );
250 for( auto&& iter : controls )
262 hbox1.SetParentOrigin( ParentOrigin::CENTER );
263 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
264 hbox2.SetParentOrigin( ParentOrigin::CENTER );
265 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
267 auto hbox3 = Control::New();
268 auto hboxLayout3 = LinearLayout::New();
269 DevelControl::SetLayout( hbox3, hboxLayout3);
271 hbox3.SetParentOrigin( ParentOrigin::CENTER );
272 hbox3.SetName( "HBox3");
278 //std::ostringstream oss;
279 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
280 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
282 // Ensure layouting happens
283 application.SendNotification();
284 application.Render();
287 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
288 // hbox left justifies elements
289 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
290 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
291 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
292 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
294 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
295 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
296 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
297 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
299 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
300 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
301 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
302 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
304 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
305 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
306 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
307 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
309 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
310 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
311 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
312 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
314 // Test hbox3 matches parent (root layer)
315 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
316 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
321 int UtcDaliLayouting_HboxLayout04(void)
323 ToolkitTestApplication application;
324 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
326 Stage stage = Stage::GetCurrent();
328 auto hbox1 = Control::New();
329 auto hboxLayout1 = LinearLayout::New();
330 DevelControl::SetLayout( hbox1, hboxLayout1 );
332 auto hbox2 = Control::New();
333 auto hboxLayout2 = LinearLayout::New();
334 DevelControl::SetLayout( hbox2, hboxLayout2 );
336 hbox1.SetName( "HBox1"); // Default spec is to wrap content
337 hbox2.SetName( "HBox2");
338 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
339 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
340 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
341 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
343 std::vector< Control > controls;
344 controls.push_back( CreateLeafControl( 80, 40 ) );
345 controls.push_back( CreateLeafControl( 80, 50 ) );
346 controls.push_back( CreateLeafControl( 80, 60 ) );
347 controls.push_back( CreateLeafControl( 80, 70 ) );
349 controls.push_back( CreateLeafControl( 80, 40 ) );
350 controls.push_back( CreateLeafControl( 80, 50 ) );
351 controls.push_back( CreateLeafControl( 80, 60 ) );
352 controls.push_back( CreateLeafControl( 80, 70 ) );
355 for( auto&& iter : controls )
368 controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
369 auto hbox3 = Control::New();
370 auto hboxLayout3 = LinearLayout::New();
371 DevelControl::SetLayout( hbox3, hboxLayout3 );
373 hbox3.SetParentOrigin( ParentOrigin::CENTER );
374 hbox3.SetName( "HBox3");
379 //std::ostringstream oss;
380 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
381 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
383 // Ensure layouting happens
384 application.SendNotification();
385 application.Render();
388 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
389 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
390 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
391 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
393 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
394 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
395 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
396 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
398 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
399 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
400 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
401 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
403 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
404 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
405 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
406 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
408 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
409 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
410 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
411 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
414 // Test hbox3 matches parent (root layer)
415 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
416 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
421 int UtcDaliLayouting_HboxLayout05(void)
423 ToolkitTestApplication application;
424 tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
426 Stage stage = Stage::GetCurrent();
427 auto hbox = Control::New();
428 auto hboxLayout = LinearLayout::New();
429 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
430 DevelControl::SetLayout( hbox, hboxLayout );
431 hbox.SetName( "HBox");
433 std::vector< Control > controls;
434 controls.push_back( CreateLeafControl( 40, 40 ) );
435 controls.push_back( CreateLeafControl( 60, 40 ) );
436 controls.push_back( CreateLeafControl( 80, 40 ) );
437 controls.push_back( CreateLeafControl( 100, 40 ) );
439 for( auto&& iter : controls )
442 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
443 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
446 hbox.SetParentOrigin( ParentOrigin::CENTER );
447 hbox.SetAnchorPoint( AnchorPoint::CENTER );
450 // Ensure layouting happens
451 application.SendNotification();
452 application.Render();
454 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
455 // hbox left justifies elements
456 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
457 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
458 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
459 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
461 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
462 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
463 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
464 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
469 int UtcDaliLayouting_HboxLayout06(void)
471 ToolkitTestApplication application;
472 tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
474 Stage stage = Stage::GetCurrent();
476 auto rootControl = Control::New();
477 auto absoluteLayout = AbsoluteLayout::New();
478 DevelControl::SetLayout( rootControl, absoluteLayout );
479 rootControl.SetName( "AbsoluteLayout" );
480 stage.Add( rootControl );
482 auto hbox = Control::New();
483 auto hboxLayout = LinearLayout::New();
484 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
485 DevelControl::SetLayout( hbox, hboxLayout );
486 hbox.SetName( "HBox" );
488 std::vector< Control > controls;
489 controls.push_back( CreateLeafControl( 40, 40 ) );
490 controls.push_back( CreateLeafControl( 60, 40 ) );
492 for( auto&& iter : controls )
496 hbox.SetParentOrigin( ParentOrigin::CENTER );
497 hbox.SetAnchorPoint( AnchorPoint::CENTER );
498 rootControl.Add( hbox );
500 // Ensure layouting happens
501 application.SendNotification();
502 application.Render();
504 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
505 // hbox left justifies elements
506 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
507 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
509 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
510 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
512 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
515 auto newHBoxLayout = LinearLayout::New();
516 newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
517 DevelControl::SetLayout( hbox, newHBoxLayout );
519 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
520 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
522 application.SendNotification();
523 application.Render();
525 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
527 // Change size specification
528 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
529 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
531 application.SendNotification();
532 application.Render();
534 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
536 // Use WRAP_CONTENT again
537 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
538 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
540 application.SendNotification();
541 application.Render();
543 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
548 int UtcDaliLayouting_HboxLayout07(void)
550 ToolkitTestApplication application;
551 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
553 Stage stage = Stage::GetCurrent();
554 auto hbox = Control::New();
555 auto hboxLayout = LinearLayout::New();
556 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
557 DevelControl::SetLayout( hbox, hboxLayout );
558 hbox.SetName( "HBox");
560 std::vector< Control > controls;
561 controls.push_back( CreateLeafControl( 40, 40 ) );
562 controls.push_back( CreateLeafControl( 60, 40 ) );
563 controls.push_back( CreateLeafControl( 80, 40 ) );
564 controls.push_back( CreateLeafControl( 100, 40 ) );
566 for( auto&& iter : controls )
570 hbox.SetParentOrigin( ParentOrigin::CENTER );
571 hbox.SetAnchorPoint( AnchorPoint::CENTER );
574 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
576 // Ensure layouting happens
577 application.SendNotification();
578 application.Render();
580 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
581 // hbox left justifies elements
582 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
583 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
584 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
585 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
587 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
588 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
589 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
590 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
592 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
594 // Ensure layouting happens
595 application.SendNotification();
596 application.Render();
598 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
599 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
600 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
601 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
603 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
604 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
605 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
606 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
611 int UtcDaliLayouting_HboxLayout08(void)
613 ToolkitTestApplication application;
614 tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation");
616 Stage stage = Stage::GetCurrent();
618 auto rootControl = Control::New();
619 auto absoluteLayout = AbsoluteLayout::New();
620 absoluteLayout.SetAnimateLayout( true );
621 DevelControl::SetLayout( rootControl, absoluteLayout );
622 rootControl.SetName( "AbsoluteLayout" );
623 stage.Add( rootControl );
625 Control control1 = CreateLeafControl( 40, 40 );
626 rootControl.Add( control1 );
627 auto hbox = Control::New();
628 auto hboxLayout = LinearLayout::New();
629 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
630 DevelControl::SetLayout( hbox, hboxLayout );
631 hbox.SetName( "HBox" );
633 Control control2 = CreateLeafControl( 40, 40 );
634 hbox.Add( control2 );
636 hbox.SetParentOrigin( ParentOrigin::CENTER );
637 hbox.SetAnchorPoint( AnchorPoint::CENTER );
638 rootControl.Add( hbox );
640 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION );
641 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION );
642 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION );
643 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION );
645 hboxLayout.SetAnimateLayout( true );
646 absoluteLayout.SetAnimateLayout( false );
648 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION );
649 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION );
650 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION );
651 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION );
656 int UtcDaliLayouting_HboxLayout09(void)
658 ToolkitTestApplication application;
659 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set alignment");
661 Stage stage = Stage::GetCurrent();
662 auto hbox = Control::New();
663 auto hboxLayout = LinearLayout::New();
664 DevelControl::SetLayout( hbox, hboxLayout );
665 hbox.SetName( "HBox");
667 std::vector< Control > controls;
668 controls.push_back( CreateLeafControl( 40, 40 ) );
669 controls.push_back( CreateLeafControl( 60, 60 ) );
671 for( auto&& iter : controls )
675 hbox.SetParentOrigin( ParentOrigin::CENTER );
676 hbox.SetAnchorPoint( AnchorPoint::CENTER );
679 // Check default orientation
680 DALI_TEST_EQUALS( static_cast<unsigned int>( hboxLayout.GetOrientation() ), static_cast<unsigned int>( LinearLayout::Orientation::HORIZONTAL ), TEST_LOCATION );
681 // Check default alignment
682 DALI_TEST_EQUALS( hboxLayout.GetAlignment(), ( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL ), TEST_LOCATION );
684 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN );
686 // Ensure layouting happens
687 application.SendNotification();
688 application.Render();
690 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
691 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
693 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
694 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
696 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END );
698 // Ensure layouting happens
699 application.SendNotification();
700 application.Render();
702 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
703 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
705 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
706 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
708 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
710 // Ensure layouting happens
711 application.SendNotification();
712 application.Render();
714 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
715 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
717 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
718 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
720 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP );
722 // Ensure layouting happens
723 application.SendNotification();
724 application.Render();
726 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
727 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
729 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
730 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
732 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP );
734 // Ensure layouting happens
735 application.SendNotification();
736 application.Render();
738 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
739 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
741 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
742 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
744 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP );
746 // Ensure layouting happens
747 application.SendNotification();
748 application.Render();
750 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
751 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
753 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
754 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
756 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
758 // Ensure layouting happens
759 application.SendNotification();
760 application.Render();
762 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
763 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
765 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
766 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
768 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
770 // Ensure layouting happens
771 application.SendNotification();
772 application.Render();
774 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
775 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
777 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
778 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
780 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
782 // Ensure layouting happens
783 application.SendNotification();
784 application.Render();
786 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
787 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
789 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
790 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
792 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL );
794 // Ensure layouting happens
795 application.SendNotification();
796 application.Render();
798 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
799 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
801 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
802 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
804 hboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
805 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN );
807 // Ensure layouting happens
808 application.SendNotification();
809 application.Render();
811 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
812 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
814 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
815 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
817 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END );
819 // Ensure layouting happens
820 application.SendNotification();
821 application.Render();
823 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
824 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
826 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
827 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
829 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
831 // Ensure layouting happens
832 application.SendNotification();
833 application.Render();
835 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
836 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
838 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
839 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
841 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP );
843 // Ensure layouting happens
844 application.SendNotification();
845 application.Render();
847 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
848 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
850 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
851 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
853 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP );
855 // Ensure layouting happens
856 application.SendNotification();
857 application.Render();
859 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
860 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
862 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
863 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
865 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP );
867 // Ensure layouting happens
868 application.SendNotification();
869 application.Render();
871 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
872 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
874 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
875 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
877 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
879 // Ensure layouting happens
880 application.SendNotification();
881 application.Render();
883 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
884 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
886 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
887 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
889 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
891 // Ensure layouting happens
892 application.SendNotification();
893 application.Render();
895 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
896 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
898 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
899 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
901 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
903 // Ensure layouting happens
904 application.SendNotification();
905 application.Render();
907 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
908 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
910 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
911 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
913 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL );
915 // Ensure layouting happens
916 application.SendNotification();
917 application.Render();
919 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
920 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
922 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
923 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
930 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/broken.png";
933 int UtcDaliLayouting_HboxLayout_ImageView(void)
935 ToolkitTestApplication application;
936 tet_infoline(" UtcDaliLayouting_HboxLayout - Use image view for leaf");
938 Stage stage = Stage::GetCurrent();
939 auto hbox = Control::New();
940 auto hboxLayout = LinearLayout::New();
941 DevelControl::SetLayout( hbox, hboxLayout );
942 hbox.SetName( "HBox" );
944 std::string url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 100, 100 ) );
945 ImageView imageView = CreateImageView( url, ImageDimensions() );
947 hbox.SetParentOrigin( ParentOrigin::CENTER );
948 hbox.SetAnchorPoint( AnchorPoint::CENTER );
949 hbox.Add( imageView );
952 // Ensure layouting happens
953 application.SendNotification();
954 application.Render();
956 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
957 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
959 url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 200, 200 ) );
960 imageView.SetImage( url );
962 // Ensure layouting happenss
963 application.SendNotification();
964 application.Render();
966 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
967 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
969 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
970 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
972 // Ensure layouting happenss
973 application.SendNotification();
974 application.Render();
976 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
977 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
979 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
980 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
982 // Ensure layouting happenss
983 application.SendNotification();
984 application.Render();
986 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
987 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
989 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
990 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
992 Image image = FrameBufferImage::New( 50, 50, Pixel::RGBA8888 );
993 imageView.SetImage( image );
995 // Ensure layouting happenss
996 application.SendNotification();
997 application.Render();
999 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1000 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1002 Property::Map imagePropertyMap;
1003 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1004 imagePropertyMap[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
1005 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 150;
1006 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 150;
1007 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap );
1009 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1010 // Ensure layouting happenss
1011 application.SendNotification();
1012 application.Render();
1014 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 325.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1015 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1020 int UtcDaliLayouting_HboxLayout_TextLabel(void)
1022 ToolkitTestApplication application;
1023 tet_infoline(" UtcDaliLayouting_HboxLayout - Use text label for leaf");
1025 Stage stage = Stage::GetCurrent();
1027 auto hbox = Control::New();
1028 auto hboxLayout = LinearLayout::New();
1029 DevelControl::SetLayout( hbox, hboxLayout );
1030 hbox.SetName( "HBox" );
1031 hbox.SetParentOrigin( ParentOrigin::CENTER );
1032 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1034 std::vector< Control > controls;
1035 TextLabel textLabel = CreateTextLabel( "W" );
1036 controls.push_back( textLabel );
1037 hbox.Add( textLabel );
1040 // Ensure layouting happens
1041 application.SendNotification();
1042 application.Render();
1044 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1045 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 54.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1047 textLabel.SetProperty( TextLabel::Property::TEXT, "WWWW" );
1049 // Ensure layouting happens
1050 application.SendNotification();
1051 application.Render();
1053 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1054 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 216.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1056 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
1058 // Ensure layouting happens
1059 application.SendNotification();
1060 application.Render();
1062 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1063 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1065 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1066 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1068 // Ensure layouting happens
1069 application.SendNotification();
1070 application.Render();
1072 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1073 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1075 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1076 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1078 // Ensure layouting happens
1079 application.SendNotification();
1080 application.Render();
1082 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1083 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1090 int UtcDaliLayouting_HboxLayout_Padding01(void)
1092 ToolkitTestApplication application;
1093 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
1095 Stage stage = Stage::GetCurrent();
1096 auto hbox = Control::New();
1097 auto hboxLayout = LinearLayout::New();
1098 DevelControl::SetLayout( hbox, hboxLayout );
1099 hbox.SetName( "HBox");
1101 std::vector< Control > controls;
1102 controls.push_back( CreateLeafControl( 40, 40 ) );
1103 controls.push_back( CreateLeafControl( 60, 40 ) );
1104 controls.push_back( CreateLeafControl( 80, 40 ) );
1105 controls.push_back( CreateLeafControl( 100, 40 ) );
1107 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1108 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
1109 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1111 for( auto&& iter : controls )
1115 hbox.SetParentOrigin( ParentOrigin::CENTER );
1116 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1119 // Ensure layouting happens
1120 application.SendNotification();
1121 application.Render();
1123 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1124 // hbox left justifies elements
1125 tet_infoline("Test Child Actor Position");
1126 float xPositionOfControlBeingTested = 0.0f;
1127 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1129 0.0f ), 0.0001f, TEST_LOCATION );
1130 xPositionOfControlBeingTested += 40.0f;
1132 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1133 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1134 0.0001f, TEST_LOCATION );
1136 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1137 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1139 xPositionOfControlBeingTested += 80.0f;
1140 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1142 tet_infoline("Test Child Actor Size");
1143 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1145 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1146 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
1147 0.0001f, TEST_LOCATION );
1149 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1150 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1155 int UtcDaliLayouting_HboxLayout_Padding02(void)
1157 ToolkitTestApplication application;
1158 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
1160 Stage stage = Stage::GetCurrent();
1161 auto hbox = Control::New();
1162 auto hboxLayout = LinearLayout::New();
1163 DevelControl::SetLayout( hbox, hboxLayout );
1164 hbox.SetName( "HBox");
1166 std::vector< Control > controls;
1167 controls.push_back( CreateLeafControl( 40, 40 ) );
1168 controls.push_back( CreateLeafControl( 60, 40 ) );
1169 controls.push_back( CreateLeafControl( 80, 40 ) );
1170 controls.push_back( CreateLeafControl( 100, 40 ) );
1172 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1174 for( auto&& iter : controls )
1176 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1179 hbox.SetParentOrigin( ParentOrigin::CENTER );
1180 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1183 // Ensure layouting happens
1184 application.SendNotification();
1185 application.Render();
1187 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1188 // hbox left justifies elements
1189 tet_infoline("Test Child Actor Position");
1190 float xPositionOfControlBeingTested = 0.0f;
1191 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
1193 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1194 yPositionOfControlBeingTested,
1195 0.0f ), 0.0001f, TEST_LOCATION );
1196 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1198 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1199 yPositionOfControlBeingTested,
1201 0.0001f, TEST_LOCATION );
1203 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1204 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1205 yPositionOfControlBeingTested,
1206 0.0f ), 0.0001f, TEST_LOCATION );
1208 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1209 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1210 yPositionOfControlBeingTested,
1211 0.0f ), 0.0001f, TEST_LOCATION );
1213 tet_infoline("Test Child Actor Size");
1214 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1215 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1216 0.0f ), 0.0001f, TEST_LOCATION );
1218 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1219 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1220 0.0f ), 0.0001f, TEST_LOCATION );
1222 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
1223 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1224 0.0f ), 0.0001f, TEST_LOCATION );
1226 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1227 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1228 0.0f ), 0.0001f, TEST_LOCATION );
1234 int UtcDaliLayouting_HboxLayout_Padding03(void)
1236 ToolkitTestApplication application;
1237 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
1239 Stage stage = Stage::GetCurrent();
1240 auto hbox = Control::New();
1241 auto hboxLayout = LinearLayout::New();
1242 DevelControl::SetLayout( hbox, hboxLayout );
1243 hbox.SetName( "HBox");
1245 std::vector< Control > controls;
1246 controls.push_back( CreateLeafControl( 40, 40 ) );
1247 controls.push_back( CreateLeafControl( 40, 40 ) );
1248 controls.push_back( CreateLeafControl( 40, 40 ) );
1250 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1251 tet_printf( "\nAdding Padding to control at index 1 \n" );
1252 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1254 for( auto&& iter : controls )
1258 hbox.SetParentOrigin( ParentOrigin::CENTER );
1259 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1262 // Ensure layouting happens
1263 application.SendNotification();
1264 application.Render();
1266 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1267 // hbox left justifies elements
1268 tet_infoline("Test Child Actor Position");
1269 float xPositionOfControlBeingTested = 0.0f;
1270 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1272 0.0f ), 0.0001f, TEST_LOCATION );
1273 xPositionOfControlBeingTested += 40.0f;
1275 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1276 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1277 0.0001f, TEST_LOCATION );
1279 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1280 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1282 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
1283 tet_printf( "\nChanging Padding to control at index 1 \n" );
1284 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
1286 // Ensure layouting happens
1287 application.SendNotification();
1288 application.Render();
1290 xPositionOfControlBeingTested = 0.0f; // reset
1292 tet_infoline("Test Child Actor Position");
1293 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1295 0.0f ), 0.0001f, TEST_LOCATION );
1296 xPositionOfControlBeingTested += 40.0f;
1298 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1299 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1300 0.0001f, TEST_LOCATION );
1302 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
1303 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
1304 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1306 tet_infoline("Test Child Actor Size");
1307 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1309 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
1310 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
1311 0.0001f, TEST_LOCATION );
1313 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1318 int UtcDaliLayouting_HboxLayout_Padding04(void)
1320 ToolkitTestApplication application;
1321 tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
1323 // Adding padding to the layout should offset the positioning of the children.
1325 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1326 const Size CONTROL_SIZE = Size( 40, 40 );
1328 Stage stage = Stage::GetCurrent();
1329 // Create a root layout, ideally Dali would have a default layout in the root layer.
1330 // Without this root layer the LinearLayout (or any other layout) will not
1331 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1332 // It uses the default stage size and ideally should have a layout added to it.
1333 auto rootLayoutControl = Control::New();
1334 rootLayoutControl.SetName( "AbsoluteLayout");
1335 auto rootLayout = AbsoluteLayout::New();
1336 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1337 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1338 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1339 stage.Add( rootLayoutControl );
1341 auto hbox = Control::New();
1342 auto hboxLayout = LinearLayout::New();
1343 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1344 DevelControl::SetLayout( hbox, hboxLayout );
1345 hbox.SetName( "HBox");
1346 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1347 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1348 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1350 std::vector< Control > controls;
1351 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1352 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1353 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1354 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1356 for( auto&& iter : controls )
1361 hbox.SetParentOrigin( ParentOrigin::CENTER );
1362 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1363 rootLayoutControl.Add( hbox );
1365 // Ensure layouting happens
1366 application.SendNotification();
1367 application.Render();
1369 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1370 application.SendNotification();
1372 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1373 // hbox left justifies elements
1374 tet_infoline("Test Child Actor Position");
1376 auto controlXPosition=0.0f;
1378 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1379 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1381 0.0f ), 0.0001f, TEST_LOCATION );
1383 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1384 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1387 0.0001f, TEST_LOCATION );
1389 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1390 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1392 0.0f ), 0.0001f, TEST_LOCATION );
1394 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1395 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1397 0.0f ), 0.0001f, TEST_LOCATION );
1399 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1400 auto totalControlsHeight = CONTROL_SIZE.height;
1402 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1403 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1404 0.0f ), 0.0001f, TEST_LOCATION );
1410 int UtcDaliLayouting_HboxLayout_Padding05(void)
1412 ToolkitTestApplication application;
1413 tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
1415 // Adding padding to the layout should offset the positioning of the children.
1417 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1418 const Size CONTROL_SIZE = Size( 40, 40 );
1420 Stage stage = Stage::GetCurrent();
1421 // Create a root layout, ideally Dali would have a default layout in the root layer.
1422 // Without this root layer the LinearLayout (or any other layout) will not
1423 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1424 // It uses the default stage size and ideally should have a layout added to it.
1425 auto rootLayoutControl = Control::New();
1426 rootLayoutControl.SetName( "AbsoluteLayout");
1427 auto rootLayout = AbsoluteLayout::New();
1428 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1429 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1430 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1431 stage.Add( rootLayoutControl );
1433 auto hbox = Control::New();
1434 auto hboxLayout = LinearLayout::New();
1435 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1436 DevelControl::SetLayout( hbox, hboxLayout );
1437 hbox.SetName( "HBox");
1438 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1439 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1440 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1442 std::vector< Control > controls;
1443 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1444 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1445 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1446 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1448 for( auto&& iter : controls )
1453 hbox.SetParentOrigin( ParentOrigin::CENTER );
1454 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1455 rootLayoutControl.Add( hbox );
1457 // Ensure layouting happens
1458 application.SendNotification();
1459 application.Render();
1461 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1462 application.SendNotification();
1464 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1465 // hbox left justifies elements
1466 tet_infoline("Test Child Actor Position");
1468 auto controlXPosition=0.0f;
1470 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1471 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1473 0.0f ), 0.0001f, TEST_LOCATION );
1475 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1476 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1479 0.0001f, TEST_LOCATION );
1481 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1482 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1484 0.0f ), 0.0001f, TEST_LOCATION );
1486 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1487 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1489 0.0f ), 0.0001f, TEST_LOCATION );
1491 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1492 auto totalControlsHeight = CONTROL_SIZE.height;
1494 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1495 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1496 0.0f ), 0.0001f, TEST_LOCATION );
1498 // Change layout padding
1499 const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
1500 tet_printf( "\nChanging Padding to control at index 1 \n" );
1501 hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
1503 // Ensure layouting happens
1504 application.SendNotification();
1505 application.Render();
1507 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1508 application.SendNotification();
1510 controlXPosition = NEW_LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1511 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
1512 NEW_LAYOUT_PADDING.top,
1513 0.0f ), 0.0001f, TEST_LOCATION );
1515 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1516 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1517 NEW_LAYOUT_PADDING.top,
1519 0.0001f, TEST_LOCATION );
1521 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1522 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1523 NEW_LAYOUT_PADDING.top,
1524 0.0f ), 0.0001f, TEST_LOCATION );
1526 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1527 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1528 NEW_LAYOUT_PADDING.top,
1529 0.0f ), 0.0001f, TEST_LOCATION );
1530 totalControlsWidth = CONTROL_SIZE.width * controls.size();
1531 totalControlsHeight = CONTROL_SIZE.height;
1533 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
1534 totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
1535 0.0f ), 0.0001f, TEST_LOCATION );
1541 int UtcDaliLayouting_HboxLayout_Margin01(void)
1543 ToolkitTestApplication application;
1544 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
1546 Stage stage = Stage::GetCurrent();
1547 auto hbox = Control::New();
1548 auto hboxLayout = LinearLayout::New();
1549 DevelControl::SetLayout( hbox, hboxLayout );
1550 hbox.SetName( "HBox");
1552 std::vector< Control > controls;
1553 controls.push_back( CreateLeafControl( 40, 40 ) );
1554 controls.push_back( CreateLeafControl( 60, 40 ) );
1555 controls.push_back( CreateLeafControl( 80, 40 ) );
1556 controls.push_back( CreateLeafControl( 100, 40 ) );
1558 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
1559 tet_printf( "\nAdding Margin to control at index 1 \n" );
1560 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1562 for( auto&& iter : controls )
1566 hbox.SetParentOrigin( ParentOrigin::CENTER );
1567 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1570 // Ensure layouting happens
1571 application.SendNotification();
1572 application.Render();
1574 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1575 // hbox left justifies elements
1576 tet_infoline("Test Child Actor Position");
1577 auto xPositionOfControlBeingTested = 0.0f;
1578 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1580 0.0f ), 0.0001f, TEST_LOCATION );
1581 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
1583 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1584 380.0f + CONTROL_MARGIN.top, 0.0f ),
1585 0.0001f, TEST_LOCATION );
1587 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
1588 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1590 xPositionOfControlBeingTested += 80.0f;
1591 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1593 tet_infoline("Test Child Actor Size is the same after Margin added");
1594 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1595 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
1596 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1597 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1603 int UtcDaliLayouting_VboxLayout01(void)
1605 ToolkitTestApplication application;
1606 tet_infoline(" UtcDaliLayouting_VboxLayout01");
1608 Stage stage = Stage::GetCurrent();
1609 auto vbox = Control::New();
1610 auto vboxLayout = LinearLayout::New();
1611 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1612 vboxLayout.SetAlignment( LinearLayout::Alignment::TOP | LinearLayout::Alignment::CENTER_HORIZONTAL );
1613 DevelControl::SetLayout( vbox, vboxLayout );
1614 vbox.SetName( "Vbox");
1616 std::vector< Control > controls;
1617 controls.push_back( CreateLeafControl( 40, 40 ) );
1618 controls.push_back( CreateLeafControl( 60, 60 ) );
1619 controls.push_back( CreateLeafControl( 80, 80 ) );
1620 controls.push_back( CreateLeafControl( 100, 100 ) );
1622 for( auto&& iter : controls )
1626 vbox.SetParentOrigin( ParentOrigin::CENTER );
1627 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1630 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1633 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1635 // Ensure layouting happens
1636 application.SendNotification();
1637 application.Render();
1639 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
1640 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1641 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1642 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1643 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1645 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1646 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1647 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1648 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1653 int UtcDaliLayouting_VboxLayout02(void)
1655 ToolkitTestApplication application;
1656 tet_infoline(" UtcDaliLayouting_VboxLayout01");
1658 Stage stage = Stage::GetCurrent();
1660 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1661 // LayoutGroup for this to happen automatically.
1663 // For this test, add an hbox instead
1664 auto rootControl = Control::New();
1665 auto absoluteLayout = AbsoluteLayout::New();
1666 DevelControl::SetLayout( rootControl, absoluteLayout );
1667 rootControl.SetName( "AbsoluteLayout");
1668 stage.Add( rootControl );
1670 auto vbox = Control::New();
1671 auto vboxLayout = LinearLayout::New();
1672 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1673 vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
1674 DevelControl::SetLayout( vbox, vboxLayout );
1675 vbox.SetName( "Vbox");
1676 rootControl.Add( vbox );
1678 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1679 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1681 std::vector< Control > controls;
1682 controls.push_back( CreateLeafControl( 40, 40 ) );
1683 controls.push_back( CreateLeafControl( 60, 60 ) );
1684 controls.push_back( CreateLeafControl( 80, 80 ) );
1685 controls.push_back( CreateLeafControl( 100, 100 ) );
1687 for( auto&& iter : controls )
1691 vbox.SetParentOrigin( ParentOrigin::CENTER );
1692 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1694 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1697 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1699 // Ensure layouting happens
1700 application.SendNotification();
1701 application.Render();
1703 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1704 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1706 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1707 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1708 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1710 // 3rd control is set to match parent - this should also be 100 wide
1711 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1712 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1713 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1714 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1716 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1717 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1718 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1719 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1725 int UtcDaliLayouting_VboxLayout03(void)
1727 ToolkitTestApplication application;
1728 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
1730 Stage stage = Stage::GetCurrent();
1732 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1733 // LayoutGroup for this to happen automatically.
1735 // For this test, add an hbox instead
1736 auto hbox = Control::New();
1737 auto hboxLayout = LinearLayout::New();
1738 DevelControl::SetLayout( hbox, hboxLayout );
1739 hbox.SetName( "Hbox");
1742 auto vbox = Control::New();
1743 auto vboxLayout = LinearLayout::New();
1744 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
1745 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1746 vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
1748 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
1750 DevelControl::SetLayout( vbox, vboxLayout );
1751 vbox.SetName( "Vbox");
1754 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1755 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1757 std::vector< Control > controls;
1758 controls.push_back( CreateLeafControl( 40, 40 ) );
1759 controls.push_back( CreateLeafControl( 60, 60 ) );
1760 controls.push_back( CreateLeafControl( 80, 80 ) );
1761 controls.push_back( CreateLeafControl( 100, 100 ) );
1763 for( auto&& iter : controls )
1767 vbox.SetParentOrigin( ParentOrigin::CENTER );
1768 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1770 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1773 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1775 // Ensure layouting happens
1776 application.SendNotification();
1777 application.Render();
1779 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1780 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1782 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1783 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1784 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1786 // 3rd control is set to match parent - this should also be 100 wide
1787 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1788 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1789 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1790 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1792 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1793 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1794 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1795 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1800 int UtcDaliLayouting_VboxLayout_Padding(void)
1802 ToolkitTestApplication application;
1803 tet_infoline("UtcDaliLayouting_VboxLayout_Padding - Adding Padding to the vbox");
1805 // Adding padding to the layout should offset the positioning of the children.
1807 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1808 const Size CONTROL_SIZE = Size( 40, 40 );
1810 Stage stage = Stage::GetCurrent();
1811 // Create a root layout, ideally Dali would have a default layout in the root layer.
1812 // Without this root layer the LinearLayout (or any other layout) will not
1813 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1814 // It uses the default stage size and ideally should have a layout added to it.
1815 auto rootLayoutControl = Control::New();
1816 rootLayoutControl.SetName( "AbsoluteLayout");
1817 auto rootLayout = AbsoluteLayout::New();
1818 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1819 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1820 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1821 stage.Add( rootLayoutControl );
1823 auto vbox = Control::New();
1824 auto vboxLayout = LinearLayout::New();
1825 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1826 DevelControl::SetLayout( vbox, vboxLayout );
1827 vbox.SetName( "VBox");
1828 vbox.SetProperty( Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1829 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1830 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1832 std::vector< Control > controls;
1833 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1834 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1835 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1836 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1838 for( auto&& iter : controls )
1843 vbox.SetParentOrigin( ParentOrigin::CENTER );
1844 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1845 rootLayoutControl.Add( vbox );
1847 // Ensure layouting happens
1848 application.SendNotification();
1849 application.Render();
1851 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1852 application.SendNotification();
1854 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
1855 tet_infoline("Test Child Actor Position");
1857 auto controlYPosition = 0.0f;
1859 controlYPosition = LAYOUT_PADDING.top; // First child positioned at offset defined by the padding
1860 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1862 0.0f ), 0.0001f, TEST_LOCATION );
1864 controlYPosition += CONTROL_SIZE.height; // Second child positioned is the position of the first child + the first child's height.
1865 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1868 0.0001f, TEST_LOCATION );
1870 controlYPosition += CONTROL_SIZE.height; // Third child positioned adjacent to second
1871 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1873 0.0f ), 0.0001f, TEST_LOCATION );
1875 controlYPosition += CONTROL_SIZE.height; // Forth passed adjacent to the third
1876 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1878 0.0f ), 0.0001f, TEST_LOCATION );
1880 auto totalControlsWidth = CONTROL_SIZE.width;
1881 auto totalControlsHeight = CONTROL_SIZE.height * controls.size();
1883 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1884 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1885 0.0f ), 0.0001f, TEST_LOCATION );
1891 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
1893 ToolkitTestApplication application;
1894 tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
1895 tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
1897 Stage stage = Stage::GetCurrent();
1899 auto hbox = Control::New();
1900 auto hboxLayout = Test::CustomLayout::New();
1901 DevelControl::SetLayout( hbox, hboxLayout );
1902 hbox.SetName( "HBox");
1904 std::vector< Control > controls;
1905 controls.push_back( CreateLeafControl( 40, 40 ) );
1906 controls.push_back( CreateLeafControl( 60, 40 ) );
1907 controls.push_back( CreateLeafControl( 80, 40 ) );
1908 controls.push_back( CreateLeafControl( 100, 40 ) );
1910 for( auto&& iter : controls )
1914 hbox.SetParentOrigin( ParentOrigin::CENTER );
1915 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1918 // Ensure layouting happens
1919 application.SendNotification();
1920 application.Render();
1922 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1923 // hbox left justifies elements
1924 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1925 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1926 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1927 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1929 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1930 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1931 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1932 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1934 controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
1935 controls[2].Lower(); // 2->1; 2, 1, 3, 0
1937 application.SendNotification();
1938 application.Render();
1940 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1941 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1942 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1943 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1945 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1946 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1947 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1948 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1953 int UtcDaliLayouting_HboxLayout_TargetSize(void)
1955 ToolkitTestApplication application;
1956 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
1958 Stage stage = Stage::GetCurrent();
1959 auto hbox = Control::New();
1960 auto hboxLayout = LinearLayout::New();
1961 DevelControl::SetLayout( hbox, hboxLayout );
1962 hbox.SetName( "HBox");
1964 std::vector< Control > controls;
1965 controls.push_back( CreateLeafControl( 40, 40 ) );
1966 for( auto&& iter : controls )
1968 iter.SetSize( 100, 100 );
1971 hbox.SetParentOrigin( ParentOrigin::CENTER );
1972 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1975 // Ensure layouting happens
1976 application.SendNotification();
1977 application.Render();
1979 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
1980 // hbox left justifies elements
1981 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1982 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1987 int UtcDaliLayouting_RemoveLayout01(void)
1989 ToolkitTestApplication application;
1990 tet_infoline(" UtcDaliLayouting_RemoveLayout");
1992 Stage stage = Stage::GetCurrent();
1994 auto rootControl = Control::New();
1995 auto absoluteLayout = AbsoluteLayout::New();
1996 DevelControl::SetLayout( rootControl, absoluteLayout );
1997 rootControl.SetName( "AbsoluteLayout" );
1998 stage.Add( rootControl );
2000 auto hbox = Control::New();
2001 auto hboxLayout = LinearLayout::New();
2002 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2003 DevelControl::SetLayout( hbox, hboxLayout );
2004 hbox.SetName( "HBox" );
2006 std::vector< Control > controls;
2007 controls.push_back( CreateLeafControl( 40, 40 ) );
2008 controls.push_back( CreateLeafControl( 60, 40 ) );
2010 for( auto&& iter : controls )
2014 hbox.SetParentOrigin( ParentOrigin::CENTER );
2015 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2016 rootControl.Add( hbox );
2018 tet_infoline("Layout as normal");
2019 application.SendNotification();
2020 application.Render();
2022 tet_infoline("Set an empty layout on hbox container");
2023 LinearLayout emptyLayout;
2024 DevelControl::SetLayout( hbox, emptyLayout );
2026 tet_infoline("Run another layout");
2027 application.SendNotification();
2028 application.Render();
2030 tet_infoline("Check leaf controls haven't moved");
2032 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2033 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2035 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2036 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2041 int UtcDaliLayouting_LayoutChildren01(void)
2043 ToolkitTestApplication application;
2044 tet_infoline(" UtcDaliLayouting_LayoutChildren01");
2046 Stage stage = Stage::GetCurrent();
2048 auto rootControl = Control::New();
2049 auto absoluteLayout = AbsoluteLayout::New();
2050 DevelControl::SetLayout( rootControl, absoluteLayout );
2051 stage.Add( rootControl );
2053 auto hbox = Control::New();
2054 auto hboxLayout = LinearLayout::New();
2055 DevelControl::SetLayout( hbox, hboxLayout );
2056 rootControl.Add( hbox );
2058 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2060 tet_infoline("Test removal by setting empty layout to child container" );
2061 DevelControl::SetLayout( hbox, LayoutItem{} );
2063 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2065 auto& hboxImpl = GetImplementation( hboxLayout );
2067 DALI_TEST_EQUALS( hboxLayout.GetOwner(), empty, TEST_LOCATION );
2068 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2071 hboxImpl.SetLayoutRequested();
2076 int UtcDaliLayouting_LayoutChildren02(void)
2078 ToolkitTestApplication application;
2079 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2081 Stage stage = Stage::GetCurrent();
2083 auto rootControl = Control::New();
2084 auto absoluteLayout = AbsoluteLayout::New();
2085 DevelControl::SetLayout( rootControl, absoluteLayout );
2086 stage.Add( rootControl );
2088 auto hbox = Control::New();
2089 auto hboxLayout = LinearLayout::New();
2090 DevelControl::SetLayout( hbox, hboxLayout );
2091 rootControl.Add( hbox );
2093 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2095 tet_infoline("Test removal by removing child actor from parent container" );
2098 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2100 auto& hboxImpl = GetImplementation( hboxLayout );
2101 tet_infoline("Test child actor still has hbox layout " );
2102 DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
2104 tet_infoline("Test hbox layout has no parent " );
2105 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2110 int UtcDaliLayouting_LayoutChildren03(void)
2112 ToolkitTestApplication application;
2113 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2115 Stage stage = Stage::GetCurrent();
2117 auto rootControl = Control::New();
2118 auto absoluteLayout = AbsoluteLayout::New();
2119 DevelControl::SetLayout( rootControl, absoluteLayout );
2120 stage.Add( rootControl );
2122 auto hbox = Control::New();
2123 auto hboxLayout = LinearLayout::New();
2124 DevelControl::SetLayout( hbox, hboxLayout );
2125 rootControl.Add( hbox );
2127 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2129 tet_infoline("Test removal by removing child layout from parent layout" );
2130 absoluteLayout.Remove( hboxLayout );
2132 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2134 auto& hboxImpl = GetImplementation( hboxLayout );
2136 tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
2137 DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
2138 DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
2140 tet_infoline("Check orphaned layout has no parent");
2141 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2147 int UtcDaliLayouting_LayoutChildren04(void)
2149 ToolkitTestApplication application;
2150 tet_infoline(" UtcDaliLayouting_LayoutChildren03");
2152 Stage stage = Stage::GetCurrent();
2154 auto rootControl = Control::New();
2155 auto absoluteLayout = AbsoluteLayout::New();
2156 DevelControl::SetLayout( rootControl, absoluteLayout );
2157 stage.Add( rootControl );
2159 auto hbox = Control::New();
2160 tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
2161 auto hboxLayout = LinearLayout::New();
2162 rootControl.Add( hbox );
2164 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2166 tet_infoline("Then setting a layout on the child container");
2167 DevelControl::SetLayout( hbox, hboxLayout );
2169 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2171 auto& hboxImpl = GetImplementation( hboxLayout );
2172 auto& absImpl = GetImplementation( absoluteLayout );
2173 DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
2174 DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
2179 int UtcDaliLayouting_SetLayoutOrder01(void)
2181 ToolkitTestApplication application;
2182 tet_infoline(" UtcDaliLayouting_SetLayoutOrder01 - Call SetLayout after adding the control to the root layout");
2184 Stage stage = Stage::GetCurrent();
2186 auto rootControl = Control::New();
2187 auto absoluteLayout = AbsoluteLayout::New();
2188 DevelControl::SetLayout( rootControl, absoluteLayout );
2189 rootControl.SetName( "AbsoluteLayout" );
2190 stage.Add( rootControl );
2192 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
2193 auto hbox = Control::New();
2194 auto hboxLayout = LinearLayout::New();
2195 hbox.SetName( "HBox");
2197 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
2198 rootControl.Add( hbox );
2200 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
2201 DevelControl::SetLayout( hbox, hboxLayout );
2203 // Add a Child control
2204 std::vector< Control > controls;
2205 controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
2206 for( auto&& iter : controls )
2211 // Ensure layouting happens
2212 application.SendNotification();
2213 application.Render();
2215 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2220 int UtcDaliLayouting_SetLayoutOrder02(void)
2222 ToolkitTestApplication application;
2223 tet_infoline(" UtcDaliLayouting_SetLayoutOrder02 - Test the layout item order and the control order");
2225 Stage stage = Stage::GetCurrent();
2227 auto rootControl = Control::New();
2228 auto absoluteLayout = AbsoluteLayout::New();
2229 DevelControl::SetLayout( rootControl, absoluteLayout );
2230 rootControl.SetName( "AbsoluteLayout" );
2231 stage.Add( rootControl );
2233 auto hbox = Control::New();
2234 auto hboxLayout = LinearLayout::New();
2235 hbox.SetName( "HBox");
2237 rootControl.Add( hbox );
2239 DevelControl::SetLayout( hbox, hboxLayout );
2241 // Add child controls
2242 std::vector< Control > controls;
2243 controls.push_back( CreateLeafControl( 100, 100 ) ); // 0
2244 controls.push_back( CreateLeafControl( 100, 100 ) ); // 1
2245 controls.push_back( CreateLeafControl( 100, 100 ) ); // 2
2247 for( auto&& iter : controls )
2252 // Ensure layouting happens
2253 application.SendNotification();
2254 application.Render();
2256 TestLayoutItemOrder( controls, hboxLayout );
2258 tet_infoline("RaiseToTop");
2260 controls[0].RaiseToTop(); // 1 2 0
2262 TestLayoutItemOrder( controls, hboxLayout );
2264 tet_infoline("LowerToBottom");
2266 controls[2].LowerToBottom(); // 2 1 0
2268 TestLayoutItemOrder( controls, hboxLayout );
2270 tet_infoline("Remove / Add");
2272 hbox.Remove( controls[2] ); // 1 0
2273 hbox.Add( controls[2] ); // 1 0 2
2275 TestLayoutItemOrder( controls, hboxLayout );
2277 tet_infoline("SetLayout");
2279 auto vboxLayout = LinearLayout::New();
2280 DevelControl::SetLayout( controls[0], vboxLayout );
2282 TestLayoutItemOrder( controls, hboxLayout );
2284 tet_infoline("Raise");
2286 controls[0].Raise(); // 1 2 0
2288 TestLayoutItemOrder( controls, hboxLayout );
2290 tet_infoline("Lower");
2292 controls[2].Lower(); // 2 1 0
2294 TestLayoutItemOrder( controls, hboxLayout );
2296 tet_infoline("SetLayout again");
2298 auto vboxLayout1 = LinearLayout::New();
2299 DevelControl::SetLayout( controls[2], vboxLayout1 );
2301 TestLayoutItemOrder( controls, hboxLayout );
2303 DevelControl::SetLayout( controls[2], vboxLayout );