Adding Absolute layout
[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/hbox-layout.h>
25 #include <dali-toolkit/devel-api/layouting/vbox-layout.h>
26 #include <dali-toolkit/devel-api/layouting/absolute-layout.h>
27
28 #include <layout-utils.h>
29
30 using namespace Dali;
31 using namespace Toolkit;
32
33 void utc_dali_toolkit_layouting_startup(void)
34 {
35   test_return_value = TET_UNDEF;
36 }
37
38 void utc_dali_toolkit_layouting_cleanup(void)
39 {
40   test_return_value = TET_PASS;
41 }
42
43 int UtcDaliLayouting_HboxLayout01(void)
44 {
45   ToolkitTestApplication application;
46   tet_infoline(" UtcDaliLayouting_HboxLayout01");
47
48   Stage stage = Stage::GetCurrent();
49   auto hbox = Control::New();
50   auto hboxLayout = HboxLayout::New();
51   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
52   DevelControl::SetLayout( hbox, hboxLayout );
53   hbox.SetName( "HBox");
54
55   std::vector< Control > controls;
56   controls.push_back( CreateLeafControl( 40, 40 ) );
57   controls.push_back( CreateLeafControl( 60, 40 ) );
58   controls.push_back( CreateLeafControl( 80, 40 ) );
59   controls.push_back( CreateLeafControl( 100, 40 ) );
60
61   for( auto&& iter : controls )
62   {
63     hbox.Add( iter );
64   }
65   hbox.SetParentOrigin( ParentOrigin::CENTER );
66   hbox.SetAnchorPoint( AnchorPoint::CENTER );
67   stage.Add( hbox );
68
69   // Ensure layouting happens
70   application.SendNotification();
71   application.Render();
72
73   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
74   // hbox left justifies elements
75   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
76   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
77   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
78   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
79
80   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
81   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
82   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
83   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
84
85   // Change a layout
86   auto newHBoxLayout = HboxLayout::New();
87   newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
88   DevelControl::SetLayout( hbox, newHBoxLayout );
89
90   application.SendNotification();
91   application.Render();
92
93   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
94   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
95   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
96   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
97
98   END_TEST;
99 }
100
101 int UtcDaliLayouting_HboxLayout02(void)
102 {
103   ToolkitTestApplication application;
104   tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
105
106   Stage stage = Stage::GetCurrent();
107
108   auto hbox1 = Control::New();
109   auto hboxLayout1 = HboxLayout::New();
110   DevelControl::SetLayout( hbox1, hboxLayout1 );
111
112   auto hbox2 = Control::New();
113   auto hboxLayout2 = HboxLayout::New();
114   DevelControl::SetLayout( hbox2, hboxLayout2 );
115
116   hbox1.SetName( "HBox1");
117   hbox2.SetName( "HBox2");
118
119   std::vector< Control > controls;
120   controls.push_back( CreateLeafControl( 20, 40 ) );
121   controls.push_back( CreateLeafControl( 30, 50 ) );
122   controls.push_back( CreateLeafControl( 40, 60 ) );
123   controls.push_back( CreateLeafControl( 50, 70 ) );
124
125   controls.push_back( CreateLeafControl( 25, 40 ) );
126   controls.push_back( CreateLeafControl( 35, 50 ) );
127   controls.push_back( CreateLeafControl( 45, 60 ) );
128   controls.push_back( CreateLeafControl( 55, 70 ) );
129
130   int counter=0;
131   for( auto&& iter : controls )
132   {
133     if( counter < 4 )
134     {
135       hbox1.Add( iter );
136     }
137     else
138     {
139       hbox2.Add( iter );
140     }
141     ++counter;
142   }
143   hbox1.SetParentOrigin( ParentOrigin::CENTER );
144   hbox1.SetAnchorPoint( AnchorPoint::CENTER );
145   hbox2.SetParentOrigin( ParentOrigin::CENTER );
146   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
147
148   auto hbox3 = Control::New();
149   auto hboxLayout3 = HboxLayout::New();
150   DevelControl::SetLayout( hbox3, hboxLayout3 );
151
152   hbox3.SetParentOrigin( ParentOrigin::CENTER );
153   hbox3.SetName( "HBox3");
154   hbox3.Add( hbox1 );
155   hbox3.Add( hbox2 );
156
157   stage.Add( hbox3 );
158
159   // Ensure layouting happens
160   application.SendNotification();
161   application.Render();
162
163
164   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
165   // hbox left justifies elements
166   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
167   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
168   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,  5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
169   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,  0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
170
171   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
172   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
173   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
174   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
175
176
177   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
178   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
179   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f,  5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
180   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,  0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
181
182   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
183   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
184   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
185   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
186
187   // Test hbox1 and 2 are sized to wrap their content
188   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
189   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
190   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
191   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
192
193   // Test hbox3 matches parent (root layer)
194   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
195   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
196
197   END_TEST;
198 }
199
200
201 int UtcDaliLayouting_HboxLayout03(void)
202 {
203   ToolkitTestApplication application;
204   tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
205
206   Stage stage = Stage::GetCurrent();
207
208   auto hbox1 = Control::New();
209   auto hboxLayout1 = HboxLayout::New();
210   DevelControl::SetLayout( hbox1, hboxLayout1 );
211
212   auto hbox2 = Control::New();
213   auto hboxLayout2 = HboxLayout::New();
214   DevelControl::SetLayout( hbox2, hboxLayout2 );
215
216   hbox1.SetName( "HBox1");
217   hbox2.SetName( "HBox2");
218   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
219   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
220   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
221   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
222
223   std::vector< Control > controls;
224   controls.push_back( CreateLeafControl( 20, 40 ) );
225   controls.push_back( CreateLeafControl( 30, 50 ) );
226   controls.push_back( CreateLeafControl( 40, 60 ) );
227   controls.push_back( CreateLeafControl( 50, 70 ) );
228
229   controls.push_back( CreateLeafControl( 25, 40 ) );
230   controls.push_back( CreateLeafControl( 35, 50 ) );
231   controls.push_back( CreateLeafControl( 45, 60 ) );
232   controls.push_back( CreateLeafControl( 55, 70 ) );
233
234   int counter=0;
235   for( auto&& iter : controls )
236   {
237     if( counter < 4 )
238     {
239       hbox1.Add( iter );
240     }
241     else
242     {
243       hbox2.Add( iter );
244     }
245     ++counter;
246   }
247   hbox1.SetParentOrigin( ParentOrigin::CENTER );
248   hbox1.SetAnchorPoint( AnchorPoint::CENTER );
249   hbox2.SetParentOrigin( ParentOrigin::CENTER );
250   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
251
252   auto hbox3 = Control::New();
253   auto hboxLayout3 = HboxLayout::New();
254   DevelControl::SetLayout( hbox3, hboxLayout3);
255
256   hbox3.SetParentOrigin( ParentOrigin::CENTER );
257   hbox3.SetName( "HBox3");
258   hbox3.Add( hbox1 );
259   hbox3.Add( hbox2 );
260
261   stage.Add( hbox3 );
262
263   //std::ostringstream oss;
264   //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
265   //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
266
267   // Ensure layouting happens
268   application.SendNotification();
269   application.Render();
270
271
272   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
273   // hbox left justifies elements
274   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
275   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
276   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
277   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
278
279   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
280   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
281   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
282   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
283
284   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
285   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
286   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
287   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
288
289   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
290   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
291   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
292   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
293
294   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
295   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
296   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
297   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
298
299   // Test hbox3 matches parent (root layer)
300   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
301   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
302
303   END_TEST;
304 }
305
306 int UtcDaliLayouting_HboxLayout04(void)
307 {
308   ToolkitTestApplication application;
309   tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
310
311   Stage stage = Stage::GetCurrent();
312
313   auto hbox1 = Control::New();
314   auto hboxLayout1 = HboxLayout::New();
315   DevelControl::SetLayout( hbox1, hboxLayout1 );
316
317   auto hbox2 = Control::New();
318   auto hboxLayout2 = HboxLayout::New();
319   DevelControl::SetLayout( hbox2, hboxLayout2 );
320
321   hbox1.SetName( "HBox1"); // Default spec is to wrap content
322   hbox2.SetName( "HBox2");
323   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
324   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
325   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
326   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
327
328   std::vector< Control > controls;
329   controls.push_back( CreateLeafControl( 80, 40 ) );
330   controls.push_back( CreateLeafControl( 80, 50 ) );
331   controls.push_back( CreateLeafControl( 80, 60 ) );
332   controls.push_back( CreateLeafControl( 80, 70 ) );
333
334   controls.push_back( CreateLeafControl( 80, 40 ) );
335   controls.push_back( CreateLeafControl( 80, 50 ) );
336   controls.push_back( CreateLeafControl( 80, 60 ) );
337   controls.push_back( CreateLeafControl( 80, 70 ) );
338
339   int counter=0;
340   for( auto&& iter : controls )
341   {
342     if( counter < 4 )
343     {
344       hbox1.Add( iter );
345     }
346     else
347     {
348       hbox2.Add( iter );
349     }
350     ++counter;
351   }
352
353   controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
354   auto hbox3 = Control::New();
355   auto hboxLayout3 = HboxLayout::New();
356   DevelControl::SetLayout( hbox3, hboxLayout3 );
357
358   hbox3.SetParentOrigin( ParentOrigin::CENTER );
359   hbox3.SetName( "HBox3");
360   hbox3.Add( hbox1 );
361   hbox3.Add( hbox2 );
362   stage.Add( hbox3 );
363
364   //std::ostringstream oss;
365   //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
366   //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
367
368   // Ensure layouting happens
369   application.SendNotification();
370   application.Render();
371
372
373   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
374   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
375   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
376   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
377
378   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
379   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
380   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
381   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
382
383   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
384   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
385   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
386   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
387
388   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
389   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
390   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
391   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
392
393   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
394   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
395   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
396   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
397
398
399   // Test hbox3 matches parent (root layer)
400   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
401   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
402
403   END_TEST;
404 }
405
406 int UtcDaliLayouting_HboxLayout05(void)
407 {
408   ToolkitTestApplication application;
409   tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
410
411   Stage stage = Stage::GetCurrent();
412   auto hbox = Control::New();
413   auto hboxLayout = HboxLayout::New();
414   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
415   DevelControl::SetLayout( hbox, hboxLayout );
416   hbox.SetName( "HBox");
417
418   std::vector< Control > controls;
419   controls.push_back( CreateLeafControl( 40, 40 ) );
420   controls.push_back( CreateLeafControl( 60, 40 ) );
421   controls.push_back( CreateLeafControl( 80, 40 ) );
422   controls.push_back( CreateLeafControl( 100, 40 ) );
423
424   for( auto&& iter : controls )
425   {
426     hbox.Add( iter );
427     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
428     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
429   }
430
431   hbox.SetParentOrigin( ParentOrigin::CENTER );
432   hbox.SetAnchorPoint( AnchorPoint::CENTER );
433   stage.Add( hbox );
434
435   // Ensure layouting happens
436   application.SendNotification();
437   application.Render();
438
439   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
440   // hbox left justifies elements
441   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
442   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
443   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
444   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
445
446   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
447   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
448   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
449   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
450
451   END_TEST;
452 }
453
454 // Padding tests
455
456 int UtcDaliLayouting_HboxLayout_Padding01(void)
457 {
458   ToolkitTestApplication application;
459   tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
460
461   Stage stage = Stage::GetCurrent();
462   auto hbox = Control::New();
463   auto hboxLayout = HboxLayout::New();
464   DevelControl::SetLayout( hbox, hboxLayout );
465   hbox.SetName( "HBox");
466
467   std::vector< Control > controls;
468   controls.push_back( CreateLeafControl( 40, 40 ) );
469   controls.push_back( CreateLeafControl( 60, 40 ) );
470   controls.push_back( CreateLeafControl( 80, 40 ) );
471   controls.push_back( CreateLeafControl( 100, 40 ) );
472
473   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
474   tet_printf( "\nAdding Padding to control at index %u \n", 1 );
475   controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
476
477   for( auto&& iter : controls )
478   {
479     hbox.Add( iter );
480   }
481   hbox.SetParentOrigin( ParentOrigin::CENTER );
482   hbox.SetAnchorPoint( AnchorPoint::CENTER );
483   stage.Add( hbox );
484
485   // Ensure layouting happens
486   application.SendNotification();
487   application.Render();
488
489   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
490   // hbox left justifies elements
491   tet_infoline("Test Child Actor Position");
492   float xPositionOfControlBeingTested = 0.0f;
493   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
494                                                                                             380.0f,
495                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
496   xPositionOfControlBeingTested += 40.0f;
497
498   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
499                                                                                             380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
500                                                                                             0.0001f, TEST_LOCATION );
501
502   xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
503   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
504
505   xPositionOfControlBeingTested += 80.0f;
506   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
507
508   tet_infoline("Test Child Actor Size");
509   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
510
511   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
512                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
513                                                                                         0.0001f, TEST_LOCATION );
514
515   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
516   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
517
518   END_TEST;
519 }
520
521 int UtcDaliLayouting_HboxLayout_Padding02(void)
522 {
523   ToolkitTestApplication application;
524   tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
525
526   Stage stage = Stage::GetCurrent();
527   auto hbox = Control::New();
528   auto hboxLayout = HboxLayout::New();
529   DevelControl::SetLayout( hbox, hboxLayout );
530   hbox.SetName( "HBox");
531
532   std::vector< Control > controls;
533   controls.push_back( CreateLeafControl( 40, 40 ) );
534   controls.push_back( CreateLeafControl( 60, 40 ) );
535   controls.push_back( CreateLeafControl( 80, 40 ) );
536   controls.push_back( CreateLeafControl( 100, 40 ) );
537
538   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
539
540   for( auto&& iter : controls )
541   {
542     iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
543     hbox.Add( iter );
544   }
545   hbox.SetParentOrigin( ParentOrigin::CENTER );
546   hbox.SetAnchorPoint( AnchorPoint::CENTER );
547   stage.Add( hbox );
548
549   // Ensure layouting happens
550   application.SendNotification();
551   application.Render();
552
553   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
554   // hbox left justifies elements
555   tet_infoline("Test Child Actor Position");
556   float xPositionOfControlBeingTested = 0.0f;
557   float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
558
559   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
560                                                                                             yPositionOfControlBeingTested,
561                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
562   xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
563
564   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
565                                                                                             yPositionOfControlBeingTested,
566                                                                                             0.0f ),
567                                                                                             0.0001f, TEST_LOCATION );
568
569   xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
570   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
571                                                                                             yPositionOfControlBeingTested,
572                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
573
574   xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
575   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
576                                                                                             yPositionOfControlBeingTested,
577                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
578
579   tet_infoline("Test Child Actor Size");
580   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
581                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
582                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
583
584   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
585                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
586                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
587
588   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
589                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
590                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
591
592   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
593                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
594                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
595
596   END_TEST;
597 }
598
599
600 int UtcDaliLayouting_HboxLayout_Padding03(void)
601 {
602   ToolkitTestApplication application;
603   tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Adding Changing padding on a single child");
604
605   Stage stage = Stage::GetCurrent();
606   auto hbox = Control::New();
607   auto hboxLayout = HboxLayout::New();
608   DevelControl::SetLayout( hbox, hboxLayout );
609   hbox.SetName( "HBox");
610
611   std::vector< Control > controls;
612   controls.push_back( CreateLeafControl( 40, 40 ) );
613   controls.push_back( CreateLeafControl( 40, 40 ) );
614   controls.push_back( CreateLeafControl( 40, 40 ) );
615
616   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
617   tet_printf( "\nAdding Padding to control at index 1 \n" );
618   controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
619
620   for( auto&& iter : controls )
621   {
622     hbox.Add( iter );
623   }
624   hbox.SetParentOrigin( ParentOrigin::CENTER );
625   hbox.SetAnchorPoint( AnchorPoint::CENTER );
626   stage.Add( hbox );
627
628   // Ensure layouting happens
629   application.SendNotification();
630   application.Render();
631
632   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
633   // hbox left justifies elements
634   tet_infoline("Test Child Actor Position");
635   float xPositionOfControlBeingTested = 0.0f;
636   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
637                                                                                             380.0f,
638                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
639   xPositionOfControlBeingTested += 40.0f;
640
641   DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
642                                                                                             380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
643                                                                                             0.0001f, TEST_LOCATION );
644
645   xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
646   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
647
648   const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
649   tet_printf( "\nChanging Padding to control at index 1 \n" );
650   controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
651
652   // Ensure layouting happens
653   application.SendNotification();
654   application.Render();
655
656   xPositionOfControlBeingTested = 0.0f; // reset
657
658   tet_infoline("Test Child Actor Position");
659   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
660                                                                                             380.0f,
661                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
662   xPositionOfControlBeingTested += 40.0f;
663
664   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
665                                                                                             380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
666                                                                                             0.0001f, TEST_LOCATION );
667
668   xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
669   tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
670   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
671
672   tet_infoline("Test Child Actor Size");
673   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
674
675   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
676                                                                                         40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
677                                                                                         0.0001f, TEST_LOCATION );
678
679   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
680
681   END_TEST;
682 }
683
684 // Margin Tests
685
686 int UtcDaliLayouting_HboxLayout_Margin01(void)
687 {
688   ToolkitTestApplication application;
689   tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
690
691   Stage stage = Stage::GetCurrent();
692   auto hbox = Control::New();
693   auto hboxLayout = HboxLayout::New();
694   DevelControl::SetLayout( hbox, hboxLayout );
695   hbox.SetName( "HBox");
696
697   std::vector< Control > controls;
698   controls.push_back( CreateLeafControl( 40, 40 ) );
699   controls.push_back( CreateLeafControl( 60, 40 ) );
700   controls.push_back( CreateLeafControl( 80, 40 ) );
701   controls.push_back( CreateLeafControl( 100, 40 ) );
702
703   const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
704   tet_printf( "\nAdding Margin to control at index 1 \n" );
705   controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
706
707   for( auto&& iter : controls )
708   {
709     hbox.Add( iter );
710   }
711   hbox.SetParentOrigin( ParentOrigin::CENTER );
712   hbox.SetAnchorPoint( AnchorPoint::CENTER );
713   stage.Add( hbox );
714
715   // Ensure layouting happens
716   application.SendNotification();
717   application.Render();
718
719   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
720   // hbox left justifies elements
721   tet_infoline("Test Child Actor Position");
722   auto xPositionOfControlBeingTested = 0.0f;
723   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
724                                                                                             380.0f,
725                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
726   xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
727
728   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
729                                                                                             380.0f + CONTROL_MARGIN.top, 0.0f ),
730                                                                                             0.0001f, TEST_LOCATION );
731
732   xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
733   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
734
735   xPositionOfControlBeingTested += 80.0f;
736   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
737
738   tet_infoline("Test Child Actor Size is the same after Margin added");
739   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
740   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
741   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
742   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
743
744   END_TEST;
745 }
746
747
748 int UtcDaliLayouting_VboxLayout01(void)
749 {
750   ToolkitTestApplication application;
751   tet_infoline(" UtcDaliLayouting_VboxLayout01");
752
753   Stage stage = Stage::GetCurrent();
754   auto vbox = Control::New();
755   auto vboxLayout = VboxLayout::New();
756   DevelControl::SetLayout( vbox, vboxLayout );
757   vbox.SetName( "Vbox");
758
759   std::vector< Control > controls;
760   controls.push_back( CreateLeafControl( 40, 40 ) );
761   controls.push_back( CreateLeafControl( 60, 60 ) );
762   controls.push_back( CreateLeafControl( 80, 80 ) );
763   controls.push_back( CreateLeafControl( 100, 100 ) );
764
765   for( auto&& iter : controls )
766   {
767     vbox.Add( iter );
768   }
769   vbox.SetParentOrigin( ParentOrigin::CENTER );
770   vbox.SetAnchorPoint( AnchorPoint::CENTER );
771   stage.Add( vbox );
772
773   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
774
775   // Check it.
776   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
777
778   // Ensure layouting happens
779   application.SendNotification();
780   application.Render();
781
782   // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
783   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
784   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
785   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
786   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
787
788   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
789   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
790   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
791   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
792
793   END_TEST;
794 }
795
796 int UtcDaliLayouting_VboxLayout02(void)
797 {
798   ToolkitTestApplication application;
799   tet_infoline(" UtcDaliLayouting_VboxLayout01");
800
801   Stage stage = Stage::GetCurrent();
802
803   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
804   // LayoutGroup for this to happen automatically.
805   //
806   // For this test, add an hbox instead
807   auto rootControl = Control::New();
808   auto absoluteLayout = AbsoluteLayout::New();
809   DevelControl::SetLayout( rootControl, absoluteLayout );
810   rootControl.SetName( "AbsoluteLayout");
811   stage.Add( rootControl );
812
813   auto vbox = Control::New();
814   auto vboxLayout = VboxLayout::New();
815   DevelControl::SetLayout( vbox, vboxLayout );
816   vbox.SetName( "Vbox");
817   rootControl.Add( vbox );
818
819   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
820   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
821
822   std::vector< Control > controls;
823   controls.push_back( CreateLeafControl( 40, 40 ) );
824   controls.push_back( CreateLeafControl( 60, 60 ) );
825   controls.push_back( CreateLeafControl( 80, 80 ) );
826   controls.push_back( CreateLeafControl( 100, 100 ) );
827
828   for( auto&& iter : controls )
829   {
830     vbox.Add( iter );
831   }
832   vbox.SetParentOrigin( ParentOrigin::CENTER );
833   vbox.SetAnchorPoint( AnchorPoint::CENTER );
834
835   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
836
837   // Check it.
838   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
839
840   // Ensure layouting happens
841   application.SendNotification();
842   application.Render();
843
844   DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
845   DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
846
847   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
848   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
849   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
850
851   // 3rd control is set to match parent - this should also be 100 wide
852   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
853   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
854   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
855   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
856
857   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
858   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
859   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
860   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
861
862   END_TEST;
863 }
864
865
866 int UtcDaliLayouting_VboxLayout03(void)
867 {
868   ToolkitTestApplication application;
869   tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
870
871   Stage stage = Stage::GetCurrent();
872
873   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
874   // LayoutGroup for this to happen automatically.
875   //
876   // For this test, add an hbox instead
877   auto hbox = Control::New();
878   auto hboxLayout = HboxLayout::New();
879   DevelControl::SetLayout( hbox, hboxLayout );
880   hbox.SetName( "Hbox");
881   stage.Add( hbox );
882
883   auto vbox = Control::New();
884   auto vboxLayout = VboxLayout::New();
885   vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
886
887   DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
888
889   DevelControl::SetLayout( vbox, vboxLayout );
890   vbox.SetName( "Vbox");
891   hbox.Add( vbox );
892
893   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
894   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
895
896   std::vector< Control > controls;
897   controls.push_back( CreateLeafControl( 40, 40 ) );
898   controls.push_back( CreateLeafControl( 60, 60 ) );
899   controls.push_back( CreateLeafControl( 80, 80 ) );
900   controls.push_back( CreateLeafControl( 100, 100 ) );
901
902   for( auto&& iter : controls )
903   {
904     vbox.Add( iter );
905   }
906   vbox.SetParentOrigin( ParentOrigin::CENTER );
907   vbox.SetAnchorPoint( AnchorPoint::CENTER );
908
909   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
910
911   // Check it.
912   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
913
914   // Ensure layouting happens
915   application.SendNotification();
916   application.Render();
917
918   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
919   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
920
921   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
922   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
923   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
924
925   // 3rd control is set to match parent - this should also be 100 wide
926   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
927   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
928   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
929   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
930
931   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
932   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
933   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
934   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
935
936   END_TEST;
937 }