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