2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <toolkit-event-thread-callback.h>
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>
28 #include <../custom-layout.h>
30 #include <layout-utils.h>
33 using namespace Toolkit;
35 void utc_dali_toolkit_layouting_startup(void)
37 test_return_value = TET_UNDEF;
40 void utc_dali_toolkit_layouting_cleanup(void)
42 test_return_value = TET_PASS;
45 int UtcDaliLayouting_HboxLayout01(void)
47 ToolkitTestApplication application;
48 tet_infoline(" UtcDaliLayouting_HboxLayout01");
50 Stage stage = Stage::GetCurrent();
51 auto hbox = Control::New();
52 auto hboxLayout = LinearLayout::New();
53 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
54 DevelControl::SetLayout( hbox, hboxLayout );
55 hbox.SetName( "HBox");
57 std::vector< Control > controls;
58 controls.push_back( CreateLeafControl( 40, 40 ) );
59 controls.push_back( CreateLeafControl( 60, 40 ) );
60 controls.push_back( CreateLeafControl( 80, 40 ) );
61 controls.push_back( CreateLeafControl( 100, 40 ) );
63 for( auto&& iter : controls )
67 hbox.SetParentOrigin( ParentOrigin::CENTER );
68 hbox.SetAnchorPoint( AnchorPoint::CENTER );
71 // Ensure layouting happens
72 application.SendNotification();
75 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
76 // hbox left justifies elements
77 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
78 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
79 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
80 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
82 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
83 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
84 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
85 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
88 auto newHBoxLayout = LinearLayout::New();
89 newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
90 DevelControl::SetLayout( hbox, newHBoxLayout );
92 application.SendNotification();
95 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
96 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
97 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
98 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
103 int UtcDaliLayouting_HboxLayout02(void)
105 ToolkitTestApplication application;
106 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
108 Stage stage = Stage::GetCurrent();
110 auto hbox1 = Control::New();
111 auto hboxLayout1 = LinearLayout::New();
112 DevelControl::SetLayout( hbox1, hboxLayout1 );
114 auto hbox2 = Control::New();
115 auto hboxLayout2 = LinearLayout::New();
116 DevelControl::SetLayout( hbox2, hboxLayout2 );
118 hbox1.SetName( "HBox1");
119 hbox2.SetName( "HBox2");
121 std::vector< Control > controls;
122 controls.push_back( CreateLeafControl( 20, 40 ) );
123 controls.push_back( CreateLeafControl( 30, 50 ) );
124 controls.push_back( CreateLeafControl( 40, 60 ) );
125 controls.push_back( CreateLeafControl( 50, 70 ) );
127 controls.push_back( CreateLeafControl( 25, 40 ) );
128 controls.push_back( CreateLeafControl( 35, 50 ) );
129 controls.push_back( CreateLeafControl( 45, 60 ) );
130 controls.push_back( CreateLeafControl( 55, 70 ) );
133 for( auto&& iter : controls )
145 hbox1.SetParentOrigin( ParentOrigin::CENTER );
146 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
147 hbox2.SetParentOrigin( ParentOrigin::CENTER );
148 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
150 auto hbox3 = Control::New();
151 auto hboxLayout3 = LinearLayout::New();
152 DevelControl::SetLayout( hbox3, hboxLayout3 );
154 hbox3.SetParentOrigin( ParentOrigin::CENTER );
155 hbox3.SetName( "HBox3");
161 // Ensure layouting happens
162 application.SendNotification();
163 application.Render();
166 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
167 // hbox left justifies elements
168 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
169 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
170 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
171 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
173 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
174 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
175 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
176 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
179 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
180 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
181 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
182 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
184 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
185 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
186 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
187 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
189 // Test hbox1 and 2 are sized to wrap their content
190 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
191 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
192 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
193 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
195 // Test hbox3 matches parent (root layer)
196 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
197 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
203 int UtcDaliLayouting_HboxLayout03(void)
205 ToolkitTestApplication application;
206 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
208 Stage stage = Stage::GetCurrent();
210 auto hbox1 = Control::New();
211 auto hboxLayout1 = LinearLayout::New();
212 DevelControl::SetLayout( hbox1, hboxLayout1 );
214 auto hbox2 = Control::New();
215 auto hboxLayout2 = LinearLayout::New();
216 DevelControl::SetLayout( hbox2, hboxLayout2 );
218 hbox1.SetName( "HBox1");
219 hbox2.SetName( "HBox2");
220 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
221 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
222 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
223 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
225 std::vector< Control > controls;
226 controls.push_back( CreateLeafControl( 20, 40 ) );
227 controls.push_back( CreateLeafControl( 30, 50 ) );
228 controls.push_back( CreateLeafControl( 40, 60 ) );
229 controls.push_back( CreateLeafControl( 50, 70 ) );
231 controls.push_back( CreateLeafControl( 25, 40 ) );
232 controls.push_back( CreateLeafControl( 35, 50 ) );
233 controls.push_back( CreateLeafControl( 45, 60 ) );
234 controls.push_back( CreateLeafControl( 55, 70 ) );
237 for( auto&& iter : controls )
249 hbox1.SetParentOrigin( ParentOrigin::CENTER );
250 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
251 hbox2.SetParentOrigin( ParentOrigin::CENTER );
252 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
254 auto hbox3 = Control::New();
255 auto hboxLayout3 = LinearLayout::New();
256 DevelControl::SetLayout( hbox3, hboxLayout3);
258 hbox3.SetParentOrigin( ParentOrigin::CENTER );
259 hbox3.SetName( "HBox3");
265 //std::ostringstream oss;
266 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
267 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
269 // Ensure layouting happens
270 application.SendNotification();
271 application.Render();
274 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
275 // hbox left justifies elements
276 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
277 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
278 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
279 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
281 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
282 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
283 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
284 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
286 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
287 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
288 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
289 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
291 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
292 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
293 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
294 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
296 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
297 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
298 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
299 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
301 // Test hbox3 matches parent (root layer)
302 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
303 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
308 int UtcDaliLayouting_HboxLayout04(void)
310 ToolkitTestApplication application;
311 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
313 Stage stage = Stage::GetCurrent();
315 auto hbox1 = Control::New();
316 auto hboxLayout1 = LinearLayout::New();
317 DevelControl::SetLayout( hbox1, hboxLayout1 );
319 auto hbox2 = Control::New();
320 auto hboxLayout2 = LinearLayout::New();
321 DevelControl::SetLayout( hbox2, hboxLayout2 );
323 hbox1.SetName( "HBox1"); // Default spec is to wrap content
324 hbox2.SetName( "HBox2");
325 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
326 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
327 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
328 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
330 std::vector< Control > controls;
331 controls.push_back( CreateLeafControl( 80, 40 ) );
332 controls.push_back( CreateLeafControl( 80, 50 ) );
333 controls.push_back( CreateLeafControl( 80, 60 ) );
334 controls.push_back( CreateLeafControl( 80, 70 ) );
336 controls.push_back( CreateLeafControl( 80, 40 ) );
337 controls.push_back( CreateLeafControl( 80, 50 ) );
338 controls.push_back( CreateLeafControl( 80, 60 ) );
339 controls.push_back( CreateLeafControl( 80, 70 ) );
342 for( auto&& iter : controls )
355 controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
356 auto hbox3 = Control::New();
357 auto hboxLayout3 = LinearLayout::New();
358 DevelControl::SetLayout( hbox3, hboxLayout3 );
360 hbox3.SetParentOrigin( ParentOrigin::CENTER );
361 hbox3.SetName( "HBox3");
366 //std::ostringstream oss;
367 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
368 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
370 // Ensure layouting happens
371 application.SendNotification();
372 application.Render();
375 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
376 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
377 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
378 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
380 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
381 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
382 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
383 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
385 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
386 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
387 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
388 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
390 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
391 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
392 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
393 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
395 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
396 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
397 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
398 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
401 // Test hbox3 matches parent (root layer)
402 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
403 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
408 int UtcDaliLayouting_HboxLayout05(void)
410 ToolkitTestApplication application;
411 tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
413 Stage stage = Stage::GetCurrent();
414 auto hbox = Control::New();
415 auto hboxLayout = LinearLayout::New();
416 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
417 DevelControl::SetLayout( hbox, hboxLayout );
418 hbox.SetName( "HBox");
420 std::vector< Control > controls;
421 controls.push_back( CreateLeafControl( 40, 40 ) );
422 controls.push_back( CreateLeafControl( 60, 40 ) );
423 controls.push_back( CreateLeafControl( 80, 40 ) );
424 controls.push_back( CreateLeafControl( 100, 40 ) );
426 for( auto&& iter : controls )
429 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
430 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
433 hbox.SetParentOrigin( ParentOrigin::CENTER );
434 hbox.SetAnchorPoint( AnchorPoint::CENTER );
437 // Ensure layouting happens
438 application.SendNotification();
439 application.Render();
441 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
442 // hbox left justifies elements
443 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
444 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
445 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
446 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
448 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
449 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
450 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
451 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
456 int UtcDaliLayouting_HboxLayout06(void)
458 ToolkitTestApplication application;
459 tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
461 Stage stage = Stage::GetCurrent();
463 auto rootControl = Control::New();
464 auto absoluteLayout = AbsoluteLayout::New();
465 DevelControl::SetLayout( rootControl, absoluteLayout );
466 rootControl.SetName( "AbsoluteLayout" );
467 stage.Add( rootControl );
469 auto hbox = Control::New();
470 auto hboxLayout = LinearLayout::New();
471 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
472 DevelControl::SetLayout( hbox, hboxLayout );
473 hbox.SetName( "HBox" );
475 std::vector< Control > controls;
476 controls.push_back( CreateLeafControl( 40, 40 ) );
477 controls.push_back( CreateLeafControl( 60, 40 ) );
479 for( auto&& iter : controls )
483 hbox.SetParentOrigin( ParentOrigin::CENTER );
484 hbox.SetAnchorPoint( AnchorPoint::CENTER );
485 rootControl.Add( hbox );
487 // Ensure layouting happens
488 application.SendNotification();
489 application.Render();
491 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
492 // hbox left justifies elements
493 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
494 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
496 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
497 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
499 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
502 auto newHBoxLayout = LinearLayout::New();
503 newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
504 DevelControl::SetLayout( hbox, newHBoxLayout );
506 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
507 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
509 application.SendNotification();
510 application.Render();
512 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
514 // Change size specification
515 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
516 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
518 application.SendNotification();
519 application.Render();
521 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
523 // Use WRAP_CONTENT again
524 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
525 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
527 application.SendNotification();
528 application.Render();
530 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
535 int UtcDaliLayouting_HboxLayout07(void)
537 ToolkitTestApplication application;
538 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
540 Stage stage = Stage::GetCurrent();
541 auto hbox = Control::New();
542 auto hboxLayout = LinearLayout::New();
543 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
544 DevelControl::SetLayout( hbox, hboxLayout );
545 hbox.SetName( "HBox");
547 std::vector< Control > controls;
548 controls.push_back( CreateLeafControl( 40, 40 ) );
549 controls.push_back( CreateLeafControl( 60, 40 ) );
550 controls.push_back( CreateLeafControl( 80, 40 ) );
551 controls.push_back( CreateLeafControl( 100, 40 ) );
553 for( auto&& iter : controls )
557 hbox.SetParentOrigin( ParentOrigin::CENTER );
558 hbox.SetAnchorPoint( AnchorPoint::CENTER );
561 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
563 // Ensure layouting happens
564 application.SendNotification();
565 application.Render();
567 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
568 // hbox left justifies elements
569 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
570 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
571 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
572 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
574 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
575 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
576 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
577 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
579 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
581 // Ensure layouting happens
582 application.SendNotification();
583 application.Render();
585 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
586 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
587 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
588 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
590 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
591 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
592 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
593 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
598 int UtcDaliLayouting_HboxLayout08(void)
600 ToolkitTestApplication application;
601 tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation");
603 Stage stage = Stage::GetCurrent();
605 auto rootControl = Control::New();
606 auto absoluteLayout = AbsoluteLayout::New();
607 absoluteLayout.SetAnimateLayout( true );
608 DevelControl::SetLayout( rootControl, absoluteLayout );
609 rootControl.SetName( "AbsoluteLayout" );
610 stage.Add( rootControl );
612 Control control1 = CreateLeafControl( 40, 40 );
613 rootControl.Add( control1 );
614 auto hbox = Control::New();
615 auto hboxLayout = LinearLayout::New();
616 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
617 DevelControl::SetLayout( hbox, hboxLayout );
618 hbox.SetName( "HBox" );
620 Control control2 = CreateLeafControl( 40, 40 );
621 hbox.Add( control2 );
623 hbox.SetParentOrigin( ParentOrigin::CENTER );
624 hbox.SetAnchorPoint( AnchorPoint::CENTER );
625 rootControl.Add( hbox );
627 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION );
628 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION );
629 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION );
630 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION );
632 hboxLayout.SetAnimateLayout( true );
633 absoluteLayout.SetAnimateLayout( false );
635 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION );
636 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION );
637 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION );
638 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION );
645 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/broken.png";
648 int UtcDaliLayouting_HboxLayout_ImageView(void)
650 ToolkitTestApplication application;
651 tet_infoline(" UtcDaliLayouting_HboxLayout - Use image view for leaf");
653 Stage stage = Stage::GetCurrent();
654 auto hbox = Control::New();
655 auto hboxLayout = LinearLayout::New();
656 DevelControl::SetLayout( hbox, hboxLayout );
657 hbox.SetName( "HBox" );
659 std::string url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 100, 100 ) );
660 ImageView imageView = CreateImageView( url, ImageDimensions() );
662 hbox.SetParentOrigin( ParentOrigin::CENTER );
663 hbox.SetAnchorPoint( AnchorPoint::CENTER );
664 hbox.Add( imageView );
667 // Ensure layouting happens
668 application.SendNotification();
669 application.Render();
671 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
672 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
674 url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 200, 200 ) );
675 imageView.SetImage( url );
677 // Ensure layouting happenss
678 application.SendNotification();
679 application.Render();
681 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
682 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
684 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
685 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
687 // Ensure layouting happenss
688 application.SendNotification();
689 application.Render();
691 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
692 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
694 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
695 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
697 // Ensure layouting happenss
698 application.SendNotification();
699 application.Render();
701 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
702 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
704 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
705 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
707 Image image = FrameBufferImage::New( 50, 50, Pixel::RGBA8888 );
708 imageView.SetImage( image );
710 // Ensure layouting happenss
711 application.SendNotification();
712 application.Render();
714 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
715 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
717 Property::Map imagePropertyMap;
718 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
719 imagePropertyMap[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
720 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 150;
721 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 150;
722 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap );
724 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
725 // Ensure layouting happenss
726 application.SendNotification();
727 application.Render();
729 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 325.0f, 0.0f ), 0.0001f, TEST_LOCATION );
730 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
735 int UtcDaliLayouting_HboxLayout_TextLabel(void)
737 ToolkitTestApplication application;
738 tet_infoline(" UtcDaliLayouting_HboxLayout - Use text label for leaf");
740 Stage stage = Stage::GetCurrent();
742 auto hbox = Control::New();
743 auto hboxLayout = LinearLayout::New();
744 DevelControl::SetLayout( hbox, hboxLayout );
745 hbox.SetName( "HBox" );
746 hbox.SetParentOrigin( ParentOrigin::CENTER );
747 hbox.SetAnchorPoint( AnchorPoint::CENTER );
749 std::vector< Control > controls;
750 TextLabel textLabel = CreateTextLabel( "W" );
751 controls.push_back( textLabel );
752 hbox.Add( textLabel );
755 // Ensure layouting happens
756 application.SendNotification();
757 application.Render();
759 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
760 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 54.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
762 textLabel.SetProperty( TextLabel::Property::TEXT, "WWWW" );
764 // Ensure layouting happens
765 application.SendNotification();
766 application.Render();
768 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
769 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 216.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
771 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
773 // Ensure layouting happens
774 application.SendNotification();
775 application.Render();
777 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
778 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
780 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
781 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
783 // Ensure layouting happens
784 application.SendNotification();
785 application.Render();
787 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
788 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
790 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
791 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
793 // Ensure layouting happens
794 application.SendNotification();
795 application.Render();
797 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
798 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
805 int UtcDaliLayouting_HboxLayout_Padding01(void)
807 ToolkitTestApplication application;
808 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
810 Stage stage = Stage::GetCurrent();
811 auto hbox = Control::New();
812 auto hboxLayout = LinearLayout::New();
813 DevelControl::SetLayout( hbox, hboxLayout );
814 hbox.SetName( "HBox");
816 std::vector< Control > controls;
817 controls.push_back( CreateLeafControl( 40, 40 ) );
818 controls.push_back( CreateLeafControl( 60, 40 ) );
819 controls.push_back( CreateLeafControl( 80, 40 ) );
820 controls.push_back( CreateLeafControl( 100, 40 ) );
822 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
823 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
824 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
826 for( auto&& iter : controls )
830 hbox.SetParentOrigin( ParentOrigin::CENTER );
831 hbox.SetAnchorPoint( AnchorPoint::CENTER );
834 // Ensure layouting happens
835 application.SendNotification();
836 application.Render();
838 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
839 // hbox left justifies elements
840 tet_infoline("Test Child Actor Position");
841 float xPositionOfControlBeingTested = 0.0f;
842 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
844 0.0f ), 0.0001f, TEST_LOCATION );
845 xPositionOfControlBeingTested += 40.0f;
847 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
848 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
849 0.0001f, TEST_LOCATION );
851 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
852 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
854 xPositionOfControlBeingTested += 80.0f;
855 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
857 tet_infoline("Test Child Actor Size");
858 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
860 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
861 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
862 0.0001f, TEST_LOCATION );
864 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
865 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
870 int UtcDaliLayouting_HboxLayout_Padding02(void)
872 ToolkitTestApplication application;
873 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
875 Stage stage = Stage::GetCurrent();
876 auto hbox = Control::New();
877 auto hboxLayout = LinearLayout::New();
878 DevelControl::SetLayout( hbox, hboxLayout );
879 hbox.SetName( "HBox");
881 std::vector< Control > controls;
882 controls.push_back( CreateLeafControl( 40, 40 ) );
883 controls.push_back( CreateLeafControl( 60, 40 ) );
884 controls.push_back( CreateLeafControl( 80, 40 ) );
885 controls.push_back( CreateLeafControl( 100, 40 ) );
887 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
889 for( auto&& iter : controls )
891 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
894 hbox.SetParentOrigin( ParentOrigin::CENTER );
895 hbox.SetAnchorPoint( AnchorPoint::CENTER );
898 // Ensure layouting happens
899 application.SendNotification();
900 application.Render();
902 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
903 // hbox left justifies elements
904 tet_infoline("Test Child Actor Position");
905 float xPositionOfControlBeingTested = 0.0f;
906 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
908 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
909 yPositionOfControlBeingTested,
910 0.0f ), 0.0001f, TEST_LOCATION );
911 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
913 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
914 yPositionOfControlBeingTested,
916 0.0001f, TEST_LOCATION );
918 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
919 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
920 yPositionOfControlBeingTested,
921 0.0f ), 0.0001f, TEST_LOCATION );
923 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
924 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
925 yPositionOfControlBeingTested,
926 0.0f ), 0.0001f, TEST_LOCATION );
928 tet_infoline("Test Child Actor Size");
929 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
930 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
931 0.0f ), 0.0001f, TEST_LOCATION );
933 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
934 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
935 0.0f ), 0.0001f, TEST_LOCATION );
937 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
938 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
939 0.0f ), 0.0001f, TEST_LOCATION );
941 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
942 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
943 0.0f ), 0.0001f, TEST_LOCATION );
949 int UtcDaliLayouting_HboxLayout_Padding03(void)
951 ToolkitTestApplication application;
952 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
954 Stage stage = Stage::GetCurrent();
955 auto hbox = Control::New();
956 auto hboxLayout = LinearLayout::New();
957 DevelControl::SetLayout( hbox, hboxLayout );
958 hbox.SetName( "HBox");
960 std::vector< Control > controls;
961 controls.push_back( CreateLeafControl( 40, 40 ) );
962 controls.push_back( CreateLeafControl( 40, 40 ) );
963 controls.push_back( CreateLeafControl( 40, 40 ) );
965 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
966 tet_printf( "\nAdding Padding to control at index 1 \n" );
967 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
969 for( auto&& iter : controls )
973 hbox.SetParentOrigin( ParentOrigin::CENTER );
974 hbox.SetAnchorPoint( AnchorPoint::CENTER );
977 // Ensure layouting happens
978 application.SendNotification();
979 application.Render();
981 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
982 // hbox left justifies elements
983 tet_infoline("Test Child Actor Position");
984 float xPositionOfControlBeingTested = 0.0f;
985 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
987 0.0f ), 0.0001f, TEST_LOCATION );
988 xPositionOfControlBeingTested += 40.0f;
990 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
991 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
992 0.0001f, TEST_LOCATION );
994 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
995 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
997 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
998 tet_printf( "\nChanging Padding to control at index 1 \n" );
999 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
1001 // Ensure layouting happens
1002 application.SendNotification();
1003 application.Render();
1005 xPositionOfControlBeingTested = 0.0f; // reset
1007 tet_infoline("Test Child Actor Position");
1008 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1010 0.0f ), 0.0001f, TEST_LOCATION );
1011 xPositionOfControlBeingTested += 40.0f;
1013 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1014 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1015 0.0001f, TEST_LOCATION );
1017 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
1018 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
1019 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1021 tet_infoline("Test Child Actor Size");
1022 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1024 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
1025 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
1026 0.0001f, TEST_LOCATION );
1028 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1033 int UtcDaliLayouting_HboxLayout_Padding04(void)
1035 ToolkitTestApplication application;
1036 tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
1038 // Adding padding to the layout should offset the positioning of the children.
1040 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1041 const Size CONTROL_SIZE = Size( 40, 40 );
1043 Stage stage = Stage::GetCurrent();
1044 // Create a root layout, ideally Dali would have a default layout in the root layer.
1045 // Without this root layer the LinearLayout (or any other layout) will not
1046 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1047 // It uses the default stage size and ideally should have a layout added to it.
1048 auto rootLayoutControl = Control::New();
1049 rootLayoutControl.SetName( "AbsoluteLayout");
1050 auto rootLayout = AbsoluteLayout::New();
1051 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1052 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1053 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1054 stage.Add( rootLayoutControl );
1056 auto hbox = Control::New();
1057 auto hboxLayout = LinearLayout::New();
1058 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1059 DevelControl::SetLayout( hbox, hboxLayout );
1060 hbox.SetName( "HBox");
1061 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1062 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1063 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1065 std::vector< Control > controls;
1066 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1067 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1068 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1069 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1071 for( auto&& iter : controls )
1076 hbox.SetParentOrigin( ParentOrigin::CENTER );
1077 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1078 rootLayoutControl.Add( hbox );
1080 // Ensure layouting happens
1081 application.SendNotification();
1082 application.Render();
1084 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1085 application.SendNotification();
1087 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1088 // hbox left justifies elements
1089 tet_infoline("Test Child Actor Position");
1091 auto controlXPosition=0.0f;
1093 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1094 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1096 0.0f ), 0.0001f, TEST_LOCATION );
1098 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1099 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1102 0.0001f, TEST_LOCATION );
1104 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1105 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1107 0.0f ), 0.0001f, TEST_LOCATION );
1109 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1110 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1112 0.0f ), 0.0001f, TEST_LOCATION );
1114 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1115 auto totalControlsHeight = CONTROL_SIZE.height;
1117 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1118 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1119 0.0f ), 0.0001f, TEST_LOCATION );
1125 int UtcDaliLayouting_HboxLayout_Padding05(void)
1127 ToolkitTestApplication application;
1128 tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
1130 // Adding padding to the layout should offset the positioning of the children.
1132 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1133 const Size CONTROL_SIZE = Size( 40, 40 );
1135 Stage stage = Stage::GetCurrent();
1136 // Create a root layout, ideally Dali would have a default layout in the root layer.
1137 // Without this root layer the LinearLayout (or any other layout) will not
1138 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1139 // It uses the default stage size and ideally should have a layout added to it.
1140 auto rootLayoutControl = Control::New();
1141 rootLayoutControl.SetName( "AbsoluteLayout");
1142 auto rootLayout = AbsoluteLayout::New();
1143 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1144 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1145 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1146 stage.Add( rootLayoutControl );
1148 auto hbox = Control::New();
1149 auto hboxLayout = LinearLayout::New();
1150 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1151 DevelControl::SetLayout( hbox, hboxLayout );
1152 hbox.SetName( "HBox");
1153 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1154 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1155 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1157 std::vector< Control > controls;
1158 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1159 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1160 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1161 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1163 for( auto&& iter : controls )
1168 hbox.SetParentOrigin( ParentOrigin::CENTER );
1169 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1170 rootLayoutControl.Add( hbox );
1172 // Ensure layouting happens
1173 application.SendNotification();
1174 application.Render();
1176 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1177 application.SendNotification();
1179 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1180 // hbox left justifies elements
1181 tet_infoline("Test Child Actor Position");
1183 auto controlXPosition=0.0f;
1185 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1186 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1188 0.0f ), 0.0001f, TEST_LOCATION );
1190 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1191 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1194 0.0001f, TEST_LOCATION );
1196 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1197 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1199 0.0f ), 0.0001f, TEST_LOCATION );
1201 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1202 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1204 0.0f ), 0.0001f, TEST_LOCATION );
1206 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1207 auto totalControlsHeight = CONTROL_SIZE.height;
1209 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1210 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1211 0.0f ), 0.0001f, TEST_LOCATION );
1213 // Change layout padding
1214 const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
1215 tet_printf( "\nChanging Padding to control at index 1 \n" );
1216 hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
1218 // Ensure layouting happens
1219 application.SendNotification();
1220 application.Render();
1222 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1223 application.SendNotification();
1225 controlXPosition = NEW_LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1226 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
1227 NEW_LAYOUT_PADDING.top,
1228 0.0f ), 0.0001f, TEST_LOCATION );
1230 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1231 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1232 NEW_LAYOUT_PADDING.top,
1234 0.0001f, TEST_LOCATION );
1236 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1237 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1238 NEW_LAYOUT_PADDING.top,
1239 0.0f ), 0.0001f, TEST_LOCATION );
1241 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1242 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1243 NEW_LAYOUT_PADDING.top,
1244 0.0f ), 0.0001f, TEST_LOCATION );
1245 totalControlsWidth = CONTROL_SIZE.width * controls.size();
1246 totalControlsHeight = CONTROL_SIZE.height;
1248 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
1249 totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
1250 0.0f ), 0.0001f, TEST_LOCATION );
1256 int UtcDaliLayouting_HboxLayout_Margin01(void)
1258 ToolkitTestApplication application;
1259 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
1261 Stage stage = Stage::GetCurrent();
1262 auto hbox = Control::New();
1263 auto hboxLayout = LinearLayout::New();
1264 DevelControl::SetLayout( hbox, hboxLayout );
1265 hbox.SetName( "HBox");
1267 std::vector< Control > controls;
1268 controls.push_back( CreateLeafControl( 40, 40 ) );
1269 controls.push_back( CreateLeafControl( 60, 40 ) );
1270 controls.push_back( CreateLeafControl( 80, 40 ) );
1271 controls.push_back( CreateLeafControl( 100, 40 ) );
1273 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
1274 tet_printf( "\nAdding Margin to control at index 1 \n" );
1275 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1277 for( auto&& iter : controls )
1281 hbox.SetParentOrigin( ParentOrigin::CENTER );
1282 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1285 // Ensure layouting happens
1286 application.SendNotification();
1287 application.Render();
1289 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1290 // hbox left justifies elements
1291 tet_infoline("Test Child Actor Position");
1292 auto xPositionOfControlBeingTested = 0.0f;
1293 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1295 0.0f ), 0.0001f, TEST_LOCATION );
1296 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
1298 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1299 380.0f + CONTROL_MARGIN.top, 0.0f ),
1300 0.0001f, TEST_LOCATION );
1302 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
1303 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1305 xPositionOfControlBeingTested += 80.0f;
1306 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1308 tet_infoline("Test Child Actor Size is the same after Margin added");
1309 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1310 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
1311 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1312 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1318 int UtcDaliLayouting_VboxLayout01(void)
1320 ToolkitTestApplication application;
1321 tet_infoline(" UtcDaliLayouting_VboxLayout01");
1323 Stage stage = Stage::GetCurrent();
1324 auto vbox = Control::New();
1325 auto vboxLayout = LinearLayout::New();
1326 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1327 DevelControl::SetLayout( vbox, vboxLayout );
1328 vbox.SetName( "Vbox");
1330 std::vector< Control > controls;
1331 controls.push_back( CreateLeafControl( 40, 40 ) );
1332 controls.push_back( CreateLeafControl( 60, 60 ) );
1333 controls.push_back( CreateLeafControl( 80, 80 ) );
1334 controls.push_back( CreateLeafControl( 100, 100 ) );
1336 for( auto&& iter : controls )
1340 vbox.SetParentOrigin( ParentOrigin::CENTER );
1341 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1344 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1347 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1349 // Ensure layouting happens
1350 application.SendNotification();
1351 application.Render();
1353 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
1354 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1355 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1356 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1357 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1359 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1360 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1361 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1362 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1367 int UtcDaliLayouting_VboxLayout02(void)
1369 ToolkitTestApplication application;
1370 tet_infoline(" UtcDaliLayouting_VboxLayout01");
1372 Stage stage = Stage::GetCurrent();
1374 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1375 // LayoutGroup for this to happen automatically.
1377 // For this test, add an hbox instead
1378 auto rootControl = Control::New();
1379 auto absoluteLayout = AbsoluteLayout::New();
1380 DevelControl::SetLayout( rootControl, absoluteLayout );
1381 rootControl.SetName( "AbsoluteLayout");
1382 stage.Add( rootControl );
1384 auto vbox = Control::New();
1385 auto vboxLayout = LinearLayout::New();
1386 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1387 DevelControl::SetLayout( vbox, vboxLayout );
1388 vbox.SetName( "Vbox");
1389 rootControl.Add( vbox );
1391 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1392 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1394 std::vector< Control > controls;
1395 controls.push_back( CreateLeafControl( 40, 40 ) );
1396 controls.push_back( CreateLeafControl( 60, 60 ) );
1397 controls.push_back( CreateLeafControl( 80, 80 ) );
1398 controls.push_back( CreateLeafControl( 100, 100 ) );
1400 for( auto&& iter : controls )
1404 vbox.SetParentOrigin( ParentOrigin::CENTER );
1405 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1407 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1410 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1412 // Ensure layouting happens
1413 application.SendNotification();
1414 application.Render();
1416 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1417 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1419 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1420 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1421 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1423 // 3rd control is set to match parent - this should also be 100 wide
1424 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1425 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1426 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1427 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1429 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1430 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1431 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1432 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1438 int UtcDaliLayouting_VboxLayout03(void)
1440 ToolkitTestApplication application;
1441 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
1443 Stage stage = Stage::GetCurrent();
1445 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1446 // LayoutGroup for this to happen automatically.
1448 // For this test, add an hbox instead
1449 auto hbox = Control::New();
1450 auto hboxLayout = LinearLayout::New();
1451 DevelControl::SetLayout( hbox, hboxLayout );
1452 hbox.SetName( "Hbox");
1455 auto vbox = Control::New();
1456 auto vboxLayout = LinearLayout::New();
1457 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
1458 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1460 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
1462 DevelControl::SetLayout( vbox, vboxLayout );
1463 vbox.SetName( "Vbox");
1466 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1467 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1469 std::vector< Control > controls;
1470 controls.push_back( CreateLeafControl( 40, 40 ) );
1471 controls.push_back( CreateLeafControl( 60, 60 ) );
1472 controls.push_back( CreateLeafControl( 80, 80 ) );
1473 controls.push_back( CreateLeafControl( 100, 100 ) );
1475 for( auto&& iter : controls )
1479 vbox.SetParentOrigin( ParentOrigin::CENTER );
1480 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1482 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1485 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1487 // Ensure layouting happens
1488 application.SendNotification();
1489 application.Render();
1491 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1492 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1494 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1495 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1496 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1498 // 3rd control is set to match parent - this should also be 100 wide
1499 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1500 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1501 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1502 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1504 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1505 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1506 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1507 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1514 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
1516 ToolkitTestApplication application;
1517 tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
1518 tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
1520 Stage stage = Stage::GetCurrent();
1522 auto hbox = Control::New();
1523 auto hboxLayout = Test::CustomLayout::New();
1524 DevelControl::SetLayout( hbox, hboxLayout );
1525 hbox.SetName( "HBox");
1527 std::vector< Control > controls;
1528 controls.push_back( CreateLeafControl( 40, 40 ) );
1529 controls.push_back( CreateLeafControl( 60, 40 ) );
1530 controls.push_back( CreateLeafControl( 80, 40 ) );
1531 controls.push_back( CreateLeafControl( 100, 40 ) );
1533 for( auto&& iter : controls )
1537 hbox.SetParentOrigin( ParentOrigin::CENTER );
1538 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1541 // Ensure layouting happens
1542 application.SendNotification();
1543 application.Render();
1545 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1546 // hbox left justifies elements
1547 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1548 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1549 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1550 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1552 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1553 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1554 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1555 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1557 controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
1558 controls[2].Lower(); // 2->1; 2, 1, 3, 0
1560 application.SendNotification();
1561 application.Render();
1563 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1564 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1565 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1566 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1568 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1569 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1570 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1571 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1576 int UtcDaliLayouting_HboxLayout_TargetSize(void)
1578 ToolkitTestApplication application;
1579 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
1581 Stage stage = Stage::GetCurrent();
1582 auto hbox = Control::New();
1583 auto hboxLayout = LinearLayout::New();
1584 DevelControl::SetLayout( hbox, hboxLayout );
1585 hbox.SetName( "HBox");
1587 std::vector< Control > controls;
1588 controls.push_back( CreateLeafControl( 40, 40 ) );
1589 for( auto&& iter : controls )
1591 iter.SetSize( 100, 100 );
1594 hbox.SetParentOrigin( ParentOrigin::CENTER );
1595 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1598 // Ensure layouting happens
1599 application.SendNotification();
1600 application.Render();
1602 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
1603 // hbox left justifies elements
1604 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1605 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1611 int UtcDaliLayouting_RemoveLayout01(void)
1613 ToolkitTestApplication application;
1614 tet_infoline(" UtcDaliLayouting_RemoveLayout");
1616 Stage stage = Stage::GetCurrent();
1618 auto rootControl = Control::New();
1619 auto absoluteLayout = AbsoluteLayout::New();
1620 DevelControl::SetLayout( rootControl, absoluteLayout );
1621 rootControl.SetName( "AbsoluteLayout" );
1622 stage.Add( rootControl );
1624 auto hbox = Control::New();
1625 auto hboxLayout = LinearLayout::New();
1626 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1627 DevelControl::SetLayout( hbox, hboxLayout );
1628 hbox.SetName( "HBox" );
1630 std::vector< Control > controls;
1631 controls.push_back( CreateLeafControl( 40, 40 ) );
1632 controls.push_back( CreateLeafControl( 60, 40 ) );
1634 for( auto&& iter : controls )
1638 hbox.SetParentOrigin( ParentOrigin::CENTER );
1639 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1640 rootControl.Add( hbox );
1642 tet_infoline("Layout as normal");
1643 application.SendNotification();
1644 application.Render();
1646 tet_infoline("Set an empty layout on hbox container");
1647 LinearLayout emptyLayout;
1648 DevelControl::SetLayout( hbox, emptyLayout );
1650 tet_infoline("Run another layout");
1651 application.SendNotification();
1652 application.Render();
1654 tet_infoline("Check leaf controls haven't moved");
1656 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1657 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1659 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1660 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );