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