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