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>
27 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
28 #include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
29 #include <dali/devel-api/actors/actor-devel.h>
31 #include <../custom-layout.h>
33 #include <layout-utils.h>
36 using namespace Toolkit;
38 void TestLayoutItemOrder( std::vector< Control >& controls, LayoutGroup& layoutGroup )
40 for( auto&& iter : controls )
42 unsigned int siblingOrder = static_cast< unsigned int>( iter.GetProperty< int >( DevelActor::Property::SIBLING_ORDER ) );
43 DALI_TEST_EQUALS( layoutGroup.GetChildAt( siblingOrder ), DevelControl::GetLayout( iter ), TEST_LOCATION );
47 void utc_dali_toolkit_layouting_startup(void)
49 test_return_value = TET_UNDEF;
52 void utc_dali_toolkit_layouting_cleanup(void)
54 test_return_value = TET_PASS;
57 int UtcDaliLayouting_HboxLayout01(void)
59 ToolkitTestApplication application;
60 tet_infoline(" UtcDaliLayouting_HboxLayout01");
62 Stage stage = Stage::GetCurrent();
63 auto hbox = Control::New();
64 auto hboxLayout = LinearLayout::New();
65 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
66 DevelControl::SetLayout( hbox, hboxLayout );
67 hbox.SetName( "HBox");
69 std::vector< Control > controls;
70 controls.push_back( CreateLeafControl( 40, 40 ) );
71 controls.push_back( CreateLeafControl( 60, 40 ) );
72 controls.push_back( CreateLeafControl( 80, 40 ) );
73 controls.push_back( CreateLeafControl( 100, 40 ) );
75 for( auto&& iter : controls )
79 hbox.SetParentOrigin( ParentOrigin::CENTER );
80 hbox.SetAnchorPoint( AnchorPoint::CENTER );
83 // Ensure layouting happens
84 application.SendNotification();
87 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
88 // hbox left justifies elements
89 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
90 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
91 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
92 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
94 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
95 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
96 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
97 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
100 auto newHBoxLayout = LinearLayout::New();
101 newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
102 DevelControl::SetLayout( hbox, newHBoxLayout );
104 application.SendNotification();
105 application.Render();
107 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
108 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
109 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
110 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
115 int UtcDaliLayouting_HboxLayout02(void)
117 ToolkitTestApplication application;
118 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
120 Stage stage = Stage::GetCurrent();
122 auto hbox1 = Control::New();
123 auto hboxLayout1 = LinearLayout::New();
124 DevelControl::SetLayout( hbox1, hboxLayout1 );
126 auto hbox2 = Control::New();
127 auto hboxLayout2 = LinearLayout::New();
128 DevelControl::SetLayout( hbox2, hboxLayout2 );
130 hbox1.SetName( "HBox1");
131 hbox2.SetName( "HBox2");
133 std::vector< Control > controls;
134 controls.push_back( CreateLeafControl( 20, 40 ) );
135 controls.push_back( CreateLeafControl( 30, 50 ) );
136 controls.push_back( CreateLeafControl( 40, 60 ) );
137 controls.push_back( CreateLeafControl( 50, 70 ) );
139 controls.push_back( CreateLeafControl( 25, 40 ) );
140 controls.push_back( CreateLeafControl( 35, 50 ) );
141 controls.push_back( CreateLeafControl( 45, 60 ) );
142 controls.push_back( CreateLeafControl( 55, 70 ) );
145 for( auto&& iter : controls )
157 hbox1.SetParentOrigin( ParentOrigin::CENTER );
158 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
159 hbox2.SetParentOrigin( ParentOrigin::CENTER );
160 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
162 auto hbox3 = Control::New();
163 auto hboxLayout3 = LinearLayout::New();
164 DevelControl::SetLayout( hbox3, hboxLayout3 );
166 hbox3.SetParentOrigin( ParentOrigin::CENTER );
167 hbox3.SetName( "HBox3");
173 // Ensure layouting happens
174 application.SendNotification();
175 application.Render();
178 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
179 // hbox left justifies elements
180 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
181 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
182 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
183 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
185 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
186 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
187 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
188 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
191 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
192 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
193 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
194 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
196 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
197 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
198 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
199 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
201 // Test hbox1 and 2 are sized to wrap their content
202 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
203 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
204 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
205 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
207 // Test hbox3 matches parent (root layer)
208 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
209 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
215 int UtcDaliLayouting_HboxLayout03(void)
217 ToolkitTestApplication application;
218 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
220 Stage stage = Stage::GetCurrent();
222 auto hbox1 = Control::New();
223 auto hboxLayout1 = LinearLayout::New();
224 DevelControl::SetLayout( hbox1, hboxLayout1 );
226 auto hbox2 = Control::New();
227 auto hboxLayout2 = LinearLayout::New();
228 DevelControl::SetLayout( hbox2, hboxLayout2 );
230 hbox1.SetName( "HBox1");
231 hbox2.SetName( "HBox2");
232 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
233 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
234 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
235 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
237 std::vector< Control > controls;
238 controls.push_back( CreateLeafControl( 20, 40 ) );
239 controls.push_back( CreateLeafControl( 30, 50 ) );
240 controls.push_back( CreateLeafControl( 40, 60 ) );
241 controls.push_back( CreateLeafControl( 50, 70 ) );
243 controls.push_back( CreateLeafControl( 25, 40 ) );
244 controls.push_back( CreateLeafControl( 35, 50 ) );
245 controls.push_back( CreateLeafControl( 45, 60 ) );
246 controls.push_back( CreateLeafControl( 55, 70 ) );
249 for( auto&& iter : controls )
261 hbox1.SetParentOrigin( ParentOrigin::CENTER );
262 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
263 hbox2.SetParentOrigin( ParentOrigin::CENTER );
264 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
266 auto hbox3 = Control::New();
267 auto hboxLayout3 = LinearLayout::New();
268 DevelControl::SetLayout( hbox3, hboxLayout3);
270 hbox3.SetParentOrigin( ParentOrigin::CENTER );
271 hbox3.SetName( "HBox3");
277 //std::ostringstream oss;
278 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
279 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
281 // Ensure layouting happens
282 application.SendNotification();
283 application.Render();
286 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
287 // hbox left justifies elements
288 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
289 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
290 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
291 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
293 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
294 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
295 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
296 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
298 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
299 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
300 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
301 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
303 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
304 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
305 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
306 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
308 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
309 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
310 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
311 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
313 // Test hbox3 matches parent (root layer)
314 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
315 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
320 int UtcDaliLayouting_HboxLayout04(void)
322 ToolkitTestApplication application;
323 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
325 Stage stage = Stage::GetCurrent();
327 auto hbox1 = Control::New();
328 auto hboxLayout1 = LinearLayout::New();
329 DevelControl::SetLayout( hbox1, hboxLayout1 );
331 auto hbox2 = Control::New();
332 auto hboxLayout2 = LinearLayout::New();
333 DevelControl::SetLayout( hbox2, hboxLayout2 );
335 hbox1.SetName( "HBox1"); // Default spec is to wrap content
336 hbox2.SetName( "HBox2");
337 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
338 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
339 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
340 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
342 std::vector< Control > controls;
343 controls.push_back( CreateLeafControl( 80, 40 ) );
344 controls.push_back( CreateLeafControl( 80, 50 ) );
345 controls.push_back( CreateLeafControl( 80, 60 ) );
346 controls.push_back( CreateLeafControl( 80, 70 ) );
348 controls.push_back( CreateLeafControl( 80, 40 ) );
349 controls.push_back( CreateLeafControl( 80, 50 ) );
350 controls.push_back( CreateLeafControl( 80, 60 ) );
351 controls.push_back( CreateLeafControl( 80, 70 ) );
354 for( auto&& iter : controls )
367 controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
368 auto hbox3 = Control::New();
369 auto hboxLayout3 = LinearLayout::New();
370 DevelControl::SetLayout( hbox3, hboxLayout3 );
372 hbox3.SetParentOrigin( ParentOrigin::CENTER );
373 hbox3.SetName( "HBox3");
378 //std::ostringstream oss;
379 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
380 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
382 // Ensure layouting happens
383 application.SendNotification();
384 application.Render();
387 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
388 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
389 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
390 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
392 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
393 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
394 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
395 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
397 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
398 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
399 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
400 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
402 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
403 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
404 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
405 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
407 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
408 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
409 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
410 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
413 // Test hbox3 matches parent (root layer)
414 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
415 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
420 int UtcDaliLayouting_HboxLayout05(void)
422 ToolkitTestApplication application;
423 tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
425 Stage stage = Stage::GetCurrent();
426 auto hbox = Control::New();
427 auto hboxLayout = LinearLayout::New();
428 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
429 DevelControl::SetLayout( hbox, hboxLayout );
430 hbox.SetName( "HBox");
432 std::vector< Control > controls;
433 controls.push_back( CreateLeafControl( 40, 40 ) );
434 controls.push_back( CreateLeafControl( 60, 40 ) );
435 controls.push_back( CreateLeafControl( 80, 40 ) );
436 controls.push_back( CreateLeafControl( 100, 40 ) );
438 for( auto&& iter : controls )
441 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
442 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
445 hbox.SetParentOrigin( ParentOrigin::CENTER );
446 hbox.SetAnchorPoint( AnchorPoint::CENTER );
449 // Ensure layouting happens
450 application.SendNotification();
451 application.Render();
453 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
454 // hbox left justifies elements
455 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
456 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
457 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
458 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
460 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
461 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
462 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
463 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
468 int UtcDaliLayouting_HboxLayout06(void)
470 ToolkitTestApplication application;
471 tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
473 Stage stage = Stage::GetCurrent();
475 auto rootControl = Control::New();
476 auto absoluteLayout = AbsoluteLayout::New();
477 DevelControl::SetLayout( rootControl, absoluteLayout );
478 rootControl.SetName( "AbsoluteLayout" );
479 stage.Add( rootControl );
481 auto hbox = Control::New();
482 auto hboxLayout = LinearLayout::New();
483 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
484 DevelControl::SetLayout( hbox, hboxLayout );
485 hbox.SetName( "HBox" );
487 std::vector< Control > controls;
488 controls.push_back( CreateLeafControl( 40, 40 ) );
489 controls.push_back( CreateLeafControl( 60, 40 ) );
491 for( auto&& iter : controls )
495 hbox.SetParentOrigin( ParentOrigin::CENTER );
496 hbox.SetAnchorPoint( AnchorPoint::CENTER );
497 rootControl.Add( hbox );
499 // Ensure layouting happens
500 application.SendNotification();
501 application.Render();
503 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
504 // hbox left justifies elements
505 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
506 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
508 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
509 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
511 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
514 auto newHBoxLayout = LinearLayout::New();
515 newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
516 DevelControl::SetLayout( hbox, newHBoxLayout );
518 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
519 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
521 application.SendNotification();
522 application.Render();
524 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
526 // Change size specification
527 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
528 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
530 application.SendNotification();
531 application.Render();
533 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
535 // Use WRAP_CONTENT again
536 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
537 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
539 application.SendNotification();
540 application.Render();
542 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
547 int UtcDaliLayouting_HboxLayout07(void)
549 ToolkitTestApplication application;
550 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
552 Stage stage = Stage::GetCurrent();
553 auto hbox = Control::New();
554 auto hboxLayout = LinearLayout::New();
555 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
556 DevelControl::SetLayout( hbox, hboxLayout );
557 hbox.SetName( "HBox");
559 std::vector< Control > controls;
560 controls.push_back( CreateLeafControl( 40, 40 ) );
561 controls.push_back( CreateLeafControl( 60, 40 ) );
562 controls.push_back( CreateLeafControl( 80, 40 ) );
563 controls.push_back( CreateLeafControl( 100, 40 ) );
565 for( auto&& iter : controls )
569 hbox.SetParentOrigin( ParentOrigin::CENTER );
570 hbox.SetAnchorPoint( AnchorPoint::CENTER );
573 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
575 // Ensure layouting happens
576 application.SendNotification();
577 application.Render();
579 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
580 // hbox left justifies elements
581 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
582 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
583 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
584 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
586 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
587 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
588 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
589 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
591 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
593 // Ensure layouting happens
594 application.SendNotification();
595 application.Render();
597 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
598 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
599 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
600 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
602 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
603 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
604 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
605 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
610 int UtcDaliLayouting_HboxLayout08(void)
612 ToolkitTestApplication application;
613 tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation");
615 Stage stage = Stage::GetCurrent();
617 auto rootControl = Control::New();
618 auto absoluteLayout = AbsoluteLayout::New();
619 absoluteLayout.SetAnimateLayout( true );
620 DevelControl::SetLayout( rootControl, absoluteLayout );
621 rootControl.SetName( "AbsoluteLayout" );
622 stage.Add( rootControl );
624 Control control1 = CreateLeafControl( 40, 40 );
625 rootControl.Add( control1 );
626 auto hbox = Control::New();
627 auto hboxLayout = LinearLayout::New();
628 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
629 DevelControl::SetLayout( hbox, hboxLayout );
630 hbox.SetName( "HBox" );
632 Control control2 = CreateLeafControl( 40, 40 );
633 hbox.Add( control2 );
635 hbox.SetParentOrigin( ParentOrigin::CENTER );
636 hbox.SetAnchorPoint( AnchorPoint::CENTER );
637 rootControl.Add( hbox );
639 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION );
640 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION );
641 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION );
642 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION );
644 hboxLayout.SetAnimateLayout( true );
645 absoluteLayout.SetAnimateLayout( false );
647 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION );
648 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION );
649 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION );
650 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION );
657 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/broken.png";
660 int UtcDaliLayouting_HboxLayout_ImageView(void)
662 ToolkitTestApplication application;
663 tet_infoline(" UtcDaliLayouting_HboxLayout - Use image view for leaf");
665 Stage stage = Stage::GetCurrent();
666 auto hbox = Control::New();
667 auto hboxLayout = LinearLayout::New();
668 DevelControl::SetLayout( hbox, hboxLayout );
669 hbox.SetName( "HBox" );
671 std::string url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 100, 100 ) );
672 ImageView imageView = CreateImageView( url, ImageDimensions() );
674 hbox.SetParentOrigin( ParentOrigin::CENTER );
675 hbox.SetAnchorPoint( AnchorPoint::CENTER );
676 hbox.Add( imageView );
679 // Ensure layouting happens
680 application.SendNotification();
681 application.Render();
683 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
684 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
686 url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 200, 200 ) );
687 imageView.SetImage( url );
689 // Ensure layouting happenss
690 application.SendNotification();
691 application.Render();
693 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
694 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
696 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
697 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
699 // Ensure layouting happenss
700 application.SendNotification();
701 application.Render();
703 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
704 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
706 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
707 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
709 // Ensure layouting happenss
710 application.SendNotification();
711 application.Render();
713 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
714 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
716 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
717 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
719 Image image = FrameBufferImage::New( 50, 50, Pixel::RGBA8888 );
720 imageView.SetImage( image );
722 // Ensure layouting happenss
723 application.SendNotification();
724 application.Render();
726 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
727 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
729 Property::Map imagePropertyMap;
730 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
731 imagePropertyMap[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
732 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 150;
733 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 150;
734 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap );
736 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
737 // Ensure layouting happenss
738 application.SendNotification();
739 application.Render();
741 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 325.0f, 0.0f ), 0.0001f, TEST_LOCATION );
742 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
747 int UtcDaliLayouting_HboxLayout_TextLabel(void)
749 ToolkitTestApplication application;
750 tet_infoline(" UtcDaliLayouting_HboxLayout - Use text label for leaf");
752 Stage stage = Stage::GetCurrent();
754 auto hbox = Control::New();
755 auto hboxLayout = LinearLayout::New();
756 DevelControl::SetLayout( hbox, hboxLayout );
757 hbox.SetName( "HBox" );
758 hbox.SetParentOrigin( ParentOrigin::CENTER );
759 hbox.SetAnchorPoint( AnchorPoint::CENTER );
761 std::vector< Control > controls;
762 TextLabel textLabel = CreateTextLabel( "W" );
763 controls.push_back( textLabel );
764 hbox.Add( textLabel );
767 // Ensure layouting happens
768 application.SendNotification();
769 application.Render();
771 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
772 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 54.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
774 textLabel.SetProperty( TextLabel::Property::TEXT, "WWWW" );
776 // Ensure layouting happens
777 application.SendNotification();
778 application.Render();
780 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
781 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 216.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
783 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
785 // Ensure layouting happens
786 application.SendNotification();
787 application.Render();
789 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
790 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
792 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
793 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
795 // Ensure layouting happens
796 application.SendNotification();
797 application.Render();
799 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
800 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
802 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
803 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
805 // Ensure layouting happens
806 application.SendNotification();
807 application.Render();
809 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
810 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
817 int UtcDaliLayouting_HboxLayout_Padding01(void)
819 ToolkitTestApplication application;
820 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
822 Stage stage = Stage::GetCurrent();
823 auto hbox = Control::New();
824 auto hboxLayout = LinearLayout::New();
825 DevelControl::SetLayout( hbox, hboxLayout );
826 hbox.SetName( "HBox");
828 std::vector< Control > controls;
829 controls.push_back( CreateLeafControl( 40, 40 ) );
830 controls.push_back( CreateLeafControl( 60, 40 ) );
831 controls.push_back( CreateLeafControl( 80, 40 ) );
832 controls.push_back( CreateLeafControl( 100, 40 ) );
834 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
835 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
836 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
838 for( auto&& iter : controls )
842 hbox.SetParentOrigin( ParentOrigin::CENTER );
843 hbox.SetAnchorPoint( AnchorPoint::CENTER );
846 // Ensure layouting happens
847 application.SendNotification();
848 application.Render();
850 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
851 // hbox left justifies elements
852 tet_infoline("Test Child Actor Position");
853 float xPositionOfControlBeingTested = 0.0f;
854 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
856 0.0f ), 0.0001f, TEST_LOCATION );
857 xPositionOfControlBeingTested += 40.0f;
859 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
860 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
861 0.0001f, TEST_LOCATION );
863 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
864 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
866 xPositionOfControlBeingTested += 80.0f;
867 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
869 tet_infoline("Test Child Actor Size");
870 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
872 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
873 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
874 0.0001f, TEST_LOCATION );
876 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
877 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
882 int UtcDaliLayouting_HboxLayout_Padding02(void)
884 ToolkitTestApplication application;
885 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
887 Stage stage = Stage::GetCurrent();
888 auto hbox = Control::New();
889 auto hboxLayout = LinearLayout::New();
890 DevelControl::SetLayout( hbox, hboxLayout );
891 hbox.SetName( "HBox");
893 std::vector< Control > controls;
894 controls.push_back( CreateLeafControl( 40, 40 ) );
895 controls.push_back( CreateLeafControl( 60, 40 ) );
896 controls.push_back( CreateLeafControl( 80, 40 ) );
897 controls.push_back( CreateLeafControl( 100, 40 ) );
899 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
901 for( auto&& iter : controls )
903 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
906 hbox.SetParentOrigin( ParentOrigin::CENTER );
907 hbox.SetAnchorPoint( AnchorPoint::CENTER );
910 // Ensure layouting happens
911 application.SendNotification();
912 application.Render();
914 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
915 // hbox left justifies elements
916 tet_infoline("Test Child Actor Position");
917 float xPositionOfControlBeingTested = 0.0f;
918 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
920 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
921 yPositionOfControlBeingTested,
922 0.0f ), 0.0001f, TEST_LOCATION );
923 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
925 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
926 yPositionOfControlBeingTested,
928 0.0001f, TEST_LOCATION );
930 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
931 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
932 yPositionOfControlBeingTested,
933 0.0f ), 0.0001f, TEST_LOCATION );
935 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
936 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
937 yPositionOfControlBeingTested,
938 0.0f ), 0.0001f, TEST_LOCATION );
940 tet_infoline("Test Child Actor Size");
941 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
942 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
943 0.0f ), 0.0001f, TEST_LOCATION );
945 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
946 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
947 0.0f ), 0.0001f, TEST_LOCATION );
949 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
950 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
951 0.0f ), 0.0001f, TEST_LOCATION );
953 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
954 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
955 0.0f ), 0.0001f, TEST_LOCATION );
961 int UtcDaliLayouting_HboxLayout_Padding03(void)
963 ToolkitTestApplication application;
964 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
966 Stage stage = Stage::GetCurrent();
967 auto hbox = Control::New();
968 auto hboxLayout = LinearLayout::New();
969 DevelControl::SetLayout( hbox, hboxLayout );
970 hbox.SetName( "HBox");
972 std::vector< Control > controls;
973 controls.push_back( CreateLeafControl( 40, 40 ) );
974 controls.push_back( CreateLeafControl( 40, 40 ) );
975 controls.push_back( CreateLeafControl( 40, 40 ) );
977 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
978 tet_printf( "\nAdding Padding to control at index 1 \n" );
979 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
981 for( auto&& iter : controls )
985 hbox.SetParentOrigin( ParentOrigin::CENTER );
986 hbox.SetAnchorPoint( AnchorPoint::CENTER );
989 // Ensure layouting happens
990 application.SendNotification();
991 application.Render();
993 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
994 // hbox left justifies elements
995 tet_infoline("Test Child Actor Position");
996 float xPositionOfControlBeingTested = 0.0f;
997 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
999 0.0f ), 0.0001f, TEST_LOCATION );
1000 xPositionOfControlBeingTested += 40.0f;
1002 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1003 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1004 0.0001f, TEST_LOCATION );
1006 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1007 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1009 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
1010 tet_printf( "\nChanging Padding to control at index 1 \n" );
1011 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
1013 // Ensure layouting happens
1014 application.SendNotification();
1015 application.Render();
1017 xPositionOfControlBeingTested = 0.0f; // reset
1019 tet_infoline("Test Child Actor Position");
1020 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1022 0.0f ), 0.0001f, TEST_LOCATION );
1023 xPositionOfControlBeingTested += 40.0f;
1025 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1026 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1027 0.0001f, TEST_LOCATION );
1029 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
1030 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
1031 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1033 tet_infoline("Test Child Actor Size");
1034 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1036 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
1037 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
1038 0.0001f, TEST_LOCATION );
1040 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1045 int UtcDaliLayouting_HboxLayout_Padding04(void)
1047 ToolkitTestApplication application;
1048 tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
1050 // Adding padding to the layout should offset the positioning of the children.
1052 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1053 const Size CONTROL_SIZE = Size( 40, 40 );
1055 Stage stage = Stage::GetCurrent();
1056 // Create a root layout, ideally Dali would have a default layout in the root layer.
1057 // Without this root layer the LinearLayout (or any other layout) will not
1058 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1059 // It uses the default stage size and ideally should have a layout added to it.
1060 auto rootLayoutControl = Control::New();
1061 rootLayoutControl.SetName( "AbsoluteLayout");
1062 auto rootLayout = AbsoluteLayout::New();
1063 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1064 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1065 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1066 stage.Add( rootLayoutControl );
1068 auto hbox = Control::New();
1069 auto hboxLayout = LinearLayout::New();
1070 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1071 DevelControl::SetLayout( hbox, hboxLayout );
1072 hbox.SetName( "HBox");
1073 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1074 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1075 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1077 std::vector< Control > controls;
1078 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1079 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1080 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1081 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1083 for( auto&& iter : controls )
1088 hbox.SetParentOrigin( ParentOrigin::CENTER );
1089 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1090 rootLayoutControl.Add( hbox );
1092 // Ensure layouting happens
1093 application.SendNotification();
1094 application.Render();
1096 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1097 application.SendNotification();
1099 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1100 // hbox left justifies elements
1101 tet_infoline("Test Child Actor Position");
1103 auto controlXPosition=0.0f;
1105 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1106 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1108 0.0f ), 0.0001f, TEST_LOCATION );
1110 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1111 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1114 0.0001f, TEST_LOCATION );
1116 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1117 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1119 0.0f ), 0.0001f, TEST_LOCATION );
1121 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1122 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1124 0.0f ), 0.0001f, TEST_LOCATION );
1126 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1127 auto totalControlsHeight = CONTROL_SIZE.height;
1129 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1130 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1131 0.0f ), 0.0001f, TEST_LOCATION );
1137 int UtcDaliLayouting_HboxLayout_Padding05(void)
1139 ToolkitTestApplication application;
1140 tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
1142 // Adding padding to the layout should offset the positioning of the children.
1144 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1145 const Size CONTROL_SIZE = Size( 40, 40 );
1147 Stage stage = Stage::GetCurrent();
1148 // Create a root layout, ideally Dali would have a default layout in the root layer.
1149 // Without this root layer the LinearLayout (or any other layout) will not
1150 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1151 // It uses the default stage size and ideally should have a layout added to it.
1152 auto rootLayoutControl = Control::New();
1153 rootLayoutControl.SetName( "AbsoluteLayout");
1154 auto rootLayout = AbsoluteLayout::New();
1155 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1156 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1157 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1158 stage.Add( rootLayoutControl );
1160 auto hbox = Control::New();
1161 auto hboxLayout = LinearLayout::New();
1162 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1163 DevelControl::SetLayout( hbox, hboxLayout );
1164 hbox.SetName( "HBox");
1165 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1166 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1167 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1169 std::vector< Control > controls;
1170 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1171 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1172 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1173 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1175 for( auto&& iter : controls )
1180 hbox.SetParentOrigin( ParentOrigin::CENTER );
1181 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1182 rootLayoutControl.Add( hbox );
1184 // Ensure layouting happens
1185 application.SendNotification();
1186 application.Render();
1188 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1189 application.SendNotification();
1191 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1192 // hbox left justifies elements
1193 tet_infoline("Test Child Actor Position");
1195 auto controlXPosition=0.0f;
1197 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1198 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1200 0.0f ), 0.0001f, TEST_LOCATION );
1202 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1203 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1206 0.0001f, TEST_LOCATION );
1208 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1209 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1211 0.0f ), 0.0001f, TEST_LOCATION );
1213 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1214 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1216 0.0f ), 0.0001f, TEST_LOCATION );
1218 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1219 auto totalControlsHeight = CONTROL_SIZE.height;
1221 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1222 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1223 0.0f ), 0.0001f, TEST_LOCATION );
1225 // Change layout padding
1226 const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
1227 tet_printf( "\nChanging Padding to control at index 1 \n" );
1228 hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
1230 // Ensure layouting happens
1231 application.SendNotification();
1232 application.Render();
1234 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1235 application.SendNotification();
1237 controlXPosition = NEW_LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1238 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
1239 NEW_LAYOUT_PADDING.top,
1240 0.0f ), 0.0001f, TEST_LOCATION );
1242 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1243 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1244 NEW_LAYOUT_PADDING.top,
1246 0.0001f, TEST_LOCATION );
1248 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1249 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1250 NEW_LAYOUT_PADDING.top,
1251 0.0f ), 0.0001f, TEST_LOCATION );
1253 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1254 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1255 NEW_LAYOUT_PADDING.top,
1256 0.0f ), 0.0001f, TEST_LOCATION );
1257 totalControlsWidth = CONTROL_SIZE.width * controls.size();
1258 totalControlsHeight = CONTROL_SIZE.height;
1260 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
1261 totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
1262 0.0f ), 0.0001f, TEST_LOCATION );
1268 int UtcDaliLayouting_HboxLayout_Margin01(void)
1270 ToolkitTestApplication application;
1271 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
1273 Stage stage = Stage::GetCurrent();
1274 auto hbox = Control::New();
1275 auto hboxLayout = LinearLayout::New();
1276 DevelControl::SetLayout( hbox, hboxLayout );
1277 hbox.SetName( "HBox");
1279 std::vector< Control > controls;
1280 controls.push_back( CreateLeafControl( 40, 40 ) );
1281 controls.push_back( CreateLeafControl( 60, 40 ) );
1282 controls.push_back( CreateLeafControl( 80, 40 ) );
1283 controls.push_back( CreateLeafControl( 100, 40 ) );
1285 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
1286 tet_printf( "\nAdding Margin to control at index 1 \n" );
1287 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1289 for( auto&& iter : controls )
1293 hbox.SetParentOrigin( ParentOrigin::CENTER );
1294 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1297 // Ensure layouting happens
1298 application.SendNotification();
1299 application.Render();
1301 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1302 // hbox left justifies elements
1303 tet_infoline("Test Child Actor Position");
1304 auto xPositionOfControlBeingTested = 0.0f;
1305 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1307 0.0f ), 0.0001f, TEST_LOCATION );
1308 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
1310 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1311 380.0f + CONTROL_MARGIN.top, 0.0f ),
1312 0.0001f, TEST_LOCATION );
1314 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
1315 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1317 xPositionOfControlBeingTested += 80.0f;
1318 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1320 tet_infoline("Test Child Actor Size is the same after Margin added");
1321 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1322 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
1323 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1324 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1330 int UtcDaliLayouting_VboxLayout01(void)
1332 ToolkitTestApplication application;
1333 tet_infoline(" UtcDaliLayouting_VboxLayout01");
1335 Stage stage = Stage::GetCurrent();
1336 auto vbox = Control::New();
1337 auto vboxLayout = LinearLayout::New();
1338 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1339 DevelControl::SetLayout( vbox, vboxLayout );
1340 vbox.SetName( "Vbox");
1342 std::vector< Control > controls;
1343 controls.push_back( CreateLeafControl( 40, 40 ) );
1344 controls.push_back( CreateLeafControl( 60, 60 ) );
1345 controls.push_back( CreateLeafControl( 80, 80 ) );
1346 controls.push_back( CreateLeafControl( 100, 100 ) );
1348 for( auto&& iter : controls )
1352 vbox.SetParentOrigin( ParentOrigin::CENTER );
1353 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1356 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1359 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1361 // Ensure layouting happens
1362 application.SendNotification();
1363 application.Render();
1365 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
1366 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1367 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1368 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1369 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1371 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1372 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1373 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1374 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1379 int UtcDaliLayouting_VboxLayout02(void)
1381 ToolkitTestApplication application;
1382 tet_infoline(" UtcDaliLayouting_VboxLayout01");
1384 Stage stage = Stage::GetCurrent();
1386 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1387 // LayoutGroup for this to happen automatically.
1389 // For this test, add an hbox instead
1390 auto rootControl = Control::New();
1391 auto absoluteLayout = AbsoluteLayout::New();
1392 DevelControl::SetLayout( rootControl, absoluteLayout );
1393 rootControl.SetName( "AbsoluteLayout");
1394 stage.Add( rootControl );
1396 auto vbox = Control::New();
1397 auto vboxLayout = LinearLayout::New();
1398 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1399 DevelControl::SetLayout( vbox, vboxLayout );
1400 vbox.SetName( "Vbox");
1401 rootControl.Add( vbox );
1403 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1404 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1406 std::vector< Control > controls;
1407 controls.push_back( CreateLeafControl( 40, 40 ) );
1408 controls.push_back( CreateLeafControl( 60, 60 ) );
1409 controls.push_back( CreateLeafControl( 80, 80 ) );
1410 controls.push_back( CreateLeafControl( 100, 100 ) );
1412 for( auto&& iter : controls )
1416 vbox.SetParentOrigin( ParentOrigin::CENTER );
1417 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1419 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1422 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1424 // Ensure layouting happens
1425 application.SendNotification();
1426 application.Render();
1428 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1429 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1431 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1432 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1433 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1435 // 3rd control is set to match parent - this should also be 100 wide
1436 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1437 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1438 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1439 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1441 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1442 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1443 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1444 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1450 int UtcDaliLayouting_VboxLayout03(void)
1452 ToolkitTestApplication application;
1453 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
1455 Stage stage = Stage::GetCurrent();
1457 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
1458 // LayoutGroup for this to happen automatically.
1460 // For this test, add an hbox instead
1461 auto hbox = Control::New();
1462 auto hboxLayout = LinearLayout::New();
1463 DevelControl::SetLayout( hbox, hboxLayout );
1464 hbox.SetName( "Hbox");
1467 auto vbox = Control::New();
1468 auto vboxLayout = LinearLayout::New();
1469 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
1470 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1472 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
1474 DevelControl::SetLayout( vbox, vboxLayout );
1475 vbox.SetName( "Vbox");
1478 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1479 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1481 std::vector< Control > controls;
1482 controls.push_back( CreateLeafControl( 40, 40 ) );
1483 controls.push_back( CreateLeafControl( 60, 60 ) );
1484 controls.push_back( CreateLeafControl( 80, 80 ) );
1485 controls.push_back( CreateLeafControl( 100, 100 ) );
1487 for( auto&& iter : controls )
1491 vbox.SetParentOrigin( ParentOrigin::CENTER );
1492 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1494 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1497 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
1499 // Ensure layouting happens
1500 application.SendNotification();
1501 application.Render();
1503 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
1504 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
1506 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
1507 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1508 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1510 // 3rd control is set to match parent - this should also be 100 wide
1511 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1512 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1513 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1514 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1516 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1517 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1518 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1519 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1524 int UtcDaliLayouting_VboxLayout_Padding(void)
1526 ToolkitTestApplication application;
1527 tet_infoline("UtcDaliLayouting_VboxLayout_Padding - Adding Padding to the vbox");
1529 // Adding padding to the layout should offset the positioning of the children.
1531 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1532 const Size CONTROL_SIZE = Size( 40, 40 );
1534 Stage stage = Stage::GetCurrent();
1535 // Create a root layout, ideally Dali would have a default layout in the root layer.
1536 // Without this root layer the LinearLayout (or any other layout) will not
1537 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1538 // It uses the default stage size and ideally should have a layout added to it.
1539 auto rootLayoutControl = Control::New();
1540 rootLayoutControl.SetName( "AbsoluteLayout");
1541 auto rootLayout = AbsoluteLayout::New();
1542 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1543 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1544 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1545 stage.Add( rootLayoutControl );
1547 auto vbox = Control::New();
1548 auto vboxLayout = LinearLayout::New();
1549 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1550 DevelControl::SetLayout( vbox, vboxLayout );
1551 vbox.SetName( "VBox");
1552 vbox.SetProperty( Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1553 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1554 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1556 std::vector< Control > controls;
1557 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1558 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1559 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1560 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1562 for( auto&& iter : controls )
1567 vbox.SetParentOrigin( ParentOrigin::CENTER );
1568 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1569 rootLayoutControl.Add( vbox );
1571 // Ensure layouting happens
1572 application.SendNotification();
1573 application.Render();
1575 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1576 application.SendNotification();
1578 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
1579 tet_infoline("Test Child Actor Position");
1581 auto controlYPosition = 0.0f;
1583 controlYPosition = LAYOUT_PADDING.top; // First child positioned at offset defined by the padding
1584 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1586 0.0f ), 0.0001f, TEST_LOCATION );
1588 controlYPosition += CONTROL_SIZE.height; // Second child positioned is the position of the first child + the first child's height.
1589 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1592 0.0001f, TEST_LOCATION );
1594 controlYPosition += CONTROL_SIZE.height; // Third child positioned adjacent to second
1595 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1597 0.0f ), 0.0001f, TEST_LOCATION );
1599 controlYPosition += CONTROL_SIZE.height; // Forth passed adjacent to the third
1600 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1602 0.0f ), 0.0001f, TEST_LOCATION );
1604 auto totalControlsWidth = CONTROL_SIZE.width;
1605 auto totalControlsHeight = CONTROL_SIZE.height * controls.size();
1607 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1608 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1609 0.0f ), 0.0001f, TEST_LOCATION );
1615 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
1617 ToolkitTestApplication application;
1618 tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
1619 tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
1621 Stage stage = Stage::GetCurrent();
1623 auto hbox = Control::New();
1624 auto hboxLayout = Test::CustomLayout::New();
1625 DevelControl::SetLayout( hbox, hboxLayout );
1626 hbox.SetName( "HBox");
1628 std::vector< Control > controls;
1629 controls.push_back( CreateLeafControl( 40, 40 ) );
1630 controls.push_back( CreateLeafControl( 60, 40 ) );
1631 controls.push_back( CreateLeafControl( 80, 40 ) );
1632 controls.push_back( CreateLeafControl( 100, 40 ) );
1634 for( auto&& iter : controls )
1638 hbox.SetParentOrigin( ParentOrigin::CENTER );
1639 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1642 // Ensure layouting happens
1643 application.SendNotification();
1644 application.Render();
1646 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1647 // hbox left justifies elements
1648 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1649 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1650 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1651 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1653 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1654 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1655 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1656 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1658 controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
1659 controls[2].Lower(); // 2->1; 2, 1, 3, 0
1661 application.SendNotification();
1662 application.Render();
1664 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1665 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1666 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1667 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1669 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1670 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1671 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1672 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1677 int UtcDaliLayouting_HboxLayout_TargetSize(void)
1679 ToolkitTestApplication application;
1680 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
1682 Stage stage = Stage::GetCurrent();
1683 auto hbox = Control::New();
1684 auto hboxLayout = LinearLayout::New();
1685 DevelControl::SetLayout( hbox, hboxLayout );
1686 hbox.SetName( "HBox");
1688 std::vector< Control > controls;
1689 controls.push_back( CreateLeafControl( 40, 40 ) );
1690 for( auto&& iter : controls )
1692 iter.SetSize( 100, 100 );
1695 hbox.SetParentOrigin( ParentOrigin::CENTER );
1696 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1699 // Ensure layouting happens
1700 application.SendNotification();
1701 application.Render();
1703 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
1704 // hbox left justifies elements
1705 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1706 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1711 int UtcDaliLayouting_RemoveLayout01(void)
1713 ToolkitTestApplication application;
1714 tet_infoline(" UtcDaliLayouting_RemoveLayout");
1716 Stage stage = Stage::GetCurrent();
1718 auto rootControl = Control::New();
1719 auto absoluteLayout = AbsoluteLayout::New();
1720 DevelControl::SetLayout( rootControl, absoluteLayout );
1721 rootControl.SetName( "AbsoluteLayout" );
1722 stage.Add( rootControl );
1724 auto hbox = Control::New();
1725 auto hboxLayout = LinearLayout::New();
1726 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1727 DevelControl::SetLayout( hbox, hboxLayout );
1728 hbox.SetName( "HBox" );
1730 std::vector< Control > controls;
1731 controls.push_back( CreateLeafControl( 40, 40 ) );
1732 controls.push_back( CreateLeafControl( 60, 40 ) );
1734 for( auto&& iter : controls )
1738 hbox.SetParentOrigin( ParentOrigin::CENTER );
1739 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1740 rootControl.Add( hbox );
1742 tet_infoline("Layout as normal");
1743 application.SendNotification();
1744 application.Render();
1746 tet_infoline("Set an empty layout on hbox container");
1747 LinearLayout emptyLayout;
1748 DevelControl::SetLayout( hbox, emptyLayout );
1750 tet_infoline("Run another layout");
1751 application.SendNotification();
1752 application.Render();
1754 tet_infoline("Check leaf controls haven't moved");
1756 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1757 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1759 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1760 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1765 int UtcDaliLayouting_LayoutChildren01(void)
1767 ToolkitTestApplication application;
1768 tet_infoline(" UtcDaliLayouting_LayoutChildren01");
1770 Stage stage = Stage::GetCurrent();
1772 auto rootControl = Control::New();
1773 auto absoluteLayout = AbsoluteLayout::New();
1774 DevelControl::SetLayout( rootControl, absoluteLayout );
1775 stage.Add( rootControl );
1777 auto hbox = Control::New();
1778 auto hboxLayout = LinearLayout::New();
1779 DevelControl::SetLayout( hbox, hboxLayout );
1780 rootControl.Add( hbox );
1782 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1784 tet_infoline("Test removal by setting empty layout to child container" );
1785 DevelControl::SetLayout( hbox, LayoutItem{} );
1787 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
1789 auto& hboxImpl = GetImplementation( hboxLayout );
1791 DALI_TEST_EQUALS( hboxLayout.GetOwner(), empty, TEST_LOCATION );
1792 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
1795 hboxImpl.SetLayoutRequested();
1800 int UtcDaliLayouting_LayoutChildren02(void)
1802 ToolkitTestApplication application;
1803 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
1805 Stage stage = Stage::GetCurrent();
1807 auto rootControl = Control::New();
1808 auto absoluteLayout = AbsoluteLayout::New();
1809 DevelControl::SetLayout( rootControl, absoluteLayout );
1810 stage.Add( rootControl );
1812 auto hbox = Control::New();
1813 auto hboxLayout = LinearLayout::New();
1814 DevelControl::SetLayout( hbox, hboxLayout );
1815 rootControl.Add( hbox );
1817 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1819 tet_infoline("Test removal by removing child actor from parent container" );
1822 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
1824 auto& hboxImpl = GetImplementation( hboxLayout );
1825 tet_infoline("Test child actor still has hbox layout " );
1826 DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
1828 tet_infoline("Test hbox layout has no parent " );
1829 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
1834 int UtcDaliLayouting_LayoutChildren03(void)
1836 ToolkitTestApplication application;
1837 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
1839 Stage stage = Stage::GetCurrent();
1841 auto rootControl = Control::New();
1842 auto absoluteLayout = AbsoluteLayout::New();
1843 DevelControl::SetLayout( rootControl, absoluteLayout );
1844 stage.Add( rootControl );
1846 auto hbox = Control::New();
1847 auto hboxLayout = LinearLayout::New();
1848 DevelControl::SetLayout( hbox, hboxLayout );
1849 rootControl.Add( hbox );
1851 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1853 tet_infoline("Test removal by removing child layout from parent layout" );
1854 absoluteLayout.Remove( hboxLayout );
1856 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
1858 auto& hboxImpl = GetImplementation( hboxLayout );
1860 tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
1861 DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
1862 DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
1864 tet_infoline("Check orphaned layout has no parent");
1865 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
1871 int UtcDaliLayouting_LayoutChildren04(void)
1873 ToolkitTestApplication application;
1874 tet_infoline(" UtcDaliLayouting_LayoutChildren03");
1876 Stage stage = Stage::GetCurrent();
1878 auto rootControl = Control::New();
1879 auto absoluteLayout = AbsoluteLayout::New();
1880 DevelControl::SetLayout( rootControl, absoluteLayout );
1881 stage.Add( rootControl );
1883 auto hbox = Control::New();
1884 tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
1885 auto hboxLayout = LinearLayout::New();
1886 rootControl.Add( hbox );
1888 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1890 tet_infoline("Then setting a layout on the child container");
1891 DevelControl::SetLayout( hbox, hboxLayout );
1893 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
1895 auto& hboxImpl = GetImplementation( hboxLayout );
1896 auto& absImpl = GetImplementation( absoluteLayout );
1897 DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
1898 DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
1903 int UtcDaliLayouting_SetLayoutOrder01(void)
1905 ToolkitTestApplication application;
1906 tet_infoline(" UtcDaliLayouting_SetLayoutOrder01 - Call SetLayout after adding the control to the root layout");
1908 Stage stage = Stage::GetCurrent();
1910 auto rootControl = Control::New();
1911 auto absoluteLayout = AbsoluteLayout::New();
1912 DevelControl::SetLayout( rootControl, absoluteLayout );
1913 rootControl.SetName( "AbsoluteLayout" );
1914 stage.Add( rootControl );
1916 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
1917 auto hbox = Control::New();
1918 auto hboxLayout = LinearLayout::New();
1919 hbox.SetName( "HBox");
1921 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
1922 rootControl.Add( hbox );
1924 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
1925 DevelControl::SetLayout( hbox, hboxLayout );
1927 // Add a Child control
1928 std::vector< Control > controls;
1929 controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
1930 for( auto&& iter : controls )
1935 // Ensure layouting happens
1936 application.SendNotification();
1937 application.Render();
1939 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1944 int UtcDaliLayouting_SetLayoutOrder02(void)
1946 ToolkitTestApplication application;
1947 tet_infoline(" UtcDaliLayouting_SetLayoutOrder02 - Test the layout item order and the control order");
1949 Stage stage = Stage::GetCurrent();
1951 auto rootControl = Control::New();
1952 auto absoluteLayout = AbsoluteLayout::New();
1953 DevelControl::SetLayout( rootControl, absoluteLayout );
1954 rootControl.SetName( "AbsoluteLayout" );
1955 stage.Add( rootControl );
1957 auto hbox = Control::New();
1958 auto hboxLayout = LinearLayout::New();
1959 hbox.SetName( "HBox");
1961 rootControl.Add( hbox );
1963 DevelControl::SetLayout( hbox, hboxLayout );
1965 // Add child controls
1966 std::vector< Control > controls;
1967 controls.push_back( CreateLeafControl( 100, 100 ) ); // 0
1968 controls.push_back( CreateLeafControl( 100, 100 ) ); // 1
1969 controls.push_back( CreateLeafControl( 100, 100 ) ); // 2
1971 for( auto&& iter : controls )
1976 // Ensure layouting happens
1977 application.SendNotification();
1978 application.Render();
1980 TestLayoutItemOrder( controls, hboxLayout );
1982 tet_infoline("RaiseToTop");
1984 controls[0].RaiseToTop(); // 1 2 0
1986 TestLayoutItemOrder( controls, hboxLayout );
1988 tet_infoline("LowerToBottom");
1990 controls[2].LowerToBottom(); // 2 1 0
1992 TestLayoutItemOrder( controls, hboxLayout );
1994 tet_infoline("Remove / Add");
1996 hbox.Remove( controls[2] ); // 1 0
1997 hbox.Add( controls[2] ); // 1 0 2
1999 TestLayoutItemOrder( controls, hboxLayout );
2001 tet_infoline("SetLayout");
2003 auto vboxLayout = LinearLayout::New();
2004 DevelControl::SetLayout( controls[0], vboxLayout );
2006 TestLayoutItemOrder( controls, hboxLayout );
2008 tet_infoline("Raise");
2010 controls[0].Raise(); // 1 2 0
2012 TestLayoutItemOrder( controls, hboxLayout );
2014 tet_infoline("Lower");
2016 controls[2].Lower(); // 2 1 0
2018 TestLayoutItemOrder( controls, hboxLayout );
2020 tet_infoline("SetLayout again");
2022 auto vboxLayout1 = LinearLayout::New();
2023 DevelControl::SetLayout( controls[2], vboxLayout1 );
2025 TestLayoutItemOrder( controls, hboxLayout );
2027 DevelControl::SetLayout( controls[2], vboxLayout );