2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <toolkit-event-thread-callback.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/control-devel.h>
25 #include <dali-toolkit/devel-api/layouting/absolute-layout.h>
26 #include <dali-toolkit/devel-api/layouting/grid.h>
27 #include <dali-toolkit/devel-api/layouting/linear-layout.h>
28 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
29 #include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
31 #include <../custom-layout.h>
33 #include <layout-utils.h>
36 using namespace Toolkit;
38 void utc_dali_toolkit_layouting_animation_startup(void)
40 test_return_value = TET_UNDEF;
43 void utc_dali_toolkit_layouting_animation_cleanup(void)
45 test_return_value = TET_PASS;
51 // Functor to test whether a Finish signal is emitted
52 struct LayoutTransitionFinishCheck
54 LayoutTransitionFinishCheck( bool& signalReceived )
55 : mSignalReceived( signalReceived )
59 void operator()( LayoutTransitionData::LayoutTransitionType type, LayoutTransitionData& layoutTransitionData )
61 mSignalReceived = true;
66 mSignalReceived = false;
69 void CheckSignalReceived()
73 tet_printf("Expected Finish signal was not received\n");
82 void CheckSignalNotReceived()
86 tet_printf("Unexpected Finish signal was received\n");
95 bool& mSignalReceived; // owned by individual tests
100 int UtcDaliLayouting_LayoutTransitionDataConstructorP(void)
102 TestApplication application;
104 LayoutTransitionData layoutTransitionData;
106 DALI_TEST_CHECK( !layoutTransitionData );
110 int UtcDaliLayouting_LayoutTransitionDataNewP(void)
112 TestApplication application;
114 LayoutTransitionData layoutTransitionData = LayoutTransitionData::New();
116 DALI_TEST_CHECK(layoutTransitionData);
120 int UtcDaliLayouting_LayoutTransitionDataDownCastP(void)
122 TestApplication application;
124 LayoutTransitionData layoutTransitionData = LayoutTransitionData::New();
125 BaseHandle object(layoutTransitionData);
127 LayoutTransitionData layoutTransitionData2 = LayoutTransitionData::DownCast(object);
128 DALI_TEST_CHECK(layoutTransitionData2);
130 LayoutTransitionData layoutTransitionData3 = DownCast< LayoutTransitionData >(object);
131 DALI_TEST_CHECK(layoutTransitionData2);
135 int UtcDaliLayouting_LayoutTransitionDataDownCastN(void)
137 TestApplication application;
139 BaseHandle unInitializedObject;
141 LayoutTransitionData layoutTransitionData1 = LayoutTransitionData::DownCast( unInitializedObject );
142 DALI_TEST_CHECK( !layoutTransitionData1 );
144 LayoutTransitionData layoutTransitionData2 = DownCast< LayoutTransitionData >( unInitializedObject );
145 DALI_TEST_CHECK( !layoutTransitionData2 );
149 int UtcDaliLayouting_LayoutTransitionDataSetGetTransition(void)
151 TestApplication application;
153 auto layout = LinearLayout::New();
154 auto layoutTransitionData = LayoutTransitionData::New();
156 layout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, layoutTransitionData );
157 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == layoutTransitionData );
158 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() );
159 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() );
161 layout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, LayoutTransitionData() );
162 layout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
163 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() );
164 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == layoutTransitionData );
165 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() );
167 layout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, LayoutTransitionData() );
168 layout.SetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE, layoutTransitionData );
169 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() );
170 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() );
171 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == layoutTransitionData );
176 int UtcDaliLayouting_SetLayoutTransition01(void)
178 ToolkitTestApplication application;
179 tet_infoline(" UtcDaliLayouting_SetLayoutTransition01");
181 Stage stage = Stage::GetCurrent();
182 auto container = Control::New();
183 auto horizontalLayout = LinearLayout::New();
184 horizontalLayout.SetAnimateLayout( true );
185 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
187 auto verticalLayout = LinearLayout::New();
188 verticalLayout.SetAnimateLayout( true );
189 verticalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
191 DevelControl::SetLayout( container, horizontalLayout );
192 container.SetName( "Container");
194 std::vector< Control > controls;
195 controls.push_back( CreateLeafControl( 100, 100 ) );
196 controls.push_back( CreateLeafControl( 100, 100 ) );
197 for( auto&& iter : controls )
199 container.Add( iter );
202 container.SetParentOrigin( ParentOrigin::CENTER );
203 container.SetAnchorPoint( AnchorPoint::CENTER );
204 stage.Add( container );
206 auto layoutTransitionData = LayoutTransitionData::New();
208 // Instant resize for parent
210 map["property"] = "size";
211 map["targetValue"] = Property::Value(); // capture from layout update
212 map["animator"] = Property::Map()
213 .Add("alphaFunction", "LINEAR")
214 .Add("timePeriod", Property::Map()
216 .Add("duration", 0.0f));
217 layoutTransitionData.AddPropertyAnimator( container, map );
221 map["property"] = "opacity";
222 map["initialValue"] = 0.0f;
223 map["targetValue"] = 1.0f;
224 map["animator"] = Property::Map()
225 .Add("alphaFunction", "LINEAR")
226 .Add("timePeriod", Property::Map()
228 .Add("duration", 0.5f));
229 layoutTransitionData.AddPropertyAnimator( container, map );
232 // Instant position for children
234 map["property"] = "position";
235 map["animator"] = Property::Map()
236 .Add("alphaFunction", "LINEAR")
237 .Add("timePeriod", Property::Map()
239 .Add("duration", 0.0f));
240 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
243 // Grow children from (0,0) size to full size (captured)
245 map["property"] = "size";
246 map["initialValue"] = Vector3( 0.0f, 0.0f, 0 );
247 map["animator"] = Property::Map()
248 .Add("alphaFunction", "LINEAR")
249 .Add("timePeriod", Property::Map()
251 .Add("duration", 0.5f));
252 layoutTransitionData.AddPropertyAnimator( Actor(), map );
255 // Ensure layouting happens
256 application.SendNotification();
257 application.Render();
259 // First round, no animation
260 // TODO: container size (0, 0) after it is added to the stage should be fixed with HQ patch soon
261 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
262 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
263 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
265 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
266 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
267 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
269 bool signalReceived(false);
270 LayoutTransitionFinishCheck finishCheck(signalReceived);
271 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
273 // Change a layout, start transition
274 verticalLayout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, layoutTransitionData );
275 DevelControl::SetLayout( container, verticalLayout );
277 application.SendNotification();
278 application.Render( 1u /*just very beginning of the animation*/ );
280 finishCheck.CheckSignalNotReceived();
281 // Second round, animation just started
282 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
283 DALI_TEST_EQUALS( container.GetCurrentOpacity(), 0.0f, 0.1f, TEST_LOCATION );
284 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
285 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
287 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
288 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION );
289 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION );
291 application.SendNotification();
292 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
294 // Third round, animation just finished
295 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
296 DALI_TEST_EQUALS( container.GetCurrentOpacity(), 1.0f, 0.0001f, TEST_LOCATION );
297 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
298 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
300 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
301 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
302 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
304 application.SendNotification();
305 application.Render( 10u /* wait a bit more for a signal */ );
307 finishCheck.CheckSignalReceived();
309 // Now sizes and positions are finally set
310 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
311 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
312 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
314 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
315 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
316 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
318 // Transition back now with default transition
319 DevelControl::SetLayout( container, horizontalLayout );
321 application.SendNotification();
322 application.Render( 1u /*just very beginning of the animation*/ );
324 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
325 DALI_TEST_EQUALS( container.GetCurrentOpacity(), 1.0f, 0.0001f, TEST_LOCATION );
326 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 1.0f, TEST_LOCATION );
327 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 1.0f, TEST_LOCATION );
329 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
330 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
331 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
333 application.SendNotification();
334 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
336 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
337 DALI_TEST_EQUALS( container.GetCurrentOpacity(), 1.0f, 0.0001f, TEST_LOCATION );
338 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
339 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
341 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
342 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
343 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
345 application.SendNotification();
346 application.Render( 10u /* wait a bit more for complete default animation */ );
348 // Now sizes and positions are finally set
349 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
350 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
351 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
353 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
354 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
355 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
360 int UtcDaliLayouting_AddChildLayoutTransition01(void)
362 ToolkitTestApplication application;
363 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition01");
365 Stage stage = Stage::GetCurrent();
366 auto container = Control::New();
367 auto horizontalLayout = LinearLayout::New();
368 horizontalLayout.SetAnimateLayout( true );
369 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
371 DevelControl::SetLayout( container, horizontalLayout );
372 container.SetName( "Container");
374 std::vector< Control > controls;
375 controls.push_back( CreateLeafControl( 100, 100 ) );
376 container.SetParentOrigin( ParentOrigin::CENTER );
377 container.SetAnchorPoint( AnchorPoint::CENTER );
378 stage.Add( container );
380 auto layoutTransitionData = LayoutTransitionData::New();
382 // Instant resize for parent
384 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "size";
385 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
386 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
387 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
388 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
389 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
390 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
391 layoutTransitionData.AddPropertyAnimator( container, map );
394 // Instant position for a child
396 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "position";
397 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
398 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
399 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
400 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
401 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
402 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
405 // Grow a child from (0,0) size to full size (captured)
407 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "size";
408 map[ LayoutTransitionData::AnimatorKey::INITIAL_VALUE ] = Vector3( 0.0f, 0.0f, 0 );
409 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
410 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
411 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
412 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
413 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
414 layoutTransitionData.AddPropertyAnimator( controls[0], map );
417 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
418 container.Add( controls[0] );
420 bool signalReceived(false);
421 LayoutTransitionFinishCheck finishCheck(signalReceived);
422 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
424 application.SendNotification();
425 application.Render( 1u /*just very beginning of the animation*/ );
427 finishCheck.CheckSignalNotReceived();
428 // The animation just started
429 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
430 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
432 application.SendNotification();
433 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
435 // The animation just finished
436 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
437 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
439 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
440 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
442 application.SendNotification();
443 application.Render( 10u /* wait a bit more for a signal */ );
445 // Now sizes and positions are finally set
446 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
447 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
449 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
450 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
452 finishCheck.CheckSignalReceived();
457 int UtcDaliLayouting_RemoveChildLayoutTransition01(void)
459 ToolkitTestApplication application;
460 tet_infoline(" UtcDaliLayouting_RemoveChildLayoutTransition01");
462 Stage stage = Stage::GetCurrent();
463 auto container = Control::New();
464 auto horizontalLayout = LinearLayout::New();
465 horizontalLayout.SetAnimateLayout( true );
466 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
468 DevelControl::SetLayout( container, horizontalLayout );
469 container.SetName( "Container");
471 std::vector< Control > controls;
472 controls.push_back( CreateLeafControl( 100, 100 ) );
473 controls.push_back( CreateLeafControl( 100, 100 ) );
474 container.SetParentOrigin( ParentOrigin::CENTER );
475 container.SetAnchorPoint( AnchorPoint::CENTER );
476 stage.Add( container );
477 container.Add( controls[0] );
478 container.Add( controls[1] );
480 // Initial rendering done
481 application.SendNotification();
482 application.Render();
484 auto layoutTransitionData = LayoutTransitionData::New();
486 // Instant resize for parent width
488 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_WIDTH;
489 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
490 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
491 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
492 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
493 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
494 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
495 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
496 layoutTransitionData.AddPropertyAnimator( container, map );
499 // Instant resize for parent height
501 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_HEIGHT;
502 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
503 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
504 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
505 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
506 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
507 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
508 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
509 layoutTransitionData.AddPropertyAnimator( container, map );
512 // Instant position for parent X position
514 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_X;
515 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
516 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
517 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
518 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
519 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
520 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
521 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
522 layoutTransitionData.AddPropertyAnimator( container, map );
525 // Instant position for parent Y position
527 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_Y;
528 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
529 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
530 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
531 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
532 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
533 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
534 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
535 layoutTransitionData.AddPropertyAnimator( container, map );
538 // Shrink the children
540 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_WIDTH;
541 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 0.0f;
542 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
543 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
544 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
545 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
546 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
547 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
548 layoutTransitionData.AddPropertyAnimator( Actor(), map );
551 // Shrink the children
553 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_HEIGHT;
554 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 0.0f;
555 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
556 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
557 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
558 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
559 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
560 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
561 layoutTransitionData.AddPropertyAnimator( Actor(), map );
564 // Instant position for a child
566 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_X;
567 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
568 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
569 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
570 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
571 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
572 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
573 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
576 // Instant position for a child
578 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_Y;
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.0f ) );
585 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
588 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE, layoutTransitionData );
589 container.Remove( controls[1] );
591 bool signalReceived(false);
592 LayoutTransitionFinishCheck finishCheck(signalReceived);
593 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
595 application.SendNotification();
596 application.Render( 1u /*just very beginning of the animation*/ );
598 finishCheck.CheckSignalNotReceived();
599 // Animation just started
600 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
601 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
602 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
604 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
605 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION );
606 // this control is already removed from the tree.
607 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
609 application.SendNotification();
610 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
612 // Animation just finished
613 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
614 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
615 // this control is already removed from the tree.
616 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
618 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
619 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION );
620 // this control is already removed from the tree.
621 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
623 application.SendNotification();
624 application.Render( 10u /* wait a bit more for a signal */ );
626 // Now sizes and positions are finally set
627 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
628 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
629 // this control is already removed from the tree.
630 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
632 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
633 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
634 // this control is already removed from the tree.
635 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
637 finishCheck.CheckSignalReceived();
642 int UtcDaliLayouting_AddChildLayoutTransition02_KeyFrames(void)
644 ToolkitTestApplication application;
645 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition02_KeyFrames");
647 Stage stage = Stage::GetCurrent();
648 auto container = Control::New();
649 auto horizontalLayout = LinearLayout::New();
650 horizontalLayout.SetAnimateLayout( true );
651 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
653 DevelControl::SetLayout( container, horizontalLayout );
654 container.SetName( "Container");
656 std::vector< Control > controls;
657 controls.push_back( CreateLeafControl( 100, 100 ) );
658 container.SetParentOrigin( ParentOrigin::CENTER );
659 container.SetAnchorPoint( AnchorPoint::CENTER );
660 stage.Add( container );
662 auto layoutTransitionData = LayoutTransitionData::New();
664 // Instant resize for parent
666 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
667 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
668 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
669 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
670 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
671 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
672 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
673 layoutTransitionData.AddPropertyAnimator( container, map );
676 // Instant position for a child
678 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
679 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
680 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
681 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
682 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
683 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
684 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
687 // Grow a child from (0,0) size to full size with key frames
688 KeyFrames keyFrames = KeyFrames::New();
689 keyFrames.Add( 0.0f, Vector3( 0.0f, 0.0f, 0 ) );
690 keyFrames.Add( 0.5f, Vector3( 100.0f, 100.0f, 0 ) );
693 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
694 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
695 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_BETWEEN")
696 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
697 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
698 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
699 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
700 layoutTransitionData.AddPropertyAnimator( controls[0], map, keyFrames, Animation::Interpolation::Linear );
703 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
704 container.Add( controls[0] );
706 bool signalReceived(false);
707 LayoutTransitionFinishCheck finishCheck(signalReceived);
708 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
710 application.SendNotification();
711 application.Render( 1u /*just very beginning of the animation*/ );
713 finishCheck.CheckSignalNotReceived();
714 // The animation just started
715 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
716 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
718 application.SendNotification();
719 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
721 // The animation just finished
722 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
723 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
725 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
726 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
728 application.SendNotification();
729 application.Render( 10u /* wait a bit more for a signal */ );
731 // Now sizes and positions are finally set
732 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
733 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
735 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
736 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
738 finishCheck.CheckSignalReceived();
743 int UtcDaliLayouting_AddChildLayoutTransition03_Path(void)
745 ToolkitTestApplication application;
746 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition03_Path");
748 Stage stage = Stage::GetCurrent();
749 auto container = Control::New();
750 auto horizontalLayout = LinearLayout::New();
751 horizontalLayout.SetAnimateLayout( true );
752 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
754 DevelControl::SetLayout( container, horizontalLayout );
755 container.SetName( "Container");
757 std::vector< Control > controls;
758 controls.push_back( CreateLeafControl( 100, 100 ) );
759 container.SetParentOrigin( ParentOrigin::CENTER );
760 container.SetAnchorPoint( AnchorPoint::CENTER );
761 stage.Add( container );
763 auto layoutTransitionData = LayoutTransitionData::New();
765 // Instant resize for parent
767 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
768 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
769 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
770 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
771 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
772 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
773 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
774 layoutTransitionData.AddPropertyAnimator( container, map );
777 Dali::Path path = Dali::Path::New();
779 // Curve position for a child
781 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
782 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
783 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_PATH")
784 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
785 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
786 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
787 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f ) );
790 Vector3 position0( 30.0, 80.0, 0.0 );
791 Vector3 position1( 70.0, 120.0, 0.0 );
792 Vector3 position2( 0.0, 350.0, 0.0 );
794 //Dali::Path path = Dali::Path::New();
795 path.AddPoint( position0 );
796 path.AddPoint( position1 );
797 path.AddPoint( position2 );
799 // Control points for first segment
800 path.AddControlPoint( Vector3( 39.0, 90.0, 0.0 ) );
801 path.AddControlPoint( Vector3( 56.0, 119.0, 0.0 ) );
803 // Control points for second segment
804 path.AddControlPoint( Vector3( 78.0, 120.0, 0.0 ) );
805 path.AddControlPoint( Vector3( 93.0, 104.0, 0.0 ) );
807 layoutTransitionData.AddPropertyAnimator( controls[0], map, path, Vector3::XAXIS );
810 // Grow a child from (0,0) size to full size (captured)
812 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "size";
813 map[ LayoutTransitionData::AnimatorKey::INITIAL_VALUE ] = Vector3( 0.0f, 0.0f, 0 );
814 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
815 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
816 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
817 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
818 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
819 layoutTransitionData.AddPropertyAnimator( controls[0], map );
822 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
823 container.Add( controls[0] );
825 bool signalReceived(false);
826 LayoutTransitionFinishCheck finishCheck(signalReceived);
827 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
829 application.SendNotification();
830 application.Render( 0 );
832 finishCheck.CheckSignalNotReceived();
833 // The animation just started
834 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
836 Vector3 position, tangent;
838 path.Sample( 0.0f, position, tangent );
839 rotation = Quaternion( Vector3::XAXIS, tangent );
840 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), position, 0.0001f, TEST_LOCATION );
841 DALI_TEST_EQUALS( controls[0].GetCurrentOrientation(), rotation, 0.0001f, TEST_LOCATION );
843 application.SendNotification();
844 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
846 path.Sample( 1.0f, position, tangent );
847 rotation = Quaternion( Vector3::XAXIS, tangent );
848 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), position, 0.0001f, TEST_LOCATION );
849 DALI_TEST_EQUALS( controls[0].GetCurrentOrientation(), rotation, 0.0001f, TEST_LOCATION );
851 // The animation just finished
852 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
853 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
855 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
856 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
858 application.SendNotification();
859 application.Render( 10u /* wait a bit more for a signal */ );
861 // Now sizes and positions are finally set
862 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
863 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
865 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
866 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
868 finishCheck.CheckSignalReceived();
873 int UtcDaliLayouting_AddChildLayoutTransition04_AnimateBy(void)
875 ToolkitTestApplication application;
876 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition04_AnimateBy");
878 Stage stage = Stage::GetCurrent();
879 auto container = Control::New();
880 auto horizontalLayout = LinearLayout::New();
881 horizontalLayout.SetAnimateLayout( true );
882 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
884 DevelControl::SetLayout( container, horizontalLayout );
885 container.SetName( "Container");
887 std::vector< Control > controls;
888 controls.push_back( CreateLeafControl( 100, 100 ) );
889 container.SetParentOrigin( ParentOrigin::CENTER );
890 container.SetAnchorPoint( AnchorPoint::CENTER );
891 stage.Add( container );
893 auto layoutTransitionData = LayoutTransitionData::New();
895 // Instant resize for parent
897 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
898 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
899 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
900 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
901 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
902 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
903 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
904 layoutTransitionData.AddPropertyAnimator( container, map );
907 // Instant position for a child
909 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
910 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
911 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
912 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
913 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
914 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
915 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
919 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
920 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 0.0f, 350.0f, 0 );
921 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
922 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_BY")
923 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
924 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
925 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
926 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
927 layoutTransitionData.AddPropertyAnimator( controls[0], map );
930 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
931 container.Add( controls[0] );
933 bool signalReceived(false);
934 LayoutTransitionFinishCheck finishCheck(signalReceived);
935 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
937 application.SendNotification();
938 application.Render( 1u /*just very beginning of the animation*/ );
940 finishCheck.CheckSignalNotReceived();
941 // The animation just started
942 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
943 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
945 application.SendNotification();
946 application.Render( static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
948 // The animation just finished
949 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
950 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
952 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
953 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
955 application.SendNotification();
956 application.Render( 10u /* wait a bit more for a signal */ );
958 // Now sizes and positions are finally set
959 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
960 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
962 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
963 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
965 finishCheck.CheckSignalReceived();
970 int UtcDaliLayouting_AddChildLayoutTransition05(void)
972 ToolkitTestApplication application;
973 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition05");
975 Stage stage = Stage::GetCurrent();
976 auto container = Control::New();
977 auto horizontalLayout = LinearLayout::New();
978 horizontalLayout.SetAnimateLayout( true );
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 container.SetParentOrigin( ParentOrigin::CENTER );
987 container.SetAnchorPoint( AnchorPoint::CENTER );
988 stage.Add( container );
990 auto layoutTransitionData = LayoutTransitionData::New();
992 // Instant resize for parent
994 map[ "property" ] = Actor::Property::SIZE;
995 map[ "targetValue" ] = Property::Value(); // capture from layout update
996 map[ "animator" ] = Property::Map()
997 .Add( "name", "InstantAnimator" )
998 .Add( "type", "ANIMATE_TO")
999 .Add( "alphaFunction", "LINEAR" )
1000 .Add( "timePeriod", Property::Map()
1001 .Add( "delay", 0.0f )
1002 .Add( "duration", 0.0f ) );
1003 layoutTransitionData.AddPropertyAnimator( container, map );
1006 // Instant position for a child
1008 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::COLOR_ALPHA;
1009 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = "InstantAnimator";
1010 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1013 // Grow a child from (0,0) size to full size (captured)
1015 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1016 map[ LayoutTransitionData::AnimatorKey::INITIAL_VALUE ] = Vector3( 0.0f, 0.0f, 0 );
1017 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = std::string();
1018 layoutTransitionData.AddPropertyAnimator( controls[0], map );
1021 // Instant opacity for a child, for testing
1023 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1024 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = "InstantAnimator";
1025 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1028 // Just throw all other alpha functions in
1029 { // no property, not going to be used, but going to be parsed
1031 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1032 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "WRONG" );
1033 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1035 { // no property, not going to be used, but going to be parsed
1037 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1038 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" );
1039 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1041 { // no property, not going to be used, but going to be parsed
1043 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1044 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "REVERSE" );
1045 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1047 { // no property, not going to be used, but going to be parsed
1049 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1050 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_SQUARE" );
1051 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1053 { // no property, not going to be used, but going to be parsed
1055 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1056 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT_SQUARE" );
1057 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1059 { // no property, not going to be used, but going to be parsed
1061 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1062 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN" );
1063 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1065 { // no property, not going to be used, but going to be parsed
1067 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1068 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN" );
1069 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1071 { // no property, not going to be used, but going to be parsed
1073 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1074 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT" );
1075 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1077 { // no property, not going to be used, but going to be parsed
1079 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1080 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_OUT" );
1081 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1083 { // no property, not going to be used, but going to be parsed
1085 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1086 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_OUT_SINE" );
1087 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1089 { // no property, not going to be used, but going to be parsed
1091 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1092 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_SINE" );
1093 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1095 { // no property, not going to be used, but going to be parsed
1097 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1098 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT_SINE" );
1099 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1101 { // no property, not going to be used, but going to be parsed
1103 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1104 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "BOUNCE" );
1105 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1107 { // no property, not going to be used, but going to be parsed
1109 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1110 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "SIN" );
1111 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1113 { // no property, not going to be used, but going to be parsed
1115 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1116 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT_BACK" );
1117 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1119 { // no property, not going to be used, but going to be parsed
1121 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1122 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, Vector4( 0.0f, 1.0f, 2.0f, 3.0f ) );
1123 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1125 { // no property, not going to be used, but going to be parsed
1128 Property::Array array;
1130 array.PushBack( 0.0f );
1131 array.PushBack( 1.0f );
1132 array.PushBack( 2.0f );
1133 array.PushBack( 3.0f );
1134 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1135 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, array );
1136 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1138 { // no property, not going to be used, but going to be parsed
1141 Property::Array array;
1143 array.PushBack( 0.0f );
1144 array.PushBack( 1.0f );
1145 array.PushBack( 2.0f );
1146 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1147 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, array );
1148 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1150 { // no property, not going to be used, but going to be parsed
1153 Property::Array array;
1155 array.PushBack( 0.0f );
1156 array.PushBack( 10 );
1157 array.PushBack( 2.0f );
1158 array.PushBack( 3.0f );
1159 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1160 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, array );
1161 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1163 { // no property, not going to be used, but going to be parsed
1165 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = 0; // invalid
1166 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1169 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
1170 container.Add( controls[0] );
1172 bool signalReceived(false);
1173 LayoutTransitionFinishCheck finishCheck(signalReceived);
1174 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1176 application.SendNotification();
1177 application.Render( 1u /*just very beginning of the animation*/ );
1179 finishCheck.CheckSignalNotReceived();
1180 // The animation just started
1181 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1182 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1184 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 1.0f, TEST_LOCATION );
1185 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION );
1187 application.SendNotification();
1188 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1190 // The animation just finished
1191 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1192 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1194 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1195 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1197 application.SendNotification();
1198 application.Render( 10u /* wait a bit more for a signal */ );
1200 // Now sizes and positions are finally set
1201 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1202 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1204 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1205 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1207 finishCheck.CheckSignalReceived();