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>
34 #include <layout-utils.h>
37 using namespace Toolkit;
39 void utc_dali_toolkit_layouting_animation_startup(void)
41 test_return_value = TET_UNDEF;
44 void utc_dali_toolkit_layouting_animation_cleanup(void)
46 test_return_value = TET_PASS;
52 // Functor to test whether a Finish signal is emitted
53 struct LayoutTransitionFinishCheck
55 LayoutTransitionFinishCheck( bool& signalReceived )
56 : mSignalReceived( signalReceived )
60 void operator()( LayoutTransitionData::Type type, LayoutTransitionData& layoutTransitionData )
62 mSignalReceived = true;
67 mSignalReceived = false;
70 void CheckSignalReceived()
74 tet_printf("Expected Finish signal was not received\n");
83 void CheckSignalNotReceived()
87 tet_printf("Unexpected Finish signal was received\n");
96 bool& mSignalReceived; // owned by individual tests
101 int UtcDaliLayouting_LayoutTransitionDataConstructorP(void)
103 TestApplication application;
105 LayoutTransitionData layoutTransitionData;
107 DALI_TEST_CHECK( !layoutTransitionData );
111 int UtcDaliLayouting_LayoutTransitionDataNewP(void)
113 TestApplication application;
115 LayoutTransitionData layoutTransitionData = LayoutTransitionData::New();
117 DALI_TEST_CHECK(layoutTransitionData);
121 int UtcDaliLayouting_LayoutTransitionDataDownCastP(void)
123 TestApplication application;
125 LayoutTransitionData layoutTransitionData = LayoutTransitionData::New();
126 BaseHandle object(layoutTransitionData);
128 LayoutTransitionData layoutTransitionData2 = LayoutTransitionData::DownCast(object);
129 DALI_TEST_CHECK(layoutTransitionData2);
131 LayoutTransitionData layoutTransitionData3 = DownCast< LayoutTransitionData >(object);
132 DALI_TEST_CHECK(layoutTransitionData2);
136 int UtcDaliLayouting_LayoutTransitionDataDownCastN(void)
138 TestApplication application;
140 BaseHandle unInitializedObject;
142 LayoutTransitionData layoutTransitionData1 = LayoutTransitionData::DownCast( unInitializedObject );
143 DALI_TEST_CHECK( !layoutTransitionData1 );
145 LayoutTransitionData layoutTransitionData2 = DownCast< LayoutTransitionData >( unInitializedObject );
146 DALI_TEST_CHECK( !layoutTransitionData2 );
150 int UtcDaliLayouting_LayoutTransitionDataSetGetTransition(void)
152 TestApplication application;
154 auto layout = LinearLayout::New();
155 auto layoutTransitionData = LayoutTransitionData::New();
157 layout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
158 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == layoutTransitionData );
159 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() );
160 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == LayoutTransitionData() );
161 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() );
162 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == LayoutTransitionData() );
164 layout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, LayoutTransitionData() );
165 layout.SetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE, layoutTransitionData );
166 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() );
167 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == layoutTransitionData );
168 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == LayoutTransitionData() );
169 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() );
170 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == LayoutTransitionData() );
172 layout.SetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE, LayoutTransitionData() );
173 layout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, layoutTransitionData );
174 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() );
175 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() );
176 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == layoutTransitionData );
177 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() );
178 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == LayoutTransitionData() );
180 layout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, LayoutTransitionData() );
181 layout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, layoutTransitionData );
182 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() );
183 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() );
184 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == LayoutTransitionData() );
185 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == layoutTransitionData );
186 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == LayoutTransitionData() );
188 layout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, LayoutTransitionData() );
189 layout.SetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE, layoutTransitionData );
190 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() );
191 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() );
192 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == LayoutTransitionData() );
193 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() );
194 DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == layoutTransitionData );
199 int UtcDaliLayouting_SetLayoutTransition01(void)
201 ToolkitTestApplication application;
202 tet_infoline(" UtcDaliLayouting_SetLayoutTransition01");
204 Stage stage = Stage::GetCurrent();
205 auto container = Control::New();
206 auto horizontalLayout = LinearLayout::New();
207 horizontalLayout.SetAnimateLayout( false );
208 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
210 auto verticalLayout = LinearLayout::New();
211 verticalLayout.SetAnimateLayout( false );
212 verticalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
214 DevelControl::SetLayout( container, horizontalLayout );
215 container.SetName( "Container");
217 std::vector< Control > controls;
218 controls.push_back( CreateLeafControl( 100, 100 ) );
219 controls.push_back( CreateLeafControl( 100, 100 ) );
220 for( auto&& iter : controls )
222 container.Add( iter );
224 stage.Add( container );
226 auto layoutTransitionData = LayoutTransitionData::New();
228 // Instant resize for parent
230 map["property"] = "size";
231 map["targetValue"] = Property::Value(); // capture from layout update
232 map["animator"] = Property::Map()
233 .Add("alphaFunction", "LINEAR")
234 .Add("timePeriod", Property::Map()
236 .Add("duration", 0.0f));
237 layoutTransitionData.AddPropertyAnimator( container, map );
241 map["property"] = "opacity";
242 map["initialValue"] = 0.0f;
243 map["targetValue"] = 1.0f;
244 map["animator"] = Property::Map()
245 .Add("alphaFunction", "LINEAR")
246 .Add("timePeriod", Property::Map()
248 .Add("duration", 0.5f));
249 layoutTransitionData.AddPropertyAnimator( container, map );
252 // Instant position for children
254 map["property"] = "position";
255 map["animator"] = Property::Map()
256 .Add("alphaFunction", "LINEAR")
257 .Add("timePeriod", Property::Map()
259 .Add("duration", 0.0f));
260 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
263 // Grow children from (0,0) size to full size (captured)
265 map["property"] = "size";
266 map["initialValue"] = Vector3( 0.0f, 0.0f, 0 );
267 map["animator"] = Property::Map()
268 .Add("alphaFunction", "LINEAR")
269 .Add("timePeriod", Property::Map()
271 .Add("duration", 0.5f));
272 layoutTransitionData.AddPropertyAnimator( Actor(), map );
275 // Ensure layouting happens
276 application.SendNotification();
277 application.Render();
279 // First round, no animation
280 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
281 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
282 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
284 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
285 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
286 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
288 bool signalReceived(false);
289 LayoutTransitionFinishCheck finishCheck(signalReceived);
290 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
292 horizontalLayout.SetAnimateLayout( true );
293 verticalLayout.SetAnimateLayout( true );
295 // Change a layout, start transition
296 verticalLayout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, layoutTransitionData );
297 DevelControl::SetLayout( container, verticalLayout );
299 application.SendNotification();
300 application.Render( 1u /*just very beginning of the animation*/ );
302 finishCheck.CheckSignalNotReceived();
303 // Second round, animation just started
304 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
305 DALI_TEST_EQUALS( container.GetCurrentOpacity(), 0.0f, 0.1f, TEST_LOCATION );
306 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
307 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
309 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
310 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION );
311 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION );
313 application.SendNotification();
314 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
316 // Third round, animation just finished
317 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
318 DALI_TEST_EQUALS( container.GetCurrentOpacity(), 1.0f, 0.0001f, TEST_LOCATION );
319 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
320 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
322 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
323 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
324 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
326 application.SendNotification();
327 application.Render( 10u /* wait a bit more for a signal */ );
329 finishCheck.CheckSignalReceived();
331 // Now sizes and positions are finally set
332 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
333 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
334 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
336 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
337 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
338 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
340 // Transition back now with default transition
341 DevelControl::SetLayout( container, horizontalLayout );
343 application.SendNotification();
344 application.Render( 1u /*just very beginning of the animation*/ );
346 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
347 DALI_TEST_EQUALS( container.GetCurrentOpacity(), 1.0f, 0.0001f, TEST_LOCATION );
348 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 1.0f, TEST_LOCATION );
349 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 1.0f, TEST_LOCATION );
351 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
352 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
353 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
355 application.SendNotification();
356 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
358 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
359 DALI_TEST_EQUALS( container.GetCurrentOpacity(), 1.0f, 0.0001f, TEST_LOCATION );
360 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
361 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
363 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
364 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
365 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
367 application.SendNotification();
368 application.Render( 10u /* wait a bit more for complete default animation */ );
370 // Now sizes and positions are finally set
371 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
372 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
373 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
375 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
376 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
377 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
382 int UtcDaliLayouting_AddChildLayoutTransition01(void)
384 ToolkitTestApplication application;
385 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition01");
387 Stage stage = Stage::GetCurrent();
388 auto container = Control::New();
389 auto horizontalLayout = LinearLayout::New();
390 horizontalLayout.SetAnimateLayout( true );
391 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
393 DevelControl::SetLayout( container, horizontalLayout );
394 container.SetName( "Container");
396 std::vector< Control > controls;
397 controls.push_back( CreateLeafControl( 100, 100 ) );
398 stage.Add( container );
400 auto layoutTransitionData = LayoutTransitionData::New();
402 // Instant resize for parent
404 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "size";
405 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
406 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
407 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
408 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
409 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
410 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
411 layoutTransitionData.AddPropertyAnimator( container, map );
414 // Instant position for a child
416 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::NONE;
417 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "position";
418 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
419 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
420 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
421 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
422 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
423 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
426 // Grow a child from (0,0) size to full size (captured)
428 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_ADD;
429 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "size";
430 map[ LayoutTransitionData::AnimatorKey::INITIAL_VALUE ] = Vector3( 0.0f, 0.0f, 0 );
431 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
432 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
433 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
434 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
435 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
436 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to an added child
439 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
440 container.Add( controls[0] );
442 bool signalReceived(false);
443 LayoutTransitionFinishCheck finishCheck(signalReceived);
444 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
446 application.SendNotification();
447 application.Render( 1u /*just very beginning of the animation*/ );
449 finishCheck.CheckSignalNotReceived();
450 // The animation just started
451 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
452 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
454 application.SendNotification();
455 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
457 // The animation just finished
458 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
459 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
461 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
462 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
464 application.SendNotification();
465 application.Render( 10u /* wait a bit more for a signal */ );
467 // Now sizes and positions are finally set
468 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
469 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
471 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
472 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
474 finishCheck.CheckSignalReceived();
479 int UtcDaliLayouting_RemoveChildLayoutTransition01(void)
481 ToolkitTestApplication application;
482 tet_infoline(" UtcDaliLayouting_RemoveChildLayoutTransition01");
484 Stage stage = Stage::GetCurrent();
485 auto container = Control::New();
486 auto horizontalLayout = LinearLayout::New();
487 horizontalLayout.SetAnimateLayout( false );
488 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
490 DevelControl::SetLayout( container, horizontalLayout );
491 container.SetName( "Container" );
493 std::vector< Control > controls;
494 controls.push_back( CreateLeafControl( 100, 100 ) );
495 controls.push_back( CreateLeafControl( 100, 100 ) );
497 stage.Add( container );
498 container.Add( controls[0] );
499 container.Add( controls[1] );
501 // Initial rendering done
502 application.SendNotification();
503 application.Render();
505 horizontalLayout.SetAnimateLayout( true );
507 auto layoutTransitionData = LayoutTransitionData::New();
509 // Instant resize for parent width
511 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_WIDTH;
512 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
513 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
514 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
515 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
516 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
517 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
518 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
519 layoutTransitionData.AddPropertyAnimator( container, map );
522 // Instant resize for parent height
524 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_HEIGHT;
525 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
526 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
527 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
528 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
529 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
530 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
531 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
532 layoutTransitionData.AddPropertyAnimator( container, map );
535 // Instant position for parent X position
537 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_X;
538 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
539 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
540 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
541 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
542 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
543 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
544 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
545 layoutTransitionData.AddPropertyAnimator( container, map );
548 // Instant position for parent Y position
550 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_Y;
551 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
552 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
553 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
554 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
555 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
556 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
557 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
558 layoutTransitionData.AddPropertyAnimator( container, map );
561 // Shrink the children
563 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_WIDTH;
564 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 0.0f;
565 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
566 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
567 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
568 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
569 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
570 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
571 layoutTransitionData.AddPropertyAnimator( Actor(), map );
574 // Shrink the children
576 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_HEIGHT;
577 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 0.0f;
578 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
579 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
580 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
581 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
582 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
583 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
584 layoutTransitionData.AddPropertyAnimator( Actor(), map );
587 // Shrink the removed child
589 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_REMOVE;
590 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
591 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Size( 0.0f, 0.0f );
592 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
593 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
594 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
595 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
596 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
597 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
598 layoutTransitionData.AddPropertyAnimator( Actor(), map );
601 // Instant position for children
603 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_X;
604 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
605 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
606 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
607 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
608 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
609 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
610 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
613 // Instant position for children
615 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_Y;
616 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
617 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" )
618 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
619 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
620 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
621 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
622 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
625 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE, layoutTransitionData );
626 container.Remove( controls[1] );
628 bool signalReceived(false);
629 LayoutTransitionFinishCheck finishCheck(signalReceived);
630 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
632 application.SendNotification();
633 application.Render( 1u /*just very beginning of the animation*/ );
635 finishCheck.CheckSignalNotReceived();
636 // Animation just started
637 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
638 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
639 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
641 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
642 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
643 // this control is already removed from the tree.
644 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
646 application.SendNotification();
647 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
649 // Animation just finished
650 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
651 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
652 // this control is already removed from the tree.
653 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION );
655 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
656 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION );
657 // this control is already removed from the tree.
658 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
660 application.SendNotification();
661 application.Render( 10u /* wait a bit more for a signal */ );
663 // Now sizes and positions are finally set
664 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
665 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
666 // this control is already removed from the tree.
667 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION );
669 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
670 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
671 // this control is already removed from the tree.
672 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
674 finishCheck.CheckSignalReceived();
679 int UtcDaliLayouting_FocusChildLayoutTransition01(void)
681 ToolkitTestApplication application;
682 tet_infoline(" UtcDaliLayouting_FocusChildLayoutTransition01");
684 Stage stage = Stage::GetCurrent();
685 auto container = Control::New();
686 auto horizontalLayout = LinearLayout::New();
687 horizontalLayout.SetAnimateLayout( false );
688 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
690 DevelControl::SetLayout( container, horizontalLayout );
691 container.SetName( "Container" );
693 std::vector< Control > controls;
694 controls.push_back( CreateLeafControl( 100, 100 ) );
695 controls.push_back( CreateLeafControl( 100, 100 ) );
697 stage.Add( container );
698 container.Add( controls[0] );
699 container.Add( controls[1] );
701 KeyInputFocusManager manager = KeyInputFocusManager::Get();
702 manager.SetFocus( controls[0] );
704 // Initial rendering done
705 application.SendNotification();
706 application.Render();
708 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
709 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
710 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
712 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
713 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
714 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
716 horizontalLayout.SetAnimateLayout( true );
718 auto layoutTransitionData = LayoutTransitionData::New();
720 // Instant resize for parent
722 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
723 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
724 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
725 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
726 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
727 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
728 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
729 layoutTransitionData.AddPropertyAnimator( container, map );
732 // Instant position for parent
734 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
735 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
736 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
737 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
738 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
739 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
740 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
741 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
744 // Shrink the lost focus child
746 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
747 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST;
748 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 80.0f, 80.0f, 0 );
749 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
750 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
751 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
752 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
753 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
754 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child
757 // Grow the gained focus child
759 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
760 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_GAINED;
761 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 120.0f, 120.0f, 0 );
762 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
763 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
764 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
765 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
766 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
767 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus gained child
770 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, layoutTransitionData );
772 bool signalReceived(false);
773 LayoutTransitionFinishCheck finishCheck(signalReceived);
774 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
775 manager.SetFocus( controls[1] );
777 application.SendNotification();
778 application.Render( 1u /*just very beginning of the animation*/ );
780 finishCheck.CheckSignalNotReceived();
781 // Animation just started
782 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
783 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
784 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
786 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
787 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
788 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
790 application.SendNotification();
791 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
793 // Animation just finished
794 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
795 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
796 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
798 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
799 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 80.0f, 80.0f, 0.0f ), 1.0f, TEST_LOCATION );
800 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 120.0f, 120.0f, 0.0f ), 1.0f, TEST_LOCATION );
802 application.SendNotification();
803 application.Render( 10u /* wait a bit more for a signal */ );
805 // Now sizes and positions are finally set
806 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
807 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
808 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
810 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
811 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
812 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
814 finishCheck.CheckSignalReceived();
819 int UtcDaliLayouting_AddChildLayoutTransition02_KeyFrames(void)
821 ToolkitTestApplication application;
822 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition02_KeyFrames");
824 Stage stage = Stage::GetCurrent();
825 auto container = Control::New();
826 auto horizontalLayout = LinearLayout::New();
827 horizontalLayout.SetAnimateLayout( true );
828 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
830 DevelControl::SetLayout( container, horizontalLayout );
831 container.SetName( "Container");
833 std::vector< Control > controls;
834 controls.push_back( CreateLeafControl( 100, 100 ) );
835 stage.Add( container );
837 auto layoutTransitionData = LayoutTransitionData::New();
839 // Instant resize for parent
841 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
842 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
843 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
844 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
845 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
846 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
847 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
848 layoutTransitionData.AddPropertyAnimator( container, map );
851 // Instant position for a child
853 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
854 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
855 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
856 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
857 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
858 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
859 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
862 // Grow a child from (0,0) size to full size with key frames
863 KeyFrames keyFrames = KeyFrames::New();
864 keyFrames.Add( 0.0f, Vector3( 0.0f, 0.0f, 0 ) );
865 keyFrames.Add( 0.5f, Vector3( 100.0f, 100.0f, 0 ) );
868 map[ "property" ] = Actor::Property::SIZE;
869 map[ "condition" ] = LayoutTransitionData::Condition::ON_ADD;
870 map[ "animator" ] = Property::Map()
871 .Add( "type", "ANIMATE_BETWEEN")
872 .Add( "alphaFunction", "LINEAR")
873 .Add( "timePeriod", Property::Map()
875 .Add( "duration", 0.5f));
876 layoutTransitionData.AddPropertyAnimator( Actor(), map, keyFrames, Animation::Interpolation::Linear );
879 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
880 container.Add( controls[0] );
882 bool signalReceived(false);
883 LayoutTransitionFinishCheck finishCheck(signalReceived);
884 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
886 application.SendNotification();
887 application.Render( 1u /*just very beginning of the animation*/ );
889 finishCheck.CheckSignalNotReceived();
890 // The animation just started
891 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
892 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
894 application.SendNotification();
895 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
897 // The animation just finished
898 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
899 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
901 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
902 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
904 application.SendNotification();
905 application.Render( 10u /* wait a bit more for a signal */ );
907 // Now sizes and positions are finally set
908 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
909 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
911 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
912 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
914 finishCheck.CheckSignalReceived();
919 int UtcDaliLayouting_AddChildLayoutTransition03_Path(void)
921 ToolkitTestApplication application;
922 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition03_Path");
924 Stage stage = Stage::GetCurrent();
925 auto container = Control::New();
926 auto horizontalLayout = LinearLayout::New();
927 horizontalLayout.SetAnimateLayout( true );
928 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
930 DevelControl::SetLayout( container, horizontalLayout );
931 container.SetName( "Container");
933 std::vector< Control > controls;
934 controls.push_back( CreateLeafControl( 100, 100 ) );
935 stage.Add( container );
937 auto layoutTransitionData = LayoutTransitionData::New();
939 // Instant resize for parent
941 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
942 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
943 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
944 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
945 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
946 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
947 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
948 layoutTransitionData.AddPropertyAnimator( container, map );
951 Dali::Path path = Dali::Path::New();
953 // Curve position for a child
955 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
956 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
957 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_PATH")
958 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
959 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
960 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
961 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f ) );
964 Vector3 position0( 30.0, 80.0, 0.0 );
965 Vector3 position1( 70.0, 120.0, 0.0 );
966 Vector3 position2( 0.0, 350.0, 0.0 );
968 //Dali::Path path = Dali::Path::New();
969 path.AddPoint( position0 );
970 path.AddPoint( position1 );
971 path.AddPoint( position2 );
973 // Control points for first segment
974 path.AddControlPoint( Vector3( 39.0, 90.0, 0.0 ) );
975 path.AddControlPoint( Vector3( 56.0, 119.0, 0.0 ) );
977 // Control points for second segment
978 path.AddControlPoint( Vector3( 78.0, 120.0, 0.0 ) );
979 path.AddControlPoint( Vector3( 93.0, 104.0, 0.0 ) );
981 layoutTransitionData.AddPropertyAnimator( controls[0], map, path, Vector3::XAXIS );
984 // Grow a child from (0,0) size to full size (captured)
986 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "size";
987 map[ LayoutTransitionData::AnimatorKey::INITIAL_VALUE ] = Vector3( 0.0f, 0.0f, 0 );
988 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
989 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
990 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
991 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
992 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
993 layoutTransitionData.AddPropertyAnimator( controls[0], map );
996 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
997 container.Add( controls[0] );
999 bool signalReceived(false);
1000 LayoutTransitionFinishCheck finishCheck(signalReceived);
1001 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1003 application.SendNotification();
1004 application.Render( 0 );
1006 finishCheck.CheckSignalNotReceived();
1007 // The animation just started
1008 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1010 Vector3 position, tangent;
1011 Quaternion rotation;
1012 path.Sample( 0.0f, position, tangent );
1013 rotation = Quaternion( Vector3::XAXIS, tangent );
1014 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), position, 0.0001f, TEST_LOCATION );
1015 DALI_TEST_EQUALS( controls[0].GetCurrentOrientation(), rotation, 0.0001f, TEST_LOCATION );
1017 application.SendNotification();
1018 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1020 path.Sample( 1.0f, position, tangent );
1021 rotation = Quaternion( Vector3::XAXIS, tangent );
1022 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), position, 0.0001f, TEST_LOCATION );
1023 DALI_TEST_EQUALS( controls[0].GetCurrentOrientation(), rotation, 0.0001f, TEST_LOCATION );
1025 // The animation just finished
1026 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1027 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1029 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1030 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1032 application.SendNotification();
1033 application.Render( 10u /* wait a bit more for a signal */ );
1035 // Now sizes and positions are finally set
1036 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1037 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1039 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1040 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1042 finishCheck.CheckSignalReceived();
1047 int UtcDaliLayouting_AddChildLayoutTransition04_AnimateBy(void)
1049 ToolkitTestApplication application;
1050 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition04_AnimateBy");
1052 Stage stage = Stage::GetCurrent();
1053 auto container = Control::New();
1054 auto horizontalLayout = LinearLayout::New();
1055 horizontalLayout.SetAnimateLayout( true );
1056 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1058 DevelControl::SetLayout( container, horizontalLayout );
1059 container.SetName( "Container");
1061 std::vector< Control > controls;
1062 controls.push_back( CreateLeafControl( 100, 100 ) );
1063 stage.Add( container );
1065 auto layoutTransitionData = LayoutTransitionData::New();
1067 // Instant resize for parent
1069 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1070 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1071 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1072 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
1073 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1074 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1075 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1076 layoutTransitionData.AddPropertyAnimator( container, map );
1079 // Instant position for a child
1081 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1082 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1083 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
1084 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1085 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1086 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1087 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1091 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1092 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 0.0f, 350.0f, 0 );
1093 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1094 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_BY")
1095 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
1096 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1097 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
1098 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
1099 layoutTransitionData.AddPropertyAnimator( controls[0], map );
1102 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
1103 container.Add( controls[0] );
1105 bool signalReceived(false);
1106 LayoutTransitionFinishCheck finishCheck(signalReceived);
1107 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1109 application.SendNotification();
1110 application.Render( 1u /*just very beginning of the animation*/ );
1112 finishCheck.CheckSignalNotReceived();
1113 // The animation just started
1114 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1115 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1117 application.SendNotification();
1118 application.Render( static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1120 // The animation just finished
1121 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1122 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1124 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1125 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1127 application.SendNotification();
1128 application.Render( 10u /* wait a bit more for a signal */ );
1130 // Now sizes and positions are finally set
1131 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1132 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1134 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1135 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1137 finishCheck.CheckSignalReceived();
1142 int UtcDaliLayouting_AddChildLayoutTransition05(void)
1144 ToolkitTestApplication application;
1145 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition05");
1147 Stage stage = Stage::GetCurrent();
1148 auto container = Control::New();
1149 auto horizontalLayout = LinearLayout::New();
1150 horizontalLayout.SetAnimateLayout( true );
1151 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1153 DevelControl::SetLayout( container, horizontalLayout );
1154 container.SetName( "Container");
1156 std::vector< Control > controls;
1157 controls.push_back( CreateLeafControl( 100, 100 ) );
1158 stage.Add( container );
1160 auto layoutTransitionData = LayoutTransitionData::New();
1162 // Instant resize for parent
1164 map[ "property" ] = Actor::Property::SIZE;
1165 map[ "targetValue" ] = Property::Value(); // capture from layout update
1166 map[ "animator" ] = Property::Map()
1167 .Add( "name", "InstantAnimator" )
1168 .Add( "type", "ANIMATE_TO")
1169 .Add( "alphaFunction", "LINEAR" )
1170 .Add( "timePeriod", Property::Map()
1171 .Add( "delay", 0.0f )
1172 .Add( "duration", 0.0f ) );
1173 layoutTransitionData.AddPropertyAnimator( container, map );
1176 // Instant position for a child
1178 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::COLOR_ALPHA;
1179 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = "InstantAnimator";
1180 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1183 // Grow a child from (0,0) size to full size (captured)
1185 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1186 map[ LayoutTransitionData::AnimatorKey::INITIAL_VALUE ] = Vector3( 0.0f, 0.0f, 0 );
1187 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = std::string();
1188 layoutTransitionData.AddPropertyAnimator( controls[0], map );
1191 // Instant opacity for a child, for testing
1193 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1194 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = "InstantAnimator";
1195 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1198 // Just throw all other alpha functions in
1199 { // no property, not going to be used, but going to be parsed
1201 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1202 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "WRONG" );
1203 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1205 { // no property, not going to be used, but going to be parsed
1207 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1208 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" );
1209 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1211 { // no property, not going to be used, but going to be parsed
1213 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1214 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "REVERSE" );
1215 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1217 { // no property, not going to be used, but going to be parsed
1219 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1220 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_SQUARE" );
1221 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1223 { // no property, not going to be used, but going to be parsed
1225 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1226 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT_SQUARE" );
1227 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1229 { // no property, not going to be used, but going to be parsed
1231 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1232 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN" );
1233 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1235 { // no property, not going to be used, but going to be parsed
1237 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1238 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN" );
1239 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1241 { // no property, not going to be used, but going to be parsed
1243 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1244 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT" );
1245 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1247 { // no property, not going to be used, but going to be parsed
1249 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1250 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_OUT" );
1251 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1253 { // no property, not going to be used, but going to be parsed
1255 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1256 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_OUT_SINE" );
1257 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1259 { // no property, not going to be used, but going to be parsed
1261 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1262 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_SINE" );
1263 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1265 { // no property, not going to be used, but going to be parsed
1267 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1268 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT_SINE" );
1269 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1271 { // no property, not going to be used, but going to be parsed
1273 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1274 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "BOUNCE" );
1275 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1277 { // no property, not going to be used, but going to be parsed
1279 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1280 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "SIN" );
1281 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1283 { // no property, not going to be used, but going to be parsed
1285 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1286 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT_BACK" );
1287 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1289 { // no property, not going to be used, but going to be parsed
1291 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1292 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, Vector4( 0.0f, 1.0f, 2.0f, 3.0f ) );
1293 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1295 { // no property, not going to be used, but going to be parsed
1298 Property::Array array;
1300 array.PushBack( 0.0f );
1301 array.PushBack( 1.0f );
1302 array.PushBack( 2.0f );
1303 array.PushBack( 3.0f );
1304 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1305 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, array );
1306 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1308 { // no property, not going to be used, but going to be parsed
1311 Property::Array array;
1313 array.PushBack( 0.0f );
1314 array.PushBack( 1.0f );
1315 array.PushBack( 2.0f );
1316 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1317 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, array );
1318 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1320 { // no property, not going to be used, but going to be parsed
1323 Property::Array array;
1325 array.PushBack( 0.0f );
1326 array.PushBack( 10 );
1327 array.PushBack( 2.0f );
1328 array.PushBack( 3.0f );
1329 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1330 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, array );
1331 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1333 { // no property, not going to be used, but going to be parsed
1335 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = 0; // invalid
1336 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1339 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
1340 container.Add( controls[0] );
1342 bool signalReceived(false);
1343 LayoutTransitionFinishCheck finishCheck(signalReceived);
1344 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1346 application.SendNotification();
1347 application.Render( 1u /*just very beginning of the animation*/ );
1349 finishCheck.CheckSignalNotReceived();
1350 // The animation just started
1351 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1352 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1354 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 1.0f, TEST_LOCATION );
1355 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION );
1357 application.SendNotification();
1358 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1360 // The animation just finished
1361 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1362 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1364 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1365 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1367 application.SendNotification();
1368 application.Render( 10u /* wait a bit more for a signal */ );
1370 // Now sizes and positions are finally set
1371 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1372 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1374 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1375 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1377 finishCheck.CheckSignalReceived();
1382 int UtcDaliLayouting_DefaultTransition01(void)
1384 ToolkitTestApplication application;
1385 tet_infoline(" UtcDaliLayouting_DefaultTransition01");
1387 Stage stage = Stage::GetCurrent();
1388 auto container = Control::New();
1389 auto horizontalLayout = LinearLayout::New();
1390 horizontalLayout.SetAnimateLayout( false );
1391 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1393 DevelControl::SetLayout( container, horizontalLayout );
1394 container.SetName( "Container" );
1396 std::vector< Control > controls;
1397 controls.push_back( CreateLeafControl( 100, 100 ) );
1398 controls.push_back( CreateLeafControl( 100, 100 ) );
1400 stage.Add( container );
1401 container.Add( controls[0] );
1402 container.Add( controls[1] );
1404 // Initial rendering done
1405 application.SendNotification();
1406 application.Render();
1408 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1409 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1410 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1412 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1413 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1414 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1416 horizontalLayout.SetAnimateLayout( true );
1418 auto layoutTransitionData0 = LayoutTransitionData::New();
1420 // Default instant resize
1422 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1423 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1424 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1425 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1426 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1427 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1428 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1429 layoutTransitionData0.AddPropertyAnimator( controls[0], map );
1432 // Instant instant position
1434 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1435 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1436 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1437 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1438 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1439 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1440 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1441 layoutTransitionData0.AddPropertyAnimator( controls[0], map );
1443 DevelControl::GetLayout( controls[0] ).SetTransitionData(LayoutTransitionData::Type::ON_LAYOUT_CHANGE, layoutTransitionData0 );
1445 auto layoutTransitionData1 = LayoutTransitionData::New();
1447 // Default instant resize
1449 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1450 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1451 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1452 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1453 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1454 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1455 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1456 layoutTransitionData1.AddPropertyAnimator( controls[1], map );
1459 // Instant instant position
1461 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1462 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1463 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1464 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1465 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1466 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1467 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1468 layoutTransitionData0.AddPropertyAnimator( controls[1], map );
1470 DevelControl::GetLayout( controls[1] ).SetTransitionData(LayoutTransitionData::Type::ON_LAYOUT_CHANGE, layoutTransitionData1 );
1472 horizontalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1474 application.SendNotification();
1475 application.Render( 10u /*just very beginning of the animation*/ );
1477 // Animation just finished
1478 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1479 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1480 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1482 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1483 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
1484 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
1486 // Now sizes and positions are set
1487 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1488 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1489 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1491 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1492 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1493 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );