2 * Copyright (c) 2016 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.
19 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali/devel-api/object/handle-devel.h>
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
24 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
25 #include "dummy-control.h"
28 using namespace Toolkit;
31 void utc_dali_toolkit_transition_data_startup(void)
33 test_return_value = TET_UNDEF;
36 void utc_dali_toolkit_transition_data_cleanup(void)
38 test_return_value = TET_PASS;
41 Property::Map CreateMap()
45 map["target"] = "Actor1";
46 map["property"] = "color";
47 map["initialValue"] = Color::MAGENTA;
48 map["targetValue"] = Color::RED;
49 map["animator"] = Property::Map()
50 .Add("alphaFunction", "EASE_IN_OUT_BACK")
51 .Add("timePeriod", Property::Map()
53 .Add("duration", 1.0f));
57 void CHECK_ARRAY_EQUALS( Property::Array test, Property::Value result )
59 if( result.GetType() == Property::ARRAY )
62 Property::Array *resultArray = result.GetArray();
63 DALI_TEST_EQUALS( test.Count(), resultArray->Count(), TEST_LOCATION );
64 for( size_t i=0; i < std::min(test.Count(), resultArray->Count()); ++i )
66 Property::Value a = test.GetElementAt(i);
67 Property::Value b = resultArray->GetElementAt(i);
68 DALI_TEST_EQUALS( a.GetType(), b.GetType(), TEST_LOCATION );
69 DALI_TEST_EQUALS( a, b, 0.001, TEST_LOCATION );
72 else if( result.GetType() == Property::VECTOR4 )
74 Vector4 value = result.Get<Vector4>();
75 DALI_TEST_CHECK( test.Count() >= 4 );
76 for( size_t i=0; i < 4; ++i )
78 Property::Value a = test.GetElementAt(i);
79 DALI_TEST_EQUALS( a.GetType(), Property::FLOAT, TEST_LOCATION );
80 DALI_TEST_EQUALS( a.Get<float>(), value[i], 0.001, TEST_LOCATION );
89 void CHECK_MAP_EQUALS( Property::Map test, Property::Map result )
91 DALI_TEST_EQUALS(test.Count(), result.Count(), TEST_LOCATION);
93 for( unsigned int i=0; i< test.Count(); ++i )
95 KeyValuePair keyValue = test.GetKeyValue(i);
96 Property::Value* value;
98 if( keyValue.first.type == Property::Key::STRING )
100 value = result.Find(keyValue.first.stringKey);
104 value = result.Find(keyValue.first.indexKey);
107 DALI_TEST_CHECK( value != NULL );
110 if( keyValue.second.GetType() == Property::MAP )
112 DALI_TEST_EQUALS( keyValue.second.GetType(), value->GetType(), TEST_LOCATION );
113 CHECK_MAP_EQUALS( *(keyValue.second.GetMap()), *(value->GetMap()) );
115 else if( keyValue.second.GetType() == Property::ARRAY )
117 CHECK_ARRAY_EQUALS( *(keyValue.second.GetArray()), *value );
119 else if( keyValue.second.GetType() == Property::STRING )
121 DALI_TEST_EQUALS( keyValue.second.GetType(), value->GetType(), TEST_LOCATION );
124 DALI_TEST_EQUALS( keyValue.second, str.c_str(), TEST_LOCATION );
128 DALI_TEST_EQUALS( keyValue.second.GetType(), value->GetType(), TEST_LOCATION );
129 DALI_TEST_EQUALS( keyValue.second, *value, 0.001f, TEST_LOCATION );
136 int UtcDaliTransitionDataNew(void)
138 TestApplication application;
140 Property::Map map = CreateMap();
141 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
142 DALI_TEST_CHECK( transition );
147 int UtcDaliTransitionDataDownCast(void)
149 TestApplication application;
151 Property::Map map = CreateMap();
153 BaseHandle handle = TransitionData::New( map );
154 DALI_TEST_CHECK( handle );
156 TransitionData transitionData = TransitionData::DownCast( handle );
157 DALI_TEST_CHECK( transitionData );
161 int UtcDaliTransitionDataCopyConstructor(void)
163 TestApplication application;
165 Property::Map map = CreateMap();
167 TransitionData transitionData = TransitionData::New( map );
168 DALI_TEST_CHECK( transitionData );
170 TransitionData td2( transitionData );
171 DALI_TEST_CHECK( td2 );
172 DALI_TEST_EQUALS( td2.Count(), 1, TEST_LOCATION );
176 int UtcDaliTransitionDataAssignmentOperator(void)
178 TestApplication application;
180 Property::Map map = CreateMap();
182 TransitionData transitionData = TransitionData::New( map );
183 DALI_TEST_CHECK( transitionData );
186 DALI_TEST_CHECK( !td2 );
188 td2 = transitionData;
189 DALI_TEST_CHECK( td2 );
191 DALI_TEST_EQUALS( td2.Count(), 1, TEST_LOCATION );
195 int UtcDaliTransitionDataCount(void)
197 TestApplication application;
199 Property::Map map = CreateMap();
200 TransitionData transitionData = TransitionData::New( map );
201 DALI_TEST_CHECK( transitionData );
202 DALI_TEST_EQUALS( transitionData.Count(), 1, TEST_LOCATION );
204 Property::Array array;
205 array.PushBack( map );
206 array.PushBack( map );
207 array.PushBack( map );
209 TransitionData transitionData2 = TransitionData::New( array );
210 DALI_TEST_CHECK( transitionData2 );
211 DALI_TEST_EQUALS( transitionData2.Count(), 3, TEST_LOCATION );
216 int UtcDaliTransitionDataMap1P(void)
218 TestApplication application;
220 tet_printf("Testing animation of a visual property using stylesheet equivalent maps\n");
223 map["target"] = "visual1";
224 map["property"] = "mixColor";
225 map["initialValue"] = Color::MAGENTA;
226 map["targetValue"] = Color::RED;
227 map["animator"] = Property::Map()
228 .Add("alphaFunction", "EASE_IN_OUT")
229 .Add("timePeriod", Property::Map()
231 .Add("duration", 1.0f));
233 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
235 DummyControl actor = DummyControl::New();
236 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
237 actor.SetName("Actor1");
238 actor.SetColor(Color::CYAN);
239 Stage::GetCurrent().Add(actor);
241 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
243 Property::Map visualMap;
244 visualMap[Visual::Property::TYPE] = Visual::COLOR;
245 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
246 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
247 visual.SetName( "visual1" );
249 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
250 dummyImpl.RegisterVisual( visualIndex, visual );
252 Animation anim = dummyImpl.CreateTransition( transition );
253 DALI_TEST_CHECK( anim );
255 Renderer renderer = actor.GetRendererAt(0);
256 Property::Index mixColorIndex = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
257 application.SendNotification();
258 application.Render(0);
260 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), Color::MAGENTA, TEST_LOCATION);
264 application.SendNotification();
265 application.Render(0);
266 application.Render(500); // Start animation
267 application.Render(500); // Halfway thru anim
268 application.SendNotification();
269 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), (Color::MAGENTA+Color::RED)*0.5f, TEST_LOCATION);
271 application.Render(500); // End of anim
272 application.SendNotification();
273 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), Color::RED, TEST_LOCATION );
278 int UtcDaliTransitionDataMap2P(void)
280 TestApplication application;
282 tet_printf("Testing animation of a visual property using programmatic maps\n");
285 map["target"] = "visual1";
286 //Control::CONTROL_PROPERTY_END_INDEX + 1
287 map["property"] = ColorVisual::Property::MIX_COLOR;
288 map["initialValue"] = Color::MAGENTA;
289 map["targetValue"] = Color::RED;
290 map["animator"] = Property::Map()
291 .Add("alphaFunction", "LINEAR")
292 .Add("timePeriod", Property::Map()
294 .Add("duration", 1.0f));
296 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
298 DummyControl actor = DummyControl::New();
299 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
300 actor.SetName("Actor1");
301 actor.SetColor(Color::CYAN);
302 Stage::GetCurrent().Add(actor);
304 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
306 Property::Map visualMap;
307 visualMap[Visual::Property::TYPE] = Visual::COLOR;
308 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
309 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
310 visual.SetName( "visual1" );
312 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
313 dummyImpl.RegisterVisual( visualIndex, visual );
315 Animation anim = dummyImpl.CreateTransition( transition );
316 DALI_TEST_CHECK( anim );
318 Renderer renderer = actor.GetRendererAt(0);
319 Property::Index mixColorIndex = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
320 application.SendNotification();
321 application.Render(0);
323 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), Color::MAGENTA, TEST_LOCATION);
327 application.SendNotification();
328 application.Render(0);
329 application.Render(500); // Start animation
330 application.Render(500); // Halfway thru anim
331 application.SendNotification();
332 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), (Color::MAGENTA+Color::RED)*0.5f, TEST_LOCATION);
334 application.Render(500); // End of anim
335 application.SendNotification();
336 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), Color::RED, TEST_LOCATION );
342 int UtcDaliTransitionDataMap3P(void)
344 TestApplication application;
346 tet_printf("Testing animation of a visual's placement actor property\n");
349 map["target"] = "visual1";
350 map["property"] = "color";
351 map["initialValue"] = Color::MAGENTA;
352 map["targetValue"] = Color::RED;
353 map["animator"] = Property::Map()
354 .Add("alphaFunction", "EASE_IN_OUT")
355 .Add("timePeriod", Property::Map()
357 .Add("duration", 1.0f));
359 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
361 DummyControl actor = DummyControl::New();
362 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
363 actor.SetName("Actor1");
364 actor.SetColor(Color::CYAN);
365 Stage::GetCurrent().Add(actor);
367 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
369 Property::Map visualMap;
370 visualMap[Visual::Property::TYPE] = Visual::COLOR;
371 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
372 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
373 visual.SetName( "visual1" );
375 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
376 dummyImpl.RegisterVisual( visualIndex, visual );
378 Animation anim = dummyImpl.CreateTransition( transition );
379 DALI_TEST_CHECK( anim );
381 application.SendNotification();
382 application.Render(0);
383 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION);
387 application.SendNotification();
388 application.Render(0);
389 application.Render(500);
390 application.Render(500); // Halfway thru map1 anim
391 application.SendNotification();
392 DALI_TEST_EQUALS( actor.GetCurrentColor(), (Color::MAGENTA+Color::RED)*0.5f, TEST_LOCATION);
394 application.Render(500); // End of map1 anim
395 application.SendNotification();
396 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::RED, TEST_LOCATION );
401 int UtcDaliTransitionDataMap4P(void)
403 TestApplication application;
405 tet_printf("Testing animation of a visual's placement actor property using bezier curve\n");
408 map["target"] = "Actor1";
409 map["property"] = "position";
410 map["initialValue"] = Vector3(0, 0, 0);
411 map["targetValue"] = Vector3(100, 100, 0);
412 map["animator"] = Property::Map()
413 .Add("alphaFunction", Vector4(0.71, -0.57, 0.42, 1.38) )
414 .Add("timePeriod", Property::Map()
416 .Add("duration", 1.0f));
418 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
420 DummyControl actor = DummyControl::New();
421 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
422 actor.SetName("Actor1");
423 Stage::GetCurrent().Add(actor);
425 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
426 Animation anim = dummyImpl.CreateTransition( transition );
427 DALI_TEST_CHECK( anim );
429 application.SendNotification();
430 application.Render(0);
431 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0,0,0), 0.001f, TEST_LOCATION);
435 application.SendNotification();
436 application.Render(0);
438 application.Render(250); // 25%
439 application.SendNotification();
440 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(-10,-10,0), 1.0, TEST_LOCATION); // High epsilon as we don't have exact figure for bezier curve at 50%
442 application.Render(250); // Halfway thru map1 anim
443 application.SendNotification();
444 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(24,24,0), 1.0, TEST_LOCATION); // High epsilon as we don't have exact figure for bezier curve at 50%
446 application.Render(250); // End of map1 anim
447 application.SendNotification();
448 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100,100,0), 1.0, TEST_LOCATION); // High epsilon as we don't have exact figure for bezier curve
450 application.Render(250); // End of map1 anim
451 application.SendNotification();
452 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100,100,0), TEST_LOCATION );
456 int UtcDaliTransitionDataMap1N(void)
458 TestApplication application;
461 map["target"] = "Actor1";
462 map["property"] = "randomProperty";
463 map["initialValue"] = Color::MAGENTA;
464 map["targetValue"] = Color::RED;
465 map["animator"] = Property::Map()
466 .Add("alphaFunction", "EASE_OUT")
467 .Add("timePeriod", Property::Map()
469 .Add("duration", 1.0f));
471 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
473 DummyControl actor = DummyControl::New();
474 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
475 actor.SetName("Actor1");
476 actor.SetColor(Color::CYAN);
477 Stage::GetCurrent().Add(actor);
479 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
480 Animation anim = dummyImpl.CreateTransition( transition );
481 DALI_TEST_CHECK( ! anim );
483 CHECK_MAP_EQUALS( map, transition.GetAnimatorAt(0) );
488 int UtcDaliTransitionDataMapN3(void)
490 TestApplication application;
492 tet_printf("Testing visual lookup with no renderers\n");
495 map["target"] = "visual1";
496 map["property"] = "mixColor";
497 map["initialValue"] = Color::MAGENTA;
498 map["targetValue"] = Color::RED;
499 map["animator"] = Property::Map()
500 .Add("alphaFunction", "EASE_OUT_BACK")
501 .Add("timePeriod", Property::Map()
503 .Add("duration", 1.0f));
505 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
506 CHECK_MAP_EQUALS( map, transition.GetAnimatorAt(0) );
508 DummyControl actor = DummyControl::New();
509 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
510 actor.SetName("Actor1");
511 actor.SetColor(Color::CYAN);
514 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
515 Property::Map visualMap;
516 visualMap[Visual::Property::TYPE] = Visual::COLOR;
517 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
518 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
519 visual.SetName( "visual1" );
521 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
522 dummyImpl.RegisterVisual( visualIndex, visual );
524 Animation anim = dummyImpl.CreateTransition( transition );
525 DALI_TEST_CHECK( !anim );
530 int UtcDaliTransitionDataMapN4(void)
532 TestApplication application;
534 tet_printf("Testing visual doesn't animate with duff bezier data \n");
537 map["target"] = "visual1";
538 map["property"] = "mixColor";
539 map["initialValue"] = Color::MAGENTA;
540 map["targetValue"] = Color::RED;
541 map["animator"] = Property::Map()
542 .Add("alphaFunction", Vector3(.1f,1.0f,0.5f))
543 .Add("timePeriod", Property::Map()
545 .Add("duration", 1.0f));
547 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
549 DummyControl actor = DummyControl::New();
550 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
551 actor.SetName("Actor1");
552 actor.SetColor(Color::CYAN);
553 Stage::GetCurrent().Add(actor);
555 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
556 Property::Map visualMap;
557 visualMap[Visual::Property::TYPE] = Visual::COLOR;
558 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
559 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
560 visual.SetName( "visual1" );
562 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
563 dummyImpl.RegisterVisual( visualIndex, visual );
565 Animation anim = dummyImpl.CreateTransition( transition );
566 DALI_TEST_CHECK( !anim );
568 application.SendNotification();
569 application.Render(0);
570 application.SendNotification();
572 Renderer renderer = actor.GetRendererAt(0);
573 Property::Index mixColorIdx = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
575 tet_printf( "Test that the property has been set to target value\n");
576 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
581 int UtcDaliTransitionDataMapN5(void)
583 TestApplication application;
585 tet_printf("Testing visual doesn't animate with duff bezier data \n");
588 map["target"] = "visual1";
589 map["property"] = "mixColor";
590 map["initialValue"] = Color::MAGENTA;
591 map["targetValue"] = Color::RED;
592 map["animator"] = Property::Map()
593 .Add("alphaFunction", Property::Array().Add(.1f).Add(1.0f).Add(0.5f))
594 .Add("timePeriod", Property::Map()
596 .Add("duration", 1.0f));
598 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
600 DummyControl actor = DummyControl::New();
601 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
602 actor.SetName("Actor1");
603 actor.SetColor(Color::CYAN);
604 Stage::GetCurrent().Add(actor);
606 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
607 Property::Map visualMap;
608 visualMap[Visual::Property::TYPE] = Visual::COLOR;
609 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
610 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
611 visual.SetName( "visual1" );
613 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
614 dummyImpl.RegisterVisual( visualIndex, visual );
616 Animation anim = dummyImpl.CreateTransition( transition );
617 DALI_TEST_CHECK( !anim );
619 application.SendNotification();
620 application.Render(0);
621 application.SendNotification();
623 Renderer renderer = actor.GetRendererAt(0);
624 Property::Index mixColorIdx = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
626 tet_printf( "Test that the property has been set to target value\n");
627 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
632 int UtcDaliTransitionDataMapN6(void)
634 TestApplication application;
636 tet_printf("Testing visual doesn't animate with duff bezier data \n");
639 map["target"] = "visual1";
640 map["property"] = "mixColor";
641 map["initialValue"] = Color::MAGENTA;
642 map["targetValue"] = Color::RED;
643 map["animator"] = Property::Map()
644 .Add("alphaFunction", Property::Array().Add("1").Add("Two").Add("3").Add("4"))
645 .Add("timePeriod", Property::Map()
647 .Add("duration", 1.0f));
649 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
651 DummyControl actor = DummyControl::New();
652 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
653 actor.SetName("Actor1");
654 actor.SetColor(Color::CYAN);
655 Stage::GetCurrent().Add(actor);
657 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
658 Property::Map visualMap;
659 visualMap[Visual::Property::TYPE] = Visual::COLOR;
660 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
661 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
662 visual.SetName( "visual1" );
664 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
665 dummyImpl.RegisterVisual( visualIndex, visual );
667 Animation anim = dummyImpl.CreateTransition( transition );
668 DALI_TEST_CHECK( !anim );
670 application.SendNotification();
671 application.Render(0);
672 application.SendNotification();
674 Renderer renderer = actor.GetRendererAt(0);
675 Property::Index mixColorIdx = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
677 tet_printf( "Test that the property has been set to target value\n");
678 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
684 int UtcDaliTransitionDataArrayP(void)
686 TestApplication application;
689 map1["target"] = "Actor1";
690 map1["property"] = "color";
691 map1["initialValue"] = Color::MAGENTA;
692 map1["targetValue"] = Color::RED;
693 map1["animator"] = Property::Map()
694 .Add("alphaFunction", "EASE_IN_OUT")
695 .Add("timePeriod", Property::Map()
697 .Add("duration", 1.0f));
700 map2["target"] = "Actor1";
701 map2["property"] = "position";
702 map2["initialValue"] = Vector3(100,0,0);
703 map2["targetValue"] = Vector3(0,100,0);
704 map2["animator"] = Property::Map()
705 .Add("alphaFunction", "EASE_IN_OUT")
706 .Add("timePeriod", Property::Map()
708 .Add("duration", 1.0f));
711 map3["target"] = "Actor1";
712 map3["property"] = "orientation";
713 map3["targetValue"] = Quaternion( Radian(Math::PI_2), Vector3::ZAXIS );
715 Property::Array array;
716 array.PushBack(map1);
717 array.PushBack(map2);
718 array.PushBack(map3);
720 Dali::Toolkit::TransitionData transition = TransitionData::New( array );
722 DummyControl actor = DummyControl::New();
723 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
724 actor.SetName("Actor1");
725 actor.SetColor(Color::CYAN);
726 Stage::GetCurrent().Add(actor);
727 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0), Vector3::ZAXIS), TEST_LOCATION);
729 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
730 Animation anim = dummyImpl.CreateTransition( transition );
731 DALI_TEST_CHECK( anim );
732 application.SendNotification();
733 application.Render(0);
734 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION);
735 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(Math::PI_2), Vector3::ZAXIS), TEST_LOCATION);
738 application.SendNotification();
739 application.Render(0); // start map2 anim
740 application.SendNotification();
741 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100,0,0), TEST_LOCATION);
743 application.Render(500); // Start map1 animation, halfway thru map2 anim
744 application.SendNotification();
745 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(50,50,0), TEST_LOCATION);
747 application.Render(500); // Halfway thru map1 anim, end of map2 anim
748 application.SendNotification();
749 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0,100,0), TEST_LOCATION);
750 DALI_TEST_EQUALS( actor.GetCurrentColor(), (Color::MAGENTA+Color::RED)*0.5f, TEST_LOCATION);
752 application.Render(500); // End of map1 anim
753 application.SendNotification();
754 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::RED, TEST_LOCATION );
760 int UtcDaliTransitionDataGetAnimatorP(void)
762 TestApplication application;
765 map1["target"] = "Actor1";
766 map1["property"] = "color";
767 map1["initialValue"] = Color::MAGENTA;
768 map1["targetValue"] = Color::RED;
769 map1["animator"] = Property::Map()
770 .Add("alphaFunction", "EASE_IN_SQUARE")
771 .Add("timePeriod", Property::Map()
773 .Add("duration", 0.5f));
776 map2["target"] = "Actor1";
777 map2["property"] = "position";
778 map2["initialValue"] = Vector3(100,0,0);
779 map2["targetValue"] = Vector3(0,100,0);
780 map2["animator"] = Property::Map()
781 .Add("alphaFunction", "EASE_OUT_SQUARE")
782 .Add("timePeriod", Property::Map()
784 .Add("duration", 2.0f));
787 map3["target"] = "Actor1";
788 map3["property"] = "size";
789 map3["initialValue"] = Vector2(10,10);
790 map3["targetValue"] = Vector2(100,100);
791 map3["animator"] = Property::Map()
792 .Add("alphaFunction", "EASE_OUT_SINE")
793 .Add("timePeriod", Property::Map()
795 .Add("duration", 3.0f));
798 map4["target"] = "Actor2";
799 map4["property"] = "color";
800 map4["initialValue"] = Color::BLACK;
801 map4["targetValue"] = Color::GREEN;
802 map4["animator"] = Property::Map()
803 .Add("alphaFunction", "EASE_IN_OUT_SINE")
804 .Add("timePeriod", Property::Map()
806 .Add("duration", 0.5f));
809 map5["target"] = "Actor2";
810 map5["property"] = "position";
811 map5["initialValue"] = Vector3(100,0,0);
812 map5["targetValue"] = Vector3(0,100,0);
813 map5["animator"] = Property::Map()
814 .Add("alphaFunction", "BOUNCE")
815 .Add("timePeriod", Property::Map()
817 .Add("duration", 2.0f));
820 map6["target"] = "Actor2";
821 map6["property"] = "size";
822 map6["initialValue"] = Vector2(10,10);
823 map6["targetValue"] = Vector2(100,100);
824 map6["animator"] = Property::Map()
825 .Add("alphaFunction", "SIN")
826 .Add("timePeriod", Property::Map()
828 .Add("duration", 3.0f));
831 map7["target"] = "Actor4";
832 map7["property"] = "sizeModeFactor";
833 map7["initialValue"] = Vector3(1,1,1);
834 map7["targetValue"] = Vector3(2,2,2);
835 map7["animator"] = Property::Map()
836 .Add("alphaFunction", "EASE_IN_SINE")
837 .Add("timePeriod", Property::Map()
839 .Add("duration", 1.0f));
842 map8["target"] = "Visual1";
843 map8["property"] = "colorAlpha";
844 map8["targetValue"] = 1.0f;
845 map8["animator"] = Property::Map()
846 .Add("alphaFunction", "EASE_IN")
847 .Add("timePeriod", Property::Map()
849 .Add("duration", 9.0f));
852 map9["target"] = "Actor2";
853 map9["property"] = "scale";
854 map9["initialValue"] = Vector3(0,0,0);
855 map9["targetValue"] = Vector3(1,1,1);
856 map9["animator"] = Property::Map()
857 .Add("alphaFunction", "REVERSE")
858 .Add("timePeriod", Property::Map()
860 .Add("duration", 1.0f));
863 map10["target"] = "Actor2";
864 map10["property"] = "scale";
865 map10["initialValue"] = Vector3(0,0,0);
866 map10["targetValue"] = Vector3(1,1,1);
867 map10["animator"] = Property::Map()
868 .Add("alphaFunction", Vector4(.23,.4,.8,1.2))
869 .Add("timePeriod", Property::Map()
871 .Add("duration", 1.0f));
874 map11["target"] = "Actor2";
875 map11["property"] = "scale";
876 map11["initialValue"] = Vector3(0,0,0);
877 map11["targetValue"] = Vector3(1,1,1);
878 map11["animator"] = Property::Map()
879 .Add("alphaFunction", Property::Array().Add(.23f).Add(.4f).Add(.8f).Add(.2f))
880 .Add("timePeriod", Property::Map()
882 .Add("duration", 1.0f));
885 map12["target"] = "Actor1";
886 map12["property"] = "orientation";
887 map12["targetValue"] = Quaternion( Radian(Math::PI_2), Vector3::ZAXIS );
889 Property::Array array;
890 array.PushBack(map1);
891 array.PushBack(map2);
892 array.PushBack(map3);
893 array.PushBack(map4);
894 array.PushBack(map5);
895 array.PushBack(map6);
896 array.PushBack(map7);
897 array.PushBack(map8);
898 array.PushBack(map9);
899 array.PushBack(map10);
900 array.PushBack(map11);
901 array.PushBack(map12);
903 Dali::Toolkit::TransitionData transition = TransitionData::New( array );
905 DALI_TEST_EQUALS( transition.Count(), array.Count(), TEST_LOCATION );
907 for( unsigned int i=0; i < array.Count(); ++i )
909 Property::Map animatorMap = transition.GetAnimatorAt(i);
910 Property::Value& value = array.GetElementAt(i);
911 Property::Map* inputMap = value.GetMap();
912 DALI_TEST_CHECK( inputMap );
913 CHECK_MAP_EQUALS( *inputMap, animatorMap );