Merge "Relayout again for LTR / RTL order when layout direction is changed." into...
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-LayoutingAnimation.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <toolkit-event-thread-callback.h>
22
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>
31
32 #include <../custom-layout.h>
33
34 #include <layout-utils.h>
35
36 using namespace Dali;
37 using namespace Toolkit;
38
39 void utc_dali_toolkit_layouting_animation_startup(void)
40 {
41   test_return_value = TET_UNDEF;
42 }
43
44 void utc_dali_toolkit_layouting_animation_cleanup(void)
45 {
46   test_return_value = TET_PASS;
47 }
48
49 namespace
50 {
51
52 // Functor to test whether a Finish signal is emitted
53 struct LayoutTransitionFinishCheck
54 {
55   LayoutTransitionFinishCheck( bool& signalReceived )
56   : mSignalReceived( signalReceived )
57   {
58   }
59
60   void operator()( LayoutTransitionData::Type type, LayoutTransitionData& layoutTransitionData )
61   {
62     mSignalReceived = true;
63   }
64
65   void Reset()
66   {
67     mSignalReceived = false;
68   }
69
70   void CheckSignalReceived()
71   {
72     if (!mSignalReceived)
73     {
74       tet_printf("Expected Finish signal was not received\n");
75       tet_result(TET_FAIL);
76     }
77     else
78     {
79       tet_result(TET_PASS);
80     }
81   }
82
83   void CheckSignalNotReceived()
84   {
85     if (mSignalReceived)
86     {
87       tet_printf("Unexpected Finish signal was received\n");
88       tet_result(TET_FAIL);
89     }
90     else
91     {
92       tet_result(TET_PASS);
93     }
94   }
95
96   bool& mSignalReceived; // owned by individual tests
97 };
98
99 } // anon namespace
100
101 int UtcDaliLayouting_LayoutTransitionDataConstructorP(void)
102 {
103   TestApplication application;
104
105   LayoutTransitionData layoutTransitionData;
106
107   DALI_TEST_CHECK( !layoutTransitionData );
108   END_TEST;
109 }
110
111 int UtcDaliLayouting_LayoutTransitionDataNewP(void)
112 {
113   TestApplication application;
114
115   LayoutTransitionData layoutTransitionData = LayoutTransitionData::New();
116
117   DALI_TEST_CHECK(layoutTransitionData);
118   END_TEST;
119 }
120
121 int UtcDaliLayouting_LayoutTransitionDataDownCastP(void)
122 {
123   TestApplication application;
124
125   LayoutTransitionData layoutTransitionData = LayoutTransitionData::New();
126   BaseHandle object(layoutTransitionData);
127
128   LayoutTransitionData layoutTransitionData2 = LayoutTransitionData::DownCast(object);
129   DALI_TEST_CHECK(layoutTransitionData2);
130
131   LayoutTransitionData layoutTransitionData3 = DownCast< LayoutTransitionData >(object);
132   DALI_TEST_CHECK(layoutTransitionData2);
133   END_TEST;
134 }
135
136 int UtcDaliLayouting_LayoutTransitionDataDownCastN(void)
137 {
138   TestApplication application;
139
140   BaseHandle unInitializedObject;
141
142   LayoutTransitionData layoutTransitionData1 = LayoutTransitionData::DownCast( unInitializedObject );
143   DALI_TEST_CHECK( !layoutTransitionData1 );
144
145   LayoutTransitionData layoutTransitionData2 = DownCast< LayoutTransitionData >( unInitializedObject );
146   DALI_TEST_CHECK( !layoutTransitionData2 );
147   END_TEST;
148 }
149
150 int UtcDaliLayouting_LayoutTransitionDataSetGetTransition(void)
151 {
152   TestApplication application;
153
154   auto layout = LinearLayout::New();
155   auto layoutTransitionData = LayoutTransitionData::New();
156
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() );
163
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() );
171
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() );
179
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() );
187
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 );
195
196   END_TEST;
197 }
198
199 int UtcDaliLayouting_SetLayoutTransition01(void)
200 {
201   ToolkitTestApplication application;
202   tet_infoline(" UtcDaliLayouting_SetLayoutTransition01");
203
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 );
209
210   auto verticalLayout = LinearLayout::New();
211   verticalLayout.SetAnimateLayout( false );
212   verticalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
213
214   DevelControl::SetLayout( container, horizontalLayout );
215   container.SetName( "Container");
216
217   std::vector< Control > controls;
218   controls.push_back( CreateLeafControl( 100, 100 ) );
219   controls.push_back( CreateLeafControl( 100, 100 ) );
220   for( auto&& iter : controls )
221   {
222     container.Add( iter );
223   }
224   stage.Add( container );
225
226   auto layoutTransitionData = LayoutTransitionData::New();
227   {
228     // Instant resize for parent
229     Property::Map map;
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()
235         .Add("delay", 0.0f)
236         .Add("duration", 0.0f));
237     layoutTransitionData.AddPropertyAnimator( container, map );
238   }
239   {
240     Property::Map 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()
247         .Add("delay", 0.0f)
248         .Add("duration", 0.5f));
249     layoutTransitionData.AddPropertyAnimator( container, map );
250   }
251   {
252     // Instant position for children
253     Property::Map map;
254     map["property"] = "position";
255     map["animator"] = Property::Map()
256        .Add("alphaFunction", "LINEAR")
257        .Add("timePeriod", Property::Map()
258          .Add("delay", 0.0f)
259          .Add("duration", 0.0f));
260     layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
261   }
262   {
263     // Grow children from (0,0) size to full size (captured)
264     Property::Map map;
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()
270         .Add("delay", 0.0f)
271         .Add("duration", 0.5f));
272     layoutTransitionData.AddPropertyAnimator( Actor(), map );
273   }
274
275   // Ensure layouting happens
276   application.SendNotification();
277   application.Render();
278
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 );
283
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 );
287
288   bool signalReceived(false);
289   LayoutTransitionFinishCheck finishCheck(signalReceived);
290   layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
291
292   horizontalLayout.SetAnimateLayout( true );
293   verticalLayout.SetAnimateLayout( true );
294
295   // Change a layout, start transition
296   verticalLayout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, layoutTransitionData );
297   DevelControl::SetLayout( container, verticalLayout );
298
299   application.SendNotification();
300   application.Render( 1u /*just very beginning of the animation*/ );
301
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 );
308
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 );
312
313   application.SendNotification();
314   application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
315
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 );
321
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 );
325
326   application.SendNotification();
327   application.Render( 10u /* wait a bit more for a signal */ );
328
329   finishCheck.CheckSignalReceived();
330
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 );
335
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 );
339
340   // Transition back now with default transition
341   DevelControl::SetLayout( container, horizontalLayout );
342
343   application.SendNotification();
344   application.Render( 1u /*just very beginning of the animation*/ );
345
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 );
350
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 );
354
355   application.SendNotification();
356   application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
357
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 );
362
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 );
366
367   application.SendNotification();
368   application.Render( 10u /* wait a bit more for complete default animation */ );
369
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 );
374
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 );
378
379   END_TEST;
380 }
381
382 int UtcDaliLayouting_AddChildLayoutTransition01(void)
383 {
384   ToolkitTestApplication application;
385   tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition01");
386
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 );
392
393   DevelControl::SetLayout( container, horizontalLayout );
394   container.SetName( "Container");
395
396   std::vector< Control > controls;
397   controls.push_back( CreateLeafControl( 100, 100 ) );
398   stage.Add( container );
399
400   auto layoutTransitionData = LayoutTransitionData::New();
401   {
402     // Instant resize for parent
403     Property::Map map;
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 );
412   }
413   {
414     // Instant position for a child
415     Property::Map map;
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
424   }
425   {
426     // Grow a child from (0,0) size to full size (captured)
427     Property::Map map;
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
437   }
438
439   horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
440   container.Add( controls[0] );
441
442   bool signalReceived(false);
443   LayoutTransitionFinishCheck finishCheck(signalReceived);
444   layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
445
446   application.SendNotification();
447   application.Render( 1u /*just very beginning of the animation*/ );
448
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 );
453
454   application.SendNotification();
455   application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
456
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 );
460
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 );
463
464   application.SendNotification();
465   application.Render( 10u /* wait a bit more for a signal */ );
466
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 );
470
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 );
473
474   finishCheck.CheckSignalReceived();
475
476   END_TEST;
477 }
478
479 int UtcDaliLayouting_RemoveChildLayoutTransition01(void)
480 {
481   ToolkitTestApplication application;
482   tet_infoline(" UtcDaliLayouting_RemoveChildLayoutTransition01");
483
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 );
489
490   DevelControl::SetLayout( container, horizontalLayout );
491   container.SetName( "Container" );
492
493   std::vector< Control > controls;
494   controls.push_back( CreateLeafControl( 100, 100 ) );
495   controls.push_back( CreateLeafControl( 100, 100 ) );
496
497   stage.Add( container );
498   container.Add( controls[0] );
499   container.Add( controls[1] );
500
501   // Initial rendering done
502   application.SendNotification();
503   application.Render();
504
505   horizontalLayout.SetAnimateLayout( true );
506
507   auto layoutTransitionData = LayoutTransitionData::New();
508   {
509     // Instant resize for parent width
510     Property::Map map;
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 );
520   }
521   {
522     // Instant resize for parent height
523     Property::Map map;
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 );
533   }
534   {
535     // Instant position for parent X position
536     Property::Map map;
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 );
546   }
547   {
548     // Instant position for parent Y position
549     Property::Map map;
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 );
559   }
560   {
561     // Shrink the children
562     Property::Map map;
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 );
572   }
573   {
574     // Shrink the children
575     Property::Map map;
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 );
585   }
586   {
587     // Shrink the removed child
588     Property::Map map;
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 );
599   }
600   {
601     // Instant position for children
602     Property::Map map;
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
611   }
612   {
613     // Instant position for children
614     Property::Map map;
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
623   }
624
625   horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE, layoutTransitionData );
626   container.Remove( controls[1] );
627
628   bool signalReceived(false);
629   LayoutTransitionFinishCheck finishCheck(signalReceived);
630   layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
631
632   application.SendNotification();
633   application.Render( 1u /*just very beginning of the animation*/ );
634
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 );
640
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 );
645
646   application.SendNotification();
647   application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
648
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 );
654
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 );
659
660   application.SendNotification();
661   application.Render( 10u /* wait a bit more for a signal */ );
662
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 );
668
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 );
673
674   finishCheck.CheckSignalReceived();
675
676   END_TEST;
677 }
678
679 int UtcDaliLayouting_FocusChildLayoutTransition01(void)
680 {
681   ToolkitTestApplication application;
682   tet_infoline(" UtcDaliLayouting_FocusChildLayoutTransition01");
683
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 );
689
690   DevelControl::SetLayout( container, horizontalLayout );
691   container.SetName( "Container" );
692
693   std::vector< Control > controls;
694   controls.push_back( CreateLeafControl( 100, 100 ) );
695   controls.push_back( CreateLeafControl( 100, 100 ) );
696
697   stage.Add( container );
698   container.Add( controls[0] );
699   container.Add( controls[1] );
700
701   KeyInputFocusManager manager = KeyInputFocusManager::Get();
702   manager.SetFocus( controls[0] );
703
704   // Initial rendering done
705   application.SendNotification();
706   application.Render();
707
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 );
711
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 );
715
716   horizontalLayout.SetAnimateLayout( true );
717
718   auto layoutTransitionData = LayoutTransitionData::New();
719   {
720     // Instant resize for parent
721     Property::Map map;
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 );
730   }
731   {
732     // Instant position for parent
733     Property::Map map;
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
742   }
743   {
744     // Shrink the lost focus child
745     Property::Map map;
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
755   }
756   {
757     // Grow the gained focus child
758     Property::Map map;
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
768   }
769
770   horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, layoutTransitionData );
771
772   bool signalReceived(false);
773   LayoutTransitionFinishCheck finishCheck(signalReceived);
774   layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
775   manager.SetFocus( controls[1] );
776
777   application.SendNotification();
778   application.Render( 1u /*just very beginning of the animation*/ );
779
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 );
785
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 );
789
790   application.SendNotification();
791   application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
792
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 );
797
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 );
801
802   application.SendNotification();
803   application.Render( 10u /* wait a bit more for a signal */ );
804
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 );
809
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 );
813
814   finishCheck.CheckSignalReceived();
815
816   END_TEST;
817 }
818
819 int UtcDaliLayouting_AddChildLayoutTransition02_KeyFrames(void)
820 {
821   ToolkitTestApplication application;
822   tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition02_KeyFrames");
823
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 );
829
830   DevelControl::SetLayout( container, horizontalLayout );
831   container.SetName( "Container");
832
833   std::vector< Control > controls;
834   controls.push_back( CreateLeafControl( 100, 100 ) );
835   stage.Add( container );
836
837   auto layoutTransitionData = LayoutTransitionData::New();
838   {
839     // Instant resize for parent
840     Property::Map map;
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 );
849   }
850   {
851     // Instant position for a child
852     Property::Map map;
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
860   }
861   {
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 ) );
866
867     Property::Map map;
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()
874         .Add( "delay", 0.0f)
875         .Add( "duration", 0.5f));
876     layoutTransitionData.AddPropertyAnimator( Actor(), map, keyFrames, Animation::Interpolation::Linear );
877   }
878
879   horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
880   container.Add( controls[0] );
881
882   bool signalReceived(false);
883   LayoutTransitionFinishCheck finishCheck(signalReceived);
884   layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
885
886   application.SendNotification();
887   application.Render( 1u /*just very beginning of the animation*/ );
888
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 );
893
894   application.SendNotification();
895   application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
896
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 );
900
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 );
903
904   application.SendNotification();
905   application.Render( 10u /* wait a bit more for a signal */ );
906
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 );
910
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 );
913
914   finishCheck.CheckSignalReceived();
915
916   END_TEST;
917 }
918
919 int UtcDaliLayouting_AddChildLayoutTransition03_Path(void)
920 {
921   ToolkitTestApplication application;
922   tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition03_Path");
923
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 );
929
930   DevelControl::SetLayout( container, horizontalLayout );
931   container.SetName( "Container");
932
933   std::vector< Control > controls;
934   controls.push_back( CreateLeafControl( 100, 100 ) );
935   stage.Add( container );
936
937   auto layoutTransitionData = LayoutTransitionData::New();
938   {
939     // Instant resize for parent
940     Property::Map map;
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 );
949   }
950
951   Dali::Path path = Dali::Path::New();
952   {
953     // Curve position for a child
954     Property::Map map;
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 ) );
962
963     // Build the path
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 );
967
968     //Dali::Path path = Dali::Path::New();
969     path.AddPoint( position0 );
970     path.AddPoint( position1 );
971     path.AddPoint( position2 );
972
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 ) );
976
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 ) );
980
981     layoutTransitionData.AddPropertyAnimator( controls[0], map, path, Vector3::XAXIS );
982   }
983   {
984     // Grow a child from (0,0) size to full size (captured)
985     Property::Map map;
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 );
994   }
995
996   horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
997   container.Add( controls[0] );
998
999   bool signalReceived(false);
1000   LayoutTransitionFinishCheck finishCheck(signalReceived);
1001   layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1002
1003   application.SendNotification();
1004   application.Render( 0 );
1005
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 );
1009
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 );
1016
1017   application.SendNotification();
1018   application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1019
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 );
1024
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 );
1028
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 );
1031
1032   application.SendNotification();
1033   application.Render( 10u /* wait a bit more for a signal */ );
1034
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 );
1038
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 );
1041
1042   finishCheck.CheckSignalReceived();
1043
1044   END_TEST;
1045 }
1046
1047 int UtcDaliLayouting_AddChildLayoutTransition04_AnimateBy(void)
1048 {
1049   ToolkitTestApplication application;
1050   tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition04_AnimateBy");
1051
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 );
1057
1058   DevelControl::SetLayout( container, horizontalLayout );
1059   container.SetName( "Container");
1060
1061   std::vector< Control > controls;
1062   controls.push_back( CreateLeafControl( 100, 100 ) );
1063   stage.Add( container );
1064
1065   auto layoutTransitionData = LayoutTransitionData::New();
1066   {
1067     // Instant resize for parent
1068     Property::Map map;
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 );
1077   }
1078   {
1079     // Instant position for a child
1080     Property::Map map;
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
1088   }
1089   {
1090     Property::Map map;
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 );
1100   }
1101
1102   horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
1103   container.Add( controls[0] );
1104
1105   bool signalReceived(false);
1106   LayoutTransitionFinishCheck finishCheck(signalReceived);
1107   layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1108
1109   application.SendNotification();
1110   application.Render( 1u /*just very beginning of the animation*/ );
1111
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 );
1116
1117   application.SendNotification();
1118   application.Render( static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1119
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 );
1123
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 );
1126
1127   application.SendNotification();
1128   application.Render( 10u /* wait a bit more for a signal */ );
1129
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 );
1133
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 );
1136
1137   finishCheck.CheckSignalReceived();
1138
1139   END_TEST;
1140 }
1141
1142 int UtcDaliLayouting_AddChildLayoutTransition05(void)
1143 {
1144   ToolkitTestApplication application;
1145   tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition05");
1146
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 );
1152
1153   DevelControl::SetLayout( container, horizontalLayout );
1154   container.SetName( "Container");
1155
1156   std::vector< Control > controls;
1157   controls.push_back( CreateLeafControl( 100, 100 ) );
1158   stage.Add( container );
1159
1160   auto layoutTransitionData = LayoutTransitionData::New();
1161   {
1162     // Instant resize for parent
1163     Property::Map map;
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 );
1174   }
1175   {
1176     // Instant position for a child
1177     Property::Map map;
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
1181   }
1182   {
1183     // Grow a child from (0,0) size to full size (captured)
1184     Property::Map map;
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 );
1189   }
1190   {
1191     // Instant opacity for a child, for testing
1192     Property::Map map;
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
1196   }
1197
1198   // Just throw all other alpha functions in
1199   { // no property, not going to be used, but going to be parsed
1200     Property::Map map;
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
1204   }
1205   { // no property, not going to be used, but going to be parsed
1206     Property::Map map;
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
1210   }
1211   { // no property, not going to be used, but going to be parsed
1212     Property::Map map;
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
1216   }
1217   { // no property, not going to be used, but going to be parsed
1218     Property::Map map;
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
1222   }
1223   { // no property, not going to be used, but going to be parsed
1224     Property::Map map;
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
1228   }
1229   { // no property, not going to be used, but going to be parsed
1230     Property::Map map;
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
1234   }
1235   { // no property, not going to be used, but going to be parsed
1236     Property::Map map;
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
1240   }
1241   { // no property, not going to be used, but going to be parsed
1242     Property::Map map;
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
1246   }
1247   { // no property, not going to be used, but going to be parsed
1248     Property::Map map;
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
1252   }
1253   { // no property, not going to be used, but going to be parsed
1254     Property::Map map;
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
1258   }
1259   { // no property, not going to be used, but going to be parsed
1260     Property::Map map;
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
1264   }
1265   { // no property, not going to be used, but going to be parsed
1266     Property::Map map;
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
1270   }
1271   { // no property, not going to be used, but going to be parsed
1272     Property::Map map;
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
1276   }
1277   { // no property, not going to be used, but going to be parsed
1278     Property::Map map;
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
1282   }
1283   { // no property, not going to be used, but going to be parsed
1284     Property::Map map;
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
1288   }
1289   { // no property, not going to be used, but going to be parsed
1290     Property::Map map;
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
1294   }
1295   { // no property, not going to be used, but going to be parsed
1296     Property::Map map;
1297     // valid
1298     Property::Array array;
1299     array.Reserve( 4 );
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
1307   }
1308   { // no property, not going to be used, but going to be parsed
1309     Property::Map map;
1310     // invalid
1311     Property::Array array;
1312     array.Reserve( 3 );
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
1319   }
1320   { // no property, not going to be used, but going to be parsed
1321     Property::Map map;
1322     // invalid
1323     Property::Array array;
1324     array.Reserve( 4 );
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
1332   }
1333   { // no property, not going to be used, but going to be parsed
1334     Property::Map map;
1335     map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = 0; // invalid
1336     layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent
1337   }
1338
1339   horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData );
1340   container.Add( controls[0] );
1341
1342   bool signalReceived(false);
1343   LayoutTransitionFinishCheck finishCheck(signalReceived);
1344   layoutTransitionData.FinishedSignal().Connect(&application, finishCheck);
1345
1346   application.SendNotification();
1347   application.Render( 1u /*just very beginning of the animation*/ );
1348
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 );
1353
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 );
1356
1357   application.SendNotification();
1358   application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
1359
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 );
1363
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 );
1366
1367   application.SendNotification();
1368   application.Render( 10u /* wait a bit more for a signal */ );
1369
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 );
1373
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 );
1376
1377   finishCheck.CheckSignalReceived();
1378
1379   END_TEST;
1380 }
1381
1382 int UtcDaliLayouting_DefaultTransition01(void)
1383 {
1384   ToolkitTestApplication application;
1385   tet_infoline(" UtcDaliLayouting_DefaultTransition01");
1386
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 );
1392
1393   DevelControl::SetLayout( container, horizontalLayout );
1394   container.SetName( "Container" );
1395
1396   std::vector< Control > controls;
1397   controls.push_back( CreateLeafControl( 100, 100 ) );
1398   controls.push_back( CreateLeafControl( 100, 100 ) );
1399
1400   stage.Add( container );
1401   container.Add( controls[0] );
1402   container.Add( controls[1] );
1403
1404   // Initial rendering done
1405   application.SendNotification();
1406   application.Render();
1407
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 );
1411
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 );
1415
1416   horizontalLayout.SetAnimateLayout( true );
1417
1418   auto layoutTransitionData0 = LayoutTransitionData::New();
1419   {
1420     // Default instant resize
1421     Property::Map map;
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 );
1430   }
1431   {
1432     // Instant instant position
1433     Property::Map map;
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 );
1442   }
1443   DevelControl::GetLayout( controls[0] ).SetTransitionData(LayoutTransitionData::Type::ON_LAYOUT_CHANGE, layoutTransitionData0 );
1444
1445   auto layoutTransitionData1 = LayoutTransitionData::New();
1446   {
1447     // Default instant resize
1448     Property::Map map;
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 );
1457   }
1458   {
1459     // Instant instant position
1460     Property::Map map;
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 );
1469   }
1470   DevelControl::GetLayout( controls[1] ).SetTransitionData(LayoutTransitionData::Type::ON_LAYOUT_CHANGE, layoutTransitionData1 );
1471
1472   horizontalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
1473
1474   application.SendNotification();
1475   application.Render( 10u /*just very beginning of the animation*/ );
1476
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 );
1481
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 );
1485
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 );
1490
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 );
1494
1495   END_TEST;
1496 }
1497