0806353abefd9f23d67f39aec01a8be8f574fc55
[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 void TestLayoutItemOrder( std::vector< Control >& controls, LayoutGroup& layoutGroup )
39 {
40   for( auto&& iter : controls )
41   {
42     unsigned int siblingOrder = static_cast< unsigned int>( iter.GetProperty< int >( DevelActor::Property::SIBLING_ORDER ) );
43     DALI_TEST_EQUALS( layoutGroup.GetChildAt( siblingOrder ), DevelControl::GetLayout( iter ), TEST_LOCATION );
44   }
45 }
46
47 void utc_dali_toolkit_layouting_startup(void)
48 {
49   test_return_value = TET_UNDEF;
50 }
51
52 void utc_dali_toolkit_layouting_cleanup(void)
53 {
54   test_return_value = TET_PASS;
55 }
56
57 int UtcDaliLayouting_HboxLayout01(void)
58 {
59   ToolkitTestApplication application;
60   tet_infoline(" UtcDaliLayouting_HboxLayout01");
61
62   Stage stage = Stage::GetCurrent();
63   auto hbox = Control::New();
64   auto hboxLayout = LinearLayout::New();
65   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
66   DevelControl::SetLayout( hbox, hboxLayout );
67   hbox.SetName( "HBox");
68
69   std::vector< Control > controls;
70   controls.push_back( CreateLeafControl( 40, 40 ) );
71   controls.push_back( CreateLeafControl( 60, 40 ) );
72   controls.push_back( CreateLeafControl( 80, 40 ) );
73   controls.push_back( CreateLeafControl( 100, 40 ) );
74
75   for( auto&& iter : controls )
76   {
77     hbox.Add( iter );
78   }
79
80   hbox.SetParentOrigin( ParentOrigin::CENTER );
81   hbox.SetAnchorPoint( AnchorPoint::CENTER );
82   stage.Add( hbox );
83
84   // Ensure layouting happens
85   application.SendNotification();
86   application.Render();
87
88   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
89   // hbox left justifies elements
90   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
91   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
92   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
93   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
94
95   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
96   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
97   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
98   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
99
100   // Change a layout
101   auto newHBoxLayout = LinearLayout::New();
102   newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
103   DevelControl::SetLayout( hbox, newHBoxLayout );
104
105   application.SendNotification();
106   application.Render();
107
108   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
109   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
110   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
111   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
112
113   END_TEST;
114 }
115
116 int UtcDaliLayouting_HboxLayout02(void)
117 {
118   ToolkitTestApplication application;
119   tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
120
121   Stage stage = Stage::GetCurrent();
122
123   auto hbox1 = Control::New();
124   auto hboxLayout1 = LinearLayout::New();
125   DevelControl::SetLayout( hbox1, hboxLayout1 );
126
127   auto hbox2 = Control::New();
128   auto hboxLayout2 = LinearLayout::New();
129   DevelControl::SetLayout( hbox2, hboxLayout2 );
130
131   hbox1.SetName( "HBox1");
132   hbox2.SetName( "HBox2");
133
134   std::vector< Control > controls;
135   controls.push_back( CreateLeafControl( 20, 40 ) );
136   controls.push_back( CreateLeafControl( 30, 50 ) );
137   controls.push_back( CreateLeafControl( 40, 60 ) );
138   controls.push_back( CreateLeafControl( 50, 70 ) );
139
140   controls.push_back( CreateLeafControl( 25, 40 ) );
141   controls.push_back( CreateLeafControl( 35, 50 ) );
142   controls.push_back( CreateLeafControl( 45, 60 ) );
143   controls.push_back( CreateLeafControl( 55, 70 ) );
144
145   int counter=0;
146   for( auto&& iter : controls )
147   {
148     if( counter < 4 )
149     {
150       hbox1.Add( iter );
151     }
152     else
153     {
154       hbox2.Add( iter );
155     }
156     ++counter;
157   }
158   hbox1.SetParentOrigin( ParentOrigin::CENTER );
159   hbox1.SetAnchorPoint( AnchorPoint::CENTER );
160   hbox2.SetParentOrigin( ParentOrigin::CENTER );
161   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
162
163   auto hbox3 = Control::New();
164   auto hboxLayout3 = LinearLayout::New();
165   DevelControl::SetLayout( hbox3, hboxLayout3 );
166
167   hbox3.SetParentOrigin( ParentOrigin::CENTER );
168   hbox3.SetName( "HBox3");
169   hbox3.Add( hbox1 );
170   hbox3.Add( hbox2 );
171
172   stage.Add( hbox3 );
173
174   // Ensure layouting happens
175   application.SendNotification();
176   application.Render();
177
178
179   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
180   // hbox left justifies elements
181   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
182   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
183   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,  5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
184   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,  0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
185
186   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
187   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
188   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
189   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
190
191
192   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
193   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
194   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f,  5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
195   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,  0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
196
197   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
198   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
199   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
200   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
201
202   // Test hbox1 and 2 are sized to wrap their content
203   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
204   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
205   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
206   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
207
208   // Test hbox3 matches parent (root layer)
209   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
210   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
211
212   END_TEST;
213 }
214
215
216 int UtcDaliLayouting_HboxLayout03(void)
217 {
218   ToolkitTestApplication application;
219   tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
220
221   Stage stage = Stage::GetCurrent();
222
223   auto hbox1 = Control::New();
224   auto hboxLayout1 = LinearLayout::New();
225   DevelControl::SetLayout( hbox1, hboxLayout1 );
226
227   auto hbox2 = Control::New();
228   auto hboxLayout2 = LinearLayout::New();
229   DevelControl::SetLayout( hbox2, hboxLayout2 );
230
231   hbox1.SetName( "HBox1");
232   hbox2.SetName( "HBox2");
233   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
234   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
235   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
236   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
237
238   std::vector< Control > controls;
239   controls.push_back( CreateLeafControl( 20, 40 ) );
240   controls.push_back( CreateLeafControl( 30, 50 ) );
241   controls.push_back( CreateLeafControl( 40, 60 ) );
242   controls.push_back( CreateLeafControl( 50, 70 ) );
243
244   controls.push_back( CreateLeafControl( 25, 40 ) );
245   controls.push_back( CreateLeafControl( 35, 50 ) );
246   controls.push_back( CreateLeafControl( 45, 60 ) );
247   controls.push_back( CreateLeafControl( 55, 70 ) );
248
249   int counter=0;
250   for( auto&& iter : controls )
251   {
252     if( counter < 4 )
253     {
254       hbox1.Add( iter );
255     }
256     else
257     {
258       hbox2.Add( iter );
259     }
260     ++counter;
261   }
262   hbox1.SetParentOrigin( ParentOrigin::CENTER );
263   hbox1.SetAnchorPoint( AnchorPoint::CENTER );
264   hbox2.SetParentOrigin( ParentOrigin::CENTER );
265   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
266
267   auto hbox3 = Control::New();
268   auto hboxLayout3 = LinearLayout::New();
269   DevelControl::SetLayout( hbox3, hboxLayout3);
270
271   hbox3.SetParentOrigin( ParentOrigin::CENTER );
272   hbox3.SetName( "HBox3");
273   hbox3.Add( hbox1 );
274   hbox3.Add( hbox2 );
275
276   stage.Add( hbox3 );
277
278   //std::ostringstream oss;
279   //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
280   //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
281
282   // Ensure layouting happens
283   application.SendNotification();
284   application.Render();
285
286
287   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
288   // hbox left justifies elements
289   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
290   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
291   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
292   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
293
294   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
295   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
296   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
297   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
298
299   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
300   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
301   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
302   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
303
304   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
305   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
306   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
307   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
308
309   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
310   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
311   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
312   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
313
314   // Test hbox3 matches parent (root layer)
315   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
316   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
317
318   END_TEST;
319 }
320
321 int UtcDaliLayouting_HboxLayout04(void)
322 {
323   ToolkitTestApplication application;
324   tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
325
326   Stage stage = Stage::GetCurrent();
327
328   auto hbox1 = Control::New();
329   auto hboxLayout1 = LinearLayout::New();
330   DevelControl::SetLayout( hbox1, hboxLayout1 );
331
332   auto hbox2 = Control::New();
333   auto hboxLayout2 = LinearLayout::New();
334   DevelControl::SetLayout( hbox2, hboxLayout2 );
335
336   hbox1.SetName( "HBox1"); // Default spec is to wrap content
337   hbox2.SetName( "HBox2");
338   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
339   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
340   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
341   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
342
343   std::vector< Control > controls;
344   controls.push_back( CreateLeafControl( 80, 40 ) );
345   controls.push_back( CreateLeafControl( 80, 50 ) );
346   controls.push_back( CreateLeafControl( 80, 60 ) );
347   controls.push_back( CreateLeafControl( 80, 70 ) );
348
349   controls.push_back( CreateLeafControl( 80, 40 ) );
350   controls.push_back( CreateLeafControl( 80, 50 ) );
351   controls.push_back( CreateLeafControl( 80, 60 ) );
352   controls.push_back( CreateLeafControl( 80, 70 ) );
353
354   int counter=0;
355   for( auto&& iter : controls )
356   {
357     if( counter < 4 )
358     {
359       hbox1.Add( iter );
360     }
361     else
362     {
363       hbox2.Add( iter );
364     }
365     ++counter;
366   }
367
368   controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
369   auto hbox3 = Control::New();
370   auto hboxLayout3 = LinearLayout::New();
371   DevelControl::SetLayout( hbox3, hboxLayout3 );
372
373   hbox3.SetParentOrigin( ParentOrigin::CENTER );
374   hbox3.SetName( "HBox3");
375   hbox3.Add( hbox1 );
376   hbox3.Add( hbox2 );
377   stage.Add( hbox3 );
378
379   //std::ostringstream oss;
380   //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
381   //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
382
383   // Ensure layouting happens
384   application.SendNotification();
385   application.Render();
386
387
388   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
389   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
390   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
391   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
392
393   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
394   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
395   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
396   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
397
398   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
399   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
400   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
401   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
402
403   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
404   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
405   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
406   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
407
408   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
409   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
410   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
411   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
412
413
414   // Test hbox3 matches parent (root layer)
415   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
416   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
417
418   END_TEST;
419 }
420
421 int UtcDaliLayouting_HboxLayout05(void)
422 {
423   ToolkitTestApplication application;
424   tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
425
426   Stage stage = Stage::GetCurrent();
427   auto hbox = Control::New();
428   auto hboxLayout = LinearLayout::New();
429   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
430   DevelControl::SetLayout( hbox, hboxLayout );
431   hbox.SetName( "HBox");
432
433   std::vector< Control > controls;
434   controls.push_back( CreateLeafControl( 40, 40 ) );
435   controls.push_back( CreateLeafControl( 60, 40 ) );
436   controls.push_back( CreateLeafControl( 80, 40 ) );
437   controls.push_back( CreateLeafControl( 100, 40 ) );
438
439   for( auto&& iter : controls )
440   {
441     hbox.Add( iter );
442     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
443     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
444   }
445
446   hbox.SetParentOrigin( ParentOrigin::CENTER );
447   hbox.SetAnchorPoint( AnchorPoint::CENTER );
448   stage.Add( hbox );
449
450   // Ensure layouting happens
451   application.SendNotification();
452   application.Render();
453
454   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
455   // hbox left justifies elements
456   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
457   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
458   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
459   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
460
461   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
462   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
463   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
464   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
465
466   END_TEST;
467 }
468
469 int UtcDaliLayouting_HboxLayout06(void)
470 {
471   ToolkitTestApplication application;
472   tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
473
474   Stage stage = Stage::GetCurrent();
475
476   auto rootControl = Control::New();
477   auto absoluteLayout = AbsoluteLayout::New();
478   DevelControl::SetLayout( rootControl, absoluteLayout );
479   rootControl.SetName( "AbsoluteLayout" );
480   stage.Add( rootControl );
481
482   auto hbox = Control::New();
483   auto hboxLayout = LinearLayout::New();
484   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
485   DevelControl::SetLayout( hbox, hboxLayout );
486   hbox.SetName( "HBox" );
487
488   std::vector< Control > controls;
489   controls.push_back( CreateLeafControl( 40, 40 ) );
490   controls.push_back( CreateLeafControl( 60, 40 ) );
491
492   for( auto&& iter : controls )
493   {
494     hbox.Add( iter );
495   }
496   hbox.SetParentOrigin( ParentOrigin::CENTER );
497   hbox.SetAnchorPoint( AnchorPoint::CENTER );
498   rootControl.Add( hbox );
499
500   // Ensure layouting happens
501   application.SendNotification();
502   application.Render();
503
504   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
505   // hbox left justifies elements
506   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
507   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
508
509   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
510   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
511
512   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
513
514   // Change a layout
515   auto newHBoxLayout = LinearLayout::New();
516   newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
517   DevelControl::SetLayout( hbox, newHBoxLayout );
518
519   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
520   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
521
522   application.SendNotification();
523   application.Render();
524
525   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
526
527   // Change size specification
528   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
529   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
530
531   application.SendNotification();
532   application.Render();
533
534   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
535
536   // Use WRAP_CONTENT again
537   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
538   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
539
540   application.SendNotification();
541   application.Render();
542
543   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
544
545   END_TEST;
546 }
547
548 int UtcDaliLayouting_HboxLayout07(void)
549 {
550   ToolkitTestApplication application;
551   tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
552
553   Stage stage = Stage::GetCurrent();
554   auto hbox = Control::New();
555   auto hboxLayout = LinearLayout::New();
556   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
557   DevelControl::SetLayout( hbox, hboxLayout );
558   hbox.SetName( "HBox");
559
560   std::vector< Control > controls;
561   controls.push_back( CreateLeafControl( 40, 40 ) );
562   controls.push_back( CreateLeafControl( 60, 40 ) );
563   controls.push_back( CreateLeafControl( 80, 40 ) );
564   controls.push_back( CreateLeafControl( 100, 40 ) );
565
566   for( auto&& iter : controls )
567   {
568     hbox.Add( iter );
569   }
570   hbox.SetParentOrigin( ParentOrigin::CENTER );
571   hbox.SetAnchorPoint( AnchorPoint::CENTER );
572   stage.Add( hbox );
573
574   hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
575
576   // Ensure layouting happens
577   application.SendNotification();
578   application.Render();
579
580   // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
581   // hbox left justifies elements
582   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
583   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
584   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
585   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
586
587   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
588   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
589   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
590   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
591
592   hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
593
594   // Ensure layouting happens
595   application.SendNotification();
596   application.Render();
597
598   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
599   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
600   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
601   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.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   END_TEST;
609 }
610
611 int UtcDaliLayouting_HboxLayout08(void)
612 {
613   ToolkitTestApplication application;
614   tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation");
615
616   Stage stage = Stage::GetCurrent();
617
618   auto rootControl = Control::New();
619   auto absoluteLayout = AbsoluteLayout::New();
620   absoluteLayout.SetAnimateLayout( true );
621   DevelControl::SetLayout( rootControl, absoluteLayout );
622   rootControl.SetName( "AbsoluteLayout" );
623   stage.Add( rootControl );
624
625   Control control1 = CreateLeafControl( 40, 40 );
626   rootControl.Add( control1 );
627   auto hbox = Control::New();
628   auto hboxLayout = LinearLayout::New();
629   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
630   DevelControl::SetLayout( hbox, hboxLayout );
631   hbox.SetName( "HBox" );
632
633   Control control2 = CreateLeafControl( 40, 40 );
634   hbox.Add( control2 );
635
636   hbox.SetParentOrigin( ParentOrigin::CENTER );
637   hbox.SetAnchorPoint( AnchorPoint::CENTER );
638   rootControl.Add( hbox );
639
640   DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION );
641   DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION );
642   DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION );
643   DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION );
644
645   hboxLayout.SetAnimateLayout( true );
646   absoluteLayout.SetAnimateLayout( false );
647
648   DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION );
649   DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION );
650   DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION );
651   DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION );
652
653   END_TEST;
654 }
655
656 int UtcDaliLayouting_HboxLayout09(void)
657 {
658   ToolkitTestApplication application;
659   tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set alignment");
660
661   Stage stage = Stage::GetCurrent();
662   auto hbox = Control::New();
663   auto hboxLayout = LinearLayout::New();
664   DevelControl::SetLayout( hbox, hboxLayout );
665   hbox.SetName( "HBox");
666
667   std::vector< Control > controls;
668   controls.push_back( CreateLeafControl( 40, 40 ) );
669   controls.push_back( CreateLeafControl( 60, 60 ) );
670
671   for( auto&& iter : controls )
672   {
673     hbox.Add( iter );
674   }
675   hbox.SetParentOrigin( ParentOrigin::CENTER );
676   hbox.SetAnchorPoint( AnchorPoint::CENTER );
677   stage.Add( hbox );
678
679   // Check default orientation
680   DALI_TEST_EQUALS( static_cast<unsigned int>( hboxLayout.GetOrientation() ), static_cast<unsigned int>( LinearLayout::Orientation::HORIZONTAL ), TEST_LOCATION );
681   // Check default alignment
682   DALI_TEST_EQUALS( hboxLayout.GetAlignment(), ( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL ), TEST_LOCATION );
683
684   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN );
685
686   // Ensure layouting happens
687   application.SendNotification();
688   application.Render();
689
690   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
691   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
692
693   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
694   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
695
696   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END );
697
698   // Ensure layouting happens
699   application.SendNotification();
700   application.Render();
701
702   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
703   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
704
705   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
706   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
707
708   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
709
710   // Ensure layouting happens
711   application.SendNotification();
712   application.Render();
713
714   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
715   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
716
717   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
718   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
719
720   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP );
721
722   // Ensure layouting happens
723   application.SendNotification();
724   application.Render();
725
726   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
727   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
728
729   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
730   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
731
732   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP );
733
734   // Ensure layouting happens
735   application.SendNotification();
736   application.Render();
737
738   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
739   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
740
741   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
742   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
743
744   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP );
745
746   // Ensure layouting happens
747   application.SendNotification();
748   application.Render();
749
750   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
751   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
752
753   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
754   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
755
756   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
757
758   // Ensure layouting happens
759   application.SendNotification();
760   application.Render();
761
762   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
763   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
764
765   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
766   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
767
768   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
769
770   // Ensure layouting happens
771   application.SendNotification();
772   application.Render();
773
774   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
775   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
776
777   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
778   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
779
780   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
781
782   // Ensure layouting happens
783   application.SendNotification();
784   application.Render();
785
786   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
787   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
788
789   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
790   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
791
792   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL );
793
794   // Ensure layouting happens
795   application.SendNotification();
796   application.Render();
797
798   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
799   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
800
801   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
802   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
803
804   hboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
805   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN );
806
807   // Ensure layouting happens
808   application.SendNotification();
809   application.Render();
810
811   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
812   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
813
814   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
815   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
816
817   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END );
818
819   // Ensure layouting happens
820   application.SendNotification();
821   application.Render();
822
823   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
824   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
825
826   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
827   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
828
829   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
830
831   // Ensure layouting happens
832   application.SendNotification();
833   application.Render();
834
835   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
836   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
837
838   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
839   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
840
841   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP );
842
843   // Ensure layouting happens
844   application.SendNotification();
845   application.Render();
846
847   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
848   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
849
850   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
851   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
852
853   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP );
854
855   // Ensure layouting happens
856   application.SendNotification();
857   application.Render();
858
859   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
860   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
861
862   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
863   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
864
865   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP );
866
867   // Ensure layouting happens
868   application.SendNotification();
869   application.Render();
870
871   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
872   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
873
874   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
875   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
876
877   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
878
879   // Ensure layouting happens
880   application.SendNotification();
881   application.Render();
882
883   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
884   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
885
886   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
887   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
888
889   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
890
891   // Ensure layouting happens
892   application.SendNotification();
893   application.Render();
894
895   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
896   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
897
898   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
899   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
900
901   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
902
903   // Ensure layouting happens
904   application.SendNotification();
905   application.Render();
906
907   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
908   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
909
910   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
911   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
912
913   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL );
914
915   // Ensure layouting happens
916   application.SendNotification();
917   application.Render();
918
919   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
920   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
921
922   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
923   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
924
925   END_TEST;
926 }
927
928 namespace
929 {
930 const char* TEST_IMAGE_FILE_NAME =  TEST_RESOURCE_DIR  "/broken.png";
931 }
932
933 int UtcDaliLayouting_HboxLayout_ImageView(void)
934 {
935   ToolkitTestApplication application;
936   tet_infoline(" UtcDaliLayouting_HboxLayout - Use image view for leaf");
937
938   Stage stage = Stage::GetCurrent();
939   auto hbox = Control::New();
940   auto hboxLayout = LinearLayout::New();
941   DevelControl::SetLayout( hbox, hboxLayout );
942   hbox.SetName( "HBox" );
943
944   std::string url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 100, 100 ) );
945   ImageView imageView = CreateImageView( url, ImageDimensions() );
946
947   hbox.SetParentOrigin( ParentOrigin::CENTER );
948   hbox.SetAnchorPoint( AnchorPoint::CENTER );
949   hbox.Add( imageView );
950   stage.Add( hbox );
951
952   // Ensure layouting happens
953   application.SendNotification();
954   application.Render();
955
956   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
957   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
958
959   url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 200, 200 ) );
960   imageView.SetImage( url );
961
962   // Ensure layouting happenss
963   application.SendNotification();
964   application.Render();
965
966   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
967   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
968
969   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
970   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
971
972   // Ensure layouting happenss
973   application.SendNotification();
974   application.Render();
975
976   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
977   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
978
979   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
980   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
981
982   // Ensure layouting happenss
983   application.SendNotification();
984   application.Render();
985
986   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
987   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
988
989   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
990   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
991
992   Image image = FrameBufferImage::New( 50, 50, Pixel::RGBA8888 );
993   imageView.SetImage( image );
994
995   // Ensure layouting happenss
996   application.SendNotification();
997   application.Render();
998
999   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1000   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1001
1002   Property::Map imagePropertyMap;
1003   imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1004   imagePropertyMap[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
1005   imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 150;
1006   imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 150;
1007   imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap );
1008
1009   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1010   // Ensure layouting happenss
1011   application.SendNotification();
1012   application.Render();
1013
1014   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 325.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1015   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1016
1017   END_TEST;
1018 }
1019
1020 int UtcDaliLayouting_HboxLayout_TextLabel(void)
1021 {
1022   ToolkitTestApplication application;
1023   tet_infoline(" UtcDaliLayouting_HboxLayout - Use text label for leaf");
1024
1025   Stage stage = Stage::GetCurrent();
1026
1027   auto hbox = Control::New();
1028   auto hboxLayout = LinearLayout::New();
1029   DevelControl::SetLayout( hbox, hboxLayout );
1030   hbox.SetName( "HBox" );
1031   hbox.SetParentOrigin( ParentOrigin::CENTER );
1032   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1033
1034   std::vector< Control > controls;
1035   TextLabel textLabel = CreateTextLabel( "W" );
1036   controls.push_back( textLabel );
1037   hbox.Add( textLabel );
1038   stage.Add( hbox );
1039
1040   // Ensure layouting happens
1041   application.SendNotification();
1042   application.Render();
1043
1044   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1045   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 54.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1046
1047   textLabel.SetProperty( TextLabel::Property::TEXT, "WWWW" );
1048
1049   // Ensure layouting happens
1050   application.SendNotification();
1051   application.Render();
1052
1053   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1054   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 216.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1055
1056   textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
1057
1058   // Ensure layouting happens
1059   application.SendNotification();
1060   application.Render();
1061
1062   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1063   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1064
1065   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1066   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1067
1068   // Ensure layouting happens
1069   application.SendNotification();
1070   application.Render();
1071
1072   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1073   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1074
1075   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1076   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1077
1078   // Ensure layouting happens
1079   application.SendNotification();
1080   application.Render();
1081
1082   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1083   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1084
1085   END_TEST;
1086 }
1087
1088 // Padding tests
1089
1090 int UtcDaliLayouting_HboxLayout_Padding01(void)
1091 {
1092   ToolkitTestApplication application;
1093   tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
1094
1095   Stage stage = Stage::GetCurrent();
1096   auto hbox = Control::New();
1097   auto hboxLayout = LinearLayout::New();
1098   DevelControl::SetLayout( hbox, hboxLayout );
1099   hbox.SetName( "HBox");
1100
1101   std::vector< Control > controls;
1102   controls.push_back( CreateLeafControl( 40, 40 ) );
1103   controls.push_back( CreateLeafControl( 60, 40 ) );
1104   controls.push_back( CreateLeafControl( 80, 40 ) );
1105   controls.push_back( CreateLeafControl( 100, 40 ) );
1106
1107   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1108   tet_printf( "\nAdding Padding to control at index %u \n", 1 );
1109   controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1110
1111   for( auto&& iter : controls )
1112   {
1113     hbox.Add( iter );
1114   }
1115   hbox.SetParentOrigin( ParentOrigin::CENTER );
1116   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1117   stage.Add( hbox );
1118
1119   // Ensure layouting happens
1120   application.SendNotification();
1121   application.Render();
1122
1123   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1124   // hbox left justifies elements
1125   tet_infoline("Test Child Actor Position");
1126   float xPositionOfControlBeingTested = 0.0f;
1127   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1128                                                                                             380.0f,
1129                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1130   xPositionOfControlBeingTested += 40.0f;
1131
1132   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1133                                                                                             380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
1134                                                                                             0.0001f, TEST_LOCATION );
1135
1136   xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1137   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1138
1139   xPositionOfControlBeingTested += 80.0f;
1140   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1141
1142   tet_infoline("Test Child Actor Size");
1143   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1144
1145   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1146                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
1147                                                                                         0.0001f, TEST_LOCATION );
1148
1149   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1150   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1151
1152   END_TEST;
1153 }
1154
1155 int UtcDaliLayouting_HboxLayout_Padding02(void)
1156 {
1157   ToolkitTestApplication application;
1158   tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
1159
1160   Stage stage = Stage::GetCurrent();
1161   auto hbox = Control::New();
1162   auto hboxLayout = LinearLayout::New();
1163   DevelControl::SetLayout( hbox, hboxLayout );
1164   hbox.SetName( "HBox");
1165
1166   std::vector< Control > controls;
1167   controls.push_back( CreateLeafControl( 40, 40 ) );
1168   controls.push_back( CreateLeafControl( 60, 40 ) );
1169   controls.push_back( CreateLeafControl( 80, 40 ) );
1170   controls.push_back( CreateLeafControl( 100, 40 ) );
1171
1172   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1173
1174   for( auto&& iter : controls )
1175   {
1176     iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1177     hbox.Add( iter );
1178   }
1179   hbox.SetParentOrigin( ParentOrigin::CENTER );
1180   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1181   stage.Add( hbox );
1182
1183   // Ensure layouting happens
1184   application.SendNotification();
1185   application.Render();
1186
1187   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1188   // hbox left justifies elements
1189   tet_infoline("Test Child Actor Position");
1190   float xPositionOfControlBeingTested = 0.0f;
1191   float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
1192
1193   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1194                                                                                             yPositionOfControlBeingTested,
1195                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1196   xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1197
1198   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1199                                                                                             yPositionOfControlBeingTested,
1200                                                                                             0.0f ),
1201                                                                                             0.0001f, TEST_LOCATION );
1202
1203   xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1204   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1205                                                                                             yPositionOfControlBeingTested,
1206                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1207
1208   xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1209   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1210                                                                                             yPositionOfControlBeingTested,
1211                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1212
1213   tet_infoline("Test Child Actor Size");
1214   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1215                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1216                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
1217
1218   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1219                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1220                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
1221
1222   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
1223                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1224                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
1225
1226   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1227                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1228                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
1229
1230   END_TEST;
1231 }
1232
1233
1234 int UtcDaliLayouting_HboxLayout_Padding03(void)
1235 {
1236   ToolkitTestApplication application;
1237   tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
1238
1239   Stage stage = Stage::GetCurrent();
1240   auto hbox = Control::New();
1241   auto hboxLayout = LinearLayout::New();
1242   DevelControl::SetLayout( hbox, hboxLayout );
1243   hbox.SetName( "HBox");
1244
1245   std::vector< Control > controls;
1246   controls.push_back( CreateLeafControl( 40, 40 ) );
1247   controls.push_back( CreateLeafControl( 40, 40 ) );
1248   controls.push_back( CreateLeafControl( 40, 40 ) );
1249
1250   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1251   tet_printf( "\nAdding Padding to control at index 1 \n" );
1252   controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1253
1254   for( auto&& iter : controls )
1255   {
1256     hbox.Add( iter );
1257   }
1258   hbox.SetParentOrigin( ParentOrigin::CENTER );
1259   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1260   stage.Add( hbox );
1261
1262   // Ensure layouting happens
1263   application.SendNotification();
1264   application.Render();
1265
1266   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1267   // hbox left justifies elements
1268   tet_infoline("Test Child Actor Position");
1269   float xPositionOfControlBeingTested = 0.0f;
1270   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1271                                                                                             380.0f,
1272                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1273   xPositionOfControlBeingTested += 40.0f;
1274
1275   DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1276                                                                                             380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
1277                                                                                             0.0001f, TEST_LOCATION );
1278
1279   xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1280   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1281
1282   const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
1283   tet_printf( "\nChanging Padding to control at index 1 \n" );
1284   controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
1285
1286   // Ensure layouting happens
1287   application.SendNotification();
1288   application.Render();
1289
1290   xPositionOfControlBeingTested = 0.0f; // reset
1291
1292   tet_infoline("Test Child Actor Position");
1293   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1294                                                                                             380.0f,
1295                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1296   xPositionOfControlBeingTested += 40.0f;
1297
1298   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1299                                                                                             380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
1300                                                                                             0.0001f, TEST_LOCATION );
1301
1302   xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
1303   tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
1304   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1305
1306   tet_infoline("Test Child Actor Size");
1307   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1308
1309   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
1310                                                                                         40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
1311                                                                                         0.0001f, TEST_LOCATION );
1312
1313   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1314
1315   END_TEST;
1316 }
1317
1318 int UtcDaliLayouting_HboxLayout_Padding04(void)
1319 {
1320   ToolkitTestApplication application;
1321   tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
1322
1323   // Adding padding to the layout should offset the positioning of the children.
1324
1325   const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1326   const Size CONTROL_SIZE = Size( 40, 40 );
1327
1328   Stage stage = Stage::GetCurrent();
1329   // Create a root layout, ideally Dali would have a default layout in the root layer.
1330   // Without this root layer the LinearLayout (or any other layout) will not
1331   // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1332   // It uses the default stage size and ideally should have a layout added to it.
1333   auto rootLayoutControl = Control::New();
1334   rootLayoutControl.SetName( "AbsoluteLayout");
1335   auto rootLayout = AbsoluteLayout::New();
1336   DevelControl::SetLayout( rootLayoutControl, rootLayout );
1337   rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1338   rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1339   stage.Add( rootLayoutControl );
1340
1341   auto hbox = Control::New();
1342   auto hboxLayout = LinearLayout::New();
1343   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1344   DevelControl::SetLayout( hbox, hboxLayout );
1345   hbox.SetName( "HBox");
1346   hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1347   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1348   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1349
1350   std::vector< Control > controls;
1351   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1352   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1353   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1354   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1355
1356   for( auto&& iter : controls )
1357   {
1358     hbox.Add( iter );
1359   }
1360
1361   hbox.SetParentOrigin( ParentOrigin::CENTER );
1362   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1363   rootLayoutControl.Add( hbox );
1364
1365   // Ensure layouting happens
1366   application.SendNotification();
1367   application.Render();
1368
1369   // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1370   application.SendNotification();
1371
1372   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1373   // hbox left justifies elements
1374   tet_infoline("Test Child Actor Position");
1375
1376   auto controlXPosition=0.0f;
1377
1378   controlXPosition = LAYOUT_PADDING.start;  // First child positioned at offset defined by the padding
1379   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1380                                                                                             LAYOUT_PADDING.top,
1381                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1382
1383   controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1384   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1385                                                                                             LAYOUT_PADDING.top,
1386                                                                                             0.0f ),
1387                                                                                             0.0001f, TEST_LOCATION );
1388
1389   controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1390   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1391                                                                                             LAYOUT_PADDING.top,
1392                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1393
1394   controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1395   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1396                                                                                             LAYOUT_PADDING.top,
1397                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1398
1399   auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1400   auto totalControlsHeight = CONTROL_SIZE.height;
1401
1402   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1403                                                                                  totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1404                                                                                  0.0f ), 0.0001f, TEST_LOCATION );
1405
1406
1407   END_TEST;
1408 }
1409
1410 int UtcDaliLayouting_HboxLayout_Padding05(void)
1411 {
1412   ToolkitTestApplication application;
1413   tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
1414
1415   // Adding padding to the layout should offset the positioning of the children.
1416
1417   const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1418   const Size CONTROL_SIZE = Size( 40, 40 );
1419
1420   Stage stage = Stage::GetCurrent();
1421   // Create a root layout, ideally Dali would have a default layout in the root layer.
1422   // Without this root layer the LinearLayout (or any other layout) will not
1423   // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1424   // It uses the default stage size and ideally should have a layout added to it.
1425   auto rootLayoutControl = Control::New();
1426   rootLayoutControl.SetName( "AbsoluteLayout");
1427   auto rootLayout = AbsoluteLayout::New();
1428   DevelControl::SetLayout( rootLayoutControl, rootLayout );
1429   rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1430   rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1431   stage.Add( rootLayoutControl );
1432
1433   auto hbox = Control::New();
1434   auto hboxLayout = LinearLayout::New();
1435   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1436   DevelControl::SetLayout( hbox, hboxLayout );
1437   hbox.SetName( "HBox");
1438   hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1439   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1440   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1441
1442   std::vector< Control > controls;
1443   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1444   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1445   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1446   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1447
1448   for( auto&& iter : controls )
1449   {
1450     hbox.Add( iter );
1451   }
1452
1453   hbox.SetParentOrigin( ParentOrigin::CENTER );
1454   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1455   rootLayoutControl.Add( hbox );
1456
1457   // Ensure layouting happens
1458   application.SendNotification();
1459   application.Render();
1460
1461   // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1462   application.SendNotification();
1463
1464   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1465   // hbox left justifies elements
1466   tet_infoline("Test Child Actor Position");
1467
1468   auto controlXPosition=0.0f;
1469
1470   controlXPosition = LAYOUT_PADDING.start;  // First child positioned at offset defined by the padding
1471   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1472                                                                                             LAYOUT_PADDING.top,
1473                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1474
1475   controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1476   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1477                                                                                             LAYOUT_PADDING.top,
1478                                                                                             0.0f ),
1479                                                                                             0.0001f, TEST_LOCATION );
1480
1481   controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1482   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1483                                                                                             LAYOUT_PADDING.top,
1484                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1485
1486   controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1487   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1488                                                                                             LAYOUT_PADDING.top,
1489                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1490
1491   auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1492   auto totalControlsHeight = CONTROL_SIZE.height;
1493
1494   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1495                                                                                  totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1496                                                                                  0.0f ), 0.0001f, TEST_LOCATION );
1497
1498   // Change layout padding
1499   const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
1500   tet_printf( "\nChanging Padding to control at index 1 \n" );
1501   hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
1502
1503   // Ensure layouting happens
1504   application.SendNotification();
1505   application.Render();
1506
1507   // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1508   application.SendNotification();
1509
1510   controlXPosition = NEW_LAYOUT_PADDING.start;  // First child positioned at offset defined by the padding
1511   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
1512                                                                                             NEW_LAYOUT_PADDING.top,
1513                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1514
1515   controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1516   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1517                                                                                             NEW_LAYOUT_PADDING.top,
1518                                                                                             0.0f ),
1519                                                                                             0.0001f, TEST_LOCATION );
1520
1521   controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1522   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1523                                                                                             NEW_LAYOUT_PADDING.top,
1524                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1525
1526   controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1527   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1528                                                                                             NEW_LAYOUT_PADDING.top,
1529                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1530   totalControlsWidth = CONTROL_SIZE.width * controls.size();
1531   totalControlsHeight = CONTROL_SIZE.height;
1532
1533   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
1534                                                                                  totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
1535                                                                                  0.0f ), 0.0001f, TEST_LOCATION );
1536   END_TEST;
1537 }
1538
1539 // Margin Tests
1540
1541 int UtcDaliLayouting_HboxLayout_Margin01(void)
1542 {
1543   ToolkitTestApplication application;
1544   tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
1545
1546   Stage stage = Stage::GetCurrent();
1547   auto hbox = Control::New();
1548   auto hboxLayout = LinearLayout::New();
1549   DevelControl::SetLayout( hbox, hboxLayout );
1550   hbox.SetName( "HBox");
1551
1552   std::vector< Control > controls;
1553   controls.push_back( CreateLeafControl( 40, 40 ) );
1554   controls.push_back( CreateLeafControl( 60, 40 ) );
1555   controls.push_back( CreateLeafControl( 80, 40 ) );
1556   controls.push_back( CreateLeafControl( 100, 40 ) );
1557
1558   const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
1559   tet_printf( "\nAdding Margin to control at index 1 \n" );
1560   controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1561
1562   for( auto&& iter : controls )
1563   {
1564     hbox.Add( iter );
1565   }
1566   hbox.SetParentOrigin( ParentOrigin::CENTER );
1567   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1568   stage.Add( hbox );
1569
1570   // Ensure layouting happens
1571   application.SendNotification();
1572   application.Render();
1573
1574   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1575   // hbox left justifies elements
1576   tet_infoline("Test Child Actor Position");
1577   auto xPositionOfControlBeingTested = 0.0f;
1578   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1579                                                                                             380.0f,
1580                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1581   xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
1582
1583   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1584                                                                                             380.0f + CONTROL_MARGIN.top, 0.0f ),
1585                                                                                             0.0001f, TEST_LOCATION );
1586
1587   xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
1588   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1589
1590   xPositionOfControlBeingTested += 80.0f;
1591   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1592
1593   tet_infoline("Test Child Actor Size is the same after Margin added");
1594   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1595   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
1596   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1597   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1598
1599   END_TEST;
1600 }
1601
1602
1603 int UtcDaliLayouting_VboxLayout01(void)
1604 {
1605   ToolkitTestApplication application;
1606   tet_infoline(" UtcDaliLayouting_VboxLayout01");
1607
1608   Stage stage = Stage::GetCurrent();
1609   auto vbox = Control::New();
1610   auto vboxLayout = LinearLayout::New();
1611   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1612   vboxLayout.SetAlignment( LinearLayout::Alignment::TOP | LinearLayout::Alignment::CENTER_HORIZONTAL );
1613   DevelControl::SetLayout( vbox, vboxLayout );
1614   vbox.SetName( "Vbox");
1615
1616   std::vector< Control > controls;
1617   controls.push_back( CreateLeafControl( 40, 40 ) );
1618   controls.push_back( CreateLeafControl( 60, 60 ) );
1619   controls.push_back( CreateLeafControl( 80, 80 ) );
1620   controls.push_back( CreateLeafControl( 100, 100 ) );
1621
1622   for( auto&& iter : controls )
1623   {
1624     vbox.Add( iter );
1625   }
1626   vbox.SetParentOrigin( ParentOrigin::CENTER );
1627   vbox.SetAnchorPoint( AnchorPoint::CENTER );
1628   stage.Add( vbox );
1629
1630   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1631
1632   // Check it.
1633   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1634
1635   // Ensure layouting happens
1636   application.SendNotification();
1637   application.Render();
1638
1639   // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
1640   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1641   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1642   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1643   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1644
1645   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1646   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1647   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1648   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1649
1650   END_TEST;
1651 }
1652
1653 int UtcDaliLayouting_VboxLayout02(void)
1654 {
1655   ToolkitTestApplication application;
1656   tet_infoline(" UtcDaliLayouting_VboxLayout01");
1657
1658   Stage stage = Stage::GetCurrent();
1659
1660   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1661   // LayoutGroup for this to happen automatically.
1662   //
1663   // For this test, add an hbox instead
1664   auto rootControl = Control::New();
1665   auto absoluteLayout = AbsoluteLayout::New();
1666   DevelControl::SetLayout( rootControl, absoluteLayout );
1667   rootControl.SetName( "AbsoluteLayout");
1668   stage.Add( rootControl );
1669
1670   auto vbox = Control::New();
1671   auto vboxLayout = LinearLayout::New();
1672   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1673   vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
1674   DevelControl::SetLayout( vbox, vboxLayout );
1675   vbox.SetName( "Vbox");
1676   rootControl.Add( vbox );
1677
1678   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1679   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1680
1681   std::vector< Control > controls;
1682   controls.push_back( CreateLeafControl( 40, 40 ) );
1683   controls.push_back( CreateLeafControl( 60, 60 ) );
1684   controls.push_back( CreateLeafControl( 80, 80 ) );
1685   controls.push_back( CreateLeafControl( 100, 100 ) );
1686
1687   for( auto&& iter : controls )
1688   {
1689     vbox.Add( iter );
1690   }
1691   vbox.SetParentOrigin( ParentOrigin::CENTER );
1692   vbox.SetAnchorPoint( AnchorPoint::CENTER );
1693
1694   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1695
1696   // Check it.
1697   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1698
1699   // Ensure layouting happens
1700   application.SendNotification();
1701   application.Render();
1702
1703   DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1704   DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1705
1706   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1707   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1708   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1709
1710   // 3rd control is set to match parent - this should also be 100 wide
1711   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1712   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1713   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1714   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1715
1716   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1717   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1718   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1719   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1720
1721   END_TEST;
1722 }
1723
1724
1725 int UtcDaliLayouting_VboxLayout03(void)
1726 {
1727   ToolkitTestApplication application;
1728   tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
1729
1730   Stage stage = Stage::GetCurrent();
1731
1732   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1733   // LayoutGroup for this to happen automatically.
1734   //
1735   // For this test, add an hbox instead
1736   auto hbox = Control::New();
1737   auto hboxLayout = LinearLayout::New();
1738   DevelControl::SetLayout( hbox, hboxLayout );
1739   hbox.SetName( "Hbox");
1740   stage.Add( hbox );
1741
1742   auto vbox = Control::New();
1743   auto vboxLayout = LinearLayout::New();
1744   vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
1745   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1746   vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
1747
1748   DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
1749
1750   DevelControl::SetLayout( vbox, vboxLayout );
1751   vbox.SetName( "Vbox");
1752   hbox.Add( vbox );
1753
1754   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1755   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1756
1757   std::vector< Control > controls;
1758   controls.push_back( CreateLeafControl( 40, 40 ) );
1759   controls.push_back( CreateLeafControl( 60, 60 ) );
1760   controls.push_back( CreateLeafControl( 80, 80 ) );
1761   controls.push_back( CreateLeafControl( 100, 100 ) );
1762
1763   for( auto&& iter : controls )
1764   {
1765     vbox.Add( iter );
1766   }
1767   vbox.SetParentOrigin( ParentOrigin::CENTER );
1768   vbox.SetAnchorPoint( AnchorPoint::CENTER );
1769
1770   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1771
1772   // Check it.
1773   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1774
1775   // Ensure layouting happens
1776   application.SendNotification();
1777   application.Render();
1778
1779   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1780   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1781
1782   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1783   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1784   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1785
1786   // 3rd control is set to match parent - this should also be 100 wide
1787   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1788   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1789   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1790   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1791
1792   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1793   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1794   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1795   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1796
1797   END_TEST;
1798 }
1799
1800 int UtcDaliLayouting_VboxLayout_Padding(void)
1801 {
1802   ToolkitTestApplication application;
1803   tet_infoline("UtcDaliLayouting_VboxLayout_Padding - Adding Padding to the vbox");
1804
1805   // Adding padding to the layout should offset the positioning of the children.
1806
1807   const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1808   const Size CONTROL_SIZE = Size( 40, 40 );
1809
1810   Stage stage = Stage::GetCurrent();
1811   // Create a root layout, ideally Dali would have a default layout in the root layer.
1812   // Without this root layer the LinearLayout (or any other layout) will not
1813   // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1814   // It uses the default stage size and ideally should have a layout added to it.
1815   auto rootLayoutControl = Control::New();
1816   rootLayoutControl.SetName( "AbsoluteLayout");
1817   auto rootLayout = AbsoluteLayout::New();
1818   DevelControl::SetLayout( rootLayoutControl, rootLayout );
1819   rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1820   rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1821   stage.Add( rootLayoutControl );
1822
1823   auto vbox = Control::New();
1824   auto vboxLayout = LinearLayout::New();
1825   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1826   DevelControl::SetLayout( vbox, vboxLayout );
1827   vbox.SetName( "VBox");
1828   vbox.SetProperty( Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1829   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1830   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1831
1832   std::vector< Control > controls;
1833   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1834   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1835   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1836   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1837
1838   for( auto&& iter : controls )
1839   {
1840     vbox.Add( iter );
1841   }
1842
1843   vbox.SetParentOrigin( ParentOrigin::CENTER );
1844   vbox.SetAnchorPoint( AnchorPoint::CENTER );
1845   rootLayoutControl.Add( vbox );
1846
1847   // Ensure layouting happens
1848   application.SendNotification();
1849   application.Render();
1850
1851   // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1852   application.SendNotification();
1853
1854   // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
1855   tet_infoline("Test Child Actor Position");
1856
1857   auto controlYPosition = 0.0f;
1858
1859   controlYPosition = LAYOUT_PADDING.top;  // First child positioned at offset defined by the padding
1860   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1861                                                                                             LAYOUT_PADDING.top,
1862                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1863
1864   controlYPosition += CONTROL_SIZE.height; // Second child positioned is the position of the first child + the first child's height.
1865   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1866                                                                                             controlYPosition,
1867                                                                                             0.0f ),
1868                                                                                             0.0001f, TEST_LOCATION );
1869
1870   controlYPosition += CONTROL_SIZE.height; // Third child positioned adjacent to second
1871   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1872                                                                                             controlYPosition,
1873                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1874
1875   controlYPosition += CONTROL_SIZE.height; // Forth passed adjacent to the third
1876   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1877                                                                                             controlYPosition,
1878                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1879
1880   auto totalControlsWidth = CONTROL_SIZE.width;
1881   auto totalControlsHeight = CONTROL_SIZE.height * controls.size();
1882
1883   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1884                                                                                  totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1885                                                                                  0.0f ), 0.0001f, TEST_LOCATION );
1886
1887   END_TEST;
1888 }
1889
1890
1891 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
1892 {
1893   ToolkitTestApplication application;
1894   tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
1895   tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
1896
1897   Stage stage = Stage::GetCurrent();
1898
1899   auto hbox = Control::New();
1900   auto hboxLayout = Test::CustomLayout::New();
1901   DevelControl::SetLayout( hbox, hboxLayout );
1902   hbox.SetName( "HBox");
1903
1904   std::vector< Control > controls;
1905   controls.push_back( CreateLeafControl( 40, 40 ) );
1906   controls.push_back( CreateLeafControl( 60, 40 ) );
1907   controls.push_back( CreateLeafControl( 80, 40 ) );
1908   controls.push_back( CreateLeafControl( 100, 40 ) );
1909
1910   for( auto&& iter : controls )
1911   {
1912     hbox.Add( iter );
1913   }
1914   hbox.SetParentOrigin( ParentOrigin::CENTER );
1915   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1916   stage.Add( hbox );
1917
1918   // Ensure layouting happens
1919   application.SendNotification();
1920   application.Render();
1921
1922   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1923   // hbox left justifies elements
1924   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1925   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1926   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1927   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1928
1929   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1930   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1931   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1932   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1933
1934   controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
1935   controls[2].Lower();      // 2->1; 2, 1, 3, 0
1936
1937   application.SendNotification();
1938   application.Render();
1939
1940   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1941   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1942   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1943   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1944
1945   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1946   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1947   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1948   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1949
1950   END_TEST;
1951 }
1952
1953 int UtcDaliLayouting_HboxLayout_TargetSize(void)
1954 {
1955   ToolkitTestApplication application;
1956   tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
1957
1958   Stage stage = Stage::GetCurrent();
1959   auto hbox = Control::New();
1960   auto hboxLayout = LinearLayout::New();
1961   DevelControl::SetLayout( hbox, hboxLayout );
1962   hbox.SetName( "HBox");
1963
1964   std::vector< Control > controls;
1965   controls.push_back( CreateLeafControl( 40, 40 ) );
1966   for( auto&& iter : controls )
1967   {
1968     iter.SetSize( 100, 100 );
1969     hbox.Add( iter );
1970   }
1971   hbox.SetParentOrigin( ParentOrigin::CENTER );
1972   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1973   stage.Add( hbox );
1974
1975   // Ensure layouting happens
1976   application.SendNotification();
1977   application.Render();
1978
1979   // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
1980   // hbox left justifies elements
1981   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1982   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1983
1984   END_TEST;
1985 }
1986
1987 int UtcDaliLayouting_RemoveLayout01(void)
1988 {
1989   ToolkitTestApplication application;
1990   tet_infoline(" UtcDaliLayouting_RemoveLayout");
1991
1992   Stage stage = Stage::GetCurrent();
1993
1994   auto rootControl = Control::New();
1995   auto absoluteLayout = AbsoluteLayout::New();
1996   DevelControl::SetLayout( rootControl, absoluteLayout );
1997   rootControl.SetName( "AbsoluteLayout" );
1998   stage.Add( rootControl );
1999
2000   auto hbox = Control::New();
2001   auto hboxLayout = LinearLayout::New();
2002   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2003   DevelControl::SetLayout( hbox, hboxLayout );
2004   hbox.SetName( "HBox" );
2005
2006   std::vector< Control > controls;
2007   controls.push_back( CreateLeafControl( 40, 40 ) );
2008   controls.push_back( CreateLeafControl( 60, 40 ) );
2009
2010   for( auto&& iter : controls )
2011   {
2012     hbox.Add( iter );
2013   }
2014   hbox.SetParentOrigin( ParentOrigin::CENTER );
2015   hbox.SetAnchorPoint( AnchorPoint::CENTER );
2016   rootControl.Add( hbox );
2017
2018   tet_infoline("Layout as normal");
2019   application.SendNotification();
2020   application.Render();
2021
2022   tet_infoline("Set an empty layout on hbox container");
2023   LinearLayout emptyLayout;
2024   DevelControl::SetLayout( hbox, emptyLayout );
2025
2026   tet_infoline("Run another layout");
2027   application.SendNotification();
2028   application.Render();
2029
2030   tet_infoline("Check leaf controls haven't moved");
2031
2032   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2033   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2034
2035   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2036   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2037
2038   END_TEST;
2039 }
2040
2041 int UtcDaliLayouting_LayoutChildren01(void)
2042 {
2043   ToolkitTestApplication application;
2044   tet_infoline(" UtcDaliLayouting_LayoutChildren01");
2045
2046   Stage stage = Stage::GetCurrent();
2047
2048   auto rootControl = Control::New();
2049   auto absoluteLayout = AbsoluteLayout::New();
2050   DevelControl::SetLayout( rootControl, absoluteLayout );
2051   stage.Add( rootControl );
2052
2053   auto hbox = Control::New();
2054   auto hboxLayout = LinearLayout::New();
2055   DevelControl::SetLayout( hbox, hboxLayout );
2056   rootControl.Add( hbox );
2057
2058   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2059
2060   tet_infoline("Test removal by setting empty layout to child container" );
2061   DevelControl::SetLayout( hbox, LayoutItem{} );
2062
2063   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2064
2065   auto& hboxImpl = GetImplementation( hboxLayout );
2066   Handle empty;
2067   DALI_TEST_EQUALS( hboxLayout.GetOwner(), empty, TEST_LOCATION );
2068   DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2069
2070   // For coverage
2071   hboxImpl.SetLayoutRequested();
2072
2073   END_TEST;
2074 }
2075
2076 int UtcDaliLayouting_LayoutChildren02(void)
2077 {
2078   ToolkitTestApplication application;
2079   tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2080
2081   Stage stage = Stage::GetCurrent();
2082
2083   auto rootControl = Control::New();
2084   auto absoluteLayout = AbsoluteLayout::New();
2085   DevelControl::SetLayout( rootControl, absoluteLayout );
2086   stage.Add( rootControl );
2087
2088   auto hbox = Control::New();
2089   auto hboxLayout = LinearLayout::New();
2090   DevelControl::SetLayout( hbox, hboxLayout );
2091   rootControl.Add( hbox );
2092
2093   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2094
2095   tet_infoline("Test removal by removing child actor from parent container" );
2096   hbox.Unparent();
2097
2098   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2099
2100   auto& hboxImpl = GetImplementation( hboxLayout );
2101   tet_infoline("Test child actor still has hbox layout " );
2102   DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
2103
2104   tet_infoline("Test hbox layout has no parent " );
2105   DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2106
2107   END_TEST;
2108 }
2109
2110 int UtcDaliLayouting_LayoutChildren03(void)
2111 {
2112   ToolkitTestApplication application;
2113   tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2114
2115   Stage stage = Stage::GetCurrent();
2116
2117   auto rootControl = Control::New();
2118   auto absoluteLayout = AbsoluteLayout::New();
2119   DevelControl::SetLayout( rootControl, absoluteLayout );
2120   stage.Add( rootControl );
2121
2122   auto hbox = Control::New();
2123   auto hboxLayout = LinearLayout::New();
2124   DevelControl::SetLayout( hbox, hboxLayout );
2125   rootControl.Add( hbox );
2126
2127   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2128
2129   tet_infoline("Test removal by removing child layout from parent layout" );
2130   absoluteLayout.Remove( hboxLayout );
2131
2132   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2133
2134   auto& hboxImpl = GetImplementation( hboxLayout );
2135
2136   tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
2137   DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
2138   DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
2139
2140   tet_infoline("Check orphaned layout has no parent");
2141   DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2142
2143   END_TEST;
2144 }
2145
2146
2147 int UtcDaliLayouting_LayoutChildren04(void)
2148 {
2149   ToolkitTestApplication application;
2150   tet_infoline(" UtcDaliLayouting_LayoutChildren03");
2151
2152   Stage stage = Stage::GetCurrent();
2153
2154   auto rootControl = Control::New();
2155   auto absoluteLayout = AbsoluteLayout::New();
2156   DevelControl::SetLayout( rootControl, absoluteLayout );
2157   stage.Add( rootControl );
2158
2159   auto hbox = Control::New();
2160   tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
2161   auto hboxLayout = LinearLayout::New();
2162   rootControl.Add( hbox );
2163
2164   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2165
2166   tet_infoline("Then setting a layout on the child container");
2167   DevelControl::SetLayout( hbox, hboxLayout );
2168
2169   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2170
2171   auto& hboxImpl = GetImplementation( hboxLayout );
2172   auto& absImpl = GetImplementation( absoluteLayout );
2173   DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
2174   DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
2175
2176   END_TEST;
2177 }
2178
2179 int UtcDaliLayouting_SetLayoutOrder01(void)
2180 {
2181   ToolkitTestApplication application;
2182   tet_infoline(" UtcDaliLayouting_SetLayoutOrder01 - Call SetLayout after adding the control to the root layout");
2183
2184   Stage stage = Stage::GetCurrent();
2185
2186   auto rootControl = Control::New();
2187   auto absoluteLayout = AbsoluteLayout::New();
2188   DevelControl::SetLayout( rootControl, absoluteLayout );
2189   rootControl.SetName( "AbsoluteLayout" );
2190   stage.Add( rootControl );
2191
2192   tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
2193   auto hbox = Control::New();
2194   auto hboxLayout = LinearLayout::New();
2195   hbox.SetName( "HBox");
2196
2197   tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
2198   rootControl.Add( hbox );
2199
2200   tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
2201   DevelControl::SetLayout( hbox, hboxLayout );
2202
2203   // Add a Child control
2204   std::vector< Control > controls;
2205   controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
2206   for( auto&& iter : controls )
2207   {
2208     hbox.Add( iter );
2209   }
2210
2211   // Ensure layouting happens
2212   application.SendNotification();
2213   application.Render();
2214
2215   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2216
2217   END_TEST;
2218 }
2219
2220 int UtcDaliLayouting_SetLayoutOrder02(void)
2221 {
2222   ToolkitTestApplication application;
2223   tet_infoline(" UtcDaliLayouting_SetLayoutOrder02 - Test the layout item order and the control order");
2224
2225   Stage stage = Stage::GetCurrent();
2226
2227   auto rootControl = Control::New();
2228   auto absoluteLayout = AbsoluteLayout::New();
2229   DevelControl::SetLayout( rootControl, absoluteLayout );
2230   rootControl.SetName( "AbsoluteLayout" );
2231   stage.Add( rootControl );
2232
2233   auto hbox = Control::New();
2234   auto hboxLayout = LinearLayout::New();
2235   hbox.SetName( "HBox");
2236
2237   rootControl.Add( hbox );
2238
2239   DevelControl::SetLayout( hbox, hboxLayout );
2240
2241   // Add child controls
2242   std::vector< Control > controls;
2243   controls.push_back( CreateLeafControl( 100, 100 ) );  // 0
2244   controls.push_back( CreateLeafControl( 100, 100 ) );  // 1
2245   controls.push_back( CreateLeafControl( 100, 100 ) );  // 2
2246
2247   for( auto&& iter : controls )
2248   {
2249     hbox.Add( iter );
2250   }
2251
2252   // Ensure layouting happens
2253   application.SendNotification();
2254   application.Render();
2255
2256   TestLayoutItemOrder( controls, hboxLayout );
2257
2258   tet_infoline("RaiseToTop");
2259
2260   controls[0].RaiseToTop(); // 1 2 0
2261
2262   TestLayoutItemOrder( controls, hboxLayout );
2263
2264   tet_infoline("LowerToBottom");
2265
2266   controls[2].LowerToBottom();  // 2 1 0
2267
2268   TestLayoutItemOrder( controls, hboxLayout );
2269
2270   tet_infoline("Remove / Add");
2271
2272   hbox.Remove( controls[2] );  // 1 0
2273   hbox.Add( controls[2] );     // 1 0 2
2274
2275   TestLayoutItemOrder( controls, hboxLayout );
2276
2277   tet_infoline("SetLayout");
2278
2279   auto vboxLayout = LinearLayout::New();
2280   DevelControl::SetLayout( controls[0], vboxLayout );
2281
2282   TestLayoutItemOrder( controls, hboxLayout );
2283
2284   tet_infoline("Raise");
2285
2286   controls[0].Raise();  // 1 2 0
2287
2288   TestLayoutItemOrder( controls, hboxLayout );
2289
2290   tet_infoline("Lower");
2291
2292   controls[2].Lower();   // 2 1 0
2293
2294   TestLayoutItemOrder( controls, hboxLayout );
2295
2296   tet_infoline("SetLayout again");
2297
2298   auto vboxLayout1 = LinearLayout::New();
2299   DevelControl::SetLayout( controls[2], vboxLayout1 );
2300
2301   TestLayoutItemOrder( controls, hboxLayout );
2302
2303   DevelControl::SetLayout( controls[2], vboxLayout );
2304
2305   END_TEST;
2306 }