49da596138bf7bffcccb18bf62ce602e9a4a5c01
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-Layouting.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <toolkit-event-thread-callback.h>
22
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/control-devel.h>
25 #include <dali-toolkit/devel-api/layouting/absolute-layout.h>
26 #include <dali-toolkit/devel-api/layouting/linear-layout.h>
27 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
28 #include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
29 #include <dali/devel-api/actors/actor-devel.h>
30
31 #include <../custom-layout.h>
32
33 #include <layout-utils.h>
34
35 using namespace Dali;
36 using namespace Toolkit;
37
38 namespace
39 {
40
41 void TestLayoutItemOrder( std::vector< Control >& controls, LayoutGroup& layoutGroup )
42 {
43   for( auto&& iter : controls )
44   {
45     unsigned int siblingOrder = static_cast< unsigned int>( iter.GetProperty< int >( DevelActor::Property::SIBLING_ORDER ) );
46     DALI_TEST_EQUALS( layoutGroup.GetChildAt( siblingOrder ), DevelControl::GetLayout( iter ), TEST_LOCATION );
47   }
48 }
49
50 // Turns the given control into a Root layout control and adds it to the stage.
51 void SetupRootLayoutControl( Control& rootControl )
52 {
53   rootControl = Control::New();
54   auto absoluteLayout = AbsoluteLayout::New();
55   DevelControl::SetLayout( rootControl, absoluteLayout );
56   rootControl.SetName( "RootAbsoluteLayout" );
57   Stage stage = Stage::GetCurrent();
58   stage.Add( rootControl );
59 }
60
61 } // unnamed namespace
62
63 void utc_dali_toolkit_layouting_startup(void)
64 {
65   test_return_value = TET_UNDEF;
66 }
67
68 void utc_dali_toolkit_layouting_cleanup(void)
69 {
70   test_return_value = TET_PASS;
71 }
72
73 int UtcDaliLayouting_LayoutLength_Types(void)
74 {
75   tet_infoline("UtcDaliLayouting_LayoutLength Types");
76
77   // testing that operators return correct type
78   // operator+
79   {
80     auto value = LayoutLength( 10 ) + LayoutLength();
81     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
82   }
83   {
84     auto value = LayoutLength( 10 ) + 20;
85     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
86   }
87   {
88     auto value = 22 + LayoutLength( 10 );
89     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
90   }
91   {
92     auto value = LayoutLength( 10 ) + 2.1f;
93     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
94   }
95   {
96     auto value = 2.2f + LayoutLength( 10 );
97     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
98   }
99   // operator-
100   {
101     auto value = LayoutLength() - LayoutLength( 10 );
102     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
103   }
104   {
105     auto value = LayoutLength( 10 ) - 99;
106     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
107   }
108   {
109     auto value = 20 - LayoutLength( 10 );
110     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
111   }
112   {
113     auto value = LayoutLength( 10 ) - 9.9f;
114     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
115   }
116   {
117     auto value = 2.0f - LayoutLength( 10 );
118     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
119   }
120
121   // operator*
122   {
123     auto value = LayoutLength() * LayoutLength( 10 );
124     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
125   }
126   {
127     auto value = LayoutLength( 10 ) * 2;
128     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
129   }
130   {
131     auto value = 10 * LayoutLength( 10 );
132     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
133   }
134   {
135     auto value = LayoutLength( 10 ) * 2.1f;
136     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
137   }
138   {
139     auto value = 1.0f * LayoutLength( 10 );
140     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
141   }
142   // operator/
143   {
144     auto value = LayoutLength( 10 ) / 2.0f;
145     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
146   }
147
148   // combinations
149   {
150     auto value = ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
151     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
152   }
153   {
154     auto value = 20 + ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
155     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
156   }
157
158   END_TEST;
159 }
160
161 int UtcDaliLayouting_LayoutLength_Values(void)
162 {
163   tet_infoline("UtcDaliLayouting_LayoutLength Values");
164
165   // operator+
166   {
167     LayoutLength value = LayoutLength( 10 ) + LayoutLength();
168     DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
169   }
170   {
171     LayoutLength value = LayoutLength( 10 ) + 20;
172     DALI_TEST_EQUALS( value.AsInteger(), 30.0f, 0.0001f, TEST_LOCATION );
173   }
174   {
175     LayoutLength value = 22 - LayoutLength( 10 );
176     DALI_TEST_EQUALS( value.AsInteger(), 12.0f, 0.0001f, TEST_LOCATION );
177   }
178   {
179     LayoutLength value = LayoutLength( 10 ) + 2.1f;
180     DALI_TEST_EQUALS( value.AsDecimal(), 12.1f, 0.0001f, TEST_LOCATION );
181     DALI_TEST_EQUALS( value.AsTruncated(), 12.0f, 0.0001f, TEST_LOCATION );
182   }
183   {
184     LayoutLength value = 2.3f - LayoutLength( 10 );
185     DALI_TEST_EQUALS( value.AsDecimal(), -7.7f, 0.0001f, TEST_LOCATION );
186     DALI_TEST_EQUALS( value.AsInteger(), -8.0f, 0.0001f, TEST_LOCATION );
187     DALI_TEST_EQUALS( value.AsTruncated(), -7.0f, 0.0001f, TEST_LOCATION );
188   }
189   // operator-
190   {
191     LayoutLength value = LayoutLength() - LayoutLength( 10 );
192     DALI_TEST_EQUALS( value.AsInteger(), -10.0f, 0.0001f, TEST_LOCATION );
193   }
194   {
195     LayoutLength value = LayoutLength( 10 ) - 99;
196     DALI_TEST_EQUALS( value.AsInteger(), -89.0f, 0.0001f, TEST_LOCATION );
197   }
198   {
199     LayoutLength value = 20 - LayoutLength( 10 );
200     DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
201     DALI_TEST_EQUALS( value.AsTruncated(), 10.f, 0.0001f, TEST_LOCATION );
202   }
203   {
204     LayoutLength value = LayoutLength( 10 ) - 9.9f;
205     DALI_TEST_EQUALS( value.AsInteger(), 0.0f, 0.0001f, TEST_LOCATION );
206     DALI_TEST_EQUALS( value.AsDecimal(), 0.1f, 0.0001f, TEST_LOCATION );
207     DALI_TEST_EQUALS( value.AsTruncated(), 0.0f, 0.0001f, TEST_LOCATION );
208   }
209   {
210     LayoutLength value = 10.9f - LayoutLength( 10 );
211     DALI_TEST_EQUALS( value.AsInteger(), 1.0f, 0.0001f, TEST_LOCATION );
212     DALI_TEST_EQUALS( value.AsDecimal(), 0.9f, 0.0001f, TEST_LOCATION );
213     DALI_TEST_EQUALS( value.AsTruncated(), 0.0f, 0.0001f, TEST_LOCATION );
214   }
215   // operator*
216   {
217     LayoutLength value = LayoutLength() * LayoutLength( 10 );
218     DALI_TEST_EQUALS( value.AsInteger(), 0.0f, 0.0001f, TEST_LOCATION );
219   }
220   {
221     LayoutLength value = LayoutLength(1) * 10;
222     DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
223   }
224   {
225     LayoutLength value = 11 * LayoutLength( 10 );
226     DALI_TEST_EQUALS( value.AsInteger(), 110.0f, 0.0001f, TEST_LOCATION );
227   }
228   {
229     LayoutLength value = LayoutLength( 10 ) * 2.12f;
230     DALI_TEST_EQUALS( value.AsDecimal(), 21.2f, 0.0001f, TEST_LOCATION );
231     DALI_TEST_EQUALS( value.AsInteger(), 21.0f, 0.0001f, TEST_LOCATION );
232     DALI_TEST_EQUALS( value.AsTruncated(), 21.0f, 0.0001f, TEST_LOCATION );
233   }
234   {
235     LayoutLength value = 2.189f * LayoutLength( 10 );
236     DALI_TEST_EQUALS( value.AsDecimal(), 21.89f, 0.0001f, TEST_LOCATION );
237     DALI_TEST_EQUALS( value.AsInteger(), 22.0f, 0.0001f, TEST_LOCATION );
238     DALI_TEST_EQUALS( value.AsTruncated(), 21.0f, 0.0001f, TEST_LOCATION );
239   }
240   // operator/
241   {
242     LayoutLength value = LayoutLength( 11 ) / 2.0f;
243     DALI_TEST_EQUALS( value.AsDecimal(), 5.5f, 0.0001f, TEST_LOCATION );
244     DALI_TEST_EQUALS( value.AsInteger(), 6.0f, 0.0001f, TEST_LOCATION );
245   }
246
247   // combinations
248   {
249     LayoutLength value;
250     value = 20 + ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
251     DALI_TEST_EQUALS( value.AsInteger(), 33.0f, 0.0001f, TEST_LOCATION );
252     DALI_TEST_EQUALS( value.AsDecimal(), 33.3333f, 0.0001f, TEST_LOCATION );
253   }
254   {
255     uint16_t padding( 1 );
256     LayoutLength right(35), left(10), mTotalLength(2);
257     LayoutLength value;
258     value = padding + ( right - left - mTotalLength ) / 2.0f;
259     //    = 1 + ( 35 - 10 - 2 ) / 2
260     DALI_TEST_EQUALS( value.AsInteger(), 13.0f, 0.0001f, TEST_LOCATION );
261     DALI_TEST_EQUALS( value.AsDecimal(), 12.5f, 0.0001f, TEST_LOCATION );
262   }
263   {
264     uint16_t padding = 1, top = 2, bottom = 3;
265     LayoutLength childSpace( 44 ), childHeight( 23 );
266     LayoutLength value;
267     value = padding + ( ( childSpace - childHeight ) / 2.0f ) + top - bottom;
268     //    = 1       + ( ( 44 - 23                  ) / 2 ) + 2 - 3
269     DALI_TEST_EQUALS( value.AsInteger(), 11.0f, 0.0001f, TEST_LOCATION );
270     DALI_TEST_EQUALS( value.AsDecimal(), 10.5f, 0.0001f, TEST_LOCATION );
271   }
272
273   END_TEST;
274 }
275
276 int UtcDaliLayouting_LayoutLength_Operators(void)
277 {
278   tet_infoline("UtcDaliLayouting_LayoutLength operators");
279
280   {
281     LayoutLength value = 10;
282     DALI_TEST_EQUALS( (int)value.AsInteger(), 10, TEST_LOCATION );
283     value += 1;
284     DALI_TEST_EQUALS( (int)value.AsInteger(), 11, TEST_LOCATION );
285     value -= 12;
286     DALI_TEST_EQUALS( (int)value.AsInteger(), -1, TEST_LOCATION );
287     LayoutLength value2 = value;
288     DALI_TEST_EQUALS( value == value2, true, TEST_LOCATION );
289     value2 = 123;
290     DALI_TEST_EQUALS( value != value2, true, TEST_LOCATION );
291     DALI_TEST_EQUALS( value < value2, true, TEST_LOCATION );
292     DALI_TEST_EQUALS( value <= value2, true, TEST_LOCATION );
293     value = 456;
294     DALI_TEST_EQUALS( value > value2, true, TEST_LOCATION );
295     DALI_TEST_EQUALS( value >= value2, true, TEST_LOCATION );
296   }
297
298   {
299     LayoutLength value( 123 );
300     std::stringstream ss;
301     ss << value;
302     DALI_TEST_EQUALS( ss.str(), "123", TEST_LOCATION );
303   }
304   {
305     LayoutLength value( 0.123f );
306     std::stringstream ss;
307     ss << value;
308     DALI_TEST_EQUALS( ss.str(), "0.123", TEST_LOCATION );
309   }
310   END_TEST;
311 }
312
313 int UtcDaliLayouting_HboxLayout01(void)
314 {
315   ToolkitTestApplication application;
316   tet_infoline(" UtcDaliLayouting_HboxLayout01");
317
318   Stage stage = Stage::GetCurrent();
319   auto hbox = Control::New();
320   auto hboxLayout = LinearLayout::New();
321   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
322   DevelControl::SetLayout( hbox, hboxLayout );
323   hbox.SetName( "HBox");
324
325   std::vector< Control > controls;
326   controls.push_back( CreateLeafControl( 40, 40 ) );
327   controls.push_back( CreateLeafControl( 60, 40 ) );
328   controls.push_back( CreateLeafControl( 80, 40 ) );
329   controls.push_back( CreateLeafControl( 100, 40 ) );
330
331   for( auto&& iter : controls )
332   {
333     hbox.Add( iter );
334   }
335
336   hbox.SetParentOrigin( ParentOrigin::CENTER );
337   hbox.SetAnchorPoint( AnchorPoint::CENTER );
338   stage.Add( hbox );
339
340   // Ensure layouting happens
341   application.SendNotification();
342   application.Render();
343
344   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
345   // hbox left justifies elements
346   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
347   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
348   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
349   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
350
351   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
352   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
353   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
354   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
355
356   // Change a layout
357   auto newHBoxLayout = LinearLayout::New();
358   newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
359   DevelControl::SetLayout( hbox, newHBoxLayout );
360
361   application.SendNotification();
362   application.Render();
363
364   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
365   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
366   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
367   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
368
369   END_TEST;
370 }
371
372 int UtcDaliLayouting_HboxLayout02(void)
373 {
374   ToolkitTestApplication application;
375   tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
376
377   Stage stage = Stage::GetCurrent();
378
379   auto hbox1 = Control::New();
380   auto hboxLayout1 = LinearLayout::New();
381   DevelControl::SetLayout( hbox1, hboxLayout1 );
382
383   auto hbox2 = Control::New();
384   auto hboxLayout2 = LinearLayout::New();
385   DevelControl::SetLayout( hbox2, hboxLayout2 );
386
387   hbox1.SetName( "HBox1");
388   hbox2.SetName( "HBox2");
389
390   std::vector< Control > controls;
391   controls.push_back( CreateLeafControl( 20, 40 ) );
392   controls.push_back( CreateLeafControl( 30, 50 ) );
393   controls.push_back( CreateLeafControl( 40, 60 ) );
394   controls.push_back( CreateLeafControl( 50, 70 ) );
395
396   controls.push_back( CreateLeafControl( 25, 40 ) );
397   controls.push_back( CreateLeafControl( 35, 50 ) );
398   controls.push_back( CreateLeafControl( 45, 60 ) );
399   controls.push_back( CreateLeafControl( 55, 70 ) );
400
401   int counter=0;
402   for( auto&& iter : controls )
403   {
404     if( counter < 4 )
405     {
406       hbox1.Add( iter );
407     }
408     else
409     {
410       hbox2.Add( iter );
411     }
412     ++counter;
413   }
414   hbox1.SetParentOrigin( ParentOrigin::CENTER );
415   hbox1.SetAnchorPoint( AnchorPoint::CENTER );
416   hbox2.SetParentOrigin( ParentOrigin::CENTER );
417   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
418
419   auto hbox3 = Control::New();
420   auto hboxLayout3 = LinearLayout::New();
421   DevelControl::SetLayout( hbox3, hboxLayout3 );
422
423   hbox3.SetParentOrigin( ParentOrigin::CENTER );
424   hbox3.SetName( "HBox3");
425   hbox3.Add( hbox1 );
426   hbox3.Add( hbox2 );
427
428   stage.Add( hbox3 );
429
430   // Ensure layouting happens
431   application.SendNotification();
432   application.Render();
433
434
435   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
436   // hbox left justifies elements
437   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
438   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
439   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,  5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
440   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,  0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
441
442   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
443   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
444   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
445   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
446
447
448   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
449   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
450   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f,  5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
451   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,  0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
452
453   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
454   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
455   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
456   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
457
458   // Test hbox1 and 2 are sized to wrap their content
459   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
460   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
461   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
462   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
463
464   // Test hbox3 matches parent (root layer)
465   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
466   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
467
468   END_TEST;
469 }
470
471
472 int UtcDaliLayouting_HboxLayout03(void)
473 {
474   ToolkitTestApplication application;
475   tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
476
477   Stage stage = Stage::GetCurrent();
478
479   auto hbox1 = Control::New();
480   auto hboxLayout1 = LinearLayout::New();
481   DevelControl::SetLayout( hbox1, hboxLayout1 );
482
483   auto hbox2 = Control::New();
484   auto hboxLayout2 = LinearLayout::New();
485   DevelControl::SetLayout( hbox2, hboxLayout2 );
486
487   hbox1.SetName( "HBox1");
488   hbox2.SetName( "HBox2");
489   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
490   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
491   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
492   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
493
494   std::vector< Control > controls;
495   controls.push_back( CreateLeafControl( 20, 40 ) );
496   controls.push_back( CreateLeafControl( 30, 50 ) );
497   controls.push_back( CreateLeafControl( 40, 60 ) );
498   controls.push_back( CreateLeafControl( 50, 70 ) );
499
500   controls.push_back( CreateLeafControl( 25, 40 ) );
501   controls.push_back( CreateLeafControl( 35, 50 ) );
502   controls.push_back( CreateLeafControl( 45, 60 ) );
503   controls.push_back( CreateLeafControl( 55, 70 ) );
504
505   int counter=0;
506   for( auto&& iter : controls )
507   {
508     if( counter < 4 )
509     {
510       hbox1.Add( iter );
511     }
512     else
513     {
514       hbox2.Add( iter );
515     }
516     ++counter;
517   }
518   hbox1.SetParentOrigin( ParentOrigin::CENTER );
519   hbox1.SetAnchorPoint( AnchorPoint::CENTER );
520   hbox2.SetParentOrigin( ParentOrigin::CENTER );
521   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
522
523   auto hbox3 = Control::New();
524   auto hboxLayout3 = LinearLayout::New();
525   DevelControl::SetLayout( hbox3, hboxLayout3);
526
527   hbox3.SetParentOrigin( ParentOrigin::CENTER );
528   hbox3.SetName( "HBox3");
529   hbox3.Add( hbox1 );
530   hbox3.Add( hbox2 );
531
532   stage.Add( hbox3 );
533
534   //std::ostringstream oss;
535   //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
536   //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
537
538   // Ensure layouting happens
539   application.SendNotification();
540   application.Render();
541
542
543   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
544   // hbox left justifies elements
545   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
546   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
547   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
548   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
549
550   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
551   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
552   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
553   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
554
555   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
556   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
557   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
558   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
559
560   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
561   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
562   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
563   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
564
565   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
566   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
567   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
568   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
569
570   // Test hbox3 matches parent (root layer)
571   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
572   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
573
574   END_TEST;
575 }
576
577 int UtcDaliLayouting_HboxLayout04(void)
578 {
579   ToolkitTestApplication application;
580   tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
581
582   Stage stage = Stage::GetCurrent();
583
584   auto hbox1 = Control::New();
585   auto hboxLayout1 = LinearLayout::New();
586   DevelControl::SetLayout( hbox1, hboxLayout1 );
587
588   auto hbox2 = Control::New();
589   auto hboxLayout2 = LinearLayout::New();
590   DevelControl::SetLayout( hbox2, hboxLayout2 );
591
592   hbox1.SetName( "HBox1"); // Default spec is to wrap content
593   hbox2.SetName( "HBox2");
594   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
595   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
596   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
597   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
598
599   std::vector< Control > controls;
600   controls.push_back( CreateLeafControl( 80, 40 ) );
601   controls.push_back( CreateLeafControl( 80, 50 ) );
602   controls.push_back( CreateLeafControl( 80, 60 ) );
603   controls.push_back( CreateLeafControl( 80, 70 ) );
604
605   controls.push_back( CreateLeafControl( 80, 40 ) );
606   controls.push_back( CreateLeafControl( 80, 50 ) );
607   controls.push_back( CreateLeafControl( 80, 60 ) );
608   controls.push_back( CreateLeafControl( 80, 70 ) );
609
610   int counter=0;
611   for( auto&& iter : controls )
612   {
613     if( counter < 4 )
614     {
615       hbox1.Add( iter );
616     }
617     else
618     {
619       hbox2.Add( iter );
620     }
621     ++counter;
622   }
623
624   controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
625   auto hbox3 = Control::New();
626   auto hboxLayout3 = LinearLayout::New();
627   DevelControl::SetLayout( hbox3, hboxLayout3 );
628
629   hbox3.SetParentOrigin( ParentOrigin::CENTER );
630   hbox3.SetName( "HBox3");
631   hbox3.Add( hbox1 );
632   hbox3.Add( hbox2 );
633   stage.Add( hbox3 );
634
635   //std::ostringstream oss;
636   //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
637   //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
638
639   // Ensure layouting happens
640   application.SendNotification();
641   application.Render();
642
643
644   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
645   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
646   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
647   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
648
649   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
650   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
651   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
652   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
653
654   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
655   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
656   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
657   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
658
659   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
660   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
661   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
662   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
663
664   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
665   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
666   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
667   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
668
669
670   // Test hbox3 matches parent (root layer)
671   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
672   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
673
674   END_TEST;
675 }
676
677 int UtcDaliLayouting_HboxLayout05(void)
678 {
679   ToolkitTestApplication application;
680   tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
681
682   Stage stage = Stage::GetCurrent();
683   auto hbox = Control::New();
684   auto hboxLayout = LinearLayout::New();
685   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
686   DevelControl::SetLayout( hbox, hboxLayout );
687   hbox.SetName( "HBox");
688
689   std::vector< Control > controls;
690   controls.push_back( CreateLeafControl( 40, 40 ) );
691   controls.push_back( CreateLeafControl( 60, 40 ) );
692   controls.push_back( CreateLeafControl( 80, 40 ) );
693   controls.push_back( CreateLeafControl( 100, 40 ) );
694
695   for( auto&& iter : controls )
696   {
697     hbox.Add( iter );
698     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
699     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
700   }
701
702   hbox.SetParentOrigin( ParentOrigin::CENTER );
703   hbox.SetAnchorPoint( AnchorPoint::CENTER );
704   stage.Add( hbox );
705
706   // Ensure layouting happens
707   application.SendNotification();
708   application.Render();
709
710   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
711   // hbox left justifies elements
712   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
713   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
714   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
715   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
716
717   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
718   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
719   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
720   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
721
722   END_TEST;
723 }
724
725 int UtcDaliLayouting_HboxLayout06(void)
726 {
727   ToolkitTestApplication application;
728   tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
729
730   Stage stage = Stage::GetCurrent();
731
732   auto rootControl = Control::New();
733   auto absoluteLayout = AbsoluteLayout::New();
734   DevelControl::SetLayout( rootControl, absoluteLayout );
735   rootControl.SetName( "AbsoluteLayout" );
736   stage.Add( rootControl );
737
738   auto hbox = Control::New();
739   auto hboxLayout = LinearLayout::New();
740   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
741   DevelControl::SetLayout( hbox, hboxLayout );
742   hbox.SetName( "HBox" );
743
744   std::vector< Control > controls;
745   controls.push_back( CreateLeafControl( 40, 40 ) );
746   controls.push_back( CreateLeafControl( 60, 40 ) );
747
748   for( auto&& iter : controls )
749   {
750     hbox.Add( iter );
751   }
752   hbox.SetParentOrigin( ParentOrigin::CENTER );
753   hbox.SetAnchorPoint( AnchorPoint::CENTER );
754   rootControl.Add( hbox );
755
756   // Ensure layouting happens
757   application.SendNotification();
758   application.Render();
759
760   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
761   // hbox left justifies elements
762   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
763   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
764
765   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
766   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
767
768   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
769
770   // Change a layout
771   auto newHBoxLayout = LinearLayout::New();
772   newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
773   DevelControl::SetLayout( hbox, newHBoxLayout );
774
775   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
776   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
777
778   application.SendNotification();
779   application.Render();
780
781   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
782
783   // Change size specification
784   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
785   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
786
787   application.SendNotification();
788   application.Render();
789
790   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
791
792   // Use WRAP_CONTENT again
793   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
794   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
795
796   application.SendNotification();
797   application.Render();
798
799   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
800
801   END_TEST;
802 }
803
804 int UtcDaliLayouting_HboxLayout07(void)
805 {
806   ToolkitTestApplication application;
807   tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
808
809   Stage stage = Stage::GetCurrent();
810   auto hbox = Control::New();
811   auto hboxLayout = LinearLayout::New();
812   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
813   DevelControl::SetLayout( hbox, hboxLayout );
814   hbox.SetName( "HBox");
815
816   std::vector< Control > controls;
817   controls.push_back( CreateLeafControl( 40, 40 ) );
818   controls.push_back( CreateLeafControl( 60, 40 ) );
819   controls.push_back( CreateLeafControl( 80, 40 ) );
820   controls.push_back( CreateLeafControl( 100, 40 ) );
821
822   for( auto&& iter : controls )
823   {
824     hbox.Add( iter );
825   }
826   hbox.SetParentOrigin( ParentOrigin::CENTER );
827   hbox.SetAnchorPoint( AnchorPoint::CENTER );
828   stage.Add( hbox );
829
830   hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
831
832   // Ensure layouting happens
833   application.SendNotification();
834   application.Render();
835
836   // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
837   // hbox left justifies elements
838   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
839   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
840   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
841   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
842
843   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
844   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
845   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
846   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
847
848   hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
849
850   // Ensure layouting happens
851   application.SendNotification();
852   application.Render();
853
854   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
855   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
856   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
857   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
858
859   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
860   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
861   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
862   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
863
864   END_TEST;
865 }
866
867 int UtcDaliLayouting_HboxLayout08(void)
868 {
869   ToolkitTestApplication application;
870   tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation");
871
872   Stage stage = Stage::GetCurrent();
873
874   auto rootControl = Control::New();
875   auto absoluteLayout = AbsoluteLayout::New();
876   absoluteLayout.SetAnimateLayout( true );
877   DevelControl::SetLayout( rootControl, absoluteLayout );
878   rootControl.SetName( "AbsoluteLayout" );
879   stage.Add( rootControl );
880
881   Control control1 = CreateLeafControl( 40, 40 );
882   rootControl.Add( control1 );
883
884   auto hbox = Control::New();
885   auto hboxLayout = LinearLayout::New();
886   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
887   DevelControl::SetLayout( hbox, hboxLayout );
888   hbox.SetName( "HBox" );
889
890   Control control2 = CreateLeafControl( 40, 40 );
891   hbox.Add( control2 );
892
893   hbox.SetParentOrigin( ParentOrigin::CENTER );
894   hbox.SetAnchorPoint( AnchorPoint::CENTER );
895   rootControl.Add( hbox );
896
897   DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION );
898   DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION );
899   DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION );
900   DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION );
901
902   tet_infoline(" Set hBoxLayout to animate");
903   hboxLayout.SetAnimateLayout( true );
904   tet_infoline(" Set absoluteLayout not to animate");
905   absoluteLayout.SetAnimateLayout( false );
906
907   DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION );
908   DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION );
909   DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION );
910   DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION );
911
912   END_TEST;
913 }
914
915 int UtcDaliLayouting_HboxLayout09(void)
916 {
917   ToolkitTestApplication application;
918   tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set alignment");
919
920   Stage stage = Stage::GetCurrent();
921   auto hbox = Control::New();
922   auto hboxLayout = LinearLayout::New();
923   DevelControl::SetLayout( hbox, hboxLayout );
924   hbox.SetName( "HBox");
925
926   std::vector< Control > controls;
927   controls.push_back( CreateLeafControl( 40, 40 ) );
928   controls.push_back( CreateLeafControl( 60, 60 ) );
929
930   for( auto&& iter : controls )
931   {
932     hbox.Add( iter );
933   }
934   hbox.SetParentOrigin( ParentOrigin::CENTER );
935   hbox.SetAnchorPoint( AnchorPoint::CENTER );
936   stage.Add( hbox );
937
938   // Check default orientation
939   DALI_TEST_EQUALS( static_cast<unsigned int>( hboxLayout.GetOrientation() ), static_cast<unsigned int>( LinearLayout::Orientation::HORIZONTAL ), TEST_LOCATION );
940   // Check default alignment
941   DALI_TEST_EQUALS( hboxLayout.GetAlignment(), ( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL ), TEST_LOCATION );
942
943   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN );
944
945   // Ensure layouting happens
946   application.SendNotification();
947   application.Render();
948
949   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
950   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
951
952   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
953   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
954
955   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END );
956
957   // Ensure layouting happens
958   application.SendNotification();
959   application.Render();
960
961   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
962   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
963
964   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
965   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
966
967   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
968
969   // Ensure layouting happens
970   application.SendNotification();
971   application.Render();
972
973   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
974   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
975
976   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
977   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
978
979   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP );
980
981   // Ensure layouting happens
982   application.SendNotification();
983   application.Render();
984
985   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
986   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
987
988   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
989   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
990
991   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP );
992
993   // Ensure layouting happens
994   application.SendNotification();
995   application.Render();
996
997   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
998   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
999
1000   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1001   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1002
1003   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP );
1004
1005   // Ensure layouting happens
1006   application.SendNotification();
1007   application.Render();
1008
1009   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1010   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1011
1012   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1013   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1014
1015   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1016
1017   // Ensure layouting happens
1018   application.SendNotification();
1019   application.Render();
1020
1021   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1022   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1023
1024   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1025   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1026
1027   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1028
1029   // Ensure layouting happens
1030   application.SendNotification();
1031   application.Render();
1032
1033   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1034   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1035
1036   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1037   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1038
1039   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1040
1041   // Ensure layouting happens
1042   application.SendNotification();
1043   application.Render();
1044
1045   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1046   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1047
1048   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1049   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1050
1051   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL );
1052
1053   // Ensure layouting happens
1054   application.SendNotification();
1055   application.Render();
1056
1057   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1058   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1059
1060   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1061   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1062
1063   hboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1064   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN );
1065
1066   // Ensure layouting happens
1067   application.SendNotification();
1068   application.Render();
1069
1070   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1071   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1072
1073   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1074   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1075
1076   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END );
1077
1078   // Ensure layouting happens
1079   application.SendNotification();
1080   application.Render();
1081
1082   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1083   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1084
1085   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1086   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1087
1088   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
1089
1090   // Ensure layouting happens
1091   application.SendNotification();
1092   application.Render();
1093
1094   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1095   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1096
1097   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1098   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1099
1100   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP );
1101
1102   // Ensure layouting happens
1103   application.SendNotification();
1104   application.Render();
1105
1106   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1107   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1108
1109   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1110   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1111
1112   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP );
1113
1114   // Ensure layouting happens
1115   application.SendNotification();
1116   application.Render();
1117
1118   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1119   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1120
1121   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1122   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1123
1124   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP );
1125
1126   // Ensure layouting happens
1127   application.SendNotification();
1128   application.Render();
1129
1130   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1131   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1132
1133   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1134   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1135
1136   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1137
1138   // Ensure layouting happens
1139   application.SendNotification();
1140   application.Render();
1141
1142   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1143   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1144
1145   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1146   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1147
1148   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1149
1150   // Ensure layouting happens
1151   application.SendNotification();
1152   application.Render();
1153
1154   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1155   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1156
1157   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1158   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1159
1160   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1161
1162   // Ensure layouting happens
1163   application.SendNotification();
1164   application.Render();
1165
1166   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1167   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1168
1169   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1170   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1171
1172   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL );
1173
1174   // Ensure layouting happens
1175   application.SendNotification();
1176   application.Render();
1177
1178   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1179   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1180
1181   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1182   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1183
1184   END_TEST;
1185 }
1186
1187 int UtcDaliLayouting_HboxLayout_Weight(void)
1188 {
1189   ToolkitTestApplication application;
1190   tet_infoline( " UtcDaliLayouting_HboxLayout_Weight - Test LinearLayout weight horizontally" );
1191
1192   Stage stage = Stage::GetCurrent();
1193   auto hbox = Control::New();
1194   auto hboxLayout = LinearLayout::New();
1195   DevelControl::SetLayout( hbox, hboxLayout );
1196   hbox.SetName( "HBox" );
1197
1198   std::vector<Control> controls;
1199   controls.push_back( CreateLeafControl( 40, 40 ) );
1200   controls.push_back( CreateLeafControl( 60, 40 ) );
1201   controls.push_back( CreateLeafControl( 80, 40 ) );
1202   controls.push_back( CreateLeafControl( 100, 40 ) );
1203
1204   // Set weight for each leaf to use quarter of available space
1205   // 480 * 0.25, 480 * 0.25, 480 * 0.25, 480 * 0.25,
1206   // width spec has to be set to 0 so not to consume any extra space.
1207   for( auto&& iter : controls )
1208   {
1209     iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1210     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1211     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1212     hbox.Add( iter );
1213   }
1214
1215   hbox.SetParentOrigin( ParentOrigin::CENTER );
1216   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1217   stage.Add( hbox );
1218
1219   // Ensure layouting happens
1220   application.SendNotification();
1221   application.Render();
1222
1223   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1224   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1225   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1226   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 360.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1227
1228   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1229   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1230   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1231   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1232
1233   // Set weight for 3, 4 leafs to use all remaining available space after 1, 2 content sized leafs.
1234   // 40, 60, (480 - 40 - 60) * 0.5, (480 - 40 - 60) * 0.5
1235   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1236   controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1237   controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1238   controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1239   controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1240   controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1241
1242   // Ensure layouting happens
1243   application.SendNotification();
1244   application.Render();
1245
1246   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1247   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1248   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1249   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 290.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1250
1251   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1252   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1253   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 190.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1254   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 190.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1255
1256   // Add intrinsic width for 3rd leaf so now we should get
1257   // 40, 60, (480 - 40 - 60 - 80) * 0.5 + 80, (480 - 40 - 60 - 80) * 0.5
1258   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 80 );
1259
1260   // Ensure layouting happens
1261   application.SendNotification();
1262   application.Render();
1263
1264   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1265   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1266   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1267   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1268
1269   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1270   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1271   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1272   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1273
1274   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1275   controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1276   controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1277   controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1278   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1279   controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1280   controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 40 );
1281   controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1282
1283   // Ensure layouting happens
1284   application.SendNotification();
1285   application.Render();
1286
1287   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1288   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1289   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1290   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1291
1292   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 110.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1293   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 220.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1294   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 110.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1295   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1296
1297   // WRAP_CONTENT doesn't affect weight
1298   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1299   controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1300   controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1301   controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1302   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1303   controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1304   controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1305   controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1306
1307   // Ensure layouting happens
1308   application.SendNotification();
1309   application.Render();
1310
1311   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1312   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1313   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1314   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1315
1316   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1317   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1318   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1319   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 300.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1320
1321   // MATCH_PARENT doesn't affect weight
1322   for( auto&& iter : controls )
1323   {
1324     iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1325     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1326     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1327   }
1328
1329   // Ensure layouting happens
1330   application.SendNotification();
1331   application.Render();
1332
1333   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1334   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1335   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1336   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 360.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1337
1338   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1339   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1340   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1341   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1342
1343   const Extents CONTROL_MARGIN = Extents( 10, 10, 0, 0 );
1344   for( auto&& iter : controls )
1345   {
1346     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1347     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1348     iter.SetProperty( Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1349   }
1350
1351   controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1352   controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1353   controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1354   controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1355
1356   application.SendNotification();
1357   application.Render();
1358
1359   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 10.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1360   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 70.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1361   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 150.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1362   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 250.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1363
1364   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1365   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1366   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1367   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 220.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1368
1369   END_TEST;
1370 }
1371
1372 int UtcDaliLayouting_VboxLayout_Weight(void)
1373 {
1374   ToolkitTestApplication application;
1375   tet_infoline( " UtcDaliLayouting_VboxLayout_Weight - Test LinearLayout weight vertically" );
1376
1377   Stage stage = Stage::GetCurrent();
1378   auto vbox = Control::New();
1379   auto vboxLayout = LinearLayout::New();
1380   vboxLayout.SetOrientation( Dali::Toolkit::LinearLayout::Orientation::VERTICAL );
1381   DevelControl::SetLayout( vbox, vboxLayout );
1382   vbox.SetName( "VBox" );
1383
1384   std::vector<Control> controls;
1385   controls.push_back( CreateLeafControl( 40, 40 ) );
1386   controls.push_back( CreateLeafControl( 60, 60 ) );
1387   controls.push_back( CreateLeafControl( 80, 80 ) );
1388   controls.push_back( CreateLeafControl( 100, 100 ) );
1389
1390   // Set weight for each leaf to use quarter of available space
1391   // 800 * 0.25, 800 * 0.25, 800 * 0.25, 800 * 0.25,
1392   // width spec has to be set to 0 so not to consume any extra space.
1393   for( auto&& iter : controls )
1394   {
1395     iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1396     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1397     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1398     vbox.Add( iter );
1399   }
1400
1401   vbox.SetParentOrigin( ParentOrigin::CENTER );
1402   vbox.SetAnchorPoint( AnchorPoint::CENTER );
1403   stage.Add( vbox );
1404
1405   // Ensure layouting happens
1406   application.SendNotification();
1407   application.Render();
1408
1409   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1410   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1411   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1412   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 600.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1413
1414   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1415   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1416   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1417   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1418
1419   // Set weight for 3, 4 leafs to use all remaining available space after 1, 2 content sized leafs.
1420   // 40, 60, (800 - 40 - 60) * 0.5, (800 - 40 - 60) * 0.5
1421   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1422   controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1423   controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1424   controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1425   controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1426   controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1427
1428   // Ensure layouting happens
1429   application.SendNotification();
1430   application.Render();
1431
1432   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1433   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1434   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1435   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 450.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1436
1437   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1438   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1439   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1440   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1441
1442   // Add intrinsic width for 3rd leaf so now we should get
1443   // 40, 60, (800 - 40 - 60 - 100) * 0.5 + 100, (800 - 40 - 60 - 100) * 0.5
1444   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
1445
1446   // Ensure layouting happens
1447   application.SendNotification();
1448   application.Render();
1449
1450   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1451   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1452   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1453   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 500.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1454
1455   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1456   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1457   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1458   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1459
1460   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1461   controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1462   controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1463   controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1464   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1465   controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1466   controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
1467   controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1468
1469   // Ensure layouting happens
1470   application.SendNotification();
1471   application.Render();
1472
1473   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1474   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1475   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 525.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1476   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1477
1478   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1479   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1480   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1481   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1482
1483   // WRAP_CONTENT doesn't affect weight
1484   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1485   controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1486   controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1487   controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1488   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1489   controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1490   controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1491   controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1492
1493   // Ensure layouting happens
1494   application.SendNotification();
1495   application.Render();
1496
1497   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1498   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1499   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1500   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1501
1502   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1503   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1504   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1505   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 620.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1506
1507   // MATCH_PARENT doesn't affect weight
1508   for( auto&& iter : controls )
1509   {
1510     iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1511     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1512     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1513   }
1514
1515   // Ensure layouting happens
1516   application.SendNotification();
1517   application.Render();
1518
1519   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1520   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1521   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1522   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 600.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1523
1524   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1525   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1526   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1527   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1528
1529   const Extents CONTROL_MARGIN = Extents( 0, 0, 10, 10 );
1530   for( auto&& iter : controls )
1531   {
1532     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1533     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1534     iter.SetProperty( Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1535   }
1536
1537   controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1538   controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1539   controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1540   controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1541
1542   application.SendNotification();
1543   application.Render();
1544
1545   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1546   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1547   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1548   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 250.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1549
1550   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1551   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1552   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1553   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 540.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1554
1555   END_TEST;
1556 }
1557
1558 int UtcDaliLayouting_NestedLinearLayout_Weight(void)
1559 {
1560   ToolkitTestApplication application;
1561   tet_infoline("UtcDaliLayouting_NestedLinearLayout_Weight - test weighted children with wrapped parent");
1562
1563   Stage stage = Stage::GetCurrent();
1564   auto rootControl = Control::New();
1565   rootControl.SetName( "AbsoluteLayout");
1566   auto rootLayout = AbsoluteLayout::New();
1567   DevelControl::SetLayout( rootControl, rootLayout );
1568   rootControl.SetAnchorPoint( AnchorPoint::CENTER );
1569   rootControl.SetParentOrigin( ParentOrigin::CENTER );
1570   stage.Add( rootControl );
1571
1572   auto hbox = Control::New();
1573   auto hboxLayout = LinearLayout::New();
1574   DevelControl::SetLayout( hbox, hboxLayout );
1575   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1576   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1577
1578   std::vector< Control > controls;
1579   controls.push_back( CreateLeafControl( 40, 40 ) );
1580   controls.push_back( CreateLeafControl( 60, 60 ) );
1581
1582   // set equal share of wrapped content width (40 + 60 = 100) for both children 100 * 0.5, 100 * 0.5
1583   for( auto&& iter : controls )
1584   {
1585     iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1586     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1587     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1588     hbox.Add( iter );
1589   }
1590
1591   hbox.SetParentOrigin( ParentOrigin::CENTER );
1592   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1593   rootControl.Add( hbox );
1594
1595   // Ensure layouting happens
1596   application.SendNotification();
1597   application.Render();
1598
1599   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1600   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1601
1602   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1603   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1604
1605   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1606   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1607
1608   hboxLayout.SetOrientation(Dali::Toolkit::LinearLayout::Orientation::VERTICAL);
1609
1610   // set equal share of wrapped content height (40 + 60 = 100) for both children 100 * 0.5, 100 * 0.5
1611   for( auto&& iter : controls )
1612   {
1613     iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1614     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1615     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1616   }
1617
1618   // Ensure layouting happens
1619   application.SendNotification();
1620   application.Render();
1621
1622   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1623   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1624
1625   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1626   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1627
1628   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1629   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1630
1631   END_TEST;
1632 }
1633
1634
1635 namespace
1636 {
1637 const char* TEST_IMAGE_FILE_NAME =  TEST_RESOURCE_DIR  "/broken.png";
1638 }
1639
1640 int UtcDaliLayouting_HboxLayout_ImageView(void)
1641 {
1642   ToolkitTestApplication application;
1643   tet_infoline(" UtcDaliLayouting_HboxLayout - Use image view for leaf");
1644
1645   Stage stage = Stage::GetCurrent();
1646   auto hbox = Control::New();
1647   auto hboxLayout = LinearLayout::New();
1648   DevelControl::SetLayout( hbox, hboxLayout );
1649   hbox.SetName( "HBox" );
1650
1651   std::string url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 100, 100 ) );
1652   ImageView imageView = CreateImageView( url, ImageDimensions() );
1653
1654   hbox.SetParentOrigin( ParentOrigin::CENTER );
1655   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1656   hbox.Add( imageView );
1657   stage.Add( hbox );
1658
1659   // Ensure layouting happens
1660   application.SendNotification();
1661   application.Render();
1662
1663   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1664   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1665
1666   tet_infoline("UtcDaliLayouting_HboxLayout - Change image (new size)");
1667   url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 200, 200 ) );
1668   imageView.SetImage( url );
1669
1670   // Ensure layouting happenss
1671   application.SendNotification();
1672   application.Render();
1673
1674   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1675   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1676
1677   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1678   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1679
1680   // Ensure layouting happenss
1681   application.SendNotification();
1682   application.Render();
1683
1684   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1685   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1686
1687   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1688   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1689
1690   // Ensure layouting happenss
1691   application.SendNotification();
1692   application.Render();
1693
1694   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1695   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1696
1697   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1698   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1699
1700   Image image = FrameBufferImage::New( 50, 50, Pixel::RGBA8888 );
1701   imageView.SetImage( image );
1702
1703   // Ensure layouting happenss
1704   application.SendNotification();
1705   application.Render();
1706
1707   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1708   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1709
1710   Property::Map imagePropertyMap;
1711   imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1712   imagePropertyMap[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
1713   imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 150;
1714   imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 150;
1715   imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap );
1716
1717   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1718   // Ensure layouting happenss
1719   application.SendNotification();
1720   application.Render();
1721
1722   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 325.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1723   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1724
1725   END_TEST;
1726 }
1727
1728 int UtcDaliLayouting_HboxLayout_TextLabel(void)
1729 {
1730   ToolkitTestApplication application;
1731   tet_infoline(" UtcDaliLayouting_HboxLayout - Use text label for leaf");
1732
1733   Stage stage = Stage::GetCurrent();
1734
1735   auto hbox = Control::New();
1736   auto hboxLayout = LinearLayout::New();
1737   DevelControl::SetLayout( hbox, hboxLayout );
1738   hbox.SetName( "HBox" );
1739   hbox.SetParentOrigin( ParentOrigin::CENTER );
1740   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1741
1742   std::vector< Control > controls;
1743   TextLabel textLabel = CreateTextLabel( "W" );
1744   controls.push_back( textLabel );
1745   hbox.Add( textLabel );
1746   stage.Add( hbox );
1747
1748   // Ensure layouting happens
1749   application.SendNotification();
1750   application.Render();
1751
1752   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1753   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 54.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1754
1755   textLabel.SetProperty( TextLabel::Property::TEXT, "WWWW" );
1756
1757   // Ensure layouting happens
1758   application.SendNotification();
1759   application.Render();
1760
1761   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1762   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 216.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1763
1764   textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
1765
1766   // Ensure layouting happens
1767   application.SendNotification();
1768   application.Render();
1769
1770   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1771   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1772
1773   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1774   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1775
1776   // Ensure layouting happens
1777   application.SendNotification();
1778   application.Render();
1779
1780   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1781   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1782
1783   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1784   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1785
1786   // Ensure layouting happens
1787   application.SendNotification();
1788   application.Render();
1789
1790   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1791   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1792
1793   END_TEST;
1794 }
1795
1796 // Padding tests
1797
1798 int UtcDaliLayouting_HboxLayout_Padding01(void)
1799 {
1800   ToolkitTestApplication application;
1801   tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
1802
1803   Stage stage = Stage::GetCurrent();
1804   auto hbox = Control::New();
1805   auto hboxLayout = LinearLayout::New();
1806   DevelControl::SetLayout( hbox, hboxLayout );
1807   hbox.SetName( "HBox");
1808
1809   std::vector< Control > controls;
1810   controls.push_back( CreateLeafControl( 40, 40 ) );
1811   controls.push_back( CreateLeafControl( 60, 40 ) );
1812   controls.push_back( CreateLeafControl( 80, 40 ) );
1813   controls.push_back( CreateLeafControl( 100, 40 ) );
1814
1815   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1816   tet_printf( "\nAdding Padding to control at index %u \n", 1 );
1817   controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1818
1819   for( auto&& iter : controls )
1820   {
1821     hbox.Add( iter );
1822   }
1823   hbox.SetParentOrigin( ParentOrigin::CENTER );
1824   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1825   stage.Add( hbox );
1826
1827   // Ensure layouting happens
1828   application.SendNotification();
1829   application.Render();
1830
1831   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1832   // hbox left justifies elements
1833   tet_infoline("Test Child Actor Position");
1834   float xPositionOfControlBeingTested = 0.0f;
1835   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1836                                                                                             380.0f,
1837                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1838   xPositionOfControlBeingTested += 40.0f;
1839
1840   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1841                                                                                             380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
1842                                                                                             0.0001f, TEST_LOCATION );
1843
1844   xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1845   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1846
1847   xPositionOfControlBeingTested += 80.0f;
1848   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1849
1850   tet_infoline("Test Child Actor Size");
1851   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1852
1853   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1854                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
1855                                                                                         0.0001f, TEST_LOCATION );
1856
1857   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1858   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1859
1860   END_TEST;
1861 }
1862
1863 int UtcDaliLayouting_HboxLayout_Padding02(void)
1864 {
1865   ToolkitTestApplication application;
1866   tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
1867
1868   Stage stage = Stage::GetCurrent();
1869   auto hbox = Control::New();
1870   auto hboxLayout = LinearLayout::New();
1871   DevelControl::SetLayout( hbox, hboxLayout );
1872   hbox.SetName( "HBox");
1873
1874   std::vector< Control > controls;
1875   controls.push_back( CreateLeafControl( 40, 40 ) );
1876   controls.push_back( CreateLeafControl( 60, 40 ) );
1877   controls.push_back( CreateLeafControl( 80, 40 ) );
1878   controls.push_back( CreateLeafControl( 100, 40 ) );
1879
1880   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1881
1882   for( auto&& iter : controls )
1883   {
1884     iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1885     hbox.Add( iter );
1886   }
1887   hbox.SetParentOrigin( ParentOrigin::CENTER );
1888   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1889   stage.Add( hbox );
1890
1891   // Ensure layouting happens
1892   application.SendNotification();
1893   application.Render();
1894
1895   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1896   // hbox left justifies elements
1897   tet_infoline("Test Child Actor Position");
1898   float xPositionOfControlBeingTested = 0.0f;
1899   float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
1900
1901   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1902                                                                                             yPositionOfControlBeingTested,
1903                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1904   xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1905
1906   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1907                                                                                             yPositionOfControlBeingTested,
1908                                                                                             0.0f ),
1909                                                                                             0.0001f, TEST_LOCATION );
1910
1911   xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1912   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1913                                                                                             yPositionOfControlBeingTested,
1914                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1915
1916   xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1917   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1918                                                                                             yPositionOfControlBeingTested,
1919                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1920
1921   tet_infoline("Test Child Actor Size");
1922   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1923                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1924                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
1925
1926   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1927                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1928                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
1929
1930   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
1931                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1932                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
1933
1934   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1935                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1936                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
1937
1938   END_TEST;
1939 }
1940
1941
1942 int UtcDaliLayouting_HboxLayout_Padding03(void)
1943 {
1944   ToolkitTestApplication application;
1945   tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
1946
1947   Stage stage = Stage::GetCurrent();
1948   auto hbox = Control::New();
1949   auto hboxLayout = LinearLayout::New();
1950   DevelControl::SetLayout( hbox, hboxLayout );
1951   hbox.SetName( "HBox");
1952
1953   std::vector< Control > controls;
1954   controls.push_back( CreateLeafControl( 40, 40 ) );
1955   controls.push_back( CreateLeafControl( 40, 40 ) );
1956   controls.push_back( CreateLeafControl( 40, 40 ) );
1957
1958   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1959   tet_printf( "\nAdding Padding to control at index 1 \n" );
1960   controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1961
1962   for( auto&& iter : controls )
1963   {
1964     hbox.Add( iter );
1965   }
1966   hbox.SetParentOrigin( ParentOrigin::CENTER );
1967   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1968   stage.Add( hbox );
1969
1970   // Ensure layouting happens
1971   application.SendNotification();
1972   application.Render();
1973
1974   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1975   // hbox left justifies elements
1976   tet_infoline("Test Child Actor Position");
1977   float xPositionOfControlBeingTested = 0.0f;
1978   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1979                                                                                             380.0f,
1980                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1981   xPositionOfControlBeingTested += 40.0f;
1982
1983   DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1984                                                                                             380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
1985                                                                                             0.0001f, TEST_LOCATION );
1986
1987   xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1988   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1989
1990   const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
1991   tet_printf( "\nChanging Padding to control at index 1 \n" );
1992   controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
1993
1994   // Ensure layouting happens
1995   application.SendNotification();
1996   application.Render();
1997
1998   xPositionOfControlBeingTested = 0.0f; // reset
1999
2000   tet_infoline("Test Child Actor Position");
2001   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2002                                                                                             380.0f,
2003                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2004   xPositionOfControlBeingTested += 40.0f;
2005
2006   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2007                                                                                             380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
2008                                                                                             0.0001f, TEST_LOCATION );
2009
2010   xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
2011   tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
2012   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2013
2014   tet_infoline("Test Child Actor Size");
2015   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2016
2017   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
2018                                                                                         40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
2019                                                                                         0.0001f, TEST_LOCATION );
2020
2021   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2022
2023   END_TEST;
2024 }
2025
2026 int UtcDaliLayouting_HboxLayout_Padding04(void)
2027 {
2028   ToolkitTestApplication application;
2029   tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
2030
2031   // Adding padding to the layout should offset the positioning of the children.
2032
2033   const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2034   const Size CONTROL_SIZE = Size( 40, 40 );
2035
2036   Stage stage = Stage::GetCurrent();
2037   // Create a root layout, ideally Dali would have a default layout in the root layer.
2038   // Without this root layer the LinearLayout (or any other layout) will not
2039   // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2040   // It uses the default stage size and ideally should have a layout added to it.
2041   auto rootLayoutControl = Control::New();
2042   rootLayoutControl.SetName( "AbsoluteLayout");
2043   auto rootLayout = AbsoluteLayout::New();
2044   DevelControl::SetLayout( rootLayoutControl, rootLayout );
2045   rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2046   rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2047   stage.Add( rootLayoutControl );
2048
2049   auto hbox = Control::New();
2050   auto hboxLayout = LinearLayout::New();
2051   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2052   DevelControl::SetLayout( hbox, hboxLayout );
2053   hbox.SetName( "HBox");
2054   hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2055   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2056   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2057
2058   std::vector< Control > controls;
2059   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2060   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2061   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2062   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2063
2064   for( auto&& iter : controls )
2065   {
2066     hbox.Add( iter );
2067   }
2068
2069   hbox.SetParentOrigin( ParentOrigin::CENTER );
2070   hbox.SetAnchorPoint( AnchorPoint::CENTER );
2071   rootLayoutControl.Add( hbox );
2072
2073   // Ensure layouting happens
2074   application.SendNotification();
2075   application.Render();
2076
2077   // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2078   application.SendNotification();
2079
2080   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2081   // hbox left justifies elements
2082   tet_infoline("Test Child Actor Position");
2083
2084   auto controlXPosition=0.0f;
2085
2086   controlXPosition = LAYOUT_PADDING.start;  // First child positioned at offset defined by the padding
2087   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2088                                                                                             LAYOUT_PADDING.top,
2089                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2090
2091   controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
2092   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2093                                                                                             LAYOUT_PADDING.top,
2094                                                                                             0.0f ),
2095                                                                                             0.0001f, TEST_LOCATION );
2096
2097   controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
2098   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2099                                                                                             LAYOUT_PADDING.top,
2100                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2101
2102   controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
2103   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2104                                                                                             LAYOUT_PADDING.top,
2105                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2106
2107   auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
2108   auto totalControlsHeight = CONTROL_SIZE.height;
2109
2110   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2111                                                                                  totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2112                                                                                  0.0f ), 0.0001f, TEST_LOCATION );
2113
2114
2115   END_TEST;
2116 }
2117
2118 int UtcDaliLayouting_HboxLayout_Padding05(void)
2119 {
2120   ToolkitTestApplication application;
2121   tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
2122
2123   // Adding padding to the layout should offset the positioning of the children.
2124
2125   const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2126   const Size CONTROL_SIZE = Size( 40, 40 );
2127
2128   Stage stage = Stage::GetCurrent();
2129   // Create a root layout, ideally Dali would have a default layout in the root layer.
2130   // Without this root layer the LinearLayout (or any other layout) will not
2131   // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2132   // It uses the default stage size and ideally should have a layout added to it.
2133   auto rootLayoutControl = Control::New();
2134   rootLayoutControl.SetName( "AbsoluteLayout");
2135   auto rootLayout = AbsoluteLayout::New();
2136   DevelControl::SetLayout( rootLayoutControl, rootLayout );
2137   rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2138   rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2139   stage.Add( rootLayoutControl );
2140
2141   auto hbox = Control::New();
2142   auto hboxLayout = LinearLayout::New();
2143   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2144   DevelControl::SetLayout( hbox, hboxLayout );
2145   hbox.SetName( "HBox");
2146   hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2147   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2148   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2149
2150   std::vector< Control > controls;
2151   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2152   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2153   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2154   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2155
2156   for( auto&& iter : controls )
2157   {
2158     hbox.Add( iter );
2159   }
2160
2161   hbox.SetParentOrigin( ParentOrigin::CENTER );
2162   hbox.SetAnchorPoint( AnchorPoint::CENTER );
2163   rootLayoutControl.Add( hbox );
2164
2165   // Ensure layouting happens
2166   application.SendNotification();
2167   application.Render();
2168
2169   // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2170   application.SendNotification();
2171
2172   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2173   // hbox left justifies elements
2174   tet_infoline("Test Child Actor Position");
2175
2176   auto controlXPosition=0.0f;
2177
2178   controlXPosition = LAYOUT_PADDING.start;  // First child positioned at offset defined by the padding
2179   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2180                                                                                             LAYOUT_PADDING.top,
2181                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2182
2183   controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
2184   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2185                                                                                             LAYOUT_PADDING.top,
2186                                                                                             0.0f ),
2187                                                                                             0.0001f, TEST_LOCATION );
2188
2189   controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
2190   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2191                                                                                             LAYOUT_PADDING.top,
2192                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2193
2194   controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
2195   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2196                                                                                             LAYOUT_PADDING.top,
2197                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2198
2199   auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
2200   auto totalControlsHeight = CONTROL_SIZE.height;
2201
2202   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2203                                                                                  totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2204                                                                                  0.0f ), 0.0001f, TEST_LOCATION );
2205
2206   // Change layout padding
2207   const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
2208   tet_printf( "\nChanging Padding to control at index 1 \n" );
2209   hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
2210
2211   // Ensure layouting happens
2212   application.SendNotification();
2213   application.Render();
2214
2215   // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2216   application.SendNotification();
2217
2218   controlXPosition = NEW_LAYOUT_PADDING.start;  // First child positioned at offset defined by the padding
2219   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
2220                                                                                             NEW_LAYOUT_PADDING.top,
2221                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2222
2223   controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
2224   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2225                                                                                             NEW_LAYOUT_PADDING.top,
2226                                                                                             0.0f ),
2227                                                                                             0.0001f, TEST_LOCATION );
2228
2229   controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
2230   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2231                                                                                             NEW_LAYOUT_PADDING.top,
2232                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2233
2234   controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
2235   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2236                                                                                             NEW_LAYOUT_PADDING.top,
2237                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2238   totalControlsWidth = CONTROL_SIZE.width * controls.size();
2239   totalControlsHeight = CONTROL_SIZE.height;
2240
2241   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
2242                                                                                  totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
2243                                                                                  0.0f ), 0.0001f, TEST_LOCATION );
2244   END_TEST;
2245 }
2246
2247 // Margin Tests
2248
2249 int UtcDaliLayouting_HboxLayout_Margin01(void)
2250 {
2251   ToolkitTestApplication application;
2252   tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
2253
2254   Stage stage = Stage::GetCurrent();
2255   auto hbox = Control::New();
2256   auto hboxLayout = LinearLayout::New();
2257   DevelControl::SetLayout( hbox, hboxLayout );
2258   hbox.SetName( "HBox");
2259
2260   std::vector< Control > controls;
2261   controls.push_back( CreateLeafControl( 40, 40 ) );
2262   controls.push_back( CreateLeafControl( 60, 40 ) );
2263   controls.push_back( CreateLeafControl( 80, 40 ) );
2264   controls.push_back( CreateLeafControl( 100, 40 ) );
2265
2266   const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
2267   tet_printf( "\nAdding Margin to control at index 1 \n" );
2268   controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
2269
2270   for( auto&& iter : controls )
2271   {
2272     hbox.Add( iter );
2273   }
2274   hbox.SetParentOrigin( ParentOrigin::CENTER );
2275   hbox.SetAnchorPoint( AnchorPoint::CENTER );
2276   stage.Add( hbox );
2277
2278   // Ensure layouting happens
2279   application.SendNotification();
2280   application.Render();
2281
2282   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2283   // hbox left justifies elements
2284   tet_infoline("Test Child Actor Position");
2285   auto xPositionOfControlBeingTested = 0.0f;
2286   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2287                                                                                             380.0f,
2288                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2289   xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
2290
2291   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2292                                                                                             380.0f + CONTROL_MARGIN.top, 0.0f ),
2293                                                                                             0.0001f, TEST_LOCATION );
2294
2295   xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
2296   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2297
2298   xPositionOfControlBeingTested += 80.0f;
2299   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2300
2301   tet_infoline("Test Child Actor Size is the same after Margin added");
2302   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2303   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
2304   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2305   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2306
2307   END_TEST;
2308 }
2309
2310
2311 int UtcDaliLayouting_VboxLayout01(void)
2312 {
2313   ToolkitTestApplication application;
2314   tet_infoline(" UtcDaliLayouting_VboxLayout01");
2315
2316   Stage stage = Stage::GetCurrent();
2317   auto vbox = Control::New();
2318   auto vboxLayout = LinearLayout::New();
2319   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2320   vboxLayout.SetAlignment( LinearLayout::Alignment::TOP | LinearLayout::Alignment::CENTER_HORIZONTAL );
2321   DevelControl::SetLayout( vbox, vboxLayout );
2322   vbox.SetName( "Vbox");
2323
2324   std::vector< Control > controls;
2325   controls.push_back( CreateLeafControl( 40, 40 ) );
2326   controls.push_back( CreateLeafControl( 60, 60 ) );
2327   controls.push_back( CreateLeafControl( 80, 80 ) );
2328   controls.push_back( CreateLeafControl( 100, 100 ) );
2329
2330   for( auto&& iter : controls )
2331   {
2332     vbox.Add( iter );
2333   }
2334   vbox.SetParentOrigin( ParentOrigin::CENTER );
2335   vbox.SetAnchorPoint( AnchorPoint::CENTER );
2336   stage.Add( vbox );
2337
2338   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2339
2340   // Check it.
2341   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2342
2343   // Ensure layouting happens
2344   application.SendNotification();
2345   application.Render();
2346
2347   // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
2348   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2349   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2350   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2351   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2352
2353   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2354   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2355   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2356   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2357
2358   END_TEST;
2359 }
2360
2361 int UtcDaliLayouting_VboxLayout02(void)
2362 {
2363   ToolkitTestApplication application;
2364   tet_infoline(" UtcDaliLayouting_VboxLayout01");
2365
2366   Stage stage = Stage::GetCurrent();
2367
2368   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
2369   // LayoutGroup for this to happen automatically.
2370   //
2371   // For this test, add an hbox instead
2372   auto rootControl = Control::New();
2373   auto absoluteLayout = AbsoluteLayout::New();
2374   DevelControl::SetLayout( rootControl, absoluteLayout );
2375   rootControl.SetName( "AbsoluteLayout");
2376   stage.Add( rootControl );
2377
2378   auto vbox = Control::New();
2379   auto vboxLayout = LinearLayout::New();
2380   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2381   vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
2382   DevelControl::SetLayout( vbox, vboxLayout );
2383   vbox.SetName( "Vbox");
2384   rootControl.Add( vbox );
2385
2386   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2387   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2388
2389   std::vector< Control > controls;
2390   controls.push_back( CreateLeafControl( 40, 40 ) );
2391   controls.push_back( CreateLeafControl( 60, 60 ) );
2392   controls.push_back( CreateLeafControl( 80, 80 ) );
2393   controls.push_back( CreateLeafControl( 100, 100 ) );
2394
2395   for( auto&& iter : controls )
2396   {
2397     vbox.Add( iter );
2398   }
2399   vbox.SetParentOrigin( ParentOrigin::CENTER );
2400   vbox.SetAnchorPoint( AnchorPoint::CENTER );
2401
2402   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2403
2404   // Check it.
2405   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2406
2407   // Ensure layouting happens
2408   application.SendNotification();
2409   application.Render();
2410
2411   DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
2412   DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
2413
2414   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
2415   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2416   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2417
2418   // 3rd control is set to match parent - this should also be 100 wide
2419   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2420   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2421   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2422   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2423
2424   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2425   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2426   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2427   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2428
2429   END_TEST;
2430 }
2431
2432
2433 int UtcDaliLayouting_VboxLayout03(void)
2434 {
2435   ToolkitTestApplication application;
2436   tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
2437
2438   Stage stage = Stage::GetCurrent();
2439
2440   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
2441   // LayoutGroup for this to happen automatically.
2442   //
2443   // For this test, add an hbox instead
2444   auto hbox = Control::New();
2445   auto hboxLayout = LinearLayout::New();
2446   DevelControl::SetLayout( hbox, hboxLayout );
2447   hbox.SetName( "Hbox");
2448   stage.Add( hbox );
2449
2450   auto vbox = Control::New();
2451   auto vboxLayout = LinearLayout::New();
2452   vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
2453   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2454   vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
2455
2456   DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
2457
2458   DevelControl::SetLayout( vbox, vboxLayout );
2459   vbox.SetName( "Vbox");
2460   hbox.Add( vbox );
2461
2462   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2463   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2464
2465   std::vector< Control > controls;
2466   controls.push_back( CreateLeafControl( 40, 40 ) );
2467   controls.push_back( CreateLeafControl( 60, 60 ) );
2468   controls.push_back( CreateLeafControl( 80, 80 ) );
2469   controls.push_back( CreateLeafControl( 100, 100 ) );
2470
2471   for( auto&& iter : controls )
2472   {
2473     vbox.Add( iter );
2474   }
2475   vbox.SetParentOrigin( ParentOrigin::CENTER );
2476   vbox.SetAnchorPoint( AnchorPoint::CENTER );
2477
2478   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2479
2480   // Check it.
2481   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2482
2483   // Ensure layouting happens
2484   application.SendNotification();
2485   application.Render();
2486
2487   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
2488   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
2489
2490   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
2491   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2492   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2493
2494   // 3rd control is set to match parent - this should also be 100 wide
2495   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2496   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2497   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2498   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2499
2500   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2501   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2502   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2503   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2504
2505   END_TEST;
2506 }
2507
2508 int UtcDaliLayouting_VboxLayout_Padding(void)
2509 {
2510   ToolkitTestApplication application;
2511   tet_infoline("UtcDaliLayouting_VboxLayout_Padding - Adding Padding to the vbox");
2512
2513   // Adding padding to the layout should offset the positioning of the children.
2514
2515   const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2516   const Size CONTROL_SIZE = Size( 40, 40 );
2517
2518   Stage stage = Stage::GetCurrent();
2519   // Create a root layout, ideally Dali would have a default layout in the root layer.
2520   // Without this root layer the LinearLayout (or any other layout) will not
2521   // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2522   // It uses the default stage size and ideally should have a layout added to it.
2523   auto rootLayoutControl = Control::New();
2524   rootLayoutControl.SetName( "AbsoluteLayout");
2525   auto rootLayout = AbsoluteLayout::New();
2526   DevelControl::SetLayout( rootLayoutControl, rootLayout );
2527   rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2528   rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2529   stage.Add( rootLayoutControl );
2530
2531   auto vbox = Control::New();
2532   auto vboxLayout = LinearLayout::New();
2533   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2534   DevelControl::SetLayout( vbox, vboxLayout );
2535   vbox.SetName( "VBox");
2536   vbox.SetProperty( Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2537   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2538   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2539
2540   std::vector< Control > controls;
2541   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2542   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2543   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2544   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2545
2546   for( auto&& iter : controls )
2547   {
2548     vbox.Add( iter );
2549   }
2550
2551   vbox.SetParentOrigin( ParentOrigin::CENTER );
2552   vbox.SetAnchorPoint( AnchorPoint::CENTER );
2553   rootLayoutControl.Add( vbox );
2554
2555   // Ensure layouting happens
2556   application.SendNotification();
2557   application.Render();
2558
2559   // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2560   application.SendNotification();
2561
2562   // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
2563   tet_infoline("Test Child Actor Position");
2564
2565   auto controlYPosition = 0.0f;
2566
2567   controlYPosition = LAYOUT_PADDING.top;  // First child positioned at offset defined by the padding
2568   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2569                                                                                             LAYOUT_PADDING.top,
2570                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2571
2572   controlYPosition += CONTROL_SIZE.height; // Second child positioned is the position of the first child + the first child's height.
2573   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2574                                                                                             controlYPosition,
2575                                                                                             0.0f ),
2576                                                                                             0.0001f, TEST_LOCATION );
2577
2578   controlYPosition += CONTROL_SIZE.height; // Third child positioned adjacent to second
2579   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2580                                                                                             controlYPosition,
2581                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2582
2583   controlYPosition += CONTROL_SIZE.height; // Forth passed adjacent to the third
2584   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2585                                                                                             controlYPosition,
2586                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2587
2588   auto totalControlsWidth = CONTROL_SIZE.width;
2589   auto totalControlsHeight = CONTROL_SIZE.height * controls.size();
2590
2591   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2592                                                                                  totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2593                                                                                  0.0f ), 0.0001f, TEST_LOCATION );
2594
2595   END_TEST;
2596 }
2597
2598
2599 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
2600 {
2601   ToolkitTestApplication application;
2602   tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
2603   tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
2604
2605   Stage stage = Stage::GetCurrent();
2606
2607   auto hbox = Control::New();
2608   auto hboxLayout = Test::CustomLayout::New();
2609   DevelControl::SetLayout( hbox, hboxLayout );
2610   hbox.SetName( "HBox");
2611
2612   std::vector< Control > controls;
2613   controls.push_back( CreateLeafControl( 40, 40 ) );
2614   controls.push_back( CreateLeafControl( 60, 40 ) );
2615   controls.push_back( CreateLeafControl( 80, 40 ) );
2616   controls.push_back( CreateLeafControl( 100, 40 ) );
2617
2618   for( auto&& iter : controls )
2619   {
2620     hbox.Add( iter );
2621   }
2622   hbox.SetParentOrigin( ParentOrigin::CENTER );
2623   hbox.SetAnchorPoint( AnchorPoint::CENTER );
2624   stage.Add( hbox );
2625
2626   // Ensure layouting happens
2627   application.SendNotification();
2628   application.Render();
2629
2630   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2631   // hbox left justifies elements
2632   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2633   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2634   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2635   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2636
2637   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2638   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2639   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2640   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2641
2642   controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
2643   controls[2].Lower();      // 2->1; 2, 1, 3, 0
2644
2645   application.SendNotification();
2646   application.Render();
2647
2648   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2649   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2650   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2651   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2652
2653   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2654   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2655   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2656   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2657
2658   END_TEST;
2659 }
2660
2661 int UtcDaliLayouting_HboxLayout_TargetSize(void)
2662 {
2663   ToolkitTestApplication application;
2664   tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
2665
2666   Stage stage = Stage::GetCurrent();
2667   auto hbox = Control::New();
2668   auto hboxLayout = LinearLayout::New();
2669   DevelControl::SetLayout( hbox, hboxLayout );
2670   hbox.SetName( "HBox");
2671
2672   std::vector< Control > controls;
2673   controls.push_back( CreateLeafControl( 40, 40 ) );
2674   for( auto&& iter : controls )
2675   {
2676     iter.SetSize( 100, 100 );
2677     hbox.Add( iter );
2678   }
2679   hbox.SetParentOrigin( ParentOrigin::CENTER );
2680   hbox.SetAnchorPoint( AnchorPoint::CENTER );
2681   stage.Add( hbox );
2682
2683   // Ensure layouting happens
2684   application.SendNotification();
2685   application.Render();
2686
2687   // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
2688   // hbox left justifies elements
2689   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2690   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2691
2692   END_TEST;
2693 }
2694
2695 int UtcDaliLayouting_RemoveLayout01(void)
2696 {
2697   ToolkitTestApplication application;
2698   tet_infoline(" UtcDaliLayouting_RemoveLayout");
2699
2700   Stage stage = Stage::GetCurrent();
2701
2702   auto rootControl = Control::New();
2703   auto absoluteLayout = AbsoluteLayout::New();
2704   DevelControl::SetLayout( rootControl, absoluteLayout );
2705   rootControl.SetName( "AbsoluteLayout" );
2706   stage.Add( rootControl );
2707
2708   auto hbox = Control::New();
2709   auto hboxLayout = LinearLayout::New();
2710   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2711   DevelControl::SetLayout( hbox, hboxLayout );
2712   hbox.SetName( "HBox" );
2713
2714   std::vector< Control > controls;
2715   controls.push_back( CreateLeafControl( 40, 40 ) );
2716   controls.push_back( CreateLeafControl( 60, 40 ) );
2717
2718   for( auto&& iter : controls )
2719   {
2720     hbox.Add( iter );
2721   }
2722   hbox.SetParentOrigin( ParentOrigin::CENTER );
2723   hbox.SetAnchorPoint( AnchorPoint::CENTER );
2724   rootControl.Add( hbox );
2725
2726   tet_infoline("Layout as normal");
2727   application.SendNotification();
2728   application.Render();
2729
2730   tet_infoline("Set an empty layout on hbox container");
2731   LinearLayout emptyLayout;
2732   DevelControl::SetLayout( hbox, emptyLayout );
2733
2734   tet_infoline("Run another layout");
2735   application.SendNotification();
2736   application.Render();
2737
2738   tet_infoline("Check leaf controls haven't moved");
2739
2740   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2741   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2742
2743   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2744   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2745
2746   END_TEST;
2747 }
2748
2749 int UtcDaliLayouting_LayoutChildren01(void)
2750 {
2751   ToolkitTestApplication application;
2752   tet_infoline(" UtcDaliLayouting_LayoutChildren01");
2753
2754   Stage stage = Stage::GetCurrent();
2755
2756   auto rootControl = Control::New();
2757   auto absoluteLayout = AbsoluteLayout::New();
2758   DevelControl::SetLayout( rootControl, absoluteLayout );
2759   stage.Add( rootControl );
2760
2761   auto hbox = Control::New();
2762   auto hboxLayout = LinearLayout::New();
2763   DevelControl::SetLayout( hbox, hboxLayout );
2764   rootControl.Add( hbox );
2765
2766   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2767
2768   tet_infoline("Test removal by setting empty layout to child container" );
2769   DevelControl::SetLayout( hbox, LayoutItem{} );
2770
2771   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2772
2773   auto& hboxImpl = GetImplementation( hboxLayout );
2774   Handle empty;
2775   DALI_TEST_EQUALS( hboxLayout.GetOwner(), empty, TEST_LOCATION );
2776   DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2777
2778   // For coverage
2779   hboxImpl.SetLayoutRequested();
2780
2781   END_TEST;
2782 }
2783
2784 int UtcDaliLayouting_LayoutChildren02(void)
2785 {
2786   ToolkitTestApplication application;
2787   tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2788
2789   Stage stage = Stage::GetCurrent();
2790
2791   auto rootControl = Control::New();
2792   auto absoluteLayout = AbsoluteLayout::New();
2793   DevelControl::SetLayout( rootControl, absoluteLayout );
2794   stage.Add( rootControl );
2795
2796   auto hbox = Control::New();
2797   auto hboxLayout = LinearLayout::New();
2798   DevelControl::SetLayout( hbox, hboxLayout );
2799   rootControl.Add( hbox );
2800
2801   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2802
2803   tet_infoline("Test removal by removing child actor from parent container" );
2804   hbox.Unparent();
2805
2806   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2807
2808   auto& hboxImpl = GetImplementation( hboxLayout );
2809   tet_infoline("Test child actor still has hbox layout " );
2810   DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
2811
2812   tet_infoline("Test hbox layout has no parent " );
2813   DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2814
2815   END_TEST;
2816 }
2817
2818 int UtcDaliLayouting_LayoutChildren03(void)
2819 {
2820   ToolkitTestApplication application;
2821   tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2822
2823   Stage stage = Stage::GetCurrent();
2824
2825   auto rootControl = Control::New();
2826   auto absoluteLayout = AbsoluteLayout::New();
2827   DevelControl::SetLayout( rootControl, absoluteLayout );
2828   stage.Add( rootControl );
2829
2830   auto hbox = Control::New();
2831   auto hboxLayout = LinearLayout::New();
2832   DevelControl::SetLayout( hbox, hboxLayout );
2833   rootControl.Add( hbox );
2834
2835   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2836
2837   tet_infoline("Test removal by removing child layout from parent layout" );
2838   absoluteLayout.Remove( hboxLayout );
2839
2840   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2841
2842   auto& hboxImpl = GetImplementation( hboxLayout );
2843
2844   tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
2845   DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
2846   DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
2847
2848   tet_infoline("Check orphaned layout has no parent");
2849   DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2850
2851   END_TEST;
2852 }
2853
2854
2855 int UtcDaliLayouting_LayoutChildren04(void)
2856 {
2857   ToolkitTestApplication application;
2858   tet_infoline(" UtcDaliLayouting_LayoutChildren03");
2859
2860   Stage stage = Stage::GetCurrent();
2861
2862   auto rootControl = Control::New();
2863   auto absoluteLayout = AbsoluteLayout::New();
2864   DevelControl::SetLayout( rootControl, absoluteLayout );
2865   stage.Add( rootControl );
2866
2867   auto hbox = Control::New();
2868   tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
2869   auto hboxLayout = LinearLayout::New();
2870   rootControl.Add( hbox );
2871
2872   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2873
2874   tet_infoline("Then setting a layout on the child container");
2875   DevelControl::SetLayout( hbox, hboxLayout );
2876
2877   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2878
2879   auto& hboxImpl = GetImplementation( hboxLayout );
2880   auto& absImpl = GetImplementation( absoluteLayout );
2881   DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
2882   DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
2883
2884   END_TEST;
2885 }
2886
2887 int UtcDaliLayouting_SetLayoutOrder01(void)
2888 {
2889   ToolkitTestApplication application;
2890   tet_infoline(" UtcDaliLayouting_SetLayoutOrder01 - Call SetLayout after adding the control to the root layout");
2891
2892   Stage stage = Stage::GetCurrent();
2893
2894   auto rootControl = Control::New();
2895   auto absoluteLayout = AbsoluteLayout::New();
2896   DevelControl::SetLayout( rootControl, absoluteLayout );
2897   rootControl.SetName( "AbsoluteLayout" );
2898   stage.Add( rootControl );
2899
2900   tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
2901   auto hbox = Control::New();
2902   auto hboxLayout = LinearLayout::New();
2903   hbox.SetName( "HBox");
2904
2905   tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
2906   rootControl.Add( hbox );
2907
2908   tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
2909   DevelControl::SetLayout( hbox, hboxLayout );
2910
2911   // Add a Child control
2912   std::vector< Control > controls;
2913   controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
2914   for( auto&& iter : controls )
2915   {
2916     hbox.Add( iter );
2917   }
2918
2919   // Ensure layouting happens
2920   application.SendNotification();
2921   application.Render();
2922
2923   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2924
2925   END_TEST;
2926 }
2927
2928 int UtcDaliLayouting_SetLayoutOrder02(void)
2929 {
2930   ToolkitTestApplication application;
2931   tet_infoline(" UtcDaliLayouting_SetLayoutOrder02 - Test the layout item order and the control order");
2932
2933   Stage stage = Stage::GetCurrent();
2934
2935   auto rootControl = Control::New();
2936   auto absoluteLayout = AbsoluteLayout::New();
2937   DevelControl::SetLayout( rootControl, absoluteLayout );
2938   rootControl.SetName( "AbsoluteLayout" );
2939   stage.Add( rootControl );
2940
2941   auto hbox = Control::New();
2942   auto hboxLayout = LinearLayout::New();
2943   hbox.SetName( "HBox");
2944
2945   rootControl.Add( hbox );
2946
2947   DevelControl::SetLayout( hbox, hboxLayout );
2948
2949   // Add child controls
2950   std::vector< Control > controls;
2951   controls.push_back( CreateLeafControl( 100, 100 ) );  // 0
2952   controls.push_back( CreateLeafControl( 100, 100 ) );  // 1
2953   controls.push_back( CreateLeafControl( 100, 100 ) );  // 2
2954
2955   for( auto&& iter : controls )
2956   {
2957     hbox.Add( iter );
2958   }
2959
2960   // Ensure layouting happens
2961   application.SendNotification();
2962   application.Render();
2963
2964   TestLayoutItemOrder( controls, hboxLayout );
2965
2966   tet_infoline("RaiseToTop");
2967
2968   controls[0].RaiseToTop(); // 1 2 0
2969
2970   TestLayoutItemOrder( controls, hboxLayout );
2971
2972   tet_infoline("LowerToBottom");
2973
2974   controls[2].LowerToBottom();  // 2 1 0
2975
2976   TestLayoutItemOrder( controls, hboxLayout );
2977
2978   tet_infoline("Remove / Add");
2979
2980   hbox.Remove( controls[2] );  // 1 0
2981   hbox.Add( controls[2] );     // 1 0 2
2982
2983   TestLayoutItemOrder( controls, hboxLayout );
2984
2985   tet_infoline("SetLayout");
2986
2987   auto vboxLayout = LinearLayout::New();
2988   DevelControl::SetLayout( controls[0], vboxLayout );
2989
2990   TestLayoutItemOrder( controls, hboxLayout );
2991
2992   tet_infoline("Raise");
2993
2994   controls[0].Raise();  // 1 2 0
2995
2996   TestLayoutItemOrder( controls, hboxLayout );
2997
2998   tet_infoline("Lower");
2999
3000   controls[2].Lower();   // 2 1 0
3001
3002   TestLayoutItemOrder( controls, hboxLayout );
3003
3004   tet_infoline("SetLayout again");
3005
3006   auto vboxLayout1 = LinearLayout::New();
3007   DevelControl::SetLayout( controls[2], vboxLayout1 );
3008
3009   TestLayoutItemOrder( controls, hboxLayout );
3010
3011   DevelControl::SetLayout( controls[2], vboxLayout );
3012
3013   END_TEST;
3014 }
3015
3016 int UtcDaliLayouting_LayoutGroup01(void)
3017 {
3018   ToolkitTestApplication application;
3019   tet_infoline("UtcDaliLayouting_LayoutGroup01 - Test adding a control to a layout then adding a TextLabel to that control");
3020
3021   Control rootControl;
3022   SetupRootLayoutControl( rootControl );
3023
3024   // Create a parent layout
3025   auto hbox = Control::New();
3026   auto hboxLayout = LinearLayout::New();
3027   hbox.SetName( "HBox");
3028   rootControl.Add( hbox );
3029   DevelControl::SetLayout( hbox, hboxLayout );
3030   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3031   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3032   DevelControl::SetLayoutingRequired( hbox, true );
3033   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3034
3035   tet_infoline("Add a control without SetLayout being called but with layout required set true");
3036
3037   auto control = Control::New();
3038   control.SetName("Control1");
3039   DevelControl::SetLayoutingRequired( control, true );
3040   hbox.Add( control );
3041   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3042   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3043   tet_infoline("Add a Textlabel to the control");
3044   auto textLabel = TextLabel::New("Test text");
3045   textLabel.SetName("TextLabel");
3046
3047   control.Add( textLabel );
3048
3049   // Ensure layouting happens
3050   application.SendNotification();
3051   application.Render();
3052
3053   tet_infoline("Test text is it's natural size");
3054   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3055   tet_infoline("Test control is width of it's parent and height of it's child");
3056   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3057
3058   END_TEST;
3059 }
3060
3061 int UtcDaliLayouting_LayoutGroup02(void)
3062 {
3063   ToolkitTestApplication application;
3064   tet_infoline("UtcDaliLayouting_LayoutGroup02 - Test control is the size of it's largest child");
3065
3066   Control rootControl;
3067   SetupRootLayoutControl( rootControl );
3068
3069   // Create a parent layout
3070   auto hbox = Control::New();
3071   auto hboxLayout = LinearLayout::New();
3072   DevelControl::SetLayout( hbox, hboxLayout );
3073   hbox.SetName( "HBox");
3074   rootControl.Add( hbox );
3075   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3076   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3077   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3078
3079   tet_infoline("Add a control without SetLayout being called but with layout required set true");
3080
3081   auto control = Control::New();
3082   control.SetName("Control1");
3083   DevelControl::SetLayoutingRequired( control, true );
3084   hbox.Add( control );
3085   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3086   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3087
3088   tet_infoline("Add a Textlabel to the control");
3089   auto textLabel = TextLabel::New("Test text");
3090   textLabel.SetName("TextLabel");
3091   control.Add( textLabel );
3092
3093   tet_infoline("Add another  Textlabel to the control");
3094   auto largeTextLabel = TextLabel::New("Test large text");
3095   largeTextLabel.SetName("TextLabel-Large");
3096   control.Add( largeTextLabel );
3097
3098   // Ensure layouting happens
3099   application.SendNotification();
3100   application.Render();
3101
3102   tet_infoline("Test text is it's natural size");
3103   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3104   tet_infoline("Test text is centered in the control, the control is the size of the largest child");
3105   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3106
3107   tet_infoline("Test large text is it's natural size");
3108   DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3109   tet_infoline("Test text is aligned to start as is the size of the control");
3110   DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3111
3112   tet_infoline("Test control is width of it's parent and height of it's largest child");
3113   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3114
3115   END_TEST;
3116 }
3117
3118 int UtcDaliLayouting_LayoutGroup03(void)
3119 {
3120   ToolkitTestApplication application;
3121   tet_infoline("UtcDaliLayouting_LayoutGroup03 - Test control with a LayoutGroup as a leaf");
3122
3123   Control rootControl;
3124   SetupRootLayoutControl( rootControl );
3125
3126   // Create a parent layout
3127   auto hbox = Control::New();
3128   auto hboxLayout = LinearLayout::New();
3129   DevelControl::SetLayout( hbox, hboxLayout );
3130   hbox.SetName( "HBox");
3131   rootControl.Add( hbox );
3132   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3133   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3134   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3135
3136   tet_infoline("Add a control without SetLayout being called");
3137
3138   auto control = Control::New();
3139   control.SetName("Control1");
3140   hbox.Add( control );
3141   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3142   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  100 );
3143
3144   // Ensure layouting happens
3145   application.SendNotification();
3146   application.Render();
3147
3148   tet_infoline("Test control is width of it's parent and exact given height");
3149   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3150   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3151
3152   END_TEST;
3153 }
3154
3155
3156 int UtcDaliLayouting_LayoutGroup04(void)
3157 {
3158   ToolkitTestApplication application;
3159   tet_infoline("UtcDaliLayouting_LayoutGroup04 - Test control with a LayoutGroup as a leaf and with SetLayotRequired = true");
3160
3161   Control rootControl;
3162   SetupRootLayoutControl( rootControl );
3163
3164   // Create a parent layout
3165   auto hbox = Control::New();
3166   auto hboxLayout = LinearLayout::New();
3167   DevelControl::SetLayout( hbox, hboxLayout );
3168   hbox.SetName( "HBox");
3169   rootControl.Add( hbox );
3170   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3171   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3172   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3173
3174   tet_infoline("Add a control without SetLayout being called");
3175
3176   auto control = Control::New();
3177   control.SetName("Control1");
3178   DevelControl::SetLayoutingRequired( control, true );
3179   hbox.Add( control );
3180   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3181   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  100 );
3182
3183   // Ensure layouting happens
3184   application.SendNotification();
3185   application.Render();
3186
3187   tet_infoline("Test control is width of it's parent and exact given height");
3188   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3189   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3190
3191   END_TEST;
3192 }
3193
3194 int UtcDaliLayouting_IsLayoutingRequired(void)
3195 {
3196   ToolkitTestApplication application;
3197   tet_infoline("UtcDaliLayouting_IsLayoutingRequired - Test setting the SetLayoutRequired and then check if flag was set");
3198
3199   Control rootControl;
3200   SetupRootLayoutControl( rootControl );
3201
3202   // Create a parent layout
3203   auto hbox = Control::New();
3204   auto hboxLayout = LinearLayout::New();
3205   DevelControl::SetLayout( hbox, hboxLayout );
3206   hbox.SetName( "HBox");
3207   rootControl.Add( hbox );
3208   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3209   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3210   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3211
3212   tet_infoline("Add a control without SetLayout being called");
3213
3214   auto control = Control::New();
3215   control.SetName("Control1");
3216   DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), false, TEST_LOCATION );
3217   DevelControl::SetLayoutingRequired( control, true );
3218   hbox.Add( control );
3219   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3220   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  100 );
3221
3222   // Ensure layouting happens
3223   application.SendNotification();
3224   application.Render();
3225
3226   tet_infoline("Test control is width of it's parent and exact given height");
3227   DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), true, TEST_LOCATION );
3228
3229   END_TEST;
3230 }
3231
3232 int UtcDaliLayouting_LayoutGroupWithPadding01(void)
3233 {
3234   ToolkitTestApplication application;
3235   tet_infoline("UtcDaliLayouting_LayoutGroupWithPadding01 - Test adding a control to a layout that has padding");
3236
3237   Control rootControl;
3238   SetupRootLayoutControl( rootControl );
3239
3240   // Create a parent layout
3241   auto hbox = Control::New();
3242   auto hboxLayout = LinearLayout::New();
3243   hbox.SetName( "HBox");
3244   rootControl.Add( hbox );
3245   DevelControl::SetLayout( hbox, hboxLayout );
3246   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3247   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3248   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3249
3250   tet_infoline("Add a control without SetLayout being called");
3251
3252   auto control = Control::New();
3253   control.SetName("Control1");
3254   DevelControl::SetLayoutingRequired( control, true );
3255   hbox.Add( control );
3256   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3257   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3258
3259   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
3260   tet_printf( "Adding Padding to control");
3261   control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
3262
3263   tet_infoline("Add a Textlabel to the control");
3264   auto textLabel = TextLabel::New("Test text");
3265   textLabel.SetName("TextLabel");
3266   control.Add( textLabel );
3267
3268   // Ensure layouting happens
3269   application.SendNotification();
3270   application.Render();
3271
3272   tet_infoline("Test text is it's natural size");
3273   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3274   tet_infoline("Test control is size of it's child and control it's own padding");
3275   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 245.0f, 86.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3276
3277   END_TEST;
3278 }
3279
3280 int UtcDaliLayouting_LayoutGroupWithChildMargin01(void)
3281 {
3282   ToolkitTestApplication application;
3283   tet_infoline("UtcDaliLayouting_LayoutGroupWithChildMargin01 - Test adding a control with padding to a layout that has padding");
3284
3285   Control rootControl;
3286   SetupRootLayoutControl( rootControl );
3287
3288   // Create a parent layout
3289   auto hbox = Control::New();
3290   auto hboxLayout = LinearLayout::New();
3291   hbox.SetName( "HBox");
3292   rootControl.Add( hbox );
3293   DevelControl::SetLayout( hbox, hboxLayout );
3294   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3295   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3296   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3297
3298   tet_infoline("Add a control without SetLayout being called");
3299
3300   auto control = Control::New();
3301   control.SetName("Control1");
3302   DevelControl::SetLayoutingRequired( control, true );
3303   hbox.Add( control );
3304   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3305   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3306
3307   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
3308   tet_printf( "Adding Padding to control");
3309   control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
3310
3311   tet_infoline("Add a Textlabel to the control");
3312   auto textLabel = TextLabel::New("Test text");
3313   const Extents CHILD_MARGIN = Extents( 10, 0, 5, 0 );
3314   textLabel.SetProperty( Toolkit::Control::Property::MARGIN, CHILD_MARGIN );
3315   textLabel.SetName("TextLabel");
3316   control.Add( textLabel );
3317
3318   // Ensure layouting happens
3319   application.SendNotification();
3320   application.Render();
3321
3322   tet_infoline("Test text is it's natural size");
3323   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3324   tet_infoline("Test control is width of it's parent and height of it's child");
3325   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 255.0f, 91.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3326
3327   END_TEST;
3328 }
3329
3330 int UtcDaliLayouting_SetLayout(void)
3331 {
3332   ToolkitTestApplication application;
3333   tet_infoline(" UtcDaliLayouting_SetLayout - Test reusing layouts");