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 );
115 int UtcDaliLayouting_HboxLayout02(void)
117 ToolkitTestApplication application;
118 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
120 Stage stage = Stage::GetCurrent();
122 auto hbox1 = Control::New();
123 auto hboxLayout1 = HboxLayout::New();
124 DevelControl::SetLayout( hbox1, hboxLayout1 );
126 auto hbox2 = Control::New();
127 auto hboxLayout2 = HboxLayout::New();
128 DevelControl::SetLayout( hbox2, hboxLayout2 );
130 hbox1.SetName( "HBox1");
131 hbox2.SetName( "HBox2");
133 std::vector< Control > controls;
134 controls.push_back( CreateLeafControl( 20, 40 ) );
135 controls.push_back( CreateLeafControl( 30, 50 ) );
136 controls.push_back( CreateLeafControl( 40, 60 ) );
137 controls.push_back( CreateLeafControl( 50, 70 ) );
139 controls.push_back( CreateLeafControl( 25, 40 ) );
140 controls.push_back( CreateLeafControl( 35, 50 ) );
141 controls.push_back( CreateLeafControl( 45, 60 ) );
142 controls.push_back( CreateLeafControl( 55, 70 ) );
145 for( auto&& iter : controls )
157 hbox1.SetParentOrigin( ParentOrigin::CENTER );
158 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
159 hbox2.SetParentOrigin( ParentOrigin::CENTER );
160 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
162 auto hbox3 = Control::New();
163 auto hboxLayout3 = HboxLayout::New();
164 DevelControl::SetLayout( hbox3, hboxLayout3 );
166 hbox3.SetParentOrigin( ParentOrigin::CENTER );
167 hbox3.SetName( "HBox3");
173 // Ensure layouting happens
174 application.SendNotification();
175 application.Render();
178 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
179 // hbox left justifies elements
180 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
181 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
182 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
183 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
185 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
186 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
187 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
188 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
191 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
192 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
193 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
194 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
196 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
197 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
198 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
199 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
201 // Test hbox1 and 2 are sized to wrap their content
202 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
203 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
204 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
205 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
207 // Test hbox3 matches parent (root layer)
208 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
209 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
215 int UtcDaliLayouting_HboxLayout03(void)
217 ToolkitTestApplication application;
218 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
220 Stage stage = Stage::GetCurrent();
222 auto hbox1 = Control::New();
223 auto hboxLayout1 = HboxLayout::New();
224 DevelControl::SetLayout( hbox1, hboxLayout1 );
226 auto hbox2 = Control::New();
227 auto hboxLayout2 = HboxLayout::New();
228 DevelControl::SetLayout( hbox2, hboxLayout2 );
230 hbox1.SetName( "HBox1");
231 hbox2.SetName( "HBox2");
232 hbox1.SetProperty( Toolkit::LayoutBase::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
233 hbox1.SetProperty( Toolkit::LayoutBase::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
234 hbox2.SetProperty( Toolkit::LayoutBase::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
235 hbox2.SetProperty( Toolkit::LayoutBase::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
237 std::vector< Control > controls;
238 controls.push_back( CreateLeafControl( 20, 40 ) );
239 controls.push_back( CreateLeafControl( 30, 50 ) );
240 controls.push_back( CreateLeafControl( 40, 60 ) );
241 controls.push_back( CreateLeafControl( 50, 70 ) );
243 controls.push_back( CreateLeafControl( 25, 40 ) );
244 controls.push_back( CreateLeafControl( 35, 50 ) );
245 controls.push_back( CreateLeafControl( 45, 60 ) );
246 controls.push_back( CreateLeafControl( 55, 70 ) );
249 for( auto&& iter : controls )
261 hbox1.SetParentOrigin( ParentOrigin::CENTER );
262 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
263 hbox2.SetParentOrigin( ParentOrigin::CENTER );
264 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
266 auto hbox3 = Control::New();
267 auto hboxLayout3 = HboxLayout::New();
268 DevelControl::SetLayout( hbox3, hboxLayout3);
270 hbox3.SetParentOrigin( ParentOrigin::CENTER );
271 hbox3.SetName( "HBox3");
277 //std::ostringstream oss;
278 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
279 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
281 // Ensure layouting happens
282 application.SendNotification();
283 application.Render();
286 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
287 // hbox left justifies elements
288 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
289 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
290 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
291 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
293 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
294 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
295 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
296 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
298 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
299 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
300 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
301 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
303 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
304 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
305 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
306 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
308 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
309 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
310 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
311 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
313 // Test hbox3 matches parent (root layer)
314 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
315 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
323 int UtcDaliLayouting_HboxLayout04(void)
325 ToolkitTestApplication application;
326 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
328 Stage stage = Stage::GetCurrent();
330 auto hbox1 = Control::New();
331 auto hboxLayout1 = HboxLayout::New();
332 DevelControl::SetLayout( hbox1, hboxLayout1 );
334 auto hbox2 = Control::New();
335 auto hboxLayout2 = HboxLayout::New();
336 DevelControl::SetLayout( hbox2, hboxLayout2 );
338 hbox1.SetName( "HBox1"); // Default spec is to wrap content
339 hbox2.SetName( "HBox2");
340 hbox1.SetProperty( Toolkit::LayoutBase::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
341 hbox1.SetProperty( Toolkit::LayoutBase::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
342 hbox2.SetProperty( Toolkit::LayoutBase::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
343 hbox2.SetProperty( Toolkit::LayoutBase::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
345 std::vector< Control > controls;
346 controls.push_back( CreateLeafControl( 80, 40 ) );
347 controls.push_back( CreateLeafControl( 80, 50 ) );
348 controls.push_back( CreateLeafControl( 80, 60 ) );
349 controls.push_back( CreateLeafControl( 80, 70 ) );
351 controls.push_back( CreateLeafControl( 80, 40 ) );
352 controls.push_back( CreateLeafControl( 80, 50 ) );
353 controls.push_back( CreateLeafControl( 80, 60 ) );
354 controls.push_back( CreateLeafControl( 80, 70 ) );
357 for( auto&& iter : controls )
370 controls[6].SetProperty( Toolkit::LayoutBase::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
371 auto hbox3 = Control::New();
372 auto hboxLayout3 = HboxLayout::New();
373 DevelControl::SetLayout( hbox3, hboxLayout3 );
375 hbox3.SetParentOrigin( ParentOrigin::CENTER );
376 hbox3.SetName( "HBox3");
381 //std::ostringstream oss;
382 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
383 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
385 // Ensure layouting happens
386 application.SendNotification();
387 application.Render();
390 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
391 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
392 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
393 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
395 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
396 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
397 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
398 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
400 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
401 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
402 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
403 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
405 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
406 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
407 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
408 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
410 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
411 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
412 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
413 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
416 // Test hbox3 matches parent (root layer)
417 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
418 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
424 int UtcDaliLayouting_VboxLayout01(void)
426 ToolkitTestApplication application;
427 tet_infoline(" UtcDaliLayouting_VboxLayout01");
429 Stage stage = Stage::GetCurrent();
430 auto vbox = Control::New();
431 auto vboxLayout = VboxLayout::New();
432 DevelControl::SetLayout( vbox, vboxLayout );
433 vbox.SetName( "Vbox");
435 std::vector< Control > controls;
436 controls.push_back( CreateLeafControl( 40, 40 ) );
437 controls.push_back( CreateLeafControl( 60, 60 ) );
438 controls.push_back( CreateLeafControl( 80, 80 ) );
439 controls.push_back( CreateLeafControl( 100, 100 ) );
441 for( auto&& iter : controls )
445 vbox.SetParentOrigin( ParentOrigin::CENTER );
446 vbox.SetAnchorPoint( AnchorPoint::CENTER );
449 controls[2].SetProperty( Toolkit::LayoutBase::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
452 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutBase::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
454 // Ensure layouting happens
455 application.SendNotification();
456 application.Render();
458 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
459 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
460 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
461 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
462 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
464 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
465 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
466 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
467 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
472 int UtcDaliLayouting_VboxLayout02(void)
474 ToolkitTestApplication application;
475 tet_infoline(" UtcDaliLayouting_VboxLayout01");
477 Stage stage = Stage::GetCurrent();
479 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
480 // LayoutGroup for this to happen automatically.
482 // For this test, add an hbox instead
483 auto hbox = Control::New();
484 auto hboxLayout = HboxLayout::New();
485 DevelControl::SetLayout( hbox, hboxLayout );
486 hbox.SetName( "Hbox");
489 auto vbox = Control::New();
490 auto vboxLayout = VboxLayout::New();
491 DevelControl::SetLayout( vbox, vboxLayout );
492 vbox.SetName( "Vbox");
495 vbox.SetProperty( Toolkit::LayoutBase::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
496 vbox.SetProperty( Toolkit::LayoutBase::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
498 std::vector< Control > controls;
499 controls.push_back( CreateLeafControl( 40, 40 ) );
500 controls.push_back( CreateLeafControl( 60, 60 ) );
501 controls.push_back( CreateLeafControl( 80, 80 ) );
502 controls.push_back( CreateLeafControl( 100, 100 ) );
504 for( auto&& iter : controls )
508 vbox.SetParentOrigin( ParentOrigin::CENTER );
509 vbox.SetAnchorPoint( AnchorPoint::CENTER );
511 controls[2].SetProperty( Toolkit::LayoutBase::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
514 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutBase::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
516 // Ensure layouting happens
517 application.SendNotification();
518 application.Render();
520 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
521 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
523 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
524 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
525 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
527 // 3rd control is set to match parent - this should also be 100 wide
528 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
529 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
530 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
531 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
533 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
534 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
535 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
536 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
542 int UtcDaliLayouting_VboxLayout03(void)
544 ToolkitTestApplication application;
545 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
547 Stage stage = Stage::GetCurrent();
549 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
550 // LayoutGroup for this to happen automatically.
552 // For this test, add an hbox instead
553 auto hbox = Control::New();
554 auto hboxLayout = HboxLayout::New();
555 DevelControl::SetLayout( hbox, hboxLayout );
556 hbox.SetName( "Hbox");
559 auto vbox = Control::New();
560 auto vboxLayout = VboxLayout::New();
561 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
563 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
565 DevelControl::SetLayout( vbox, vboxLayout );
566 vbox.SetName( "Vbox");
569 vbox.SetProperty( Toolkit::LayoutBase::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
570 vbox.SetProperty( Toolkit::LayoutBase::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
572 std::vector< Control > controls;
573 controls.push_back( CreateLeafControl( 40, 40 ) );
574 controls.push_back( CreateLeafControl( 60, 60 ) );
575 controls.push_back( CreateLeafControl( 80, 80 ) );
576 controls.push_back( CreateLeafControl( 100, 100 ) );
578 for( auto&& iter : controls )
582 vbox.SetParentOrigin( ParentOrigin::CENTER );
583 vbox.SetAnchorPoint( AnchorPoint::CENTER );
585 controls[2].SetProperty( Toolkit::LayoutBase::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
588 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutBase::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
590 // Ensure layouting happens
591 application.SendNotification();
592 application.Render();
594 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
595 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
597 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
598 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
599 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
601 // 3rd control is set to match parent - this should also be 100 wide
602 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
603 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
604 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
605 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
607 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
608 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
609 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
610 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );