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-toolkit/dali-toolkit.h>
22 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
23 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
24 #include "dummy-control.h"
27 using namespace Toolkit;
30 void utc_dali_toolkit_transition_data_startup(void)
32 test_return_value = TET_UNDEF;
35 void utc_dali_toolkit_transition_data_cleanup(void)
37 test_return_value = TET_PASS;
40 Property::Map CreateMap()
44 map["target"] = "Actor1";
45 map["property"] = "color";
46 map["initialValue"] = Color::MAGENTA;
47 map["targetValue"] = Color::RED;
48 map["animator"] = Property::Map()
49 .Add("alphaFunction", "EASE_IN_OUT_BACK")
50 .Add("timePeriod", Property::Map()
52 .Add("duration", 1.0f));
56 void CHECK_ARRAY_EQUALS( Property::Array test, Property::Value result )
58 if( result.GetType() == Property::ARRAY )
61 Property::Array *resultArray = result.GetArray();
62 DALI_TEST_EQUALS( test.Count(), resultArray->Count(), TEST_LOCATION );
63 for( size_t i=0; i < std::min(test.Count(), resultArray->Count()); ++i )
65 Property::Value a = test.GetElementAt(i);
66 Property::Value b = resultArray->GetElementAt(i);
67 DALI_TEST_EQUALS( a.GetType(), b.GetType(), TEST_LOCATION );
68 DALI_TEST_EQUALS( a, b, 0.001, TEST_LOCATION );
71 else if( result.GetType() == Property::VECTOR4 )
73 Vector4 value = result.Get<Vector4>();
74 DALI_TEST_CHECK( test.Count() >= 4 );
75 for( size_t i=0; i < 4; ++i )
77 Property::Value a = test.GetElementAt(i);
78 DALI_TEST_EQUALS( a.GetType(), Property::FLOAT, TEST_LOCATION );
79 DALI_TEST_EQUALS( a.Get<float>(), value[i], 0.001, TEST_LOCATION );
88 void CHECK_MAP_EQUALS( Property::Map test, Property::Map result )
90 DALI_TEST_EQUALS(test.Count(), result.Count(), TEST_LOCATION);
92 for( unsigned int i=0; i< test.Count(); ++i )
94 KeyValuePair keyValue = test.GetKeyValue(i);
95 Property::Value* value;
97 if( keyValue.first.type == Property::Key::STRING )
99 value = result.Find(keyValue.first.stringKey);
103 value = result.Find(keyValue.first.indexKey);
106 DALI_TEST_CHECK( value != NULL );
109 if( keyValue.second.GetType() == Property::MAP )
111 DALI_TEST_EQUALS( keyValue.second.GetType(), value->GetType(), TEST_LOCATION );
112 CHECK_MAP_EQUALS( *(keyValue.second.GetMap()), *(value->GetMap()) );
114 else if( keyValue.second.GetType() == Property::ARRAY )
116 CHECK_ARRAY_EQUALS( *(keyValue.second.GetArray()), *value );
118 else if( keyValue.second.GetType() == Property::STRING )
120 DALI_TEST_EQUALS( keyValue.second.GetType(), value->GetType(), TEST_LOCATION );
123 DALI_TEST_EQUALS( keyValue.second, str.c_str(), TEST_LOCATION );
127 DALI_TEST_EQUALS( keyValue.second.GetType(), value->GetType(), TEST_LOCATION );
128 DALI_TEST_EQUALS( keyValue.second, *value, 0.001f, TEST_LOCATION );
135 int UtcDaliTransitionDataNew(void)
137 TestApplication application;
139 Property::Map map = CreateMap();
140 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
141 DALI_TEST_CHECK( transition );
146 int UtcDaliTransitionDataDownCast(void)
148 TestApplication application;
150 Property::Map map = CreateMap();
152 BaseHandle handle = TransitionData::New( map );
153 DALI_TEST_CHECK( handle );
155 TransitionData transitionData = TransitionData::DownCast( handle );
156 DALI_TEST_CHECK( transitionData );
160 int UtcDaliTransitionDataCopyConstructor(void)
162 TestApplication application;
164 Property::Map map = CreateMap();
166 TransitionData transitionData = TransitionData::New( map );
167 DALI_TEST_CHECK( transitionData );
169 TransitionData td2( transitionData );
170 DALI_TEST_CHECK( td2 );
171 DALI_TEST_EQUALS( td2.Count(), 1, TEST_LOCATION );
175 int UtcDaliTransitionDataAssignmentOperator(void)
177 TestApplication application;
179 Property::Map map = CreateMap();
181 TransitionData transitionData = TransitionData::New( map );
182 DALI_TEST_CHECK( transitionData );
185 DALI_TEST_CHECK( !td2 );
187 td2 = transitionData;
188 DALI_TEST_CHECK( td2 );
190 DALI_TEST_EQUALS( td2.Count(), 1, TEST_LOCATION );
194 int UtcDaliTransitionDataCount(void)
196 TestApplication application;
198 Property::Map map = CreateMap();
199 TransitionData transitionData = TransitionData::New( map );
200 DALI_TEST_CHECK( transitionData );
201 DALI_TEST_EQUALS( transitionData.Count(), 1, TEST_LOCATION );
203 Property::Array array;
204 array.PushBack( map );
205 array.PushBack( map );
206 array.PushBack( map );
208 TransitionData transitionData2 = TransitionData::New( array );
209 DALI_TEST_CHECK( transitionData2 );
210 DALI_TEST_EQUALS( transitionData2.Count(), 3, TEST_LOCATION );
215 int UtcDaliTransitionDataMap1P(void)
217 TestApplication application;
219 tet_printf("Testing animation of a visual property using stylesheet equivalent maps\n");
222 map["target"] = "visual1";
223 map["property"] = "mixColor";
224 map["initialValue"] = Color::MAGENTA;
225 map["targetValue"] = Color::RED;
226 map["animator"] = Property::Map()
227 .Add("alphaFunction", "EASE_IN_OUT")
228 .Add("timePeriod", Property::Map()
230 .Add("duration", 1.0f));
232 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
234 DummyControl actor = DummyControl::New();
235 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
236 actor.SetName("Actor1");
237 actor.SetColor(Color::CYAN);
238 Stage::GetCurrent().Add(actor);
240 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
242 Property::Map visualMap;
243 visualMap[Visual::Property::TYPE] = Visual::COLOR;
244 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
245 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
246 visual.SetName( "visual1" );
248 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
249 dummyImpl.RegisterVisual( visualIndex, visual );
251 Animation anim = dummyImpl.CreateTransition( transition );
252 DALI_TEST_CHECK( anim );
254 Renderer renderer = actor.GetRendererAt(0);
255 Property::Index mixColorIndex = renderer.GetPropertyIndex( ColorVisual::Property::MIX_COLOR );
256 application.SendNotification();
257 application.Render(0);
259 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), Color::MAGENTA, TEST_LOCATION);
263 application.SendNotification();
264 application.Render(0);
265 application.Render(500); // Start animation
266 application.Render(500); // Halfway thru anim
267 application.SendNotification();
268 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), (Color::MAGENTA+Color::RED)*0.5f, TEST_LOCATION);
270 application.Render(500); // End of anim
271 application.SendNotification();
272 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), Color::RED, TEST_LOCATION );
277 int UtcDaliTransitionDataMap2P(void)
279 TestApplication application;
281 tet_printf("Testing animation of a visual property using programmatic maps\n");
284 map["target"] = "visual1";
285 //Control::CONTROL_PROPERTY_END_INDEX + 1
286 map["property"] = ColorVisual::Property::MIX_COLOR;
287 map["initialValue"] = Color::MAGENTA;
288 map["targetValue"] = Color::RED;
289 map["animator"] = Property::Map()
290 .Add("alphaFunction", "LINEAR")
291 .Add("timePeriod", Property::Map()
293 .Add("duration", 1.0f));
295 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
297 DummyControl actor = DummyControl::New();
298 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
299 actor.SetName("Actor1");
300 actor.SetColor(Color::CYAN);
301 Stage::GetCurrent().Add(actor);
303 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
305 Property::Map visualMap;
306 visualMap[Visual::Property::TYPE] = Visual::COLOR;
307 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
308 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
309 visual.SetName( "visual1" );
311 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
312 dummyImpl.RegisterVisual( visualIndex, visual );
314 Animation anim = dummyImpl.CreateTransition( transition );
315 DALI_TEST_CHECK( anim );
317 Renderer renderer = actor.GetRendererAt(0);
318 Property::Index mixColorIndex = renderer.GetPropertyIndex( ColorVisual::Property::MIX_COLOR );
319 application.SendNotification();
320 application.Render(0);
322 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), Color::MAGENTA, TEST_LOCATION);
326 application.SendNotification();
327 application.Render(0);
328 application.Render(500); // Start animation
329 application.Render(500); // Halfway thru anim
330 application.SendNotification();
331 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), (Color::MAGENTA+Color::RED)*0.5f, TEST_LOCATION);
333 application.Render(500); // End of anim
334 application.SendNotification();
335 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), Color::RED, TEST_LOCATION );
341 int UtcDaliTransitionDataMap3P(void)
343 TestApplication application;
345 tet_printf("Testing animation of a visual's placement actor property\n");
348 map["target"] = "visual1";
349 map["property"] = "color";
350 map["initialValue"] = Color::MAGENTA;
351 map["targetValue"] = Color::RED;
352 map["animator"] = Property::Map()
353 .Add("alphaFunction", "EASE_IN_OUT")
354 .Add("timePeriod", Property::Map()
356 .Add("duration", 1.0f));
358 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
360 DummyControl actor = DummyControl::New();
361 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
362 actor.SetName("Actor1");
363 actor.SetColor(Color::CYAN);
364 Stage::GetCurrent().Add(actor);
366 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
368 Property::Map visualMap;
369 visualMap[Visual::Property::TYPE] = Visual::COLOR;
370 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
371 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
372 visual.SetName( "visual1" );
374 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
375 dummyImpl.RegisterVisual( visualIndex, visual );
377 Animation anim = dummyImpl.CreateTransition( transition );
378 DALI_TEST_CHECK( anim );
380 application.SendNotification();
381 application.Render(0);
382 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION);
386 application.SendNotification();
387 application.Render(0);
388 application.Render(500);
389 application.Render(500); // Halfway thru map1 anim
390 application.SendNotification();
391 DALI_TEST_EQUALS( actor.GetCurrentColor(), (Color::MAGENTA+Color::RED)*0.5f, TEST_LOCATION);
393 application.Render(500); // End of map1 anim
394 application.SendNotification();
395 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::RED, TEST_LOCATION );
400 int UtcDaliTransitionDataMap4P(void)
402 TestApplication application;
404 tet_printf("Testing animation of a visual's placement actor property using bezier curve\n");
407 map["target"] = "Actor1";
408 map["property"] = "position";
409 map["initialValue"] = Vector3(0, 0, 0);
410 map["targetValue"] = Vector3(100, 100, 0);
411 map["animator"] = Property::Map()
412 .Add("alphaFunction", Vector4(0.71, -0.57, 0.42, 1.38) )
413 .Add("timePeriod", Property::Map()
415 .Add("duration", 1.0f));
417 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
419 DummyControl actor = DummyControl::New();
420 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
421 actor.SetName("Actor1");
422 Stage::GetCurrent().Add(actor);
424 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
425 Animation anim = dummyImpl.CreateTransition( transition );
426 DALI_TEST_CHECK( anim );
428 application.SendNotification();
429 application.Render(0);
430 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0,0,0), 0.001f, TEST_LOCATION);
434 application.SendNotification();
435 application.Render(0);
437 application.Render(250); // 25%
438 application.SendNotification();
439 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%
441 application.Render(250); // Halfway thru map1 anim
442 application.SendNotification();
443 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%
445 application.Render(250); // End of map1 anim
446 application.SendNotification();
447 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
449 application.Render(250); // End of map1 anim
450 application.SendNotification();
451 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100,100,0), TEST_LOCATION );
455 int UtcDaliTransitionDataMap1N(void)
457 TestApplication application;
460 map["target"] = "Actor1";
461 map["property"] = "randomProperty";
462 map["initialValue"] = Color::MAGENTA;
463 map["targetValue"] = Color::RED;
464 map["animator"] = Property::Map()
465 .Add("alphaFunction", "EASE_OUT")
466 .Add("timePeriod", Property::Map()
468 .Add("duration", 1.0f));
470 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
472 DummyControl actor = DummyControl::New();
473 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
474 actor.SetName("Actor1");
475 actor.SetColor(Color::CYAN);
476 Stage::GetCurrent().Add(actor);
478 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
479 Animation anim = dummyImpl.CreateTransition( transition );
480 DALI_TEST_CHECK( ! anim );
482 CHECK_MAP_EQUALS( map, transition.GetAnimatorAt(0) );
487 int UtcDaliTransitionDataMapN3(void)
489 TestApplication application;
491 tet_printf("Testing visual lookup with no renderers\n");
494 map["target"] = "visual1";
495 map["property"] = "mixColor";
496 map["initialValue"] = Color::MAGENTA;
497 map["targetValue"] = Color::RED;
498 map["animator"] = Property::Map()
499 .Add("alphaFunction", "EASE_OUT_BACK")
500 .Add("timePeriod", Property::Map()
502 .Add("duration", 1.0f));
504 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
505 CHECK_MAP_EQUALS( map, transition.GetAnimatorAt(0) );
507 DummyControl actor = DummyControl::New();
508 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
509 actor.SetName("Actor1");
510 actor.SetColor(Color::CYAN);
513 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
514 Property::Map visualMap;
515 visualMap[Visual::Property::TYPE] = Visual::COLOR;
516 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
517 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
518 visual.SetName( "visual1" );
520 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
521 dummyImpl.RegisterVisual( visualIndex, visual );
523 Animation anim = dummyImpl.CreateTransition( transition );
524 DALI_TEST_CHECK( !anim );
529 int UtcDaliTransitionDataMapN4(void)
531 TestApplication application;
533 tet_printf("Testing visual doesn't animate with duff bezier data \n");
536 map["target"] = "visual1";
537 map["property"] = "mixColor";
538 map["initialValue"] = Color::MAGENTA;
539 map["targetValue"] = Color::RED;
540 map["animator"] = Property::Map()
541 .Add("alphaFunction", Vector3(.1f,1.0f,0.5f))
542 .Add("timePeriod", Property::Map()
544 .Add("duration", 1.0f));
546 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
548 DummyControl actor = DummyControl::New();
549 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
550 actor.SetName("Actor1");
551 actor.SetColor(Color::CYAN);
552 Stage::GetCurrent().Add(actor);
554 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
555 Property::Map visualMap;
556 visualMap[Visual::Property::TYPE] = Visual::COLOR;
557 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
558 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
559 visual.SetName( "visual1" );
561 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
562 dummyImpl.RegisterVisual( visualIndex, visual );
564 Animation anim = dummyImpl.CreateTransition( transition );
565 DALI_TEST_CHECK( !anim );
567 application.SendNotification();
568 application.Render(0);
569 application.SendNotification();
571 Renderer renderer = actor.GetRendererAt(0);
572 Property::Index mixColorIdx = renderer.GetPropertyIndex(ColorVisual::Property::MIX_COLOR);
574 tet_printf( "Test that the property has been set to target value\n");
575 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
580 int UtcDaliTransitionDataMapN5(void)
582 TestApplication application;
584 tet_printf("Testing visual doesn't animate with duff bezier data \n");
587 map["target"] = "visual1";
588 map["property"] = "mixColor";
589 map["initialValue"] = Color::MAGENTA;
590 map["targetValue"] = Color::RED;
591 map["animator"] = Property::Map()
592 .Add("alphaFunction", Property::Array().Add(.1f).Add(1.0f).Add(0.5f))
593 .Add("timePeriod", Property::Map()
595 .Add("duration", 1.0f));
597 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
599 DummyControl actor = DummyControl::New();
600 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
601 actor.SetName("Actor1");
602 actor.SetColor(Color::CYAN);
603 Stage::GetCurrent().Add(actor);
605 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
606 Property::Map visualMap;
607 visualMap[Visual::Property::TYPE] = Visual::COLOR;
608 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
609 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
610 visual.SetName( "visual1" );
612 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
613 dummyImpl.RegisterVisual( visualIndex, visual );
615 Animation anim = dummyImpl.CreateTransition( transition );
616 DALI_TEST_CHECK( !anim );
618 application.SendNotification();
619 application.Render(0);
620 application.SendNotification();
622 Renderer renderer = actor.GetRendererAt(0);
623 Property::Index mixColorIdx = renderer.GetPropertyIndex(ColorVisual::Property::MIX_COLOR);
625 tet_printf( "Test that the property has been set to target value\n");
626 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
631 int UtcDaliTransitionDataMapN6(void)
633 TestApplication application;
635 tet_printf("Testing visual doesn't animate with duff bezier data \n");
638 map["target"] = "visual1";
639 map["property"] = "mixColor";
640 map["initialValue"] = Color::MAGENTA;
641 map["targetValue"] = Color::RED;
642 map["animator"] = Property::Map()
643 .Add("alphaFunction", Property::Array().Add("1").Add("Two").Add("3").Add("4"))
644 .Add("timePeriod", Property::Map()
646 .Add("duration", 1.0f));
648 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
650 DummyControl actor = DummyControl::New();
651 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
652 actor.SetName("Actor1");
653 actor.SetColor(Color::CYAN);
654 Stage::GetCurrent().Add(actor);
656 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
657 Property::Map visualMap;
658 visualMap[Visual::Property::TYPE] = Visual::COLOR;
659 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
660 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
661 visual.SetName( "visual1" );
663 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
664 dummyImpl.RegisterVisual( visualIndex, visual );
666 Animation anim = dummyImpl.CreateTransition( transition );
667 DALI_TEST_CHECK( !anim );
669 application.SendNotification();
670 application.Render(0);
671 application.SendNotification();
673 Renderer renderer = actor.GetRendererAt(0);
674 Property::Index mixColorIdx = renderer.GetPropertyIndex(ColorVisual::Property::MIX_COLOR);
676 tet_printf( "Test that the property has been set to target value\n");
677 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
683 int UtcDaliTransitionDataArrayP(void)
685 TestApplication application;
688 map1["target"] = "Actor1";
689 map1["property"] = "color";
690 map1["initialValue"] = Color::MAGENTA;
691 map1["targetValue"] = Color::RED;
692 map1["animator"] = Property::Map()
693 .Add("alphaFunction", "EASE_IN_OUT")
694 .Add("timePeriod", Property::Map()
696 .Add("duration", 1.0f));
699 map2["target"] = "Actor1";
700 map2["property"] = "position";
701 map2["initialValue"] = Vector3(100,0,0);
702 map2["targetValue"] = Vector3(0,100,0);
703 map2["animator"] = Property::Map()
704 .Add("alphaFunction", "EASE_IN_OUT")
705 .Add("timePeriod", Property::Map()
707 .Add("duration", 1.0f));
710 map3["target"] = "Actor1";
711 map3["property"] = "orientation";
712 map3["targetValue"] = Quaternion( Radian(Math::PI_2), Vector3::ZAXIS );
714 Property::Array array;
715 array.PushBack(map1);
716 array.PushBack(map2);
717 array.PushBack(map3);
719 Dali::Toolkit::TransitionData transition = TransitionData::New( array );
721 DummyControl actor = DummyControl::New();
722 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
723 actor.SetName("Actor1");
724 actor.SetColor(Color::CYAN);
725 Stage::GetCurrent().Add(actor);
726 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0), Vector3::ZAXIS), TEST_LOCATION);
728 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
729 Animation anim = dummyImpl.CreateTransition( transition );
730 DALI_TEST_CHECK( anim );
731 application.SendNotification();
732 application.Render(0);
733 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION);
734 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(Math::PI_2), Vector3::ZAXIS), TEST_LOCATION);
737 application.SendNotification();
738 application.Render(0); // start map2 anim
739 application.SendNotification();
740 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100,0,0), TEST_LOCATION);
742 application.Render(500); // Start map1 animation, halfway thru map2 anim
743 application.SendNotification();
744 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(50,50,0), TEST_LOCATION);
746 application.Render(500); // Halfway thru map1 anim, end of map2 anim
747 application.SendNotification();
748 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0,100,0), TEST_LOCATION);
749 DALI_TEST_EQUALS( actor.GetCurrentColor(), (Color::MAGENTA+Color::RED)*0.5f, TEST_LOCATION);
751 application.Render(500); // End of map1 anim
752 application.SendNotification();
753 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::RED, TEST_LOCATION );
759 int UtcDaliTransitionDataGetAnimatorP(void)
761 TestApplication application;
764 map1["target"] = "Actor1";
765 map1["property"] = "color";
766 map1["initialValue"] = Color::MAGENTA;
767 map1["targetValue"] = Color::RED;
768 map1["animator"] = Property::Map()
769 .Add("alphaFunction", "EASE_IN_SQUARE")
770 .Add("timePeriod", Property::Map()
772 .Add("duration", 0.5f));
775 map2["target"] = "Actor1";
776 map2["property"] = "position";
777 map2["initialValue"] = Vector3(100,0,0);
778 map2["targetValue"] = Vector3(0,100,0);
779 map2["animator"] = Property::Map()
780 .Add("alphaFunction", "EASE_OUT_SQUARE")
781 .Add("timePeriod", Property::Map()
783 .Add("duration", 2.0f));
786 map3["target"] = "Actor1";
787 map3["property"] = "size";
788 map3["initialValue"] = Vector2(10,10);
789 map3["targetValue"] = Vector2(100,100);
790 map3["animator"] = Property::Map()
791 .Add("alphaFunction", "EASE_OUT_SINE")
792 .Add("timePeriod", Property::Map()
794 .Add("duration", 3.0f));
797 map4["target"] = "Actor2";
798 map4["property"] = "color";
799 map4["initialValue"] = Color::BLACK;
800 map4["targetValue"] = Color::GREEN;
801 map4["animator"] = Property::Map()
802 .Add("alphaFunction", "EASE_IN_OUT_SINE")
803 .Add("timePeriod", Property::Map()
805 .Add("duration", 0.5f));
808 map5["target"] = "Actor2";
809 map5["property"] = "position";
810 map5["initialValue"] = Vector3(100,0,0);
811 map5["targetValue"] = Vector3(0,100,0);
812 map5["animator"] = Property::Map()
813 .Add("alphaFunction", "BOUNCE")
814 .Add("timePeriod", Property::Map()
816 .Add("duration", 2.0f));
819 map6["target"] = "Actor2";
820 map6["property"] = "size";
821 map6["initialValue"] = Vector2(10,10);
822 map6["targetValue"] = Vector2(100,100);
823 map6["animator"] = Property::Map()
824 .Add("alphaFunction", "SIN")
825 .Add("timePeriod", Property::Map()
827 .Add("duration", 3.0f));
830 map7["target"] = "Actor4";
831 map7["property"] = "sizeModeFactor";
832 map7["initialValue"] = Vector3(1,1,1);
833 map7["targetValue"] = Vector3(2,2,2);
834 map7["animator"] = Property::Map()
835 .Add("alphaFunction", "EASE_IN_SINE")
836 .Add("timePeriod", Property::Map()
838 .Add("duration", 1.0f));
841 map8["target"] = "Visual1";
842 map8["property"] = "colorAlpha";
843 map8["targetValue"] = 1.0f;
844 map8["animator"] = Property::Map()
845 .Add("alphaFunction", "EASE_IN")
846 .Add("timePeriod", Property::Map()
848 .Add("duration", 9.0f));
851 map9["target"] = "Actor2";
852 map9["property"] = "scale";
853 map9["initialValue"] = Vector3(0,0,0);
854 map9["targetValue"] = Vector3(1,1,1);
855 map9["animator"] = Property::Map()
856 .Add("alphaFunction", "REVERSE")
857 .Add("timePeriod", Property::Map()
859 .Add("duration", 1.0f));
862 map10["target"] = "Actor2";
863 map10["property"] = "scale";
864 map10["initialValue"] = Vector3(0,0,0);
865 map10["targetValue"] = Vector3(1,1,1);
866 map10["animator"] = Property::Map()
867 .Add("alphaFunction", Vector4(.23,.4,.8,1.2))
868 .Add("timePeriod", Property::Map()
870 .Add("duration", 1.0f));
873 map11["target"] = "Actor2";
874 map11["property"] = "scale";
875 map11["initialValue"] = Vector3(0,0,0);
876 map11["targetValue"] = Vector3(1,1,1);
877 map11["animator"] = Property::Map()
878 .Add("alphaFunction", Property::Array().Add(.23f).Add(.4f).Add(.8f).Add(.2f))
879 .Add("timePeriod", Property::Map()
881 .Add("duration", 1.0f));
884 map12["target"] = "Actor1";
885 map12["property"] = "orientation";
886 map12["targetValue"] = Quaternion( Radian(Math::PI_2), Vector3::ZAXIS );
888 Property::Array array;
889 array.PushBack(map1);
890 array.PushBack(map2);
891 array.PushBack(map3);
892 array.PushBack(map4);
893 array.PushBack(map5);
894 array.PushBack(map6);
895 array.PushBack(map7);
896 array.PushBack(map8);
897 array.PushBack(map9);
898 array.PushBack(map10);
899 array.PushBack(map11);
900 array.PushBack(map12);
902 Dali::Toolkit::TransitionData transition = TransitionData::New( array );
904 DALI_TEST_EQUALS( transition.Count(), array.Count(), TEST_LOCATION );
906 for( unsigned int i=0; i < array.Count(); ++i )
908 Property::Map animatorMap = transition.GetAnimatorAt(i);
909 Property::Value& value = array.GetElementAt(i);
910 Property::Map* inputMap = value.GetMap();
911 DALI_TEST_CHECK( inputMap );
912 CHECK_MAP_EQUALS( *inputMap, animatorMap );