2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
22 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
23 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
24 #include <dali-toolkit/devel-api/controls/control-devel.h>
25 #include <dali-toolkit/devel-api/layouting/hbox-layout.h>
26 #include <dali-toolkit/devel-api/layouting/vbox-layout.h>
27 //#include <dali-toolkit/internal/controls/control/control-data-impl-debug.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;
43 Control CreateLeafControl( int width, int height )
45 auto control = Control::New();
46 control.SetName( "Leaf" );
48 auto pixelBuffer = Devel::PixelBuffer::New( 1, 1, Pixel::RGB888 );
49 unsigned char* pixels = pixelBuffer.GetBuffer();
53 auto texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGB888, 1, 1 );
54 auto pixelData = Devel::PixelBuffer::Convert( pixelBuffer );
55 texture.Upload( pixelData );
56 std::string url = TextureManager::AddTexture( texture );
59 map[ Visual::Property::TYPE ] = Visual::IMAGE;
60 map[ ImageVisual::Property::URL ] = url;
61 map[ ImageVisual::Property::DESIRED_WIDTH ] = (float) width;
62 map[ ImageVisual::Property::DESIRED_HEIGHT ] = (float) height;
63 control.SetProperty( Control::Property::BACKGROUND, map );
67 int UtcDaliLayouting_HboxLayout01(void)
69 ToolkitTestApplication application;
70 tet_infoline(" UtcDaliLayouting_HboxLayout01");
72 Stage stage = Stage::GetCurrent();
73 auto hbox = Control::New();
74 auto hboxLayout = HboxLayout::New();
75 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
76 DevelControl::SetLayout( hbox, hboxLayout );
77 hbox.SetName( "HBox");
79 std::vector< Control > controls;
80 controls.push_back( CreateLeafControl( 40, 40 ) );
81 controls.push_back( CreateLeafControl( 60, 40 ) );
82 controls.push_back( CreateLeafControl( 80, 40 ) );
83 controls.push_back( CreateLeafControl( 100, 40 ) );
85 for( auto&& iter : controls )
89 hbox.SetParentOrigin( ParentOrigin::CENTER );
90 hbox.SetAnchorPoint( AnchorPoint::CENTER );
93 // Ensure layouting happens
94 application.SendNotification();
97 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
98 // hbox left justifies elements
99 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
100 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
101 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
102 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
104 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
105 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
106 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
107 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
112 int UtcDaliLayouting_HboxLayout02(void)
114 ToolkitTestApplication application;
115 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
117 Stage stage = Stage::GetCurrent();
119 auto hbox1 = Control::New();
120 auto hboxLayout1 = HboxLayout::New();
121 DevelControl::SetLayout( hbox1, hboxLayout1 );
123 auto hbox2 = Control::New();
124 auto hboxLayout2 = HboxLayout::New();
125 DevelControl::SetLayout( hbox2, hboxLayout2 );
127 hbox1.SetName( "HBox1");
128 hbox2.SetName( "HBox2");
130 std::vector< Control > controls;
131 controls.push_back( CreateLeafControl( 20, 40 ) );
132 controls.push_back( CreateLeafControl( 30, 50 ) );
133 controls.push_back( CreateLeafControl( 40, 60 ) );
134 controls.push_back( CreateLeafControl( 50, 70 ) );
136 controls.push_back( CreateLeafControl( 25, 40 ) );
137 controls.push_back( CreateLeafControl( 35, 50 ) );
138 controls.push_back( CreateLeafControl( 45, 60 ) );
139 controls.push_back( CreateLeafControl( 55, 70 ) );
142 for( auto&& iter : controls )
154 hbox1.SetParentOrigin( ParentOrigin::CENTER );
155 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
156 hbox2.SetParentOrigin( ParentOrigin::CENTER );
157 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
159 auto hbox3 = Control::New();
160 auto hboxLayout3 = HboxLayout::New();
161 DevelControl::SetLayout( hbox3, hboxLayout3 );
163 hbox3.SetParentOrigin( ParentOrigin::CENTER );
164 hbox3.SetName( "HBox3");
170 // Ensure layouting happens
171 application.SendNotification();
172 application.Render();
175 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
176 // hbox left justifies elements
177 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
178 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
179 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
180 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
182 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
183 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
184 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
185 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
188 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
189 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
190 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
191 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
193 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
194 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
195 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
196 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
198 // Test hbox1 and 2 are sized to wrap their content
199 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
200 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
201 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
202 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
204 // Test hbox3 matches parent (root layer)
205 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
206 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
212 int UtcDaliLayouting_HboxLayout03(void)
214 ToolkitTestApplication application;
215 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
217 Stage stage = Stage::GetCurrent();
219 auto hbox1 = Control::New();
220 auto hboxLayout1 = HboxLayout::New();
221 DevelControl::SetLayout( hbox1, hboxLayout1 );
223 auto hbox2 = Control::New();
224 auto hboxLayout2 = HboxLayout::New();
225 DevelControl::SetLayout( hbox2, hboxLayout2 );
227 hbox1.SetName( "HBox1");
228 hbox2.SetName( "HBox2");
229 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
230 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
231 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
232 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
234 std::vector< Control > controls;
235 controls.push_back( CreateLeafControl( 20, 40 ) );
236 controls.push_back( CreateLeafControl( 30, 50 ) );
237 controls.push_back( CreateLeafControl( 40, 60 ) );
238 controls.push_back( CreateLeafControl( 50, 70 ) );
240 controls.push_back( CreateLeafControl( 25, 40 ) );
241 controls.push_back( CreateLeafControl( 35, 50 ) );
242 controls.push_back( CreateLeafControl( 45, 60 ) );
243 controls.push_back( CreateLeafControl( 55, 70 ) );
246 for( auto&& iter : controls )
258 hbox1.SetParentOrigin( ParentOrigin::CENTER );
259 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
260 hbox2.SetParentOrigin( ParentOrigin::CENTER );
261 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
263 auto hbox3 = Control::New();
264 auto hboxLayout3 = HboxLayout::New();
265 DevelControl::SetLayout( hbox3, hboxLayout3);
267 hbox3.SetParentOrigin( ParentOrigin::CENTER );
268 hbox3.SetName( "HBox3");
274 //std::ostringstream oss;
275 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
276 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
278 // Ensure layouting happens
279 application.SendNotification();
280 application.Render();
283 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
284 // hbox left justifies elements
285 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
286 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
287 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
288 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
290 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
291 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
292 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
293 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
295 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
296 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
297 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
298 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
300 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
301 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
302 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
303 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
305 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
306 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
307 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
308 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
310 // Test hbox3 matches parent (root layer)
311 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
312 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
317 int UtcDaliLayouting_HboxLayout04(void)
319 ToolkitTestApplication application;
320 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
322 Stage stage = Stage::GetCurrent();
324 auto hbox1 = Control::New();
325 auto hboxLayout1 = HboxLayout::New();
326 DevelControl::SetLayout( hbox1, hboxLayout1 );
328 auto hbox2 = Control::New();
329 auto hboxLayout2 = HboxLayout::New();
330 DevelControl::SetLayout( hbox2, hboxLayout2 );
332 hbox1.SetName( "HBox1"); // Default spec is to wrap content
333 hbox2.SetName( "HBox2");
334 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
335 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
336 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
337 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
339 std::vector< Control > controls;
340 controls.push_back( CreateLeafControl( 80, 40 ) );
341 controls.push_back( CreateLeafControl( 80, 50 ) );
342 controls.push_back( CreateLeafControl( 80, 60 ) );
343 controls.push_back( CreateLeafControl( 80, 70 ) );
345 controls.push_back( CreateLeafControl( 80, 40 ) );
346 controls.push_back( CreateLeafControl( 80, 50 ) );
347 controls.push_back( CreateLeafControl( 80, 60 ) );
348 controls.push_back( CreateLeafControl( 80, 70 ) );
351 for( auto&& iter : controls )
364 controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
365 auto hbox3 = Control::New();
366 auto hboxLayout3 = HboxLayout::New();
367 DevelControl::SetLayout( hbox3, hboxLayout3 );
369 hbox3.SetParentOrigin( ParentOrigin::CENTER );
370 hbox3.SetName( "HBox3");
375 //std::ostringstream oss;
376 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
377 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
379 // Ensure layouting happens
380 application.SendNotification();
381 application.Render();
384 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
385 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
386 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
387 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
389 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
390 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
391 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
392 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
394 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
395 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
396 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
397 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
399 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
400 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
401 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
402 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
404 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
405 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
406 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
407 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
410 // Test hbox3 matches parent (root layer)
411 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
412 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
419 int UtcDaliLayouting_HboxLayout_Padding01(void)
421 ToolkitTestApplication application;
422 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
424 Stage stage = Stage::GetCurrent();
425 auto hbox = Control::New();
426 auto hboxLayout = HboxLayout::New();
427 DevelControl::SetLayout( hbox, hboxLayout );
428 hbox.SetName( "HBox");
430 std::vector< Control > controls;
431 controls.push_back( CreateLeafControl( 40, 40 ) );
432 controls.push_back( CreateLeafControl( 60, 40 ) );
433 controls.push_back( CreateLeafControl( 80, 40 ) );
434 controls.push_back( CreateLeafControl( 100, 40 ) );
436 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
437 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
438 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
440 for( auto&& iter : controls )
444 hbox.SetParentOrigin( ParentOrigin::CENTER );
445 hbox.SetAnchorPoint( AnchorPoint::CENTER );
448 // Ensure layouting happens
449 application.SendNotification();
450 application.Render();
452 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
453 // hbox left justifies elements
454 tet_infoline("Test Child Actor Position");
455 float xPositionOfControlBeingTested = 0.0f;
456 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
458 0.0f ), 0.0001f, TEST_LOCATION );
459 xPositionOfControlBeingTested += 40.0f;
461 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
462 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
463 0.0001f, TEST_LOCATION );
465 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
466 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
468 xPositionOfControlBeingTested += 80.0f;
469 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
471 tet_infoline("Test Child Actor Size");
472 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
474 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
475 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
476 0.0001f, TEST_LOCATION );
478 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
479 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
484 int UtcDaliLayouting_HboxLayout_Padding02(void)
486 ToolkitTestApplication application;
487 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
489 Stage stage = Stage::GetCurrent();
490 auto hbox = Control::New();
491 auto hboxLayout = HboxLayout::New();
492 DevelControl::SetLayout( hbox, hboxLayout );
493 hbox.SetName( "HBox");
495 std::vector< Control > controls;
496 controls.push_back( CreateLeafControl( 40, 40 ) );
497 controls.push_back( CreateLeafControl( 60, 40 ) );
498 controls.push_back( CreateLeafControl( 80, 40 ) );
499 controls.push_back( CreateLeafControl( 100, 40 ) );
501 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
503 for( auto&& iter : controls )
505 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
508 hbox.SetParentOrigin( ParentOrigin::CENTER );
509 hbox.SetAnchorPoint( AnchorPoint::CENTER );
512 // Ensure layouting happens
513 application.SendNotification();
514 application.Render();
516 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
517 // hbox left justifies elements
518 tet_infoline("Test Child Actor Position");
519 float xPositionOfControlBeingTested = 0.0f;
520 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
522 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
523 yPositionOfControlBeingTested,
524 0.0f ), 0.0001f, TEST_LOCATION );
525 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
527 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
528 yPositionOfControlBeingTested,
530 0.0001f, TEST_LOCATION );
532 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
533 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
534 yPositionOfControlBeingTested,
535 0.0f ), 0.0001f, TEST_LOCATION );
537 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
538 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
539 yPositionOfControlBeingTested,
540 0.0f ), 0.0001f, TEST_LOCATION );
542 tet_infoline("Test Child Actor Size");
543 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
544 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
545 0.0f ), 0.0001f, TEST_LOCATION );
547 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
548 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
549 0.0f ), 0.0001f, TEST_LOCATION );
551 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
552 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
553 0.0f ), 0.0001f, TEST_LOCATION );
555 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
556 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
557 0.0f ), 0.0001f, TEST_LOCATION );
563 int UtcDaliLayouting_HboxLayout_Padding03(void)
565 ToolkitTestApplication application;
566 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Adding Changing padding on a single child");
568 Stage stage = Stage::GetCurrent();
569 auto hbox = Control::New();
570 auto hboxLayout = HboxLayout::New();
571 DevelControl::SetLayout( hbox, hboxLayout );
572 hbox.SetName( "HBox");
574 std::vector< Control > controls;
575 controls.push_back( CreateLeafControl( 40, 40 ) );
576 controls.push_back( CreateLeafControl( 40, 40 ) );
577 controls.push_back( CreateLeafControl( 40, 40 ) );
579 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
580 tet_printf( "\nAdding Padding to control at index 1 \n" );
581 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
583 for( auto&& iter : controls )
587 hbox.SetParentOrigin( ParentOrigin::CENTER );
588 hbox.SetAnchorPoint( AnchorPoint::CENTER );
591 // Ensure layouting happens
592 application.SendNotification();
593 application.Render();
595 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
596 // hbox left justifies elements
597 tet_infoline("Test Child Actor Position");
598 float xPositionOfControlBeingTested = 0.0f;
599 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
601 0.0f ), 0.0001f, TEST_LOCATION );
602 xPositionOfControlBeingTested += 40.0f;
604 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
605 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
606 0.0001f, TEST_LOCATION );
608 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
609 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
611 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
612 tet_printf( "\nChanging Padding to control at index 1 \n" );
613 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
615 // Ensure layouting happens
616 application.SendNotification();
617 application.Render();
619 xPositionOfControlBeingTested = 0.0f; // reset
621 tet_infoline("Test Child Actor Position");
622 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
624 0.0f ), 0.0001f, TEST_LOCATION );
625 xPositionOfControlBeingTested += 40.0f;
627 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
628 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
629 0.0001f, TEST_LOCATION );
631 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
632 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
633 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
635 tet_infoline("Test Child Actor Size");
636 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
638 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
639 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
640 0.0001f, TEST_LOCATION );
642 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
649 int UtcDaliLayouting_HboxLayout_Margin01(void)
651 ToolkitTestApplication application;
652 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
654 Stage stage = Stage::GetCurrent();
655 auto hbox = Control::New();
656 auto hboxLayout = HboxLayout::New();
657 DevelControl::SetLayout( hbox, hboxLayout );
658 hbox.SetName( "HBox");
660 std::vector< Control > controls;
661 controls.push_back( CreateLeafControl( 40, 40 ) );
662 controls.push_back( CreateLeafControl( 60, 40 ) );
663 controls.push_back( CreateLeafControl( 80, 40 ) );
664 controls.push_back( CreateLeafControl( 100, 40 ) );
666 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
667 tet_printf( "\nAdding Margin to control at index 1 \n" );
668 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
670 for( auto&& iter : controls )
674 hbox.SetParentOrigin( ParentOrigin::CENTER );
675 hbox.SetAnchorPoint( AnchorPoint::CENTER );
678 // Ensure layouting happens
679 application.SendNotification();
680 application.Render();
682 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
683 // hbox left justifies elements
684 tet_infoline("Test Child Actor Position");
685 auto xPositionOfControlBeingTested = 0.0f;
686 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
688 0.0f ), 0.0001f, TEST_LOCATION );
689 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
691 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
692 380.0f + CONTROL_MARGIN.top, 0.0f ),
693 0.0001f, TEST_LOCATION );
695 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
696 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
698 xPositionOfControlBeingTested += 80.0f;
699 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
701 tet_infoline("Test Child Actor Size is the same after Margin added");
702 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
703 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
704 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
705 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
711 int UtcDaliLayouting_VboxLayout01(void)
713 ToolkitTestApplication application;
714 tet_infoline(" UtcDaliLayouting_VboxLayout01");
716 Stage stage = Stage::GetCurrent();
717 auto vbox = Control::New();
718 auto vboxLayout = VboxLayout::New();
719 DevelControl::SetLayout( vbox, vboxLayout );
720 vbox.SetName( "Vbox");
722 std::vector< Control > controls;
723 controls.push_back( CreateLeafControl( 40, 40 ) );
724 controls.push_back( CreateLeafControl( 60, 60 ) );
725 controls.push_back( CreateLeafControl( 80, 80 ) );
726 controls.push_back( CreateLeafControl( 100, 100 ) );
728 for( auto&& iter : controls )
732 vbox.SetParentOrigin( ParentOrigin::CENTER );
733 vbox.SetAnchorPoint( AnchorPoint::CENTER );
736 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
739 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
741 // Ensure layouting happens
742 application.SendNotification();
743 application.Render();
745 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
746 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
747 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
748 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
749 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
751 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
752 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
753 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
754 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
759 int UtcDaliLayouting_VboxLayout02(void)
761 ToolkitTestApplication application;
762 tet_infoline(" UtcDaliLayouting_VboxLayout01");
764 Stage stage = Stage::GetCurrent();
766 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
767 // LayoutGroup for this to happen automatically.
769 // For this test, add an hbox instead
770 auto hbox = Control::New();
771 auto hboxLayout = HboxLayout::New();
772 DevelControl::SetLayout( hbox, hboxLayout );
773 hbox.SetName( "Hbox");
776 auto vbox = Control::New();
777 auto vboxLayout = VboxLayout::New();
778 DevelControl::SetLayout( vbox, vboxLayout );
779 vbox.SetName( "Vbox");
782 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
783 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
785 std::vector< Control > controls;
786 controls.push_back( CreateLeafControl( 40, 40 ) );
787 controls.push_back( CreateLeafControl( 60, 60 ) );
788 controls.push_back( CreateLeafControl( 80, 80 ) );
789 controls.push_back( CreateLeafControl( 100, 100 ) );
791 for( auto&& iter : controls )
795 vbox.SetParentOrigin( ParentOrigin::CENTER );
796 vbox.SetAnchorPoint( AnchorPoint::CENTER );
798 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
801 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
803 // Ensure layouting happens
804 application.SendNotification();
805 application.Render();
807 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
808 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
810 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
811 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
812 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
814 // 3rd control is set to match parent - this should also be 100 wide
815 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
816 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
817 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
818 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
820 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
821 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
822 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
823 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
829 int UtcDaliLayouting_VboxLayout03(void)
831 ToolkitTestApplication application;
832 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
834 Stage stage = Stage::GetCurrent();
836 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
837 // LayoutGroup for this to happen automatically.
839 // For this test, add an hbox instead
840 auto hbox = Control::New();
841 auto hboxLayout = HboxLayout::New();
842 DevelControl::SetLayout( hbox, hboxLayout );
843 hbox.SetName( "Hbox");
846 auto vbox = Control::New();
847 auto vboxLayout = VboxLayout::New();
848 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
850 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
852 DevelControl::SetLayout( vbox, vboxLayout );
853 vbox.SetName( "Vbox");
856 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
857 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
859 std::vector< Control > controls;
860 controls.push_back( CreateLeafControl( 40, 40 ) );
861 controls.push_back( CreateLeafControl( 60, 60 ) );
862 controls.push_back( CreateLeafControl( 80, 80 ) );
863 controls.push_back( CreateLeafControl( 100, 100 ) );
865 for( auto&& iter : controls )
869 vbox.SetParentOrigin( ParentOrigin::CENTER );
870 vbox.SetAnchorPoint( AnchorPoint::CENTER );
872 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
875 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
877 // Ensure layouting happens
878 application.SendNotification();
879 application.Render();
881 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
882 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
884 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
885 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
886 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
888 // 3rd control is set to match parent - this should also be 100 wide
889 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
890 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
891 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
892 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
894 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
895 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
896 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
897 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );