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