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[ "affectsSiblings" ] = false;
747 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
748 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST;
749 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 80.0f, 80.0f, 0 );
750 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
751 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
752 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
753 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
754 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
755 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child
758 // Grow the gained focus child
760 map[ "affectsSiblings" ] = false;
761 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
762 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_GAINED;
763 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 120.0f, 120.0f, 0 );
764 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
765 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
766 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
767 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
768 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
769 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus gained child
772 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, layoutTransitionData );
774 bool signalReceived(false);
775 LayoutTransitionFinishCheck finishCheck(signalReceived);
776 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
777 manager.SetFocus( controls[1] );
779 application.SendNotification();
780 application.Render( 1u /*just very beginning of the animation*/ );
782 finishCheck.CheckSignalNotReceived();
783 // Animation just started
784 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
785 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
786 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
788 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
789 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
790 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
792 application.SendNotification();
793 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
795 // Animation just finished
796 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
797 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
798 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
800 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
801 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 80.0f, 80.0f, 0.0f ), 1.0f, TEST_LOCATION );
802 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 120.0f, 120.0f, 0.0f ), 1.0f, TEST_LOCATION );
804 application.SendNotification();
805 application.Render( 10u /* wait a bit more for a signal */ );
807 // Now sizes and positions are finally set
808 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
809 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
810 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
812 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
813 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
814 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
816 finishCheck.CheckSignalReceived();
821 int UtcDaliLayouting_FocusChildLayoutTransition02(void)
823 ToolkitTestApplication application;
824 tet_infoline(" UtcDaliLayouting_FocusChildLayoutTransition02" );
826 Stage stage = Stage::GetCurrent();
827 auto container = Control::New();
828 auto horizontalLayout = LinearLayout::New();
829 horizontalLayout.SetAnimateLayout( false );
830 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
832 DevelControl::SetLayout( container, horizontalLayout );
833 container.SetName( "Container" );
835 std::vector< Control > controls;
836 controls.push_back( CreateLeafControl( 100, 100 ) );
837 controls.push_back( CreateLeafControl( 100, 100 ) );
839 stage.Add( container );
840 container.Add( controls[0] );
841 container.Add( controls[1] );
843 KeyInputFocusManager manager = KeyInputFocusManager::Get();
844 manager.SetFocus( controls[0] );
846 // Initial rendering done
847 application.SendNotification();
848 application.Render();
850 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
851 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
852 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
854 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
855 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
856 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
858 horizontalLayout.SetAnimateLayout( true );
860 auto layoutTransitionData = LayoutTransitionData::New();
862 // Shrink the lost focus child width
864 map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = false;
865 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
866 map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO;
867 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
868 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
869 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
870 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
871 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
872 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // move all children
875 // Shrink the lost focus child width
877 map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true;
878 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_WIDTH;
879 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST;
880 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 80.0f;
881 map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO;
882 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
883 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
884 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
885 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
886 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
887 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child
890 // Shrink the lost focus child height
892 map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true;
893 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_HEIGHT;
894 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST;
895 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 80.0f;
896 map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO;
897 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
898 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
899 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
900 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
901 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
902 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child
905 // Grow the gained focus child
907 map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true;
908 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
909 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_GAINED;
910 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 120.0f, 120.0f, 0 );
911 map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO;
912 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
913 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
914 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
915 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
916 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
917 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus gained child
920 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, layoutTransitionData );
922 bool signalReceived(false);
923 LayoutTransitionFinishCheck finishCheck(signalReceived);
924 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
925 manager.SetFocus( controls[1] );
927 application.SendNotification();
928 application.Render( 1u /*just very beginning of the animation*/ );
930 finishCheck.CheckSignalNotReceived();
931 // Animation just started
932 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
933 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION );
934 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION );
936 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
937 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
938 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
940 application.SendNotification();
941 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
943 // Animation just finished
944 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
945 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 360.0f, 0.0f ), 0.0001f, TEST_LOCATION );
946 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 80.0f, 340.0f, 0.0f ), 0.0001f, TEST_LOCATION );
948 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
949 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 80.0f, 80.0f, 0.0f ), 1.0f, TEST_LOCATION );
950 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 120.0f, 120.0f, 0.0f ), 1.0f, TEST_LOCATION );
952 application.SendNotification();
953 application.Render( 10u /* wait a bit more for a signal */ );
955 // Now sizes and positions are finally set
956 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
957 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 360.0f, 0.0f ), 0.0001f, TEST_LOCATION );
958 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 80.0f, 340.0f, 0.0f ), 0.0001f, TEST_LOCATION );
960 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
961 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
962 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
964 finishCheck.CheckSignalReceived();
969 int UtcDaliLayouting_FocusChildLayoutTransition03(void)
971 ToolkitTestApplication application;
972 tet_infoline(" UtcDaliLayouting_FocusChildLayoutTransition03" );
974 Stage stage = Stage::GetCurrent();
975 auto container = Control::New();
976 auto horizontalLayout = LinearLayout::New();
977 horizontalLayout.SetAnimateLayout( false );
978 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
980 DevelControl::SetLayout( container, horizontalLayout );
981 container.SetName( "Container" );
983 std::vector< Control > controls;
984 controls.push_back( CreateLeafControl( 100, 100 ) );
985 controls.push_back( CreateLeafControl( 100, 100 ) );
987 stage.Add( container );
988 container.Add( controls[0] );
989 container.Add( controls[1] );
991 KeyInputFocusManager manager = KeyInputFocusManager::Get();
992 manager.SetFocus( controls[0] );
994 // Initial rendering done
995 application.SendNotification();
996 application.Render();
998 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
999 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1000 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1002 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1003 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1004 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1006 horizontalLayout.SetAnimateLayout( true );
1008 auto layoutTransitionData = LayoutTransitionData::New();
1010 // Shrink the lost focus child width
1012 map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = false;
1013 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1014 map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO;
1015 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1016 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1017 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1018 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
1019 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
1020 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // move all children
1023 // Shrink the lost focus child width
1025 map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true;
1026 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SCALE_X;
1027 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST;
1028 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 0.8f;
1029 map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO;
1030 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1031 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1032 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1033 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
1034 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
1035 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child
1038 // Shrink the lost focus child height
1040 map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true;
1041 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SCALE_Y;
1042 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST;
1043 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 0.8f;
1044 map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO;
1045 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1046 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1047 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1048 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
1049 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
1050 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child
1053 // Grow the gained focus child
1055 map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true;
1056 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SCALE;
1057 map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_GAINED;
1058 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 1.2f, 1.2f, 1.0f );
1059 map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO;
1060 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1061 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1062 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1063 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
1064 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
1065 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus gained child
1068 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, layoutTransitionData );
1070 bool signalReceived(false);
1071 LayoutTransitionFinishCheck finishCheck(signalReceived);
1072 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1073 manager.SetFocus( controls[1] );
1075 application.SendNotification();
1076 application.Render( 1u /*just very beginning of the animation*/ );
1078 finishCheck.CheckSignalNotReceived();
1079 // Animation just started
1080 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1081 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION );
1082 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION );
1084 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1085 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
1086 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
1088 application.SendNotification();
1089 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1091 // Animation just finished
1092 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1093 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( -10.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1094 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 90.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1096 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1097 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1098 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1099 DALI_TEST_EQUALS( controls[0].GetCurrentSize() * controls[0].GetCurrentScale(), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1100 DALI_TEST_EQUALS( controls[1].GetCurrentSize() * controls[1].GetCurrentScale(), Vector3( 120.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1102 application.SendNotification();
1103 application.Render( 10u /* wait a bit more for a signal */ );
1105 // Now sizes and positions are finally set
1106 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1107 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( -10.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1108 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 90.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1110 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1111 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1112 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1113 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) * controls[0].GetProperty<Vector3>( Actor::Property::SCALE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1114 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) * controls[1].GetProperty<Vector3>( Actor::Property::SCALE ), Vector3( 120.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1116 finishCheck.CheckSignalReceived();
1121 int UtcDaliLayouting_AddChildLayoutTransition02_KeyFrames(void)
1123 ToolkitTestApplication application;
1124 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition02_KeyFrames" );
1126 Stage stage = Stage::GetCurrent();
1127 auto container = Control::New();
1128 auto horizontalLayout = LinearLayout::New();
1129 horizontalLayout.SetAnimateLayout( true );
1130 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1132 DevelControl::SetLayout( container, horizontalLayout );
1133 container.SetName( "Container");
1135 std::vector< Control > controls;
1136 controls.push_back( CreateLeafControl( 100, 100 ) );
1137 stage.Add( container );
1139 auto layoutTransitionData = LayoutTransitionData::New();
1141 // Instant resize for parent
1143 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1144 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1145 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1146 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
1147 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1148 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1149 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1150 layoutTransitionData.AddPropertyAnimator( container, map );
1153 // Instant position for a child
1155 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1156 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1157 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
1158 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1159 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1160 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1161 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1164 // Grow a child from (0,0) size to full size with key frames
1165 KeyFrames keyFrames = KeyFrames::New();
1166 keyFrames.Add( 0.0f, Vector3( 0.0f, 0.0f, 0 ) );
1167 keyFrames.Add( 0.5f, Vector3( 100.0f, 100.0f, 0 ) );
1170 map[ "property" ] = Actor::Property::SIZE;
1171 map[ "condition" ] = LayoutTransitionData::Condition::ON_ADD;
1172 map[ "animator" ] = Property::Map()
1173 .Add( "type", "ANIMATE_BETWEEN")
1174 .Add( "alphaFunction", "LINEAR")
1175 .Add( "timePeriod", Property::Map()
1176 .Add( "delay", 0.0f)
1177 .Add( "duration", 0.5f));
1178 layoutTransitionData.AddPropertyAnimator( Actor(), map, keyFrames, Animation::Interpolation::Linear );
1181 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
1182 container.Add( controls[0] );
1184 bool signalReceived(false);
1185 LayoutTransitionFinishCheck finishCheck(signalReceived);
1186 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1188 application.SendNotification();
1189 application.Render( 1u /*just very beginning of the animation*/ );
1191 finishCheck.CheckSignalNotReceived();
1192 // The animation just started
1193 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1194 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1196 application.SendNotification();
1197 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1199 // The animation just finished
1200 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1201 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1203 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1204 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1206 application.SendNotification();
1207 application.Render( 10u /* wait a bit more for a signal */ );
1209 // Now sizes and positions are finally set
1210 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1211 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1213 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1214 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1216 finishCheck.CheckSignalReceived();
1221 int UtcDaliLayouting_AddChildLayoutTransition03_Path(void)
1223 ToolkitTestApplication application;
1224 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition03_Path" );
1226 Stage stage = Stage::GetCurrent();
1227 auto container = Control::New();
1228 auto horizontalLayout = LinearLayout::New();
1229 horizontalLayout.SetAnimateLayout( true );
1230 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1232 DevelControl::SetLayout( container, horizontalLayout );
1233 container.SetName( "Container");
1235 std::vector< Control > controls;
1236 controls.push_back( CreateLeafControl( 100, 100 ) );
1237 stage.Add( container );
1239 auto layoutTransitionData = LayoutTransitionData::New();
1241 // Instant resize for parent
1243 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1244 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1245 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1246 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
1247 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1248 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1249 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1250 layoutTransitionData.AddPropertyAnimator( container, map );
1253 Dali::Path path = Dali::Path::New();
1255 // Curve position for a child
1257 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1258 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1259 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_PATH")
1260 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
1261 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1262 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1263 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f ) );
1266 Vector3 position0( 30.0, 80.0, 0.0 );
1267 Vector3 position1( 70.0, 120.0, 0.0 );
1268 Vector3 position2( 0.0, 350.0, 0.0 );
1270 //Dali::Path path = Dali::Path::New();
1271 path.AddPoint( position0 );
1272 path.AddPoint( position1 );
1273 path.AddPoint( position2 );
1275 // Control points for first segment
1276 path.AddControlPoint( Vector3( 39.0, 90.0, 0.0 ) );
1277 path.AddControlPoint( Vector3( 56.0, 119.0, 0.0 ) );
1279 // Control points for second segment
1280 path.AddControlPoint( Vector3( 78.0, 120.0, 0.0 ) );
1281 path.AddControlPoint( Vector3( 93.0, 104.0, 0.0 ) );
1283 layoutTransitionData.AddPropertyAnimator( controls[0], map, path, Vector3::XAXIS );
1286 // Grow a child from (0,0) size to full size (captured)
1288 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "size";
1289 map[ LayoutTransitionData::AnimatorKey::INITIAL_VALUE ] = Vector3( 0.0f, 0.0f, 0 );
1290 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1291 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
1292 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1293 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
1294 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
1295 layoutTransitionData.AddPropertyAnimator( controls[0], map );
1298 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
1299 container.Add( controls[0] );
1301 bool signalReceived(false);
1302 LayoutTransitionFinishCheck finishCheck(signalReceived);
1303 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1305 application.SendNotification();
1306 application.Render( 0 );
1308 finishCheck.CheckSignalNotReceived();
1309 // The animation just started
1310 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1312 Vector3 position, tangent;
1313 Quaternion rotation;
1314 path.Sample( 0.0f, position, tangent );
1315 rotation = Quaternion( Vector3::XAXIS, tangent );
1316 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), position, 0.0001f, TEST_LOCATION );
1317 DALI_TEST_EQUALS( controls[0].GetCurrentOrientation(), rotation, 0.0001f, TEST_LOCATION );
1319 application.SendNotification();
1320 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1322 path.Sample( 1.0f, position, tangent );
1323 rotation = Quaternion( Vector3::XAXIS, tangent );
1324 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), position, 0.0001f, TEST_LOCATION );
1325 DALI_TEST_EQUALS( controls[0].GetCurrentOrientation(), rotation, 0.0001f, TEST_LOCATION );
1327 // The animation just finished
1328 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1329 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1331 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1332 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1334 application.SendNotification();
1335 application.Render( 10u /* wait a bit more for a signal */ );
1337 // Now sizes and positions are finally set
1338 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1339 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1341 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1342 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1344 finishCheck.CheckSignalReceived();
1349 int UtcDaliLayouting_AddChildLayoutTransition04_AnimateBy(void)
1351 ToolkitTestApplication application;
1352 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition04_AnimateBy" );
1354 Stage stage = Stage::GetCurrent();
1355 auto container = Control::New();
1356 auto horizontalLayout = LinearLayout::New();
1357 horizontalLayout.SetAnimateLayout( true );
1358 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1360 DevelControl::SetLayout( container, horizontalLayout );
1361 container.SetName( "Container");
1363 std::vector< Control > controls;
1364 controls.push_back( CreateLeafControl( 100, 100 ) );
1365 stage.Add( container );
1367 auto layoutTransitionData = LayoutTransitionData::New();
1369 // Instant resize for parent
1371 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1372 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1373 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1374 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" )
1375 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1376 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1377 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1378 layoutTransitionData.AddPropertyAnimator( container, map );
1381 // Instant position for a child
1383 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1384 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1385 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
1386 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1387 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1388 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1389 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1393 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1394 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 10.0f, 10.0f, 0 );
1395 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1396 .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_BY")
1397 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR")
1398 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1399 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f)
1400 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f));
1401 layoutTransitionData.AddPropertyAnimator( controls[0], map );
1404 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
1405 container.Add( controls[0] );
1407 bool signalReceived(false);
1408 LayoutTransitionFinishCheck finishCheck(signalReceived);
1409 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1411 application.SendNotification();
1412 application.Render( 1u /*just very beginning of the animation*/ );
1414 finishCheck.CheckSignalNotReceived();
1415 // The animation just started
1416 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1417 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1419 application.SendNotification();
1420 application.Render( static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1422 // The animation just finished
1423 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1424 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1426 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1427 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 110.0f, 110.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1429 application.SendNotification();
1430 application.Render( 10u /* wait a bit more for a signal */ );
1432 // Now sizes and positions are finally set
1433 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1434 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1436 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1437 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 110.0f, 110.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1439 finishCheck.CheckSignalReceived();
1444 int UtcDaliLayouting_AddChildLayoutTransition05(void)
1446 ToolkitTestApplication application;
1447 tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition05" );
1449 Stage stage = Stage::GetCurrent();
1450 auto container = Control::New();
1451 auto horizontalLayout = LinearLayout::New();
1452 horizontalLayout.SetAnimateLayout( true );
1453 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1455 DevelControl::SetLayout( container, horizontalLayout );
1456 container.SetName( "Container");
1458 std::vector< Control > controls;
1459 controls.push_back( CreateLeafControl( 100, 100 ) );
1460 stage.Add( container );
1462 auto layoutTransitionData = LayoutTransitionData::New();
1464 // Instant resize for parent
1466 map[ "property" ] = Actor::Property::SIZE;
1467 map[ "targetValue" ] = Property::Value(); // capture from layout update
1468 map[ "animator" ] = Property::Map()
1469 .Add( "name", "InstantAnimator" )
1470 .Add( "type", "ANIMATE_TO")
1471 .Add( "alphaFunction", "LINEAR" )
1472 .Add( "timePeriod", Property::Map()
1473 .Add( "delay", 0.0f )
1474 .Add( "duration", 0.0f ) );
1475 layoutTransitionData.AddPropertyAnimator( container, map );
1478 // Instant position for a child
1480 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::COLOR_ALPHA;
1481 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = "InstantAnimator";
1482 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1485 // Grow a child from (0,0) size to full size (captured)
1487 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1488 map[ LayoutTransitionData::AnimatorKey::INITIAL_VALUE ] = Vector3( 0.0f, 0.0f, 0 );
1489 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = std::string();
1490 layoutTransitionData.AddPropertyAnimator( controls[0], map );
1493 // Instant opacity for a child, for testing
1495 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1496 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = "InstantAnimator";
1497 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1500 // Just throw all other alpha functions in
1501 { // no property, not going to be used, but going to be parsed
1503 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1504 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "WRONG" );
1505 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1507 { // no property, not going to be used, but going to be parsed
1509 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1510 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" );
1511 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1513 { // no property, not going to be used, but going to be parsed
1515 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1516 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "REVERSE" );
1517 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1519 { // no property, not going to be used, but going to be parsed
1521 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1522 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_SQUARE" );
1523 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1525 { // no property, not going to be used, but going to be parsed
1527 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1528 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT_SQUARE" );
1529 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1531 { // no property, not going to be used, but going to be parsed
1533 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1534 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN" );
1535 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1537 { // no property, not going to be used, but going to be parsed
1539 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1540 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN" );
1541 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1543 { // no property, not going to be used, but going to be parsed
1545 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1546 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT" );
1547 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1549 { // no property, not going to be used, but going to be parsed
1551 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1552 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_OUT" );
1553 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1555 { // no property, not going to be used, but going to be parsed
1557 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1558 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_OUT_SINE" );
1559 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1561 { // no property, not going to be used, but going to be parsed
1563 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1564 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_SINE" );
1565 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1567 { // no property, not going to be used, but going to be parsed
1569 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1570 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT_SINE" );
1571 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1573 { // no property, not going to be used, but going to be parsed
1575 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1576 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "BOUNCE" );
1577 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1579 { // no property, not going to be used, but going to be parsed
1581 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1582 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "SIN" );
1583 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1585 { // no property, not going to be used, but going to be parsed
1587 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1588 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT_BACK" );
1589 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1591 { // no property, not going to be used, but going to be parsed
1593 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1594 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, Vector4( 0.0f, 1.0f, 2.0f, 3.0f ) );
1595 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1597 { // no property, not going to be used, but going to be parsed
1600 Property::Array array;
1602 array.PushBack( 0.0f );
1603 array.PushBack( 1.0f );
1604 array.PushBack( 2.0f );
1605 array.PushBack( 3.0f );
1606 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1607 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, array );
1608 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1610 { // no property, not going to be used, but going to be parsed
1613 Property::Array array;
1615 array.PushBack( 0.0f );
1616 array.PushBack( 1.0f );
1617 array.PushBack( 2.0f );
1618 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1619 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, array );
1620 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1622 { // no property, not going to be used, but going to be parsed
1625 Property::Array array;
1627 array.PushBack( 0.0f );
1628 array.PushBack( 10 );
1629 array.PushBack( 2.0f );
1630 array.PushBack( 3.0f );
1631 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1632 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, array );
1633 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1635 { // no property, not going to be used, but going to be parsed
1637 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = 0; // invalid
1638 layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1641 horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
1642 container.Add( controls[0] );
1644 bool signalReceived(false);
1645 LayoutTransitionFinishCheck finishCheck(signalReceived);
1646 layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1648 application.SendNotification();
1649 application.Render( 1u /*just very beginning of the animation*/ );
1651 finishCheck.CheckSignalNotReceived();
1652 // The animation just started
1653 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1654 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1656 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 1.0f, TEST_LOCATION );
1657 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION );
1659 application.SendNotification();
1660 application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1662 // The animation just finished
1663 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1664 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1666 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1667 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1669 application.SendNotification();
1670 application.Render( 10u /* wait a bit more for a signal */ );
1672 // Now sizes and positions are finally set
1673 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1674 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1676 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1677 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1679 finishCheck.CheckSignalReceived();
1684 int UtcDaliLayouting_DefaultTransition01(void)
1686 ToolkitTestApplication application;
1687 tet_infoline(" UtcDaliLayouting_DefaultTransition01" );
1689 Stage stage = Stage::GetCurrent();
1690 auto container = Control::New();
1691 auto horizontalLayout = LinearLayout::New();
1692 horizontalLayout.SetAnimateLayout( false );
1693 horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
1695 DevelControl::SetLayout( container, horizontalLayout );
1696 container.SetName( "Container" );
1698 std::vector< Control > controls;
1699 controls.push_back( CreateLeafControl( 100, 100 ) );
1700 controls.push_back( CreateLeafControl( 100, 100 ) );
1702 stage.Add( container );
1703 container.Add( controls[0] );
1704 container.Add( controls[1] );
1706 // Initial rendering done
1707 application.SendNotification();
1708 application.Render();
1710 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1711 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1712 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1714 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1715 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1716 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1718 horizontalLayout.SetAnimateLayout( true );
1720 auto layoutTransitionData0 = LayoutTransitionData::New();
1722 // Default instant resize
1724 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1725 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1726 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1727 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1728 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1729 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1730 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1731 layoutTransitionData0.AddPropertyAnimator( controls[0], map );
1734 // Instant instant position
1736 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1737 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1738 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1739 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1740 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1741 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1742 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1743 layoutTransitionData0.AddPropertyAnimator( controls[0], map );
1745 DevelControl::GetLayout( controls[0] ).SetTransitionData( LayoutTransitionData::Type::ON_LAYOUT_CHANGE, layoutTransitionData0 );
1747 auto layoutTransitionData1 = LayoutTransitionData::New();
1749 // Default instant resize
1751 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE;
1752 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1753 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1754 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1755 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1756 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1757 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1758 layoutTransitionData1.AddPropertyAnimator( controls[1], map );
1761 // Instant instant position
1763 map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION;
1764 map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update
1765 map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map()
1766 .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR )
1767 .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map()
1768 .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f )
1769 .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) );
1770 layoutTransitionData1.AddPropertyAnimator( controls[1], map );
1772 DevelControl::GetLayout( controls[1] ).SetTransitionData( LayoutTransitionData::Type::ON_LAYOUT_CHANGE, layoutTransitionData1 );
1774 horizontalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1776 application.SendNotification();
1777 application.Render( 10u /*just very beginning of the animation*/ );
1779 // Animation just finished
1780 DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1781 DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1782 DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1784 DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1785 DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
1786 DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION );
1788 // Now sizes and positions are set
1789 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1790 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1791 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1793 DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1794 DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
1795 DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );