Merge "Add FlexLayout." 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
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali-toolkit/devel-api/controls/control-devel.h>
24 #include <dali-toolkit/devel-api/layouting/hbox-layout.h>
25 #include <dali-toolkit/devel-api/layouting/vbox-layout.h>
26
27 #include <layout-utils.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 int UtcDaliLayouting_HboxLayout01(void)
43 {
44   ToolkitTestApplication application;
45   tet_infoline(" UtcDaliLayouting_HboxLayout01");
46
47   Stage stage = Stage::GetCurrent();
48   auto hbox = Control::New();
49   auto hboxLayout = HboxLayout::New();
50   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
51   DevelControl::SetLayout( hbox, hboxLayout );
52   hbox.SetName( "HBox");
53
54   std::vector< Control > controls;
55   controls.push_back( CreateLeafControl( 40, 40 ) );
56   controls.push_back( CreateLeafControl( 60, 40 ) );
57   controls.push_back( CreateLeafControl( 80, 40 ) );
58   controls.push_back( CreateLeafControl( 100, 40 ) );
59
60   for( auto&& iter : controls )
61   {
62     hbox.Add( iter );
63   }
64   hbox.SetParentOrigin( ParentOrigin::CENTER );
65   hbox.SetAnchorPoint( AnchorPoint::CENTER );
66   stage.Add( hbox );
67
68   // Ensure layouting happens
69   application.SendNotification();
70   application.Render();
71
72   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
73   // hbox left justifies elements
74   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
75   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
76   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
77   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
78
79   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
80   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
81   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
82   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
83
84   END_TEST;
85 }
86
87 int UtcDaliLayouting_HboxLayout02(void)
88 {
89   ToolkitTestApplication application;
90   tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
91
92   Stage stage = Stage::GetCurrent();
93
94   auto hbox1 = Control::New();
95   auto hboxLayout1 = HboxLayout::New();
96   DevelControl::SetLayout( hbox1, hboxLayout1 );
97
98   auto hbox2 = Control::New();
99   auto hboxLayout2 = HboxLayout::New();
100   DevelControl::SetLayout( hbox2, hboxLayout2 );
101
102   hbox1.SetName( "HBox1");
103   hbox2.SetName( "HBox2");
104
105   std::vector< Control > controls;
106   controls.push_back( CreateLeafControl( 20, 40 ) );
107   controls.push_back( CreateLeafControl( 30, 50 ) );
108   controls.push_back( CreateLeafControl( 40, 60 ) );
109   controls.push_back( CreateLeafControl( 50, 70 ) );
110
111   controls.push_back( CreateLeafControl( 25, 40 ) );
112   controls.push_back( CreateLeafControl( 35, 50 ) );
113   controls.push_back( CreateLeafControl( 45, 60 ) );
114   controls.push_back( CreateLeafControl( 55, 70 ) );
115
116   int counter=0;
117   for( auto&& iter : controls )
118   {
119     if( counter < 4 )
120     {
121       hbox1.Add( iter );
122     }
123     else
124     {
125       hbox2.Add( iter );
126     }
127     ++counter;
128   }
129   hbox1.SetParentOrigin( ParentOrigin::CENTER );
130   hbox1.SetAnchorPoint( AnchorPoint::CENTER );
131   hbox2.SetParentOrigin( ParentOrigin::CENTER );
132   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
133
134   auto hbox3 = Control::New();
135   auto hboxLayout3 = HboxLayout::New();
136   DevelControl::SetLayout( hbox3, hboxLayout3 );
137
138   hbox3.SetParentOrigin( ParentOrigin::CENTER );
139   hbox3.SetName( "HBox3");
140   hbox3.Add( hbox1 );
141   hbox3.Add( hbox2 );
142
143   stage.Add( hbox3 );
144
145   // Ensure layouting happens
146   application.SendNotification();
147   application.Render();
148
149
150   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
151   // hbox left justifies elements
152   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
153   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
154   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,  5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
155   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,  0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
156
157   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
158   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
159   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
160   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
161
162
163   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
164   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
165   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f,  5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
166   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,  0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
167
168   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
169   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
170   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
171   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
172
173   // Test hbox1 and 2 are sized to wrap their content
174   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
175   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
176   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
177   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
178
179   // Test hbox3 matches parent (root layer)
180   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
181   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
182
183   END_TEST;
184 }
185
186
187 int UtcDaliLayouting_HboxLayout03(void)
188 {
189   ToolkitTestApplication application;
190   tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
191
192   Stage stage = Stage::GetCurrent();
193
194   auto hbox1 = Control::New();
195   auto hboxLayout1 = HboxLayout::New();
196   DevelControl::SetLayout( hbox1, hboxLayout1 );
197
198   auto hbox2 = Control::New();
199   auto hboxLayout2 = HboxLayout::New();
200   DevelControl::SetLayout( hbox2, hboxLayout2 );
201
202   hbox1.SetName( "HBox1");
203   hbox2.SetName( "HBox2");
204   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
205   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
206   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
207   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
208
209   std::vector< Control > controls;
210   controls.push_back( CreateLeafControl( 20, 40 ) );
211   controls.push_back( CreateLeafControl( 30, 50 ) );
212   controls.push_back( CreateLeafControl( 40, 60 ) );
213   controls.push_back( CreateLeafControl( 50, 70 ) );
214
215   controls.push_back( CreateLeafControl( 25, 40 ) );
216   controls.push_back( CreateLeafControl( 35, 50 ) );
217   controls.push_back( CreateLeafControl( 45, 60 ) );
218   controls.push_back( CreateLeafControl( 55, 70 ) );
219
220   int counter=0;
221   for( auto&& iter : controls )
222   {
223     if( counter < 4 )
224     {
225       hbox1.Add( iter );
226     }
227     else
228     {
229       hbox2.Add( iter );
230     }
231     ++counter;
232   }
233   hbox1.SetParentOrigin( ParentOrigin::CENTER );
234   hbox1.SetAnchorPoint( AnchorPoint::CENTER );
235   hbox2.SetParentOrigin( ParentOrigin::CENTER );
236   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
237
238   auto hbox3 = Control::New();
239   auto hboxLayout3 = HboxLayout::New();
240   DevelControl::SetLayout( hbox3, hboxLayout3);
241
242   hbox3.SetParentOrigin( ParentOrigin::CENTER );
243   hbox3.SetName( "HBox3");
244   hbox3.Add( hbox1 );
245   hbox3.Add( hbox2 );
246
247   stage.Add( hbox3 );
248
249   //std::ostringstream oss;
250   //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
251   //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
252
253   // Ensure layouting happens
254   application.SendNotification();
255   application.Render();
256
257
258   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
259   // hbox left justifies elements
260   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
261   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
262   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
263   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
264
265   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
266   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
267   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
268   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
269
270   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
271   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
272   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
273   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
274
275   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
276   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
277   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
278   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
279
280   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
281   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
282   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
283   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
284
285   // Test hbox3 matches parent (root layer)
286   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
287   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
288
289   END_TEST;
290 }
291
292 int UtcDaliLayouting_HboxLayout04(void)
293 {
294   ToolkitTestApplication application;
295   tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
296
297   Stage stage = Stage::GetCurrent();
298
299   auto hbox1 = Control::New();
300   auto hboxLayout1 = HboxLayout::New();
301   DevelControl::SetLayout( hbox1, hboxLayout1 );
302
303   auto hbox2 = Control::New();
304   auto hboxLayout2 = HboxLayout::New();
305   DevelControl::SetLayout( hbox2, hboxLayout2 );
306
307   hbox1.SetName( "HBox1"); // Default spec is to wrap content
308   hbox2.SetName( "HBox2");
309   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
310   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
311   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
312   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
313
314   std::vector< Control > controls;
315   controls.push_back( CreateLeafControl( 80, 40 ) );
316   controls.push_back( CreateLeafControl( 80, 50 ) );
317   controls.push_back( CreateLeafControl( 80, 60 ) );
318   controls.push_back( CreateLeafControl( 80, 70 ) );
319
320   controls.push_back( CreateLeafControl( 80, 40 ) );
321   controls.push_back( CreateLeafControl( 80, 50 ) );
322   controls.push_back( CreateLeafControl( 80, 60 ) );
323   controls.push_back( CreateLeafControl( 80, 70 ) );
324
325   int counter=0;
326   for( auto&& iter : controls )
327   {
328     if( counter < 4 )
329     {
330       hbox1.Add( iter );
331     }
332     else
333     {
334       hbox2.Add( iter );
335     }
336     ++counter;
337   }
338
339   controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
340   auto hbox3 = Control::New();
341   auto hboxLayout3 = HboxLayout::New();
342   DevelControl::SetLayout( hbox3, hboxLayout3 );
343
344   hbox3.SetParentOrigin( ParentOrigin::CENTER );
345   hbox3.SetName( "HBox3");
346   hbox3.Add( hbox1 );
347   hbox3.Add( hbox2 );
348   stage.Add( hbox3 );
349
350   //std::ostringstream oss;
351   //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
352   //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
353
354   // Ensure layouting happens
355   application.SendNotification();
356   application.Render();
357
358
359   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
360   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
361   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
362   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
363
364   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
365   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
366   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
367   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
368
369   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
370   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
371   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
372   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
373
374   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
375   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
376   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
377   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
378
379   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
380   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
381   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
382   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
383
384
385   // Test hbox3 matches parent (root layer)
386   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
387   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
388
389   END_TEST;
390 }
391
392 // Padding tests
393
394 int UtcDaliLayouting_HboxLayout_Padding01(void)
395 {
396   ToolkitTestApplication application;
397   tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
398
399   Stage stage = Stage::GetCurrent();
400   auto hbox = Control::New();
401   auto hboxLayout = HboxLayout::New();
402   DevelControl::SetLayout( hbox, hboxLayout );
403   hbox.SetName( "HBox");
404
405   std::vector< Control > controls;
406   controls.push_back( CreateLeafControl( 40, 40 ) );
407   controls.push_back( CreateLeafControl( 60, 40 ) );
408   controls.push_back( CreateLeafControl( 80, 40 ) );
409   controls.push_back( CreateLeafControl( 100, 40 ) );
410
411   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
412   tet_printf( "\nAdding Padding to control at index %u \n", 1 );
413   controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
414
415   for( auto&& iter : controls )
416   {
417     hbox.Add( iter );
418   }
419   hbox.SetParentOrigin( ParentOrigin::CENTER );
420   hbox.SetAnchorPoint( AnchorPoint::CENTER );
421   stage.Add( hbox );
422
423   // Ensure layouting happens
424   application.SendNotification();
425   application.Render();
426
427   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
428   // hbox left justifies elements
429   tet_infoline("Test Child Actor Position");
430   float xPositionOfControlBeingTested = 0.0f;
431   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
432                                                                                             380.0f,
433                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
434   xPositionOfControlBeingTested += 40.0f;
435
436   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
437                                                                                             380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
438                                                                                             0.0001f, TEST_LOCATION );
439
440   xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
441   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
442
443   xPositionOfControlBeingTested += 80.0f;
444   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
445
446   tet_infoline("Test Child Actor Size");
447   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
448
449   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
450                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
451                                                                                         0.0001f, TEST_LOCATION );
452
453   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
454   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
455
456   END_TEST;
457 }
458
459 int UtcDaliLayouting_HboxLayout_Padding02(void)
460 {
461   ToolkitTestApplication application;
462   tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
463
464   Stage stage = Stage::GetCurrent();
465   auto hbox = Control::New();
466   auto hboxLayout = HboxLayout::New();
467   DevelControl::SetLayout( hbox, hboxLayout );
468   hbox.SetName( "HBox");
469
470   std::vector< Control > controls;
471   controls.push_back( CreateLeafControl( 40, 40 ) );
472   controls.push_back( CreateLeafControl( 60, 40 ) );
473   controls.push_back( CreateLeafControl( 80, 40 ) );
474   controls.push_back( CreateLeafControl( 100, 40 ) );
475
476   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
477
478   for( auto&& iter : controls )
479   {
480     iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
481     hbox.Add( iter );
482   }
483   hbox.SetParentOrigin( ParentOrigin::CENTER );
484   hbox.SetAnchorPoint( AnchorPoint::CENTER );
485   stage.Add( hbox );
486
487   // Ensure layouting happens
488   application.SendNotification();
489   application.Render();
490
491   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
492   // hbox left justifies elements
493   tet_infoline("Test Child Actor Position");
494   float xPositionOfControlBeingTested = 0.0f;
495   float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
496
497   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
498                                                                                             yPositionOfControlBeingTested,
499                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
500   xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
501
502   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
503                                                                                             yPositionOfControlBeingTested,
504                                                                                             0.0f ),
505                                                                                             0.0001f, TEST_LOCATION );
506
507   xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
508   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
509                                                                                             yPositionOfControlBeingTested,
510                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
511
512   xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
513   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
514                                                                                             yPositionOfControlBeingTested,
515                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
516
517   tet_infoline("Test Child Actor Size");
518   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
519                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
520                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
521
522   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
523                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
524                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
525
526   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
527                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
528                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
529
530   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
531                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
532                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
533
534   END_TEST;
535 }
536
537
538 int UtcDaliLayouting_HboxLayout_Padding03(void)
539 {
540   ToolkitTestApplication application;
541   tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Adding Changing padding on a single child");
542
543   Stage stage = Stage::GetCurrent();
544   auto hbox = Control::New();
545   auto hboxLayout = HboxLayout::New();
546   DevelControl::SetLayout( hbox, hboxLayout );
547   hbox.SetName( "HBox");
548
549   std::vector< Control > controls;
550   controls.push_back( CreateLeafControl( 40, 40 ) );
551   controls.push_back( CreateLeafControl( 40, 40 ) );
552   controls.push_back( CreateLeafControl( 40, 40 ) );
553
554   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
555   tet_printf( "\nAdding Padding to control at index 1 \n" );
556   controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
557
558   for( auto&& iter : controls )
559   {
560     hbox.Add( iter );
561   }
562   hbox.SetParentOrigin( ParentOrigin::CENTER );
563   hbox.SetAnchorPoint( AnchorPoint::CENTER );
564   stage.Add( hbox );
565
566   // Ensure layouting happens
567   application.SendNotification();
568   application.Render();
569
570   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
571   // hbox left justifies elements
572   tet_infoline("Test Child Actor Position");
573   float xPositionOfControlBeingTested = 0.0f;
574   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
575                                                                                             380.0f,
576                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
577   xPositionOfControlBeingTested += 40.0f;
578
579   DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
580                                                                                             380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
581                                                                                             0.0001f, TEST_LOCATION );
582
583   xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
584   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
585
586   const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
587   tet_printf( "\nChanging Padding to control at index 1 \n" );
588   controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
589
590   // Ensure layouting happens
591   application.SendNotification();
592   application.Render();
593
594   xPositionOfControlBeingTested = 0.0f; // reset
595
596   tet_infoline("Test Child Actor Position");
597   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
598                                                                                             380.0f,
599                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
600   xPositionOfControlBeingTested += 40.0f;
601
602   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
603                                                                                             380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
604                                                                                             0.0001f, TEST_LOCATION );
605
606   xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
607   tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
608   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
609
610   tet_infoline("Test Child Actor Size");
611   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
612
613   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
614                                                                                         40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
615                                                                                         0.0001f, TEST_LOCATION );
616
617   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
618
619   END_TEST;
620 }
621
622 // Margin Tests
623
624 int UtcDaliLayouting_HboxLayout_Margin01(void)
625 {
626   ToolkitTestApplication application;
627   tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
628
629   Stage stage = Stage::GetCurrent();
630   auto hbox = Control::New();
631   auto hboxLayout = HboxLayout::New();
632   DevelControl::SetLayout( hbox, hboxLayout );
633   hbox.SetName( "HBox");
634
635   std::vector< Control > controls;
636   controls.push_back( CreateLeafControl( 40, 40 ) );
637   controls.push_back( CreateLeafControl( 60, 40 ) );
638   controls.push_back( CreateLeafControl( 80, 40 ) );
639   controls.push_back( CreateLeafControl( 100, 40 ) );
640
641   const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
642   tet_printf( "\nAdding Margin to control at index 1 \n" );
643   controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
644
645   for( auto&& iter : controls )
646   {
647     hbox.Add( iter );
648   }
649   hbox.SetParentOrigin( ParentOrigin::CENTER );
650   hbox.SetAnchorPoint( AnchorPoint::CENTER );
651   stage.Add( hbox );
652
653   // Ensure layouting happens
654   application.SendNotification();
655   application.Render();
656
657   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
658   // hbox left justifies elements
659   tet_infoline("Test Child Actor Position");
660   auto xPositionOfControlBeingTested = 0.0f;
661   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
662                                                                                             380.0f,
663                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
664   xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
665
666   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
667                                                                                             380.0f + CONTROL_MARGIN.top, 0.0f ),
668                                                                                             0.0001f, TEST_LOCATION );
669
670   xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
671   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
672
673   xPositionOfControlBeingTested += 80.0f;
674   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
675
676   tet_infoline("Test Child Actor Size is the same after Margin added");
677   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
678   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
679   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
680   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
681
682   END_TEST;
683 }
684
685
686 int UtcDaliLayouting_VboxLayout01(void)
687 {
688   ToolkitTestApplication application;
689   tet_infoline(" UtcDaliLayouting_VboxLayout01");
690
691   Stage stage = Stage::GetCurrent();
692   auto vbox = Control::New();
693   auto vboxLayout = VboxLayout::New();
694   DevelControl::SetLayout( vbox, vboxLayout );
695   vbox.SetName( "Vbox");
696
697   std::vector< Control > controls;
698   controls.push_back( CreateLeafControl( 40, 40 ) );
699   controls.push_back( CreateLeafControl( 60, 60 ) );
700   controls.push_back( CreateLeafControl( 80, 80 ) );
701   controls.push_back( CreateLeafControl( 100, 100 ) );
702
703   for( auto&& iter : controls )
704   {
705     vbox.Add( iter );
706   }
707   vbox.SetParentOrigin( ParentOrigin::CENTER );
708   vbox.SetAnchorPoint( AnchorPoint::CENTER );
709   stage.Add( vbox );
710
711   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
712
713   // Check it.
714   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
715
716   // Ensure layouting happens
717   application.SendNotification();
718   application.Render();
719
720   // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
721   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
722   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
723   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
724   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
725
726   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
727   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
728   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
729   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
730
731   END_TEST;
732 }
733
734 int UtcDaliLayouting_VboxLayout02(void)
735 {
736   ToolkitTestApplication application;
737   tet_infoline(" UtcDaliLayouting_VboxLayout01");
738
739   Stage stage = Stage::GetCurrent();
740
741   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
742   // LayoutGroup for this to happen automatically.
743   //
744   // For this test, add an hbox instead
745   auto hbox = Control::New();
746   auto hboxLayout = HboxLayout::New();
747   DevelControl::SetLayout( hbox, hboxLayout );
748   hbox.SetName( "Hbox");
749   stage.Add( hbox );
750
751   auto vbox = Control::New();
752   auto vboxLayout = VboxLayout::New();
753   DevelControl::SetLayout( vbox, vboxLayout );
754   vbox.SetName( "Vbox");
755   hbox.Add( vbox );
756
757   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
758   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
759
760   std::vector< Control > controls;
761   controls.push_back( CreateLeafControl( 40, 40 ) );
762   controls.push_back( CreateLeafControl( 60, 60 ) );
763   controls.push_back( CreateLeafControl( 80, 80 ) );
764   controls.push_back( CreateLeafControl( 100, 100 ) );
765
766   for( auto&& iter : controls )
767   {
768     vbox.Add( iter );
769   }
770   vbox.SetParentOrigin( ParentOrigin::CENTER );
771   vbox.SetAnchorPoint( AnchorPoint::CENTER );
772
773   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
774
775   // Check it.
776   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
777
778   // Ensure layouting happens
779   application.SendNotification();
780   application.Render();
781
782   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
783   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
784
785   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
786   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
787   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
788
789   // 3rd control is set to match parent - this should also be 100 wide
790   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
791   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
792   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
793   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
794
795   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
796   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
797   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
798   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
799
800   END_TEST;
801 }
802
803
804 int UtcDaliLayouting_VboxLayout03(void)
805 {
806   ToolkitTestApplication application;
807   tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
808
809   Stage stage = Stage::GetCurrent();
810
811   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
812   // LayoutGroup for this to happen automatically.
813   //
814   // For this test, add an hbox instead
815   auto hbox = Control::New();
816   auto hboxLayout = HboxLayout::New();
817   DevelControl::SetLayout( hbox, hboxLayout );
818   hbox.SetName( "Hbox");
819   stage.Add( hbox );
820
821   auto vbox = Control::New();
822   auto vboxLayout = VboxLayout::New();
823   vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
824
825   DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
826
827   DevelControl::SetLayout( vbox, vboxLayout );
828   vbox.SetName( "Vbox");
829   hbox.Add( vbox );
830
831   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
832   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
833
834   std::vector< Control > controls;
835   controls.push_back( CreateLeafControl( 40, 40 ) );
836   controls.push_back( CreateLeafControl( 60, 60 ) );
837   controls.push_back( CreateLeafControl( 80, 80 ) );
838   controls.push_back( CreateLeafControl( 100, 100 ) );
839
840   for( auto&& iter : controls )
841   {
842     vbox.Add( iter );
843   }
844   vbox.SetParentOrigin( ParentOrigin::CENTER );
845   vbox.SetAnchorPoint( AnchorPoint::CENTER );
846
847   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
848
849   // Check it.
850   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
851
852   // Ensure layouting happens
853   application.SendNotification();
854   application.Render();
855
856   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
857   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
858
859   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
860   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
861   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
862
863   // 3rd control is set to match parent - this should also be 100 wide
864   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
865   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
866   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
867   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
868
869   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
870   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
871   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
872   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
873
874   END_TEST;
875 }