Merge "Control Padding and Margin Properties used for layouts" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-Layouting.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
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>
28
29 using namespace Dali;
30 using namespace Toolkit;
31
32 void utc_dali_toolkit_layouting_startup(void)
33 {
34   test_return_value = TET_UNDEF;
35 }
36
37 void utc_dali_toolkit_layouting_cleanup(void)
38 {
39   test_return_value = TET_PASS;
40 }
41
42
43 Control CreateLeafControl( int width, int height )
44 {
45   auto control = Control::New();
46   control.SetName( "Leaf" );
47
48   auto pixelBuffer = Devel::PixelBuffer::New( 1, 1, Pixel::RGB888 );
49   unsigned char* pixels = pixelBuffer.GetBuffer();
50   pixels[0] = 0xff;
51   pixels[1] = 0x00;
52   pixels[2] = 0x00;
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 );
57
58   Property::Map map;
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 );
64   return control;
65 }
66
67 int UtcDaliLayouting_HboxLayout01(void)
68 {
69   ToolkitTestApplication application;
70   tet_infoline(" UtcDaliLayouting_HboxLayout01");
71
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");
78
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 ) );
84
85   for( auto&& iter : controls )
86   {
87     hbox.Add( iter );
88   }
89   hbox.SetParentOrigin( ParentOrigin::CENTER );
90   hbox.SetAnchorPoint( AnchorPoint::CENTER );
91   stage.Add( hbox );
92
93   // Ensure layouting happens
94   application.SendNotification();
95   application.Render();
96
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 );
103
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 );
108
109   END_TEST;
110 }
111
112 int UtcDaliLayouting_HboxLayout02(void)
113 {
114   ToolkitTestApplication application;
115   tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
116
117   Stage stage = Stage::GetCurrent();
118
119   auto hbox1 = Control::New();
120   auto hboxLayout1 = HboxLayout::New();
121   DevelControl::SetLayout( hbox1, hboxLayout1 );
122
123   auto hbox2 = Control::New();
124   auto hboxLayout2 = HboxLayout::New();
125   DevelControl::SetLayout( hbox2, hboxLayout2 );
126
127   hbox1.SetName( "HBox1");
128   hbox2.SetName( "HBox2");
129
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 ) );
135
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 ) );
140
141   int counter=0;
142   for( auto&& iter : controls )
143   {
144     if( counter < 4 )
145     {
146       hbox1.Add( iter );
147     }
148     else
149     {
150       hbox2.Add( iter );
151     }
152     ++counter;
153   }
154   hbox1.SetParentOrigin( ParentOrigin::CENTER );
155   hbox1.SetAnchorPoint( AnchorPoint::CENTER );
156   hbox2.SetParentOrigin( ParentOrigin::CENTER );
157   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
158
159   auto hbox3 = Control::New();
160   auto hboxLayout3 = HboxLayout::New();
161   DevelControl::SetLayout( hbox3, hboxLayout3 );
162
163   hbox3.SetParentOrigin( ParentOrigin::CENTER );
164   hbox3.SetName( "HBox3");
165   hbox3.Add( hbox1 );
166   hbox3.Add( hbox2 );
167
168   stage.Add( hbox3 );
169
170   // Ensure layouting happens
171   application.SendNotification();
172   application.Render();
173
174
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 );
181
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 );
186
187
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 );
192
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 );
197
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 );
203
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 );
207
208   END_TEST;
209 }
210
211
212 int UtcDaliLayouting_HboxLayout03(void)
213 {
214   ToolkitTestApplication application;
215   tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
216
217   Stage stage = Stage::GetCurrent();
218
219   auto hbox1 = Control::New();
220   auto hboxLayout1 = HboxLayout::New();
221   DevelControl::SetLayout( hbox1, hboxLayout1 );
222
223   auto hbox2 = Control::New();
224   auto hboxLayout2 = HboxLayout::New();
225   DevelControl::SetLayout( hbox2, hboxLayout2 );
226
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 );
233
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 ) );
239
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 ) );
244
245   int counter=0;
246   for( auto&& iter : controls )
247   {
248     if( counter < 4 )
249     {
250       hbox1.Add( iter );
251     }
252     else
253     {
254       hbox2.Add( iter );
255     }
256     ++counter;
257   }
258   hbox1.SetParentOrigin( ParentOrigin::CENTER );
259   hbox1.SetAnchorPoint( AnchorPoint::CENTER );
260   hbox2.SetParentOrigin( ParentOrigin::CENTER );
261   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
262
263   auto hbox3 = Control::New();
264   auto hboxLayout3 = HboxLayout::New();
265   DevelControl::SetLayout( hbox3, hboxLayout3);
266
267   hbox3.SetParentOrigin( ParentOrigin::CENTER );
268   hbox3.SetName( "HBox3");
269   hbox3.Add( hbox1 );
270   hbox3.Add( hbox2 );
271
272   stage.Add( hbox3 );
273
274   //std::ostringstream oss;
275   //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
276   //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
277
278   // Ensure layouting happens
279   application.SendNotification();
280   application.Render();
281
282
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 );
289
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 );
294
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 );
299
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 );
304
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 );
309
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 );
313
314   END_TEST;
315 }
316
317 int UtcDaliLayouting_HboxLayout04(void)
318 {
319   ToolkitTestApplication application;
320   tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
321
322   Stage stage = Stage::GetCurrent();
323
324   auto hbox1 = Control::New();
325   auto hboxLayout1 = HboxLayout::New();
326   DevelControl::SetLayout( hbox1, hboxLayout1 );
327
328   auto hbox2 = Control::New();
329   auto hboxLayout2 = HboxLayout::New();
330   DevelControl::SetLayout( hbox2, hboxLayout2 );
331
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 );
338
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 ) );
344
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 ) );
349
350   int counter=0;
351   for( auto&& iter : controls )
352   {
353     if( counter < 4 )
354     {
355       hbox1.Add( iter );
356     }
357     else
358     {
359       hbox2.Add( iter );
360     }
361     ++counter;
362   }
363
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 );
368
369   hbox3.SetParentOrigin( ParentOrigin::CENTER );
370   hbox3.SetName( "HBox3");
371   hbox3.Add( hbox1 );
372   hbox3.Add( hbox2 );
373   stage.Add( hbox3 );
374
375   //std::ostringstream oss;
376   //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
377   //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
378
379   // Ensure layouting happens
380   application.SendNotification();
381   application.Render();
382
383
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 );
388
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 );
393
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 );
398
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 );
403
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 );
408
409
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 );
413
414   END_TEST;
415 }
416
417 // Padding tests
418
419 int UtcDaliLayouting_HboxLayout_Padding01(void)
420 {
421   ToolkitTestApplication application;
422   tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
423
424   Stage stage = Stage::GetCurrent();
425   auto hbox = Control::New();
426   auto hboxLayout = HboxLayout::New();
427   DevelControl::SetLayout( hbox, hboxLayout );
428   hbox.SetName( "HBox");
429
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 ) );
435
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 );
439
440   for( auto&& iter : controls )
441   {
442     hbox.Add( iter );
443   }
444   hbox.SetParentOrigin( ParentOrigin::CENTER );
445   hbox.SetAnchorPoint( AnchorPoint::CENTER );
446   stage.Add( hbox );
447
448   // Ensure layouting happens
449   application.SendNotification();
450   application.Render();
451
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,
457                                                                                             380.0f,
458                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
459   xPositionOfControlBeingTested += 40.0f;
460
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 );
464
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 );
467
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 );
470
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 );
473
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 );
477
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 );
480
481   END_TEST;
482 }
483
484 int UtcDaliLayouting_HboxLayout_Padding02(void)
485 {
486   ToolkitTestApplication application;
487   tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
488
489   Stage stage = Stage::GetCurrent();
490   auto hbox = Control::New();
491   auto hboxLayout = HboxLayout::New();
492   DevelControl::SetLayout( hbox, hboxLayout );
493   hbox.SetName( "HBox");
494
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 ) );
500
501   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
502
503   for( auto&& iter : controls )
504   {
505     iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
506     hbox.Add( iter );
507   }
508   hbox.SetParentOrigin( ParentOrigin::CENTER );
509   hbox.SetAnchorPoint( AnchorPoint::CENTER );
510   stage.Add( hbox );
511
512   // Ensure layouting happens
513   application.SendNotification();
514   application.Render();
515
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 ) );
521
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;
526
527   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
528                                                                                             yPositionOfControlBeingTested,
529                                                                                             0.0f ),
530                                                                                             0.0001f, TEST_LOCATION );
531
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 );
536
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 );
541
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 );
546
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 );
550
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 );
554
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 );
558
559   END_TEST;
560 }
561
562
563 int UtcDaliLayouting_HboxLayout_Padding03(void)
564 {
565   ToolkitTestApplication application;
566   tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Adding Changing padding on a single child");
567
568   Stage stage = Stage::GetCurrent();
569   auto hbox = Control::New();
570   auto hboxLayout = HboxLayout::New();
571   DevelControl::SetLayout( hbox, hboxLayout );
572   hbox.SetName( "HBox");
573
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 ) );
578
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 );
582
583   for( auto&& iter : controls )
584   {
585     hbox.Add( iter );
586   }
587   hbox.SetParentOrigin( ParentOrigin::CENTER );
588   hbox.SetAnchorPoint( AnchorPoint::CENTER );
589   stage.Add( hbox );
590
591   // Ensure layouting happens
592   application.SendNotification();
593   application.Render();
594
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,
600                                                                                             380.0f,
601                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
602   xPositionOfControlBeingTested += 40.0f;
603
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 );
607
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 );
610
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 );
614
615   // Ensure layouting happens
616   application.SendNotification();
617   application.Render();
618
619   xPositionOfControlBeingTested = 0.0f; // reset
620
621   tet_infoline("Test Child Actor Position");
622   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
623                                                                                             380.0f,
624                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
625   xPositionOfControlBeingTested += 40.0f;
626
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 );
630
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 );
634
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 );
637
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 );
641
642   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
643
644   END_TEST;
645 }
646
647 // Margin Tests
648
649 int UtcDaliLayouting_HboxLayout_Margin01(void)
650 {
651   ToolkitTestApplication application;
652   tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
653
654   Stage stage = Stage::GetCurrent();
655   auto hbox = Control::New();
656   auto hboxLayout = HboxLayout::New();
657   DevelControl::SetLayout( hbox, hboxLayout );
658   hbox.SetName( "HBox");
659
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 ) );
665
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 );
669
670   for( auto&& iter : controls )
671   {
672     hbox.Add( iter );
673   }
674   hbox.SetParentOrigin( ParentOrigin::CENTER );
675   hbox.SetAnchorPoint( AnchorPoint::CENTER );
676   stage.Add( hbox );
677
678   // Ensure layouting happens
679   application.SendNotification();
680   application.Render();
681
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,
687                                                                                             380.0f,
688                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
689   xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
690
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 );
694
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 );
697
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 );
700
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 );
706
707   END_TEST;
708 }
709
710
711 int UtcDaliLayouting_VboxLayout01(void)
712 {
713   ToolkitTestApplication application;
714   tet_infoline(" UtcDaliLayouting_VboxLayout01");
715
716   Stage stage = Stage::GetCurrent();
717   auto vbox = Control::New();
718   auto vboxLayout = VboxLayout::New();
719   DevelControl::SetLayout( vbox, vboxLayout );
720   vbox.SetName( "Vbox");
721
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 ) );
727
728   for( auto&& iter : controls )
729   {
730     vbox.Add( iter );
731   }
732   vbox.SetParentOrigin( ParentOrigin::CENTER );
733   vbox.SetAnchorPoint( AnchorPoint::CENTER );
734   stage.Add( vbox );
735
736   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
737
738   // Check it.
739   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
740
741   // Ensure layouting happens
742   application.SendNotification();
743   application.Render();
744
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 );
750
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 );
755
756   END_TEST;
757 }
758
759 int UtcDaliLayouting_VboxLayout02(void)
760 {
761   ToolkitTestApplication application;
762   tet_infoline(" UtcDaliLayouting_VboxLayout01");
763
764   Stage stage = Stage::GetCurrent();
765
766   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
767   // LayoutGroup for this to happen automatically.
768   //
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");
774   stage.Add( hbox );
775
776   auto vbox = Control::New();
777   auto vboxLayout = VboxLayout::New();
778   DevelControl::SetLayout( vbox, vboxLayout );
779   vbox.SetName( "Vbox");
780   hbox.Add( vbox );
781
782   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
783   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
784
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 ) );
790
791   for( auto&& iter : controls )
792   {
793     vbox.Add( iter );
794   }
795   vbox.SetParentOrigin( ParentOrigin::CENTER );
796   vbox.SetAnchorPoint( AnchorPoint::CENTER );
797
798   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
799
800   // Check it.
801   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
802
803   // Ensure layouting happens
804   application.SendNotification();
805   application.Render();
806
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);
809
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 );
813
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 );
819
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 );
824
825   END_TEST;
826 }
827
828
829 int UtcDaliLayouting_VboxLayout03(void)
830 {
831   ToolkitTestApplication application;
832   tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
833
834   Stage stage = Stage::GetCurrent();
835
836   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
837   // LayoutGroup for this to happen automatically.
838   //
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");
844   stage.Add( hbox );
845
846   auto vbox = Control::New();
847   auto vboxLayout = VboxLayout::New();
848   vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
849
850   DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
851
852   DevelControl::SetLayout( vbox, vboxLayout );
853   vbox.SetName( "Vbox");
854   hbox.Add( vbox );
855
856   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
857   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
858
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 ) );
864
865   for( auto&& iter : controls )
866   {
867     vbox.Add( iter );
868   }
869   vbox.SetParentOrigin( ParentOrigin::CENTER );
870   vbox.SetAnchorPoint( AnchorPoint::CENTER );
871
872   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
873
874   // Check it.
875   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
876
877   // Ensure layouting happens
878   application.SendNotification();
879   application.Render();
880
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);
883
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 );
887
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 );
893
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 );
898
899   END_TEST;
900 }