Fixed unparenting a layout item from a layout group
[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
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali-toolkit/devel-api/controls/control-devel.h>
24 #include <dali-toolkit/devel-api/layouting/absolute-layout.h>
25 #include <dali-toolkit/devel-api/layouting/linear-layout.h>
26 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
27 #include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
28
29 #include <../custom-layout.h>
30
31 #include <layout-utils.h>
32
33 using namespace Dali;
34 using namespace Toolkit;
35
36 void utc_dali_toolkit_layouting_startup(void)
37 {
38   test_return_value = TET_UNDEF;
39 }
40
41 void utc_dali_toolkit_layouting_cleanup(void)
42 {
43   test_return_value = TET_PASS;
44 }
45
46 int UtcDaliLayouting_HboxLayout01(void)
47 {
48   ToolkitTestApplication application;
49   tet_infoline(" UtcDaliLayouting_HboxLayout01");
50
51   Stage stage = Stage::GetCurrent();
52   auto hbox = Control::New();
53   auto hboxLayout = LinearLayout::New();
54   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
55   DevelControl::SetLayout( hbox, hboxLayout );
56   hbox.SetName( "HBox");
57
58   std::vector< Control > controls;
59   controls.push_back( CreateLeafControl( 40, 40 ) );
60   controls.push_back( CreateLeafControl( 60, 40 ) );
61   controls.push_back( CreateLeafControl( 80, 40 ) );
62   controls.push_back( CreateLeafControl( 100, 40 ) );
63
64   for( auto&& iter : controls )
65   {
66     hbox.Add( iter );
67   }
68   hbox.SetParentOrigin( ParentOrigin::CENTER );
69   hbox.SetAnchorPoint( AnchorPoint::CENTER );
70   stage.Add( hbox );
71
72   // Ensure layouting happens
73   application.SendNotification();
74   application.Render();
75
76   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
77   // hbox left justifies elements
78   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
79   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
80   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
81   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
82
83   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
84   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
85   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
86   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
87
88   // Change a layout
89   auto newHBoxLayout = LinearLayout::New();
90   newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
91   DevelControl::SetLayout( hbox, newHBoxLayout );
92
93   application.SendNotification();
94   application.Render();
95
96   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
97   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
98   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
99   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
100
101   END_TEST;
102 }
103
104 int UtcDaliLayouting_HboxLayout02(void)
105 {
106   ToolkitTestApplication application;
107   tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
108
109   Stage stage = Stage::GetCurrent();
110
111   auto hbox1 = Control::New();
112   auto hboxLayout1 = LinearLayout::New();
113   DevelControl::SetLayout( hbox1, hboxLayout1 );
114
115   auto hbox2 = Control::New();
116   auto hboxLayout2 = LinearLayout::New();
117   DevelControl::SetLayout( hbox2, hboxLayout2 );
118
119   hbox1.SetName( "HBox1");
120   hbox2.SetName( "HBox2");
121
122   std::vector< Control > controls;
123   controls.push_back( CreateLeafControl( 20, 40 ) );
124   controls.push_back( CreateLeafControl( 30, 50 ) );
125   controls.push_back( CreateLeafControl( 40, 60 ) );
126   controls.push_back( CreateLeafControl( 50, 70 ) );
127
128   controls.push_back( CreateLeafControl( 25, 40 ) );
129   controls.push_back( CreateLeafControl( 35, 50 ) );
130   controls.push_back( CreateLeafControl( 45, 60 ) );
131   controls.push_back( CreateLeafControl( 55, 70 ) );
132
133   int counter=0;
134   for( auto&& iter : controls )
135   {
136     if( counter < 4 )
137     {
138       hbox1.Add( iter );
139     }
140     else
141     {
142       hbox2.Add( iter );
143     }
144     ++counter;
145   }
146   hbox1.SetParentOrigin( ParentOrigin::CENTER );
147   hbox1.SetAnchorPoint( AnchorPoint::CENTER );
148   hbox2.SetParentOrigin( ParentOrigin::CENTER );
149   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
150
151   auto hbox3 = Control::New();
152   auto hboxLayout3 = LinearLayout::New();
153   DevelControl::SetLayout( hbox3, hboxLayout3 );
154
155   hbox3.SetParentOrigin( ParentOrigin::CENTER );
156   hbox3.SetName( "HBox3");
157   hbox3.Add( hbox1 );
158   hbox3.Add( hbox2 );
159
160   stage.Add( hbox3 );
161
162   // Ensure layouting happens
163   application.SendNotification();
164   application.Render();
165
166
167   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
168   // hbox left justifies elements
169   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
170   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
171   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,  5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
172   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,  0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
173
174   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
175   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
176   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
177   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
178
179
180   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
181   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
182   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f,  5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
183   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,  0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
184
185   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
186   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
187   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
188   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
189
190   // Test hbox1 and 2 are sized to wrap their content
191   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
192   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
193   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
194   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
195
196   // Test hbox3 matches parent (root layer)
197   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
198   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
199
200   END_TEST;
201 }
202
203
204 int UtcDaliLayouting_HboxLayout03(void)
205 {
206   ToolkitTestApplication application;
207   tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
208
209   Stage stage = Stage::GetCurrent();
210
211   auto hbox1 = Control::New();
212   auto hboxLayout1 = LinearLayout::New();
213   DevelControl::SetLayout( hbox1, hboxLayout1 );
214
215   auto hbox2 = Control::New();
216   auto hboxLayout2 = LinearLayout::New();
217   DevelControl::SetLayout( hbox2, hboxLayout2 );
218
219   hbox1.SetName( "HBox1");
220   hbox2.SetName( "HBox2");
221   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
222   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
223   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
224   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
225
226   std::vector< Control > controls;
227   controls.push_back( CreateLeafControl( 20, 40 ) );
228   controls.push_back( CreateLeafControl( 30, 50 ) );
229   controls.push_back( CreateLeafControl( 40, 60 ) );
230   controls.push_back( CreateLeafControl( 50, 70 ) );
231
232   controls.push_back( CreateLeafControl( 25, 40 ) );
233   controls.push_back( CreateLeafControl( 35, 50 ) );
234   controls.push_back( CreateLeafControl( 45, 60 ) );
235   controls.push_back( CreateLeafControl( 55, 70 ) );
236
237   int counter=0;
238   for( auto&& iter : controls )
239   {
240     if( counter < 4 )
241     {
242       hbox1.Add( iter );
243     }
244     else
245     {
246       hbox2.Add( iter );
247     }
248     ++counter;
249   }
250   hbox1.SetParentOrigin( ParentOrigin::CENTER );
251   hbox1.SetAnchorPoint( AnchorPoint::CENTER );
252   hbox2.SetParentOrigin( ParentOrigin::CENTER );
253   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
254
255   auto hbox3 = Control::New();
256   auto hboxLayout3 = LinearLayout::New();
257   DevelControl::SetLayout( hbox3, hboxLayout3);
258
259   hbox3.SetParentOrigin( ParentOrigin::CENTER );
260   hbox3.SetName( "HBox3");
261   hbox3.Add( hbox1 );
262   hbox3.Add( hbox2 );
263
264   stage.Add( hbox3 );
265
266   //std::ostringstream oss;
267   //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
268   //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
269
270   // Ensure layouting happens
271   application.SendNotification();
272   application.Render();
273
274
275   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
276   // hbox left justifies elements
277   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
278   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
279   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
280   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
281
282   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
283   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
284   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
285   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
286
287   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
288   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
289   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
290   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
291
292   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
293   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
294   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
295   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
296
297   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
298   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
299   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
300   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
301
302   // Test hbox3 matches parent (root layer)
303   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
304   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
305
306   END_TEST;
307 }
308
309 int UtcDaliLayouting_HboxLayout04(void)
310 {
311   ToolkitTestApplication application;
312   tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
313
314   Stage stage = Stage::GetCurrent();
315
316   auto hbox1 = Control::New();
317   auto hboxLayout1 = LinearLayout::New();
318   DevelControl::SetLayout( hbox1, hboxLayout1 );
319
320   auto hbox2 = Control::New();
321   auto hboxLayout2 = LinearLayout::New();
322   DevelControl::SetLayout( hbox2, hboxLayout2 );
323
324   hbox1.SetName( "HBox1"); // Default spec is to wrap content
325   hbox2.SetName( "HBox2");
326   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
327   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
328   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
329   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
330
331   std::vector< Control > controls;
332   controls.push_back( CreateLeafControl( 80, 40 ) );
333   controls.push_back( CreateLeafControl( 80, 50 ) );
334   controls.push_back( CreateLeafControl( 80, 60 ) );
335   controls.push_back( CreateLeafControl( 80, 70 ) );
336
337   controls.push_back( CreateLeafControl( 80, 40 ) );
338   controls.push_back( CreateLeafControl( 80, 50 ) );
339   controls.push_back( CreateLeafControl( 80, 60 ) );
340   controls.push_back( CreateLeafControl( 80, 70 ) );
341
342   int counter=0;
343   for( auto&& iter : controls )
344   {
345     if( counter < 4 )
346     {
347       hbox1.Add( iter );
348     }
349     else
350     {
351       hbox2.Add( iter );
352     }
353     ++counter;
354   }
355
356   controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
357   auto hbox3 = Control::New();
358   auto hboxLayout3 = LinearLayout::New();
359   DevelControl::SetLayout( hbox3, hboxLayout3 );
360
361   hbox3.SetParentOrigin( ParentOrigin::CENTER );
362   hbox3.SetName( "HBox3");
363   hbox3.Add( hbox1 );
364   hbox3.Add( hbox2 );
365   stage.Add( hbox3 );
366
367   //std::ostringstream oss;
368   //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
369   //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
370
371   // Ensure layouting happens
372   application.SendNotification();
373   application.Render();
374
375
376   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
377   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
378   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
379   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
380
381   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
382   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
383   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
384   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
385
386   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
387   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
388   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
389   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
390
391   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
392   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
393   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
394   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
395
396   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
397   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
398   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
399   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
400
401
402   // Test hbox3 matches parent (root layer)
403   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
404   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
405
406   END_TEST;
407 }
408
409 int UtcDaliLayouting_HboxLayout05(void)
410 {
411   ToolkitTestApplication application;
412   tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
413
414   Stage stage = Stage::GetCurrent();
415   auto hbox = Control::New();
416   auto hboxLayout = LinearLayout::New();
417   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
418   DevelControl::SetLayout( hbox, hboxLayout );
419   hbox.SetName( "HBox");
420
421   std::vector< Control > controls;
422   controls.push_back( CreateLeafControl( 40, 40 ) );
423   controls.push_back( CreateLeafControl( 60, 40 ) );
424   controls.push_back( CreateLeafControl( 80, 40 ) );
425   controls.push_back( CreateLeafControl( 100, 40 ) );
426
427   for( auto&& iter : controls )
428   {
429     hbox.Add( iter );
430     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
431     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
432   }
433
434   hbox.SetParentOrigin( ParentOrigin::CENTER );
435   hbox.SetAnchorPoint( AnchorPoint::CENTER );
436   stage.Add( hbox );
437
438   // Ensure layouting happens
439   application.SendNotification();
440   application.Render();
441
442   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
443   // hbox left justifies elements
444   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
445   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
446   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
447   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
448
449   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
450   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
451   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
452   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
453
454   END_TEST;
455 }
456
457 int UtcDaliLayouting_HboxLayout06(void)
458 {
459   ToolkitTestApplication application;
460   tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
461
462   Stage stage = Stage::GetCurrent();
463
464   auto rootControl = Control::New();
465   auto absoluteLayout = AbsoluteLayout::New();
466   DevelControl::SetLayout( rootControl, absoluteLayout );
467   rootControl.SetName( "AbsoluteLayout" );
468   stage.Add( rootControl );
469
470   auto hbox = Control::New();
471   auto hboxLayout = LinearLayout::New();
472   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
473   DevelControl::SetLayout( hbox, hboxLayout );
474   hbox.SetName( "HBox" );
475
476   std::vector< Control > controls;
477   controls.push_back( CreateLeafControl( 40, 40 ) );
478   controls.push_back( CreateLeafControl( 60, 40 ) );
479
480   for( auto&& iter : controls )
481   {
482     hbox.Add( iter );
483   }
484   hbox.SetParentOrigin( ParentOrigin::CENTER );
485   hbox.SetAnchorPoint( AnchorPoint::CENTER );
486   rootControl.Add( hbox );
487
488   // Ensure layouting happens
489   application.SendNotification();
490   application.Render();
491
492   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
493   // hbox left justifies elements
494   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
495   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
496
497   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
498   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
499
500   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
501
502   // Change a layout
503   auto newHBoxLayout = LinearLayout::New();
504   newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
505   DevelControl::SetLayout( hbox, newHBoxLayout );
506
507   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
508   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
509
510   application.SendNotification();
511   application.Render();
512
513   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
514
515   // Change size specification
516   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
517   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
518
519   application.SendNotification();
520   application.Render();
521
522   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
523
524   // Use WRAP_CONTENT again
525   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
526   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
527
528   application.SendNotification();
529   application.Render();
530
531   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
532
533   END_TEST;
534 }
535
536
537 int UtcDaliLayouting_HboxLayout07(void)
538 {
539   ToolkitTestApplication application;
540   tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
541
542   Stage stage = Stage::GetCurrent();
543   auto hbox = Control::New();
544   auto hboxLayout = LinearLayout::New();
545   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
546   DevelControl::SetLayout( hbox, hboxLayout );
547   hbox.SetName( "HBox");
548
549   std::vector< Control > controls;
550   controls.push_back( CreateLeafControl( 40, 40 ) );
551   controls.push_back( CreateLeafControl( 60, 40 ) );
552   controls.push_back( CreateLeafControl( 80, 40 ) );
553   controls.push_back( CreateLeafControl( 100, 40 ) );
554
555   for( auto&& iter : controls )
556   {
557     hbox.Add( iter );
558   }
559   hbox.SetParentOrigin( ParentOrigin::CENTER );
560   hbox.SetAnchorPoint( AnchorPoint::CENTER );
561   stage.Add( hbox );
562
563   hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
564
565   // Ensure layouting happens
566   application.SendNotification();
567   application.Render();
568
569   // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
570   // hbox left justifies elements
571   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
572   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
573   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
574   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
575
576   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
577   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
578   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
579   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
580
581   hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
582
583   // Ensure layouting happens
584   application.SendNotification();
585   application.Render();
586
587   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
588   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
589   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
590   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
591
592   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
593   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
594   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
595   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
596
597   END_TEST;
598 }
599
600 int UtcDaliLayouting_HboxLayout08(void)
601 {
602   ToolkitTestApplication application;
603   tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation");
604
605   Stage stage = Stage::GetCurrent();
606
607   auto rootControl = Control::New();
608   auto absoluteLayout = AbsoluteLayout::New();
609   absoluteLayout.SetAnimateLayout( true );
610   DevelControl::SetLayout( rootControl, absoluteLayout );
611   rootControl.SetName( "AbsoluteLayout" );
612   stage.Add( rootControl );
613
614   Control control1 = CreateLeafControl( 40, 40 );
615   rootControl.Add( control1 );
616
617   auto hbox = Control::New();
618   auto hboxLayout = LinearLayout::New();
619   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
620   DevelControl::SetLayout( hbox, hboxLayout );
621   hbox.SetName( "HBox" );
622
623   Control control2 = CreateLeafControl( 40, 40 );
624   hbox.Add( control2 );
625
626   hbox.SetParentOrigin( ParentOrigin::CENTER );
627   hbox.SetAnchorPoint( AnchorPoint::CENTER );
628   rootControl.Add( hbox );
629
630   DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION );
631   DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION );
632   DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION );
633   DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION );
634
635   hboxLayout.SetAnimateLayout( true );
636   absoluteLayout.SetAnimateLayout( false );
637
638   DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION );
639   DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION );
640   DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION );
641   DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION );
642
643   END_TEST;
644 }
645
646 // Padding tests
647
648 int UtcDaliLayouting_HboxLayout_Padding01(void)
649 {
650   ToolkitTestApplication application;
651   tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
652
653   Stage stage = Stage::GetCurrent();
654   auto hbox = Control::New();
655   auto hboxLayout = LinearLayout::New();
656   DevelControl::SetLayout( hbox, hboxLayout );
657   hbox.SetName( "HBox");
658
659   std::vector< Control > controls;
660   controls.push_back( CreateLeafControl( 40, 40 ) );
661   controls.push_back( CreateLeafControl( 60, 40 ) );
662   controls.push_back( CreateLeafControl( 80, 40 ) );
663   controls.push_back( CreateLeafControl( 100, 40 ) );
664
665   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
666   tet_printf( "\nAdding Padding to control at index %u \n", 1 );
667   controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
668
669   for( auto&& iter : controls )
670   {
671     hbox.Add( iter );
672   }
673   hbox.SetParentOrigin( ParentOrigin::CENTER );
674   hbox.SetAnchorPoint( AnchorPoint::CENTER );
675   stage.Add( hbox );
676
677   // Ensure layouting happens
678   application.SendNotification();
679   application.Render();
680
681   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
682   // hbox left justifies elements
683   tet_infoline("Test Child Actor Position");
684   float xPositionOfControlBeingTested = 0.0f;
685   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
686                                                                                             380.0f,
687                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
688   xPositionOfControlBeingTested += 40.0f;
689
690   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
691                                                                                             380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
692                                                                                             0.0001f, TEST_LOCATION );
693
694   xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
695   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
696
697   xPositionOfControlBeingTested += 80.0f;
698   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
699
700   tet_infoline("Test Child Actor Size");
701   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
702
703   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
704                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
705                                                                                         0.0001f, TEST_LOCATION );
706
707   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
708   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
709
710   END_TEST;
711 }
712
713 int UtcDaliLayouting_HboxLayout_Padding02(void)
714 {
715   ToolkitTestApplication application;
716   tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
717
718   Stage stage = Stage::GetCurrent();
719   auto hbox = Control::New();
720   auto hboxLayout = LinearLayout::New();
721   DevelControl::SetLayout( hbox, hboxLayout );
722   hbox.SetName( "HBox");
723
724   std::vector< Control > controls;
725   controls.push_back( CreateLeafControl( 40, 40 ) );
726   controls.push_back( CreateLeafControl( 60, 40 ) );
727   controls.push_back( CreateLeafControl( 80, 40 ) );
728   controls.push_back( CreateLeafControl( 100, 40 ) );
729
730   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
731
732   for( auto&& iter : controls )
733   {
734     iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
735     hbox.Add( iter );
736   }
737   hbox.SetParentOrigin( ParentOrigin::CENTER );
738   hbox.SetAnchorPoint( AnchorPoint::CENTER );
739   stage.Add( hbox );
740
741   // Ensure layouting happens
742   application.SendNotification();
743   application.Render();
744
745   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
746   // hbox left justifies elements
747   tet_infoline("Test Child Actor Position");
748   float xPositionOfControlBeingTested = 0.0f;
749   float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
750
751   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
752                                                                                             yPositionOfControlBeingTested,
753                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
754   xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
755
756   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
757                                                                                             yPositionOfControlBeingTested,
758                                                                                             0.0f ),
759                                                                                             0.0001f, TEST_LOCATION );
760
761   xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
762   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
763                                                                                             yPositionOfControlBeingTested,
764                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
765
766   xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
767   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
768                                                                                             yPositionOfControlBeingTested,
769                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
770
771   tet_infoline("Test Child Actor Size");
772   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
773                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
774                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
775
776   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
777                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
778                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
779
780   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
781                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
782                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
783
784   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
785                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
786                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
787
788   END_TEST;
789 }
790
791
792 int UtcDaliLayouting_HboxLayout_Padding03(void)
793 {
794   ToolkitTestApplication application;
795   tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
796
797   Stage stage = Stage::GetCurrent();
798   auto hbox = Control::New();
799   auto hboxLayout = LinearLayout::New();
800   DevelControl::SetLayout( hbox, hboxLayout );
801   hbox.SetName( "HBox");
802
803   std::vector< Control > controls;
804   controls.push_back( CreateLeafControl( 40, 40 ) );
805   controls.push_back( CreateLeafControl( 40, 40 ) );
806   controls.push_back( CreateLeafControl( 40, 40 ) );
807
808   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
809   tet_printf( "\nAdding Padding to control at index 1 \n" );
810   controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
811
812   for( auto&& iter : controls )
813   {
814     hbox.Add( iter );
815   }
816   hbox.SetParentOrigin( ParentOrigin::CENTER );
817   hbox.SetAnchorPoint( AnchorPoint::CENTER );
818   stage.Add( hbox );
819
820   // Ensure layouting happens
821   application.SendNotification();
822   application.Render();
823
824   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
825   // hbox left justifies elements
826   tet_infoline("Test Child Actor Position");
827   float xPositionOfControlBeingTested = 0.0f;
828   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
829                                                                                             380.0f,
830                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
831   xPositionOfControlBeingTested += 40.0f;
832
833   DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
834                                                                                             380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
835                                                                                             0.0001f, TEST_LOCATION );
836
837   xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
838   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
839
840   const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
841   tet_printf( "\nChanging Padding to control at index 1 \n" );
842   controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
843
844   // Ensure layouting happens
845   application.SendNotification();
846   application.Render();
847
848   xPositionOfControlBeingTested = 0.0f; // reset
849
850   tet_infoline("Test Child Actor Position");
851   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
852                                                                                             380.0f,
853                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
854   xPositionOfControlBeingTested += 40.0f;
855
856   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
857                                                                                             380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
858                                                                                             0.0001f, TEST_LOCATION );
859
860   xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
861   tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
862   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
863
864   tet_infoline("Test Child Actor Size");
865   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
866
867   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
868                                                                                         40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
869                                                                                         0.0001f, TEST_LOCATION );
870
871   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
872
873   END_TEST;
874 }
875
876 int UtcDaliLayouting_HboxLayout_Padding04(void)
877 {
878   ToolkitTestApplication application;
879   tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
880
881   // Adding padding to the layout should offset the positioning of the children.
882
883   const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
884   const Size CONTROL_SIZE = Size( 40, 40 );
885
886   Stage stage = Stage::GetCurrent();
887   // Create a root layout, ideally Dali would have a default layout in the root layer.
888   // Without this root layer the LinearLayout (or any other layout) will not
889   // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
890   // It uses the default stage size and ideally should have a layout added to it.
891   auto rootLayoutControl = Control::New();
892   rootLayoutControl.SetName( "AbsoluteLayout");
893   auto rootLayout = AbsoluteLayout::New();
894   DevelControl::SetLayout( rootLayoutControl, rootLayout );
895   rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
896   rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
897   stage.Add( rootLayoutControl );
898
899   auto hbox = Control::New();
900   auto hboxLayout = LinearLayout::New();
901   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
902   DevelControl::SetLayout( hbox, hboxLayout );
903   hbox.SetName( "HBox");
904   hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
905   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
906   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
907
908   std::vector< Control > controls;
909   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
910   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
911   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
912   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
913
914   for( auto&& iter : controls )
915   {
916     hbox.Add( iter );
917   }
918
919   hbox.SetParentOrigin( ParentOrigin::CENTER );
920   hbox.SetAnchorPoint( AnchorPoint::CENTER );
921   rootLayoutControl.Add( hbox );
922
923   // Ensure layouting happens
924   application.SendNotification();
925   application.Render();
926
927   // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
928   application.SendNotification();
929
930   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
931   // hbox left justifies elements
932   tet_infoline("Test Child Actor Position");
933
934   auto controlXPosition=0.0f;
935
936   controlXPosition = LAYOUT_PADDING.start;  // First child positioned at offset defined by the padding
937   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
938                                                                                             LAYOUT_PADDING.top,
939                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
940
941   controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
942   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
943                                                                                             LAYOUT_PADDING.top,
944                                                                                             0.0f ),
945                                                                                             0.0001f, TEST_LOCATION );
946
947   controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
948   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
949                                                                                             LAYOUT_PADDING.top,
950                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
951
952   controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
953   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
954                                                                                             LAYOUT_PADDING.top,
955                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
956
957   auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
958   auto totalControlsHeight = CONTROL_SIZE.height;
959
960   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
961                                                                                  totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
962                                                                                  0.0f ), 0.0001f, TEST_LOCATION );
963
964
965   END_TEST;
966 }
967
968 int UtcDaliLayouting_HboxLayout_Padding05(void)
969 {
970   ToolkitTestApplication application;
971   tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
972
973   // Adding padding to the layout should offset the positioning of the children.
974
975   const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
976   const Size CONTROL_SIZE = Size( 40, 40 );
977
978   Stage stage = Stage::GetCurrent();
979   // Create a root layout, ideally Dali would have a default layout in the root layer.
980   // Without this root layer the LinearLayout (or any other layout) will not
981   // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
982   // It uses the default stage size and ideally should have a layout added to it.
983   auto rootLayoutControl = Control::New();
984   rootLayoutControl.SetName( "AbsoluteLayout");
985   auto rootLayout = AbsoluteLayout::New();
986   DevelControl::SetLayout( rootLayoutControl, rootLayout );
987   rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
988   rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
989   stage.Add( rootLayoutControl );
990
991   auto hbox = Control::New();
992   auto hboxLayout = LinearLayout::New();
993   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
994   DevelControl::SetLayout( hbox, hboxLayout );
995   hbox.SetName( "HBox");
996   hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
997   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
998   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
999
1000   std::vector< Control > controls;
1001   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1002   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1003   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1004   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1005
1006   for( auto&& iter : controls )
1007   {
1008     hbox.Add( iter );
1009   }
1010
1011   hbox.SetParentOrigin( ParentOrigin::CENTER );
1012   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1013   rootLayoutControl.Add( hbox );
1014
1015   // Ensure layouting happens
1016   application.SendNotification();
1017   application.Render();
1018
1019   // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1020   application.SendNotification();
1021
1022   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1023   // hbox left justifies elements
1024   tet_infoline("Test Child Actor Position");
1025
1026   auto controlXPosition=0.0f;
1027
1028   controlXPosition = LAYOUT_PADDING.start;  // First child positioned at offset defined by the padding
1029   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1030                                                                                             LAYOUT_PADDING.top,
1031                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1032
1033   controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1034   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1035                                                                                             LAYOUT_PADDING.top,
1036                                                                                             0.0f ),
1037                                                                                             0.0001f, TEST_LOCATION );
1038
1039   controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1040   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1041                                                                                             LAYOUT_PADDING.top,
1042                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1043
1044   controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1045   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1046                                                                                             LAYOUT_PADDING.top,
1047                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1048
1049   auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1050   auto totalControlsHeight = CONTROL_SIZE.height;
1051
1052   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1053                                                                                  totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1054                                                                                  0.0f ), 0.0001f, TEST_LOCATION );
1055
1056   // Change layout padding
1057   const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
1058   tet_printf( "\nChanging Padding to control at index 1 \n" );
1059   hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
1060
1061   // Ensure layouting happens
1062   application.SendNotification();
1063   application.Render();
1064
1065   // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1066   application.SendNotification();
1067
1068   controlXPosition = NEW_LAYOUT_PADDING.start;  // First child positioned at offset defined by the padding
1069   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
1070                                                                                             NEW_LAYOUT_PADDING.top,
1071                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1072
1073   controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1074   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1075                                                                                             NEW_LAYOUT_PADDING.top,
1076                                                                                             0.0f ),
1077                                                                                             0.0001f, TEST_LOCATION );
1078
1079   controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1080   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1081                                                                                             NEW_LAYOUT_PADDING.top,
1082                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1083
1084   controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1085   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1086                                                                                             NEW_LAYOUT_PADDING.top,
1087                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1088   totalControlsWidth = CONTROL_SIZE.width * controls.size();
1089   totalControlsHeight = CONTROL_SIZE.height;
1090
1091   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
1092                                                                                  totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
1093                                                                                  0.0f ), 0.0001f, TEST_LOCATION );
1094   END_TEST;
1095 }
1096
1097 // Margin Tests
1098
1099 int UtcDaliLayouting_HboxLayout_Margin01(void)
1100 {
1101   ToolkitTestApplication application;
1102   tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
1103
1104   Stage stage = Stage::GetCurrent();
1105   auto hbox = Control::New();
1106   auto hboxLayout = LinearLayout::New();
1107   DevelControl::SetLayout( hbox, hboxLayout );
1108   hbox.SetName( "HBox");
1109
1110   std::vector< Control > controls;
1111   controls.push_back( CreateLeafControl( 40, 40 ) );
1112   controls.push_back( CreateLeafControl( 60, 40 ) );
1113   controls.push_back( CreateLeafControl( 80, 40 ) );
1114   controls.push_back( CreateLeafControl( 100, 40 ) );
1115
1116   const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
1117   tet_printf( "\nAdding Margin to control at index 1 \n" );
1118   controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1119
1120   for( auto&& iter : controls )
1121   {
1122     hbox.Add( iter );
1123   }
1124   hbox.SetParentOrigin( ParentOrigin::CENTER );
1125   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1126   stage.Add( hbox );
1127
1128   // Ensure layouting happens
1129   application.SendNotification();
1130   application.Render();
1131
1132   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1133   // hbox left justifies elements
1134   tet_infoline("Test Child Actor Position");
1135   auto xPositionOfControlBeingTested = 0.0f;
1136   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1137                                                                                             380.0f,
1138                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1139   xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
1140
1141   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1142                                                                                             380.0f + CONTROL_MARGIN.top, 0.0f ),
1143                                                                                             0.0001f, TEST_LOCATION );
1144
1145   xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
1146   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1147
1148   xPositionOfControlBeingTested += 80.0f;
1149   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1150
1151   tet_infoline("Test Child Actor Size is the same after Margin added");
1152   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1153   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
1154   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1155   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1156
1157   END_TEST;
1158 }
1159
1160
1161 int UtcDaliLayouting_VboxLayout01(void)
1162 {
1163   ToolkitTestApplication application;
1164   tet_infoline(" UtcDaliLayouting_VboxLayout01");
1165
1166   Stage stage = Stage::GetCurrent();
1167   auto vbox = Control::New();
1168   auto vboxLayout = LinearLayout::New();
1169   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1170   DevelControl::SetLayout( vbox, vboxLayout );
1171   vbox.SetName( "Vbox");
1172
1173   std::vector< Control > controls;
1174   controls.push_back( CreateLeafControl( 40, 40 ) );
1175   controls.push_back( CreateLeafControl( 60, 60 ) );
1176   controls.push_back( CreateLeafControl( 80, 80 ) );
1177   controls.push_back( CreateLeafControl( 100, 100 ) );
1178
1179   for( auto&& iter : controls )
1180   {
1181     vbox.Add( iter );
1182   }
1183   vbox.SetParentOrigin( ParentOrigin::CENTER );
1184   vbox.SetAnchorPoint( AnchorPoint::CENTER );
1185   stage.Add( vbox );
1186
1187   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1188
1189   // Check it.
1190   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1191
1192   // Ensure layouting happens
1193   application.SendNotification();
1194   application.Render();
1195
1196   // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
1197   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1198   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1199   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1200   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1201
1202   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1203   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1204   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1205   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1206
1207   END_TEST;
1208 }
1209
1210 int UtcDaliLayouting_VboxLayout02(void)
1211 {
1212   ToolkitTestApplication application;
1213   tet_infoline(" UtcDaliLayouting_VboxLayout01");
1214
1215   Stage stage = Stage::GetCurrent();
1216
1217   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1218   // LayoutGroup for this to happen automatically.
1219   //
1220   // For this test, add an hbox instead
1221   auto rootControl = Control::New();
1222   auto absoluteLayout = AbsoluteLayout::New();
1223   DevelControl::SetLayout( rootControl, absoluteLayout );
1224   rootControl.SetName( "AbsoluteLayout");
1225   stage.Add( rootControl );
1226
1227   auto vbox = Control::New();
1228   auto vboxLayout = LinearLayout::New();
1229   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1230   DevelControl::SetLayout( vbox, vboxLayout );
1231   vbox.SetName( "Vbox");
1232   rootControl.Add( vbox );
1233
1234   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1235   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1236
1237   std::vector< Control > controls;
1238   controls.push_back( CreateLeafControl( 40, 40 ) );
1239   controls.push_back( CreateLeafControl( 60, 60 ) );
1240   controls.push_back( CreateLeafControl( 80, 80 ) );
1241   controls.push_back( CreateLeafControl( 100, 100 ) );
1242
1243   for( auto&& iter : controls )
1244   {
1245     vbox.Add( iter );
1246   }
1247   vbox.SetParentOrigin( ParentOrigin::CENTER );
1248   vbox.SetAnchorPoint( AnchorPoint::CENTER );
1249
1250   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1251
1252   // Check it.
1253   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1254
1255   // Ensure layouting happens
1256   application.SendNotification();
1257   application.Render();
1258
1259   DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1260   DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1261
1262   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1263   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1264   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1265
1266   // 3rd control is set to match parent - this should also be 100 wide
1267   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1268   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1269   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1270   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1271
1272   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1273   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1274   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1275   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1276
1277   END_TEST;
1278 }
1279
1280
1281 int UtcDaliLayouting_VboxLayout03(void)
1282 {
1283   ToolkitTestApplication application;
1284   tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
1285
1286   Stage stage = Stage::GetCurrent();
1287
1288   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1289   // LayoutGroup for this to happen automatically.
1290   //
1291   // For this test, add an hbox instead
1292   auto hbox = Control::New();
1293   auto hboxLayout = LinearLayout::New();
1294   DevelControl::SetLayout( hbox, hboxLayout );
1295   hbox.SetName( "Hbox");
1296   stage.Add( hbox );
1297
1298   auto vbox = Control::New();
1299   auto vboxLayout = LinearLayout::New();
1300   vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
1301   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1302
1303   DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
1304
1305   DevelControl::SetLayout( vbox, vboxLayout );
1306   vbox.SetName( "Vbox");
1307   hbox.Add( vbox );
1308
1309   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1310   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1311
1312   std::vector< Control > controls;
1313   controls.push_back( CreateLeafControl( 40, 40 ) );
1314   controls.push_back( CreateLeafControl( 60, 60 ) );
1315   controls.push_back( CreateLeafControl( 80, 80 ) );
1316   controls.push_back( CreateLeafControl( 100, 100 ) );
1317
1318   for( auto&& iter : controls )
1319   {
1320     vbox.Add( iter );
1321   }
1322   vbox.SetParentOrigin( ParentOrigin::CENTER );
1323   vbox.SetAnchorPoint( AnchorPoint::CENTER );
1324
1325   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1326
1327   // Check it.
1328   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1329
1330   // Ensure layouting happens
1331   application.SendNotification();
1332   application.Render();
1333
1334   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1335   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1336
1337   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1338   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1339   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1340
1341   // 3rd control is set to match parent - this should also be 100 wide
1342   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1343   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1344   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1345   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1346
1347   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1348   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1349   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1350   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1351
1352   END_TEST;
1353 }
1354
1355
1356
1357 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
1358 {
1359   ToolkitTestApplication application;
1360   tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
1361   tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
1362
1363   Stage stage = Stage::GetCurrent();
1364
1365   auto hbox = Control::New();
1366   auto hboxLayout = Test::CustomLayout::New();
1367   DevelControl::SetLayout( hbox, hboxLayout );
1368   hbox.SetName( "HBox");
1369
1370   std::vector< Control > controls;
1371   controls.push_back( CreateLeafControl( 40, 40 ) );
1372   controls.push_back( CreateLeafControl( 60, 40 ) );
1373   controls.push_back( CreateLeafControl( 80, 40 ) );
1374   controls.push_back( CreateLeafControl( 100, 40 ) );
1375
1376   for( auto&& iter : controls )
1377   {
1378     hbox.Add( iter );
1379   }
1380   hbox.SetParentOrigin( ParentOrigin::CENTER );
1381   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1382   stage.Add( hbox );
1383
1384   // Ensure layouting happens
1385   application.SendNotification();
1386   application.Render();
1387
1388   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1389   // hbox left justifies elements
1390   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1391   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1392   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1393   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1394
1395   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1396   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1397   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1398   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1399
1400   controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
1401   controls[2].Lower();      // 2->1; 2, 1, 3, 0
1402
1403   application.SendNotification();
1404   application.Render();
1405
1406   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1407   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1408   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1409   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1410
1411   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1412   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1413   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1414   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1415
1416   END_TEST;
1417 }
1418
1419 int UtcDaliLayouting_HboxLayout_TargetSize(void)
1420 {
1421   ToolkitTestApplication application;
1422   tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
1423
1424   Stage stage = Stage::GetCurrent();
1425   auto hbox = Control::New();
1426   auto hboxLayout = LinearLayout::New();
1427   DevelControl::SetLayout( hbox, hboxLayout );
1428   hbox.SetName( "HBox");
1429
1430   std::vector< Control > controls;
1431   controls.push_back( CreateLeafControl( 40, 40 ) );
1432   for( auto&& iter : controls )
1433   {
1434     iter.SetSize( 100, 100 );
1435     hbox.Add( iter );
1436   }
1437   hbox.SetParentOrigin( ParentOrigin::CENTER );
1438   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1439   stage.Add( hbox );
1440
1441   // Ensure layouting happens
1442   application.SendNotification();
1443   application.Render();
1444
1445   // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
1446   // hbox left justifies elements
1447   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1448   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1449
1450   END_TEST;
1451 }
1452
1453 int UtcDaliLayouting_RemoveLayout01(void)
1454 {
1455   ToolkitTestApplication application;
1456   tet_infoline(" UtcDaliLayouting_RemoveLayout");
1457
1458   Stage stage = Stage::GetCurrent();
1459
1460   auto rootControl = Control::New();
1461   auto absoluteLayout = AbsoluteLayout::New();
1462   DevelControl::SetLayout( rootControl, absoluteLayout );
1463   rootControl.SetName( "AbsoluteLayout" );
1464   stage.Add( rootControl );
1465
1466   auto hbox = Control::New();
1467   auto hboxLayout = LinearLayout::New();
1468   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1469   DevelControl::SetLayout( hbox, hboxLayout );
1470   hbox.SetName( "HBox" );
1471
1472   std::vector< Control > controls;
1473   controls.push_back( CreateLeafControl( 40, 40 ) );
1474   controls.push_back( CreateLeafControl( 60, 40 ) );
1475
1476   for( auto&& iter : controls )
1477   {
1478     hbox.Add( iter );
1479   }
1480   hbox.SetParentOrigin( ParentOrigin::CENTER );
1481   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1482   rootControl.Add( hbox );
1483
1484   tet_infoline("Layout as normal");
1485   application.SendNotification();
1486   application.Render();
1487
1488   tet_infoline("Set an empty layout on hbox container");
1489   LinearLayout emptyLayout;
1490   DevelControl::SetLayout( hbox, emptyLayout );
1491
1492   tet_infoline("Run another layout");
1493   application.SendNotification();
1494   application.Render();
1495
1496   tet_infoline("Check leaf controls haven't moved");
1497
1498   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1499   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1500
1501   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1502   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1503
1504   END_TEST;
1505 }
1506
1507 int UtcDaliLayouting_LayoutChildren01(void)
1508 {
1509   ToolkitTestApplication application;
1510   tet_infoline(" UtcDaliLayouting_LayoutChildren01");
1511
1512   Stage stage = Stage::GetCurrent();
1513
1514   auto rootControl = Control::New();
1515   auto absoluteLayout = AbsoluteLayout::New();
1516   DevelControl::SetLayout( rootControl, absoluteLayout );
1517   stage.Add( rootControl );
1518
1519   auto hbox = Control::New();
1520   auto hboxLayout = LinearLayout::New();
1521   DevelControl::SetLayout( hbox, hboxLayout );
1522   rootControl.Add( hbox );
1523
1524   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1525
1526   tet_infoline("Test removal by setting empty layout to child container" );
1527   DevelControl::SetLayout( hbox, LayoutItem{} );
1528
1529   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
1530
1531   auto& hboxImpl = GetImplementation( hboxLayout );
1532   Handle empty;
1533   DALI_TEST_EQUALS( hboxLayout.GetOwner(), empty, TEST_LOCATION );
1534   DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
1535
1536   END_TEST;
1537 }
1538
1539 int UtcDaliLayouting_LayoutChildren02(void)
1540 {
1541   ToolkitTestApplication application;
1542   tet_infoline(" UtcDaliLayouting_LayoutChildren02");
1543
1544   Stage stage = Stage::GetCurrent();
1545
1546   auto rootControl = Control::New();
1547   auto absoluteLayout = AbsoluteLayout::New();
1548   DevelControl::SetLayout( rootControl, absoluteLayout );
1549   stage.Add( rootControl );
1550
1551   auto hbox = Control::New();
1552   auto hboxLayout = LinearLayout::New();
1553   DevelControl::SetLayout( hbox, hboxLayout );
1554   rootControl.Add( hbox );
1555
1556   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1557
1558   tet_infoline("Test removal by removing child actor from parent container" );
1559   hbox.Unparent();
1560
1561   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
1562
1563   auto& hboxImpl = GetImplementation( hboxLayout );
1564   tet_infoline("Test child actor still has hbox layout " );
1565   DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
1566
1567   tet_infoline("Test hbox layout has no parent " );
1568   DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
1569
1570   END_TEST;
1571 }
1572
1573 int UtcDaliLayouting_LayoutChildren03(void)
1574 {
1575   ToolkitTestApplication application;
1576   tet_infoline(" UtcDaliLayouting_LayoutChildren02");
1577
1578   Stage stage = Stage::GetCurrent();
1579
1580   auto rootControl = Control::New();
1581   auto absoluteLayout = AbsoluteLayout::New();
1582   DevelControl::SetLayout( rootControl, absoluteLayout );
1583   stage.Add( rootControl );
1584
1585   auto hbox = Control::New();
1586   auto hboxLayout = LinearLayout::New();
1587   DevelControl::SetLayout( hbox, hboxLayout );
1588   rootControl.Add( hbox );
1589
1590   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1591
1592   tet_infoline("Test removal by removing child layout from parent layout" );
1593   absoluteLayout.Remove( hboxLayout );
1594
1595   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
1596
1597   auto& hboxImpl = GetImplementation( hboxLayout );
1598
1599   tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
1600   DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
1601   DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
1602
1603   tet_infoline("Check orphaned layout has no parent");
1604   DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
1605
1606   END_TEST;
1607 }
1608
1609
1610 int UtcDaliLayouting_LayoutChildren04(void)
1611 {
1612   ToolkitTestApplication application;
1613   tet_infoline(" UtcDaliLayouting_LayoutChildren03");
1614
1615   Stage stage = Stage::GetCurrent();
1616
1617   auto rootControl = Control::New();
1618   auto absoluteLayout = AbsoluteLayout::New();
1619   DevelControl::SetLayout( rootControl, absoluteLayout );
1620   stage.Add( rootControl );
1621
1622   auto hbox = Control::New();
1623   tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
1624   auto hboxLayout = LinearLayout::New();
1625   rootControl.Add( hbox );
1626
1627   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1628
1629   tet_infoline("Then setting a layout on the child container");
1630   DevelControl::SetLayout( hbox, hboxLayout );
1631
1632   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1633
1634   auto& hboxImpl = GetImplementation( hboxLayout );
1635   auto& absImpl = GetImplementation( absoluteLayout );
1636   DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
1637   DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
1638
1639   END_TEST;
1640 }