Merge "Use Actor target size for default layout." 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 <../custom-layout.h>
28
29 #include <layout-utils.h>
30
31 using namespace Dali;
32 using namespace Toolkit;
33
34 void utc_dali_toolkit_layouting_startup(void)
35 {
36   test_return_value = TET_UNDEF;
37 }
38
39 void utc_dali_toolkit_layouting_cleanup(void)
40 {
41   test_return_value = TET_PASS;
42 }
43
44 int UtcDaliLayouting_HboxLayout01(void)
45 {
46   ToolkitTestApplication application;
47   tet_infoline(" UtcDaliLayouting_HboxLayout01");
48
49   Stage stage = Stage::GetCurrent();
50   auto hbox = Control::New();
51   auto hboxLayout = LinearLayout::New();
52   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
53   DevelControl::SetLayout( hbox, hboxLayout );
54   hbox.SetName( "HBox");
55
56   std::vector< Control > controls;
57   controls.push_back( CreateLeafControl( 40, 40 ) );
58   controls.push_back( CreateLeafControl( 60, 40 ) );
59   controls.push_back( CreateLeafControl( 80, 40 ) );
60   controls.push_back( CreateLeafControl( 100, 40 ) );
61
62   for( auto&& iter : controls )
63   {
64     hbox.Add( iter );
65   }
66   hbox.SetParentOrigin( ParentOrigin::CENTER );
67   hbox.SetAnchorPoint( AnchorPoint::CENTER );
68   stage.Add( hbox );
69
70   // Ensure layouting happens
71   application.SendNotification();
72   application.Render();
73
74   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
75   // hbox left justifies elements
76   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
77   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
78   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
79   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
80
81   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
82   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
83   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
84   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
85
86   // Change a layout
87   auto newHBoxLayout = LinearLayout::New();
88   newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
89   DevelControl::SetLayout( hbox, newHBoxLayout );
90
91   application.SendNotification();
92   application.Render();
93
94   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
95   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
96   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
97   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
98
99   END_TEST;
100 }
101
102 int UtcDaliLayouting_HboxLayout02(void)
103 {
104   ToolkitTestApplication application;
105   tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
106
107   Stage stage = Stage::GetCurrent();
108
109   auto hbox1 = Control::New();
110   auto hboxLayout1 = LinearLayout::New();
111   DevelControl::SetLayout( hbox1, hboxLayout1 );
112
113   auto hbox2 = Control::New();
114   auto hboxLayout2 = LinearLayout::New();
115   DevelControl::SetLayout( hbox2, hboxLayout2 );
116
117   hbox1.SetName( "HBox1");
118   hbox2.SetName( "HBox2");
119
120   std::vector< Control > controls;
121   controls.push_back( CreateLeafControl( 20, 40 ) );
122   controls.push_back( CreateLeafControl( 30, 50 ) );
123   controls.push_back( CreateLeafControl( 40, 60 ) );
124   controls.push_back( CreateLeafControl( 50, 70 ) );
125
126   controls.push_back( CreateLeafControl( 25, 40 ) );
127   controls.push_back( CreateLeafControl( 35, 50 ) );
128   controls.push_back( CreateLeafControl( 45, 60 ) );
129   controls.push_back( CreateLeafControl( 55, 70 ) );
130
131   int counter=0;
132   for( auto&& iter : controls )
133   {
134     if( counter < 4 )
135     {
136       hbox1.Add( iter );
137     }
138     else
139     {
140       hbox2.Add( iter );
141     }
142     ++counter;
143   }
144   hbox1.SetParentOrigin( ParentOrigin::CENTER );
145   hbox1.SetAnchorPoint( AnchorPoint::CENTER );
146   hbox2.SetParentOrigin( ParentOrigin::CENTER );
147   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
148
149   auto hbox3 = Control::New();
150   auto hboxLayout3 = LinearLayout::New();
151   DevelControl::SetLayout( hbox3, hboxLayout3 );
152
153   hbox3.SetParentOrigin( ParentOrigin::CENTER );
154   hbox3.SetName( "HBox3");
155   hbox3.Add( hbox1 );
156   hbox3.Add( hbox2 );
157
158   stage.Add( hbox3 );
159
160   // Ensure layouting happens
161   application.SendNotification();
162   application.Render();
163
164
165   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
166   // hbox left justifies elements
167   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
168   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
169   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,  5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
170   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,  0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
171
172   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
173   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
174   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
175   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
176
177
178   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
179   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
180   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f,  5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
181   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,  0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
182
183   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
184   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
185   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
186   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
187
188   // Test hbox1 and 2 are sized to wrap their content
189   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
190   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
191   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
192   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
193
194   // Test hbox3 matches parent (root layer)
195   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
196   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
197
198   END_TEST;
199 }
200
201
202 int UtcDaliLayouting_HboxLayout03(void)
203 {
204   ToolkitTestApplication application;
205   tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
206
207   Stage stage = Stage::GetCurrent();
208
209   auto hbox1 = Control::New();
210   auto hboxLayout1 = LinearLayout::New();
211   DevelControl::SetLayout( hbox1, hboxLayout1 );
212
213   auto hbox2 = Control::New();
214   auto hboxLayout2 = LinearLayout::New();
215   DevelControl::SetLayout( hbox2, hboxLayout2 );
216
217   hbox1.SetName( "HBox1");
218   hbox2.SetName( "HBox2");
219   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
220   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
221   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
222   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
223
224   std::vector< Control > controls;
225   controls.push_back( CreateLeafControl( 20, 40 ) );
226   controls.push_back( CreateLeafControl( 30, 50 ) );
227   controls.push_back( CreateLeafControl( 40, 60 ) );
228   controls.push_back( CreateLeafControl( 50, 70 ) );
229
230   controls.push_back( CreateLeafControl( 25, 40 ) );
231   controls.push_back( CreateLeafControl( 35, 50 ) );
232   controls.push_back( CreateLeafControl( 45, 60 ) );
233   controls.push_back( CreateLeafControl( 55, 70 ) );
234
235   int counter=0;
236   for( auto&& iter : controls )
237   {
238     if( counter < 4 )
239     {
240       hbox1.Add( iter );
241     }
242     else
243     {
244       hbox2.Add( iter );
245     }
246     ++counter;
247   }
248   hbox1.SetParentOrigin( ParentOrigin::CENTER );
249   hbox1.SetAnchorPoint( AnchorPoint::CENTER );
250   hbox2.SetParentOrigin( ParentOrigin::CENTER );
251   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
252
253   auto hbox3 = Control::New();
254   auto hboxLayout3 = LinearLayout::New();
255   DevelControl::SetLayout( hbox3, hboxLayout3);
256
257   hbox3.SetParentOrigin( ParentOrigin::CENTER );
258   hbox3.SetName( "HBox3");
259   hbox3.Add( hbox1 );
260   hbox3.Add( hbox2 );
261
262   stage.Add( hbox3 );
263
264   //std::ostringstream oss;
265   //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
266   //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
267
268   // Ensure layouting happens
269   application.SendNotification();
270   application.Render();
271
272
273   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
274   // hbox left justifies elements
275   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
276   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
277   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
278   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
279
280   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
281   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
282   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
283   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
284
285   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
286   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
287   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
288   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
289
290   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
291   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
292   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
293   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
294
295   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
296   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
297   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
298   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
299
300   // Test hbox3 matches parent (root layer)
301   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
302   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
303
304   END_TEST;
305 }
306
307 int UtcDaliLayouting_HboxLayout04(void)
308 {
309   ToolkitTestApplication application;
310   tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
311
312   Stage stage = Stage::GetCurrent();
313
314   auto hbox1 = Control::New();
315   auto hboxLayout1 = LinearLayout::New();
316   DevelControl::SetLayout( hbox1, hboxLayout1 );
317
318   auto hbox2 = Control::New();
319   auto hboxLayout2 = LinearLayout::New();
320   DevelControl::SetLayout( hbox2, hboxLayout2 );
321
322   hbox1.SetName( "HBox1"); // Default spec is to wrap content
323   hbox2.SetName( "HBox2");
324   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
325   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
326   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
327   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
328
329   std::vector< Control > controls;
330   controls.push_back( CreateLeafControl( 80, 40 ) );
331   controls.push_back( CreateLeafControl( 80, 50 ) );
332   controls.push_back( CreateLeafControl( 80, 60 ) );
333   controls.push_back( CreateLeafControl( 80, 70 ) );
334
335   controls.push_back( CreateLeafControl( 80, 40 ) );
336   controls.push_back( CreateLeafControl( 80, 50 ) );
337   controls.push_back( CreateLeafControl( 80, 60 ) );
338   controls.push_back( CreateLeafControl( 80, 70 ) );
339
340   int counter=0;
341   for( auto&& iter : controls )
342   {
343     if( counter < 4 )
344     {
345       hbox1.Add( iter );
346     }
347     else
348     {
349       hbox2.Add( iter );
350     }
351     ++counter;
352   }
353
354   controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
355   auto hbox3 = Control::New();
356   auto hboxLayout3 = LinearLayout::New();
357   DevelControl::SetLayout( hbox3, hboxLayout3 );
358
359   hbox3.SetParentOrigin( ParentOrigin::CENTER );
360   hbox3.SetName( "HBox3");
361   hbox3.Add( hbox1 );
362   hbox3.Add( hbox2 );
363   stage.Add( hbox3 );
364
365   //std::ostringstream oss;
366   //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
367   //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
368
369   // Ensure layouting happens
370   application.SendNotification();
371   application.Render();
372
373
374   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
375   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
376   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
377   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
378
379   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
380   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
381   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
382   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
383
384   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
385   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
386   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
387   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
388
389   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
390   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
391   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
392   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
393
394   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
395   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
396   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
397   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
398
399
400   // Test hbox3 matches parent (root layer)
401   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
402   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
403
404   END_TEST;
405 }
406
407 int UtcDaliLayouting_HboxLayout05(void)
408 {
409   ToolkitTestApplication application;
410   tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
411
412   Stage stage = Stage::GetCurrent();
413   auto hbox = Control::New();
414   auto hboxLayout = LinearLayout::New();
415   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
416   DevelControl::SetLayout( hbox, hboxLayout );
417   hbox.SetName( "HBox");
418
419   std::vector< Control > controls;
420   controls.push_back( CreateLeafControl( 40, 40 ) );
421   controls.push_back( CreateLeafControl( 60, 40 ) );
422   controls.push_back( CreateLeafControl( 80, 40 ) );
423   controls.push_back( CreateLeafControl( 100, 40 ) );
424
425   for( auto&& iter : controls )
426   {
427     hbox.Add( iter );
428     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
429     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
430   }
431
432   hbox.SetParentOrigin( ParentOrigin::CENTER );
433   hbox.SetAnchorPoint( AnchorPoint::CENTER );
434   stage.Add( hbox );
435
436   // Ensure layouting happens
437   application.SendNotification();
438   application.Render();
439
440   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
441   // hbox left justifies elements
442   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
443   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
444   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
445   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
446
447   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
448   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
449   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
450   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
451
452   END_TEST;
453 }
454
455 int UtcDaliLayouting_HboxLayout06(void)
456 {
457   ToolkitTestApplication application;
458   tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
459
460   Stage stage = Stage::GetCurrent();
461
462   auto rootControl = Control::New();
463   auto absoluteLayout = AbsoluteLayout::New();
464   DevelControl::SetLayout( rootControl, absoluteLayout );
465   rootControl.SetName( "AbsoluteLayout" );
466   stage.Add( rootControl );
467
468   auto hbox = Control::New();
469   auto hboxLayout = LinearLayout::New();
470   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
471   DevelControl::SetLayout( hbox, hboxLayout );
472   hbox.SetName( "HBox" );
473
474   std::vector< Control > controls;
475   controls.push_back( CreateLeafControl( 40, 40 ) );
476   controls.push_back( CreateLeafControl( 60, 40 ) );
477
478   for( auto&& iter : controls )
479   {
480     hbox.Add( iter );
481   }
482   hbox.SetParentOrigin( ParentOrigin::CENTER );
483   hbox.SetAnchorPoint( AnchorPoint::CENTER );
484   rootControl.Add( hbox );
485
486   // Ensure layouting happens
487   application.SendNotification();
488   application.Render();
489
490   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
491   // hbox left justifies elements
492   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
493   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
494
495   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
496   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
497
498   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
499
500   // Change a layout
501   auto newHBoxLayout = LinearLayout::New();
502   newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
503   DevelControl::SetLayout( hbox, newHBoxLayout );
504
505   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
506   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
507
508   application.SendNotification();
509   application.Render();
510
511   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
512
513   // Change size specification
514   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
515   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
516
517   application.SendNotification();
518   application.Render();
519
520   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
521
522   // Use WRAP_CONTENT again
523   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
524   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
525
526   application.SendNotification();
527   application.Render();
528
529   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
530
531   END_TEST;
532 }
533
534
535 int UtcDaliLayouting_HboxLayout07(void)
536 {
537   ToolkitTestApplication application;
538   tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
539
540   Stage stage = Stage::GetCurrent();
541   auto hbox = Control::New();
542   auto hboxLayout = LinearLayout::New();
543   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
544   DevelControl::SetLayout( hbox, hboxLayout );
545   hbox.SetName( "HBox");
546
547   std::vector< Control > controls;
548   controls.push_back( CreateLeafControl( 40, 40 ) );
549   controls.push_back( CreateLeafControl( 60, 40 ) );
550   controls.push_back( CreateLeafControl( 80, 40 ) );
551   controls.push_back( CreateLeafControl( 100, 40 ) );
552
553   for( auto&& iter : controls )
554   {
555     hbox.Add( iter );
556   }
557   hbox.SetParentOrigin( ParentOrigin::CENTER );
558   hbox.SetAnchorPoint( AnchorPoint::CENTER );
559   stage.Add( hbox );
560
561   hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
562
563   // Ensure layouting happens
564   application.SendNotification();
565   application.Render();
566
567   // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
568   // hbox left justifies elements
569   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
570   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
571   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
572   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
573
574   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
575   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
576   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
577   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
578
579   hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
580
581   // Ensure layouting happens
582   application.SendNotification();
583   application.Render();
584
585   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
586   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
587   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
588   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
589
590   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
591   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
592   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
593   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
594
595   END_TEST;
596 }
597
598 int UtcDaliLayouting_HboxLayout08(void)
599 {
600   ToolkitTestApplication application;
601   tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation");
602
603   Stage stage = Stage::GetCurrent();
604
605   auto rootControl = Control::New();
606   auto absoluteLayout = AbsoluteLayout::New();
607   absoluteLayout.SetAnimateLayout( true );
608   DevelControl::SetLayout( rootControl, absoluteLayout );
609   rootControl.SetName( "AbsoluteLayout" );
610   stage.Add( rootControl );
611
612   Control control1 = CreateLeafControl( 40, 40 );
613   rootControl.Add( control1 );
614
615   auto hbox = Control::New();
616   auto hboxLayout = LinearLayout::New();
617   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
618   DevelControl::SetLayout( hbox, hboxLayout );
619   hbox.SetName( "HBox" );
620
621   Control control2 = CreateLeafControl( 40, 40 );
622   hbox.Add( control2 );
623
624   hbox.SetParentOrigin( ParentOrigin::CENTER );
625   hbox.SetAnchorPoint( AnchorPoint::CENTER );
626   rootControl.Add( hbox );
627
628   DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION );
629   DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION );
630   DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION );
631   DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION );
632
633   hboxLayout.SetAnimateLayout( true );
634   absoluteLayout.SetAnimateLayout( false );
635
636   DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION );
637   DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION );
638   DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION );
639   DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION );
640
641   END_TEST;
642 }
643
644 // Padding tests
645
646 int UtcDaliLayouting_HboxLayout_Padding01(void)
647 {
648   ToolkitTestApplication application;
649   tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
650
651   Stage stage = Stage::GetCurrent();
652   auto hbox = Control::New();
653   auto hboxLayout = LinearLayout::New();
654   DevelControl::SetLayout( hbox, hboxLayout );
655   hbox.SetName( "HBox");
656
657   std::vector< Control > controls;
658   controls.push_back( CreateLeafControl( 40, 40 ) );
659   controls.push_back( CreateLeafControl( 60, 40 ) );
660   controls.push_back( CreateLeafControl( 80, 40 ) );
661   controls.push_back( CreateLeafControl( 100, 40 ) );
662
663   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
664   tet_printf( "\nAdding Padding to control at index %u \n", 1 );
665   controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
666
667   for( auto&& iter : controls )
668   {
669     hbox.Add( iter );
670   }
671   hbox.SetParentOrigin( ParentOrigin::CENTER );
672   hbox.SetAnchorPoint( AnchorPoint::CENTER );
673   stage.Add( hbox );
674
675   // Ensure layouting happens
676   application.SendNotification();
677   application.Render();
678
679   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
680   // hbox left justifies elements
681   tet_infoline("Test Child Actor Position");
682   float xPositionOfControlBeingTested = 0.0f;
683   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
684                                                                                             380.0f,
685                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
686   xPositionOfControlBeingTested += 40.0f;
687
688   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
689                                                                                             380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
690                                                                                             0.0001f, TEST_LOCATION );
691
692   xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
693   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
694
695   xPositionOfControlBeingTested += 80.0f;
696   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
697
698   tet_infoline("Test Child Actor Size");
699   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
700
701   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
702                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
703                                                                                         0.0001f, TEST_LOCATION );
704
705   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
706   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
707
708   END_TEST;
709 }
710
711 int UtcDaliLayouting_HboxLayout_Padding02(void)
712 {
713   ToolkitTestApplication application;
714   tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
715
716   Stage stage = Stage::GetCurrent();
717   auto hbox = Control::New();
718   auto hboxLayout = LinearLayout::New();
719   DevelControl::SetLayout( hbox, hboxLayout );
720   hbox.SetName( "HBox");
721
722   std::vector< Control > controls;
723   controls.push_back( CreateLeafControl( 40, 40 ) );
724   controls.push_back( CreateLeafControl( 60, 40 ) );
725   controls.push_back( CreateLeafControl( 80, 40 ) );
726   controls.push_back( CreateLeafControl( 100, 40 ) );
727
728   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
729
730   for( auto&& iter : controls )
731   {
732     iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
733     hbox.Add( iter );
734   }
735   hbox.SetParentOrigin( ParentOrigin::CENTER );
736   hbox.SetAnchorPoint( AnchorPoint::CENTER );
737   stage.Add( hbox );
738
739   // Ensure layouting happens
740   application.SendNotification();
741   application.Render();
742
743   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
744   // hbox left justifies elements
745   tet_infoline("Test Child Actor Position");
746   float xPositionOfControlBeingTested = 0.0f;
747   float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
748
749   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
750                                                                                             yPositionOfControlBeingTested,
751                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
752   xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
753
754   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
755                                                                                             yPositionOfControlBeingTested,
756                                                                                             0.0f ),
757                                                                                             0.0001f, TEST_LOCATION );
758
759   xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
760   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
761                                                                                             yPositionOfControlBeingTested,
762                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
763
764   xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
765   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
766                                                                                             yPositionOfControlBeingTested,
767                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
768
769   tet_infoline("Test Child Actor Size");
770   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
771                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
772                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
773
774   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
775                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
776                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
777
778   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
779                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
780                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
781
782   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
783                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
784                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
785
786   END_TEST;
787 }
788
789
790 int UtcDaliLayouting_HboxLayout_Padding03(void)
791 {
792   ToolkitTestApplication application;
793   tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Adding Changing padding on a single child");
794
795   Stage stage = Stage::GetCurrent();
796   auto hbox = Control::New();
797   auto hboxLayout = LinearLayout::New();
798   DevelControl::SetLayout( hbox, hboxLayout );
799   hbox.SetName( "HBox");
800
801   std::vector< Control > controls;
802   controls.push_back( CreateLeafControl( 40, 40 ) );
803   controls.push_back( CreateLeafControl( 40, 40 ) );
804   controls.push_back( CreateLeafControl( 40, 40 ) );
805
806   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
807   tet_printf( "\nAdding Padding to control at index 1 \n" );
808   controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
809
810   for( auto&& iter : controls )
811   {
812     hbox.Add( iter );
813   }
814   hbox.SetParentOrigin( ParentOrigin::CENTER );
815   hbox.SetAnchorPoint( AnchorPoint::CENTER );
816   stage.Add( hbox );
817
818   // Ensure layouting happens
819   application.SendNotification();
820   application.Render();
821
822   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
823   // hbox left justifies elements
824   tet_infoline("Test Child Actor Position");
825   float xPositionOfControlBeingTested = 0.0f;
826   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
827                                                                                             380.0f,
828                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
829   xPositionOfControlBeingTested += 40.0f;
830
831   DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
832                                                                                             380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
833                                                                                             0.0001f, TEST_LOCATION );
834
835   xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
836   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
837
838   const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
839   tet_printf( "\nChanging Padding to control at index 1 \n" );
840   controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
841
842   // Ensure layouting happens
843   application.SendNotification();
844   application.Render();
845
846   xPositionOfControlBeingTested = 0.0f; // reset
847
848   tet_infoline("Test Child Actor Position");
849   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
850                                                                                             380.0f,
851                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
852   xPositionOfControlBeingTested += 40.0f;
853
854   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
855                                                                                             380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
856                                                                                             0.0001f, TEST_LOCATION );
857
858   xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
859   tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
860   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
861
862   tet_infoline("Test Child Actor Size");
863   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
864
865   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
866                                                                                         40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
867                                                                                         0.0001f, TEST_LOCATION );
868
869   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
870
871   END_TEST;
872 }
873
874 // Margin Tests
875
876 int UtcDaliLayouting_HboxLayout_Margin01(void)
877 {
878   ToolkitTestApplication application;
879   tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
880
881   Stage stage = Stage::GetCurrent();
882   auto hbox = Control::New();
883   auto hboxLayout = LinearLayout::New();
884   DevelControl::SetLayout( hbox, hboxLayout );
885   hbox.SetName( "HBox");
886
887   std::vector< Control > controls;
888   controls.push_back( CreateLeafControl( 40, 40 ) );
889   controls.push_back( CreateLeafControl( 60, 40 ) );
890   controls.push_back( CreateLeafControl( 80, 40 ) );
891   controls.push_back( CreateLeafControl( 100, 40 ) );
892
893   const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
894   tet_printf( "\nAdding Margin to control at index 1 \n" );
895   controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
896
897   for( auto&& iter : controls )
898   {
899     hbox.Add( iter );
900   }
901   hbox.SetParentOrigin( ParentOrigin::CENTER );
902   hbox.SetAnchorPoint( AnchorPoint::CENTER );
903   stage.Add( hbox );
904
905   // Ensure layouting happens
906   application.SendNotification();
907   application.Render();
908
909   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
910   // hbox left justifies elements
911   tet_infoline("Test Child Actor Position");
912   auto xPositionOfControlBeingTested = 0.0f;
913   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
914                                                                                             380.0f,
915                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
916   xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
917
918   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
919                                                                                             380.0f + CONTROL_MARGIN.top, 0.0f ),
920                                                                                             0.0001f, TEST_LOCATION );
921
922   xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
923   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
924
925   xPositionOfControlBeingTested += 80.0f;
926   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
927
928   tet_infoline("Test Child Actor Size is the same after Margin added");
929   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
930   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
931   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
932   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
933
934   END_TEST;
935 }
936
937
938 int UtcDaliLayouting_VboxLayout01(void)
939 {
940   ToolkitTestApplication application;
941   tet_infoline(" UtcDaliLayouting_VboxLayout01");
942
943   Stage stage = Stage::GetCurrent();
944   auto vbox = Control::New();
945   auto vboxLayout = LinearLayout::New();
946   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
947   DevelControl::SetLayout( vbox, vboxLayout );
948   vbox.SetName( "Vbox");
949
950   std::vector< Control > controls;
951   controls.push_back( CreateLeafControl( 40, 40 ) );
952   controls.push_back( CreateLeafControl( 60, 60 ) );
953   controls.push_back( CreateLeafControl( 80, 80 ) );
954   controls.push_back( CreateLeafControl( 100, 100 ) );
955
956   for( auto&& iter : controls )
957   {
958     vbox.Add( iter );
959   }
960   vbox.SetParentOrigin( ParentOrigin::CENTER );
961   vbox.SetAnchorPoint( AnchorPoint::CENTER );
962   stage.Add( vbox );
963
964   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
965
966   // Check it.
967   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
968
969   // Ensure layouting happens
970   application.SendNotification();
971   application.Render();
972
973   // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
974   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
975   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
976   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
977   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
978
979   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
980   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
981   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
982   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
983
984   END_TEST;
985 }
986
987 int UtcDaliLayouting_VboxLayout02(void)
988 {
989   ToolkitTestApplication application;
990   tet_infoline(" UtcDaliLayouting_VboxLayout01");
991
992   Stage stage = Stage::GetCurrent();
993
994   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
995   // LayoutGroup for this to happen automatically.
996   //
997   // For this test, add an hbox instead
998   auto rootControl = Control::New();
999   auto absoluteLayout = AbsoluteLayout::New();
1000   DevelControl::SetLayout( rootControl, absoluteLayout );
1001   rootControl.SetName( "AbsoluteLayout");
1002   stage.Add( rootControl );
1003
1004   auto vbox = Control::New();
1005   auto vboxLayout = LinearLayout::New();
1006   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1007   DevelControl::SetLayout( vbox, vboxLayout );
1008   vbox.SetName( "Vbox");
1009   rootControl.Add( vbox );
1010
1011   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1012   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1013
1014   std::vector< Control > controls;
1015   controls.push_back( CreateLeafControl( 40, 40 ) );
1016   controls.push_back( CreateLeafControl( 60, 60 ) );
1017   controls.push_back( CreateLeafControl( 80, 80 ) );
1018   controls.push_back( CreateLeafControl( 100, 100 ) );
1019
1020   for( auto&& iter : controls )
1021   {
1022     vbox.Add( iter );
1023   }
1024   vbox.SetParentOrigin( ParentOrigin::CENTER );
1025   vbox.SetAnchorPoint( AnchorPoint::CENTER );
1026
1027   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1028
1029   // Check it.
1030   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1031
1032   // Ensure layouting happens
1033   application.SendNotification();
1034   application.Render();
1035
1036   DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1037   DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1038
1039   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1040   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1041   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1042
1043   // 3rd control is set to match parent - this should also be 100 wide
1044   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1045   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1046   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1047   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1048
1049   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1050   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1051   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1052   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1053
1054   END_TEST;
1055 }
1056
1057
1058 int UtcDaliLayouting_VboxLayout03(void)
1059 {
1060   ToolkitTestApplication application;
1061   tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
1062
1063   Stage stage = Stage::GetCurrent();
1064
1065   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1066   // LayoutGroup for this to happen automatically.
1067   //
1068   // For this test, add an hbox instead
1069   auto hbox = Control::New();
1070   auto hboxLayout = LinearLayout::New();
1071   DevelControl::SetLayout( hbox, hboxLayout );
1072   hbox.SetName( "Hbox");
1073   stage.Add( hbox );
1074
1075   auto vbox = Control::New();
1076   auto vboxLayout = LinearLayout::New();
1077   vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
1078   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1079
1080   DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
1081
1082   DevelControl::SetLayout( vbox, vboxLayout );
1083   vbox.SetName( "Vbox");
1084   hbox.Add( vbox );
1085
1086   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1087   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1088
1089   std::vector< Control > controls;
1090   controls.push_back( CreateLeafControl( 40, 40 ) );
1091   controls.push_back( CreateLeafControl( 60, 60 ) );
1092   controls.push_back( CreateLeafControl( 80, 80 ) );
1093   controls.push_back( CreateLeafControl( 100, 100 ) );
1094
1095   for( auto&& iter : controls )
1096   {
1097     vbox.Add( iter );
1098   }
1099   vbox.SetParentOrigin( ParentOrigin::CENTER );
1100   vbox.SetAnchorPoint( AnchorPoint::CENTER );
1101
1102   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1103
1104   // Check it.
1105   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1106
1107   // Ensure layouting happens
1108   application.SendNotification();
1109   application.Render();
1110
1111   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1112   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1113
1114   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1115   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1116   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1117
1118   // 3rd control is set to match parent - this should also be 100 wide
1119   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1120   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1121   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1122   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1123
1124   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1125   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1126   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1127   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1128
1129   END_TEST;
1130 }
1131
1132
1133
1134 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
1135 {
1136   ToolkitTestApplication application;
1137   tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
1138   tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
1139
1140   Stage stage = Stage::GetCurrent();
1141
1142   auto hbox = Control::New();
1143   auto hboxLayout = Test::CustomLayout::New();
1144   DevelControl::SetLayout( hbox, hboxLayout );
1145   hbox.SetName( "HBox");
1146
1147   std::vector< Control > controls;
1148   controls.push_back( CreateLeafControl( 40, 40 ) );
1149   controls.push_back( CreateLeafControl( 60, 40 ) );
1150   controls.push_back( CreateLeafControl( 80, 40 ) );
1151   controls.push_back( CreateLeafControl( 100, 40 ) );
1152
1153   for( auto&& iter : controls )
1154   {
1155     hbox.Add( iter );
1156   }
1157   hbox.SetParentOrigin( ParentOrigin::CENTER );
1158   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1159   stage.Add( hbox );
1160
1161   // Ensure layouting happens
1162   application.SendNotification();
1163   application.Render();
1164
1165   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1166   // hbox left justifies elements
1167   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1168   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1169   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1170   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1171
1172   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1173   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1174   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1175   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1176
1177   controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
1178   controls[2].Lower();      // 2->1; 2, 1, 3, 0
1179
1180   application.SendNotification();
1181   application.Render();
1182
1183   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1184   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1185   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1186   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1187
1188   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1189   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1190   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1191   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1192
1193   END_TEST;
1194 }
1195
1196 int UtcDaliLayouting_HboxLayout_TargetSize(void)
1197 {
1198   ToolkitTestApplication application;
1199   tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
1200
1201   Stage stage = Stage::GetCurrent();
1202   auto hbox = Control::New();
1203   auto hboxLayout = LinearLayout::New();
1204   DevelControl::SetLayout( hbox, hboxLayout );
1205   hbox.SetName( "HBox");
1206
1207   std::vector< Control > controls;
1208   controls.push_back( CreateLeafControl( 40, 40 ) );
1209   for( auto&& iter : controls )
1210   {
1211     iter.SetSize( 100, 100 );
1212     hbox.Add( iter );
1213   }
1214   hbox.SetParentOrigin( ParentOrigin::CENTER );
1215   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1216   stage.Add( hbox );
1217
1218   // Ensure layouting happens
1219   application.SendNotification();
1220   application.Render();
1221
1222   // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
1223   // hbox left justifies elements
1224   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1225   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1226
1227   END_TEST;
1228 }