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 <../custom-layout.h>
29 #include <layout-utils.h>
32 using namespace Toolkit;
34 void utc_dali_toolkit_layouting_startup(void)
36 test_return_value = TET_UNDEF;
39 void utc_dali_toolkit_layouting_cleanup(void)
41 test_return_value = TET_PASS;
44 int UtcDaliLayouting_HboxLayout01(void)
46 ToolkitTestApplication application;
47 tet_infoline(" UtcDaliLayouting_HboxLayout01");
49 Stage stage = Stage::GetCurrent();
50 auto hbox = Control::New();
51 auto hboxLayout = LinearLayout::New();
52 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
53 DevelControl::SetLayout( hbox, hboxLayout );
54 hbox.SetName( "HBox");
56 std::vector< Control > controls;
57 controls.push_back( CreateLeafControl( 40, 40 ) );
58 controls.push_back( CreateLeafControl( 60, 40 ) );
59 controls.push_back( CreateLeafControl( 80, 40 ) );
60 controls.push_back( CreateLeafControl( 100, 40 ) );
62 for( auto&& iter : controls )
66 hbox.SetParentOrigin( ParentOrigin::CENTER );
67 hbox.SetAnchorPoint( AnchorPoint::CENTER );
70 // Ensure layouting happens
71 application.SendNotification();
74 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
75 // hbox left justifies elements
76 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
77 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
78 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
79 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
81 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
82 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
83 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
84 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
87 auto newHBoxLayout = LinearLayout::New();
88 newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
89 DevelControl::SetLayout( hbox, newHBoxLayout );
91 application.SendNotification();
94 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
95 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
96 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
97 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
102 int UtcDaliLayouting_HboxLayout02(void)
104 ToolkitTestApplication application;
105 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
107 Stage stage = Stage::GetCurrent();
109 auto hbox1 = Control::New();
110 auto hboxLayout1 = LinearLayout::New();
111 DevelControl::SetLayout( hbox1, hboxLayout1 );
113 auto hbox2 = Control::New();
114 auto hboxLayout2 = LinearLayout::New();
115 DevelControl::SetLayout( hbox2, hboxLayout2 );
117 hbox1.SetName( "HBox1");
118 hbox2.SetName( "HBox2");
120 std::vector< Control > controls;
121 controls.push_back( CreateLeafControl( 20, 40 ) );
122 controls.push_back( CreateLeafControl( 30, 50 ) );
123 controls.push_back( CreateLeafControl( 40, 60 ) );
124 controls.push_back( CreateLeafControl( 50, 70 ) );
126 controls.push_back( CreateLeafControl( 25, 40 ) );
127 controls.push_back( CreateLeafControl( 35, 50 ) );
128 controls.push_back( CreateLeafControl( 45, 60 ) );
129 controls.push_back( CreateLeafControl( 55, 70 ) );
132 for( auto&& iter : controls )
144 hbox1.SetParentOrigin( ParentOrigin::CENTER );
145 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
146 hbox2.SetParentOrigin( ParentOrigin::CENTER );
147 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
149 auto hbox3 = Control::New();
150 auto hboxLayout3 = LinearLayout::New();
151 DevelControl::SetLayout( hbox3, hboxLayout3 );
153 hbox3.SetParentOrigin( ParentOrigin::CENTER );
154 hbox3.SetName( "HBox3");
160 // Ensure layouting happens
161 application.SendNotification();
162 application.Render();
165 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
166 // hbox left justifies elements
167 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
168 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
169 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
170 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
172 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
173 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
174 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
175 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
178 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
179 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
180 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
181 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
183 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
184 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
185 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
186 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
188 // Test hbox1 and 2 are sized to wrap their content
189 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
190 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
191 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
192 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
194 // Test hbox3 matches parent (root layer)
195 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
196 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
202 int UtcDaliLayouting_HboxLayout03(void)
204 ToolkitTestApplication application;
205 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
207 Stage stage = Stage::GetCurrent();
209 auto hbox1 = Control::New();
210 auto hboxLayout1 = LinearLayout::New();
211 DevelControl::SetLayout( hbox1, hboxLayout1 );
213 auto hbox2 = Control::New();
214 auto hboxLayout2 = LinearLayout::New();
215 DevelControl::SetLayout( hbox2, hboxLayout2 );
217 hbox1.SetName( "HBox1");
218 hbox2.SetName( "HBox2");
219 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
220 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
221 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
222 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
224 std::vector< Control > controls;
225 controls.push_back( CreateLeafControl( 20, 40 ) );
226 controls.push_back( CreateLeafControl( 30, 50 ) );
227 controls.push_back( CreateLeafControl( 40, 60 ) );
228 controls.push_back( CreateLeafControl( 50, 70 ) );
230 controls.push_back( CreateLeafControl( 25, 40 ) );
231 controls.push_back( CreateLeafControl( 35, 50 ) );
232 controls.push_back( CreateLeafControl( 45, 60 ) );
233 controls.push_back( CreateLeafControl( 55, 70 ) );
236 for( auto&& iter : controls )
248 hbox1.SetParentOrigin( ParentOrigin::CENTER );
249 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
250 hbox2.SetParentOrigin( ParentOrigin::CENTER );
251 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
253 auto hbox3 = Control::New();
254 auto hboxLayout3 = LinearLayout::New();
255 DevelControl::SetLayout( hbox3, hboxLayout3);
257 hbox3.SetParentOrigin( ParentOrigin::CENTER );
258 hbox3.SetName( "HBox3");
264 //std::ostringstream oss;
265 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
266 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
268 // Ensure layouting happens
269 application.SendNotification();
270 application.Render();
273 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
274 // hbox left justifies elements
275 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
276 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
277 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
278 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
280 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
281 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
282 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
283 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
285 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
286 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
287 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
288 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
290 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
291 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
292 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
293 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
295 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
296 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
297 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
298 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
300 // Test hbox3 matches parent (root layer)
301 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
302 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
307 int UtcDaliLayouting_HboxLayout04(void)
309 ToolkitTestApplication application;
310 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
312 Stage stage = Stage::GetCurrent();
314 auto hbox1 = Control::New();
315 auto hboxLayout1 = LinearLayout::New();
316 DevelControl::SetLayout( hbox1, hboxLayout1 );
318 auto hbox2 = Control::New();
319 auto hboxLayout2 = LinearLayout::New();
320 DevelControl::SetLayout( hbox2, hboxLayout2 );
322 hbox1.SetName( "HBox1"); // Default spec is to wrap content
323 hbox2.SetName( "HBox2");
324 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
325 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
326 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
327 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
329 std::vector< Control > controls;
330 controls.push_back( CreateLeafControl( 80, 40 ) );
331 controls.push_back( CreateLeafControl( 80, 50 ) );
332 controls.push_back( CreateLeafControl( 80, 60 ) );
333 controls.push_back( CreateLeafControl( 80, 70 ) );
335 controls.push_back( CreateLeafControl( 80, 40 ) );
336 controls.push_back( CreateLeafControl( 80, 50 ) );
337 controls.push_back( CreateLeafControl( 80, 60 ) );
338 controls.push_back( CreateLeafControl( 80, 70 ) );
341 for( auto&& iter : controls )
354 controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
355 auto hbox3 = Control::New();
356 auto hboxLayout3 = LinearLayout::New();
357 DevelControl::SetLayout( hbox3, hboxLayout3 );
359 hbox3.SetParentOrigin( ParentOrigin::CENTER );
360 hbox3.SetName( "HBox3");
365 //std::ostringstream oss;
366 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
367 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
369 // Ensure layouting happens
370 application.SendNotification();
371 application.Render();
374 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
375 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
376 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
377 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
379 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
380 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
381 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
382 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
384 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
385 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
386 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
387 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
389 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
390 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
391 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
392 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
394 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
395 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
396 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
397 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
400 // Test hbox3 matches parent (root layer)
401 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
402 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
407 int UtcDaliLayouting_HboxLayout05(void)
409 ToolkitTestApplication application;
410 tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
412 Stage stage = Stage::GetCurrent();
413 auto hbox = Control::New();
414 auto hboxLayout = LinearLayout::New();
415 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
416 DevelControl::SetLayout( hbox, hboxLayout );
417 hbox.SetName( "HBox");
419 std::vector< Control > controls;
420 controls.push_back( CreateLeafControl( 40, 40 ) );
421 controls.push_back( CreateLeafControl( 60, 40 ) );
422 controls.push_back( CreateLeafControl( 80, 40 ) );
423 controls.push_back( CreateLeafControl( 100, 40 ) );
425 for( auto&& iter : controls )
428 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
429 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
432 hbox.SetParentOrigin( ParentOrigin::CENTER );
433 hbox.SetAnchorPoint( AnchorPoint::CENTER );
436 // Ensure layouting happens
437 application.SendNotification();
438 application.Render();
440 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
441 // hbox left justifies elements
442 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
443 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
444 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
445 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
447 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
448 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
449 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
450 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
455 int UtcDaliLayouting_HboxLayout06(void)
457 ToolkitTestApplication application;
458 tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
460 Stage stage = Stage::GetCurrent();
462 auto rootControl = Control::New();
463 auto absoluteLayout = AbsoluteLayout::New();
464 DevelControl::SetLayout( rootControl, absoluteLayout );
465 rootControl.SetName( "AbsoluteLayout" );
466 stage.Add( rootControl );
468 auto hbox = Control::New();
469 auto hboxLayout = LinearLayout::New();
470 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
471 DevelControl::SetLayout( hbox, hboxLayout );
472 hbox.SetName( "HBox" );
474 std::vector< Control > controls;
475 controls.push_back( CreateLeafControl( 40, 40 ) );
476 controls.push_back( CreateLeafControl( 60, 40 ) );
478 for( auto&& iter : controls )
482 hbox.SetParentOrigin( ParentOrigin::CENTER );
483 hbox.SetAnchorPoint( AnchorPoint::CENTER );
484 rootControl.Add( hbox );
486 // Ensure layouting happens
487 application.SendNotification();
488 application.Render();
490 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
491 // hbox left justifies elements
492 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
493 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
495 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
496 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
498 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
501 auto newHBoxLayout = LinearLayout::New();
502 newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
503 DevelControl::SetLayout( hbox, newHBoxLayout );
505 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
506 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
508 application.SendNotification();
509 application.Render();
511 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
513 // Change size specification
514 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
515 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
517 application.SendNotification();
518 application.Render();
520 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
522 // Use WRAP_CONTENT again
523 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
524 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
526 application.SendNotification();
527 application.Render();
529 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
535 int UtcDaliLayouting_HboxLayout07(void)
537 ToolkitTestApplication application;
538 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
540 Stage stage = Stage::GetCurrent();
541 auto hbox = Control::New();
542 auto hboxLayout = LinearLayout::New();
543 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
544 DevelControl::SetLayout( hbox, hboxLayout );
545 hbox.SetName( "HBox");
547 std::vector< Control > controls;
548 controls.push_back( CreateLeafControl( 40, 40 ) );
549 controls.push_back( CreateLeafControl( 60, 40 ) );
550 controls.push_back( CreateLeafControl( 80, 40 ) );
551 controls.push_back( CreateLeafControl( 100, 40 ) );
553 for( auto&& iter : controls )
557 hbox.SetParentOrigin( ParentOrigin::CENTER );
558 hbox.SetAnchorPoint( AnchorPoint::CENTER );
561 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
563 // Ensure layouting happens
564 application.SendNotification();
565 application.Render();
567 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
568 // hbox left justifies elements
569 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
570 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
571 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
572 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
574 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
575 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
576 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
577 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
579 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
581 // Ensure layouting happens
582 application.SendNotification();
583 application.Render();
585 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
586 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
587 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
588 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
590 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
591 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
592 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
593 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
598 int UtcDaliLayouting_HboxLayout08(void)
600 ToolkitTestApplication application;
601 tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation");
603 Stage stage = Stage::GetCurrent();
605 auto rootControl = Control::New();
606 auto absoluteLayout = AbsoluteLayout::New();
607 absoluteLayout.SetAnimateLayout( true );
608 DevelControl::SetLayout( rootControl, absoluteLayout );
609 rootControl.SetName( "AbsoluteLayout" );
610 stage.Add( rootControl );
612 Control control1 = CreateLeafControl( 40, 40 );
613 rootControl.Add( control1 );
615 auto hbox = Control::New();
616 auto hboxLayout = LinearLayout::New();
617 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
618 DevelControl::SetLayout( hbox, hboxLayout );
619 hbox.SetName( "HBox" );
621 Control control2 = CreateLeafControl( 40, 40 );
622 hbox.Add( control2 );
624 hbox.SetParentOrigin( ParentOrigin::CENTER );
625 hbox.SetAnchorPoint( AnchorPoint::CENTER );
626 rootControl.Add( hbox );
628 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION );
629 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION );
630 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION );
631 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION );
633 hboxLayout.SetAnimateLayout( true );
634 absoluteLayout.SetAnimateLayout( false );
636 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION );
637 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION );
638 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION );
639 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION );
646 int UtcDaliLayouting_HboxLayout_Padding01(void)
648 ToolkitTestApplication application;
649 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
651 Stage stage = Stage::GetCurrent();
652 auto hbox = Control::New();
653 auto hboxLayout = LinearLayout::New();
654 DevelControl::SetLayout( hbox, hboxLayout );
655 hbox.SetName( "HBox");
657 std::vector< Control > controls;
658 controls.push_back( CreateLeafControl( 40, 40 ) );
659 controls.push_back( CreateLeafControl( 60, 40 ) );
660 controls.push_back( CreateLeafControl( 80, 40 ) );
661 controls.push_back( CreateLeafControl( 100, 40 ) );
663 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
664 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
665 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
667 for( auto&& iter : controls )
671 hbox.SetParentOrigin( ParentOrigin::CENTER );
672 hbox.SetAnchorPoint( AnchorPoint::CENTER );
675 // Ensure layouting happens
676 application.SendNotification();
677 application.Render();
679 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
680 // hbox left justifies elements
681 tet_infoline("Test Child Actor Position");
682 float xPositionOfControlBeingTested = 0.0f;
683 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
685 0.0f ), 0.0001f, TEST_LOCATION );
686 xPositionOfControlBeingTested += 40.0f;
688 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
689 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
690 0.0001f, TEST_LOCATION );
692 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
693 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
695 xPositionOfControlBeingTested += 80.0f;
696 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
698 tet_infoline("Test Child Actor Size");
699 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
701 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
702 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
703 0.0001f, TEST_LOCATION );
705 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
706 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
711 int UtcDaliLayouting_HboxLayout_Padding02(void)
713 ToolkitTestApplication application;
714 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
716 Stage stage = Stage::GetCurrent();
717 auto hbox = Control::New();
718 auto hboxLayout = LinearLayout::New();
719 DevelControl::SetLayout( hbox, hboxLayout );
720 hbox.SetName( "HBox");
722 std::vector< Control > controls;
723 controls.push_back( CreateLeafControl( 40, 40 ) );
724 controls.push_back( CreateLeafControl( 60, 40 ) );
725 controls.push_back( CreateLeafControl( 80, 40 ) );
726 controls.push_back( CreateLeafControl( 100, 40 ) );
728 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
730 for( auto&& iter : controls )
732 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
735 hbox.SetParentOrigin( ParentOrigin::CENTER );
736 hbox.SetAnchorPoint( AnchorPoint::CENTER );
739 // Ensure layouting happens
740 application.SendNotification();
741 application.Render();
743 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
744 // hbox left justifies elements
745 tet_infoline("Test Child Actor Position");
746 float xPositionOfControlBeingTested = 0.0f;
747 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
749 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
750 yPositionOfControlBeingTested,
751 0.0f ), 0.0001f, TEST_LOCATION );
752 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
754 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
755 yPositionOfControlBeingTested,
757 0.0001f, TEST_LOCATION );
759 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
760 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
761 yPositionOfControlBeingTested,
762 0.0f ), 0.0001f, TEST_LOCATION );
764 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
765 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
766 yPositionOfControlBeingTested,
767 0.0f ), 0.0001f, TEST_LOCATION );
769 tet_infoline("Test Child Actor Size");
770 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
771 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
772 0.0f ), 0.0001f, TEST_LOCATION );
774 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
775 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
776 0.0f ), 0.0001f, TEST_LOCATION );
778 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
779 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
780 0.0f ), 0.0001f, TEST_LOCATION );
782 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
783 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
784 0.0f ), 0.0001f, TEST_LOCATION );
790 int UtcDaliLayouting_HboxLayout_Padding03(void)
792 ToolkitTestApplication application;
793 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
795 Stage stage = Stage::GetCurrent();
796 auto hbox = Control::New();
797 auto hboxLayout = LinearLayout::New();
798 DevelControl::SetLayout( hbox, hboxLayout );
799 hbox.SetName( "HBox");
801 std::vector< Control > controls;
802 controls.push_back( CreateLeafControl( 40, 40 ) );
803 controls.push_back( CreateLeafControl( 40, 40 ) );
804 controls.push_back( CreateLeafControl( 40, 40 ) );
806 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
807 tet_printf( "\nAdding Padding to control at index 1 \n" );
808 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
810 for( auto&& iter : controls )
814 hbox.SetParentOrigin( ParentOrigin::CENTER );
815 hbox.SetAnchorPoint( AnchorPoint::CENTER );
818 // Ensure layouting happens
819 application.SendNotification();
820 application.Render();
822 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
823 // hbox left justifies elements
824 tet_infoline("Test Child Actor Position");
825 float xPositionOfControlBeingTested = 0.0f;
826 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
828 0.0f ), 0.0001f, TEST_LOCATION );
829 xPositionOfControlBeingTested += 40.0f;
831 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
832 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
833 0.0001f, TEST_LOCATION );
835 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
836 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
838 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
839 tet_printf( "\nChanging Padding to control at index 1 \n" );
840 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
842 // Ensure layouting happens
843 application.SendNotification();
844 application.Render();
846 xPositionOfControlBeingTested = 0.0f; // reset
848 tet_infoline("Test Child Actor Position");
849 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
851 0.0f ), 0.0001f, TEST_LOCATION );
852 xPositionOfControlBeingTested += 40.0f;
854 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
855 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
856 0.0001f, TEST_LOCATION );
858 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
859 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
860 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
862 tet_infoline("Test Child Actor Size");
863 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
865 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
866 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
867 0.0001f, TEST_LOCATION );
869 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
874 int UtcDaliLayouting_HboxLayout_Padding04(void)
876 ToolkitTestApplication application;
877 tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
879 // Adding padding to the layout should offset the positioning of the children.
881 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
882 const Size CONTROL_SIZE = Size( 40, 40 );
884 Stage stage = Stage::GetCurrent();
885 // Create a root layout, ideally Dali would have a default layout in the root layer.
886 // Without this root layer the LinearLayout (or any other layout) will not
887 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
888 // It uses the default stage size and ideally should have a layout added to it.
889 auto rootLayoutControl = Control::New();
890 rootLayoutControl.SetName( "AbsoluteLayout");
891 auto rootLayout = AbsoluteLayout::New();
892 DevelControl::SetLayout( rootLayoutControl, rootLayout );
893 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
894 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
895 stage.Add( rootLayoutControl );
897 auto hbox = Control::New();
898 auto hboxLayout = LinearLayout::New();
899 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
900 DevelControl::SetLayout( hbox, hboxLayout );
901 hbox.SetName( "HBox");
902 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
903 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
904 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
906 std::vector< Control > controls;
907 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
908 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
909 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
910 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
912 for( auto&& iter : controls )
917 hbox.SetParentOrigin( ParentOrigin::CENTER );
918 hbox.SetAnchorPoint( AnchorPoint::CENTER );
919 rootLayoutControl.Add( hbox );
921 // Ensure layouting happens
922 application.SendNotification();
923 application.Render();
925 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
926 application.SendNotification();
928 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
929 // hbox left justifies elements
930 tet_infoline("Test Child Actor Position");
932 auto controlXPosition=0.0f;
934 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
935 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
937 0.0f ), 0.0001f, TEST_LOCATION );
939 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
940 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
943 0.0001f, TEST_LOCATION );
945 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
946 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
948 0.0f ), 0.0001f, TEST_LOCATION );
950 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
951 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
953 0.0f ), 0.0001f, TEST_LOCATION );
955 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
956 auto totalControlsHeight = CONTROL_SIZE.height;
958 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
959 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
960 0.0f ), 0.0001f, TEST_LOCATION );
966 int UtcDaliLayouting_HboxLayout_Padding05(void)
968 ToolkitTestApplication application;
969 tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
971 // Adding padding to the layout should offset the positioning of the children.
973 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
974 const Size CONTROL_SIZE = Size( 40, 40 );
976 Stage stage = Stage::GetCurrent();
977 // Create a root layout, ideally Dali would have a default layout in the root layer.
978 // Without this root layer the LinearLayout (or any other layout) will not
979 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
980 // It uses the default stage size and ideally should have a layout added to it.
981 auto rootLayoutControl = Control::New();
982 rootLayoutControl.SetName( "AbsoluteLayout");
983 auto rootLayout = AbsoluteLayout::New();
984 DevelControl::SetLayout( rootLayoutControl, rootLayout );
985 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
986 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
987 stage.Add( rootLayoutControl );
989 auto hbox = Control::New();
990 auto hboxLayout = LinearLayout::New();
991 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
992 DevelControl::SetLayout( hbox, hboxLayout );
993 hbox.SetName( "HBox");
994 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
995 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
996 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
998 std::vector< Control > controls;
999 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1000 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1001 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1002 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1004 for( auto&& iter : controls )
1009 hbox.SetParentOrigin( ParentOrigin::CENTER );
1010 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1011 rootLayoutControl.Add( hbox );
1013 // Ensure layouting happens
1014 application.SendNotification();
1015 application.Render();
1017 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1018 application.SendNotification();
1020 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1021 // hbox left justifies elements
1022 tet_infoline("Test Child Actor Position");
1024 auto controlXPosition=0.0f;
1026 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1027 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1029 0.0f ), 0.0001f, TEST_LOCATION );
1031 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1032 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1035 0.0001f, TEST_LOCATION );
1037 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1038 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1040 0.0f ), 0.0001f, TEST_LOCATION );
1042 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1043 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1045 0.0f ), 0.0001f, TEST_LOCATION );
1047 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1048 auto totalControlsHeight = CONTROL_SIZE.height;
1050 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1051 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1052 0.0f ), 0.0001f, TEST_LOCATION );
1054 // Change layout padding
1055 const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
1056 tet_printf( "\nChanging Padding to control at index 1 \n" );
1057 hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
1059 // Ensure layouting happens
1060 application.SendNotification();
1061 application.Render();
1063 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1064 application.SendNotification();
1066 controlXPosition = NEW_LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1067 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
1068 NEW_LAYOUT_PADDING.top,
1069 0.0f ), 0.0001f, TEST_LOCATION );
1071 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1072 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1073 NEW_LAYOUT_PADDING.top,
1075 0.0001f, TEST_LOCATION );
1077 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1078 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1079 NEW_LAYOUT_PADDING.top,
1080 0.0f ), 0.0001f, TEST_LOCATION );
1082 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1083 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1084 NEW_LAYOUT_PADDING.top,
1085 0.0f ), 0.0001f, TEST_LOCATION );
1086 totalControlsWidth = CONTROL_SIZE.width * controls.size();
1087 totalControlsHeight = CONTROL_SIZE.height;
1089 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
1090 totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
1091 0.0f ), 0.0001f, TEST_LOCATION );
1097 int UtcDaliLayouting_HboxLayout_Margin01(void)
1099 ToolkitTestApplication application;
1100 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
1102 Stage stage = Stage::GetCurrent();
1103 auto hbox = Control::New();
1104 auto hboxLayout = LinearLayout::New();
1105 DevelControl::SetLayout( hbox, hboxLayout );
1106 hbox.SetName( "HBox");
1108 std::vector< Control > controls;
1109 controls.push_back( CreateLeafControl( 40, 40 ) );
1110 controls.push_back( CreateLeafControl( 60, 40 ) );
1111 controls.push_back( CreateLeafControl( 80, 40 ) );
1112 controls.push_back( CreateLeafControl( 100, 40 ) );
1114 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
1115 tet_printf( "\nAdding Margin to control at index 1 \n" );
1116 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1118 for( auto&& iter : controls )
1122 hbox.SetParentOrigin( ParentOrigin::CENTER );
1123 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1126 // Ensure layouting happens
1127 application.SendNotification();
1128 application.Render();
1130 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1131 // hbox left justifies elements
1132 tet_infoline("Test Child Actor Position");
1133 auto xPositionOfControlBeingTested = 0.0f;
1134 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1136 0.0f ), 0.0001f, TEST_LOCATION );
1137 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
1139 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1140 380.0f + CONTROL_MARGIN.top, 0.0f ),
1141 0.0001f, TEST_LOCATION );
1143 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
1144 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1146 xPositionOfControlBeingTested += 80.0f;
1147 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1149 tet_infoline("Test Child Actor Size is the same after Margin added");
1150 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1151 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
1152 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1153 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1159 int UtcDaliLayouting_VboxLayout01(void)
1161 ToolkitTestApplication application;
1162 tet_infoline(" UtcDaliLayouting_VboxLayout01");
1164 Stage stage = Stage::GetCurrent();
1165 auto vbox = Control::New();
1166 auto vboxLayout = LinearLayout::New();
1167 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1168 DevelControl::SetLayout( vbox, vboxLayout );
1169 vbox.SetName( "Vbox");
1171 std::vector< Control > controls;
1172 controls.push_back( CreateLeafControl( 40, 40 ) );
1173 controls.push_back( CreateLeafControl( 60, 60 ) );
1174 controls.push_back( CreateLeafControl( 80, 80 ) );
1175 controls.push_back( CreateLeafControl( 100, 100 ) );
1177 for( auto&& iter : controls )
1181 vbox.SetParentOrigin( ParentOrigin::CENTER );
1182 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1185 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1188 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1190 // Ensure layouting happens
1191 application.SendNotification();
1192 application.Render();
1194 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
1195 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1196 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1197 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1198 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1200 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1201 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1202 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1203 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1208 int UtcDaliLayouting_VboxLayout02(void)
1210 ToolkitTestApplication application;
1211 tet_infoline(" UtcDaliLayouting_VboxLayout01");
1213 Stage stage = Stage::GetCurrent();
1215 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1216 // LayoutGroup for this to happen automatically.
1218 // For this test, add an hbox instead
1219 auto rootControl = Control::New();
1220 auto absoluteLayout = AbsoluteLayout::New();
1221 DevelControl::SetLayout( rootControl, absoluteLayout );
1222 rootControl.SetName( "AbsoluteLayout");
1223 stage.Add( rootControl );
1225 auto vbox = Control::New();
1226 auto vboxLayout = LinearLayout::New();
1227 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1228 DevelControl::SetLayout( vbox, vboxLayout );
1229 vbox.SetName( "Vbox");
1230 rootControl.Add( vbox );
1232 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1233 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1235 std::vector< Control > controls;
1236 controls.push_back( CreateLeafControl( 40, 40 ) );
1237 controls.push_back( CreateLeafControl( 60, 60 ) );
1238 controls.push_back( CreateLeafControl( 80, 80 ) );
1239 controls.push_back( CreateLeafControl( 100, 100 ) );
1241 for( auto&& iter : controls )
1245 vbox.SetParentOrigin( ParentOrigin::CENTER );
1246 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1248 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1251 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1253 // Ensure layouting happens
1254 application.SendNotification();
1255 application.Render();
1257 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1258 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1260 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1261 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1262 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1264 // 3rd control is set to match parent - this should also be 100 wide
1265 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1266 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1267 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1268 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1270 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1271 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1272 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1273 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1279 int UtcDaliLayouting_VboxLayout03(void)
1281 ToolkitTestApplication application;
1282 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
1284 Stage stage = Stage::GetCurrent();
1286 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1287 // LayoutGroup for this to happen automatically.
1289 // For this test, add an hbox instead
1290 auto hbox = Control::New();
1291 auto hboxLayout = LinearLayout::New();
1292 DevelControl::SetLayout( hbox, hboxLayout );
1293 hbox.SetName( "Hbox");
1296 auto vbox = Control::New();
1297 auto vboxLayout = LinearLayout::New();
1298 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
1299 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1301 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
1303 DevelControl::SetLayout( vbox, vboxLayout );
1304 vbox.SetName( "Vbox");
1307 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1308 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1310 std::vector< Control > controls;
1311 controls.push_back( CreateLeafControl( 40, 40 ) );
1312 controls.push_back( CreateLeafControl( 60, 60 ) );
1313 controls.push_back( CreateLeafControl( 80, 80 ) );
1314 controls.push_back( CreateLeafControl( 100, 100 ) );
1316 for( auto&& iter : controls )
1320 vbox.SetParentOrigin( ParentOrigin::CENTER );
1321 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1323 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1326 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1328 // Ensure layouting happens
1329 application.SendNotification();
1330 application.Render();
1332 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1333 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1335 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1336 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1337 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1339 // 3rd control is set to match parent - this should also be 100 wide
1340 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1341 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1342 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1343 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1345 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1346 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1347 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1348 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1355 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
1357 ToolkitTestApplication application;
1358 tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
1359 tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
1361 Stage stage = Stage::GetCurrent();
1363 auto hbox = Control::New();
1364 auto hboxLayout = Test::CustomLayout::New();
1365 DevelControl::SetLayout( hbox, hboxLayout );
1366 hbox.SetName( "HBox");
1368 std::vector< Control > controls;
1369 controls.push_back( CreateLeafControl( 40, 40 ) );
1370 controls.push_back( CreateLeafControl( 60, 40 ) );
1371 controls.push_back( CreateLeafControl( 80, 40 ) );
1372 controls.push_back( CreateLeafControl( 100, 40 ) );
1374 for( auto&& iter : controls )
1378 hbox.SetParentOrigin( ParentOrigin::CENTER );
1379 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1382 // Ensure layouting happens
1383 application.SendNotification();
1384 application.Render();
1386 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1387 // hbox left justifies elements
1388 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1389 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1390 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1391 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1393 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1394 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1395 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1396 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1398 controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
1399 controls[2].Lower(); // 2->1; 2, 1, 3, 0
1401 application.SendNotification();
1402 application.Render();
1404 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1405 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1406 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1407 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1409 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1410 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1411 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1412 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1417 int UtcDaliLayouting_HboxLayout_TargetSize(void)
1419 ToolkitTestApplication application;
1420 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
1422 Stage stage = Stage::GetCurrent();
1423 auto hbox = Control::New();
1424 auto hboxLayout = LinearLayout::New();
1425 DevelControl::SetLayout( hbox, hboxLayout );
1426 hbox.SetName( "HBox");
1428 std::vector< Control > controls;
1429 controls.push_back( CreateLeafControl( 40, 40 ) );
1430 for( auto&& iter : controls )
1432 iter.SetSize( 100, 100 );
1435 hbox.SetParentOrigin( ParentOrigin::CENTER );
1436 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1439 // Ensure layouting happens
1440 application.SendNotification();
1441 application.Render();
1443 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
1444 // hbox left justifies elements
1445 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1446 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1452 int UtcDaliLayouting_RemoveLayout01(void)
1454 ToolkitTestApplication application;
1455 tet_infoline(" UtcDaliLayouting_RemoveLayout");
1457 Stage stage = Stage::GetCurrent();
1459 auto rootControl = Control::New();
1460 auto absoluteLayout = AbsoluteLayout::New();
1461 DevelControl::SetLayout( rootControl, absoluteLayout );
1462 rootControl.SetName( "AbsoluteLayout" );
1463 stage.Add( rootControl );
1465 auto hbox = Control::New();
1466 auto hboxLayout = LinearLayout::New();
1467 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1468 DevelControl::SetLayout( hbox, hboxLayout );
1469 hbox.SetName( "HBox" );
1471 std::vector< Control > controls;
1472 controls.push_back( CreateLeafControl( 40, 40 ) );
1473 controls.push_back( CreateLeafControl( 60, 40 ) );
1475 for( auto&& iter : controls )
1479 hbox.SetParentOrigin( ParentOrigin::CENTER );
1480 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1481 rootControl.Add( hbox );
1483 tet_infoline("Layout as normal");
1484 application.SendNotification();
1485 application.Render();
1487 tet_infoline("Set an empty layout on hbox container");
1488 LinearLayout emptyLayout;
1489 DevelControl::SetLayout( hbox, emptyLayout );
1491 tet_infoline("Run another layout");
1492 application.SendNotification();
1493 application.Render();
1495 tet_infoline("Check leaf controls haven't moved");
1497 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1498 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1500 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1501 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );