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 )
80 hbox.SetParentOrigin( ParentOrigin::CENTER );
81 hbox.SetAnchorPoint( AnchorPoint::CENTER );
84 // Ensure layouting happens
85 application.SendNotification();
88 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
89 // hbox left justifies elements
90 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
91 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
92 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
93 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
95 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
96 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
97 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
98 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
101 auto newHBoxLayout = LinearLayout::New();
102 newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
103 DevelControl::SetLayout( hbox, newHBoxLayout );
105 application.SendNotification();
106 application.Render();
108 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
109 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
110 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
111 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
116 int UtcDaliLayouting_HboxLayout02(void)
118 ToolkitTestApplication application;
119 tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT");
121 Stage stage = Stage::GetCurrent();
123 auto hbox1 = Control::New();
124 auto hboxLayout1 = LinearLayout::New();
125 DevelControl::SetLayout( hbox1, hboxLayout1 );
127 auto hbox2 = Control::New();
128 auto hboxLayout2 = LinearLayout::New();
129 DevelControl::SetLayout( hbox2, hboxLayout2 );
131 hbox1.SetName( "HBox1");
132 hbox2.SetName( "HBox2");
134 std::vector< Control > controls;
135 controls.push_back( CreateLeafControl( 20, 40 ) );
136 controls.push_back( CreateLeafControl( 30, 50 ) );
137 controls.push_back( CreateLeafControl( 40, 60 ) );
138 controls.push_back( CreateLeafControl( 50, 70 ) );
140 controls.push_back( CreateLeafControl( 25, 40 ) );
141 controls.push_back( CreateLeafControl( 35, 50 ) );
142 controls.push_back( CreateLeafControl( 45, 60 ) );
143 controls.push_back( CreateLeafControl( 55, 70 ) );
146 for( auto&& iter : controls )
158 hbox1.SetParentOrigin( ParentOrigin::CENTER );
159 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
160 hbox2.SetParentOrigin( ParentOrigin::CENTER );
161 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
163 auto hbox3 = Control::New();
164 auto hboxLayout3 = LinearLayout::New();
165 DevelControl::SetLayout( hbox3, hboxLayout3 );
167 hbox3.SetParentOrigin( ParentOrigin::CENTER );
168 hbox3.SetName( "HBox3");
174 // Ensure layouting happens
175 application.SendNotification();
176 application.Render();
179 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
180 // hbox left justifies elements
181 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
182 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
183 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
184 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
186 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
187 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
188 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
189 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
192 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
193 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
194 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
195 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
197 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
198 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
199 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
200 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
202 // Test hbox1 and 2 are sized to wrap their content
203 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
204 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
205 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
206 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
208 // Test hbox3 matches parent (root layer)
209 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
210 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
216 int UtcDaliLayouting_HboxLayout03(void)
218 ToolkitTestApplication application;
219 tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT");
221 Stage stage = Stage::GetCurrent();
223 auto hbox1 = Control::New();
224 auto hboxLayout1 = LinearLayout::New();
225 DevelControl::SetLayout( hbox1, hboxLayout1 );
227 auto hbox2 = Control::New();
228 auto hboxLayout2 = LinearLayout::New();
229 DevelControl::SetLayout( hbox2, hboxLayout2 );
231 hbox1.SetName( "HBox1");
232 hbox2.SetName( "HBox2");
233 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
234 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
235 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
236 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
238 std::vector< Control > controls;
239 controls.push_back( CreateLeafControl( 20, 40 ) );
240 controls.push_back( CreateLeafControl( 30, 50 ) );
241 controls.push_back( CreateLeafControl( 40, 60 ) );
242 controls.push_back( CreateLeafControl( 50, 70 ) );
244 controls.push_back( CreateLeafControl( 25, 40 ) );
245 controls.push_back( CreateLeafControl( 35, 50 ) );
246 controls.push_back( CreateLeafControl( 45, 60 ) );
247 controls.push_back( CreateLeafControl( 55, 70 ) );
250 for( auto&& iter : controls )
262 hbox1.SetParentOrigin( ParentOrigin::CENTER );
263 hbox1.SetAnchorPoint( AnchorPoint::CENTER );
264 hbox2.SetParentOrigin( ParentOrigin::CENTER );
265 hbox2.SetAnchorPoint( AnchorPoint::CENTER );
267 auto hbox3 = Control::New();
268 auto hboxLayout3 = LinearLayout::New();
269 DevelControl::SetLayout( hbox3, hboxLayout3);
271 hbox3.SetParentOrigin( ParentOrigin::CENTER );
272 hbox3.SetName( "HBox3");
278 //std::ostringstream oss;
279 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
280 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
282 // Ensure layouting happens
283 application.SendNotification();
284 application.Render();
287 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
288 // hbox left justifies elements
289 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
290 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
291 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
292 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
294 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
295 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
296 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
297 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
299 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
300 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
301 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
302 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
304 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
305 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
306 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
307 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
309 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
310 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
311 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
312 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
314 // Test hbox3 matches parent (root layer)
315 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
316 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
321 int UtcDaliLayouting_HboxLayout04(void)
323 ToolkitTestApplication application;
324 tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT");
326 Stage stage = Stage::GetCurrent();
328 auto hbox1 = Control::New();
329 auto hboxLayout1 = LinearLayout::New();
330 DevelControl::SetLayout( hbox1, hboxLayout1 );
332 auto hbox2 = Control::New();
333 auto hboxLayout2 = LinearLayout::New();
334 DevelControl::SetLayout( hbox2, hboxLayout2 );
336 hbox1.SetName( "HBox1"); // Default spec is to wrap content
337 hbox2.SetName( "HBox2");
338 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
339 hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
340 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
341 hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
343 std::vector< Control > controls;
344 controls.push_back( CreateLeafControl( 80, 40 ) );
345 controls.push_back( CreateLeafControl( 80, 50 ) );
346 controls.push_back( CreateLeafControl( 80, 60 ) );
347 controls.push_back( CreateLeafControl( 80, 70 ) );
349 controls.push_back( CreateLeafControl( 80, 40 ) );
350 controls.push_back( CreateLeafControl( 80, 50 ) );
351 controls.push_back( CreateLeafControl( 80, 60 ) );
352 controls.push_back( CreateLeafControl( 80, 70 ) );
355 for( auto&& iter : controls )
368 controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
369 auto hbox3 = Control::New();
370 auto hboxLayout3 = LinearLayout::New();
371 DevelControl::SetLayout( hbox3, hboxLayout3 );
373 hbox3.SetParentOrigin( ParentOrigin::CENTER );
374 hbox3.SetName( "HBox3");
379 //std::ostringstream oss;
380 //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() );
381 //printf("Control hierarchy: \n%s\n", oss.str().c_str() );
383 // Ensure layouting happens
384 application.SendNotification();
385 application.Render();
388 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
389 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
390 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION );
391 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
393 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
394 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
395 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
396 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
398 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION );
399 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
400 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
401 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
403 DALI_TEST_EQUALS( controls[4].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
404 DALI_TEST_EQUALS( controls[5].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
405 DALI_TEST_EQUALS( controls[6].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
406 DALI_TEST_EQUALS( controls[7].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
408 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
409 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
410 DALI_TEST_EQUALS( hbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
411 DALI_TEST_EQUALS( hbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION );
414 // Test hbox3 matches parent (root layer)
415 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
416 DALI_TEST_EQUALS( hbox3.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
421 int UtcDaliLayouting_HboxLayout05(void)
423 ToolkitTestApplication application;
424 tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification");
426 Stage stage = Stage::GetCurrent();
427 auto hbox = Control::New();
428 auto hboxLayout = LinearLayout::New();
429 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
430 DevelControl::SetLayout( hbox, hboxLayout );
431 hbox.SetName( "HBox");
433 std::vector< Control > controls;
434 controls.push_back( CreateLeafControl( 40, 40 ) );
435 controls.push_back( CreateLeafControl( 60, 40 ) );
436 controls.push_back( CreateLeafControl( 80, 40 ) );
437 controls.push_back( CreateLeafControl( 100, 40 ) );
439 for( auto&& iter : controls )
442 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 );
443 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 );
446 hbox.SetParentOrigin( ParentOrigin::CENTER );
447 hbox.SetAnchorPoint( AnchorPoint::CENTER );
450 // Ensure layouting happens
451 application.SendNotification();
452 application.Render();
454 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
455 // hbox left justifies elements
456 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
457 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
458 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
459 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
461 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
462 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
463 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
464 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
469 int UtcDaliLayouting_HboxLayout06(void)
471 ToolkitTestApplication application;
472 tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
474 Stage stage = Stage::GetCurrent();
476 auto rootControl = Control::New();
477 auto absoluteLayout = AbsoluteLayout::New();
478 DevelControl::SetLayout( rootControl, absoluteLayout );
479 rootControl.SetName( "AbsoluteLayout" );
480 stage.Add( rootControl );
482 auto hbox = Control::New();
483 auto hboxLayout = LinearLayout::New();
484 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
485 DevelControl::SetLayout( hbox, hboxLayout );
486 hbox.SetName( "HBox" );
488 std::vector< Control > controls;
489 controls.push_back( CreateLeafControl( 40, 40 ) );
490 controls.push_back( CreateLeafControl( 60, 40 ) );
492 for( auto&& iter : controls )
496 hbox.SetParentOrigin( ParentOrigin::CENTER );
497 hbox.SetAnchorPoint( AnchorPoint::CENTER );
498 rootControl.Add( hbox );
500 // Ensure layouting happens
501 application.SendNotification();
502 application.Render();
504 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
505 // hbox left justifies elements
506 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
507 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
509 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
510 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
512 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
515 auto newHBoxLayout = LinearLayout::New();
516 newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
517 DevelControl::SetLayout( hbox, newHBoxLayout );
519 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
520 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
522 application.SendNotification();
523 application.Render();
525 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
527 // Change size specification
528 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
529 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
531 application.SendNotification();
532 application.Render();
534 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
536 // Use WRAP_CONTENT again
537 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
538 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
540 application.SendNotification();
541 application.Render();
543 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
548 int UtcDaliLayouting_HboxLayout07(void)
550 ToolkitTestApplication application;
551 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction");
553 Stage stage = Stage::GetCurrent();
554 auto hbox = Control::New();
555 auto hboxLayout = LinearLayout::New();
556 hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
557 DevelControl::SetLayout( hbox, hboxLayout );
558 hbox.SetName( "HBox");
560 std::vector< Control > controls;
561 controls.push_back( CreateLeafControl( 40, 40 ) );
562 controls.push_back( CreateLeafControl( 60, 40 ) );
563 controls.push_back( CreateLeafControl( 80, 40 ) );
564 controls.push_back( CreateLeafControl( 100, 40 ) );
566 for( auto&& iter : controls )
570 hbox.SetParentOrigin( ParentOrigin::CENTER );
571 hbox.SetAnchorPoint( AnchorPoint::CENTER );
574 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
576 // Ensure layouting happens
577 application.SendNotification();
578 application.Render();
580 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
581 // hbox left justifies elements
582 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
583 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
584 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
585 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
587 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
588 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
589 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
590 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
592 hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
594 // Ensure layouting happens
595 application.SendNotification();
596 application.Render();
598 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
599 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
600 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
601 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
603 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
604 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
605 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
606 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
611 int UtcDaliLayouting_HboxLayout08(void)
613 ToolkitTestApplication application;
614 tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation");
616 Stage stage = Stage::GetCurrent();
618 auto rootControl = Control::New();
619 auto absoluteLayout = AbsoluteLayout::New();
620 absoluteLayout.SetAnimateLayout( true );
621 DevelControl::SetLayout( rootControl, absoluteLayout );
622 rootControl.SetName( "AbsoluteLayout" );
623 stage.Add( rootControl );
625 Control control1 = CreateLeafControl( 40, 40 );
626 rootControl.Add( control1 );
627 auto hbox = Control::New();
628 auto hboxLayout = LinearLayout::New();
629 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
630 DevelControl::SetLayout( hbox, hboxLayout );
631 hbox.SetName( "HBox" );
633 Control control2 = CreateLeafControl( 40, 40 );
634 hbox.Add( control2 );
636 hbox.SetParentOrigin( ParentOrigin::CENTER );
637 hbox.SetAnchorPoint( AnchorPoint::CENTER );
638 rootControl.Add( hbox );
640 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION );
641 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION );
642 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION );
643 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION );
645 hboxLayout.SetAnimateLayout( true );
646 absoluteLayout.SetAnimateLayout( false );
648 DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION );
649 DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION );
650 DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION );
651 DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION );
656 int UtcDaliLayouting_HboxLayout09(void)
658 ToolkitTestApplication application;
659 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set alignment");
661 Stage stage = Stage::GetCurrent();
662 auto hbox = Control::New();
663 auto hboxLayout = LinearLayout::New();
664 DevelControl::SetLayout( hbox, hboxLayout );
665 hbox.SetName( "HBox");
667 std::vector< Control > controls;
668 controls.push_back( CreateLeafControl( 40, 40 ) );
669 controls.push_back( CreateLeafControl( 60, 60 ) );
671 for( auto&& iter : controls )
675 hbox.SetParentOrigin( ParentOrigin::CENTER );
676 hbox.SetAnchorPoint( AnchorPoint::CENTER );
679 // Check default orientation
680 DALI_TEST_EQUALS( static_cast<unsigned int>( hboxLayout.GetOrientation() ), static_cast<unsigned int>( LinearLayout::Orientation::HORIZONTAL ), TEST_LOCATION );
681 // Check default alignment
682 DALI_TEST_EQUALS( hboxLayout.GetAlignment(), ( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL ), TEST_LOCATION );
684 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN );
686 // Ensure layouting happens
687 application.SendNotification();
688 application.Render();
690 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
691 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
693 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
694 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
696 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END );
698 // Ensure layouting happens
699 application.SendNotification();
700 application.Render();
702 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
703 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
705 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
706 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
708 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
710 // Ensure layouting happens
711 application.SendNotification();
712 application.Render();
714 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
715 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
717 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
718 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
720 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP );
722 // Ensure layouting happens
723 application.SendNotification();
724 application.Render();
726 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
727 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
729 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
730 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
732 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP );
734 // Ensure layouting happens
735 application.SendNotification();
736 application.Render();
738 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
739 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
741 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
742 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
744 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP );
746 // Ensure layouting happens
747 application.SendNotification();
748 application.Render();
750 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
751 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
753 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
754 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
756 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
758 // Ensure layouting happens
759 application.SendNotification();
760 application.Render();
762 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
763 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
765 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
766 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
768 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
770 // Ensure layouting happens
771 application.SendNotification();
772 application.Render();
774 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 380.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
775 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
777 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
778 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
780 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
782 // Ensure layouting happens
783 application.SendNotification();
784 application.Render();
786 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION );
787 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
789 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
790 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
792 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL );
794 // Ensure layouting happens
795 application.SendNotification();
796 application.Render();
798 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
799 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION );
801 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
802 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
804 hboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
805 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN );
807 // Ensure layouting happens
808 application.SendNotification();
809 application.Render();
811 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
812 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
814 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
815 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
817 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END );
819 // Ensure layouting happens
820 application.SendNotification();
821 application.Render();
823 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
824 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
826 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
827 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
829 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
831 // Ensure layouting happens
832 application.SendNotification();
833 application.Render();
835 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
836 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
838 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
839 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
841 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP );
843 // Ensure layouting happens
844 application.SendNotification();
845 application.Render();
847 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
848 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
850 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
851 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
853 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP );
855 // Ensure layouting happens
856 application.SendNotification();
857 application.Render();
859 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
860 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
862 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
863 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
865 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP );
867 // Ensure layouting happens
868 application.SendNotification();
869 application.Render();
871 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
872 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
874 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
875 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
877 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
879 // Ensure layouting happens
880 application.SendNotification();
881 application.Render();
883 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
884 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
886 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
887 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
889 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
891 // Ensure layouting happens
892 application.SendNotification();
893 application.Render();
895 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
896 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
898 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
899 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
901 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM );
903 // Ensure layouting happens
904 application.SendNotification();
905 application.Render();
907 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
908 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION );
910 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
911 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
913 hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL );
915 // Ensure layouting happens
916 application.SendNotification();
917 application.Render();
919 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
920 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION );
922 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
923 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
928 int UtcDaliLayouting_HboxLayout_Weight(void)
930 ToolkitTestApplication application;
931 tet_infoline( " UtcDaliLayouting_HboxLayout_Weight - Test LinearLayout weight horizontally" );
933 Stage stage = Stage::GetCurrent();
934 auto hbox = Control::New();
935 auto hboxLayout = LinearLayout::New();
936 DevelControl::SetLayout( hbox, hboxLayout );
937 hbox.SetName( "HBox" );
939 std::vector<Control> controls;
940 controls.push_back( CreateLeafControl( 40, 40 ) );
941 controls.push_back( CreateLeafControl( 60, 40 ) );
942 controls.push_back( CreateLeafControl( 80, 40 ) );
943 controls.push_back( CreateLeafControl( 100, 40 ) );
945 // Set weight for each leaf to use quarter of available space
946 // 480 * 0.25, 480 * 0.25, 480 * 0.25, 480 * 0.25,
947 // width spec has to be set to 0 so not to consume any extra space.
948 for( auto&& iter : controls )
950 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
951 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
952 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
956 hbox.SetParentOrigin( ParentOrigin::CENTER );
957 hbox.SetAnchorPoint( AnchorPoint::CENTER );
960 // Ensure layouting happens
961 application.SendNotification();
962 application.Render();
964 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
965 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
966 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
967 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 360.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
969 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
970 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
971 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
972 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
974 // Set weight for 3, 4 leafs to use all remaining available space after 1, 2 content sized leafs.
975 // 40, 60, (480 - 40 - 60) * 0.5, (480 - 40 - 60) * 0.5
976 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
977 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
978 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
979 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
980 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
981 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
983 // Ensure layouting happens
984 application.SendNotification();
985 application.Render();
987 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
988 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
989 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
990 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 290.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
992 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
993 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
994 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 190.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
995 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 190.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
997 // Add intrinsic width for 3rd leaf so now we should get
998 // 40, 60, (480 - 40 - 60 - 80) * 0.5 + 80, (480 - 40 - 60 - 80) * 0.5
999 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 80 );
1001 // Ensure layouting happens
1002 application.SendNotification();
1003 application.Render();
1005 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1006 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1007 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1008 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1010 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1011 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1012 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 230.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1013 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1015 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1016 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1017 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1018 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1019 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1020 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1021 controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 40 );
1022 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1024 // Ensure layouting happens
1025 application.SendNotification();
1026 application.Render();
1028 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1029 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 110.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1030 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 330.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1031 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 440.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1033 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 110.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1034 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 220.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1035 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 110.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1036 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1038 // WRAP_CONTENT doesn't affect weight
1039 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1040 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1041 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1042 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1043 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1044 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1045 controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1046 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1048 // Ensure layouting happens
1049 application.SendNotification();
1050 application.Render();
1052 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1053 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1054 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1055 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1057 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1058 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1059 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1060 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 300.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1062 // MATCH_PARENT doesn't affect weight
1063 for( auto&& iter : controls )
1065 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1066 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1067 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1070 // Ensure layouting happens
1071 application.SendNotification();
1072 application.Render();
1074 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1075 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1076 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1077 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 360.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1079 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1080 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1081 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1082 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1084 const Extents CONTROL_MARGIN = Extents( 10, 10, 0, 0 );
1085 for( auto&& iter : controls )
1087 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1088 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1089 iter.SetProperty( Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1092 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1093 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1094 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1095 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1097 application.SendNotification();
1098 application.Render();
1100 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 10.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1101 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 70.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1102 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 150.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1103 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 250.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1105 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1106 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1107 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1108 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 220.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1113 int UtcDaliLayouting_VboxLayout_Weight(void)
1115 ToolkitTestApplication application;
1116 tet_infoline( " UtcDaliLayouting_VboxLayout_Weight - Test LinearLayout weight vertically" );
1118 Stage stage = Stage::GetCurrent();
1119 auto vbox = Control::New();
1120 auto vboxLayout = LinearLayout::New();
1121 vboxLayout.SetOrientation( Dali::Toolkit::LinearLayout::Orientation::VERTICAL );
1122 DevelControl::SetLayout( vbox, vboxLayout );
1123 vbox.SetName( "VBox" );
1125 std::vector<Control> controls;
1126 controls.push_back( CreateLeafControl( 40, 40 ) );
1127 controls.push_back( CreateLeafControl( 60, 60 ) );
1128 controls.push_back( CreateLeafControl( 80, 80 ) );
1129 controls.push_back( CreateLeafControl( 100, 100 ) );
1131 // Set weight for each leaf to use quarter of available space
1132 // 800 * 0.25, 800 * 0.25, 800 * 0.25, 800 * 0.25,
1133 // width spec has to be set to 0 so not to consume any extra space.
1134 for( auto&& iter : controls )
1136 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1137 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1138 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1142 vbox.SetParentOrigin( ParentOrigin::CENTER );
1143 vbox.SetAnchorPoint( AnchorPoint::CENTER );
1146 // Ensure layouting happens
1147 application.SendNotification();
1148 application.Render();
1150 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1151 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1152 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1153 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 600.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1155 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1156 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1157 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1158 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1160 // Set weight for 3, 4 leafs to use all remaining available space after 1, 2 content sized leafs.
1161 // 40, 60, (800 - 40 - 60) * 0.5, (800 - 40 - 60) * 0.5
1162 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1163 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1164 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1165 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1166 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1167 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1169 // Ensure layouting happens
1170 application.SendNotification();
1171 application.Render();
1173 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1174 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1175 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1176 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 450.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1178 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1179 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1180 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1181 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1183 // Add intrinsic width for 3rd leaf so now we should get
1184 // 40, 60, (800 - 40 - 60 - 100) * 0.5 + 100, (800 - 40 - 60 - 100) * 0.5
1185 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
1187 // Ensure layouting happens
1188 application.SendNotification();
1189 application.Render();
1191 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1192 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1193 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1194 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 500.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1196 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1197 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1198 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1199 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1201 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1202 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1203 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1204 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1205 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1206 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1207 controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
1208 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1210 // Ensure layouting happens
1211 application.SendNotification();
1212 application.Render();
1214 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1215 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1216 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 525.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1217 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1219 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1220 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1221 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1222 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1224 // WRAP_CONTENT doesn't affect weight
1225 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1226 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1227 controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1228 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1229 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1230 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1231 controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1232 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1234 // Ensure layouting happens
1235 application.SendNotification();
1236 application.Render();
1238 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1239 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1240 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1241 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1243 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1244 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1245 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1246 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 620.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1248 // MATCH_PARENT doesn't affect weight
1249 for( auto&& iter : controls )
1251 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f );
1252 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1253 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1256 // Ensure layouting happens
1257 application.SendNotification();
1258 application.Render();
1260 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1261 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1262 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1263 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 600.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1265 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1266 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1267 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1268 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1270 const Extents CONTROL_MARGIN = Extents( 0, 0, 10, 10 );
1271 for( auto&& iter : controls )
1273 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1274 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1275 iter.SetProperty( Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
1278 controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1279 controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1280 controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 );
1281 controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 );
1283 application.SendNotification();
1284 application.Render();
1286 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1287 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1288 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1289 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 250.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1291 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1292 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1293 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1294 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 540.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1299 int UtcDaliLayouting_NestedLinearLayout_Weight(void)
1301 ToolkitTestApplication application;
1302 tet_infoline("UtcDaliLayouting_NestedLinearLayout_Weight - test weighted children with wrapped parent");
1304 Stage stage = Stage::GetCurrent();
1305 auto rootControl = Control::New();
1306 rootControl.SetName( "AbsoluteLayout");
1307 auto rootLayout = AbsoluteLayout::New();
1308 DevelControl::SetLayout( rootControl, rootLayout );
1309 rootControl.SetAnchorPoint( AnchorPoint::CENTER );
1310 rootControl.SetParentOrigin( ParentOrigin::CENTER );
1311 stage.Add( rootControl );
1313 auto hbox = Control::New();
1314 auto hboxLayout = LinearLayout::New();
1315 DevelControl::SetLayout( hbox, hboxLayout );
1316 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1317 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1319 std::vector< Control > controls;
1320 controls.push_back( CreateLeafControl( 40, 40 ) );
1321 controls.push_back( CreateLeafControl( 60, 60 ) );
1323 // set equal share of wrapped content width (40 + 60 = 100) for both children 100 * 0.5, 100 * 0.5
1324 for( auto&& iter : controls )
1326 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1327 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 );
1328 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1332 hbox.SetParentOrigin( ParentOrigin::CENTER );
1333 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1334 rootControl.Add( hbox );
1336 // Ensure layouting happens
1337 application.SendNotification();
1338 application.Render();
1340 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1341 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1343 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1344 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1346 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1347 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1349 hboxLayout.SetOrientation(Dali::Toolkit::LinearLayout::Orientation::VERTICAL);
1351 // set equal share of wrapped content height (40 + 60 = 100) for both children 100 * 0.5, 100 * 0.5
1352 for( auto&& iter : controls )
1354 iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f );
1355 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1356 iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 );
1359 // Ensure layouting happens
1360 application.SendNotification();
1361 application.Render();
1363 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1364 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1366 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1367 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1369 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1370 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1378 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/broken.png";
1381 int UtcDaliLayouting_HboxLayout_ImageView(void)
1383 ToolkitTestApplication application;
1384 tet_infoline(" UtcDaliLayouting_HboxLayout - Use image view for leaf");
1386 Stage stage = Stage::GetCurrent();
1387 auto hbox = Control::New();
1388 auto hboxLayout = LinearLayout::New();
1389 DevelControl::SetLayout( hbox, hboxLayout );
1390 hbox.SetName( "HBox" );
1392 std::string url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 100, 100 ) );
1393 ImageView imageView = CreateImageView( url, ImageDimensions() );
1395 hbox.SetParentOrigin( ParentOrigin::CENTER );
1396 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1397 hbox.Add( imageView );
1400 // Ensure layouting happens
1401 application.SendNotification();
1402 application.Render();
1404 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1405 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1407 url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 200, 200 ) );
1408 imageView.SetImage( url );
1410 // Ensure layouting happenss
1411 application.SendNotification();
1412 application.Render();
1414 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1415 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1417 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1418 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1420 // Ensure layouting happenss
1421 application.SendNotification();
1422 application.Render();
1424 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1425 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1427 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1428 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1430 // Ensure layouting happenss
1431 application.SendNotification();
1432 application.Render();
1434 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1435 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1437 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1438 imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1440 Image image = FrameBufferImage::New( 50, 50, Pixel::RGBA8888 );
1441 imageView.SetImage( image );
1443 // Ensure layouting happenss
1444 application.SendNotification();
1445 application.Render();
1447 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1448 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1450 Property::Map imagePropertyMap;
1451 imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
1452 imagePropertyMap[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
1453 imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 150;
1454 imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 150;
1455 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap );
1457 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1458 // Ensure layouting happenss
1459 application.SendNotification();
1460 application.Render();
1462 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 325.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1463 DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1468 int UtcDaliLayouting_HboxLayout_TextLabel(void)
1470 ToolkitTestApplication application;
1471 tet_infoline(" UtcDaliLayouting_HboxLayout - Use text label for leaf");
1473 Stage stage = Stage::GetCurrent();
1475 auto hbox = Control::New();
1476 auto hboxLayout = LinearLayout::New();
1477 DevelControl::SetLayout( hbox, hboxLayout );
1478 hbox.SetName( "HBox" );
1479 hbox.SetParentOrigin( ParentOrigin::CENTER );
1480 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1482 std::vector< Control > controls;
1483 TextLabel textLabel = CreateTextLabel( "W" );
1484 controls.push_back( textLabel );
1485 hbox.Add( textLabel );
1488 // Ensure layouting happens
1489 application.SendNotification();
1490 application.Render();
1492 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1493 DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 54.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1495 textLabel.SetProperty( TextLabel::Property::TEXT, "WWWW" );
1497 // Ensure layouting happens
1498 application.SendNotification();
1499 application.Render();
1501 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1502 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 216.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1504 textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
1506 // Ensure layouting happens
1507 application.SendNotification();
1508 application.Render();
1510 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1511 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1513 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1514 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1516 // Ensure layouting happens
1517 application.SendNotification();
1518 application.Render();
1520 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1521 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1523 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
1524 controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1526 // Ensure layouting happens
1527 application.SendNotification();
1528 application.Render();
1530 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1531 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1538 int UtcDaliLayouting_HboxLayout_Padding01(void)
1540 ToolkitTestApplication application;
1541 tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
1543 Stage stage = Stage::GetCurrent();
1544 auto hbox = Control::New();
1545 auto hboxLayout = LinearLayout::New();
1546 DevelControl::SetLayout( hbox, hboxLayout );
1547 hbox.SetName( "HBox");
1549 std::vector< Control > controls;
1550 controls.push_back( CreateLeafControl( 40, 40 ) );
1551 controls.push_back( CreateLeafControl( 60, 40 ) );
1552 controls.push_back( CreateLeafControl( 80, 40 ) );
1553 controls.push_back( CreateLeafControl( 100, 40 ) );
1555 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1556 tet_printf( "\nAdding Padding to control at index %u \n", 1 );
1557 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1559 for( auto&& iter : controls )
1563 hbox.SetParentOrigin( ParentOrigin::CENTER );
1564 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1567 // Ensure layouting happens
1568 application.SendNotification();
1569 application.Render();
1571 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1572 // hbox left justifies elements
1573 tet_infoline("Test Child Actor Position");
1574 float xPositionOfControlBeingTested = 0.0f;
1575 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1577 0.0f ), 0.0001f, TEST_LOCATION );
1578 xPositionOfControlBeingTested += 40.0f;
1580 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1581 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1582 0.0001f, TEST_LOCATION );
1584 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1585 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1587 xPositionOfControlBeingTested += 80.0f;
1588 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1590 tet_infoline("Test Child Actor Size");
1591 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1593 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1594 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
1595 0.0001f, TEST_LOCATION );
1597 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1598 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1603 int UtcDaliLayouting_HboxLayout_Padding02(void)
1605 ToolkitTestApplication application;
1606 tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
1608 Stage stage = Stage::GetCurrent();
1609 auto hbox = Control::New();
1610 auto hboxLayout = LinearLayout::New();
1611 DevelControl::SetLayout( hbox, hboxLayout );
1612 hbox.SetName( "HBox");
1614 std::vector< Control > controls;
1615 controls.push_back( CreateLeafControl( 40, 40 ) );
1616 controls.push_back( CreateLeafControl( 60, 40 ) );
1617 controls.push_back( CreateLeafControl( 80, 40 ) );
1618 controls.push_back( CreateLeafControl( 100, 40 ) );
1620 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1622 for( auto&& iter : controls )
1624 iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1627 hbox.SetParentOrigin( ParentOrigin::CENTER );
1628 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1631 // Ensure layouting happens
1632 application.SendNotification();
1633 application.Render();
1635 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1636 // hbox left justifies elements
1637 tet_infoline("Test Child Actor Position");
1638 float xPositionOfControlBeingTested = 0.0f;
1639 float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
1641 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1642 yPositionOfControlBeingTested,
1643 0.0f ), 0.0001f, TEST_LOCATION );
1644 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1646 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1647 yPositionOfControlBeingTested,
1649 0.0001f, TEST_LOCATION );
1651 xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1652 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1653 yPositionOfControlBeingTested,
1654 0.0f ), 0.0001f, TEST_LOCATION );
1656 xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1657 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1658 yPositionOfControlBeingTested,
1659 0.0f ), 0.0001f, TEST_LOCATION );
1661 tet_infoline("Test Child Actor Size");
1662 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1663 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1664 0.0f ), 0.0001f, TEST_LOCATION );
1666 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1667 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1668 0.0f ), 0.0001f, TEST_LOCATION );
1670 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
1671 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1672 0.0f ), 0.0001f, TEST_LOCATION );
1674 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
1675 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
1676 0.0f ), 0.0001f, TEST_LOCATION );
1682 int UtcDaliLayouting_HboxLayout_Padding03(void)
1684 ToolkitTestApplication application;
1685 tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
1687 Stage stage = Stage::GetCurrent();
1688 auto hbox = Control::New();
1689 auto hboxLayout = LinearLayout::New();
1690 DevelControl::SetLayout( hbox, hboxLayout );
1691 hbox.SetName( "HBox");
1693 std::vector< Control > controls;
1694 controls.push_back( CreateLeafControl( 40, 40 ) );
1695 controls.push_back( CreateLeafControl( 40, 40 ) );
1696 controls.push_back( CreateLeafControl( 40, 40 ) );
1698 const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
1699 tet_printf( "\nAdding Padding to control at index 1 \n" );
1700 controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
1702 for( auto&& iter : controls )
1706 hbox.SetParentOrigin( ParentOrigin::CENTER );
1707 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1710 // Ensure layouting happens
1711 application.SendNotification();
1712 application.Render();
1714 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1715 // hbox left justifies elements
1716 tet_infoline("Test Child Actor Position");
1717 float xPositionOfControlBeingTested = 0.0f;
1718 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1720 0.0f ), 0.0001f, TEST_LOCATION );
1721 xPositionOfControlBeingTested += 40.0f;
1723 DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1724 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1725 0.0001f, TEST_LOCATION );
1727 xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
1728 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1730 const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
1731 tet_printf( "\nChanging Padding to control at index 1 \n" );
1732 controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
1734 // Ensure layouting happens
1735 application.SendNotification();
1736 application.Render();
1738 xPositionOfControlBeingTested = 0.0f; // reset
1740 tet_infoline("Test Child Actor Position");
1741 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1743 0.0f ), 0.0001f, TEST_LOCATION );
1744 xPositionOfControlBeingTested += 40.0f;
1746 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
1747 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
1748 0.0001f, TEST_LOCATION );
1750 xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
1751 tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
1752 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1754 tet_infoline("Test Child Actor Size");
1755 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1757 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
1758 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
1759 0.0001f, TEST_LOCATION );
1761 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1766 int UtcDaliLayouting_HboxLayout_Padding04(void)
1768 ToolkitTestApplication application;
1769 tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
1771 // Adding padding to the layout should offset the positioning of the children.
1773 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1774 const Size CONTROL_SIZE = Size( 40, 40 );
1776 Stage stage = Stage::GetCurrent();
1777 // Create a root layout, ideally Dali would have a default layout in the root layer.
1778 // Without this root layer the LinearLayout (or any other layout) will not
1779 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1780 // It uses the default stage size and ideally should have a layout added to it.
1781 auto rootLayoutControl = Control::New();
1782 rootLayoutControl.SetName( "AbsoluteLayout");
1783 auto rootLayout = AbsoluteLayout::New();
1784 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1785 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1786 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1787 stage.Add( rootLayoutControl );
1789 auto hbox = Control::New();
1790 auto hboxLayout = LinearLayout::New();
1791 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1792 DevelControl::SetLayout( hbox, hboxLayout );
1793 hbox.SetName( "HBox");
1794 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1795 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1796 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1798 std::vector< Control > controls;
1799 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1800 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1801 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1802 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1804 for( auto&& iter : controls )
1809 hbox.SetParentOrigin( ParentOrigin::CENTER );
1810 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1811 rootLayoutControl.Add( hbox );
1813 // Ensure layouting happens
1814 application.SendNotification();
1815 application.Render();
1817 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1818 application.SendNotification();
1820 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1821 // hbox left justifies elements
1822 tet_infoline("Test Child Actor Position");
1824 auto controlXPosition=0.0f;
1826 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1827 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1829 0.0f ), 0.0001f, TEST_LOCATION );
1831 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1832 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1835 0.0001f, TEST_LOCATION );
1837 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1838 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1840 0.0f ), 0.0001f, TEST_LOCATION );
1842 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1843 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1845 0.0f ), 0.0001f, TEST_LOCATION );
1847 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1848 auto totalControlsHeight = CONTROL_SIZE.height;
1850 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1851 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1852 0.0f ), 0.0001f, TEST_LOCATION );
1858 int UtcDaliLayouting_HboxLayout_Padding05(void)
1860 ToolkitTestApplication application;
1861 tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
1863 // Adding padding to the layout should offset the positioning of the children.
1865 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
1866 const Size CONTROL_SIZE = Size( 40, 40 );
1868 Stage stage = Stage::GetCurrent();
1869 // Create a root layout, ideally Dali would have a default layout in the root layer.
1870 // Without this root layer the LinearLayout (or any other layout) will not
1871 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
1872 // It uses the default stage size and ideally should have a layout added to it.
1873 auto rootLayoutControl = Control::New();
1874 rootLayoutControl.SetName( "AbsoluteLayout");
1875 auto rootLayout = AbsoluteLayout::New();
1876 DevelControl::SetLayout( rootLayoutControl, rootLayout );
1877 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
1878 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
1879 stage.Add( rootLayoutControl );
1881 auto hbox = Control::New();
1882 auto hboxLayout = LinearLayout::New();
1883 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1884 DevelControl::SetLayout( hbox, hboxLayout );
1885 hbox.SetName( "HBox");
1886 hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
1887 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1888 hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
1890 std::vector< Control > controls;
1891 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1892 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1893 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1894 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
1896 for( auto&& iter : controls )
1901 hbox.SetParentOrigin( ParentOrigin::CENTER );
1902 hbox.SetAnchorPoint( AnchorPoint::CENTER );
1903 rootLayoutControl.Add( hbox );
1905 // Ensure layouting happens
1906 application.SendNotification();
1907 application.Render();
1909 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1910 application.SendNotification();
1912 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
1913 // hbox left justifies elements
1914 tet_infoline("Test Child Actor Position");
1916 auto controlXPosition=0.0f;
1918 controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1919 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
1921 0.0f ), 0.0001f, TEST_LOCATION );
1923 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1924 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1927 0.0001f, TEST_LOCATION );
1929 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1930 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1932 0.0f ), 0.0001f, TEST_LOCATION );
1934 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1935 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1937 0.0f ), 0.0001f, TEST_LOCATION );
1939 auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
1940 auto totalControlsHeight = CONTROL_SIZE.height;
1942 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
1943 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
1944 0.0f ), 0.0001f, TEST_LOCATION );
1946 // Change layout padding
1947 const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
1948 tet_printf( "\nChanging Padding to control at index 1 \n" );
1949 hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
1951 // Ensure layouting happens
1952 application.SendNotification();
1953 application.Render();
1955 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
1956 application.SendNotification();
1958 controlXPosition = NEW_LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
1959 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
1960 NEW_LAYOUT_PADDING.top,
1961 0.0f ), 0.0001f, TEST_LOCATION );
1963 controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
1964 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1965 NEW_LAYOUT_PADDING.top,
1967 0.0001f, TEST_LOCATION );
1969 controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
1970 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1971 NEW_LAYOUT_PADDING.top,
1972 0.0f ), 0.0001f, TEST_LOCATION );
1974 controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
1975 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
1976 NEW_LAYOUT_PADDING.top,
1977 0.0f ), 0.0001f, TEST_LOCATION );
1978 totalControlsWidth = CONTROL_SIZE.width * controls.size();
1979 totalControlsHeight = CONTROL_SIZE.height;
1981 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
1982 totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
1983 0.0f ), 0.0001f, TEST_LOCATION );
1989 int UtcDaliLayouting_HboxLayout_Margin01(void)
1991 ToolkitTestApplication application;
1992 tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
1994 Stage stage = Stage::GetCurrent();
1995 auto hbox = Control::New();
1996 auto hboxLayout = LinearLayout::New();
1997 DevelControl::SetLayout( hbox, hboxLayout );
1998 hbox.SetName( "HBox");
2000 std::vector< Control > controls;
2001 controls.push_back( CreateLeafControl( 40, 40 ) );
2002 controls.push_back( CreateLeafControl( 60, 40 ) );
2003 controls.push_back( CreateLeafControl( 80, 40 ) );
2004 controls.push_back( CreateLeafControl( 100, 40 ) );
2006 const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
2007 tet_printf( "\nAdding Margin to control at index 1 \n" );
2008 controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
2010 for( auto&& iter : controls )
2014 hbox.SetParentOrigin( ParentOrigin::CENTER );
2015 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2018 // Ensure layouting happens
2019 application.SendNotification();
2020 application.Render();
2022 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2023 // hbox left justifies elements
2024 tet_infoline("Test Child Actor Position");
2025 auto xPositionOfControlBeingTested = 0.0f;
2026 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2028 0.0f ), 0.0001f, TEST_LOCATION );
2029 xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
2031 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
2032 380.0f + CONTROL_MARGIN.top, 0.0f ),
2033 0.0001f, TEST_LOCATION );
2035 xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
2036 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2038 xPositionOfControlBeingTested += 80.0f;
2039 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2041 tet_infoline("Test Child Actor Size is the same after Margin added");
2042 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2043 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
2044 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2045 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2051 int UtcDaliLayouting_VboxLayout01(void)
2053 ToolkitTestApplication application;
2054 tet_infoline(" UtcDaliLayouting_VboxLayout01");
2056 Stage stage = Stage::GetCurrent();
2057 auto vbox = Control::New();
2058 auto vboxLayout = LinearLayout::New();
2059 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2060 vboxLayout.SetAlignment( LinearLayout::Alignment::TOP | LinearLayout::Alignment::CENTER_HORIZONTAL );
2061 DevelControl::SetLayout( vbox, vboxLayout );
2062 vbox.SetName( "Vbox");
2064 std::vector< Control > controls;
2065 controls.push_back( CreateLeafControl( 40, 40 ) );
2066 controls.push_back( CreateLeafControl( 60, 60 ) );
2067 controls.push_back( CreateLeafControl( 80, 80 ) );
2068 controls.push_back( CreateLeafControl( 100, 100 ) );
2070 for( auto&& iter : controls )
2074 vbox.SetParentOrigin( ParentOrigin::CENTER );
2075 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2078 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2081 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2083 // Ensure layouting happens
2084 application.SendNotification();
2085 application.Render();
2087 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
2088 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2089 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2090 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2091 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2093 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2094 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2095 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2096 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2101 int UtcDaliLayouting_VboxLayout02(void)
2103 ToolkitTestApplication application;
2104 tet_infoline(" UtcDaliLayouting_VboxLayout01");
2106 Stage stage = Stage::GetCurrent();
2108 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
2109 // LayoutGroup for this to happen automatically.
2111 // For this test, add an hbox instead
2112 auto rootControl = Control::New();
2113 auto absoluteLayout = AbsoluteLayout::New();
2114 DevelControl::SetLayout( rootControl, absoluteLayout );
2115 rootControl.SetName( "AbsoluteLayout");
2116 stage.Add( rootControl );
2118 auto vbox = Control::New();
2119 auto vboxLayout = LinearLayout::New();
2120 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2121 vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
2122 DevelControl::SetLayout( vbox, vboxLayout );
2123 vbox.SetName( "Vbox");
2124 rootControl.Add( vbox );
2126 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2127 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2129 std::vector< Control > controls;
2130 controls.push_back( CreateLeafControl( 40, 40 ) );
2131 controls.push_back( CreateLeafControl( 60, 60 ) );
2132 controls.push_back( CreateLeafControl( 80, 80 ) );
2133 controls.push_back( CreateLeafControl( 100, 100 ) );
2135 for( auto&& iter : controls )
2139 vbox.SetParentOrigin( ParentOrigin::CENTER );
2140 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2142 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2145 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2147 // Ensure layouting happens
2148 application.SendNotification();
2149 application.Render();
2151 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
2152 DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
2154 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
2155 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2156 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2158 // 3rd control is set to match parent - this should also be 100 wide
2159 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2160 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2161 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2162 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2164 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2165 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2166 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2167 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2173 int UtcDaliLayouting_VboxLayout03(void)
2175 ToolkitTestApplication application;
2176 tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set");
2178 Stage stage = Stage::GetCurrent();
2180 // @todo Can't set specification properties on root control. Really need to make LayoutController a root
2181 // LayoutGroup for this to happen automatically.
2183 // For this test, add an hbox instead
2184 auto hbox = Control::New();
2185 auto hboxLayout = LinearLayout::New();
2186 DevelControl::SetLayout( hbox, hboxLayout );
2187 hbox.SetName( "Hbox");
2190 auto vbox = Control::New();
2191 auto vboxLayout = LinearLayout::New();
2192 vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
2193 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2194 vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL );
2196 DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
2198 DevelControl::SetLayout( vbox, vboxLayout );
2199 vbox.SetName( "Vbox");
2202 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2203 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2205 std::vector< Control > controls;
2206 controls.push_back( CreateLeafControl( 40, 40 ) );
2207 controls.push_back( CreateLeafControl( 60, 60 ) );
2208 controls.push_back( CreateLeafControl( 80, 80 ) );
2209 controls.push_back( CreateLeafControl( 100, 100 ) );
2211 for( auto&& iter : controls )
2215 vbox.SetParentOrigin( ParentOrigin::CENTER );
2216 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2218 controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
2221 DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION );
2223 // Ensure layouting happens
2224 application.SendNotification();
2225 application.Render();
2227 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
2228 DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
2230 // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
2231 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2232 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2234 // 3rd control is set to match parent - this should also be 100 wide
2235 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2236 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2237 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2238 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2240 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2241 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2242 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2243 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2248 int UtcDaliLayouting_VboxLayout_Padding(void)
2250 ToolkitTestApplication application;
2251 tet_infoline("UtcDaliLayouting_VboxLayout_Padding - Adding Padding to the vbox");
2253 // Adding padding to the layout should offset the positioning of the children.
2255 const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
2256 const Size CONTROL_SIZE = Size( 40, 40 );
2258 Stage stage = Stage::GetCurrent();
2259 // Create a root layout, ideally Dali would have a default layout in the root layer.
2260 // Without this root layer the LinearLayout (or any other layout) will not
2261 // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
2262 // It uses the default stage size and ideally should have a layout added to it.
2263 auto rootLayoutControl = Control::New();
2264 rootLayoutControl.SetName( "AbsoluteLayout");
2265 auto rootLayout = AbsoluteLayout::New();
2266 DevelControl::SetLayout( rootLayoutControl, rootLayout );
2267 rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
2268 rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
2269 stage.Add( rootLayoutControl );
2271 auto vbox = Control::New();
2272 auto vboxLayout = LinearLayout::New();
2273 vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
2274 DevelControl::SetLayout( vbox, vboxLayout );
2275 vbox.SetName( "VBox");
2276 vbox.SetProperty( Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
2277 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2278 vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
2280 std::vector< Control > controls;
2281 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2282 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2283 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2284 controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
2286 for( auto&& iter : controls )
2291 vbox.SetParentOrigin( ParentOrigin::CENTER );
2292 vbox.SetAnchorPoint( AnchorPoint::CENTER );
2293 rootLayoutControl.Add( vbox );
2295 // Ensure layouting happens
2296 application.SendNotification();
2297 application.Render();
2299 // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
2300 application.SendNotification();
2302 // vbox centers elements horizontally, it fills test harness stage, which is 480x800.
2303 tet_infoline("Test Child Actor Position");
2305 auto controlYPosition = 0.0f;
2307 controlYPosition = LAYOUT_PADDING.top; // First child positioned at offset defined by the padding
2308 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2310 0.0f ), 0.0001f, TEST_LOCATION );
2312 controlYPosition += CONTROL_SIZE.height; // Second child positioned is the position of the first child + the first child's height.
2313 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2316 0.0001f, TEST_LOCATION );
2318 controlYPosition += CONTROL_SIZE.height; // Third child positioned adjacent to second
2319 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2321 0.0f ), 0.0001f, TEST_LOCATION );
2323 controlYPosition += CONTROL_SIZE.height; // Forth passed adjacent to the third
2324 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
2326 0.0f ), 0.0001f, TEST_LOCATION );
2328 auto totalControlsWidth = CONTROL_SIZE.width;
2329 auto totalControlsHeight = CONTROL_SIZE.height * controls.size();
2331 DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
2332 totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
2333 0.0f ), 0.0001f, TEST_LOCATION );
2339 int UtcDaliLayouting_RelayoutOnChildOrderChanged(void)
2341 ToolkitTestApplication application;
2342 tet_infoline(" UtcDaliLayouting_RelayoutOnChildOrderChanged");
2343 tet_infoline(" Test that if the sibling order changes, the container is re-laid out automatically");
2345 Stage stage = Stage::GetCurrent();
2347 auto hbox = Control::New();
2348 auto hboxLayout = Test::CustomLayout::New();
2349 DevelControl::SetLayout( hbox, hboxLayout );
2350 hbox.SetName( "HBox");
2352 std::vector< Control > controls;
2353 controls.push_back( CreateLeafControl( 40, 40 ) );
2354 controls.push_back( CreateLeafControl( 60, 40 ) );
2355 controls.push_back( CreateLeafControl( 80, 40 ) );
2356 controls.push_back( CreateLeafControl( 100, 40 ) );
2358 for( auto&& iter : controls )
2362 hbox.SetParentOrigin( ParentOrigin::CENTER );
2363 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2366 // Ensure layouting happens
2367 application.SendNotification();
2368 application.Render();
2370 // hbox centers elements vertically, it fills test harness stage, which is 480x800.
2371 // hbox left justifies elements
2372 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2373 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2374 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2375 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2377 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2378 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2379 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2380 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2382 controls[0].RaiseToTop(); // 0->3; 1, 2, 3, 0
2383 controls[2].Lower(); // 2->1; 2, 1, 3, 0
2385 application.SendNotification();
2386 application.Render();
2388 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2389 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2390 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 140.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2391 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2393 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2394 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2395 DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2396 DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2401 int UtcDaliLayouting_HboxLayout_TargetSize(void)
2403 ToolkitTestApplication application;
2404 tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf");
2406 Stage stage = Stage::GetCurrent();
2407 auto hbox = Control::New();
2408 auto hboxLayout = LinearLayout::New();
2409 DevelControl::SetLayout( hbox, hboxLayout );
2410 hbox.SetName( "HBox");
2412 std::vector< Control > controls;
2413 controls.push_back( CreateLeafControl( 40, 40 ) );
2414 for( auto&& iter : controls )
2416 iter.SetSize( 100, 100 );
2419 hbox.SetParentOrigin( ParentOrigin::CENTER );
2420 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2423 // Ensure layouting happens
2424 application.SendNotification();
2425 application.Render();
2427 // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right.
2428 // hbox left justifies elements
2429 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2430 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2435 int UtcDaliLayouting_RemoveLayout01(void)
2437 ToolkitTestApplication application;
2438 tet_infoline(" UtcDaliLayouting_RemoveLayout");
2440 Stage stage = Stage::GetCurrent();
2442 auto rootControl = Control::New();
2443 auto absoluteLayout = AbsoluteLayout::New();
2444 DevelControl::SetLayout( rootControl, absoluteLayout );
2445 rootControl.SetName( "AbsoluteLayout" );
2446 stage.Add( rootControl );
2448 auto hbox = Control::New();
2449 auto hboxLayout = LinearLayout::New();
2450 hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
2451 DevelControl::SetLayout( hbox, hboxLayout );
2452 hbox.SetName( "HBox" );
2454 std::vector< Control > controls;
2455 controls.push_back( CreateLeafControl( 40, 40 ) );
2456 controls.push_back( CreateLeafControl( 60, 40 ) );
2458 for( auto&& iter : controls )
2462 hbox.SetParentOrigin( ParentOrigin::CENTER );
2463 hbox.SetAnchorPoint( AnchorPoint::CENTER );
2464 rootControl.Add( hbox );
2466 tet_infoline("Layout as normal");
2467 application.SendNotification();
2468 application.Render();
2470 tet_infoline("Set an empty layout on hbox container");
2471 LinearLayout emptyLayout;
2472 DevelControl::SetLayout( hbox, emptyLayout );
2474 tet_infoline("Run another layout");
2475 application.SendNotification();
2476 application.Render();
2478 tet_infoline("Check leaf controls haven't moved");
2480 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2481 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2483 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2484 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2489 int UtcDaliLayouting_LayoutChildren01(void)
2491 ToolkitTestApplication application;
2492 tet_infoline(" UtcDaliLayouting_LayoutChildren01");
2494 Stage stage = Stage::GetCurrent();
2496 auto rootControl = Control::New();
2497 auto absoluteLayout = AbsoluteLayout::New();
2498 DevelControl::SetLayout( rootControl, absoluteLayout );
2499 stage.Add( rootControl );
2501 auto hbox = Control::New();
2502 auto hboxLayout = LinearLayout::New();
2503 DevelControl::SetLayout( hbox, hboxLayout );
2504 rootControl.Add( hbox );
2506 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2508 tet_infoline("Test removal by setting empty layout to child container" );
2509 DevelControl::SetLayout( hbox, LayoutItem{} );
2511 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2513 auto& hboxImpl = GetImplementation( hboxLayout );
2515 DALI_TEST_EQUALS( hboxLayout.GetOwner(), empty, TEST_LOCATION );
2516 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2519 hboxImpl.SetLayoutRequested();
2524 int UtcDaliLayouting_LayoutChildren02(void)
2526 ToolkitTestApplication application;
2527 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2529 Stage stage = Stage::GetCurrent();
2531 auto rootControl = Control::New();
2532 auto absoluteLayout = AbsoluteLayout::New();
2533 DevelControl::SetLayout( rootControl, absoluteLayout );
2534 stage.Add( rootControl );
2536 auto hbox = Control::New();
2537 auto hboxLayout = LinearLayout::New();
2538 DevelControl::SetLayout( hbox, hboxLayout );
2539 rootControl.Add( hbox );
2541 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2543 tet_infoline("Test removal by removing child actor from parent container" );
2546 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2548 auto& hboxImpl = GetImplementation( hboxLayout );
2549 tet_infoline("Test child actor still has hbox layout " );
2550 DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
2552 tet_infoline("Test hbox layout has no parent " );
2553 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2558 int UtcDaliLayouting_LayoutChildren03(void)
2560 ToolkitTestApplication application;
2561 tet_infoline(" UtcDaliLayouting_LayoutChildren02");
2563 Stage stage = Stage::GetCurrent();
2565 auto rootControl = Control::New();
2566 auto absoluteLayout = AbsoluteLayout::New();
2567 DevelControl::SetLayout( rootControl, absoluteLayout );
2568 stage.Add( rootControl );
2570 auto hbox = Control::New();
2571 auto hboxLayout = LinearLayout::New();
2572 DevelControl::SetLayout( hbox, hboxLayout );
2573 rootControl.Add( hbox );
2575 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2577 tet_infoline("Test removal by removing child layout from parent layout" );
2578 absoluteLayout.Remove( hboxLayout );
2580 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
2582 auto& hboxImpl = GetImplementation( hboxLayout );
2584 tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
2585 DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
2586 DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
2588 tet_infoline("Check orphaned layout has no parent");
2589 DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
2595 int UtcDaliLayouting_LayoutChildren04(void)
2597 ToolkitTestApplication application;
2598 tet_infoline(" UtcDaliLayouting_LayoutChildren03");
2600 Stage stage = Stage::GetCurrent();
2602 auto rootControl = Control::New();
2603 auto absoluteLayout = AbsoluteLayout::New();
2604 DevelControl::SetLayout( rootControl, absoluteLayout );
2605 stage.Add( rootControl );
2607 auto hbox = Control::New();
2608 tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
2609 auto hboxLayout = LinearLayout::New();
2610 rootControl.Add( hbox );
2612 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2614 tet_infoline("Then setting a layout on the child container");
2615 DevelControl::SetLayout( hbox, hboxLayout );
2617 DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
2619 auto& hboxImpl = GetImplementation( hboxLayout );
2620 auto& absImpl = GetImplementation( absoluteLayout );
2621 DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
2622 DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
2627 int UtcDaliLayouting_SetLayoutOrder01(void)
2629 ToolkitTestApplication application;
2630 tet_infoline(" UtcDaliLayouting_SetLayoutOrder01 - Call SetLayout after adding the control to the root layout");
2632 Stage stage = Stage::GetCurrent();
2634 auto rootControl = Control::New();
2635 auto absoluteLayout = AbsoluteLayout::New();
2636 DevelControl::SetLayout( rootControl, absoluteLayout );
2637 rootControl.SetName( "AbsoluteLayout" );
2638 stage.Add( rootControl );
2640 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
2641 auto hbox = Control::New();
2642 auto hboxLayout = LinearLayout::New();
2643 hbox.SetName( "HBox");
2645 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
2646 rootControl.Add( hbox );
2648 tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
2649 DevelControl::SetLayout( hbox, hboxLayout );
2651 // Add a Child control
2652 std::vector< Control > controls;
2653 controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
2654 for( auto&& iter : controls )
2659 // Ensure layouting happens
2660 application.SendNotification();
2661 application.Render();
2663 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
2668 int UtcDaliLayouting_SetLayoutOrder02(void)
2670 ToolkitTestApplication application;
2671 tet_infoline(" UtcDaliLayouting_SetLayoutOrder02 - Test the layout item order and the control order");
2673 Stage stage = Stage::GetCurrent();
2675 auto rootControl = Control::New();
2676 auto absoluteLayout = AbsoluteLayout::New();
2677 DevelControl::SetLayout( rootControl, absoluteLayout );
2678 rootControl.SetName( "AbsoluteLayout" );
2679 stage.Add( rootControl );
2681 auto hbox = Control::New();
2682 auto hboxLayout = LinearLayout::New();
2683 hbox.SetName( "HBox");
2685 rootControl.Add( hbox );
2687 DevelControl::SetLayout( hbox, hboxLayout );
2689 // Add child controls
2690 std::vector< Control > controls;
2691 controls.push_back( CreateLeafControl( 100, 100 ) ); // 0
2692 controls.push_back( CreateLeafControl( 100, 100 ) ); // 1
2693 controls.push_back( CreateLeafControl( 100, 100 ) ); // 2
2695 for( auto&& iter : controls )
2700 // Ensure layouting happens
2701 application.SendNotification();
2702 application.Render();
2704 TestLayoutItemOrder( controls, hboxLayout );
2706 tet_infoline("RaiseToTop");
2708 controls[0].RaiseToTop(); // 1 2 0
2710 TestLayoutItemOrder( controls, hboxLayout );
2712 tet_infoline("LowerToBottom");
2714 controls[2].LowerToBottom(); // 2 1 0
2716 TestLayoutItemOrder( controls, hboxLayout );
2718 tet_infoline("Remove / Add");
2720 hbox.Remove( controls[2] ); // 1 0
2721 hbox.Add( controls[2] ); // 1 0 2
2723 TestLayoutItemOrder( controls, hboxLayout );
2725 tet_infoline("SetLayout");
2727 auto vboxLayout = LinearLayout::New();
2728 DevelControl::SetLayout( controls[0], vboxLayout );
2730 TestLayoutItemOrder( controls, hboxLayout );
2732 tet_infoline("Raise");
2734 controls[0].Raise(); // 1 2 0
2736 TestLayoutItemOrder( controls, hboxLayout );
2738 tet_infoline("Lower");
2740 controls[2].Lower(); // 2 1 0
2742 TestLayoutItemOrder( controls, hboxLayout );
2744 tet_infoline("SetLayout again");
2746 auto vboxLayout1 = LinearLayout::New();
2747 DevelControl::SetLayout( controls[2], vboxLayout1 );
2749 TestLayoutItemOrder( controls, hboxLayout );
2751 DevelControl::SetLayout( controls[2], vboxLayout );