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/focus-manager/keyinput-focus-manager.h>
25 #include <dali-toolkit/devel-api/controls/control-devel.h>
26 #include <dali-toolkit/devel-api/layouting/absolute-layout.h>
27 #include <dali-toolkit/devel-api/layouting/grid.h>
28 #include <dali-toolkit/devel-api/layouting/linear-layout.h>
29 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
30 #include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
32 #include <../custom-layout.h>
33 #include <dummy-control.h>
35 #include <layout-utils.h>
38 using namespace Toolkit;
40 void utc_dali_toolkit_layouting_animation_startup(void)
42 test_return_value = TET_UNDEF;
45 void utc_dali_toolkit_layouting_animation_cleanup(void)
47 test_return_value = TET_PASS;
53 // Functor to test whether a Finish signal is emitted
54 struct LayoutTransitionFinishCheck
56 LayoutTransitionFinishCheck( bool& signalReceived )
57 : mSignalReceived( signalReceived )
61 void operator()( LayoutTransitionData::Type type, LayoutTransitionData& layoutTransitionData )
63 mSignalReceived = true;
68 mSignalReceived = false;
71 void CheckSignalReceived()
75 tet_printf("Expected Finish signal was not received\n");
84 void CheckSignalNotReceived()
88 tet_printf("Unexpected Finish signal was received\n");
97 bool& mSignalReceived; // owned by individual tests
102 int UtcDaliLayouting_LayoutTransitionDataConstructorP(void)
104 TestApplication application;
106 LayoutTransitionData layoutTransitionData;
108 DALI_TEST_CHECK( !layoutTransitionData );
112 int UtcDaliLayouting_LayoutTransitionDataNewP(void)
114 TestApplication application;
116 LayoutTransitionData layoutTransitionData = LayoutTransitionData::New();
118 DALI_TEST_CHECK(layoutTransitionData);
122 int UtcDaliLayouting_LayoutTransitionDataDownCastP(void)
124 TestApplication application;
126 LayoutTransitionData layoutTransitionData = LayoutTransitionData::New();
127 BaseHandle object(layoutTransitionData);
129 LayoutTransitionData layoutTransitionData2 = LayoutTransitionData::DownCast(object);
130 DALI_TEST_CHECK(layoutTransitionData2);
132 LayoutTransitionData layoutTransitionData3 = DownCast< LayoutTransitionData >(object);
133 DALI_TEST_CHECK(layoutTransitionData2);
137 int UtcDaliLayouting_LayoutTransitionDataDownCastN(void)
139 TestApplication application;
141 BaseHandle unInitializedObject;
143 LayoutTransitionData layoutTransitionData1 = LayoutTransitionData::DownCast( unInitializedObject );
144 DALI_TEST_CHECK( !layoutTransitionData1 );
146 LayoutTransitionData layoutTransitionData2 = DownCast< LayoutTransitionData >( unInitializedObject );
147 DALI_TEST_CHECK( !layoutTransitionData2 );
151 int UtcDaliLayouting_LayoutTransitionDataSetGetTransition(void)
153 TestApplication application;
155 auto layout = LinearLayout::New();
156 auto layoutTransitionData = LayoutTransitionData::New();
158 layout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
159 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == layoutTransitionData );
160 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() );
161 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == LayoutTransitionData() );
162 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() );
163 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == LayoutTransitionData() );
165 layout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, LayoutTransitionData() );
166 layout.SetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE, layoutTransitionData );
167 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() );
168 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == layoutTransitionData );
169 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == LayoutTransitionData() );
170 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() );
171 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == LayoutTransitionData() );
173 layout.SetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE, LayoutTransitionData() );
174 layout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, layoutTransitionData );
175 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() );
176 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() );
177 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == layoutTransitionData );
178 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() );
179 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == LayoutTransitionData() );
181 layout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, LayoutTransitionData() );
182 layout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, layoutTransitionData );
183 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() );
184 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() );
185 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == LayoutTransitionData() );
186 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == layoutTransitionData );
187 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == LayoutTransitionData() );
189 layout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, LayoutTransitionData() );
190 layout.SetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE, layoutTransitionData );
191 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() );
192 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() );
193 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == LayoutTransitionData() );
194 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() );
195 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == layoutTransitionData );
200 int UtcDaliLayouting_SetLayoutTransition01(void)
202 ToolkitTestApplication application;
203 tet_infoline(" UtcDaliLayouting_SetLayoutTransition01" );
205 Stage stage = Stage::GetCurrent();
206 auto container = Control::New();
207 auto horizontalLayout = LinearLayout::New();
208 horizontalLayout.SetAnimateLayout( false );
209 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
211 auto verticalLayout = LinearLayout::New();
212 verticalLayout.SetAnimateLayout( false );
213 verticalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
215 DevelControl::SetLayout( container, horizontalLayout );
216 container.SetName( "Container");
218 std::vector< Control > controls;
219 controls.push_back( CreateLeafControl( 100, 100 ) );
220 controls.push_back( CreateLeafControl( 100, 100 ) );
221 for( auto&& iter : controls )
223 container.Add( iter );
225 stage.Add( container );
227 auto layoutTransitionData = LayoutTransitionData::New();
229 // Instant resize for parent
231 map["property"] = "size";
232 map["targetValue"] = Property::Value(); // capture from layout update
233 map["animator"] = Property::Map()
234 .Add("alphaFunction", "LINEAR")
235 .Add("timePeriod", Property::Map()
237 .Add("duration", 0.0f));
238 layoutTransitionData.AddPropertyAnimator( container, map );
242 map["property"] = "opacity";
243 map["initialValue"] = 0.0f;
244 map["targetValue"] = 1.0f;
245 map["animator"] = Property::Map()
246 .Add("alphaFunction", "LINEAR")
247 .Add("timePeriod", Property::Map()
249 .Add("duration", 0.5f));
250 layoutTransitionData.AddPropertyAnimator( container, map );
253 // Instant position for children
255 map["property"] = "position";
256 map["animator"] = Property::Map()
257 .Add("alphaFunction", "LINEAR")
258 .Add("timePeriod", Property::Map()
260 .Add("duration", 0.0f));
261 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
264 // Grow children from (0,0) size to full size (captured)
266 map["property"] = "size";
267 map["initialValue"] = Vector3( 0.0f, 0.0f, 0 );
268 map["animator"] = Property::Map()
269 .Add("alphaFunction", "LINEAR")
270 .Add("timePeriod", Property::Map()
272 .Add("duration", 0.5f));
273 layoutTransitionData.AddPropertyAnimator( Actor(), map );
276 // Ensure layouting happens
277 application.SendNotification();
278 application.Render();
280 // First round, no animation
281 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
282 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
283 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
285 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
286 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
287 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
289 bool signalReceived(false);
290 LayoutTransitionFinishCheck finishCheck(signalReceived);
291 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
293 horizontalLayout.SetAnimateLayout( true );
294 verticalLayout.SetAnimateLayout( true );
296 // Change a layout, start transition
297 verticalLayout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, layoutTransitionData );
298 DevelControl::SetLayout( container, verticalLayout );
300 application.SendNotification();
301 application.Render( 1u /*just very beginning of the animation*/ );
303 finishCheck.CheckSignalNotReceived();
304 // Second round, animation just started
305 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
306 DALI_TEST_EQUALS( container.GetCurrentOpacity(), 0.0f, 0.1f, TEST_LOCATION );
307 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
308 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
310 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
311 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION );
312 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION );
314 application.SendNotification();
315 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
317 // Third round, animation just finished
318 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
319 DALI_TEST_EQUALS( container.GetCurrentOpacity(), 1.0f, 0.0001f, TEST_LOCATION );
320 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
321 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
323 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
324 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
325 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
327 application.SendNotification();
328 application.Render( 10u /* wait a bit more for a signal */ );
330 finishCheck.CheckSignalReceived();
332 // Now sizes and positions are finally set
333 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
334 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
335 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
337 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
338 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
339 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
341 // Transition back now with default transition
342 DevelControl::SetLayout( container, horizontalLayout );
344 application.SendNotification();
345 application.Render( 1u /*just very beginning of the animation*/ );
347 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
348 DALI_TEST_EQUALS( container.GetCurrentOpacity(), 1.0f, 0.0001f, TEST_LOCATION );
349 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 1.0f, TEST_LOCATION );
350 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 1.0f, TEST_LOCATION );
352 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
353 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
354 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
356 application.SendNotification();
357 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
359 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
360 DALI_TEST_EQUALS( container.GetCurrentOpacity(), 1.0f, 0.0001f, TEST_LOCATION );
361 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
362 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
364 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
365 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
366 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
368 application.SendNotification();
369 application.Render( 10u /* wait a bit more for complete default animation */ );
371 // Now sizes and positions are finally set
372 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
373 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
374 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
376 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
377 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
378 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
383 int UtcDaliLayouting_AddChildLayoutTransition01(void)
385 ToolkitTestApplication application;
386 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition01" );
388 Stage stage = Stage::GetCurrent();
389 auto container = Control::New();
390 auto horizontalLayout = LinearLayout::New();
391 horizontalLayout.SetAnimateLayout( true );
392 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
394 DevelControl::SetLayout( container, horizontalLayout );
395 container.SetName( "Container");
397 std::vector< Control > controls;
398 controls.push_back( CreateLeafControl( 100, 100 ) );
399 stage.Add( container );
401 auto layoutTransitionData = LayoutTransitionData::New();
403 // Instant resize for parent
405 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "size";
406 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
407 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
408 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
409 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
410 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
411 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
412 layoutTransitionData.AddPropertyAnimator( container, map );
415 // Instant position for a child
417 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::NONE;
418 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "position";
419 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
420 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
421 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
422 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
423 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
424 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
427 // Grow a child from (0,0) size to full size (captured)
429 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_ADD;
430 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "size";
431 map[ LayoutTransitionData::AnimatorKey::INITIAL_VALUE ] = Vector3( 0.0f, 0.0f, 0 );
432 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
433 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
434 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
435 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
436 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
437 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to an added child
440 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
441 container.Add( controls[0] );
443 bool signalReceived(false);
444 LayoutTransitionFinishCheck finishCheck(signalReceived);
445 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
447 application.SendNotification();
448 application.Render( 1u /*just very beginning of the animation*/ );
450 finishCheck.CheckSignalNotReceived();
451 // The animation just started
452 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
453 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
455 application.SendNotification();
456 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
458 // The animation just finished
459 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
460 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
462 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
463 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
465 application.SendNotification();
466 application.Render( 10u /* wait a bit more for a signal */ );
468 // Now sizes and positions are finally set
469 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
470 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
472 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
473 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
475 finishCheck.CheckSignalReceived();
480 int UtcDaliLayouting_RemoveChildLayoutTransition01(void)
482 ToolkitTestApplication application;
483 tet_infoline(" UtcDaliLayouting_RemoveChildLayoutTransition01" );
485 Stage stage = Stage::GetCurrent();
486 auto container = Control::New();
487 auto horizontalLayout = LinearLayout::New();
488 horizontalLayout.SetAnimateLayout( false );
489 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
491 DevelControl::SetLayout( container, horizontalLayout );
492 container.SetName( "Container" );
494 std::vector< Control > controls;
495 controls.push_back( CreateLeafControl( 100, 100 ) );
496 controls.push_back( CreateLeafControl( 100, 100 ) );
498 stage.Add( container );
499 container.Add( controls[0] );
500 container.Add( controls[1] );
502 // Initial rendering done
503 application.SendNotification();
504 application.Render();
506 horizontalLayout.SetAnimateLayout( true );
508 auto layoutTransitionData = LayoutTransitionData::New();
510 // Instant resize for parent width
512 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_WIDTH;
513 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
514 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
515 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
516 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
517 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
518 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
519 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
520 layoutTransitionData.AddPropertyAnimator( container, map );
523 // Instant resize for parent height
525 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_HEIGHT;
526 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
527 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
528 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
529 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
530 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
531 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
532 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
533 layoutTransitionData.AddPropertyAnimator( container, map );
536 // Instant position for parent X position
538 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_X;
539 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
540 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
541 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
542 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
543 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
544 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
545 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
546 layoutTransitionData.AddPropertyAnimator( container, map );
549 // Instant position for parent Y position
551 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_Y;
552 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
553 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
554 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
555 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
556 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
557 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
558 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
559 layoutTransitionData.AddPropertyAnimator( container, map );
562 // Shrink the children
564 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_WIDTH;
565 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 0.0f;
566 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
567 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
568 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
569 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
570 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
571 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
572 layoutTransitionData.AddPropertyAnimator( Actor(), map );
575 // Shrink the children
577 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_HEIGHT;
578 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 0.0f;
579 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
580 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
581 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
582 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
583 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
584 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
585 layoutTransitionData.AddPropertyAnimator( Actor(), map );
588 // Shrink the removed child
590 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_REMOVE;
591 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
592 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Size( 0.0f, 0.0f );
593 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
594 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
595 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
596 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
597 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
598 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
599 layoutTransitionData.AddPropertyAnimator( Actor(), map );
602 // Instant position for children
604 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_X;
605 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
606 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
607 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
608 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
609 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
610 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
611 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
614 // Instant position for children
616 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_Y;
617 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
618 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
619 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
620 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
621 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
622 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
623 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
626 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE, layoutTransitionData );
627 container.Remove( controls[1] );
629 bool signalReceived(false);
630 LayoutTransitionFinishCheck finishCheck(signalReceived);
631 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
633 application.SendNotification();
634 application.Render( 1u /*just very beginning of the animation*/ );
636 finishCheck.CheckSignalNotReceived();
637 // Animation just started
638 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
639 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
640 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
642 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
643 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
644 // this control is already removed from the tree.
645 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
647 application.SendNotification();
648 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
650 // Animation just finished
651 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
652 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
653 // this control is already removed from the tree.
654 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION );
656 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
657 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION );
658 // this control is already removed from the tree.
659 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
661 application.SendNotification();
662 application.Render( 10u /* wait a bit more for a signal */ );
664 // Now sizes and positions are finally set
665 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
666 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
667 // this control is already removed from the tree.
668 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION );
670 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
671 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
672 // this control is already removed from the tree.
673 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
675 finishCheck.CheckSignalReceived();
680 int UtcDaliLayouting_FocusChildLayoutTransition01(void)
682 ToolkitTestApplication application;
683 tet_infoline(" UtcDaliLayouting_FocusChildLayoutTransition01" );
685 Stage stage = Stage::GetCurrent();
686 auto container = Control::New();
687 auto horizontalLayout = LinearLayout::New();
688 horizontalLayout.SetAnimateLayout( false );
689 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
691 DevelControl::SetLayout( container, horizontalLayout );
692 container.SetName( "Container" );
694 std::vector< Control > controls;
695 controls.push_back( CreateLeafControl( 100, 100 ) );
696 controls.push_back( CreateLeafControl( 100, 100 ) );
698 stage.Add( container );
699 container.Add( controls[0] );
700 container.Add( controls[1] );
702 KeyInputFocusManager manager = KeyInputFocusManager::Get();
703 manager.SetFocus( controls[0] );
705 // Initial rendering done
706 application.SendNotification();
707 application.Render();
709 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
710 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
711 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
713 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
714 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
715 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
717 horizontalLayout.SetAnimateLayout( true );
719 auto layoutTransitionData = LayoutTransitionData::New();
721 // Instant resize for parent
723 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
724 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
725 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
726 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
727 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
728 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
729 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
730 layoutTransitionData.AddPropertyAnimator( container, map );
733 // Instant position for parent
735 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
736 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
737 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
738 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
739 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
740 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
741 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
742 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
745 // Shrink the lost focus child
747 map[ "affectsSiblings" ] = false;
748 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
749 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST;
750 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 80.0f, 80.0f, 0 );
751 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
752 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
753 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
754 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
755 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
756 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child
759 // Grow the gained focus child
761 map[ "affectsSiblings" ] = false;
762 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
763 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_GAINED;
764 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 120.0f, 120.0f, 0 );
765 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
766 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
767 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
768 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
769 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
770 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus gained child
773 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, layoutTransitionData );
775 bool signalReceived(false);
776 LayoutTransitionFinishCheck finishCheck(signalReceived);
777 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
778 manager.SetFocus( controls[1] );
780 application.SendNotification();
781 application.Render( 1u /*just very beginning of the animation*/ );
783 finishCheck.CheckSignalNotReceived();
784 // Animation just started
785 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
786 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
787 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
789 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
790 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
791 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
793 application.SendNotification();
794 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
796 // Animation just finished
797 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
798 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
799 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
801 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
802 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 80.0f, 80.0f, 0.0f ), 1.0f, TEST_LOCATION );
803 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 120.0f, 120.0f, 0.0f ), 1.0f, TEST_LOCATION );
805 application.SendNotification();
806 application.Render( 10u /* wait a bit more for a signal */ );
808 // Now sizes and positions are finally set
809 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
810 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
811 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
813 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
814 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
815 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
817 finishCheck.CheckSignalReceived();
822 int UtcDaliLayouting_FocusChildLayoutTransition02(void)
824 ToolkitTestApplication application;
825 tet_infoline(" UtcDaliLayouting_FocusChildLayoutTransition02" );
827 Stage stage = Stage::GetCurrent();
828 auto container = Control::New();
829 auto horizontalLayout = LinearLayout::New();
830 horizontalLayout.SetAnimateLayout( false );
831 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
833 DevelControl::SetLayout( container, horizontalLayout );
834 container.SetName( "Container" );
836 std::vector< Control > controls;
837 controls.push_back( CreateLeafControl( 100, 100 ) );
838 controls.push_back( CreateLeafControl( 100, 100 ) );
840 stage.Add( container );
841 container.Add( controls[0] );
842 container.Add( controls[1] );
844 KeyInputFocusManager manager = KeyInputFocusManager::Get();
845 manager.SetFocus( controls[0] );
847 // Initial rendering done
848 application.SendNotification();
849 application.Render();
851 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
852 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
853 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
855 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
856 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
857 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
859 horizontalLayout.SetAnimateLayout( true );
861 auto layoutTransitionData = LayoutTransitionData::New();
863 // Shrink the lost focus child width
865 map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = false;
866 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
867 map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO;
868 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
869 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
870 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
871 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
872 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
873 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // move all children
876 // Shrink the lost focus child width
878 map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true;
879 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_WIDTH;
880 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST;
881 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 80.0f;
882 map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO;
883 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
884 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
885 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
886 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
887 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
888 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child
891 // Shrink the lost focus child height
893 map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true;
894 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_HEIGHT;
895 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST;
896 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 80.0f;
897 map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO;
898 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
899 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
900 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
901 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
902 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
903 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child
906 // Grow the gained focus child
908 map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true;
909 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
910 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_GAINED;
911 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 120.0f, 120.0f, 0 );
912 map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO;
913 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
914 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
915 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
916 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
917 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
918 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus gained child
921 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, layoutTransitionData );
923 bool signalReceived(false);
924 LayoutTransitionFinishCheck finishCheck(signalReceived);
925 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
926 manager.SetFocus( controls[1] );
928 application.SendNotification();
929 application.Render( 1u /*just very beginning of the animation*/ );
931 finishCheck.CheckSignalNotReceived();
932 // Animation just started
933 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
934 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION );
935 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION );
937 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
938 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
939 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
941 application.SendNotification();
942 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
944 // Animation just finished
945 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
946 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 360.0f, 0.0f ), 0.0001f, TEST_LOCATION );
947 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 80.0f, 340.0f, 0.0f ), 0.0001f, TEST_LOCATION );
949 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
950 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 80.0f, 80.0f, 0.0f ), 1.0f, TEST_LOCATION );
951 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 120.0f, 120.0f, 0.0f ), 1.0f, TEST_LOCATION );
953 application.SendNotification();
954 application.Render( 10u /* wait a bit more for a signal */ );
956 // Now sizes and positions are finally set
957 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
958 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 360.0f, 0.0f ), 0.0001f, TEST_LOCATION );
959 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 340.0f, 0.0f ), 0.0001f, TEST_LOCATION );
961 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
962 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
963 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
965 finishCheck.CheckSignalReceived();
970 int UtcDaliLayouting_FocusChildLayoutTransition03(void)
972 ToolkitTestApplication application;
973 tet_infoline(" UtcDaliLayouting_FocusChildLayoutTransition03" );
975 Stage stage = Stage::GetCurrent();
976 auto container = Control::New();
977 auto horizontalLayout = LinearLayout::New();
978 horizontalLayout.SetAnimateLayout( false );
979 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
981 DevelControl::SetLayout( container, horizontalLayout );
982 container.SetName( "Container" );
984 std::vector< Control > controls;
985 controls.push_back( CreateLeafControl( 100, 100 ) );
986 controls.push_back( CreateLeafControl( 100, 100 ) );
988 stage.Add( container );
989 container.Add( controls[0] );
990 container.Add( controls[1] );
992 KeyInputFocusManager manager = KeyInputFocusManager::Get();
993 manager.SetFocus( controls[0] );
995 // Initial rendering done
996 application.SendNotification();
997 application.Render();
999 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1000 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1001 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1003 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1004 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1005 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1007 horizontalLayout.SetAnimateLayout( true );
1009 auto layoutTransitionData = LayoutTransitionData::New();
1011 // Shrink the lost focus child width
1013 map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = false;
1014 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1015 map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO;
1016 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1017 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1018 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1019 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
1020 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
1021 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // move all children
1024 // Shrink the lost focus child width
1026 map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true;
1027 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SCALE_X;
1028 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST;
1029 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 0.8f;
1030 map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO;
1031 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1032 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1033 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1034 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
1035 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
1036 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child
1039 // Shrink the lost focus child height
1041 map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true;
1042 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SCALE_Y;
1043 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST;
1044 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 0.8f;
1045 map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO;
1046 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1047 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1048 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1049 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
1050 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
1051 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child
1054 // Grow the gained focus child
1056 map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true;
1057 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SCALE;
1058 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_GAINED;
1059 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 1.2f, 1.2f, 1.0f );
1060 map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO;
1061 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1062 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1063 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1064 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
1065 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
1066 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus gained child
1069 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, layoutTransitionData );
1071 bool signalReceived(false);
1072 LayoutTransitionFinishCheck finishCheck(signalReceived);
1073 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1074 manager.SetFocus( controls[1] );
1076 application.SendNotification();
1077 application.Render( 1u /*just very beginning of the animation*/ );
1079 finishCheck.CheckSignalNotReceived();
1080 // Animation just started
1081 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1082 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION );
1083 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION );
1085 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1086 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
1087 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
1089 application.SendNotification();
1090 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1092 // Animation just finished
1093 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1094 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( -10.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1095 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 90.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1097 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1098 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1099 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1100 DALI_TEST_EQUALS( controls[0].GetCurrentSize() * controls[0].GetCurrentScale(), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1101 DALI_TEST_EQUALS( controls[1].GetCurrentSize() * controls[1].GetCurrentScale(), Vector3( 120.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1103 application.SendNotification();
1104 application.Render( 10u /* wait a bit more for a signal */ );
1106 // Now sizes and positions are finally set
1107 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1108 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( -10.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1109 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1111 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1112 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1113 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1114 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) * controls[0].GetProperty<Vector3>( Actor::Property::SCALE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1115 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) * controls[1].GetProperty<Vector3>( Actor::Property::SCALE ), Vector3( 120.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1117 finishCheck.CheckSignalReceived();
1122 int UtcDaliLayouting_AddChildLayoutTransition02_KeyFrames(void)
1124 ToolkitTestApplication application;
1125 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition02_KeyFrames" );
1127 Stage stage = Stage::GetCurrent();
1128 auto container = Control::New();
1129 auto horizontalLayout = LinearLayout::New();
1130 horizontalLayout.SetAnimateLayout( true );
1131 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1133 DevelControl::SetLayout( container, horizontalLayout );
1134 container.SetName( "Container");
1136 std::vector< Control > controls;
1137 controls.push_back( CreateLeafControl( 100, 100 ) );
1138 stage.Add( container );
1140 auto layoutTransitionData = LayoutTransitionData::New();
1142 // Instant resize for parent
1144 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1145 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1146 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1147 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
1148 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1149 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1150 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1151 layoutTransitionData.AddPropertyAnimator( container, map );
1154 // Instant position for a child
1156 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1157 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1158 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
1159 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1160 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1161 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1162 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1165 // Grow a child from (0,0) size to full size with key frames
1166 KeyFrames keyFrames = KeyFrames::New();
1167 keyFrames.Add( 0.0f, Vector3( 0.0f, 0.0f, 0 ) );
1168 keyFrames.Add( 0.5f, Vector3( 100.0f, 100.0f, 0 ) );
1171 map[ "property" ] = Actor::Property::SIZE;
1172 map[ "condition" ] = LayoutTransitionData::Condition::ON_ADD;
1173 map[ "animator" ] = Property::Map()
1174 .Add( "type", "ANIMATE_BETWEEN")
1175 .Add( "alphaFunction", "LINEAR")
1176 .Add( "timePeriod", Property::Map()
1177 .Add( "delay", 0.0f)
1178 .Add( "duration", 0.5f));
1179 layoutTransitionData.AddPropertyAnimator( Actor(), map, keyFrames, Animation::Interpolation::Linear );
1182 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
1183 container.Add( controls[0] );
1185 bool signalReceived(false);
1186 LayoutTransitionFinishCheck finishCheck(signalReceived);
1187 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1189 application.SendNotification();
1190 application.Render( 1u /*just very beginning of the animation*/ );
1192 finishCheck.CheckSignalNotReceived();
1193 // The animation just started
1194 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1195 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1197 application.SendNotification();
1198 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1200 // The animation just finished
1201 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1202 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1204 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1205 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1207 application.SendNotification();
1208 application.Render( 10u /* wait a bit more for a signal */ );
1210 // Now sizes and positions are finally set
1211 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1212 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1214 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1215 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1217 finishCheck.CheckSignalReceived();
1222 int UtcDaliLayouting_AddChildLayoutTransition03_Path(void)
1224 ToolkitTestApplication application;
1225 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition03_Path" );
1227 Stage stage = Stage::GetCurrent();
1228 auto container = Control::New();
1229 auto horizontalLayout = LinearLayout::New();
1230 horizontalLayout.SetAnimateLayout( true );
1231 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1233 DevelControl::SetLayout( container, horizontalLayout );
1234 container.SetName( "Container");
1236 std::vector< Control > controls;
1237 controls.push_back( CreateLeafControl( 100, 100 ) );
1238 stage.Add( container );
1240 auto layoutTransitionData = LayoutTransitionData::New();
1242 // Instant resize for parent
1244 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1245 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1246 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1247 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
1248 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1249 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1250 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1251 layoutTransitionData.AddPropertyAnimator( container, map );
1254 Dali::Path path = Dali::Path::New();
1256 // Curve position for a child
1258 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1259 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1260 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_PATH")
1261 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
1262 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1263 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1264 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f ) );
1267 Vector3 position0( 30.0, 80.0, 0.0 );
1268 Vector3 position1( 70.0, 120.0, 0.0 );
1269 Vector3 position2( 0.0, 350.0, 0.0 );
1271 //Dali::Path path = Dali::Path::New();
1272 path.AddPoint( position0 );
1273 path.AddPoint( position1 );
1274 path.AddPoint( position2 );
1276 // Control points for first segment
1277 path.AddControlPoint( Vector3( 39.0, 90.0, 0.0 ) );
1278 path.AddControlPoint( Vector3( 56.0, 119.0, 0.0 ) );
1280 // Control points for second segment
1281 path.AddControlPoint( Vector3( 78.0, 120.0, 0.0 ) );
1282 path.AddControlPoint( Vector3( 93.0, 104.0, 0.0 ) );
1284 layoutTransitionData.AddPropertyAnimator( controls[0], map, path, Vector3::XAXIS );
1287 // Grow a child from (0,0) size to full size (captured)
1289 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "size";
1290 map[ LayoutTransitionData::AnimatorKey::INITIAL_VALUE ] = Vector3( 0.0f, 0.0f, 0 );
1291 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1292 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
1293 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1294 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
1295 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
1296 layoutTransitionData.AddPropertyAnimator( controls[0], map );
1299 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
1300 container.Add( controls[0] );
1302 bool signalReceived(false);
1303 LayoutTransitionFinishCheck finishCheck(signalReceived);
1304 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1306 application.SendNotification();
1307 application.Render( 0 );
1309 finishCheck.CheckSignalNotReceived();
1310 // The animation just started
1311 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1313 Vector3 position, tangent;
1314 Quaternion rotation;
1315 path.Sample( 0.0f, position, tangent );
1316 rotation = Quaternion( Vector3::XAXIS, tangent );
1317 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), position, 0.0001f, TEST_LOCATION );
1318 DALI_TEST_EQUALS( controls[0].GetCurrentOrientation(), rotation, 0.0001f, TEST_LOCATION );
1320 application.SendNotification();
1321 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1323 path.Sample( 1.0f, position, tangent );
1324 rotation = Quaternion( Vector3::XAXIS, tangent );
1325 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), position, 0.0001f, TEST_LOCATION );
1326 DALI_TEST_EQUALS( controls[0].GetCurrentOrientation(), rotation, 0.0001f, TEST_LOCATION );
1328 // The animation just finished
1329 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1330 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1332 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1333 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1335 application.SendNotification();
1336 application.Render( 10u /* wait a bit more for a signal */ );
1338 // Now sizes and positions are finally set
1339 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1340 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1342 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1343 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1345 finishCheck.CheckSignalReceived();
1350 int UtcDaliLayouting_AddChildLayoutTransition04_AnimateBy(void)
1352 ToolkitTestApplication application;
1353 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition04_AnimateBy" );
1355 Stage stage = Stage::GetCurrent();
1356 auto container = Control::New();
1357 auto horizontalLayout = LinearLayout::New();
1358 horizontalLayout.SetAnimateLayout( true );
1359 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1361 DevelControl::SetLayout( container, horizontalLayout );
1362 container.SetName( "Container");
1364 std::vector< Control > controls;
1365 controls.push_back( CreateLeafControl( 100, 100 ) );
1366 stage.Add( container );
1368 auto layoutTransitionData = LayoutTransitionData::New();
1370 // Instant resize for parent
1372 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1373 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1374 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1375 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
1376 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1377 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1378 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1379 layoutTransitionData.AddPropertyAnimator( container, map );
1382 // Instant position for a child
1384 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1385 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1386 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
1387 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1388 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1389 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1390 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1394 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1395 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 10.0f, 10.0f, 0 );
1396 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1397 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_BY")
1398 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
1399 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1400 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
1401 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
1402 layoutTransitionData.AddPropertyAnimator( controls[0], map );
1405 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
1406 container.Add( controls[0] );
1408 bool signalReceived(false);
1409 LayoutTransitionFinishCheck finishCheck(signalReceived);
1410 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1412 application.SendNotification();
1413 application.Render( 1u /*just very beginning of the animation*/ );
1415 finishCheck.CheckSignalNotReceived();
1416 // The animation just started
1417 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1418 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1420 application.SendNotification();
1421 application.Render( static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1423 // The animation just finished
1424 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1425 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1427 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1428 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 110.0f, 110.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1430 application.SendNotification();
1431 application.Render( 10u /* wait a bit more for a signal */ );
1433 // Now sizes and positions are finally set
1434 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1435 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1437 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1438 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 110.0f, 110.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1440 finishCheck.CheckSignalReceived();
1445 int UtcDaliLayouting_AddChildLayoutTransition05(void)
1447 ToolkitTestApplication application;
1448 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition05" );
1450 Stage stage = Stage::GetCurrent();
1451 auto container = Control::New();
1452 auto horizontalLayout = LinearLayout::New();
1453 horizontalLayout.SetAnimateLayout( true );
1454 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1456 DevelControl::SetLayout( container, horizontalLayout );
1457 container.SetName( "Container");
1459 std::vector< Control > controls;
1460 controls.push_back( CreateLeafControl( 100, 100 ) );
1461 stage.Add( container );
1463 auto layoutTransitionData = LayoutTransitionData::New();
1465 // Instant resize for parent
1467 map[ "property" ] = Actor::Property::SIZE;
1468 map[ "targetValue" ] = Property::Value(); // capture from layout update
1469 map[ "animator" ] = Property::Map()
1470 .Add( "name", "InstantAnimator" )
1471 .Add( "type", "ANIMATE_TO")
1472 .Add( "alphaFunction", "LINEAR" )
1473 .Add( "timePeriod", Property::Map()
1474 .Add( "delay", 0.0f )
1475 .Add( "duration", 0.0f ) );
1476 layoutTransitionData.AddPropertyAnimator( container, map );
1479 // Instant position for a child
1481 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::COLOR_ALPHA;
1482 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = "InstantAnimator";
1483 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1486 // Grow a child from (0,0) size to full size (captured)
1488 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1489 map[ LayoutTransitionData::AnimatorKey::INITIAL_VALUE ] = Vector3( 0.0f, 0.0f, 0 );
1490 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = std::string();
1491 layoutTransitionData.AddPropertyAnimator( controls[0], map );
1494 // Instant opacity for a child, for testing
1496 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1497 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = "InstantAnimator";
1498 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1501 // Just throw all other alpha functions in
1502 { // no property, not going to be used, but going to be parsed
1504 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1505 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "WRONG" );
1506 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1508 { // no property, not going to be used, but going to be parsed
1510 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1511 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" );
1512 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1514 { // no property, not going to be used, but going to be parsed
1516 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1517 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "REVERSE" );
1518 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1520 { // no property, not going to be used, but going to be parsed
1522 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1523 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_SQUARE" );
1524 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1526 { // no property, not going to be used, but going to be parsed
1528 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1529 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT_SQUARE" );
1530 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1532 { // no property, not going to be used, but going to be parsed
1534 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1535 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN" );
1536 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1538 { // no property, not going to be used, but going to be parsed
1540 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1541 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN" );
1542 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1544 { // no property, not going to be used, but going to be parsed
1546 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1547 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT" );
1548 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1550 { // no property, not going to be used, but going to be parsed
1552 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1553 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_OUT" );
1554 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1556 { // no property, not going to be used, but going to be parsed
1558 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1559 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_OUT_SINE" );
1560 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1562 { // no property, not going to be used, but going to be parsed
1564 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1565 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_SINE" );
1566 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1568 { // no property, not going to be used, but going to be parsed
1570 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1571 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT_SINE" );
1572 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1574 { // no property, not going to be used, but going to be parsed
1576 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1577 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "BOUNCE" );
1578 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1580 { // no property, not going to be used, but going to be parsed
1582 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1583 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "SIN" );
1584 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1586 { // no property, not going to be used, but going to be parsed
1588 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1589 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT_BACK" );
1590 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1592 { // no property, not going to be used, but going to be parsed
1594 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1595 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, Vector4( 0.0f, 1.0f, 2.0f, 3.0f ) );
1596 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1598 { // no property, not going to be used, but going to be parsed
1601 Property::Array array;
1603 array.PushBack( 0.0f );
1604 array.PushBack( 1.0f );
1605 array.PushBack( 2.0f );
1606 array.PushBack( 3.0f );
1607 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1608 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, array );
1609 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1611 { // no property, not going to be used, but going to be parsed
1614 Property::Array array;
1616 array.PushBack( 0.0f );
1617 array.PushBack( 1.0f );
1618 array.PushBack( 2.0f );
1619 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1620 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, array );
1621 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1623 { // no property, not going to be used, but going to be parsed
1626 Property::Array array;
1628 array.PushBack( 0.0f );
1629 array.PushBack( 10 );
1630 array.PushBack( 2.0f );
1631 array.PushBack( 3.0f );
1632 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1633 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, array );
1634 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1636 { // no property, not going to be used, but going to be parsed
1638 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = 0; // invalid
1639 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1642 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
1643 container.Add( controls[0] );
1645 bool signalReceived(false);
1646 LayoutTransitionFinishCheck finishCheck(signalReceived);
1647 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1649 application.SendNotification();
1650 application.Render( 1u /*just very beginning of the animation*/ );
1652 finishCheck.CheckSignalNotReceived();
1653 // The animation just started
1654 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1655 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1657 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 1.0f, TEST_LOCATION );
1658 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION );
1660 application.SendNotification();
1661 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1663 // The animation just finished
1664 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1665 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1667 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1668 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1670 application.SendNotification();
1671 application.Render( 10u /* wait a bit more for a signal */ );
1673 // Now sizes and positions are finally set
1674 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1675 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1677 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1678 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1680 finishCheck.CheckSignalReceived();
1685 int UtcDaliLayouting_DefaultTransition01(void)
1687 ToolkitTestApplication application;
1688 tet_infoline(" UtcDaliLayouting_DefaultTransition01" );
1690 Stage stage = Stage::GetCurrent();
1691 auto container = Control::New();
1692 auto horizontalLayout = LinearLayout::New();
1693 horizontalLayout.SetAnimateLayout( false );
1694 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1696 DevelControl::SetLayout( container, horizontalLayout );
1697 container.SetName( "Container" );
1699 std::vector< Control > controls;
1700 controls.push_back( CreateLeafControl( 100, 100 ) );
1701 controls.push_back( CreateLeafControl( 100, 100 ) );
1703 stage.Add( container );
1704 container.Add( controls[0] );
1705 container.Add( controls[1] );
1707 // Initial rendering done
1708 application.SendNotification();
1709 application.Render();
1711 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1712 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1713 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1715 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1716 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1717 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1719 horizontalLayout.SetAnimateLayout( true );
1721 auto layoutTransitionData0 = LayoutTransitionData::New();
1723 // Default instant resize
1725 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1726 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1727 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1728 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1729 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1730 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1731 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1732 layoutTransitionData0.AddPropertyAnimator( controls[0], map );
1735 // Instant instant position
1737 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1738 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1739 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1740 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1741 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1742 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1743 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1744 layoutTransitionData0.AddPropertyAnimator( controls[0], map );
1746 DevelControl::GetLayout( controls[0] ).SetTransitionData( LayoutTransitionData::Type::ON_LAYOUT_CHANGE, layoutTransitionData0 );
1748 auto layoutTransitionData1 = LayoutTransitionData::New();
1750 // Default instant resize
1752 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1753 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1754 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1755 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1756 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1757 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1758 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1759 layoutTransitionData1.AddPropertyAnimator( controls[1], map );
1762 // Instant instant position
1764 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1765 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1766 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1767 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1768 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1769 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1770 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1771 layoutTransitionData1.AddPropertyAnimator( controls[1], map );
1773 DevelControl::GetLayout( controls[1] ).SetTransitionData( LayoutTransitionData::Type::ON_LAYOUT_CHANGE, layoutTransitionData1 );
1775 horizontalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1777 application.SendNotification();
1778 application.Render( 10u /*just very beginning of the animation*/ );
1780 // Animation just finished
1781 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1782 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1783 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1785 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1786 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
1787 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
1789 // Now sizes and positions are set
1790 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1791 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1792 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1794 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1795 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1796 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1801 int UtcDaliLayouting_CheckResourceLeak01(void)
1803 ToolkitTestApplication application;
1804 tet_infoline(" UtcDaliLayouting_CheckResourceLeak01 - Remove animating layout and add child to stage" );
1806 Dali::Toolkit::Impl::DummyControl::constructorCount = 0;
1807 Dali::Toolkit::Impl::DummyControl::destructorCount = 0;
1809 Stage stage = Stage::GetCurrent();
1810 auto container = Control::New();
1811 auto linearLayout = LinearLayout::New();
1812 linearLayout.SetAnimateLayout( true );
1814 DevelControl::SetLayout( container, linearLayout );
1815 container.SetName( "Container" );
1817 stage.Add( container );
1819 DummyControl control = DummyControl::New( true );
1820 control.SetName( "DummyControl01" );
1821 control.SetSize( 100, 100 );
1822 container.Add( control );
1824 control = DummyControl::New( true );
1825 control.SetName( "DummyControl02" );
1826 control.SetSize( 100, 100 );
1827 container.Add( control );
1829 linearLayout.SetAnimateLayout( true );
1831 DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::constructorCount, 2, TEST_LOCATION );
1832 DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::destructorCount, 0, TEST_LOCATION );
1834 // Initial rendering done
1835 application.SendNotification();
1836 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1838 DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::constructorCount, 2, TEST_LOCATION );
1839 DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::destructorCount, 0, TEST_LOCATION );
1841 stage.Remove( container );
1844 application.SendNotification();
1845 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1847 DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::constructorCount, 2, TEST_LOCATION );
1848 DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::destructorCount, 1, TEST_LOCATION );
1850 Stage::GetCurrent().Add( control );
1852 application.SendNotification();
1853 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1855 DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::constructorCount, 2, TEST_LOCATION );
1856 DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::destructorCount, 1, TEST_LOCATION );
1858 stage.Remove( control );
1861 application.SendNotification();
1862 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1864 DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::constructorCount, 2, TEST_LOCATION );
1865 DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::destructorCount, 2, TEST_LOCATION );