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