[dali_1.3.47] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-Layouting.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <dali-toolkit-test-suite-utils.h>
21 #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_LayoutChildren01(void)
2696 {
2697   ToolkitTestApplication application;
2698   tet_infoline(" UtcDaliLayouting_LayoutChildren01");
2699
2700   Stage stage = Stage::GetCurrent();
2701
2702   auto rootControl = Control::New();
2703   auto absoluteLayout = AbsoluteLayout::New();
2704   DevelControl::SetLayout( rootControl, absoluteLayout );
2705   stage.Add( rootControl );
2706
2707   auto hbox = Control::New();
2708   auto hboxLayout = LinearLayout::New();
2709   DevelControl::SetLayout( hbox, hboxLayout );
2710   rootControl.Add( hbox );
2711
2712   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2713
2714   tet_infoline("Test removal by removing child actor from parent container" );
2715   hbox.Unparent();
2716
2717   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2718
2719   auto& hboxImpl = GetImplementation( hboxLayout );
2720   tet_infoline("Test child actor still has hbox layout " );
2721   DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
2722
2723   tet_infoline("Test hbox layout has no parent " );
2724   DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2725
2726   END_TEST;
2727 }
2728
2729 int UtcDaliLayouting_LayoutChildren02(void)
2730 {
2731   ToolkitTestApplication application;
2732   tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2733
2734   Stage stage = Stage::GetCurrent();
2735
2736   auto rootControl = Control::New();
2737   auto absoluteLayout = AbsoluteLayout::New();
2738   DevelControl::SetLayout( rootControl, absoluteLayout );
2739   stage.Add( rootControl );
2740
2741   auto hbox = Control::New();
2742   auto hboxLayout = LinearLayout::New();
2743   DevelControl::SetLayout( hbox, hboxLayout );
2744   rootControl.Add( hbox );
2745
2746   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2747
2748   tet_infoline("Test removal by removing child layout from parent layout" );
2749   absoluteLayout.Remove( hboxLayout );
2750
2751   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2752
2753   auto& hboxImpl = GetImplementation( hboxLayout );
2754
2755   tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
2756   DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
2757   DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
2758
2759   tet_infoline("Check orphaned layout has no parent");
2760   DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2761
2762   END_TEST;
2763 }
2764
2765
2766 int UtcDaliLayouting_LayoutChildren03(void)
2767 {
2768   ToolkitTestApplication application;
2769   tet_infoline(" UtcDaliLayouting_LayoutChildren03");
2770
2771   Stage stage = Stage::GetCurrent();
2772
2773   auto rootControl = Control::New();
2774   auto absoluteLayout = AbsoluteLayout::New();
2775   DevelControl::SetLayout( rootControl, absoluteLayout );
2776   stage.Add( rootControl );
2777
2778   auto hbox = Control::New();
2779   tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
2780   auto hboxLayout = LinearLayout::New();
2781   rootControl.Add( hbox );
2782
2783   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2784
2785   tet_infoline("Then setting a layout on the child container");
2786   DevelControl::SetLayout( hbox, hboxLayout );
2787
2788   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2789
2790   auto& hboxImpl = GetImplementation( hboxLayout );
2791   auto& absImpl = GetImplementation( absoluteLayout );
2792   DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
2793   DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
2794
2795   END_TEST;
2796 }
2797
2798 int UtcDaliLayouting_SetLayoutOrder01(void)
2799 {
2800   ToolkitTestApplication application;
2801   tet_infoline(" UtcDaliLayouting_SetLayoutOrder01 - Call SetLayout after adding the control to the root layout");
2802
2803   Stage stage = Stage::GetCurrent();
2804
2805   auto rootControl = Control::New();
2806   auto absoluteLayout = AbsoluteLayout::New();
2807   DevelControl::SetLayout( rootControl, absoluteLayout );
2808   rootControl.SetName( "AbsoluteLayout" );
2809   stage.Add( rootControl );
2810
2811   tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
2812   auto hbox = Control::New();
2813   auto hboxLayout = LinearLayout::New();
2814   hbox.SetName( "HBox");
2815
2816   tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
2817   rootControl.Add( hbox );
2818
2819   tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
2820   DevelControl::SetLayout( hbox, hboxLayout );
2821
2822   // Add a Child control
2823   std::vector< Control > controls;
2824   controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
2825   for( auto&& iter : controls )
2826   {
2827     hbox.Add( iter );
2828   }
2829
2830   // Ensure layouting happens
2831   application.SendNotification();
2832   application.Render();
2833
2834   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2835
2836   END_TEST;
2837 }
2838
2839 int UtcDaliLayouting_SetLayoutOrder02(void)
2840 {
2841   ToolkitTestApplication application;
2842   tet_infoline(" UtcDaliLayouting_SetLayoutOrder02 - Test the layout item order and the control order");
2843
2844   Stage stage = Stage::GetCurrent();
2845
2846   auto rootControl = Control::New();
2847   auto absoluteLayout = AbsoluteLayout::New();
2848   DevelControl::SetLayout( rootControl, absoluteLayout );
2849   rootControl.SetName( "AbsoluteLayout" );
2850   stage.Add( rootControl );
2851
2852   auto hbox = Control::New();
2853   auto hboxLayout = LinearLayout::New();
2854   hbox.SetName( "HBox");
2855
2856   rootControl.Add( hbox );
2857
2858   DevelControl::SetLayout( hbox, hboxLayout );
2859
2860   // Add child controls
2861   std::vector< Control > controls;
2862   controls.push_back( CreateLeafControl( 100, 100 ) );  // 0
2863   controls.push_back( CreateLeafControl( 100, 100 ) );  // 1
2864   controls.push_back( CreateLeafControl( 100, 100 ) );  // 2
2865
2866   for( auto&& iter : controls )
2867   {
2868     hbox.Add( iter );
2869   }
2870
2871   // Ensure layouting happens
2872   application.SendNotification();
2873   application.Render();
2874
2875   TestLayoutItemOrder( controls, hboxLayout );
2876
2877   tet_infoline("RaiseToTop");
2878
2879   controls[0].RaiseToTop(); // 1 2 0
2880
2881   TestLayoutItemOrder( controls, hboxLayout );
2882
2883   tet_infoline("LowerToBottom");
2884
2885   controls[2].LowerToBottom();  // 2 1 0
2886
2887   TestLayoutItemOrder( controls, hboxLayout );
2888
2889   tet_infoline("Remove / Add");
2890
2891   hbox.Remove( controls[2] );  // 1 0
2892   hbox.Add( controls[2] );     // 1 0 2
2893
2894   TestLayoutItemOrder( controls, hboxLayout );
2895
2896   tet_infoline("SetLayout");
2897
2898   auto vboxLayout = LinearLayout::New();
2899   DevelControl::SetLayout( controls[0], vboxLayout ); // 1 2 0(vbox)
2900
2901   TestLayoutItemOrder( controls, hboxLayout );
2902
2903   tet_infoline("Raise");
2904
2905   controls[0].Raise();  // 1 2 0(vbox)
2906
2907   TestLayoutItemOrder( controls, hboxLayout );
2908
2909   tet_infoline("Lower");
2910
2911   controls[2].Lower();   // 2 1 0(vbox)
2912
2913   TestLayoutItemOrder( controls, hboxLayout );
2914
2915   tet_infoline("SetLayout again");
2916
2917   auto vboxLayout1 = LinearLayout::New();
2918   DevelControl::SetLayout( controls[2], vboxLayout1 );  // 2 1(vbox1) 0(vbox)
2919
2920   TestLayoutItemOrder( controls, hboxLayout );
2921
2922   tet_infoline("SetLayout with empty handle");
2923
2924   DevelControl::SetLayout( controls[0], LayoutItem{} );  // 2 1(vbox1) 0
2925
2926   TestLayoutItemOrder( controls, hboxLayout );
2927
2928   tet_infoline("SetLayout to another control");
2929
2930   DevelControl::SetLayout( controls[2], vboxLayout1 );  // 2(vbox1) 1 0
2931
2932   TestLayoutItemOrder( controls, hboxLayout );
2933
2934   tet_infoline("SetLayout to change layout");
2935
2936   DevelControl::SetLayout( controls[2], vboxLayout1 );  // 2(vbox) 1 0
2937
2938   TestLayoutItemOrder( controls, hboxLayout );
2939
2940   END_TEST;
2941 }
2942
2943
2944 int UtcDaliLayouting_LayoutGroup01(void)
2945 {
2946   ToolkitTestApplication application;
2947   tet_infoline("UtcDaliLayouting_LayoutGroup01 - Test adding a control to a layout then adding a TextLabel to that control");
2948
2949   Control rootControl;
2950   SetupRootLayoutControl( rootControl );
2951
2952   // Create a parent layout
2953   auto hbox = Control::New();
2954   auto hboxLayout = LinearLayout::New();
2955   hbox.SetName( "HBox");
2956   rootControl.Add( hbox );
2957   DevelControl::SetLayout( hbox, hboxLayout );
2958   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
2959   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
2960   DevelControl::SetLayoutingRequired( hbox, true );
2961   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
2962
2963   tet_infoline("Add a control without SetLayout being called but with layout required set true");
2964
2965   auto control = Control::New();
2966   control.SetName("Control1");
2967   DevelControl::SetLayoutingRequired( control, true );
2968   hbox.Add( control );
2969   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2970   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
2971   tet_infoline("Add a Textlabel to the control");
2972   auto textLabel = TextLabel::New("Test text");
2973   textLabel.SetName("TextLabel");
2974
2975   control.Add( textLabel );
2976
2977   // Ensure layouting happens
2978   application.SendNotification();
2979   application.Render();
2980
2981   tet_infoline("Test text is it's natural size");
2982   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2983   tet_infoline("Test control is width of it's parent and height of it's child");
2984   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2985
2986   END_TEST;
2987 }
2988
2989 int UtcDaliLayouting_LayoutGroup02(void)
2990 {
2991   ToolkitTestApplication application;
2992   tet_infoline("UtcDaliLayouting_LayoutGroup02 - Test control is the size of it's largest child");
2993
2994   Control rootControl;
2995   SetupRootLayoutControl( rootControl );
2996
2997   // Create a parent layout
2998   auto hbox = Control::New();
2999   auto hboxLayout = LinearLayout::New();
3000   DevelControl::SetLayout( hbox, hboxLayout );
3001   hbox.SetName( "HBox");
3002   rootControl.Add( hbox );
3003   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3004   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3005   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3006
3007   tet_infoline("Add a control without SetLayout being called but with layout required set true");
3008
3009   auto control = Control::New();
3010   control.SetName("Control1");
3011   DevelControl::SetLayoutingRequired( control, true );
3012   hbox.Add( control );
3013   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3014   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3015
3016   tet_infoline("Add a Textlabel to the control");
3017   auto textLabel = TextLabel::New("Test text");
3018   textLabel.SetName("TextLabel");
3019   control.Add( textLabel );
3020
3021   tet_infoline("Add another  Textlabel to the control");
3022   auto largeTextLabel = TextLabel::New("Test large text");
3023   largeTextLabel.SetName("TextLabel-Large");
3024   control.Add( largeTextLabel );
3025
3026   // Ensure layouting happens
3027   application.SendNotification();
3028   application.Render();
3029
3030   tet_infoline("Test text is it's natural size");
3031   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3032   tet_infoline("Test text is centered in the control, the control is the size of the largest child");
3033   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3034
3035   tet_infoline("Test large text is it's natural size");
3036   DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3037   tet_infoline("Test text is aligned to start as is the size of the control");
3038   DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3039
3040   tet_infoline("Test control is width of it's parent and height of it's largest child");
3041   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3042
3043   END_TEST;
3044 }
3045
3046 int UtcDaliLayouting_LayoutGroup03(void)
3047 {
3048   ToolkitTestApplication application;
3049   tet_infoline("UtcDaliLayouting_LayoutGroup03 - Test control with a LayoutGroup as a leaf");
3050
3051   Control rootControl;
3052   SetupRootLayoutControl( rootControl );
3053
3054   // Create a parent layout
3055   auto hbox = Control::New();
3056   auto hboxLayout = LinearLayout::New();
3057   DevelControl::SetLayout( hbox, hboxLayout );
3058   hbox.SetName( "HBox");
3059   rootControl.Add( hbox );
3060   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3061   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3062   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3063
3064   tet_infoline("Add a control without SetLayout being called");
3065
3066   auto control = Control::New();
3067   control.SetName("Control1");
3068   hbox.Add( control );
3069   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3070   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  100 );
3071
3072   // Ensure layouting happens
3073   application.SendNotification();
3074   application.Render();
3075
3076   tet_infoline("Test control is width of it's parent and exact given height");
3077   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3078   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3079
3080   END_TEST;
3081 }
3082
3083
3084 int UtcDaliLayouting_LayoutGroup04(void)
3085 {
3086   ToolkitTestApplication application;
3087   tet_infoline("UtcDaliLayouting_LayoutGroup04 - Test control with a LayoutGroup as a leaf and with SetLayotRequired = true");
3088
3089   Control rootControl;
3090   SetupRootLayoutControl( rootControl );
3091
3092   // Create a parent layout
3093   auto hbox = Control::New();
3094   auto hboxLayout = LinearLayout::New();
3095   DevelControl::SetLayout( hbox, hboxLayout );
3096   hbox.SetName( "HBox");
3097   rootControl.Add( hbox );
3098   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3099   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3100   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3101
3102   tet_infoline("Add a control without SetLayout being called");
3103
3104   auto control = Control::New();
3105   control.SetName("Control1");
3106   DevelControl::SetLayoutingRequired( control, true );
3107   hbox.Add( control );
3108   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3109   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  100 );
3110
3111   // Ensure layouting happens
3112   application.SendNotification();
3113   application.Render();
3114
3115   tet_infoline("Test control is width of it's parent and exact given height");
3116   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3117   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3118
3119   END_TEST;
3120 }
3121
3122 int UtcDaliLayouting_IsLayoutingRequired(void)
3123 {
3124   ToolkitTestApplication application;
3125   tet_infoline("UtcDaliLayouting_IsLayoutingRequired - Test setting the SetLayoutRequired and then check if flag was set");
3126
3127   Control rootControl;
3128   SetupRootLayoutControl( rootControl );
3129
3130   // Create a parent layout
3131   auto hbox = Control::New();
3132   auto hboxLayout = LinearLayout::New();
3133   DevelControl::SetLayout( hbox, hboxLayout );
3134   hbox.SetName( "HBox");
3135   rootControl.Add( hbox );
3136   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3137   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3138   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3139
3140   tet_infoline("Add a control without SetLayout being called");
3141
3142   auto control = Control::New();
3143   control.SetName("Control1");
3144   DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), false, TEST_LOCATION );
3145   DevelControl::SetLayoutingRequired( control, true );
3146   hbox.Add( control );
3147   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3148   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  100 );
3149
3150   // Ensure layouting happens
3151   application.SendNotification();
3152   application.Render();
3153
3154   tet_infoline("Test control is width of it's parent and exact given height");
3155   DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), true, TEST_LOCATION );
3156
3157   END_TEST;
3158 }
3159
3160 int UtcDaliLayouting_LayoutGroupWithPadding01(void)
3161 {
3162   ToolkitTestApplication application;
3163   tet_infoline("UtcDaliLayouting_LayoutGroupWithPadding01 - Test adding a control to a layout that has padding");
3164
3165   Control rootControl;
3166   SetupRootLayoutControl( rootControl );
3167
3168   // Create a parent layout
3169   auto hbox = Control::New();
3170   auto hboxLayout = LinearLayout::New();
3171   hbox.SetName( "HBox");
3172   rootControl.Add( hbox );
3173   DevelControl::SetLayout( hbox, hboxLayout );
3174   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3175   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3176   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3177
3178   tet_infoline("Add a control without SetLayout being called");
3179
3180   auto control = Control::New();
3181   control.SetName("Control1");
3182   DevelControl::SetLayoutingRequired( control, true );
3183   hbox.Add( control );
3184   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3185   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3186
3187   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
3188   tet_printf( "Adding Padding to control");
3189   control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
3190
3191   tet_infoline("Add a Textlabel to the control");
3192   auto textLabel = TextLabel::New("Test text");
3193   textLabel.SetName("TextLabel");
3194   control.Add( textLabel );
3195
3196   // Ensure layouting happens
3197   application.SendNotification();
3198   application.Render();
3199
3200   tet_infoline("Test text is it's natural size");
3201   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3202   tet_infoline("Test control is size of it's child and control it's own padding");
3203   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 245.0f, 86.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3204
3205   END_TEST;
3206 }
3207
3208 int UtcDaliLayouting_LayoutGroupWithChildMargin01(void)
3209 {
3210   ToolkitTestApplication application;
3211   tet_infoline("UtcDaliLayouting_LayoutGroupWithChildMargin01 - Test adding a control with padding to a layout that has padding");
3212
3213   Control rootControl;
3214   SetupRootLayoutControl( rootControl );
3215
3216   // Create a parent layout
3217   auto hbox = Control::New();
3218   auto hboxLayout = LinearLayout::New();
3219   hbox.SetName( "HBox");
3220   rootControl.Add( hbox );
3221   DevelControl::SetLayout( hbox, hboxLayout );
3222   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3223   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3224   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3225
3226   tet_infoline("Add a control without SetLayout being called");
3227
3228   auto control = Control::New();
3229   control.SetName("Control1");
3230   DevelControl::SetLayoutingRequired( control, true );
3231   hbox.Add( control );
3232   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3233   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3234
3235   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
3236   tet_printf( "Adding Padding to control");
3237   control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
3238
3239   tet_infoline("Add a Textlabel to the control");
3240   auto textLabel = TextLabel::New("Test text");
3241   const Extents CHILD_MARGIN = Extents( 10, 0, 5, 0 );
3242   textLabel.SetProperty( Toolkit::Control::Property::MARGIN, CHILD_MARGIN );
3243   textLabel.SetName("TextLabel");
3244   control.Add( textLabel );
3245
3246   // Ensure layouting happens
3247   application.SendNotification();
3248   application.Render();
3249
3250   tet_infoline("Test text is it's natural size");
3251   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3252   tet_infoline("Test control is width of it's parent and height of it's child");
3253   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 255.0f, 91.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3254
3255   END_TEST;
3256 }
3257
3258 int UtcDaliLayouting_SetLayout(void)
3259 {
3260   ToolkitTestApplication application;
3261   tet_infoline(" UtcDaliLayouting_SetLayout - Test reusing layouts");
3262
3263   Control rootControl;
3264   SetupRootLayoutControl( rootControl );
3265
3266   auto container = Control::New();
3267   auto horizontalLayout = LinearLayout::New();
3268   horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
3269   DevelControl::SetLayout( container, horizontalLayout );
3270   container.SetName( "Container" );
3271   rootControl.Add( container );
3272
3273   std::vector< Control > controls;
3274   controls.push_back( CreateLeafControl( 40, 40 ) );
3275   controls.push_back( CreateLeafControl( 60, 60 ) );
3276
3277   for( auto&& iter : controls )
3278   {
3279     container.Add( iter );
3280   }
3281
3282   container.SetParentOrigin( ParentOrigin::CENTER );
3283   container.SetAnchorPoint( AnchorPoint::CENTER );
3284
3285   // Ensure layouting happens
3286   application.SendNotification();
3287   application.Render();
3288
3289   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3290   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3291   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3292
3293   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3294   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3295   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3296
3297   // Change a layout
3298   auto verticalLayout = LinearLayout::New();
3299   verticalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
3300   DevelControl::SetLayout( container, verticalLayout );
3301
3302   application.SendNotification();
3303   application.Render();
3304
3305   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3306   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3307   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3308
3309   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3310   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3311   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3312
3313   // Second round
3314   DevelControl::SetLayout( container, horizontalLayout );
3315
3316   application.SendNotification();
3317   application.Render();
3318
3319   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3320   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3321   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3322
3323   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3324   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3325   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3326
3327   // Change a layout
3328   DevelControl::SetLayout( container, verticalLayout );
3329
3330   application.SendNotification();
3331   application.Render();
3332
3333   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3334   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3335   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3336
3337   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3338   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3339   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3340
3341   END_TEST;
3342 }
3343
3344 int UtcDaliLayouting_StageAdd(void)
3345 {
3346   ToolkitTestApplication application;
3347   tet_infoline(" UtcDaliLayouting_StageAdd");
3348
3349   Stage stage = Stage::GetCurrent();
3350
3351   AbsoluteLayout absoluteLayout = AbsoluteLayout::New();
3352   Control container = Control::New();
3353   container.SetName( "Container" );
3354   DevelControl::SetLayout( container, absoluteLayout );
3355   container.SetAnchorPoint( Dali::AnchorPoint::CENTER );
3356   container.SetParentOrigin( Dali::ParentOrigin::CENTER );
3357
3358   Control child = Control::New();
3359   child.SetAnchorPoint( Dali::AnchorPoint::TOP_LEFT );
3360   child.SetPosition( 0.0f, 0.0f );
3361   child.SetSize( 480.0f, 180.0f );
3362   child.SetName( "Child Control" );
3363   container.Add( child );
3364
3365   // Ensure layouting happens
3366   application.SendNotification();
3367   application.Render();
3368
3369   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3370   DALI_TEST_EQUALS( child.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3371
3372   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); // Not re-laid out
3373   DALI_TEST_EQUALS( child.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3374
3375   application.SendNotification();
3376   application.Render();
3377
3378   // Add container to stage here
3379   // Should call RequestLayout() to measure and layout
3380   stage.Add( container );
3381
3382   application.SendNotification();
3383   application.Render();
3384
3385   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3386   DALI_TEST_EQUALS( child.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3387
3388   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); // Stage Size
3389   DALI_TEST_EQUALS( child.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3390
3391   END_TEST;
3392 }