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>
27 #include <layout-utils.h>
30 using namespace Toolkit;
32 void utc_dali_toolkit_layouting_startup(void)
34 test_return_value = TET_UNDEF;
37 void utc_dali_toolkit_layouting_cleanup(void)
39 test_return_value = TET_PASS;
42 int UtcDaliLayouting_HboxLayout01(void)
44 ToolkitTestApplication application;
45 tet_infoline(" UtcDaliLayouting_HboxLayout01");
47 Stage stage = Stage::GetCurrent();
48 auto hbox = Control::New();
49 auto hboxLayout = LinearLayout::New();
50 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
51 DevelControl::SetLayout( hbox, hboxLayout );
52 hbox.SetName( "HBox");
54 std::vector< Control > controls;
55 controls.push_back( CreateLeafControl( 40, 40 ) );
56 controls.push_back( CreateLeafControl( 60, 40 ) );
57 controls.push_back( CreateLeafControl( 80, 40 ) );
58 controls.push_back( CreateLeafControl( 100, 40 ) );
60 for( auto&& iter : controls )
64 hbox.SetParentOrigin( ParentOrigin::CENTER );
65 hbox.SetAnchorPoint( AnchorPoint::CENTER );
68 // Ensure layouting happens
69 application.SendNotification();
72 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
73 // hbox left justifies elements
74 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
75 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
76 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
77 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
79 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
80 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
81 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
82 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
85 auto newHBoxLayout = LinearLayout::New();
86 newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
87 DevelControl::SetLayout( hbox, newHBoxLayout );
89 application.SendNotification();
92 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
93 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
94 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
95 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
100 int UtcDaliLayouting_HboxLayout02(void)
102 ToolkitTestApplication application;
103 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
105 Stage stage = Stage::GetCurrent();
107 auto hbox1 = Control::New();
108 auto hboxLayout1 = LinearLayout::New();
109 DevelControl::SetLayout( hbox1, hboxLayout1 );
111 auto hbox2 = Control::New();
112 auto hboxLayout2 = LinearLayout::New();
113 DevelControl::SetLayout( hbox2, hboxLayout2 );
115 hbox1.SetName( "HBox1");
116 hbox2.SetName( "HBox2");
118 std::vector< Control > controls;
119 controls.push_back( CreateLeafControl( 20, 40 ) );
120 controls.push_back( CreateLeafControl( 30, 50 ) );
121 controls.push_back( CreateLeafControl( 40, 60 ) );
122 controls.push_back( CreateLeafControl( 50, 70 ) );
124 controls.push_back( CreateLeafControl( 25, 40 ) );
125 controls.push_back( CreateLeafControl( 35, 50 ) );
126 controls.push_back( CreateLeafControl( 45, 60 ) );
127 controls.push_back( CreateLeafControl( 55, 70 ) );
130 for( auto&& iter : controls )
142 hbox1.SetParentOrigin( ParentOrigin::CENTER );
143 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
144 hbox2.SetParentOrigin( ParentOrigin::CENTER );
145 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
147 auto hbox3 = Control::New();
148 auto hboxLayout3 = LinearLayout::New();
149 DevelControl::SetLayout( hbox3, hboxLayout3 );
151 hbox3.SetParentOrigin( ParentOrigin::CENTER );
152 hbox3.SetName( "HBox3");
158 // Ensure layouting happens
159 application.SendNotification();
160 application.Render();
163 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
164 // hbox left justifies elements
165 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
166 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
167 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
168 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
170 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
171 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
172 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
173 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
176 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
177 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
178 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
179 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
181 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
182 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
183 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
184 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
186 // Test hbox1 and 2 are sized to wrap their content
187 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
188 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
189 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
190 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
192 // Test hbox3 matches parent (root layer)
193 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
194 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
200 int UtcDaliLayouting_HboxLayout03(void)
202 ToolkitTestApplication application;
203 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
205 Stage stage = Stage::GetCurrent();
207 auto hbox1 = Control::New();
208 auto hboxLayout1 = LinearLayout::New();
209 DevelControl::SetLayout( hbox1, hboxLayout1 );
211 auto hbox2 = Control::New();
212 auto hboxLayout2 = LinearLayout::New();
213 DevelControl::SetLayout( hbox2, hboxLayout2 );
215 hbox1.SetName( "HBox1");
216 hbox2.SetName( "HBox2");
217 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
218 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
219 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
220 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
222 std::vector< Control > controls;
223 controls.push_back( CreateLeafControl( 20, 40 ) );
224 controls.push_back( CreateLeafControl( 30, 50 ) );
225 controls.push_back( CreateLeafControl( 40, 60 ) );
226 controls.push_back( CreateLeafControl( 50, 70 ) );
228 controls.push_back( CreateLeafControl( 25, 40 ) );
229 controls.push_back( CreateLeafControl( 35, 50 ) );
230 controls.push_back( CreateLeafControl( 45, 60 ) );
231 controls.push_back( CreateLeafControl( 55, 70 ) );
234 for( auto&& iter : controls )
246 hbox1.SetParentOrigin( ParentOrigin::CENTER );
247 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
248 hbox2.SetParentOrigin( ParentOrigin::CENTER );
249 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
251 auto hbox3 = Control::New();
252 auto hboxLayout3 = LinearLayout::New();
253 DevelControl::SetLayout( hbox3, hboxLayout3);
255 hbox3.SetParentOrigin( ParentOrigin::CENTER );
256 hbox3.SetName( "HBox3");
262 //std::ostringstream oss;
263 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
264 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
266 // Ensure layouting happens
267 application.SendNotification();
268 application.Render();
271 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
272 // hbox left justifies elements
273 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
274 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
275 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
276 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
278 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
279 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
280 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
281 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
283 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
284 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
285 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
286 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
288 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
289 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
290 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
291 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
293 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
294 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
295 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
296 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
298 // Test hbox3 matches parent (root layer)
299 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
300 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
305 int UtcDaliLayouting_HboxLayout04(void)
307 ToolkitTestApplication application;
308 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
310 Stage stage = Stage::GetCurrent();
312 auto hbox1 = Control::New();
313 auto hboxLayout1 = LinearLayout::New();
314 DevelControl::SetLayout( hbox1, hboxLayout1 );
316 auto hbox2 = Control::New();
317 auto hboxLayout2 = LinearLayout::New();
318 DevelControl::SetLayout( hbox2, hboxLayout2 );
320 hbox1.SetName( "HBox1"); // Default spec is to wrap content
321 hbox2.SetName( "HBox2");
322 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
323 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
324 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
325 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
327 std::vector< Control > controls;
328 controls.push_back( CreateLeafControl( 80, 40 ) );
329 controls.push_back( CreateLeafControl( 80, 50 ) );
330 controls.push_back( CreateLeafControl( 80, 60 ) );
331 controls.push_back( CreateLeafControl( 80, 70 ) );
333 controls.push_back( CreateLeafControl( 80, 40 ) );
334 controls.push_back( CreateLeafControl( 80, 50 ) );
335 controls.push_back( CreateLeafControl( 80, 60 ) );
336 controls.push_back( CreateLeafControl( 80, 70 ) );
339 for( auto&& iter : controls )
352 controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
353 auto hbox3 = Control::New();
354 auto hboxLayout3 = LinearLayout::New();
355 DevelControl::SetLayout( hbox3, hboxLayout3 );
357 hbox3.SetParentOrigin( ParentOrigin::CENTER );
358 hbox3.SetName( "HBox3");
363 //std::ostringstream oss;
364 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
365 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
367 // Ensure layouting happens
368 application.SendNotification();
369 application.Render();
372 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
373 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
374 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
375 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
377 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
378 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
379 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
380 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
382 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
383 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
384 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
385 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
387 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
388 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
389 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
390 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
392 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
393 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
394 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
395 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
398 // Test hbox3 matches parent (root layer)
399 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
400 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
405 int UtcDaliLayouting_HboxLayout05(void)
407 ToolkitTestApplication application;
408 tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
410 Stage stage = Stage::GetCurrent();
411 auto hbox = Control::New();
412 auto hboxLayout = LinearLayout::New();
413 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
414 DevelControl::SetLayout( hbox, hboxLayout );
415 hbox.SetName( "HBox");
417 std::vector< Control > controls;
418 controls.push_back( CreateLeafControl( 40, 40 ) );
419 controls.push_back( CreateLeafControl( 60, 40 ) );
420 controls.push_back( CreateLeafControl( 80, 40 ) );
421 controls.push_back( CreateLeafControl( 100, 40 ) );
423 for( auto&& iter : controls )
426 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
427 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
430 hbox.SetParentOrigin( ParentOrigin::CENTER );
431 hbox.SetAnchorPoint( AnchorPoint::CENTER );
434 // Ensure layouting happens
435 application.SendNotification();
436 application.Render();
438 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
439 // hbox left justifies elements
440 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
441 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
442 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
443 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
445 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
446 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
447 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
448 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
453 int UtcDaliLayouting_HboxLayout06(void)
455 ToolkitTestApplication application;
456 tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
458 Stage stage = Stage::GetCurrent();
460 auto rootControl = Control::New();
461 auto absoluteLayout = AbsoluteLayout::New();
462 DevelControl::SetLayout( rootControl, absoluteLayout );
463 rootControl.SetName( "AbsoluteLayout" );
464 stage.Add( rootControl );
466 auto hbox = Control::New();
467 auto hboxLayout = LinearLayout::New();
468 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
469 DevelControl::SetLayout( hbox, hboxLayout );
470 hbox.SetName( "HBox" );
472 std::vector< Control > controls;
473 controls.push_back( CreateLeafControl( 40, 40 ) );
474 controls.push_back( CreateLeafControl( 60, 40 ) );
476 for( auto&& iter : controls )
480 hbox.SetParentOrigin( ParentOrigin::CENTER );
481 hbox.SetAnchorPoint( AnchorPoint::CENTER );
482 rootControl.Add( hbox );
484 // Ensure layouting happens
485 application.SendNotification();
486 application.Render();
488 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
489 // hbox left justifies elements
490 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
491 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
493 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
494 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
496 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
499 auto newHBoxLayout = LinearLayout::New();
500 newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
501 DevelControl::SetLayout( hbox, newHBoxLayout );
503 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
504 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
506 application.SendNotification();
507 application.Render();
509 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
511 // Change size specification
512 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
513 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
515 application.SendNotification();
516 application.Render();
518 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
520 // Use WRAP_CONTENT again
521 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
522 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
524 application.SendNotification();
525 application.Render();
527 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
533 int UtcDaliLayouting_HboxLayout07(void)
535 ToolkitTestApplication application;
536 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
538 Stage stage = Stage::GetCurrent();
539 auto hbox = Control::New();
540 auto hboxLayout = LinearLayout::New();
541 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
542 DevelControl::SetLayout( hbox, hboxLayout );
543 hbox.SetName( "HBox");
545 std::vector< Control > controls;
546 controls.push_back( CreateLeafControl( 40, 40 ) );
547 controls.push_back( CreateLeafControl( 60, 40 ) );
548 controls.push_back( CreateLeafControl( 80, 40 ) );
549 controls.push_back( CreateLeafControl( 100, 40 ) );
551 for( auto&& iter : controls )
555 hbox.SetParentOrigin( ParentOrigin::CENTER );
556 hbox.SetAnchorPoint( AnchorPoint::CENTER );
559 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
561 // Ensure layouting happens
562 application.SendNotification();
563 application.Render();
565 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
566 // hbox left justifies elements
567 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
568 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
569 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
570 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
572 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
573 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
574 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
575 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
577 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
579 // Ensure layouting happens
580 application.SendNotification();
581 application.Render();
583 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
584 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
585 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
586 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
588 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
589 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
590 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
591 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
598 int UtcDaliLayouting_HboxLayout_Padding01(void)
600 ToolkitTestApplication application;
601 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
603 Stage stage = Stage::GetCurrent();
604 auto hbox = Control::New();
605 auto hboxLayout = LinearLayout::New();
606 DevelControl::SetLayout( hbox, hboxLayout );
607 hbox.SetName( "HBox");
609 std::vector< Control > controls;
610 controls.push_back( CreateLeafControl( 40, 40 ) );
611 controls.push_back( CreateLeafControl( 60, 40 ) );
612 controls.push_back( CreateLeafControl( 80, 40 ) );
613 controls.push_back( CreateLeafControl( 100, 40 ) );
615 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
616 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
617 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
619 for( auto&& iter : controls )
623 hbox.SetParentOrigin( ParentOrigin::CENTER );
624 hbox.SetAnchorPoint( AnchorPoint::CENTER );
627 // Ensure layouting happens
628 application.SendNotification();
629 application.Render();
631 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
632 // hbox left justifies elements
633 tet_infoline("Test Child Actor Position");
634 float xPositionOfControlBeingTested = 0.0f;
635 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
637 0.0f ), 0.0001f, TEST_LOCATION );
638 xPositionOfControlBeingTested += 40.0f;
640 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
641 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
642 0.0001f, TEST_LOCATION );
644 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
645 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
647 xPositionOfControlBeingTested += 80.0f;
648 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
650 tet_infoline("Test Child Actor Size");
651 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
653 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
654 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
655 0.0001f, TEST_LOCATION );
657 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
658 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
663 int UtcDaliLayouting_HboxLayout_Padding02(void)
665 ToolkitTestApplication application;
666 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
668 Stage stage = Stage::GetCurrent();
669 auto hbox = Control::New();
670 auto hboxLayout = LinearLayout::New();
671 DevelControl::SetLayout( hbox, hboxLayout );
672 hbox.SetName( "HBox");
674 std::vector< Control > controls;
675 controls.push_back( CreateLeafControl( 40, 40 ) );
676 controls.push_back( CreateLeafControl( 60, 40 ) );
677 controls.push_back( CreateLeafControl( 80, 40 ) );
678 controls.push_back( CreateLeafControl( 100, 40 ) );
680 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
682 for( auto&& iter : controls )
684 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
687 hbox.SetParentOrigin( ParentOrigin::CENTER );
688 hbox.SetAnchorPoint( AnchorPoint::CENTER );
691 // Ensure layouting happens
692 application.SendNotification();
693 application.Render();
695 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
696 // hbox left justifies elements
697 tet_infoline("Test Child Actor Position");
698 float xPositionOfControlBeingTested = 0.0f;
699 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
701 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
702 yPositionOfControlBeingTested,
703 0.0f ), 0.0001f, TEST_LOCATION );
704 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
706 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
707 yPositionOfControlBeingTested,
709 0.0001f, TEST_LOCATION );
711 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
712 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
713 yPositionOfControlBeingTested,
714 0.0f ), 0.0001f, TEST_LOCATION );
716 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
717 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
718 yPositionOfControlBeingTested,
719 0.0f ), 0.0001f, TEST_LOCATION );
721 tet_infoline("Test Child Actor Size");
722 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
723 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
724 0.0f ), 0.0001f, TEST_LOCATION );
726 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
727 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
728 0.0f ), 0.0001f, TEST_LOCATION );
730 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
731 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
732 0.0f ), 0.0001f, TEST_LOCATION );
734 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
735 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
736 0.0f ), 0.0001f, TEST_LOCATION );
742 int UtcDaliLayouting_HboxLayout_Padding03(void)
744 ToolkitTestApplication application;
745 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Adding Changing padding on a single child");
747 Stage stage = Stage::GetCurrent();
748 auto hbox = Control::New();
749 auto hboxLayout = LinearLayout::New();
750 DevelControl::SetLayout( hbox, hboxLayout );
751 hbox.SetName( "HBox");
753 std::vector< Control > controls;
754 controls.push_back( CreateLeafControl( 40, 40 ) );
755 controls.push_back( CreateLeafControl( 40, 40 ) );
756 controls.push_back( CreateLeafControl( 40, 40 ) );
758 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
759 tet_printf( "\nAdding Padding to control at index 1 \n" );
760 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
762 for( auto&& iter : controls )
766 hbox.SetParentOrigin( ParentOrigin::CENTER );
767 hbox.SetAnchorPoint( AnchorPoint::CENTER );
770 // Ensure layouting happens
771 application.SendNotification();
772 application.Render();
774 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
775 // hbox left justifies elements
776 tet_infoline("Test Child Actor Position");
777 float xPositionOfControlBeingTested = 0.0f;
778 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
780 0.0f ), 0.0001f, TEST_LOCATION );
781 xPositionOfControlBeingTested += 40.0f;
783 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
784 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
785 0.0001f, TEST_LOCATION );
787 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
788 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
790 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
791 tet_printf( "\nChanging Padding to control at index 1 \n" );
792 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
794 // Ensure layouting happens
795 application.SendNotification();
796 application.Render();
798 xPositionOfControlBeingTested = 0.0f; // reset
800 tet_infoline("Test Child Actor Position");
801 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
803 0.0f ), 0.0001f, TEST_LOCATION );
804 xPositionOfControlBeingTested += 40.0f;
806 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
807 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
808 0.0001f, TEST_LOCATION );
810 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
811 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
812 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
814 tet_infoline("Test Child Actor Size");
815 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
817 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
818 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
819 0.0001f, TEST_LOCATION );
821 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
828 int UtcDaliLayouting_HboxLayout_Margin01(void)
830 ToolkitTestApplication application;
831 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
833 Stage stage = Stage::GetCurrent();
834 auto hbox = Control::New();
835 auto hboxLayout = LinearLayout::New();
836 DevelControl::SetLayout( hbox, hboxLayout );
837 hbox.SetName( "HBox");
839 std::vector< Control > controls;
840 controls.push_back( CreateLeafControl( 40, 40 ) );
841 controls.push_back( CreateLeafControl( 60, 40 ) );
842 controls.push_back( CreateLeafControl( 80, 40 ) );
843 controls.push_back( CreateLeafControl( 100, 40 ) );
845 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
846 tet_printf( "\nAdding Margin to control at index 1 \n" );
847 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
849 for( auto&& iter : controls )
853 hbox.SetParentOrigin( ParentOrigin::CENTER );
854 hbox.SetAnchorPoint( AnchorPoint::CENTER );
857 // Ensure layouting happens
858 application.SendNotification();
859 application.Render();
861 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
862 // hbox left justifies elements
863 tet_infoline("Test Child Actor Position");
864 auto xPositionOfControlBeingTested = 0.0f;
865 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
867 0.0f ), 0.0001f, TEST_LOCATION );
868 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
870 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
871 380.0f + CONTROL_MARGIN.top, 0.0f ),
872 0.0001f, TEST_LOCATION );
874 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
875 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
877 xPositionOfControlBeingTested += 80.0f;
878 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
880 tet_infoline("Test Child Actor Size is the same after Margin added");
881 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
882 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
883 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
884 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
890 int UtcDaliLayouting_VboxLayout01(void)
892 ToolkitTestApplication application;
893 tet_infoline(" UtcDaliLayouting_VboxLayout01");
895 Stage stage = Stage::GetCurrent();
896 auto vbox = Control::New();
897 auto vboxLayout = LinearLayout::New();
898 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
899 DevelControl::SetLayout( vbox, vboxLayout );
900 vbox.SetName( "Vbox");
902 std::vector< Control > controls;
903 controls.push_back( CreateLeafControl( 40, 40 ) );
904 controls.push_back( CreateLeafControl( 60, 60 ) );
905 controls.push_back( CreateLeafControl( 80, 80 ) );
906 controls.push_back( CreateLeafControl( 100, 100 ) );
908 for( auto&& iter : controls )
912 vbox.SetParentOrigin( ParentOrigin::CENTER );
913 vbox.SetAnchorPoint( AnchorPoint::CENTER );
916 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
919 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
921 // Ensure layouting happens
922 application.SendNotification();
923 application.Render();
925 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
926 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
927 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
928 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
929 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
931 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
932 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
933 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
934 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
939 int UtcDaliLayouting_VboxLayout02(void)
941 ToolkitTestApplication application;
942 tet_infoline(" UtcDaliLayouting_VboxLayout01");
944 Stage stage = Stage::GetCurrent();
946 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
947 // LayoutGroup for this to happen automatically.
949 // For this test, add an hbox instead
950 auto rootControl = Control::New();
951 auto absoluteLayout = AbsoluteLayout::New();
952 DevelControl::SetLayout( rootControl, absoluteLayout );
953 rootControl.SetName( "AbsoluteLayout");
954 stage.Add( rootControl );
956 auto vbox = Control::New();
957 auto vboxLayout = LinearLayout::New();
958 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
959 DevelControl::SetLayout( vbox, vboxLayout );
960 vbox.SetName( "Vbox");
961 rootControl.Add( vbox );
963 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
964 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
966 std::vector< Control > controls;
967 controls.push_back( CreateLeafControl( 40, 40 ) );
968 controls.push_back( CreateLeafControl( 60, 60 ) );
969 controls.push_back( CreateLeafControl( 80, 80 ) );
970 controls.push_back( CreateLeafControl( 100, 100 ) );
972 for( auto&& iter : controls )
976 vbox.SetParentOrigin( ParentOrigin::CENTER );
977 vbox.SetAnchorPoint( AnchorPoint::CENTER );
979 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
982 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
984 // Ensure layouting happens
985 application.SendNotification();
986 application.Render();
988 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
989 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
991 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
992 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
993 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
995 // 3rd control is set to match parent - this should also be 100 wide
996 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
997 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
998 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
999 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1001 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1002 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1003 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1004 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1010 int UtcDaliLayouting_VboxLayout03(void)
1012 ToolkitTestApplication application;
1013 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
1015 Stage stage = Stage::GetCurrent();
1017 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1018 // LayoutGroup for this to happen automatically.
1020 // For this test, add an hbox instead
1021 auto hbox = Control::New();
1022 auto hboxLayout = LinearLayout::New();
1023 DevelControl::SetLayout( hbox, hboxLayout );
1024 hbox.SetName( "Hbox");
1027 auto vbox = Control::New();
1028 auto vboxLayout = LinearLayout::New();
1029 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
1030 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1032 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
1034 DevelControl::SetLayout( vbox, vboxLayout );
1035 vbox.SetName( "Vbox");
1038 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1039 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1041 std::vector< Control > controls;
1042 controls.push_back( CreateLeafControl( 40, 40 ) );
1043 controls.push_back( CreateLeafControl( 60, 60 ) );
1044 controls.push_back( CreateLeafControl( 80, 80 ) );
1045 controls.push_back( CreateLeafControl( 100, 100 ) );
1047 for( auto&& iter : controls )
1051 vbox.SetParentOrigin( ParentOrigin::CENTER );
1052 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1054 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1057 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1059 // Ensure layouting happens
1060 application.SendNotification();
1061 application.Render();
1063 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1064 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1066 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1067 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1068 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1070 // 3rd control is set to match parent - this should also be 100 wide
1071 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1072 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1073 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1074 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1076 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1077 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1078 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1079 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );