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>
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali-toolkit/devel-api/controls/control-devel.h>
24 #include <dali-toolkit/devel-api/layouting/absolute-layout.h>
25 #include <dali-toolkit/devel-api/layouting/linear-layout.h>
26 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
27 #include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
29 #include <../custom-layout.h>
31 #include <layout-utils.h>
34 using namespace Toolkit;
36 void utc_dali_toolkit_layouting_startup(void)
38 test_return_value = TET_UNDEF;
41 void utc_dali_toolkit_layouting_cleanup(void)
43 test_return_value = TET_PASS;
46 int UtcDaliLayouting_HboxLayout01(void)
48 ToolkitTestApplication application;
49 tet_infoline(" UtcDaliLayouting_HboxLayout01");
51 Stage stage = Stage::GetCurrent();
52 auto hbox = Control::New();
53 auto hboxLayout = LinearLayout::New();
54 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
55 DevelControl::SetLayout( hbox, hboxLayout );
56 hbox.SetName( "HBox");
58 std::vector< Control > controls;
59 controls.push_back( CreateLeafControl( 40, 40 ) );
60 controls.push_back( CreateLeafControl( 60, 40 ) );
61 controls.push_back( CreateLeafControl( 80, 40 ) );
62 controls.push_back( CreateLeafControl( 100, 40 ) );
64 for( auto&& iter : controls )
68 hbox.SetParentOrigin( ParentOrigin::CENTER );
69 hbox.SetAnchorPoint( AnchorPoint::CENTER );
72 // Ensure layouting happens
73 application.SendNotification();
76 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
77 // hbox left justifies elements
78 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
79 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
80 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
81 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
83 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
84 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
85 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
86 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
89 auto newHBoxLayout = LinearLayout::New();
90 newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
91 DevelControl::SetLayout( hbox, newHBoxLayout );
93 application.SendNotification();
96 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
97 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
98 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
99 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
104 int UtcDaliLayouting_HboxLayout02(void)
106 ToolkitTestApplication application;
107 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
109 Stage stage = Stage::GetCurrent();
111 auto hbox1 = Control::New();
112 auto hboxLayout1 = LinearLayout::New();
113 DevelControl::SetLayout( hbox1, hboxLayout1 );
115 auto hbox2 = Control::New();
116 auto hboxLayout2 = LinearLayout::New();
117 DevelControl::SetLayout( hbox2, hboxLayout2 );
119 hbox1.SetName( "HBox1");
120 hbox2.SetName( "HBox2");
122 std::vector< Control > controls;
123 controls.push_back( CreateLeafControl( 20, 40 ) );
124 controls.push_back( CreateLeafControl( 30, 50 ) );
125 controls.push_back( CreateLeafControl( 40, 60 ) );
126 controls.push_back( CreateLeafControl( 50, 70 ) );
128 controls.push_back( CreateLeafControl( 25, 40 ) );
129 controls.push_back( CreateLeafControl( 35, 50 ) );
130 controls.push_back( CreateLeafControl( 45, 60 ) );
131 controls.push_back( CreateLeafControl( 55, 70 ) );
134 for( auto&& iter : controls )
146 hbox1.SetParentOrigin( ParentOrigin::CENTER );
147 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
148 hbox2.SetParentOrigin( ParentOrigin::CENTER );
149 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
151 auto hbox3 = Control::New();
152 auto hboxLayout3 = LinearLayout::New();
153 DevelControl::SetLayout( hbox3, hboxLayout3 );
155 hbox3.SetParentOrigin( ParentOrigin::CENTER );
156 hbox3.SetName( "HBox3");
162 // Ensure layouting happens
163 application.SendNotification();
164 application.Render();
167 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
168 // hbox left justifies elements
169 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
170 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
171 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
172 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
174 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
175 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
176 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
177 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
180 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
181 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
182 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
183 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
185 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
186 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
187 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
188 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
190 // Test hbox1 and 2 are sized to wrap their content
191 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
192 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
193 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
194 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
196 // Test hbox3 matches parent (root layer)
197 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
198 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
204 int UtcDaliLayouting_HboxLayout03(void)
206 ToolkitTestApplication application;
207 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
209 Stage stage = Stage::GetCurrent();
211 auto hbox1 = Control::New();
212 auto hboxLayout1 = LinearLayout::New();
213 DevelControl::SetLayout( hbox1, hboxLayout1 );
215 auto hbox2 = Control::New();
216 auto hboxLayout2 = LinearLayout::New();
217 DevelControl::SetLayout( hbox2, hboxLayout2 );
219 hbox1.SetName( "HBox1");
220 hbox2.SetName( "HBox2");
221 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
222 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
223 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
224 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
226 std::vector< Control > controls;
227 controls.push_back( CreateLeafControl( 20, 40 ) );
228 controls.push_back( CreateLeafControl( 30, 50 ) );
229 controls.push_back( CreateLeafControl( 40, 60 ) );
230 controls.push_back( CreateLeafControl( 50, 70 ) );
232 controls.push_back( CreateLeafControl( 25, 40 ) );
233 controls.push_back( CreateLeafControl( 35, 50 ) );
234 controls.push_back( CreateLeafControl( 45, 60 ) );
235 controls.push_back( CreateLeafControl( 55, 70 ) );
238 for( auto&& iter : controls )
250 hbox1.SetParentOrigin( ParentOrigin::CENTER );
251 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
252 hbox2.SetParentOrigin( ParentOrigin::CENTER );
253 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
255 auto hbox3 = Control::New();
256 auto hboxLayout3 = LinearLayout::New();
257 DevelControl::SetLayout( hbox3, hboxLayout3);
259 hbox3.SetParentOrigin( ParentOrigin::CENTER );
260 hbox3.SetName( "HBox3");
266 //std::ostringstream oss;
267 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
268 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
270 // Ensure layouting happens
271 application.SendNotification();
272 application.Render();
275 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
276 // hbox left justifies elements
277 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
278 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
279 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
280 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
282 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
283 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
284 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
285 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
287 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
288 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
289 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
290 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
292 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
293 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
294 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
295 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
297 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
298 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
299 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
300 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
302 // Test hbox3 matches parent (root layer)
303 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
304 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
309 int UtcDaliLayouting_HboxLayout04(void)
311 ToolkitTestApplication application;
312 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
314 Stage stage = Stage::GetCurrent();
316 auto hbox1 = Control::New();
317 auto hboxLayout1 = LinearLayout::New();
318 DevelControl::SetLayout( hbox1, hboxLayout1 );
320 auto hbox2 = Control::New();
321 auto hboxLayout2 = LinearLayout::New();
322 DevelControl::SetLayout( hbox2, hboxLayout2 );
324 hbox1.SetName( "HBox1"); // Default spec is to wrap content
325 hbox2.SetName( "HBox2");
326 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
327 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
328 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
329 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
331 std::vector< Control > controls;
332 controls.push_back( CreateLeafControl( 80, 40 ) );
333 controls.push_back( CreateLeafControl( 80, 50 ) );
334 controls.push_back( CreateLeafControl( 80, 60 ) );
335 controls.push_back( CreateLeafControl( 80, 70 ) );
337 controls.push_back( CreateLeafControl( 80, 40 ) );
338 controls.push_back( CreateLeafControl( 80, 50 ) );
339 controls.push_back( CreateLeafControl( 80, 60 ) );
340 controls.push_back( CreateLeafControl( 80, 70 ) );
343 for( auto&& iter : controls )
356 controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
357 auto hbox3 = Control::New();
358 auto hboxLayout3 = LinearLayout::New();
359 DevelControl::SetLayout( hbox3, hboxLayout3 );
361 hbox3.SetParentOrigin( ParentOrigin::CENTER );
362 hbox3.SetName( "HBox3");
367 //std::ostringstream oss;
368 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
369 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
371 // Ensure layouting happens
372 application.SendNotification();
373 application.Render();
376 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
377 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
378 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
379 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
381 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
382 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
383 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
384 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
386 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
387 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
388 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
389 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
391 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
392 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
393 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
394 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
396 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
397 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
398 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
399 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
402 // Test hbox3 matches parent (root layer)
403 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
404 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
409 int UtcDaliLayouting_HboxLayout05(void)
411 ToolkitTestApplication application;
412 tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
414 Stage stage = Stage::GetCurrent();
415 auto hbox = Control::New();
416 auto hboxLayout = LinearLayout::New();
417 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
418 DevelControl::SetLayout( hbox, hboxLayout );
419 hbox.SetName( "HBox");
421 std::vector< Control > controls;
422 controls.push_back( CreateLeafControl( 40, 40 ) );
423 controls.push_back( CreateLeafControl( 60, 40 ) );
424 controls.push_back( CreateLeafControl( 80, 40 ) );
425 controls.push_back( CreateLeafControl( 100, 40 ) );
427 for( auto&& iter : controls )
430 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
431 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
434 hbox.SetParentOrigin( ParentOrigin::CENTER );
435 hbox.SetAnchorPoint( AnchorPoint::CENTER );
438 // Ensure layouting happens
439 application.SendNotification();
440 application.Render();
442 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
443 // hbox left justifies elements
444 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
445 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
446 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
447 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
449 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
450 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
451 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
452 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
457 int UtcDaliLayouting_HboxLayout06(void)
459 ToolkitTestApplication application;
460 tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
462 Stage stage = Stage::GetCurrent();
464 auto rootControl = Control::New();
465 auto absoluteLayout = AbsoluteLayout::New();
466 DevelControl::SetLayout( rootControl, absoluteLayout );
467 rootControl.SetName( "AbsoluteLayout" );
468 stage.Add( rootControl );
470 auto hbox = Control::New();
471 auto hboxLayout = LinearLayout::New();
472 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
473 DevelControl::SetLayout( hbox, hboxLayout );
474 hbox.SetName( "HBox" );
476 std::vector< Control > controls;
477 controls.push_back( CreateLeafControl( 40, 40 ) );
478 controls.push_back( CreateLeafControl( 60, 40 ) );
480 for( auto&& iter : controls )
484 hbox.SetParentOrigin( ParentOrigin::CENTER );
485 hbox.SetAnchorPoint( AnchorPoint::CENTER );
486 rootControl.Add( hbox );
488 // Ensure layouting happens
489 application.SendNotification();
490 application.Render();
492 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
493 // hbox left justifies elements
494 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
495 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
497 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
498 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
500 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
503 auto newHBoxLayout = LinearLayout::New();
504 newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
505 DevelControl::SetLayout( hbox, newHBoxLayout );
507 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
508 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
510 application.SendNotification();
511 application.Render();
513 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
515 // Change size specification
516 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
517 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
519 application.SendNotification();
520 application.Render();
522 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
524 // Use WRAP_CONTENT again
525 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
526 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
528 application.SendNotification();
529 application.Render();
531 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
537 int UtcDaliLayouting_HboxLayout07(void)
539 ToolkitTestApplication application;
540 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
542 Stage stage = Stage::GetCurrent();
543 auto hbox = Control::New();
544 auto hboxLayout = LinearLayout::New();
545 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
546 DevelControl::SetLayout( hbox, hboxLayout );
547 hbox.SetName( "HBox");
549 std::vector< Control > controls;
550 controls.push_back( CreateLeafControl( 40, 40 ) );
551 controls.push_back( CreateLeafControl( 60, 40 ) );
552 controls.push_back( CreateLeafControl( 80, 40 ) );
553 controls.push_back( CreateLeafControl( 100, 40 ) );
555 for( auto&& iter : controls )
559 hbox.SetParentOrigin( ParentOrigin::CENTER );
560 hbox.SetAnchorPoint( AnchorPoint::CENTER );
563 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
565 // Ensure layouting happens
566 application.SendNotification();
567 application.Render();
569 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
570 // hbox left justifies elements
571 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
572 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
573 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
574 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
576 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
577 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
578 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
579 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
581 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
583 // Ensure layouting happens
584 application.SendNotification();
585 application.Render();
587 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
588 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
589 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
590 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
592 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
593 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
594 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
595 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
600 int UtcDaliLayouting_HboxLayout08(void)
602 ToolkitTestApplication application;
603 tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation");
605 Stage stage = Stage::GetCurrent();
607 auto rootControl = Control::New();
608 auto absoluteLayout = AbsoluteLayout::New();
609 absoluteLayout.SetAnimateLayout( true );
610 DevelControl::SetLayout( rootControl, absoluteLayout );
611 rootControl.SetName( "AbsoluteLayout" );
612 stage.Add( rootControl );
614 Control control1 = CreateLeafControl( 40, 40 );
615 rootControl.Add( control1 );
617 auto hbox = Control::New();
618 auto hboxLayout = LinearLayout::New();
619 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
620 DevelControl::SetLayout( hbox, hboxLayout );
621 hbox.SetName( "HBox" );
623 Control control2 = CreateLeafControl( 40, 40 );
624 hbox.Add( control2 );
626 hbox.SetParentOrigin( ParentOrigin::CENTER );
627 hbox.SetAnchorPoint( AnchorPoint::CENTER );
628 rootControl.Add( hbox );
630 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION );
631 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION );
632 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION );
633 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION );
635 hboxLayout.SetAnimateLayout( true );
636 absoluteLayout.SetAnimateLayout( false );
638 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION );
639 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION );
640 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION );
641 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION );
648 int UtcDaliLayouting_HboxLayout_Padding01(void)
650 ToolkitTestApplication application;
651 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
653 Stage stage = Stage::GetCurrent();
654 auto hbox = Control::New();
655 auto hboxLayout = LinearLayout::New();
656 DevelControl::SetLayout( hbox, hboxLayout );
657 hbox.SetName( "HBox");
659 std::vector< Control > controls;
660 controls.push_back( CreateLeafControl( 40, 40 ) );
661 controls.push_back( CreateLeafControl( 60, 40 ) );
662 controls.push_back( CreateLeafControl( 80, 40 ) );
663 controls.push_back( CreateLeafControl( 100, 40 ) );
665 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
666 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
667 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
669 for( auto&& iter : controls )
673 hbox.SetParentOrigin( ParentOrigin::CENTER );
674 hbox.SetAnchorPoint( AnchorPoint::CENTER );
677 // Ensure layouting happens
678 application.SendNotification();
679 application.Render();
681 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
682 // hbox left justifies elements
683 tet_infoline("Test Child Actor Position");
684 float xPositionOfControlBeingTested = 0.0f;
685 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
687 0.0f ), 0.0001f, TEST_LOCATION );
688 xPositionOfControlBeingTested += 40.0f;
690 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
691 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
692 0.0001f, TEST_LOCATION );
694 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
695 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
697 xPositionOfControlBeingTested += 80.0f;
698 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
700 tet_infoline("Test Child Actor Size");
701 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
703 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
704 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
705 0.0001f, TEST_LOCATION );
707 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
708 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
713 int UtcDaliLayouting_HboxLayout_Padding02(void)
715 ToolkitTestApplication application;
716 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
718 Stage stage = Stage::GetCurrent();
719 auto hbox = Control::New();
720 auto hboxLayout = LinearLayout::New();
721 DevelControl::SetLayout( hbox, hboxLayout );
722 hbox.SetName( "HBox");
724 std::vector< Control > controls;
725 controls.push_back( CreateLeafControl( 40, 40 ) );
726 controls.push_back( CreateLeafControl( 60, 40 ) );
727 controls.push_back( CreateLeafControl( 80, 40 ) );
728 controls.push_back( CreateLeafControl( 100, 40 ) );
730 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
732 for( auto&& iter : controls )
734 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
737 hbox.SetParentOrigin( ParentOrigin::CENTER );
738 hbox.SetAnchorPoint( AnchorPoint::CENTER );
741 // Ensure layouting happens
742 application.SendNotification();
743 application.Render();
745 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
746 // hbox left justifies elements
747 tet_infoline("Test Child Actor Position");
748 float xPositionOfControlBeingTested = 0.0f;
749 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
751 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
752 yPositionOfControlBeingTested,
753 0.0f ), 0.0001f, TEST_LOCATION );
754 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
756 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
757 yPositionOfControlBeingTested,
759 0.0001f, TEST_LOCATION );
761 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
762 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
763 yPositionOfControlBeingTested,
764 0.0f ), 0.0001f, TEST_LOCATION );
766 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
767 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
768 yPositionOfControlBeingTested,
769 0.0f ), 0.0001f, TEST_LOCATION );
771 tet_infoline("Test Child Actor Size");
772 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
773 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
774 0.0f ), 0.0001f, TEST_LOCATION );
776 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
777 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
778 0.0f ), 0.0001f, TEST_LOCATION );
780 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
781 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
782 0.0f ), 0.0001f, TEST_LOCATION );
784 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
785 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
786 0.0f ), 0.0001f, TEST_LOCATION );
792 int UtcDaliLayouting_HboxLayout_Padding03(void)
794 ToolkitTestApplication application;
795 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
797 Stage stage = Stage::GetCurrent();
798 auto hbox = Control::New();
799 auto hboxLayout = LinearLayout::New();
800 DevelControl::SetLayout( hbox, hboxLayout );
801 hbox.SetName( "HBox");
803 std::vector< Control > controls;
804 controls.push_back( CreateLeafControl( 40, 40 ) );
805 controls.push_back( CreateLeafControl( 40, 40 ) );
806 controls.push_back( CreateLeafControl( 40, 40 ) );
808 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
809 tet_printf( "\nAdding Padding to control at index 1 \n" );
810 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
812 for( auto&& iter : controls )
816 hbox.SetParentOrigin( ParentOrigin::CENTER );
817 hbox.SetAnchorPoint( AnchorPoint::CENTER );
820 // Ensure layouting happens
821 application.SendNotification();
822 application.Render();
824 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
825 // hbox left justifies elements
826 tet_infoline("Test Child Actor Position");
827 float xPositionOfControlBeingTested = 0.0f;
828 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
830 0.0f ), 0.0001f, TEST_LOCATION );
831 xPositionOfControlBeingTested += 40.0f;
833 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
834 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
835 0.0001f, TEST_LOCATION );
837 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
838 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
840 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
841 tet_printf( "\nChanging Padding to control at index 1 \n" );
842 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
844 // Ensure layouting happens
845 application.SendNotification();
846 application.Render();
848 xPositionOfControlBeingTested = 0.0f; // reset
850 tet_infoline("Test Child Actor Position");
851 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
853 0.0f ), 0.0001f, TEST_LOCATION );
854 xPositionOfControlBeingTested += 40.0f;
856 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
857 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
858 0.0001f, TEST_LOCATION );
860 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
861 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
862 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
864 tet_infoline("Test Child Actor Size");
865 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
867 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
868 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
869 0.0001f, TEST_LOCATION );
871 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
876 int UtcDaliLayouting_HboxLayout_Padding04(void)
878 ToolkitTestApplication application;
879 tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
881 // Adding padding to the layout should offset the positioning of the children.
883 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
884 const Size CONTROL_SIZE = Size( 40, 40 );
886 Stage stage = Stage::GetCurrent();
887 // Create a root layout, ideally Dali would have a default layout in the root layer.
888 // Without this root layer the LinearLayout (or any other layout) will not
889 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
890 // It uses the default stage size and ideally should have a layout added to it.
891 auto rootLayoutControl = Control::New();
892 rootLayoutControl.SetName( "AbsoluteLayout");
893 auto rootLayout = AbsoluteLayout::New();
894 DevelControl::SetLayout( rootLayoutControl, rootLayout );
895 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
896 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
897 stage.Add( rootLayoutControl );
899 auto hbox = Control::New();
900 auto hboxLayout = LinearLayout::New();
901 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
902 DevelControl::SetLayout( hbox, hboxLayout );
903 hbox.SetName( "HBox");
904 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
905 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
906 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
908 std::vector< Control > controls;
909 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
910 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
911 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
912 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
914 for( auto&& iter : controls )
919 hbox.SetParentOrigin( ParentOrigin::CENTER );
920 hbox.SetAnchorPoint( AnchorPoint::CENTER );
921 rootLayoutControl.Add( hbox );
923 // Ensure layouting happens
924 application.SendNotification();
925 application.Render();
927 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
928 application.SendNotification();
930 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
931 // hbox left justifies elements
932 tet_infoline("Test Child Actor Position");
934 auto controlXPosition=0.0f;
936 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
937 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
939 0.0f ), 0.0001f, TEST_LOCATION );
941 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
942 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
945 0.0001f, TEST_LOCATION );
947 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
948 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
950 0.0f ), 0.0001f, TEST_LOCATION );
952 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
953 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
955 0.0f ), 0.0001f, TEST_LOCATION );
957 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
958 auto totalControlsHeight = CONTROL_SIZE.height;
960 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
961 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
962 0.0f ), 0.0001f, TEST_LOCATION );
968 int UtcDaliLayouting_HboxLayout_Padding05(void)
970 ToolkitTestApplication application;
971 tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
973 // Adding padding to the layout should offset the positioning of the children.
975 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
976 const Size CONTROL_SIZE = Size( 40, 40 );
978 Stage stage = Stage::GetCurrent();
979 // Create a root layout, ideally Dali would have a default layout in the root layer.
980 // Without this root layer the LinearLayout (or any other layout) will not
981 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
982 // It uses the default stage size and ideally should have a layout added to it.
983 auto rootLayoutControl = Control::New();
984 rootLayoutControl.SetName( "AbsoluteLayout");
985 auto rootLayout = AbsoluteLayout::New();
986 DevelControl::SetLayout( rootLayoutControl, rootLayout );
987 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
988 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
989 stage.Add( rootLayoutControl );
991 auto hbox = Control::New();
992 auto hboxLayout = LinearLayout::New();
993 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
994 DevelControl::SetLayout( hbox, hboxLayout );
995 hbox.SetName( "HBox");
996 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
997 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
998 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1000 std::vector< Control > controls;
1001 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1002 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1003 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1004 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1006 for( auto&& iter : controls )
1011 hbox.SetParentOrigin( ParentOrigin::CENTER );
1012 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1013 rootLayoutControl.Add( hbox );
1015 // Ensure layouting happens
1016 application.SendNotification();
1017 application.Render();
1019 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1020 application.SendNotification();
1022 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1023 // hbox left justifies elements
1024 tet_infoline("Test Child Actor Position");
1026 auto controlXPosition=0.0f;
1028 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1029 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1031 0.0f ), 0.0001f, TEST_LOCATION );
1033 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1034 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1037 0.0001f, TEST_LOCATION );
1039 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1040 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1042 0.0f ), 0.0001f, TEST_LOCATION );
1044 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1045 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1047 0.0f ), 0.0001f, TEST_LOCATION );
1049 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1050 auto totalControlsHeight = CONTROL_SIZE.height;
1052 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1053 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1054 0.0f ), 0.0001f, TEST_LOCATION );
1056 // Change layout padding
1057 const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
1058 tet_printf( "\nChanging Padding to control at index 1 \n" );
1059 hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
1061 // Ensure layouting happens
1062 application.SendNotification();
1063 application.Render();
1065 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1066 application.SendNotification();
1068 controlXPosition = NEW_LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1069 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
1070 NEW_LAYOUT_PADDING.top,
1071 0.0f ), 0.0001f, TEST_LOCATION );
1073 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1074 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1075 NEW_LAYOUT_PADDING.top,
1077 0.0001f, TEST_LOCATION );
1079 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1080 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1081 NEW_LAYOUT_PADDING.top,
1082 0.0f ), 0.0001f, TEST_LOCATION );
1084 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1085 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1086 NEW_LAYOUT_PADDING.top,
1087 0.0f ), 0.0001f, TEST_LOCATION );
1088 totalControlsWidth = CONTROL_SIZE.width * controls.size();
1089 totalControlsHeight = CONTROL_SIZE.height;
1091 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
1092 totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
1093 0.0f ), 0.0001f, TEST_LOCATION );
1099 int UtcDaliLayouting_HboxLayout_Margin01(void)
1101 ToolkitTestApplication application;
1102 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
1104 Stage stage = Stage::GetCurrent();
1105 auto hbox = Control::New();
1106 auto hboxLayout = LinearLayout::New();
1107 DevelControl::SetLayout( hbox, hboxLayout );
1108 hbox.SetName( "HBox");
1110 std::vector< Control > controls;
1111 controls.push_back( CreateLeafControl( 40, 40 ) );
1112 controls.push_back( CreateLeafControl( 60, 40 ) );
1113 controls.push_back( CreateLeafControl( 80, 40 ) );
1114 controls.push_back( CreateLeafControl( 100, 40 ) );
1116 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
1117 tet_printf( "\nAdding Margin to control at index 1 \n" );
1118 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1120 for( auto&& iter : controls )
1124 hbox.SetParentOrigin( ParentOrigin::CENTER );
1125 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1128 // Ensure layouting happens
1129 application.SendNotification();
1130 application.Render();
1132 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1133 // hbox left justifies elements
1134 tet_infoline("Test Child Actor Position");
1135 auto xPositionOfControlBeingTested = 0.0f;
1136 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1138 0.0f ), 0.0001f, TEST_LOCATION );
1139 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
1141 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1142 380.0f + CONTROL_MARGIN.top, 0.0f ),
1143 0.0001f, TEST_LOCATION );
1145 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
1146 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1148 xPositionOfControlBeingTested += 80.0f;
1149 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1151 tet_infoline("Test Child Actor Size is the same after Margin added");
1152 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1153 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
1154 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1155 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1161 int UtcDaliLayouting_VboxLayout01(void)
1163 ToolkitTestApplication application;
1164 tet_infoline(" UtcDaliLayouting_VboxLayout01");
1166 Stage stage = Stage::GetCurrent();
1167 auto vbox = Control::New();
1168 auto vboxLayout = LinearLayout::New();
1169 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1170 DevelControl::SetLayout( vbox, vboxLayout );
1171 vbox.SetName( "Vbox");
1173 std::vector< Control > controls;
1174 controls.push_back( CreateLeafControl( 40, 40 ) );
1175 controls.push_back( CreateLeafControl( 60, 60 ) );
1176 controls.push_back( CreateLeafControl( 80, 80 ) );
1177 controls.push_back( CreateLeafControl( 100, 100 ) );
1179 for( auto&& iter : controls )
1183 vbox.SetParentOrigin( ParentOrigin::CENTER );
1184 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1187 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1190 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1192 // Ensure layouting happens
1193 application.SendNotification();
1194 application.Render();
1196 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
1197 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1198 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1199 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1200 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1202 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1203 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1204 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1205 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1210 int UtcDaliLayouting_VboxLayout02(void)
1212 ToolkitTestApplication application;
1213 tet_infoline(" UtcDaliLayouting_VboxLayout01");
1215 Stage stage = Stage::GetCurrent();
1217 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1218 // LayoutGroup for this to happen automatically.
1220 // For this test, add an hbox instead
1221 auto rootControl = Control::New();
1222 auto absoluteLayout = AbsoluteLayout::New();
1223 DevelControl::SetLayout( rootControl, absoluteLayout );
1224 rootControl.SetName( "AbsoluteLayout");
1225 stage.Add( rootControl );
1227 auto vbox = Control::New();
1228 auto vboxLayout = LinearLayout::New();
1229 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1230 DevelControl::SetLayout( vbox, vboxLayout );
1231 vbox.SetName( "Vbox");
1232 rootControl.Add( vbox );
1234 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1235 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1237 std::vector< Control > controls;
1238 controls.push_back( CreateLeafControl( 40, 40 ) );
1239 controls.push_back( CreateLeafControl( 60, 60 ) );
1240 controls.push_back( CreateLeafControl( 80, 80 ) );
1241 controls.push_back( CreateLeafControl( 100, 100 ) );
1243 for( auto&& iter : controls )
1247 vbox.SetParentOrigin( ParentOrigin::CENTER );
1248 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1250 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1253 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1255 // Ensure layouting happens
1256 application.SendNotification();
1257 application.Render();
1259 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1260 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1262 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1263 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1264 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1266 // 3rd control is set to match parent - this should also be 100 wide
1267 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1268 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1269 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1270 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1272 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1273 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1274 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1275 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1281 int UtcDaliLayouting_VboxLayout03(void)
1283 ToolkitTestApplication application;
1284 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
1286 Stage stage = Stage::GetCurrent();
1288 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1289 // LayoutGroup for this to happen automatically.
1291 // For this test, add an hbox instead
1292 auto hbox = Control::New();
1293 auto hboxLayout = LinearLayout::New();
1294 DevelControl::SetLayout( hbox, hboxLayout );
1295 hbox.SetName( "Hbox");
1298 auto vbox = Control::New();
1299 auto vboxLayout = LinearLayout::New();
1300 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
1301 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1303 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
1305 DevelControl::SetLayout( vbox, vboxLayout );
1306 vbox.SetName( "Vbox");
1309 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1310 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1312 std::vector< Control > controls;
1313 controls.push_back( CreateLeafControl( 40, 40 ) );
1314 controls.push_back( CreateLeafControl( 60, 60 ) );
1315 controls.push_back( CreateLeafControl( 80, 80 ) );
1316 controls.push_back( CreateLeafControl( 100, 100 ) );
1318 for( auto&& iter : controls )
1322 vbox.SetParentOrigin( ParentOrigin::CENTER );
1323 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1325 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1328 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1330 // Ensure layouting happens
1331 application.SendNotification();
1332 application.Render();
1334 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1335 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1337 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1338 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1339 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1341 // 3rd control is set to match parent - this should also be 100 wide
1342 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1343 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1344 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1345 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1347 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1348 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1349 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1350 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1357 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
1359 ToolkitTestApplication application;
1360 tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
1361 tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
1363 Stage stage = Stage::GetCurrent();
1365 auto hbox = Control::New();
1366 auto hboxLayout = Test::CustomLayout::New();
1367 DevelControl::SetLayout( hbox, hboxLayout );
1368 hbox.SetName( "HBox");
1370 std::vector< Control > controls;
1371 controls.push_back( CreateLeafControl( 40, 40 ) );
1372 controls.push_back( CreateLeafControl( 60, 40 ) );
1373 controls.push_back( CreateLeafControl( 80, 40 ) );
1374 controls.push_back( CreateLeafControl( 100, 40 ) );
1376 for( auto&& iter : controls )
1380 hbox.SetParentOrigin( ParentOrigin::CENTER );
1381 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1384 // Ensure layouting happens
1385 application.SendNotification();
1386 application.Render();
1388 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1389 // hbox left justifies elements
1390 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1391 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1392 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1393 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1395 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1396 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1397 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1398 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1400 controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
1401 controls[2].Lower(); // 2->1; 2, 1, 3, 0
1403 application.SendNotification();
1404 application.Render();
1406 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1407 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1408 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1409 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1411 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1412 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1413 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1414 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1419 int UtcDaliLayouting_HboxLayout_TargetSize(void)
1421 ToolkitTestApplication application;
1422 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
1424 Stage stage = Stage::GetCurrent();
1425 auto hbox = Control::New();
1426 auto hboxLayout = LinearLayout::New();
1427 DevelControl::SetLayout( hbox, hboxLayout );
1428 hbox.SetName( "HBox");
1430 std::vector< Control > controls;
1431 controls.push_back( CreateLeafControl( 40, 40 ) );
1432 for( auto&& iter : controls )
1434 iter.SetSize( 100, 100 );
1437 hbox.SetParentOrigin( ParentOrigin::CENTER );
1438 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1441 // Ensure layouting happens
1442 application.SendNotification();
1443 application.Render();
1445 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
1446 // hbox left justifies elements
1447 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1448 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1453 int UtcDaliLayouting_RemoveLayout01(void)
1455 ToolkitTestApplication application;
1456 tet_infoline(" UtcDaliLayouting_RemoveLayout");
1458 Stage stage = Stage::GetCurrent();
1460 auto rootControl = Control::New();
1461 auto absoluteLayout = AbsoluteLayout::New();
1462 DevelControl::SetLayout( rootControl, absoluteLayout );
1463 rootControl.SetName( "AbsoluteLayout" );
1464 stage.Add( rootControl );
1466 auto hbox = Control::New();
1467 auto hboxLayout = LinearLayout::New();
1468 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1469 DevelControl::SetLayout( hbox, hboxLayout );
1470 hbox.SetName( "HBox" );
1472 std::vector< Control > controls;
1473 controls.push_back( CreateLeafControl( 40, 40 ) );
1474 controls.push_back( CreateLeafControl( 60, 40 ) );
1476 for( auto&& iter : controls )
1480 hbox.SetParentOrigin( ParentOrigin::CENTER );
1481 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1482 rootControl.Add( hbox );
1484 tet_infoline("Layout as normal");
1485 application.SendNotification();
1486 application.Render();
1488 tet_infoline("Set an empty layout on hbox container");
1489 LinearLayout emptyLayout;
1490 DevelControl::SetLayout( hbox, emptyLayout );
1492 tet_infoline("Run another layout");
1493 application.SendNotification();
1494 application.Render();
1496 tet_infoline("Check leaf controls haven't moved");
1498 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1499 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1501 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1502 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1507 int UtcDaliLayouting_LayoutChildren01(void)
1509 ToolkitTestApplication application;
1510 tet_infoline(" UtcDaliLayouting_LayoutChildren01");
1512 Stage stage = Stage::GetCurrent();
1514 auto rootControl = Control::New();
1515 auto absoluteLayout = AbsoluteLayout::New();
1516 DevelControl::SetLayout( rootControl, absoluteLayout );
1517 stage.Add( rootControl );
1519 auto hbox = Control::New();
1520 auto hboxLayout = LinearLayout::New();
1521 DevelControl::SetLayout( hbox, hboxLayout );
1522 rootControl.Add( hbox );
1524 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1526 tet_infoline("Test removal by setting empty layout to child container" );
1527 DevelControl::SetLayout( hbox, LayoutItem{} );
1529 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
1531 auto& hboxImpl = GetImplementation( hboxLayout );
1533 DALI_TEST_EQUALS( hboxLayout.GetOwner(), empty, TEST_LOCATION );
1534 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
1539 int UtcDaliLayouting_LayoutChildren02(void)
1541 ToolkitTestApplication application;
1542 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
1544 Stage stage = Stage::GetCurrent();
1546 auto rootControl = Control::New();
1547 auto absoluteLayout = AbsoluteLayout::New();
1548 DevelControl::SetLayout( rootControl, absoluteLayout );
1549 stage.Add( rootControl );
1551 auto hbox = Control::New();
1552 auto hboxLayout = LinearLayout::New();
1553 DevelControl::SetLayout( hbox, hboxLayout );
1554 rootControl.Add( hbox );
1556 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1558 tet_infoline("Test removal by removing child actor from parent container" );
1561 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
1563 auto& hboxImpl = GetImplementation( hboxLayout );
1564 tet_infoline("Test child actor still has hbox layout " );
1565 DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
1567 tet_infoline("Test hbox layout has no parent " );
1568 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
1573 int UtcDaliLayouting_LayoutChildren03(void)
1575 ToolkitTestApplication application;
1576 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
1578 Stage stage = Stage::GetCurrent();
1580 auto rootControl = Control::New();
1581 auto absoluteLayout = AbsoluteLayout::New();
1582 DevelControl::SetLayout( rootControl, absoluteLayout );
1583 stage.Add( rootControl );
1585 auto hbox = Control::New();
1586 auto hboxLayout = LinearLayout::New();
1587 DevelControl::SetLayout( hbox, hboxLayout );
1588 rootControl.Add( hbox );
1590 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1592 tet_infoline("Test removal by removing child layout from parent layout" );
1593 absoluteLayout.Remove( hboxLayout );
1595 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
1597 auto& hboxImpl = GetImplementation( hboxLayout );
1599 tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
1600 DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
1601 DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
1603 tet_infoline("Check orphaned layout has no parent");
1604 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
1610 int UtcDaliLayouting_LayoutChildren04(void)
1612 ToolkitTestApplication application;
1613 tet_infoline(" UtcDaliLayouting_LayoutChildren03");
1615 Stage stage = Stage::GetCurrent();
1617 auto rootControl = Control::New();
1618 auto absoluteLayout = AbsoluteLayout::New();
1619 DevelControl::SetLayout( rootControl, absoluteLayout );
1620 stage.Add( rootControl );
1622 auto hbox = Control::New();
1623 tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
1624 auto hboxLayout = LinearLayout::New();
1625 rootControl.Add( hbox );
1627 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1629 tet_infoline("Then setting a layout on the child container");
1630 DevelControl::SetLayout( hbox, hboxLayout );
1632 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1634 auto& hboxImpl = GetImplementation( hboxLayout );
1635 auto& absImpl = GetImplementation( absoluteLayout );
1636 DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
1637 DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );