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