Merge "Do not substarct outline width in text-controller" 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 #include <toolkit-event-thread-callback.h>
22
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/control-devel.h>
25 #include <dali-toolkit/devel-api/layouting/absolute-layout.h>
26 #include <dali-toolkit/devel-api/layouting/linear-layout.h>
27 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
28 #include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
29 #include <dali/devel-api/actors/actor-devel.h>
30
31 #include <../custom-layout.h>
32
33 #include <layout-utils.h>
34
35 using namespace Dali;
36 using namespace Toolkit;
37
38 namespace
39 {
40
41 void TestLayoutItemOrder( std::vector< Control >& controls, LayoutGroup& layoutGroup )
42 {
43   for( auto&& iter : controls )
44   {
45     unsigned int siblingOrder = static_cast< unsigned int>( iter.GetProperty< int >( DevelActor::Property::SIBLING_ORDER ) );
46     DALI_TEST_EQUALS( layoutGroup.GetChildAt( siblingOrder ), DevelControl::GetLayout( iter ), TEST_LOCATION );
47   }
48 }
49
50 // Turns the given control into a Root layout control and adds it to the stage.
51 void SetupRootLayoutControl( Control& rootControl )
52 {
53   rootControl = Control::New();
54   auto absoluteLayout = AbsoluteLayout::New();
55   DevelControl::SetLayout( rootControl, absoluteLayout );
56   rootControl.SetName( "RootAbsoluteLayout" );
57   Stage stage = Stage::GetCurrent();
58   stage.Add( rootControl );
59 }
60
61 } // unnamed namespace
62
63 void utc_dali_toolkit_layouting_startup(void)
64 {
65   test_return_value = TET_UNDEF;
66 }
67
68 void utc_dali_toolkit_layouting_cleanup(void)
69 {
70   test_return_value = TET_PASS;
71 }
72
73 int UtcDaliLayouting_LayoutLength_Types(void)
74 {
75   tet_infoline("UtcDaliLayouting_LayoutLength Types");
76
77   // testing that operators return correct type
78   // operator+
79   {
80     auto value = LayoutLength( 10 ) + LayoutLength();
81     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
82   }
83   {
84     auto value = LayoutLength( 10 ) + 20;
85     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
86   }
87   {
88     auto value = 22 + LayoutLength( 10 );
89     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
90   }
91   {
92     auto value = LayoutLength( 10 ) + 2.1f;
93     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
94   }
95   {
96     auto value = 2.2f + LayoutLength( 10 );
97     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
98   }
99   // operator-
100   {
101     auto value = LayoutLength() - LayoutLength( 10 );
102     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
103   }
104   {
105     auto value = LayoutLength( 10 ) - 99;
106     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
107   }
108   {
109     auto value = 20 - LayoutLength( 10 );
110     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
111   }
112   {
113     auto value = LayoutLength( 10 ) - 9.9f;
114     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
115   }
116   {
117     auto value = 2.0f - LayoutLength( 10 );
118     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
119   }
120
121   // operator*
122   {
123     auto value = LayoutLength() * LayoutLength( 10 );
124     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
125   }
126   {
127     auto value = LayoutLength( 10 ) * 2;
128     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
129   }
130   {
131     auto value = 10 * LayoutLength( 10 );
132     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
133   }
134   {
135     auto value = LayoutLength( 10 ) * 2.1f;
136     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
137   }
138   {
139     auto value = 1.0f * LayoutLength( 10 );
140     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
141   }
142   // operator/
143   {
144     auto value = LayoutLength( 10 ) / 2.0f;
145     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
146   }
147
148   // combinations
149   {
150     auto value = ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
151     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
152   }
153   {
154     auto value = 20 + ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
155     DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
156   }
157
158   END_TEST;
159 }
160
161 int UtcDaliLayouting_LayoutLength_Values(void)
162 {
163   tet_infoline("UtcDaliLayouting_LayoutLength Values");
164
165   // operator+
166   {
167     LayoutLength value = LayoutLength( 10 ) + LayoutLength();
168     DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
169   }
170   {
171     LayoutLength value = LayoutLength( 10 ) + 20;
172     DALI_TEST_EQUALS( value.AsInteger(), 30.0f, 0.0001f, TEST_LOCATION );
173   }
174   {
175     LayoutLength value = 22 - LayoutLength( 10 );
176     DALI_TEST_EQUALS( value.AsInteger(), 12.0f, 0.0001f, TEST_LOCATION );
177   }
178   {
179     LayoutLength value = LayoutLength( 10 ) + 2.1f;
180     DALI_TEST_EQUALS( value.AsDecimal(), 12.1f, 0.0001f, TEST_LOCATION );
181     DALI_TEST_EQUALS( value.AsTruncated(), 12.0f, 0.0001f, TEST_LOCATION );
182   }
183   {
184     LayoutLength value = 2.3f - LayoutLength( 10 );
185     DALI_TEST_EQUALS( value.AsDecimal(), -7.7f, 0.0001f, TEST_LOCATION );
186     DALI_TEST_EQUALS( value.AsInteger(), -8.0f, 0.0001f, TEST_LOCATION );
187     DALI_TEST_EQUALS( value.AsTruncated(), -7.0f, 0.0001f, TEST_LOCATION );
188   }
189   // operator-
190   {
191     LayoutLength value = LayoutLength() - LayoutLength( 10 );
192     DALI_TEST_EQUALS( value.AsInteger(), -10.0f, 0.0001f, TEST_LOCATION );
193   }
194   {
195     LayoutLength value = LayoutLength( 10 ) - 99;
196     DALI_TEST_EQUALS( value.AsInteger(), -89.0f, 0.0001f, TEST_LOCATION );
197   }
198   {
199     LayoutLength value = 20 - LayoutLength( 10 );
200     DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
201     DALI_TEST_EQUALS( value.AsTruncated(), 10.f, 0.0001f, TEST_LOCATION );
202   }
203   {
204     LayoutLength value = LayoutLength( 10 ) - 9.9f;
205     DALI_TEST_EQUALS( value.AsInteger(), 0.0f, 0.0001f, TEST_LOCATION );
206     DALI_TEST_EQUALS( value.AsDecimal(), 0.1f, 0.0001f, TEST_LOCATION );
207     DALI_TEST_EQUALS( value.AsTruncated(), 0.0f, 0.0001f, TEST_LOCATION );
208   }
209   {
210     LayoutLength value = 10.9f - LayoutLength( 10 );
211     DALI_TEST_EQUALS( value.AsInteger(), 1.0f, 0.0001f, TEST_LOCATION );
212     DALI_TEST_EQUALS( value.AsDecimal(), 0.9f, 0.0001f, TEST_LOCATION );
213     DALI_TEST_EQUALS( value.AsTruncated(), 0.0f, 0.0001f, TEST_LOCATION );
214   }
215   // operator*
216   {
217     LayoutLength value = LayoutLength() * LayoutLength( 10 );
218     DALI_TEST_EQUALS( value.AsInteger(), 0.0f, 0.0001f, TEST_LOCATION );
219   }
220   {
221     LayoutLength value = LayoutLength(1) * 10;
222     DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
223   }
224   {
225     LayoutLength value = 11 * LayoutLength( 10 );
226     DALI_TEST_EQUALS( value.AsInteger(), 110.0f, 0.0001f, TEST_LOCATION );
227   }
228   {
229     LayoutLength value = LayoutLength( 10 ) * 2.12f;
230     DALI_TEST_EQUALS( value.AsDecimal(), 21.2f, 0.0001f, TEST_LOCATION );
231     DALI_TEST_EQUALS( value.AsInteger(), 21.0f, 0.0001f, TEST_LOCATION );
232     DALI_TEST_EQUALS( value.AsTruncated(), 21.0f, 0.0001f, TEST_LOCATION );
233   }
234   {
235     LayoutLength value = 2.189f * LayoutLength( 10 );
236     DALI_TEST_EQUALS( value.AsDecimal(), 21.89f, 0.0001f, TEST_LOCATION );
237     DALI_TEST_EQUALS( value.AsInteger(), 22.0f, 0.0001f, TEST_LOCATION );
238     DALI_TEST_EQUALS( value.AsTruncated(), 21.0f, 0.0001f, TEST_LOCATION );
239   }
240   // operator/
241   {
242     LayoutLength value = LayoutLength( 11 ) / 2.0f;
243     DALI_TEST_EQUALS( value.AsDecimal(), 5.5f, 0.0001f, TEST_LOCATION );
244     DALI_TEST_EQUALS( value.AsInteger(), 6.0f, 0.0001f, TEST_LOCATION );
245   }
246
247   // combinations
248   {
249     LayoutLength value;
250     value = 20 + ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
251     DALI_TEST_EQUALS( value.AsInteger(), 33.0f, 0.0001f, TEST_LOCATION );
252     DALI_TEST_EQUALS( value.AsDecimal(), 33.3333f, 0.0001f, TEST_LOCATION );
253   }
254   {
255     uint16_t padding( 1 );
256     LayoutLength right(35), left(10), mTotalLength(2);
257     LayoutLength value;
258     value = padding + ( right - left - mTotalLength ) / 2.0f;
259     //    = 1 + ( 35 - 10 - 2 ) / 2
260     DALI_TEST_EQUALS( value.AsInteger(), 13.0f, 0.0001f, TEST_LOCATION );
261     DALI_TEST_EQUALS( value.AsDecimal(), 12.5f, 0.0001f, TEST_LOCATION );
262   }
263   {
264     uint16_t padding = 1, top = 2, bottom = 3;
265     LayoutLength childSpace( 44 ), childHeight( 23 );
266     LayoutLength value;
267     value = padding + ( ( childSpace - childHeight ) / 2.0f ) + top - bottom;
268     //    = 1       + ( ( 44 - 23                  ) / 2 ) + 2 - 3
269     DALI_TEST_EQUALS( value.AsInteger(), 11.0f, 0.0001f, TEST_LOCATION );
270     DALI_TEST_EQUALS( value.AsDecimal(), 10.5f, 0.0001f, TEST_LOCATION );
271   }
272
273   END_TEST;
274 }
275
276 int UtcDaliLayouting_LayoutLength_Operators(void)
277 {
278   tet_infoline("UtcDaliLayouting_LayoutLength operators");
279
280   {
281     LayoutLength value = 10;
282     DALI_TEST_EQUALS( (int)value.AsInteger(), 10, TEST_LOCATION );
283     value += 1;
284     DALI_TEST_EQUALS( (int)value.AsInteger(), 11, TEST_LOCATION );
285     value -= 12;
286     DALI_TEST_EQUALS( (int)value.AsInteger(), -1, TEST_LOCATION );
287     LayoutLength value2 = value;
288     DALI_TEST_EQUALS( value == value2, true, TEST_LOCATION );
289     value2 = 123;
290     DALI_TEST_EQUALS( value != value2, true, TEST_LOCATION );
291     DALI_TEST_EQUALS( value < value2, true, TEST_LOCATION );
292     DALI_TEST_EQUALS( value <= value2, true, TEST_LOCATION );
293     value = 456;
294     DALI_TEST_EQUALS( value > value2, true, TEST_LOCATION );
295     DALI_TEST_EQUALS( value >= value2, true, TEST_LOCATION );
296   }
297
298   {
299     LayoutLength value( 123 );
300     std::stringstream ss;
301     ss << value;
302     DALI_TEST_EQUALS( ss.str(), "123", TEST_LOCATION );
303   }
304   {
305     LayoutLength value( 0.123f );
306     std::stringstream ss;
307     ss << value;
308     DALI_TEST_EQUALS( ss.str(), "0.123", TEST_LOCATION );
309   }
310   END_TEST;
311 }
312
313 int UtcDaliLayouting_HboxLayout01(void)
314 {
315   ToolkitTestApplication application;
316   tet_infoline(" UtcDaliLayouting_HboxLayout01");
317
318   Stage stage = Stage::GetCurrent();
319   auto hbox = Control::New();
320   auto hboxLayout = LinearLayout::New();
321   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
322   DevelControl::SetLayout( hbox, hboxLayout );
323   hbox.SetName( "HBox");
324
325   std::vector< Control > controls;
326   controls.push_back( CreateLeafControl( 40, 40 ) );
327   controls.push_back( CreateLeafControl( 60, 40 ) );
328   controls.push_back( CreateLeafControl( 80, 40 ) );
329   controls.push_back( CreateLeafControl( 100, 40 ) );
330
331   for( auto&& iter : controls )
332   {
333     hbox.Add( iter );
334   }
335
336   hbox.SetParentOrigin( ParentOrigin::CENTER );
337   hbox.SetAnchorPoint( AnchorPoint::CENTER );
338   stage.Add( hbox );
339
340   // Ensure layouting happens
341   application.SendNotification();
342   application.Render();
343
344   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
345   // hbox left justifies elements
346   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
347   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
348   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
349   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
350
351   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
352   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
353   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
354   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
355
356   // Change a layout
357   auto newHBoxLayout = LinearLayout::New();
358   newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
359   DevelControl::SetLayout( hbox, newHBoxLayout );
360
361   application.SendNotification();
362   application.Render();
363
364   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
365   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
366   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
367   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
368
369   END_TEST;
370 }
371
372 int UtcDaliLayouting_HboxLayout02(void)
373 {
374   ToolkitTestApplication application;
375   tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
376
377   Stage stage = Stage::GetCurrent();
378
379   auto hbox1 = Control::New();
380   auto hboxLayout1 = LinearLayout::New();
381   DevelControl::SetLayout( hbox1, hboxLayout1 );
382
383   auto hbox2 = Control::New();
384   auto hboxLayout2 = LinearLayout::New();
385   DevelControl::SetLayout( hbox2, hboxLayout2 );
386
387   hbox1.SetName( "HBox1");
388   hbox2.SetName( "HBox2");
389
390   std::vector< Control > controls;
391   controls.push_back( CreateLeafControl( 20, 40 ) );
392   controls.push_back( CreateLeafControl( 30, 50 ) );
393   controls.push_back( CreateLeafControl( 40, 60 ) );
394   controls.push_back( CreateLeafControl( 50, 70 ) );
395
396   controls.push_back( CreateLeafControl( 25, 40 ) );
397   controls.push_back( CreateLeafControl( 35, 50 ) );
398   controls.push_back( CreateLeafControl( 45, 60 ) );
399   controls.push_back( CreateLeafControl( 55, 70 ) );
400
401   int counter=0;
402   for( auto&& iter : controls )
403   {
404     if( counter < 4 )
405     {
406       hbox1.Add( iter );
407     }
408     else
409     {
410       hbox2.Add( iter );
411     }
412     ++counter;
413   }
414   hbox1.SetParentOrigin( ParentOrigin::CENTER );
415   hbox1.SetAnchorPoint( AnchorPoint::CENTER );
416   hbox2.SetParentOrigin( ParentOrigin::CENTER );
417   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
418
419   auto hbox3 = Control::New();
420   auto hboxLayout3 = LinearLayout::New();
421   DevelControl::SetLayout( hbox3, hboxLayout3 );
422
423   hbox3.SetParentOrigin( ParentOrigin::CENTER );
424   hbox3.SetName( "HBox3");
425   hbox3.Add( hbox1 );
426   hbox3.Add( hbox2 );
427
428   stage.Add( hbox3 );
429
430   // Ensure layouting happens
431   application.SendNotification();
432   application.Render();
433
434
435   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
436   // hbox left justifies elements
437   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
438   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
439   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,  5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
440   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,  0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
441
442   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
443   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
444   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
445   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
446
447
448   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
449   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
450   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f,  5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
451   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,  0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
452
453   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
454   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
455   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
456   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
457
458   // Test hbox1 and 2 are sized to wrap their content
459   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
460   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
461   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
462   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
463
464   // Test hbox3 matches parent (root layer)
465   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
466   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
467
468   END_TEST;
469 }
470
471
472 int UtcDaliLayouting_HboxLayout03(void)
473 {
474   ToolkitTestApplication application;
475   tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
476
477   Stage stage = Stage::GetCurrent();
478
479   auto hbox1 = Control::New();
480   auto hboxLayout1 = LinearLayout::New();
481   DevelControl::SetLayout( hbox1, hboxLayout1 );
482
483   auto hbox2 = Control::New();
484   auto hboxLayout2 = LinearLayout::New();
485   DevelControl::SetLayout( hbox2, hboxLayout2 );
486
487   hbox1.SetName( "HBox1");
488   hbox2.SetName( "HBox2");
489   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
490   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
491   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
492   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
493
494   std::vector< Control > controls;
495   controls.push_back( CreateLeafControl( 20, 40 ) );
496   controls.push_back( CreateLeafControl( 30, 50 ) );
497   controls.push_back( CreateLeafControl( 40, 60 ) );
498   controls.push_back( CreateLeafControl( 50, 70 ) );
499
500   controls.push_back( CreateLeafControl( 25, 40 ) );
501   controls.push_back( CreateLeafControl( 35, 50 ) );
502   controls.push_back( CreateLeafControl( 45, 60 ) );
503   controls.push_back( CreateLeafControl( 55, 70 ) );
504
505   int counter=0;
506   for( auto&& iter : controls )
507   {
508     if( counter < 4 )
509     {
510       hbox1.Add( iter );
511     }
512     else
513     {
514       hbox2.Add( iter );
515     }
516     ++counter;
517   }
518   hbox1.SetParentOrigin( ParentOrigin::CENTER );
519   hbox1.SetAnchorPoint( AnchorPoint::CENTER );
520   hbox2.SetParentOrigin( ParentOrigin::CENTER );
521   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
522
523   auto hbox3 = Control::New();
524   auto hboxLayout3 = LinearLayout::New();
525   DevelControl::SetLayout( hbox3, hboxLayout3);
526
527   hbox3.SetParentOrigin( ParentOrigin::CENTER );
528   hbox3.SetName( "HBox3");
529   hbox3.Add( hbox1 );
530   hbox3.Add( hbox2 );
531
532   stage.Add( hbox3 );
533
534   //std::ostringstream oss;
535   //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
536   //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
537
538   // Ensure layouting happens
539   application.SendNotification();
540   application.Render();
541
542
543   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
544   // hbox left justifies elements
545   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
546   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
547   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
548   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
549
550   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
551   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
552   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
553   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
554
555   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
556   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
557   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
558   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
559
560   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
561   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
562   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
563   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
564
565   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
566   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
567   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
568   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
569
570   // Test hbox3 matches parent (root layer)
571   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
572   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
573
574   END_TEST;
575 }
576
577 int UtcDaliLayouting_HboxLayout04(void)
578 {
579   ToolkitTestApplication application;
580   tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
581
582   Stage stage = Stage::GetCurrent();
583
584   auto hbox1 = Control::New();
585   auto hboxLayout1 = LinearLayout::New();
586   DevelControl::SetLayout( hbox1, hboxLayout1 );
587
588   auto hbox2 = Control::New();
589   auto hboxLayout2 = LinearLayout::New();
590   DevelControl::SetLayout( hbox2, hboxLayout2 );
591
592   hbox1.SetName( "HBox1"); // Default spec is to wrap content
593   hbox2.SetName( "HBox2");
594   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
595   hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
596   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
597   hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
598
599   std::vector< Control > controls;
600   controls.push_back( CreateLeafControl( 80, 40 ) );
601   controls.push_back( CreateLeafControl( 80, 50 ) );
602   controls.push_back( CreateLeafControl( 80, 60 ) );
603   controls.push_back( CreateLeafControl( 80, 70 ) );
604
605   controls.push_back( CreateLeafControl( 80, 40 ) );
606   controls.push_back( CreateLeafControl( 80, 50 ) );
607   controls.push_back( CreateLeafControl( 80, 60 ) );
608   controls.push_back( CreateLeafControl( 80, 70 ) );
609
610   int counter=0;
611   for( auto&& iter : controls )
612   {
613     if( counter < 4 )
614     {
615       hbox1.Add( iter );
616     }
617     else
618     {
619       hbox2.Add( iter );
620     }
621     ++counter;
622   }
623
624   controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
625   auto hbox3 = Control::New();
626   auto hboxLayout3 = LinearLayout::New();
627   DevelControl::SetLayout( hbox3, hboxLayout3 );
628
629   hbox3.SetParentOrigin( ParentOrigin::CENTER );
630   hbox3.SetName( "HBox3");
631   hbox3.Add( hbox1 );
632   hbox3.Add( hbox2 );
633   stage.Add( hbox3 );
634
635   //std::ostringstream oss;
636   //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
637   //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
638
639   // Ensure layouting happens
640   application.SendNotification();
641   application.Render();
642
643
644   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
645   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
646   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
647   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
648
649   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
650   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
651   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
652   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
653
654   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3(  0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
655   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
656   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
657   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
658
659   DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
660   DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
661   DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
662   DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
663
664   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
665   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
666   DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
667   DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
668
669
670   // Test hbox3 matches parent (root layer)
671   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
672   DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
673
674   END_TEST;
675 }
676
677 int UtcDaliLayouting_HboxLayout05(void)
678 {
679   ToolkitTestApplication application;
680   tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
681
682   Stage stage = Stage::GetCurrent();
683   auto hbox = Control::New();
684   auto hboxLayout = LinearLayout::New();
685   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
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( 60, 40 ) );
692   controls.push_back( CreateLeafControl( 80, 40 ) );
693   controls.push_back( CreateLeafControl( 100, 40 ) );
694
695   for( auto&& iter : controls )
696   {
697     hbox.Add( iter );
698     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
699     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
700   }
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   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
713   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
714   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
715   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
716
717   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
718   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
719   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
720   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
721
722   END_TEST;
723 }
724
725 int UtcDaliLayouting_HboxLayout06(void)
726 {
727   ToolkitTestApplication application;
728   tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
729
730   Stage stage = Stage::GetCurrent();
731
732   auto rootControl = Control::New();
733   auto absoluteLayout = AbsoluteLayout::New();
734   DevelControl::SetLayout( rootControl, absoluteLayout );
735   rootControl.SetName( "AbsoluteLayout" );
736   stage.Add( rootControl );
737
738   auto hbox = Control::New();
739   auto hboxLayout = LinearLayout::New();
740   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
741   DevelControl::SetLayout( hbox, hboxLayout );
742   hbox.SetName( "HBox" );
743
744   std::vector< Control > controls;
745   controls.push_back( CreateLeafControl( 40, 40 ) );
746   controls.push_back( CreateLeafControl( 60, 40 ) );
747
748   for( auto&& iter : controls )
749   {
750     hbox.Add( iter );
751   }
752   hbox.SetParentOrigin( ParentOrigin::CENTER );
753   hbox.SetAnchorPoint( AnchorPoint::CENTER );
754   rootControl.Add( hbox );
755
756   // Ensure layouting happens
757   application.SendNotification();
758   application.Render();
759
760   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
761   // hbox left justifies elements
762   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
763   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
764
765   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
766   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
767
768   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
769
770   // Change a layout
771   auto newHBoxLayout = LinearLayout::New();
772   newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
773   DevelControl::SetLayout( hbox, newHBoxLayout );
774
775   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
776   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
777
778   application.SendNotification();
779   application.Render();
780
781   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
782
783   // Change size specification
784   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
785   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
786
787   application.SendNotification();
788   application.Render();
789
790   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
791
792   // Use WRAP_CONTENT again
793   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
794   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
795
796   application.SendNotification();
797   application.Render();
798
799   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
800
801   END_TEST;
802 }
803
804 int UtcDaliLayouting_HboxLayout07(void)
805 {
806   ToolkitTestApplication application;
807   tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
808
809   Stage stage = Stage::GetCurrent();
810   auto hbox = Control::New();
811   auto hboxLayout = LinearLayout::New();
812   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
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   for( auto&& iter : controls )
823   {
824     hbox.Add( iter );
825   }
826   hbox.SetParentOrigin( ParentOrigin::CENTER );
827   hbox.SetAnchorPoint( AnchorPoint::CENTER );
828   stage.Add( hbox );
829
830   hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
831
832   // Ensure layouting happens
833   application.SendNotification();
834   application.Render();
835
836   // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
837   // hbox left justifies elements
838   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
839   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
840   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
841   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
842
843   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
844   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
845   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
846   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
847
848   hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
849
850   // Ensure layouting happens
851   application.SendNotification();
852   application.Render();
853
854   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
855   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
856   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
857   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
858
859   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
860   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
861   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
862   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
863
864   END_TEST;
865 }
866
867 int UtcDaliLayouting_HboxLayout08(void)
868 {
869   ToolkitTestApplication application;
870   tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation");
871
872   Stage stage = Stage::GetCurrent();
873
874   auto rootControl = Control::New();
875   auto absoluteLayout = AbsoluteLayout::New();
876   absoluteLayout.SetAnimateLayout( true );
877   DevelControl::SetLayout( rootControl, absoluteLayout );
878   rootControl.SetName( "AbsoluteLayout" );
879   stage.Add( rootControl );
880
881   Control control1 = CreateLeafControl( 40, 40 );
882   rootControl.Add( control1 );
883
884   auto hbox = Control::New();
885   auto hboxLayout = LinearLayout::New();
886   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
887   DevelControl::SetLayout( hbox, hboxLayout );
888   hbox.SetName( "HBox" );
889
890   Control control2 = CreateLeafControl( 40, 40 );
891   hbox.Add( control2 );
892
893   hbox.SetParentOrigin( ParentOrigin::CENTER );
894   hbox.SetAnchorPoint( AnchorPoint::CENTER );
895   rootControl.Add( hbox );
896
897   DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION );
898   DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION );
899   DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION );
900   DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION );
901
902   tet_infoline(" Set hBoxLayout to animate");
903   hboxLayout.SetAnimateLayout( true );
904   tet_infoline(" Set absoluteLayout not to animate");
905   absoluteLayout.SetAnimateLayout( false );
906
907   DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION );
908   DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION );
909   DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION );
910   DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION );
911
912   END_TEST;
913 }
914
915 int UtcDaliLayouting_HboxLayout09(void)
916 {
917   ToolkitTestApplication application;
918   tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set alignment");
919
920   Stage stage = Stage::GetCurrent();
921   auto hbox = Control::New();
922   auto hboxLayout = LinearLayout::New();
923   DevelControl::SetLayout( hbox, hboxLayout );
924   hbox.SetName( "HBox");
925
926   std::vector< Control > controls;
927   controls.push_back( CreateLeafControl( 40, 40 ) );
928   controls.push_back( CreateLeafControl( 60, 60 ) );
929
930   for( auto&& iter : controls )
931   {
932     hbox.Add( iter );
933   }
934   hbox.SetParentOrigin( ParentOrigin::CENTER );
935   hbox.SetAnchorPoint( AnchorPoint::CENTER );
936   stage.Add( hbox );
937
938   // Check default orientation
939   DALI_TEST_EQUALS( static_cast<unsigned int>( hboxLayout.GetOrientation() ), static_cast<unsigned int>( LinearLayout::Orientation::HORIZONTAL ), TEST_LOCATION );
940   // Check default alignment
941   DALI_TEST_EQUALS( hboxLayout.GetAlignment(), ( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL ), TEST_LOCATION );
942
943   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN );
944
945   // Ensure layouting happens
946   application.SendNotification();
947   application.Render();
948
949   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
950   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
951
952   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
953   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
954
955   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END );
956
957   // Ensure layouting happens
958   application.SendNotification();
959   application.Render();
960
961   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
962   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
963
964   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
965   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
966
967   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
968
969   // Ensure layouting happens
970   application.SendNotification();
971   application.Render();
972
973   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
974   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
975
976   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
977   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
978
979   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP );
980
981   // Ensure layouting happens
982   application.SendNotification();
983   application.Render();
984
985   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
986   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
987
988   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
989   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
990
991   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP );
992
993   // Ensure layouting happens
994   application.SendNotification();
995   application.Render();
996
997   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
998   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
999
1000   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1001   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1002
1003   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP );
1004
1005   // Ensure layouting happens
1006   application.SendNotification();
1007   application.Render();
1008
1009   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1010   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 0.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
1015   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1016
1017   // Ensure layouting happens
1018   application.SendNotification();
1019   application.Render();
1020
1021   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1022   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1023
1024   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1025   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1026
1027   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1028
1029   // Ensure layouting happens
1030   application.SendNotification();
1031   application.Render();
1032
1033   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1034   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1035
1036   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1037   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1038
1039   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1040
1041   // Ensure layouting happens
1042   application.SendNotification();
1043   application.Render();
1044
1045   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1046   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1047
1048   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1049   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1050
1051   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL );
1052
1053   // Ensure layouting happens
1054   application.SendNotification();
1055   application.Render();
1056
1057   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1058   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1059
1060   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1061   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1062
1063   hboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1064   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN );
1065
1066   // Ensure layouting happens
1067   application.SendNotification();
1068   application.Render();
1069
1070   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1071   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1072
1073   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1074   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1075
1076   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END );
1077
1078   // Ensure layouting happens
1079   application.SendNotification();
1080   application.Render();
1081
1082   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1083   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1084
1085   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1086   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1087
1088   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
1089
1090   // Ensure layouting happens
1091   application.SendNotification();
1092   application.Render();
1093
1094   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1095   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1096
1097   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1098   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1099
1100   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP );
1101
1102   // Ensure layouting happens
1103   application.SendNotification();
1104   application.Render();
1105
1106   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1107   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1108
1109   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1110   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1111
1112   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP );
1113
1114   // Ensure layouting happens
1115   application.SendNotification();
1116   application.Render();
1117
1118   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1119   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1120
1121   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1122   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1123
1124   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP );
1125
1126   // Ensure layouting happens
1127   application.SendNotification();
1128   application.Render();
1129
1130   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1131   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1132
1133   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1134   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1135
1136   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1137
1138   // Ensure layouting happens
1139   application.SendNotification();
1140   application.Render();
1141
1142   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1143   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1144
1145   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1146   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1147
1148   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1149
1150   // Ensure layouting happens
1151   application.SendNotification();
1152   application.Render();
1153
1154   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1155   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1156
1157   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1158   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1159
1160   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
1161
1162   // Ensure layouting happens
1163   application.SendNotification();
1164   application.Render();
1165
1166   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1167   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1168
1169   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1170   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1171
1172   hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL );
1173
1174   // Ensure layouting happens
1175   application.SendNotification();
1176   application.Render();
1177
1178   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1179   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1180
1181   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1182   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1183
1184   END_TEST;
1185 }
1186
1187 int UtcDaliLayouting_HboxLayout_Weight(void)
1188 {
1189   ToolkitTestApplication application;
1190   tet_infoline( " UtcDaliLayouting_HboxLayout_Weight - Test LinearLayout weight horizontally" );
1191
1192   Stage stage = Stage::GetCurrent();
1193   auto hbox = Control::New();
1194   auto hboxLayout = LinearLayout::New();
1195   DevelControl::SetLayout( hbox, hboxLayout );
1196   hbox.SetName( "HBox" );
1197
1198   std::vector<Control> controls;
1199   controls.push_back( CreateLeafControl( 40, 40 ) );
1200   controls.push_back( CreateLeafControl( 60, 40 ) );
1201   controls.push_back( CreateLeafControl( 80, 40 ) );
1202   controls.push_back( CreateLeafControl( 100, 40 ) );
1203
1204   // Set weight for each leaf to use quarter of available space
1205   // 480 * 0.25, 480 * 0.25, 480 * 0.25, 480 * 0.25,
1206   // width spec has to be set to 0 so not to consume any extra space.
1207   for( auto&& iter : controls )
1208   {
1209     iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1210     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1211     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1212     hbox.Add( iter );
1213   }
1214
1215   hbox.SetParentOrigin( ParentOrigin::CENTER );
1216   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1217   stage.Add( hbox );
1218
1219   // Ensure layouting happens
1220   application.SendNotification();
1221   application.Render();
1222
1223   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1224   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1225   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1226   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 360.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1227
1228   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1229   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1230   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1231   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1232
1233   // Set weight for 3, 4 leafs to use all remaining available space after 1, 2 content sized leafs.
1234   // 40, 60, (480 - 40 - 60) * 0.5, (480 - 40 - 60) * 0.5
1235   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1236   controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1237   controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1238   controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1239   controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1240   controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1241
1242   // Ensure layouting happens
1243   application.SendNotification();
1244   application.Render();
1245
1246   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1247   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1248   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1249   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 290.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1250
1251   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1252   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1253   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 190.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1254   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 190.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1255
1256   // Add intrinsic width for 3rd leaf so now we should get
1257   // 40, 60, (480 - 40 - 60 - 80) * 0.5 + 80, (480 - 40 - 60 - 80) * 0.5
1258   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 80 );
1259
1260   // Ensure layouting happens
1261   application.SendNotification();
1262   application.Render();
1263
1264   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1265   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1266   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1267   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1268
1269   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1270   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1271   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1272   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1273
1274   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1275   controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1276   controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1277   controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1278   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1279   controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1280   controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 40 );
1281   controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1282
1283   // Ensure layouting happens
1284   application.SendNotification();
1285   application.Render();
1286
1287   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1288   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1289   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1290   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1291
1292   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 110.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1293   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 220.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1294   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 110.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1295   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1296
1297   // WRAP_CONTENT doesn't affect weight
1298   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1299   controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1300   controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1301   controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1302   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1303   controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1304   controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1305   controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1306
1307   // Ensure layouting happens
1308   application.SendNotification();
1309   application.Render();
1310
1311   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1312   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1313   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1314   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1315
1316   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1317   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1318   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1319   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 300.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1320
1321   // MATCH_PARENT doesn't affect weight
1322   for( auto&& iter : controls )
1323   {
1324     iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1325     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1326     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1327   }
1328
1329   // Ensure layouting happens
1330   application.SendNotification();
1331   application.Render();
1332
1333   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1334   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1335   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1336   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 360.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1337
1338   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1339   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1340   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1341   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1342
1343   const Extents CONTROL_MARGIN = Extents( 10, 10, 0, 0 );
1344   for( auto&& iter : controls )
1345   {
1346     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1347     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1348     iter.SetProperty( Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1349   }
1350
1351   controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1352   controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1353   controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1354   controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1355
1356   application.SendNotification();
1357   application.Render();
1358
1359   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 10.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1360   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 70.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1361   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 150.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1362   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 250.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1363
1364   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1365   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1366   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1367   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 220.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1368
1369   END_TEST;
1370 }
1371
1372 int UtcDaliLayouting_VboxLayout_Weight(void)
1373 {
1374   ToolkitTestApplication application;
1375   tet_infoline( " UtcDaliLayouting_VboxLayout_Weight - Test LinearLayout weight vertically" );
1376
1377   Stage stage = Stage::GetCurrent();
1378   auto vbox = Control::New();
1379   auto vboxLayout = LinearLayout::New();
1380   vboxLayout.SetOrientation( Dali::Toolkit::LinearLayout::Orientation::VERTICAL );
1381   DevelControl::SetLayout( vbox, vboxLayout );
1382   vbox.SetName( "VBox" );
1383
1384   std::vector<Control> controls;
1385   controls.push_back( CreateLeafControl( 40, 40 ) );
1386   controls.push_back( CreateLeafControl( 60, 60 ) );
1387   controls.push_back( CreateLeafControl( 80, 80 ) );
1388   controls.push_back( CreateLeafControl( 100, 100 ) );
1389
1390   // Set weight for each leaf to use quarter of available space
1391   // 800 * 0.25, 800 * 0.25, 800 * 0.25, 800 * 0.25,
1392   // width spec has to be set to 0 so not to consume any extra space.
1393   for( auto&& iter : controls )
1394   {
1395     iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1396     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1397     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1398     vbox.Add( iter );
1399   }
1400
1401   vbox.SetParentOrigin( ParentOrigin::CENTER );
1402   vbox.SetAnchorPoint( AnchorPoint::CENTER );
1403   stage.Add( vbox );
1404
1405   // Ensure layouting happens
1406   application.SendNotification();
1407   application.Render();
1408
1409   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1410   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1411   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1412   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 600.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1413
1414   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1415   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1416   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1417   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1418
1419   // Set weight for 3, 4 leafs to use all remaining available space after 1, 2 content sized leafs.
1420   // 40, 60, (800 - 40 - 60) * 0.5, (800 - 40 - 60) * 0.5
1421   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1422   controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1423   controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1424   controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1425   controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1426   controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1427
1428   // Ensure layouting happens
1429   application.SendNotification();
1430   application.Render();
1431
1432   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1433   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1434   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1435   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 450.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1436
1437   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1438   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1439   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1440   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1441
1442   // Add intrinsic width for 3rd leaf so now we should get
1443   // 40, 60, (800 - 40 - 60 - 100) * 0.5 + 100, (800 - 40 - 60 - 100) * 0.5
1444   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
1445
1446   // Ensure layouting happens
1447   application.SendNotification();
1448   application.Render();
1449
1450   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1451   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1452   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1453   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 500.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1454
1455   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1456   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1457   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1458   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1459
1460   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1461   controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1462   controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1463   controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1464   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1465   controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1466   controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
1467   controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1468
1469   // Ensure layouting happens
1470   application.SendNotification();
1471   application.Render();
1472
1473   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1474   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1475   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 525.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1476   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1477
1478   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1479   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1480   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1481   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1482
1483   // WRAP_CONTENT doesn't affect weight
1484   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1485   controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1486   controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1487   controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1488   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1489   controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1490   controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1491   controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1492
1493   // Ensure layouting happens
1494   application.SendNotification();
1495   application.Render();
1496
1497   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1498   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1499   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1500   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1501
1502   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1503   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1504   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1505   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 620.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1506
1507   // MATCH_PARENT doesn't affect weight
1508   for( auto&& iter : controls )
1509   {
1510     iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1511     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1512     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1513   }
1514
1515   // Ensure layouting happens
1516   application.SendNotification();
1517   application.Render();
1518
1519   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1520   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1521   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1522   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 600.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1523
1524   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1525   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1526   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1527   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1528
1529   const Extents CONTROL_MARGIN = Extents( 0, 0, 10, 10 );
1530   for( auto&& iter : controls )
1531   {
1532     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1533     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1534     iter.SetProperty( Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1535   }
1536
1537   controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1538   controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1539   controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1540   controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1541
1542   application.SendNotification();
1543   application.Render();
1544
1545   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1546   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1547   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1548   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 250.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1549
1550   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1551   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1552   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1553   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 540.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1554
1555   END_TEST;
1556 }
1557
1558 int UtcDaliLayouting_NestedLinearLayout_Weight(void)
1559 {
1560   ToolkitTestApplication application;
1561   tet_infoline("UtcDaliLayouting_NestedLinearLayout_Weight - test weighted children with wrapped parent");
1562
1563   Stage stage = Stage::GetCurrent();
1564   auto rootControl = Control::New();
1565   rootControl.SetName( "AbsoluteLayout");
1566   auto rootLayout = AbsoluteLayout::New();
1567   DevelControl::SetLayout( rootControl, rootLayout );
1568   rootControl.SetAnchorPoint( AnchorPoint::CENTER );
1569   rootControl.SetParentOrigin( ParentOrigin::CENTER );
1570   stage.Add( rootControl );
1571
1572   auto hbox = Control::New();
1573   auto hboxLayout = LinearLayout::New();
1574   DevelControl::SetLayout( hbox, hboxLayout );
1575   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1576   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1577
1578   std::vector< Control > controls;
1579   controls.push_back( CreateLeafControl( 40, 40 ) );
1580   controls.push_back( CreateLeafControl( 60, 60 ) );
1581
1582   // set equal share of wrapped content width (40 + 60 = 100) for both children 100 * 0.5, 100 * 0.5
1583   for( auto&& iter : controls )
1584   {
1585     iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1586     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1587     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1588     hbox.Add( iter );
1589   }
1590
1591   hbox.SetParentOrigin( ParentOrigin::CENTER );
1592   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1593   rootControl.Add( hbox );
1594
1595   // Ensure layouting happens
1596   application.SendNotification();
1597   application.Render();
1598
1599   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1600   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1601
1602   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1603   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1604
1605   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1606   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1607
1608   hboxLayout.SetOrientation(Dali::Toolkit::LinearLayout::Orientation::VERTICAL);
1609
1610   // set equal share of wrapped content height (40 + 60 = 100) for both children 100 * 0.5, 100 * 0.5
1611   for( auto&& iter : controls )
1612   {
1613     iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1614     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1615     iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1616   }
1617
1618   // Ensure layouting happens
1619   application.SendNotification();
1620   application.Render();
1621
1622   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1623   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1624
1625   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1626   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1627
1628   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1629   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1630
1631   END_TEST;
1632 }
1633
1634
1635 namespace
1636 {
1637 const char* TEST_IMAGE_FILE_NAME =  TEST_RESOURCE_DIR  "/broken.png";
1638 }
1639
1640 int UtcDaliLayouting_HboxLayout_ImageView(void)
1641 {
1642   ToolkitTestApplication application;
1643   tet_infoline(" UtcDaliLayouting_HboxLayout - Use image view for leaf");
1644
1645   Stage stage = Stage::GetCurrent();
1646   auto hbox = Control::New();
1647   auto hboxLayout = LinearLayout::New();
1648   DevelControl::SetLayout( hbox, hboxLayout );
1649   hbox.SetName( "HBox" );
1650
1651   std::string url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 100, 100 ) );
1652   ImageView imageView = CreateImageView( url, ImageDimensions() );
1653
1654   hbox.SetParentOrigin( ParentOrigin::CENTER );
1655   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1656   hbox.Add( imageView );
1657   stage.Add( hbox );
1658
1659   // Ensure layouting happens
1660   application.SendNotification();
1661   application.Render();
1662
1663   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1664   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1665
1666   url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 200, 200 ) );
1667   imageView.SetImage( url );
1668
1669   // Ensure layouting happenss
1670   application.SendNotification();
1671   application.Render();
1672
1673   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1674   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1675
1676   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1677   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1678
1679   // Ensure layouting happenss
1680   application.SendNotification();
1681   application.Render();
1682
1683   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1684   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1685
1686   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1687   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1688
1689   // Ensure layouting happenss
1690   application.SendNotification();
1691   application.Render();
1692
1693   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1694   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1695
1696   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1697   imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1698
1699   Image image = FrameBufferImage::New( 50, 50, Pixel::RGBA8888 );
1700   imageView.SetImage( image );
1701
1702   // Ensure layouting happenss
1703   application.SendNotification();
1704   application.Render();
1705
1706   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1707   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1708
1709   Property::Map imagePropertyMap;
1710   imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1711   imagePropertyMap[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
1712   imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 150;
1713   imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 150;
1714   imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap );
1715
1716   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1717   // Ensure layouting happenss
1718   application.SendNotification();
1719   application.Render();
1720
1721   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 325.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1722   DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1723
1724   END_TEST;
1725 }
1726
1727 int UtcDaliLayouting_HboxLayout_TextLabel(void)
1728 {
1729   ToolkitTestApplication application;
1730   tet_infoline(" UtcDaliLayouting_HboxLayout - Use text label for leaf");
1731
1732   Stage stage = Stage::GetCurrent();
1733
1734   auto hbox = Control::New();
1735   auto hboxLayout = LinearLayout::New();
1736   DevelControl::SetLayout( hbox, hboxLayout );
1737   hbox.SetName( "HBox" );
1738   hbox.SetParentOrigin( ParentOrigin::CENTER );
1739   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1740
1741   std::vector< Control > controls;
1742   TextLabel textLabel = CreateTextLabel( "W" );
1743   controls.push_back( textLabel );
1744   hbox.Add( textLabel );
1745   stage.Add( hbox );
1746
1747   // Ensure layouting happens
1748   application.SendNotification();
1749   application.Render();
1750
1751   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1752   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 54.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1753
1754   textLabel.SetProperty( TextLabel::Property::TEXT, "WWWW" );
1755
1756   // Ensure layouting happens
1757   application.SendNotification();
1758   application.Render();
1759
1760   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1761   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 216.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1762
1763   textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
1764
1765   // Ensure layouting happens
1766   application.SendNotification();
1767   application.Render();
1768
1769   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1770   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1771
1772   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1773   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1774
1775   // Ensure layouting happens
1776   application.SendNotification();
1777   application.Render();
1778
1779   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1780   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1781
1782   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1783   controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1784
1785   // Ensure layouting happens
1786   application.SendNotification();
1787   application.Render();
1788
1789   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1790   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1791
1792   END_TEST;
1793 }
1794
1795 // Padding tests
1796
1797 int UtcDaliLayouting_HboxLayout_Padding01(void)
1798 {
1799   ToolkitTestApplication application;
1800   tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
1801
1802   Stage stage = Stage::GetCurrent();
1803   auto hbox = Control::New();
1804   auto hboxLayout = LinearLayout::New();
1805   DevelControl::SetLayout( hbox, hboxLayout );
1806   hbox.SetName( "HBox");
1807
1808   std::vector< Control > controls;
1809   controls.push_back( CreateLeafControl( 40, 40 ) );
1810   controls.push_back( CreateLeafControl( 60, 40 ) );
1811   controls.push_back( CreateLeafControl( 80, 40 ) );
1812   controls.push_back( CreateLeafControl( 100, 40 ) );
1813
1814   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1815   tet_printf( "\nAdding Padding to control at index %u \n", 1 );
1816   controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1817
1818   for( auto&& iter : controls )
1819   {
1820     hbox.Add( iter );
1821   }
1822   hbox.SetParentOrigin( ParentOrigin::CENTER );
1823   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1824   stage.Add( hbox );
1825
1826   // Ensure layouting happens
1827   application.SendNotification();
1828   application.Render();
1829
1830   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1831   // hbox left justifies elements
1832   tet_infoline("Test Child Actor Position");
1833   float xPositionOfControlBeingTested = 0.0f;
1834   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1835                                                                                             380.0f,
1836                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1837   xPositionOfControlBeingTested += 40.0f;
1838
1839   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1840                                                                                             380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
1841                                                                                             0.0001f, TEST_LOCATION );
1842
1843   xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1844   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1845
1846   xPositionOfControlBeingTested += 80.0f;
1847   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1848
1849   tet_infoline("Test Child Actor Size");
1850   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1851
1852   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1853                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
1854                                                                                         0.0001f, TEST_LOCATION );
1855
1856   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1857   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1858
1859   END_TEST;
1860 }
1861
1862 int UtcDaliLayouting_HboxLayout_Padding02(void)
1863 {
1864   ToolkitTestApplication application;
1865   tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
1866
1867   Stage stage = Stage::GetCurrent();
1868   auto hbox = Control::New();
1869   auto hboxLayout = LinearLayout::New();
1870   DevelControl::SetLayout( hbox, hboxLayout );
1871   hbox.SetName( "HBox");
1872
1873   std::vector< Control > controls;
1874   controls.push_back( CreateLeafControl( 40, 40 ) );
1875   controls.push_back( CreateLeafControl( 60, 40 ) );
1876   controls.push_back( CreateLeafControl( 80, 40 ) );
1877   controls.push_back( CreateLeafControl( 100, 40 ) );
1878
1879   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1880
1881   for( auto&& iter : controls )
1882   {
1883     iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1884     hbox.Add( iter );
1885   }
1886   hbox.SetParentOrigin( ParentOrigin::CENTER );
1887   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1888   stage.Add( hbox );
1889
1890   // Ensure layouting happens
1891   application.SendNotification();
1892   application.Render();
1893
1894   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1895   // hbox left justifies elements
1896   tet_infoline("Test Child Actor Position");
1897   float xPositionOfControlBeingTested = 0.0f;
1898   float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
1899
1900   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1901                                                                                             yPositionOfControlBeingTested,
1902                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1903   xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1904
1905   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1906                                                                                             yPositionOfControlBeingTested,
1907                                                                                             0.0f ),
1908                                                                                             0.0001f, TEST_LOCATION );
1909
1910   xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1911   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1912                                                                                             yPositionOfControlBeingTested,
1913                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1914
1915   xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1916   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1917                                                                                             yPositionOfControlBeingTested,
1918                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1919
1920   tet_infoline("Test Child Actor Size");
1921   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1922                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1923                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
1924
1925   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1926                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1927                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
1928
1929   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
1930                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1931                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
1932
1933   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1934                                                                                         40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1935                                                                                         0.0f ), 0.0001f, TEST_LOCATION );
1936
1937   END_TEST;
1938 }
1939
1940
1941 int UtcDaliLayouting_HboxLayout_Padding03(void)
1942 {
1943   ToolkitTestApplication application;
1944   tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
1945
1946   Stage stage = Stage::GetCurrent();
1947   auto hbox = Control::New();
1948   auto hboxLayout = LinearLayout::New();
1949   DevelControl::SetLayout( hbox, hboxLayout );
1950   hbox.SetName( "HBox");
1951
1952   std::vector< Control > controls;
1953   controls.push_back( CreateLeafControl( 40, 40 ) );
1954   controls.push_back( CreateLeafControl( 40, 40 ) );
1955   controls.push_back( CreateLeafControl( 40, 40 ) );
1956
1957   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1958   tet_printf( "\nAdding Padding to control at index 1 \n" );
1959   controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1960
1961   for( auto&& iter : controls )
1962   {
1963     hbox.Add( iter );
1964   }
1965   hbox.SetParentOrigin( ParentOrigin::CENTER );
1966   hbox.SetAnchorPoint( AnchorPoint::CENTER );
1967   stage.Add( hbox );
1968
1969   // Ensure layouting happens
1970   application.SendNotification();
1971   application.Render();
1972
1973   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1974   // hbox left justifies elements
1975   tet_infoline("Test Child Actor Position");
1976   float xPositionOfControlBeingTested = 0.0f;
1977   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1978                                                                                             380.0f,
1979                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
1980   xPositionOfControlBeingTested += 40.0f;
1981
1982   DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1983                                                                                             380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
1984                                                                                             0.0001f, TEST_LOCATION );
1985
1986   xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1987   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1988
1989   const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
1990   tet_printf( "\nChanging Padding to control at index 1 \n" );
1991   controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
1992
1993   // Ensure layouting happens
1994   application.SendNotification();
1995   application.Render();
1996
1997   xPositionOfControlBeingTested = 0.0f; // reset
1998
1999   tet_infoline("Test Child Actor Position");
2000   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2001                                                                                             380.0f,
2002                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2003   xPositionOfControlBeingTested += 40.0f;
2004
2005   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2006                                                                                             380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
2007                                                                                             0.0001f, TEST_LOCATION );
2008
2009   xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
2010   tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
2011   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2012
2013   tet_infoline("Test Child Actor Size");
2014   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2015
2016   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
2017                                                                                         40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
2018                                                                                         0.0001f, TEST_LOCATION );
2019
2020   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2021
2022   END_TEST;
2023 }
2024
2025 int UtcDaliLayouting_HboxLayout_Padding04(void)
2026 {
2027   ToolkitTestApplication application;
2028   tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
2029
2030   // Adding padding to the layout should offset the positioning of the children.
2031
2032   const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2033   const Size CONTROL_SIZE = Size( 40, 40 );
2034
2035   Stage stage = Stage::GetCurrent();
2036   // Create a root layout, ideally Dali would have a default layout in the root layer.
2037   // Without this root layer the LinearLayout (or any other layout) will not
2038   // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2039   // It uses the default stage size and ideally should have a layout added to it.
2040   auto rootLayoutControl = Control::New();
2041   rootLayoutControl.SetName( "AbsoluteLayout");
2042   auto rootLayout = AbsoluteLayout::New();
2043   DevelControl::SetLayout( rootLayoutControl, rootLayout );
2044   rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2045   rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2046   stage.Add( rootLayoutControl );
2047
2048   auto hbox = Control::New();
2049   auto hboxLayout = LinearLayout::New();
2050   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2051   DevelControl::SetLayout( hbox, hboxLayout );
2052   hbox.SetName( "HBox");
2053   hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2054   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2055   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2056
2057   std::vector< Control > controls;
2058   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2059   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2060   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2061   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2062
2063   for( auto&& iter : controls )
2064   {
2065     hbox.Add( iter );
2066   }
2067
2068   hbox.SetParentOrigin( ParentOrigin::CENTER );
2069   hbox.SetAnchorPoint( AnchorPoint::CENTER );
2070   rootLayoutControl.Add( hbox );
2071
2072   // Ensure layouting happens
2073   application.SendNotification();
2074   application.Render();
2075
2076   // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2077   application.SendNotification();
2078
2079   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2080   // hbox left justifies elements
2081   tet_infoline("Test Child Actor Position");
2082
2083   auto controlXPosition=0.0f;
2084
2085   controlXPosition = LAYOUT_PADDING.start;  // First child positioned at offset defined by the padding
2086   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2087                                                                                             LAYOUT_PADDING.top,
2088                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2089
2090   controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
2091   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2092                                                                                             LAYOUT_PADDING.top,
2093                                                                                             0.0f ),
2094                                                                                             0.0001f, TEST_LOCATION );
2095
2096   controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
2097   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2098                                                                                             LAYOUT_PADDING.top,
2099                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2100
2101   controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
2102   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2103                                                                                             LAYOUT_PADDING.top,
2104                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2105
2106   auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
2107   auto totalControlsHeight = CONTROL_SIZE.height;
2108
2109   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2110                                                                                  totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2111                                                                                  0.0f ), 0.0001f, TEST_LOCATION );
2112
2113
2114   END_TEST;
2115 }
2116
2117 int UtcDaliLayouting_HboxLayout_Padding05(void)
2118 {
2119   ToolkitTestApplication application;
2120   tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
2121
2122   // Adding padding to the layout should offset the positioning of the children.
2123
2124   const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2125   const Size CONTROL_SIZE = Size( 40, 40 );
2126
2127   Stage stage = Stage::GetCurrent();
2128   // Create a root layout, ideally Dali would have a default layout in the root layer.
2129   // Without this root layer the LinearLayout (or any other layout) will not
2130   // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2131   // It uses the default stage size and ideally should have a layout added to it.
2132   auto rootLayoutControl = Control::New();
2133   rootLayoutControl.SetName( "AbsoluteLayout");
2134   auto rootLayout = AbsoluteLayout::New();
2135   DevelControl::SetLayout( rootLayoutControl, rootLayout );
2136   rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2137   rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2138   stage.Add( rootLayoutControl );
2139
2140   auto hbox = Control::New();
2141   auto hboxLayout = LinearLayout::New();
2142   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2143   DevelControl::SetLayout( hbox, hboxLayout );
2144   hbox.SetName( "HBox");
2145   hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2146   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2147   hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2148
2149   std::vector< Control > controls;
2150   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2151   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2152   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2153   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2154
2155   for( auto&& iter : controls )
2156   {
2157     hbox.Add( iter );
2158   }
2159
2160   hbox.SetParentOrigin( ParentOrigin::CENTER );
2161   hbox.SetAnchorPoint( AnchorPoint::CENTER );
2162   rootLayoutControl.Add( hbox );
2163
2164   // Ensure layouting happens
2165   application.SendNotification();
2166   application.Render();
2167
2168   // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2169   application.SendNotification();
2170
2171   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2172   // hbox left justifies elements
2173   tet_infoline("Test Child Actor Position");
2174
2175   auto controlXPosition=0.0f;
2176
2177   controlXPosition = LAYOUT_PADDING.start;  // First child positioned at offset defined by the padding
2178   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2179                                                                                             LAYOUT_PADDING.top,
2180                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2181
2182   controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
2183   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2184                                                                                             LAYOUT_PADDING.top,
2185                                                                                             0.0f ),
2186                                                                                             0.0001f, TEST_LOCATION );
2187
2188   controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
2189   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2190                                                                                             LAYOUT_PADDING.top,
2191                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2192
2193   controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
2194   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2195                                                                                             LAYOUT_PADDING.top,
2196                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2197
2198   auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
2199   auto totalControlsHeight = CONTROL_SIZE.height;
2200
2201   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2202                                                                                  totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2203                                                                                  0.0f ), 0.0001f, TEST_LOCATION );
2204
2205   // Change layout padding
2206   const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
2207   tet_printf( "\nChanging Padding to control at index 1 \n" );
2208   hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
2209
2210   // Ensure layouting happens
2211   application.SendNotification();
2212   application.Render();
2213
2214   // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2215   application.SendNotification();
2216
2217   controlXPosition = NEW_LAYOUT_PADDING.start;  // First child positioned at offset defined by the padding
2218   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
2219                                                                                             NEW_LAYOUT_PADDING.top,
2220                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2221
2222   controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
2223   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2224                                                                                             NEW_LAYOUT_PADDING.top,
2225                                                                                             0.0f ),
2226                                                                                             0.0001f, TEST_LOCATION );
2227
2228   controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
2229   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2230                                                                                             NEW_LAYOUT_PADDING.top,
2231                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2232
2233   controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
2234   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
2235                                                                                             NEW_LAYOUT_PADDING.top,
2236                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2237   totalControlsWidth = CONTROL_SIZE.width * controls.size();
2238   totalControlsHeight = CONTROL_SIZE.height;
2239
2240   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
2241                                                                                  totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
2242                                                                                  0.0f ), 0.0001f, TEST_LOCATION );
2243   END_TEST;
2244 }
2245
2246 // Margin Tests
2247
2248 int UtcDaliLayouting_HboxLayout_Margin01(void)
2249 {
2250   ToolkitTestApplication application;
2251   tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
2252
2253   Stage stage = Stage::GetCurrent();
2254   auto hbox = Control::New();
2255   auto hboxLayout = LinearLayout::New();
2256   DevelControl::SetLayout( hbox, hboxLayout );
2257   hbox.SetName( "HBox");
2258
2259   std::vector< Control > controls;
2260   controls.push_back( CreateLeafControl( 40, 40 ) );
2261   controls.push_back( CreateLeafControl( 60, 40 ) );
2262   controls.push_back( CreateLeafControl( 80, 40 ) );
2263   controls.push_back( CreateLeafControl( 100, 40 ) );
2264
2265   const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
2266   tet_printf( "\nAdding Margin to control at index 1 \n" );
2267   controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
2268
2269   for( auto&& iter : controls )
2270   {
2271     hbox.Add( iter );
2272   }
2273   hbox.SetParentOrigin( ParentOrigin::CENTER );
2274   hbox.SetAnchorPoint( AnchorPoint::CENTER );
2275   stage.Add( hbox );
2276
2277   // Ensure layouting happens
2278   application.SendNotification();
2279   application.Render();
2280
2281   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2282   // hbox left justifies elements
2283   tet_infoline("Test Child Actor Position");
2284   auto xPositionOfControlBeingTested = 0.0f;
2285   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2286                                                                                             380.0f,
2287                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2288   xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
2289
2290   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2291                                                                                             380.0f + CONTROL_MARGIN.top, 0.0f ),
2292                                                                                             0.0001f, TEST_LOCATION );
2293
2294   xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
2295   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2296
2297   xPositionOfControlBeingTested += 80.0f;
2298   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2299
2300   tet_infoline("Test Child Actor Size is the same after Margin added");
2301   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2302   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
2303   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2304   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2305
2306   END_TEST;
2307 }
2308
2309
2310 int UtcDaliLayouting_VboxLayout01(void)
2311 {
2312   ToolkitTestApplication application;
2313   tet_infoline(" UtcDaliLayouting_VboxLayout01");
2314
2315   Stage stage = Stage::GetCurrent();
2316   auto vbox = Control::New();
2317   auto vboxLayout = LinearLayout::New();
2318   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2319   vboxLayout.SetAlignment( LinearLayout::Alignment::TOP | LinearLayout::Alignment::CENTER_HORIZONTAL );
2320   DevelControl::SetLayout( vbox, vboxLayout );
2321   vbox.SetName( "Vbox");
2322
2323   std::vector< Control > controls;
2324   controls.push_back( CreateLeafControl( 40, 40 ) );
2325   controls.push_back( CreateLeafControl( 60, 60 ) );
2326   controls.push_back( CreateLeafControl( 80, 80 ) );
2327   controls.push_back( CreateLeafControl( 100, 100 ) );
2328
2329   for( auto&& iter : controls )
2330   {
2331     vbox.Add( iter );
2332   }
2333   vbox.SetParentOrigin( ParentOrigin::CENTER );
2334   vbox.SetAnchorPoint( AnchorPoint::CENTER );
2335   stage.Add( vbox );
2336
2337   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2338
2339   // Check it.
2340   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2341
2342   // Ensure layouting happens
2343   application.SendNotification();
2344   application.Render();
2345
2346   // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
2347   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2348   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2349   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2350   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2351
2352   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2353   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2354   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2355   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2356
2357   END_TEST;
2358 }
2359
2360 int UtcDaliLayouting_VboxLayout02(void)
2361 {
2362   ToolkitTestApplication application;
2363   tet_infoline(" UtcDaliLayouting_VboxLayout01");
2364
2365   Stage stage = Stage::GetCurrent();
2366
2367   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
2368   // LayoutGroup for this to happen automatically.
2369   //
2370   // For this test, add an hbox instead
2371   auto rootControl = Control::New();
2372   auto absoluteLayout = AbsoluteLayout::New();
2373   DevelControl::SetLayout( rootControl, absoluteLayout );
2374   rootControl.SetName( "AbsoluteLayout");
2375   stage.Add( rootControl );
2376
2377   auto vbox = Control::New();
2378   auto vboxLayout = LinearLayout::New();
2379   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2380   vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
2381   DevelControl::SetLayout( vbox, vboxLayout );
2382   vbox.SetName( "Vbox");
2383   rootControl.Add( vbox );
2384
2385   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2386   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2387
2388   std::vector< Control > controls;
2389   controls.push_back( CreateLeafControl( 40, 40 ) );
2390   controls.push_back( CreateLeafControl( 60, 60 ) );
2391   controls.push_back( CreateLeafControl( 80, 80 ) );
2392   controls.push_back( CreateLeafControl( 100, 100 ) );
2393
2394   for( auto&& iter : controls )
2395   {
2396     vbox.Add( iter );
2397   }
2398   vbox.SetParentOrigin( ParentOrigin::CENTER );
2399   vbox.SetAnchorPoint( AnchorPoint::CENTER );
2400
2401   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2402
2403   // Check it.
2404   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2405
2406   // Ensure layouting happens
2407   application.SendNotification();
2408   application.Render();
2409
2410   DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
2411   DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
2412
2413   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
2414   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2415   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2416
2417   // 3rd control is set to match parent - this should also be 100 wide
2418   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2419   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2420   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2421   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2422
2423   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2424   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2425   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2426   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2427
2428   END_TEST;
2429 }
2430
2431
2432 int UtcDaliLayouting_VboxLayout03(void)
2433 {
2434   ToolkitTestApplication application;
2435   tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
2436
2437   Stage stage = Stage::GetCurrent();
2438
2439   // @todo Can't set specification properties on root control. Really need to make LayoutController a root
2440   // LayoutGroup for this to happen automatically.
2441   //
2442   // For this test, add an hbox instead
2443   auto hbox = Control::New();
2444   auto hboxLayout = LinearLayout::New();
2445   DevelControl::SetLayout( hbox, hboxLayout );
2446   hbox.SetName( "Hbox");
2447   stage.Add( hbox );
2448
2449   auto vbox = Control::New();
2450   auto vboxLayout = LinearLayout::New();
2451   vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
2452   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2453   vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
2454
2455   DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
2456
2457   DevelControl::SetLayout( vbox, vboxLayout );
2458   vbox.SetName( "Vbox");
2459   hbox.Add( vbox );
2460
2461   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2462   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2463
2464   std::vector< Control > controls;
2465   controls.push_back( CreateLeafControl( 40, 40 ) );
2466   controls.push_back( CreateLeafControl( 60, 60 ) );
2467   controls.push_back( CreateLeafControl( 80, 80 ) );
2468   controls.push_back( CreateLeafControl( 100, 100 ) );
2469
2470   for( auto&& iter : controls )
2471   {
2472     vbox.Add( iter );
2473   }
2474   vbox.SetParentOrigin( ParentOrigin::CENTER );
2475   vbox.SetAnchorPoint( AnchorPoint::CENTER );
2476
2477   controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2478
2479   // Check it.
2480   DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2481
2482   // Ensure layouting happens
2483   application.SendNotification();
2484   application.Render();
2485
2486   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
2487   DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
2488
2489   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
2490   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2491   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2492
2493   // 3rd control is set to match parent - this should also be 100 wide
2494   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2495   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2496   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2497   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2498
2499   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2500   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2501   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2502   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2503
2504   END_TEST;
2505 }
2506
2507 int UtcDaliLayouting_VboxLayout_Padding(void)
2508 {
2509   ToolkitTestApplication application;
2510   tet_infoline("UtcDaliLayouting_VboxLayout_Padding - Adding Padding to the vbox");
2511
2512   // Adding padding to the layout should offset the positioning of the children.
2513
2514   const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2515   const Size CONTROL_SIZE = Size( 40, 40 );
2516
2517   Stage stage = Stage::GetCurrent();
2518   // Create a root layout, ideally Dali would have a default layout in the root layer.
2519   // Without this root layer the LinearLayout (or any other layout) will not
2520   // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2521   // It uses the default stage size and ideally should have a layout added to it.
2522   auto rootLayoutControl = Control::New();
2523   rootLayoutControl.SetName( "AbsoluteLayout");
2524   auto rootLayout = AbsoluteLayout::New();
2525   DevelControl::SetLayout( rootLayoutControl, rootLayout );
2526   rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2527   rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2528   stage.Add( rootLayoutControl );
2529
2530   auto vbox = Control::New();
2531   auto vboxLayout = LinearLayout::New();
2532   vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2533   DevelControl::SetLayout( vbox, vboxLayout );
2534   vbox.SetName( "VBox");
2535   vbox.SetProperty( Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2536   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2537   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2538
2539   std::vector< Control > controls;
2540   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2541   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2542   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2543   controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2544
2545   for( auto&& iter : controls )
2546   {
2547     vbox.Add( iter );
2548   }
2549
2550   vbox.SetParentOrigin( ParentOrigin::CENTER );
2551   vbox.SetAnchorPoint( AnchorPoint::CENTER );
2552   rootLayoutControl.Add( vbox );
2553
2554   // Ensure layouting happens
2555   application.SendNotification();
2556   application.Render();
2557
2558   // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2559   application.SendNotification();
2560
2561   // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
2562   tet_infoline("Test Child Actor Position");
2563
2564   auto controlYPosition = 0.0f;
2565
2566   controlYPosition = LAYOUT_PADDING.top;  // First child positioned at offset defined by the padding
2567   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2568                                                                                             LAYOUT_PADDING.top,
2569                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2570
2571   controlYPosition += CONTROL_SIZE.height; // Second child positioned is the position of the first child + the first child's height.
2572   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2573                                                                                             controlYPosition,
2574                                                                                             0.0f ),
2575                                                                                             0.0001f, TEST_LOCATION );
2576
2577   controlYPosition += CONTROL_SIZE.height; // Third child positioned adjacent to second
2578   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2579                                                                                             controlYPosition,
2580                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2581
2582   controlYPosition += CONTROL_SIZE.height; // Forth passed adjacent to the third
2583   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2584                                                                                             controlYPosition,
2585                                                                                             0.0f ), 0.0001f, TEST_LOCATION );
2586
2587   auto totalControlsWidth = CONTROL_SIZE.width;
2588   auto totalControlsHeight = CONTROL_SIZE.height * controls.size();
2589
2590   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2591                                                                                  totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2592                                                                                  0.0f ), 0.0001f, TEST_LOCATION );
2593
2594   END_TEST;
2595 }
2596
2597
2598 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
2599 {
2600   ToolkitTestApplication application;
2601   tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
2602   tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
2603
2604   Stage stage = Stage::GetCurrent();
2605
2606   auto hbox = Control::New();
2607   auto hboxLayout = Test::CustomLayout::New();
2608   DevelControl::SetLayout( hbox, hboxLayout );
2609   hbox.SetName( "HBox");
2610
2611   std::vector< Control > controls;
2612   controls.push_back( CreateLeafControl( 40, 40 ) );
2613   controls.push_back( CreateLeafControl( 60, 40 ) );
2614   controls.push_back( CreateLeafControl( 80, 40 ) );
2615   controls.push_back( CreateLeafControl( 100, 40 ) );
2616
2617   for( auto&& iter : controls )
2618   {
2619     hbox.Add( iter );
2620   }
2621   hbox.SetParentOrigin( ParentOrigin::CENTER );
2622   hbox.SetAnchorPoint( AnchorPoint::CENTER );
2623   stage.Add( hbox );
2624
2625   // Ensure layouting happens
2626   application.SendNotification();
2627   application.Render();
2628
2629   // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2630   // hbox left justifies elements
2631   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2632   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2633   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2634   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2635
2636   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2637   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2638   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2639   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2640
2641   controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
2642   controls[2].Lower();      // 2->1; 2, 1, 3, 0
2643
2644   application.SendNotification();
2645   application.Render();
2646
2647   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2648   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2649   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2650   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2651
2652   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2653   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2654   DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2655   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2656
2657   END_TEST;
2658 }
2659
2660 int UtcDaliLayouting_HboxLayout_TargetSize(void)
2661 {
2662   ToolkitTestApplication application;
2663   tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
2664
2665   Stage stage = Stage::GetCurrent();
2666   auto hbox = Control::New();
2667   auto hboxLayout = LinearLayout::New();
2668   DevelControl::SetLayout( hbox, hboxLayout );
2669   hbox.SetName( "HBox");
2670
2671   std::vector< Control > controls;
2672   controls.push_back( CreateLeafControl( 40, 40 ) );
2673   for( auto&& iter : controls )
2674   {
2675     iter.SetSize( 100, 100 );
2676     hbox.Add( iter );
2677   }
2678   hbox.SetParentOrigin( ParentOrigin::CENTER );
2679   hbox.SetAnchorPoint( AnchorPoint::CENTER );
2680   stage.Add( hbox );
2681
2682   // Ensure layouting happens
2683   application.SendNotification();
2684   application.Render();
2685
2686   // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
2687   // hbox left justifies elements
2688   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2689   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2690
2691   END_TEST;
2692 }
2693
2694 int UtcDaliLayouting_RemoveLayout01(void)
2695 {
2696   ToolkitTestApplication application;
2697   tet_infoline(" UtcDaliLayouting_RemoveLayout");
2698
2699   Stage stage = Stage::GetCurrent();
2700
2701   auto rootControl = Control::New();
2702   auto absoluteLayout = AbsoluteLayout::New();
2703   DevelControl::SetLayout( rootControl, absoluteLayout );
2704   rootControl.SetName( "AbsoluteLayout" );
2705   stage.Add( rootControl );
2706
2707   auto hbox = Control::New();
2708   auto hboxLayout = LinearLayout::New();
2709   hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2710   DevelControl::SetLayout( hbox, hboxLayout );
2711   hbox.SetName( "HBox" );
2712
2713   std::vector< Control > controls;
2714   controls.push_back( CreateLeafControl( 40, 40 ) );
2715   controls.push_back( CreateLeafControl( 60, 40 ) );
2716
2717   for( auto&& iter : controls )
2718   {
2719     hbox.Add( iter );
2720   }
2721   hbox.SetParentOrigin( ParentOrigin::CENTER );
2722   hbox.SetAnchorPoint( AnchorPoint::CENTER );
2723   rootControl.Add( hbox );
2724
2725   tet_infoline("Layout as normal");
2726   application.SendNotification();
2727   application.Render();
2728
2729   tet_infoline("Set an empty layout on hbox container");
2730   LinearLayout emptyLayout;
2731   DevelControl::SetLayout( hbox, emptyLayout );
2732
2733   tet_infoline("Run another layout");
2734   application.SendNotification();
2735   application.Render();
2736
2737   tet_infoline("Check leaf controls haven't moved");
2738
2739   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2740   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2741
2742   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2743   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2744
2745   END_TEST;
2746 }
2747
2748 int UtcDaliLayouting_LayoutChildren01(void)
2749 {
2750   ToolkitTestApplication application;
2751   tet_infoline(" UtcDaliLayouting_LayoutChildren01");
2752
2753   Stage stage = Stage::GetCurrent();
2754
2755   auto rootControl = Control::New();
2756   auto absoluteLayout = AbsoluteLayout::New();
2757   DevelControl::SetLayout( rootControl, absoluteLayout );
2758   stage.Add( rootControl );
2759
2760   auto hbox = Control::New();
2761   auto hboxLayout = LinearLayout::New();
2762   DevelControl::SetLayout( hbox, hboxLayout );
2763   rootControl.Add( hbox );
2764
2765   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2766
2767   tet_infoline("Test removal by setting empty layout to child container" );
2768   DevelControl::SetLayout( hbox, LayoutItem{} );
2769
2770   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2771
2772   auto& hboxImpl = GetImplementation( hboxLayout );
2773   Handle empty;
2774   DALI_TEST_EQUALS( hboxLayout.GetOwner(), empty, TEST_LOCATION );
2775   DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2776
2777   // For coverage
2778   hboxImpl.SetLayoutRequested();
2779
2780   END_TEST;
2781 }
2782
2783 int UtcDaliLayouting_LayoutChildren02(void)
2784 {
2785   ToolkitTestApplication application;
2786   tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2787
2788   Stage stage = Stage::GetCurrent();
2789
2790   auto rootControl = Control::New();
2791   auto absoluteLayout = AbsoluteLayout::New();
2792   DevelControl::SetLayout( rootControl, absoluteLayout );
2793   stage.Add( rootControl );
2794
2795   auto hbox = Control::New();
2796   auto hboxLayout = LinearLayout::New();
2797   DevelControl::SetLayout( hbox, hboxLayout );
2798   rootControl.Add( hbox );
2799
2800   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2801
2802   tet_infoline("Test removal by removing child actor from parent container" );
2803   hbox.Unparent();
2804
2805   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2806
2807   auto& hboxImpl = GetImplementation( hboxLayout );
2808   tet_infoline("Test child actor still has hbox layout " );
2809   DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
2810
2811   tet_infoline("Test hbox layout has no parent " );
2812   DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2813
2814   END_TEST;
2815 }
2816
2817 int UtcDaliLayouting_LayoutChildren03(void)
2818 {
2819   ToolkitTestApplication application;
2820   tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2821
2822   Stage stage = Stage::GetCurrent();
2823
2824   auto rootControl = Control::New();
2825   auto absoluteLayout = AbsoluteLayout::New();
2826   DevelControl::SetLayout( rootControl, absoluteLayout );
2827   stage.Add( rootControl );
2828
2829   auto hbox = Control::New();
2830   auto hboxLayout = LinearLayout::New();
2831   DevelControl::SetLayout( hbox, hboxLayout );
2832   rootControl.Add( hbox );
2833
2834   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2835
2836   tet_infoline("Test removal by removing child layout from parent layout" );
2837   absoluteLayout.Remove( hboxLayout );
2838
2839   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2840
2841   auto& hboxImpl = GetImplementation( hboxLayout );
2842
2843   tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
2844   DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
2845   DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
2846
2847   tet_infoline("Check orphaned layout has no parent");
2848   DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2849
2850   END_TEST;
2851 }
2852
2853
2854 int UtcDaliLayouting_LayoutChildren04(void)
2855 {
2856   ToolkitTestApplication application;
2857   tet_infoline(" UtcDaliLayouting_LayoutChildren03");
2858
2859   Stage stage = Stage::GetCurrent();
2860
2861   auto rootControl = Control::New();
2862   auto absoluteLayout = AbsoluteLayout::New();
2863   DevelControl::SetLayout( rootControl, absoluteLayout );
2864   stage.Add( rootControl );
2865
2866   auto hbox = Control::New();
2867   tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
2868   auto hboxLayout = LinearLayout::New();
2869   rootControl.Add( hbox );
2870
2871   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2872
2873   tet_infoline("Then setting a layout on the child container");
2874   DevelControl::SetLayout( hbox, hboxLayout );
2875
2876   DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2877
2878   auto& hboxImpl = GetImplementation( hboxLayout );
2879   auto& absImpl = GetImplementation( absoluteLayout );
2880   DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
2881   DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
2882
2883   END_TEST;
2884 }
2885
2886 int UtcDaliLayouting_SetLayoutOrder01(void)
2887 {
2888   ToolkitTestApplication application;
2889   tet_infoline(" UtcDaliLayouting_SetLayoutOrder01 - Call SetLayout after adding the control to the root layout");
2890
2891   Stage stage = Stage::GetCurrent();
2892
2893   auto rootControl = Control::New();
2894   auto absoluteLayout = AbsoluteLayout::New();
2895   DevelControl::SetLayout( rootControl, absoluteLayout );
2896   rootControl.SetName( "AbsoluteLayout" );
2897   stage.Add( rootControl );
2898
2899   tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
2900   auto hbox = Control::New();
2901   auto hboxLayout = LinearLayout::New();
2902   hbox.SetName( "HBox");
2903
2904   tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
2905   rootControl.Add( hbox );
2906
2907   tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
2908   DevelControl::SetLayout( hbox, hboxLayout );
2909
2910   // Add a Child control
2911   std::vector< Control > controls;
2912   controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
2913   for( auto&& iter : controls )
2914   {
2915     hbox.Add( iter );
2916   }
2917
2918   // Ensure layouting happens
2919   application.SendNotification();
2920   application.Render();
2921
2922   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2923
2924   END_TEST;
2925 }
2926
2927 int UtcDaliLayouting_SetLayoutOrder02(void)
2928 {
2929   ToolkitTestApplication application;
2930   tet_infoline(" UtcDaliLayouting_SetLayoutOrder02 - Test the layout item order and the control order");
2931
2932   Stage stage = Stage::GetCurrent();
2933
2934   auto rootControl = Control::New();
2935   auto absoluteLayout = AbsoluteLayout::New();
2936   DevelControl::SetLayout( rootControl, absoluteLayout );
2937   rootControl.SetName( "AbsoluteLayout" );
2938   stage.Add( rootControl );
2939
2940   auto hbox = Control::New();
2941   auto hboxLayout = LinearLayout::New();
2942   hbox.SetName( "HBox");
2943
2944   rootControl.Add( hbox );
2945
2946   DevelControl::SetLayout( hbox, hboxLayout );
2947
2948   // Add child controls
2949   std::vector< Control > controls;
2950   controls.push_back( CreateLeafControl( 100, 100 ) );  // 0
2951   controls.push_back( CreateLeafControl( 100, 100 ) );  // 1
2952   controls.push_back( CreateLeafControl( 100, 100 ) );  // 2
2953
2954   for( auto&& iter : controls )
2955   {
2956     hbox.Add( iter );
2957   }
2958
2959   // Ensure layouting happens
2960   application.SendNotification();
2961   application.Render();
2962
2963   TestLayoutItemOrder( controls, hboxLayout );
2964
2965   tet_infoline("RaiseToTop");
2966
2967   controls[0].RaiseToTop(); // 1 2 0
2968
2969   TestLayoutItemOrder( controls, hboxLayout );
2970
2971   tet_infoline("LowerToBottom");
2972
2973   controls[2].LowerToBottom();  // 2 1 0
2974
2975   TestLayoutItemOrder( controls, hboxLayout );
2976
2977   tet_infoline("Remove / Add");
2978
2979   hbox.Remove( controls[2] );  // 1 0
2980   hbox.Add( controls[2] );     // 1 0 2
2981
2982   TestLayoutItemOrder( controls, hboxLayout );
2983
2984   tet_infoline("SetLayout");
2985
2986   auto vboxLayout = LinearLayout::New();
2987   DevelControl::SetLayout( controls[0], vboxLayout );
2988
2989   TestLayoutItemOrder( controls, hboxLayout );
2990
2991   tet_infoline("Raise");
2992
2993   controls[0].Raise();  // 1 2 0
2994
2995   TestLayoutItemOrder( controls, hboxLayout );
2996
2997   tet_infoline("Lower");
2998
2999   controls[2].Lower();   // 2 1 0
3000
3001   TestLayoutItemOrder( controls, hboxLayout );
3002
3003   tet_infoline("SetLayout again");
3004
3005   auto vboxLayout1 = LinearLayout::New();
3006   DevelControl::SetLayout( controls[2], vboxLayout1 );
3007
3008   TestLayoutItemOrder( controls, hboxLayout );
3009
3010   DevelControl::SetLayout( controls[2], vboxLayout );
3011
3012   END_TEST;
3013 }
3014
3015 int UtcDaliLayouting_LayoutGroup01(void)
3016 {
3017   ToolkitTestApplication application;
3018   tet_infoline("UtcDaliLayouting_LayoutGroup01 - Test adding a control to a layout then adding a TextLabel to that control");
3019
3020   Control rootControl;
3021   SetupRootLayoutControl( rootControl );
3022
3023   // Create a parent layout
3024   auto hbox = Control::New();
3025   auto hboxLayout = LinearLayout::New();
3026   hbox.SetName( "HBox");
3027   rootControl.Add( hbox );
3028   DevelControl::SetLayout( hbox, hboxLayout );
3029   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3030   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3031   DevelControl::SetLayoutingRequired( hbox, true );
3032   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3033
3034   tet_infoline("Add a control without SetLayout being called but with layout required set true");
3035
3036   auto control = Control::New();
3037   control.SetName("Control1");
3038   DevelControl::SetLayoutingRequired( control, true );
3039   hbox.Add( control );
3040   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3041   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3042   tet_infoline("Add a Textlabel to the control");
3043   auto textLabel = TextLabel::New("Test text");
3044   textLabel.SetName("TextLabel");
3045
3046   control.Add( textLabel );
3047
3048   // Ensure layouting happens
3049   application.SendNotification();
3050   application.Render();
3051
3052   tet_infoline("Test text is it's natural size");
3053   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3054   tet_infoline("Test control is width of it's parent and height of it's child");
3055   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3056
3057   END_TEST;
3058 }
3059
3060 int UtcDaliLayouting_LayoutGroup02(void)
3061 {
3062   ToolkitTestApplication application;
3063   tet_infoline("UtcDaliLayouting_LayoutGroup02 - Test control is the size of it's largest child");
3064
3065   Control rootControl;
3066   SetupRootLayoutControl( rootControl );
3067
3068   // Create a parent layout
3069   auto hbox = Control::New();
3070   auto hboxLayout = LinearLayout::New();
3071   DevelControl::SetLayout( hbox, hboxLayout );
3072   hbox.SetName( "HBox");
3073   rootControl.Add( hbox );
3074   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3075   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3076   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3077
3078   tet_infoline("Add a control without SetLayout being called but with layout required set true");
3079
3080   auto control = Control::New();
3081   control.SetName("Control1");
3082   DevelControl::SetLayoutingRequired( control, true );
3083   hbox.Add( control );
3084   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3085   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3086
3087   tet_infoline("Add a Textlabel to the control");
3088   auto textLabel = TextLabel::New("Test text");
3089   textLabel.SetName("TextLabel");
3090   control.Add( textLabel );
3091
3092   tet_infoline("Add another  Textlabel to the control");
3093   auto largeTextLabel = TextLabel::New("Test large text");
3094   largeTextLabel.SetName("TextLabel-Large");
3095   control.Add( largeTextLabel );
3096
3097   // Ensure layouting happens
3098   application.SendNotification();
3099   application.Render();
3100
3101   tet_infoline("Test text is it's natural size");
3102   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3103   tet_infoline("Test text is centered in the control, the control is the size of the largest child");
3104   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3105
3106   tet_infoline("Test large text is it's natural size");
3107   DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3108   tet_infoline("Test text is aligned to start as is the size of the control");
3109   DALI_TEST_EQUALS( largeTextLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3110
3111   tet_infoline("Test control is width of it's parent and height of it's largest child");
3112   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3113
3114   END_TEST;
3115 }
3116
3117 int UtcDaliLayouting_LayoutGroup03(void)
3118 {
3119   ToolkitTestApplication application;
3120   tet_infoline("UtcDaliLayouting_LayoutGroup03 - Test control with a LayoutGroup as a leaf");
3121
3122   Control rootControl;
3123   SetupRootLayoutControl( rootControl );
3124
3125   // Create a parent layout
3126   auto hbox = Control::New();
3127   auto hboxLayout = LinearLayout::New();
3128   DevelControl::SetLayout( hbox, hboxLayout );
3129   hbox.SetName( "HBox");
3130   rootControl.Add( hbox );
3131   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3132   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3133   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3134
3135   tet_infoline("Add a control without SetLayout being called");
3136
3137   auto control = Control::New();
3138   control.SetName("Control1");
3139   hbox.Add( control );
3140   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3141   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  100 );
3142
3143   // Ensure layouting happens
3144   application.SendNotification();
3145   application.Render();
3146
3147   tet_infoline("Test control is width of it's parent and exact given height");
3148   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3149   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3150
3151   END_TEST;
3152 }
3153
3154
3155 int UtcDaliLayouting_LayoutGroup04(void)
3156 {
3157   ToolkitTestApplication application;
3158   tet_infoline("UtcDaliLayouting_LayoutGroup04 - Test control with a LayoutGroup as a leaf and with SetLayotRequired = true");
3159
3160   Control rootControl;
3161   SetupRootLayoutControl( rootControl );
3162
3163   // Create a parent layout
3164   auto hbox = Control::New();
3165   auto hboxLayout = LinearLayout::New();
3166   DevelControl::SetLayout( hbox, hboxLayout );
3167   hbox.SetName( "HBox");
3168   rootControl.Add( hbox );
3169   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3170   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3171   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3172
3173   tet_infoline("Add a control without SetLayout being called");
3174
3175   auto control = Control::New();
3176   control.SetName("Control1");
3177   DevelControl::SetLayoutingRequired( control, true );
3178   hbox.Add( control );
3179   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3180   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  100 );
3181
3182   // Ensure layouting happens
3183   application.SendNotification();
3184   application.Render();
3185
3186   tet_infoline("Test control is width of it's parent and exact given height");
3187   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3188   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3189
3190   END_TEST;
3191 }
3192
3193 int UtcDaliLayouting_IsLayoutingRequired(void)
3194 {
3195   ToolkitTestApplication application;
3196   tet_infoline("UtcDaliLayouting_IsLayoutingRequired - Test setting the SetLayoutRequired and then check if flag was set");
3197
3198   Control rootControl;
3199   SetupRootLayoutControl( rootControl );
3200
3201   // Create a parent layout
3202   auto hbox = Control::New();
3203   auto hboxLayout = LinearLayout::New();
3204   DevelControl::SetLayout( hbox, hboxLayout );
3205   hbox.SetName( "HBox");
3206   rootControl.Add( hbox );
3207   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3208   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3209   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3210
3211   tet_infoline("Add a control without SetLayout being called");
3212
3213   auto control = Control::New();
3214   control.SetName("Control1");
3215   DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), false, TEST_LOCATION );
3216   DevelControl::SetLayoutingRequired( control, true );
3217   hbox.Add( control );
3218   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
3219   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  100 );
3220
3221   // Ensure layouting happens
3222   application.SendNotification();
3223   application.Render();
3224
3225   tet_infoline("Test control is width of it's parent and exact given height");
3226   DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), true, TEST_LOCATION );
3227
3228   END_TEST;
3229 }
3230
3231 int UtcDaliLayouting_LayoutGroupWithPadding01(void)
3232 {
3233   ToolkitTestApplication application;
3234   tet_infoline("UtcDaliLayouting_LayoutGroupWithPadding01 - Test adding a control to a layout that has padding");
3235
3236   Control rootControl;
3237   SetupRootLayoutControl( rootControl );
3238
3239   // Create a parent layout
3240   auto hbox = Control::New();
3241   auto hboxLayout = LinearLayout::New();
3242   hbox.SetName( "HBox");
3243   rootControl.Add( hbox );
3244   DevelControl::SetLayout( hbox, hboxLayout );
3245   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3246   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3247   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3248
3249   tet_infoline("Add a control without SetLayout being called");
3250
3251   auto control = Control::New();
3252   control.SetName("Control1");
3253   DevelControl::SetLayoutingRequired( control, true );
3254   hbox.Add( control );
3255   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3256   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3257
3258   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
3259   tet_printf( "Adding Padding to control");
3260   control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
3261
3262   tet_infoline("Add a Textlabel to the control");
3263   auto textLabel = TextLabel::New("Test text");
3264   textLabel.SetName("TextLabel");
3265   control.Add( textLabel );
3266
3267   // Ensure layouting happens
3268   application.SendNotification();
3269   application.Render();
3270
3271   tet_infoline("Test text is it's natural size");
3272   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3273   tet_infoline("Test control is size of it's child and control it's own padding");
3274   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 245.0f, 86.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3275
3276   END_TEST;
3277 }
3278
3279 int UtcDaliLayouting_LayoutGroupWithChildMargin01(void)
3280 {
3281   ToolkitTestApplication application;
3282   tet_infoline("UtcDaliLayouting_LayoutGroupWithChildMargin01 - Test adding a control with padding to a layout that has padding");
3283
3284   Control rootControl;
3285   SetupRootLayoutControl( rootControl );
3286
3287   // Create a parent layout
3288   auto hbox = Control::New();
3289   auto hboxLayout = LinearLayout::New();
3290   hbox.SetName( "HBox");
3291   rootControl.Add( hbox );
3292   DevelControl::SetLayout( hbox, hboxLayout );
3293   hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
3294   hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3295   hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT );  // LinearLayout will eventually do this internally.
3296
3297   tet_infoline("Add a control without SetLayout being called");
3298
3299   auto control = Control::New();
3300   control.SetName("Control1");
3301   DevelControl::SetLayoutingRequired( control, true );
3302   hbox.Add( control );
3303   control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
3304   control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,  ChildLayoutData::WRAP_CONTENT );
3305
3306   const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
3307   tet_printf( "Adding Padding to control");
3308   control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING );
3309
3310   tet_infoline("Add a Textlabel to the control");
3311   auto textLabel = TextLabel::New("Test text");
3312   const Extents CHILD_MARGIN = Extents( 10, 0, 5, 0 );
3313   textLabel.SetProperty( Toolkit::Control::Property::MARGIN, CHILD_MARGIN );
3314   textLabel.SetName("TextLabel");
3315   control.Add( textLabel );
3316
3317   // Ensure layouting happens
3318   application.SendNotification();
3319   application.Render();
3320
3321   tet_infoline("Test text is it's natural size");
3322   DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3323   tet_infoline("Test control is width of it's parent and height of it's child");
3324   DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 255.0f, 91.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3325
3326   END_TEST;
3327 }
3328
3329 int UtcDaliLayouting_SetLayout(void)
3330 {
3331   ToolkitTestApplication application;
3332   tet_infoline(" UtcDaliLayouting_SetLayout - Test reusing layouts");
3333
3334   Control rootControl;
3335   SetupRootLayoutControl( rootControl );
3336
3337   auto container = Control::New();
3338   auto horizontalLayout = LinearLayout::New();
3339   horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
3340   DevelControl::SetLayout( container, horizontalLayout );
3341   container.SetName( "Container" );
3342   rootControl.Add( container );
3343
3344   std::vector< Control > controls;
3345   controls.push_back( CreateLeafControl( 40, 40 ) );
3346   controls.push_back( CreateLeafControl( 60, 60 ) );
3347
3348   for( auto&& iter : controls )
3349   {
3350     container.Add( iter );
3351   }
3352
3353   container.SetParentOrigin( ParentOrigin::CENTER );
3354   container.SetAnchorPoint( AnchorPoint::CENTER );
3355
3356   // Ensure layouting happens
3357   application.SendNotification();
3358   application.Render();
3359
3360   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3361   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3362   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3363
3364   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3365   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3366   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3367
3368   // Change a layout
3369   auto verticalLayout = LinearLayout::New();
3370   verticalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
3371   DevelControl::SetLayout( container, verticalLayout );
3372
3373   application.SendNotification();
3374   application.Render();
3375
3376   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3377   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3378   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3379
3380   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3381   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3382   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3383
3384   // Second round
3385   DevelControl::SetLayout( container, horizontalLayout );
3386
3387   application.SendNotification();
3388   application.Render();
3389
3390   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3391   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3392   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3393
3394   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3395   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3396   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3397
3398   // Change a layout
3399   DevelControl::SetLayout( container, verticalLayout );
3400
3401   application.SendNotification();
3402   application.Render();
3403
3404   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3405   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3406   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3407
3408   DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3409   DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3410   DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
3411
3412   END_TEST;
3413 }