Merge "Fix nested layout issue" 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/absolute-layout.h>
25 #include <dali-toolkit/devel-api/layouting/linear-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 = LinearLayout::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 = LinearLayout::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 = LinearLayout::New();
109   DevelControl::SetLayout( hbox1, hboxLayout1 );
110
111   auto hbox2 = Control::New();
112   auto hboxLayout2 = LinearLayout::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 = LinearLayout::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 = LinearLayout::New();
209   DevelControl::SetLayout( hbox1, hboxLayout1 );
210
211   auto hbox2 = Control::New();
212   auto hboxLayout2 = LinearLayout::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 = LinearLayout::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 = LinearLayout::New();
314   DevelControl::SetLayout( hbox1, hboxLayout1 );
315
316   auto hbox2 = Control::New();
317   auto hboxLayout2 = LinearLayout::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 = LinearLayout::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 = LinearLayout::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 int UtcDaliLayouting_HboxLayout06(void)
454 {
455   ToolkitTestApplication application;
456   tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
457
458   Stage stage = Stage::GetCurrent();
459
460   auto rootControl = Control::New();
461   auto absoluteLayout = AbsoluteLayout::New();
462   DevelControl::SetLayout( rootControl, absoluteLayout );
463   rootControl.SetName( "AbsoluteLayout" );
464   stage.Add( rootControl );
465
466   auto hbox = Control::New();
467   auto hboxLayout = LinearLayout::New();
468   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
469   DevelControl::SetLayout( hbox, hboxLayout );
470   hbox.SetName( "HBox" );
471
472   std::vector< Control > controls;
473   controls.push_back( CreateLeafControl( 40, 40 ) );
474   controls.push_back( CreateLeafControl( 60, 40 ) );
475
476   for( auto&& iter : controls )
477   {
478     hbox.Add( iter );
479   }
480   hbox.SetParentOrigin( ParentOrigin::CENTER );
481   hbox.SetAnchorPoint( AnchorPoint::CENTER );
482   rootControl.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   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
491   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
492
493   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
494   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
495
496   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
497
498   // Change a layout
499   auto newHBoxLayout = LinearLayout::New();
500   newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
501   DevelControl::SetLayout( hbox, newHBoxLayout );
502
503   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
504   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
505
506   application.SendNotification();
507   application.Render();
508
509   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
510
511   END_TEST;
512 }
513
514 // Padding tests
515
516 int UtcDaliLayouting_HboxLayout_Padding01(void)
517 {
518   ToolkitTestApplication application;
519   tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
520
521   Stage stage = Stage::GetCurrent();
522   auto hbox = Control::New();
523   auto hboxLayout = LinearLayout::New();
524   DevelControl::SetLayout( hbox, hboxLayout );
525   hbox.SetName( "HBox");
526
527   std::vector< Control > controls;
528   controls.push_back( CreateLeafControl( 40, 40 ) );
529   controls.push_back( CreateLeafControl( 60, 40 ) );
530   controls.push_back( CreateLeafControl( 80, 40 ) );
531   controls.push_back( CreateLeafControl( 100, 40 ) );
532
533   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
534   tet_printf( "\nAdding Padding to control at index %u \n", 1 );
535   controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
536
537   for( auto&& iter : controls )
538   {
539     hbox.Add( iter );
540   }
541   hbox.SetParentOrigin( ParentOrigin::CENTER );
542   hbox.SetAnchorPoint( AnchorPoint::CENTER );
543   stage.Add( hbox );
544
545   // Ensure layouting happens
546   application.SendNotification();
547   application.Render();
548
549   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
550   // hbox left justifies elements
551   tet_infoline("Test Child Actor Position");
552   float xPositionOfControlBeingTested = 0.0f;
553   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
554                                                                                             380.0f,
555                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
556   xPositionOfControlBeingTested += 40.0f;
557
558   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
559                                                                                             380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
560                                                                                             0.0001f, TEST_LOCATION );
561
562   xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
563   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
564
565   xPositionOfControlBeingTested += 80.0f;
566   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
567
568   tet_infoline("Test Child Actor Size");
569   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
570
571   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
572                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
573                                                                                         0.0001f, TEST_LOCATION );
574
575   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
576   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
577
578   END_TEST;
579 }
580
581 int UtcDaliLayouting_HboxLayout_Padding02(void)
582 {
583   ToolkitTestApplication application;
584   tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
585
586   Stage stage = Stage::GetCurrent();
587   auto hbox = Control::New();
588   auto hboxLayout = LinearLayout::New();
589   DevelControl::SetLayout( hbox, hboxLayout );
590   hbox.SetName( "HBox");
591
592   std::vector< Control > controls;
593   controls.push_back( CreateLeafControl( 40, 40 ) );
594   controls.push_back( CreateLeafControl( 60, 40 ) );
595   controls.push_back( CreateLeafControl( 80, 40 ) );
596   controls.push_back( CreateLeafControl( 100, 40 ) );
597
598   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
599
600   for( auto&& iter : controls )
601   {
602     iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
603     hbox.Add( iter );
604   }
605   hbox.SetParentOrigin( ParentOrigin::CENTER );
606   hbox.SetAnchorPoint( AnchorPoint::CENTER );
607   stage.Add( hbox );
608
609   // Ensure layouting happens
610   application.SendNotification();
611   application.Render();
612
613   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
614   // hbox left justifies elements
615   tet_infoline("Test Child Actor Position");
616   float xPositionOfControlBeingTested = 0.0f;
617   float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
618
619   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
620                                                                                             yPositionOfControlBeingTested,
621                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
622   xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
623
624   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
625                                                                                             yPositionOfControlBeingTested,
626                                                                                             0.0f ),
627                                                                                             0.0001f, TEST_LOCATION );
628
629   xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
630   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
631                                                                                             yPositionOfControlBeingTested,
632                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
633
634   xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
635   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
636                                                                                             yPositionOfControlBeingTested,
637                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
638
639   tet_infoline("Test Child Actor Size");
640   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
641                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
642                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
643
644   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
645                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
646                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
647
648   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
649                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
650                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
651
652   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
653                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
654                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
655
656   END_TEST;
657 }
658
659
660 int UtcDaliLayouting_HboxLayout_Padding03(void)
661 {
662   ToolkitTestApplication application;
663   tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Adding Changing padding on a single child");
664
665   Stage stage = Stage::GetCurrent();
666   auto hbox = Control::New();
667   auto hboxLayout = LinearLayout::New();
668   DevelControl::SetLayout( hbox, hboxLayout );
669   hbox.SetName( "HBox");
670
671   std::vector< Control > controls;
672   controls.push_back( CreateLeafControl( 40, 40 ) );
673   controls.push_back( CreateLeafControl( 40, 40 ) );
674   controls.push_back( CreateLeafControl( 40, 40 ) );
675
676   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
677   tet_printf( "\nAdding Padding to control at index 1 \n" );
678   controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
679
680   for( auto&& iter : controls )
681   {
682     hbox.Add( iter );
683   }
684   hbox.SetParentOrigin( ParentOrigin::CENTER );
685   hbox.SetAnchorPoint( AnchorPoint::CENTER );
686   stage.Add( hbox );
687
688   // Ensure layouting happens
689   application.SendNotification();
690   application.Render();
691
692   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
693   // hbox left justifies elements
694   tet_infoline("Test Child Actor Position");
695   float xPositionOfControlBeingTested = 0.0f;
696   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
697                                                                                             380.0f,
698                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
699   xPositionOfControlBeingTested += 40.0f;
700
701   DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
702                                                                                             380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
703                                                                                             0.0001f, TEST_LOCATION );
704
705   xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
706   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
707
708   const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
709   tet_printf( "\nChanging Padding to control at index 1 \n" );
710   controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
711
712   // Ensure layouting happens
713   application.SendNotification();
714   application.Render();
715
716   xPositionOfControlBeingTested = 0.0f; // reset
717
718   tet_infoline("Test Child Actor Position");
719   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
720                                                                                             380.0f,
721                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
722   xPositionOfControlBeingTested += 40.0f;
723
724   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
725                                                                                             380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
726                                                                                             0.0001f, TEST_LOCATION );
727
728   xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
729   tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
730   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
731
732   tet_infoline("Test Child Actor Size");
733   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
734
735   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
736                                                                                         40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
737                                                                                         0.0001f, TEST_LOCATION );
738
739   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
740
741   END_TEST;
742 }
743
744 // Margin Tests
745
746 int UtcDaliLayouting_HboxLayout_Margin01(void)
747 {
748   ToolkitTestApplication application;
749   tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
750
751   Stage stage = Stage::GetCurrent();
752   auto hbox = Control::New();
753   auto hboxLayout = LinearLayout::New();
754   DevelControl::SetLayout( hbox, hboxLayout );
755   hbox.SetName( "HBox");
756
757   std::vector< Control > controls;
758   controls.push_back( CreateLeafControl( 40, 40 ) );
759   controls.push_back( CreateLeafControl( 60, 40 ) );
760   controls.push_back( CreateLeafControl( 80, 40 ) );
761   controls.push_back( CreateLeafControl( 100, 40 ) );
762
763   const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
764   tet_printf( "\nAdding Margin to control at index 1 \n" );
765   controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
766
767   for( auto&& iter : controls )
768   {
769     hbox.Add( iter );
770   }
771   hbox.SetParentOrigin( ParentOrigin::CENTER );
772   hbox.SetAnchorPoint( AnchorPoint::CENTER );
773   stage.Add( hbox );
774
775   // Ensure layouting happens
776   application.SendNotification();
777   application.Render();
778
779   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
780   // hbox left justifies elements
781   tet_infoline("Test Child Actor Position");
782   auto xPositionOfControlBeingTested = 0.0f;
783   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
784                                                                                             380.0f,
785                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
786   xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
787
788   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
789                                                                                             380.0f + CONTROL_MARGIN.top, 0.0f ),
790                                                                                             0.0001f, TEST_LOCATION );
791
792   xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
793   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
794
795   xPositionOfControlBeingTested += 80.0f;
796   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
797
798   tet_infoline("Test Child Actor Size is the same after Margin added");
799   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
800   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
801   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
802   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
803
804   END_TEST;
805 }
806
807
808 int UtcDaliLayouting_VboxLayout01(void)
809 {
810   ToolkitTestApplication application;
811   tet_infoline(" UtcDaliLayouting_VboxLayout01");
812
813   Stage stage = Stage::GetCurrent();
814   auto vbox = Control::New();
815   auto vboxLayout = LinearLayout::New();
816   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
817   DevelControl::SetLayout( vbox, vboxLayout );
818   vbox.SetName( "Vbox");
819
820   std::vector< Control > controls;
821   controls.push_back( CreateLeafControl( 40, 40 ) );
822   controls.push_back( CreateLeafControl( 60, 60 ) );
823   controls.push_back( CreateLeafControl( 80, 80 ) );
824   controls.push_back( CreateLeafControl( 100, 100 ) );
825
826   for( auto&& iter : controls )
827   {
828     vbox.Add( iter );
829   }
830   vbox.SetParentOrigin( ParentOrigin::CENTER );
831   vbox.SetAnchorPoint( AnchorPoint::CENTER );
832   stage.Add( vbox );
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   // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
844   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
845   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
846   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
847   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
848
849   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
850   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
851   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
852   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
853
854   END_TEST;
855 }
856
857 int UtcDaliLayouting_VboxLayout02(void)
858 {
859   ToolkitTestApplication application;
860   tet_infoline(" UtcDaliLayouting_VboxLayout01");
861
862   Stage stage = Stage::GetCurrent();
863
864   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
865   // LayoutGroup for this to happen automatically.
866   //
867   // For this test, add an hbox instead
868   auto rootControl = Control::New();
869   auto absoluteLayout = AbsoluteLayout::New();
870   DevelControl::SetLayout( rootControl, absoluteLayout );
871   rootControl.SetName( "AbsoluteLayout");
872   stage.Add( rootControl );
873
874   auto vbox = Control::New();
875   auto vboxLayout = LinearLayout::New();
876   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
877   DevelControl::SetLayout( vbox, vboxLayout );
878   vbox.SetName( "Vbox");
879   rootControl.Add( vbox );
880
881   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
882   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
883
884   std::vector< Control > controls;
885   controls.push_back( CreateLeafControl( 40, 40 ) );
886   controls.push_back( CreateLeafControl( 60, 60 ) );
887   controls.push_back( CreateLeafControl( 80, 80 ) );
888   controls.push_back( CreateLeafControl( 100, 100 ) );
889
890   for( auto&& iter : controls )
891   {
892     vbox.Add( iter );
893   }
894   vbox.SetParentOrigin( ParentOrigin::CENTER );
895   vbox.SetAnchorPoint( AnchorPoint::CENTER );
896
897   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
898
899   // Check it.
900   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
901
902   // Ensure layouting happens
903   application.SendNotification();
904   application.Render();
905
906   DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
907   DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
908
909   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
910   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
911   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
912
913   // 3rd control is set to match parent - this should also be 100 wide
914   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
915   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
916   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
917   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
918
919   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
920   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
921   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
922   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
923
924   END_TEST;
925 }
926
927
928 int UtcDaliLayouting_VboxLayout03(void)
929 {
930   ToolkitTestApplication application;
931   tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
932
933   Stage stage = Stage::GetCurrent();
934
935   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
936   // LayoutGroup for this to happen automatically.
937   //
938   // For this test, add an hbox instead
939   auto hbox = Control::New();
940   auto hboxLayout = LinearLayout::New();
941   DevelControl::SetLayout( hbox, hboxLayout );
942   hbox.SetName( "Hbox");
943   stage.Add( hbox );
944
945   auto vbox = Control::New();
946   auto vboxLayout = LinearLayout::New();
947   vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
948   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
949
950   DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
951
952   DevelControl::SetLayout( vbox, vboxLayout );
953   vbox.SetName( "Vbox");
954   hbox.Add( vbox );
955
956   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
957   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
958
959   std::vector< Control > controls;
960   controls.push_back( CreateLeafControl( 40, 40 ) );
961   controls.push_back( CreateLeafControl( 60, 60 ) );
962   controls.push_back( CreateLeafControl( 80, 80 ) );
963   controls.push_back( CreateLeafControl( 100, 100 ) );
964
965   for( auto&& iter : controls )
966   {
967     vbox.Add( iter );
968   }
969   vbox.SetParentOrigin( ParentOrigin::CENTER );
970   vbox.SetAnchorPoint( AnchorPoint::CENTER );
971
972   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
973
974   // Check it.
975   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
976
977   // Ensure layouting happens
978   application.SendNotification();
979   application.Render();
980
981   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
982   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
983
984   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
985   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
986   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
987
988   // 3rd control is set to match parent - this should also be 100 wide
989   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
990   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
991   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
992   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
993
994   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
995   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
996   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
997   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
998
999   END_TEST;
1000 }