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(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 = DevelHandle::GetPropertyIndex( renderer, 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 );
340 int UtcDaliTransitionDataMap3P(void)
342 TestApplication application;
344 tet_printf("Testing animation of an actor's position property using bezier curve\n");
347 map["target"] = "Actor1";
348 map["property"] = "position";
349 map["initialValue"] = Vector3(0, 0, 0);
350 map["targetValue"] = Vector3(100, 100, 0);
351 map["animator"] = Property::Map()
352 .Add("alphaFunction", Vector4(0.71, -0.57, 0.42, 1.38) )
353 .Add("timePeriod", Property::Map()
355 .Add("duration", 1.0f));
357 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
359 DummyControl actor = DummyControl::New();
360 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
361 actor.SetName("Actor1");
362 Stage::GetCurrent().Add(actor);
364 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
365 Animation anim = dummyImpl.CreateTransition( transition );
366 DALI_TEST_CHECK( anim );
368 application.SendNotification();
369 application.Render(0);
370 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0,0,0), 0.001f, TEST_LOCATION);
374 application.SendNotification();
375 application.Render(0);
377 application.Render(250); // 25%
378 application.SendNotification();
379 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%
381 application.Render(250); // Halfway thru map1 anim
382 application.SendNotification();
383 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%
385 application.Render(250); // End of map1 anim
386 application.SendNotification();
387 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
389 application.Render(250); // End of map1 anim
390 application.SendNotification();
391 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100,100,0), TEST_LOCATION );
396 int UtcDaliTransitionDataMap4P(void)
398 TestApplication application;
400 tet_printf("Testing animation of a visual's transform property using programmatic maps\n");
403 map1["target"] = "testVisual";
404 map1["property"] = "offset";
405 map1["initialValue"] = Vector2(0.0f, 0.0f);
406 map1["targetValue"] = Vector2(100.0f, 100.0f);
407 map1["animator"] = Property::Map()
408 .Add("alphaFunction", "LINEAR")
409 .Add("timePeriod", Property::Map()
411 .Add("duration", 1.0f));
414 map2["target"] = "testVisual";
415 map2["property"] = "size";
416 map2["initialValue"] = Vector2(10.0f, 10.0f);
417 map2["targetValue"] = Vector2(110.0f, 110.0f);
418 map2["animator"] = Property::Map()
419 .Add("alphaFunction", "LINEAR")
420 .Add("timePeriod", Property::Map()
422 .Add("duration", 1.0f));
424 Dali::Toolkit::TransitionData transition = TransitionData::New( Property::Array().Add(map1).Add(map2) );
426 DummyControl actor = DummyControl::New();
427 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
428 actor.SetName("Actor1");
429 Stage::GetCurrent().Add(actor);
431 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
433 Property::Map visualMap;
434 visualMap[Visual::Property::TYPE] = Visual::COLOR;
435 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
436 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
438 visual.SetName( "testVisual" );
439 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
441 Animation anim = dummyImpl.CreateTransition( transition );
442 DALI_TEST_CHECK( anim );
444 Renderer renderer = actor.GetRendererAt(0);
445 Property::Index sizeIndex = renderer.GetPropertyIndex( "size" );
446 application.SendNotification();
447 application.Render(0);
449 DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(sizeIndex), Vector2(10.0f, 10.0f), TEST_LOCATION);
453 application.SendNotification();
454 application.Render(0);
455 application.Render(500); // Start animation
456 application.Render(500); // Halfway thru anim
457 application.SendNotification();
458 DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(sizeIndex), Vector2(60.0f, 60.0f), TEST_LOCATION);
460 application.Render(500); // End of anim
461 application.SendNotification();
462 DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(sizeIndex), Vector2(110.0f, 110.0f), TEST_LOCATION );
468 int UtcDaliTransitionDataMap1N(void)
470 TestApplication application;
473 map["target"] = "Actor1";
474 map["property"] = "randomProperty";
475 map["initialValue"] = Color::MAGENTA;
476 map["targetValue"] = Color::RED;
477 map["animator"] = Property::Map()
478 .Add("alphaFunction", "EASE_OUT")
479 .Add("timePeriod", Property::Map()
481 .Add("duration", 1.0f));
483 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
485 DummyControl actor = DummyControl::New();
486 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
487 actor.SetName("Actor1");
488 actor.SetColor(Color::CYAN);
489 Stage::GetCurrent().Add(actor);
491 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
492 Animation anim = dummyImpl.CreateTransition( transition );
493 DALI_TEST_CHECK( ! anim );
495 CHECK_MAP_EQUALS( map, transition.GetAnimatorAt(0) );
500 int UtcDaliTransitionDataMapN3(void)
502 TestApplication application;
504 tet_printf("Testing visual lookup with no renderers\n");
507 map["target"] = "visual1";
508 map["property"] = "mixColor";
509 map["initialValue"] = Color::MAGENTA;
510 map["targetValue"] = Color::RED;
511 map["animator"] = Property::Map()
512 .Add("alphaFunction", "EASE_OUT_BACK")
513 .Add("timePeriod", Property::Map()
515 .Add("duration", 1.0f));
517 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
518 CHECK_MAP_EQUALS( map, transition.GetAnimatorAt(0) );
520 DummyControl actor = DummyControl::New();
521 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
522 actor.SetName("Actor1");
523 actor.SetColor(Color::CYAN);
526 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
527 Property::Map visualMap;
528 visualMap[Visual::Property::TYPE] = Visual::COLOR;
529 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
530 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
531 visual.SetName( "visual1" );
533 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
534 dummyImpl.RegisterVisual( visualIndex, visual );
536 Animation anim = dummyImpl.CreateTransition( transition );
537 DALI_TEST_CHECK( !anim );
542 int UtcDaliTransitionDataMapN4(void)
544 TestApplication application;
546 tet_printf("Testing visual doesn't animate with duff bezier data \n");
549 map["target"] = "visual1";
550 map["property"] = "mixColor";
551 map["initialValue"] = Color::MAGENTA;
552 map["targetValue"] = Color::RED;
553 map["animator"] = Property::Map()
554 .Add("alphaFunction", Vector3(.1f,1.0f,0.5f))
555 .Add("timePeriod", Property::Map()
557 .Add("duration", 1.0f));
559 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
561 DummyControl actor = DummyControl::New();
562 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
563 actor.SetName("Actor1");
564 actor.SetColor(Color::CYAN);
565 Stage::GetCurrent().Add(actor);
567 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
568 Property::Map visualMap;
569 visualMap[Visual::Property::TYPE] = Visual::COLOR;
570 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
571 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
572 visual.SetName( "visual1" );
574 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
575 dummyImpl.RegisterVisual( visualIndex, visual );
577 Animation anim = dummyImpl.CreateTransition( transition );
578 DALI_TEST_CHECK( !anim );
580 application.SendNotification();
581 application.Render(0);
582 application.SendNotification();
584 Renderer renderer = actor.GetRendererAt(0);
585 Property::Index mixColorIdx = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
587 tet_printf( "Test that the property has been set to target value\n");
588 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
593 int UtcDaliTransitionDataMapN5(void)
595 TestApplication application;
597 tet_printf("Testing visual doesn't animate with duff bezier data \n");
600 map["target"] = "visual1";
601 map["property"] = "mixColor";
602 map["initialValue"] = Color::MAGENTA;
603 map["targetValue"] = Color::RED;
604 map["animator"] = Property::Map()
605 .Add("alphaFunction", Property::Array().Add(.1f).Add(1.0f).Add(0.5f))
606 .Add("timePeriod", Property::Map()
608 .Add("duration", 1.0f));
610 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
612 DummyControl actor = DummyControl::New();
613 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
614 actor.SetName("Actor1");
615 actor.SetColor(Color::CYAN);
616 Stage::GetCurrent().Add(actor);
618 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
619 Property::Map visualMap;
620 visualMap[Visual::Property::TYPE] = Visual::COLOR;
621 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
622 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
623 visual.SetName( "visual1" );
625 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
626 dummyImpl.RegisterVisual( visualIndex, visual );
628 Animation anim = dummyImpl.CreateTransition( transition );
629 DALI_TEST_CHECK( !anim );
631 application.SendNotification();
632 application.Render(0);
633 application.SendNotification();
635 Renderer renderer = actor.GetRendererAt(0);
636 Property::Index mixColorIdx = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
638 tet_printf( "Test that the property has been set to target value\n");
639 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
644 int UtcDaliTransitionDataMapN6(void)
646 TestApplication application;
648 tet_printf("Testing visual doesn't animate with duff bezier data \n");
651 map["target"] = "visual1";
652 map["property"] = "mixColor";
653 map["initialValue"] = Color::MAGENTA;
654 map["targetValue"] = Color::RED;
655 map["animator"] = Property::Map()
656 .Add("alphaFunction", Property::Array().Add("1").Add("Two").Add("3").Add("4"))
657 .Add("timePeriod", Property::Map()
659 .Add("duration", 1.0f));
661 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
663 DummyControl actor = DummyControl::New();
664 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
665 actor.SetName("Actor1");
666 actor.SetColor(Color::CYAN);
667 Stage::GetCurrent().Add(actor);
669 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
670 Property::Map visualMap;
671 visualMap[Visual::Property::TYPE] = Visual::COLOR;
672 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
673 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
674 visual.SetName( "visual1" );
676 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
677 dummyImpl.RegisterVisual( visualIndex, visual );
679 Animation anim = dummyImpl.CreateTransition( transition );
680 DALI_TEST_CHECK( !anim );
682 application.SendNotification();
683 application.Render(0);
684 application.SendNotification();
686 Renderer renderer = actor.GetRendererAt(0);
687 Property::Index mixColorIdx = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
689 tet_printf( "Test that the property has been set to target value\n");
690 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
696 int UtcDaliTransitionDataArrayP(void)
698 TestApplication application;
701 map1["target"] = "Actor1";
702 map1["property"] = "color";
703 map1["initialValue"] = Color::MAGENTA;
704 map1["targetValue"] = Color::RED;
705 map1["animator"] = Property::Map()
706 .Add("alphaFunction", "EASE_IN_OUT")
707 .Add("timePeriod", Property::Map()
709 .Add("duration", 1.0f));
712 map2["target"] = "Actor1";
713 map2["property"] = "position";
714 map2["initialValue"] = Vector3(100,0,0);
715 map2["targetValue"] = Vector3(0,100,0);
716 map2["animator"] = Property::Map()
717 .Add("alphaFunction", "EASE_IN_OUT")
718 .Add("timePeriod", Property::Map()
720 .Add("duration", 1.0f));
723 map3["target"] = "Actor1";
724 map3["property"] = "orientation";
725 map3["targetValue"] = Quaternion( Radian(Math::PI_2), Vector3::ZAXIS );
727 Property::Array array;
728 array.PushBack(map1);
729 array.PushBack(map2);
730 array.PushBack(map3);
732 Dali::Toolkit::TransitionData transition = TransitionData::New( array );
734 DummyControl actor = DummyControl::New();
735 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
736 actor.SetName("Actor1");
737 actor.SetColor(Color::CYAN);
738 Stage::GetCurrent().Add(actor);
739 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0), Vector3::ZAXIS), TEST_LOCATION);
741 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
742 Animation anim = dummyImpl.CreateTransition( transition );
743 DALI_TEST_CHECK( anim );
744 application.SendNotification();
745 application.Render(0);
746 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION);
747 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(Math::PI_2), Vector3::ZAXIS), TEST_LOCATION);
750 application.SendNotification();
751 application.Render(0); // start map2 anim
752 application.SendNotification();
753 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100,0,0), TEST_LOCATION);
755 application.Render(500); // Start map1 animation, halfway thru map2 anim
756 application.SendNotification();
757 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(50,50,0), TEST_LOCATION);
759 application.Render(500); // Halfway thru map1 anim, end of map2 anim
760 application.SendNotification();
761 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0,100,0), TEST_LOCATION);
762 DALI_TEST_EQUALS( actor.GetCurrentColor(), (Color::MAGENTA+Color::RED)*0.5f, TEST_LOCATION);
764 application.Render(500); // End of map1 anim
765 application.SendNotification();
766 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::RED, TEST_LOCATION );
772 int UtcDaliTransitionDataGetAnimatorP(void)
774 TestApplication application;
777 map1["target"] = "Actor1";
778 map1["property"] = "color";
779 map1["initialValue"] = Color::MAGENTA;
780 map1["targetValue"] = Color::RED;
781 map1["animator"] = Property::Map()
782 .Add("alphaFunction", "EASE_IN_SQUARE")
783 .Add("timePeriod", Property::Map()
785 .Add("duration", 0.5f));
788 map2["target"] = "Actor1";
789 map2["property"] = "position";
790 map2["initialValue"] = Vector3(100,0,0);
791 map2["targetValue"] = Vector3(0,100,0);
792 map2["animator"] = Property::Map()
793 .Add("alphaFunction", "EASE_OUT_SQUARE")
794 .Add("timePeriod", Property::Map()
796 .Add("duration", 2.0f));
799 map3["target"] = "Actor1";
800 map3["property"] = "size";
801 map3["initialValue"] = Vector2(10,10);
802 map3["targetValue"] = Vector2(100,100);
803 map3["animator"] = Property::Map()
804 .Add("alphaFunction", "EASE_OUT_SINE")
805 .Add("timePeriod", Property::Map()
807 .Add("duration", 3.0f));
810 map4["target"] = "Actor2";
811 map4["property"] = "color";
812 map4["initialValue"] = Color::BLACK;
813 map4["targetValue"] = Color::GREEN;
814 map4["animator"] = Property::Map()
815 .Add("alphaFunction", "EASE_IN_OUT_SINE")
816 .Add("timePeriod", Property::Map()
818 .Add("duration", 0.5f));
821 map5["target"] = "Actor2";
822 map5["property"] = "position";
823 map5["initialValue"] = Vector3(100,0,0);
824 map5["targetValue"] = Vector3(0,100,0);
825 map5["animator"] = Property::Map()
826 .Add("alphaFunction", "BOUNCE")
827 .Add("timePeriod", Property::Map()
829 .Add("duration", 2.0f));
832 map6["target"] = "Actor2";
833 map6["property"] = "size";
834 map6["initialValue"] = Vector2(10,10);
835 map6["targetValue"] = Vector2(100,100);
836 map6["animator"] = Property::Map()
837 .Add("alphaFunction", "SIN")
838 .Add("timePeriod", Property::Map()
840 .Add("duration", 3.0f));
843 map7["target"] = "Actor4";
844 map7["property"] = "sizeModeFactor";
845 map7["initialValue"] = Vector3(1,1,1);
846 map7["targetValue"] = Vector3(2,2,2);
847 map7["animator"] = Property::Map()
848 .Add("alphaFunction", "EASE_IN_SINE")
849 .Add("timePeriod", Property::Map()
851 .Add("duration", 1.0f));
854 map8["target"] = "Visual1";
855 map8["property"] = "colorAlpha";
856 map8["targetValue"] = 1.0f;
857 map8["animator"] = Property::Map()
858 .Add("alphaFunction", "EASE_IN")
859 .Add("timePeriod", Property::Map()
861 .Add("duration", 9.0f));
864 map9["target"] = "Actor2";
865 map9["property"] = "scale";
866 map9["initialValue"] = Vector3(0,0,0);
867 map9["targetValue"] = Vector3(1,1,1);
868 map9["animator"] = Property::Map()
869 .Add("alphaFunction", "REVERSE")
870 .Add("timePeriod", Property::Map()
872 .Add("duration", 1.0f));
875 map10["target"] = "Actor2";
876 map10["property"] = "scale";
877 map10["initialValue"] = Vector3(0,0,0);
878 map10["targetValue"] = Vector3(1,1,1);
879 map10["animator"] = Property::Map()
880 .Add("alphaFunction", Vector4(.23,.4,.8,1.2))
881 .Add("timePeriod", Property::Map()
883 .Add("duration", 1.0f));
886 map11["target"] = "Actor2";
887 map11["property"] = "scale";
888 map11["initialValue"] = Vector3(0,0,0);
889 map11["targetValue"] = Vector3(1,1,1);
890 map11["animator"] = Property::Map()
891 .Add("alphaFunction", Property::Array().Add(.23f).Add(.4f).Add(.8f).Add(.2f))
892 .Add("timePeriod", Property::Map()
894 .Add("duration", 1.0f));
897 map12["target"] = "Actor1";
898 map12["property"] = "orientation";
899 map12["targetValue"] = Quaternion( Radian(Math::PI_2), Vector3::ZAXIS );
901 Property::Array array;
902 array.PushBack(map1);
903 array.PushBack(map2);
904 array.PushBack(map3);
905 array.PushBack(map4);
906 array.PushBack(map5);
907 array.PushBack(map6);
908 array.PushBack(map7);
909 array.PushBack(map8);
910 array.PushBack(map9);
911 array.PushBack(map10);
912 array.PushBack(map11);
913 array.PushBack(map12);
915 Dali::Toolkit::TransitionData transition = TransitionData::New( array );
917 DALI_TEST_EQUALS( transition.Count(), array.Count(), TEST_LOCATION );
919 for( unsigned int i=0; i < array.Count(); ++i )
921 Property::Map animatorMap = transition.GetAnimatorAt(i);
922 Property::Value& value = array.GetElementAt(i);
923 Property::Map* inputMap = value.GetMap();
924 DALI_TEST_CHECK( inputMap );
925 CHECK_MAP_EQUALS( *inputMap, animatorMap );