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 );
341 int UtcDaliTransitionDataMap3P(void)
343 TestApplication application;
345 tet_printf("Testing animation of an actor's position property using bezier curve\n");
348 map["target"] = "Actor1";
349 map["property"] = "position";
350 map["initialValue"] = Vector3(0, 0, 0);
351 map["targetValue"] = Vector3(100, 100, 0);
352 map["animator"] = Property::Map()
353 .Add("alphaFunction", Vector4(0.71, -0.57, 0.42, 1.38) )
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 Stage::GetCurrent().Add(actor);
365 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
366 Animation anim = dummyImpl.CreateTransition( transition );
367 DALI_TEST_CHECK( anim );
369 application.SendNotification();
370 application.Render(0);
371 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0,0,0), 0.001f, TEST_LOCATION);
375 application.SendNotification();
376 application.Render(0);
378 application.Render(250); // 25%
379 application.SendNotification();
380 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%
382 application.Render(250); // Halfway thru map1 anim
383 application.SendNotification();
384 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%
386 application.Render(250); // End of map1 anim
387 application.SendNotification();
388 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
390 application.Render(250); // End of map1 anim
391 application.SendNotification();
392 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100,100,0), TEST_LOCATION );
397 int UtcDaliTransitionDataMap4P(void)
399 TestApplication application;
401 tet_printf("Testing animation of a visual's transform property using programmatic maps\n");
404 map1["target"] = "testVisual";
405 map1["property"] = "offset";
406 map1["initialValue"] = Vector2(0.0f, 0.0f);
407 map1["targetValue"] = Vector2(100.0f, 100.0f);
408 map1["animator"] = Property::Map()
409 .Add("alphaFunction", "LINEAR")
410 .Add("timePeriod", Property::Map()
412 .Add("duration", 1.0f));
415 map2["target"] = "testVisual";
416 map2["property"] = "size";
417 map2["initialValue"] = Vector2(10.0f, 10.0f);
418 map2["targetValue"] = Vector2(110.0f, 110.0f);
419 map2["animator"] = Property::Map()
420 .Add("alphaFunction", "LINEAR")
421 .Add("timePeriod", Property::Map()
423 .Add("duration", 1.0f));
425 Dali::Toolkit::TransitionData transition = TransitionData::New( Property::Array().Add(map1).Add(map2) );
427 DummyControl actor = DummyControl::New();
428 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
429 actor.SetName("Actor1");
430 Stage::GetCurrent().Add(actor);
432 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
434 Property::Map visualMap;
435 visualMap[Visual::Property::TYPE] = Visual::COLOR;
436 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
437 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
439 visual.SetName( "testVisual" );
440 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
442 Animation anim = dummyImpl.CreateTransition( transition );
443 DALI_TEST_CHECK( anim );
445 Renderer renderer = actor.GetRendererAt(0);
446 Property::Index sizeIndex = renderer.GetPropertyIndex( "size" );
447 application.SendNotification();
448 application.Render(0);
450 DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(sizeIndex), Vector2(10.0f, 10.0f), TEST_LOCATION);
454 application.SendNotification();
455 application.Render(0);
456 application.Render(500); // Start animation
457 application.Render(500); // Halfway thru anim
458 application.SendNotification();
459 DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(sizeIndex), Vector2(60.0f, 60.0f), TEST_LOCATION);
461 application.Render(500); // End of anim
462 application.SendNotification();
463 DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(sizeIndex), Vector2(110.0f, 110.0f), TEST_LOCATION );
469 int UtcDaliTransitionDataMap1N(void)
471 TestApplication application;
474 map["target"] = "Actor1";
475 map["property"] = "randomProperty";
476 map["initialValue"] = Color::MAGENTA;
477 map["targetValue"] = Color::RED;
478 map["animator"] = Property::Map()
479 .Add("alphaFunction", "EASE_OUT")
480 .Add("timePeriod", Property::Map()
482 .Add("duration", 1.0f));
484 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
486 DummyControl actor = DummyControl::New();
487 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
488 actor.SetName("Actor1");
489 actor.SetColor(Color::CYAN);
490 Stage::GetCurrent().Add(actor);
492 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
493 Animation anim = dummyImpl.CreateTransition( transition );
494 DALI_TEST_CHECK( ! anim );
496 CHECK_MAP_EQUALS( map, transition.GetAnimatorAt(0) );
501 int UtcDaliTransitionDataMapN3(void)
503 TestApplication application;
505 tet_printf("Testing visual lookup with no renderers\n");
508 map["target"] = "visual1";
509 map["property"] = "mixColor";
510 map["initialValue"] = Color::MAGENTA;
511 map["targetValue"] = Color::RED;
512 map["animator"] = Property::Map()
513 .Add("alphaFunction", "EASE_OUT_BACK")
514 .Add("timePeriod", Property::Map()
516 .Add("duration", 1.0f));
518 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
519 CHECK_MAP_EQUALS( map, transition.GetAnimatorAt(0) );
521 DummyControl actor = DummyControl::New();
522 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
523 actor.SetName("Actor1");
524 actor.SetColor(Color::CYAN);
527 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
528 Property::Map visualMap;
529 visualMap[Visual::Property::TYPE] = Visual::COLOR;
530 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
531 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
532 visual.SetName( "visual1" );
534 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
535 dummyImpl.RegisterVisual( visualIndex, visual );
537 Animation anim = dummyImpl.CreateTransition( transition );
538 DALI_TEST_CHECK( !anim );
543 int UtcDaliTransitionDataMapN4(void)
545 TestApplication application;
547 tet_printf("Testing visual doesn't animate with duff bezier data \n");
550 map["target"] = "visual1";
551 map["property"] = "mixColor";
552 map["initialValue"] = Color::MAGENTA;
553 map["targetValue"] = Color::RED;
554 map["animator"] = Property::Map()
555 .Add("alphaFunction", Vector3(.1f,1.0f,0.5f))
556 .Add("timePeriod", Property::Map()
558 .Add("duration", 1.0f));
560 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
562 DummyControl actor = DummyControl::New();
563 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
564 actor.SetName("Actor1");
565 actor.SetColor(Color::CYAN);
566 Stage::GetCurrent().Add(actor);
568 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
569 Property::Map visualMap;
570 visualMap[Visual::Property::TYPE] = Visual::COLOR;
571 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
572 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
573 visual.SetName( "visual1" );
575 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
576 dummyImpl.RegisterVisual( visualIndex, visual );
578 Animation anim = dummyImpl.CreateTransition( transition );
579 DALI_TEST_CHECK( !anim );
581 application.SendNotification();
582 application.Render(0);
583 application.SendNotification();
585 Renderer renderer = actor.GetRendererAt(0);
586 Property::Index mixColorIdx = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
588 tet_printf( "Test that the property has been set to target value\n");
589 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
594 int UtcDaliTransitionDataMapN5(void)
596 TestApplication application;
598 tet_printf("Testing visual doesn't animate with duff bezier data \n");
601 map["target"] = "visual1";
602 map["property"] = "mixColor";
603 map["initialValue"] = Color::MAGENTA;
604 map["targetValue"] = Color::RED;
605 map["animator"] = Property::Map()
606 .Add("alphaFunction", Property::Array().Add(.1f).Add(1.0f).Add(0.5f))
607 .Add("timePeriod", Property::Map()
609 .Add("duration", 1.0f));
611 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
613 DummyControl actor = DummyControl::New();
614 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
615 actor.SetName("Actor1");
616 actor.SetColor(Color::CYAN);
617 Stage::GetCurrent().Add(actor);
619 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
620 Property::Map visualMap;
621 visualMap[Visual::Property::TYPE] = Visual::COLOR;
622 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
623 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
624 visual.SetName( "visual1" );
626 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
627 dummyImpl.RegisterVisual( visualIndex, visual );
629 Animation anim = dummyImpl.CreateTransition( transition );
630 DALI_TEST_CHECK( !anim );
632 application.SendNotification();
633 application.Render(0);
634 application.SendNotification();
636 Renderer renderer = actor.GetRendererAt(0);
637 Property::Index mixColorIdx = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
639 tet_printf( "Test that the property has been set to target value\n");
640 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
645 int UtcDaliTransitionDataMapN6(void)
647 TestApplication application;
649 tet_printf("Testing visual doesn't animate with duff bezier data \n");
652 map["target"] = "visual1";
653 map["property"] = "mixColor";
654 map["initialValue"] = Color::MAGENTA;
655 map["targetValue"] = Color::RED;
656 map["animator"] = Property::Map()
657 .Add("alphaFunction", Property::Array().Add("1").Add("Two").Add("3").Add("4"))
658 .Add("timePeriod", Property::Map()
660 .Add("duration", 1.0f));
662 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
664 DummyControl actor = DummyControl::New();
665 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
666 actor.SetName("Actor1");
667 actor.SetColor(Color::CYAN);
668 Stage::GetCurrent().Add(actor);
670 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
671 Property::Map visualMap;
672 visualMap[Visual::Property::TYPE] = Visual::COLOR;
673 visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
674 Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
675 visual.SetName( "visual1" );
677 Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
678 dummyImpl.RegisterVisual( visualIndex, visual );
680 Animation anim = dummyImpl.CreateTransition( transition );
681 DALI_TEST_CHECK( !anim );
683 application.SendNotification();
684 application.Render(0);
685 application.SendNotification();
687 Renderer renderer = actor.GetRendererAt(0);
688 Property::Index mixColorIdx = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
690 tet_printf( "Test that the property has been set to target value\n");
691 DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
697 int UtcDaliTransitionDataArrayP(void)
699 TestApplication application;
702 map1["target"] = "Actor1";
703 map1["property"] = "color";
704 map1["initialValue"] = Color::MAGENTA;
705 map1["targetValue"] = Color::RED;
706 map1["animator"] = Property::Map()
707 .Add("alphaFunction", "EASE_IN_OUT")
708 .Add("timePeriod", Property::Map()
710 .Add("duration", 1.0f));
713 map2["target"] = "Actor1";
714 map2["property"] = "position";
715 map2["initialValue"] = Vector3(100,0,0);
716 map2["targetValue"] = Vector3(0,100,0);
717 map2["animator"] = Property::Map()
718 .Add("alphaFunction", "EASE_IN_OUT")
719 .Add("timePeriod", Property::Map()
721 .Add("duration", 1.0f));
724 map3["target"] = "Actor1";
725 map3["property"] = "orientation";
726 map3["targetValue"] = Quaternion( Radian(Math::PI_2), Vector3::ZAXIS );
728 Property::Array array;
729 array.PushBack(map1);
730 array.PushBack(map2);
731 array.PushBack(map3);
733 Dali::Toolkit::TransitionData transition = TransitionData::New( array );
735 DummyControl actor = DummyControl::New();
736 actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
737 actor.SetName("Actor1");
738 actor.SetColor(Color::CYAN);
739 Stage::GetCurrent().Add(actor);
740 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0), Vector3::ZAXIS), TEST_LOCATION);
742 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
743 Animation anim = dummyImpl.CreateTransition( transition );
744 DALI_TEST_CHECK( anim );
745 application.SendNotification();
746 application.Render(0);
747 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION);
748 DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(Math::PI_2), Vector3::ZAXIS), TEST_LOCATION);
751 application.SendNotification();
752 application.Render(0); // start map2 anim
753 application.SendNotification();
754 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100,0,0), TEST_LOCATION);
756 application.Render(500); // Start map1 animation, halfway thru map2 anim
757 application.SendNotification();
758 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(50,50,0), TEST_LOCATION);
760 application.Render(500); // Halfway thru map1 anim, end of map2 anim
761 application.SendNotification();
762 DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0,100,0), TEST_LOCATION);
763 DALI_TEST_EQUALS( actor.GetCurrentColor(), (Color::MAGENTA+Color::RED)*0.5f, TEST_LOCATION);
765 application.Render(500); // End of map1 anim
766 application.SendNotification();
767 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::RED, TEST_LOCATION );
773 int UtcDaliTransitionDataGetAnimatorP(void)
775 TestApplication application;
778 map1["target"] = "Actor1";
779 map1["property"] = "color";
780 map1["initialValue"] = Color::MAGENTA;
781 map1["targetValue"] = Color::RED;
782 map1["animator"] = Property::Map()
783 .Add("alphaFunction", "EASE_IN_SQUARE")
784 .Add("timePeriod", Property::Map()
786 .Add("duration", 0.5f));
789 map2["target"] = "Actor1";
790 map2["property"] = "position";
791 map2["initialValue"] = Vector3(100,0,0);
792 map2["targetValue"] = Vector3(0,100,0);
793 map2["animator"] = Property::Map()
794 .Add("alphaFunction", "EASE_OUT_SQUARE")
795 .Add("timePeriod", Property::Map()
797 .Add("duration", 2.0f));
800 map3["target"] = "Actor1";
801 map3["property"] = "size";
802 map3["initialValue"] = Vector2(10,10);
803 map3["targetValue"] = Vector2(100,100);
804 map3["animator"] = Property::Map()
805 .Add("alphaFunction", "EASE_OUT_SINE")
806 .Add("timePeriod", Property::Map()
808 .Add("duration", 3.0f));
811 map4["target"] = "Actor2";
812 map4["property"] = "color";
813 map4["initialValue"] = Color::BLACK;
814 map4["targetValue"] = Color::GREEN;
815 map4["animator"] = Property::Map()
816 .Add("alphaFunction", "EASE_IN_OUT_SINE")
817 .Add("timePeriod", Property::Map()
819 .Add("duration", 0.5f));
822 map5["target"] = "Actor2";
823 map5["property"] = "position";
824 map5["initialValue"] = Vector3(100,0,0);
825 map5["targetValue"] = Vector3(0,100,0);
826 map5["animator"] = Property::Map()
827 .Add("alphaFunction", "BOUNCE")
828 .Add("timePeriod", Property::Map()
830 .Add("duration", 2.0f));
833 map6["target"] = "Actor2";
834 map6["property"] = "size";
835 map6["initialValue"] = Vector2(10,10);
836 map6["targetValue"] = Vector2(100,100);
837 map6["animator"] = Property::Map()
838 .Add("alphaFunction", "SIN")
839 .Add("timePeriod", Property::Map()
841 .Add("duration", 3.0f));
844 map7["target"] = "Actor4";
845 map7["property"] = "sizeModeFactor";
846 map7["initialValue"] = Vector3(1,1,1);
847 map7["targetValue"] = Vector3(2,2,2);
848 map7["animator"] = Property::Map()
849 .Add("alphaFunction", "EASE_IN_SINE")
850 .Add("timePeriod", Property::Map()
852 .Add("duration", 1.0f));
855 map8["target"] = "Visual1";
856 map8["property"] = "colorAlpha";
857 map8["targetValue"] = 1.0f;
858 map8["animator"] = Property::Map()
859 .Add("alphaFunction", "EASE_IN")
860 .Add("timePeriod", Property::Map()
862 .Add("duration", 9.0f));
865 map9["target"] = "Actor2";
866 map9["property"] = "scale";
867 map9["initialValue"] = Vector3(0,0,0);
868 map9["targetValue"] = Vector3(1,1,1);
869 map9["animator"] = Property::Map()
870 .Add("alphaFunction", "REVERSE")
871 .Add("timePeriod", Property::Map()
873 .Add("duration", 1.0f));
876 map10["target"] = "Actor2";
877 map10["property"] = "scale";
878 map10["initialValue"] = Vector3(0,0,0);
879 map10["targetValue"] = Vector3(1,1,1);
880 map10["animator"] = Property::Map()
881 .Add("alphaFunction", Vector4(.23,.4,.8,1.2))
882 .Add("timePeriod", Property::Map()
884 .Add("duration", 1.0f));
887 map11["target"] = "Actor2";
888 map11["property"] = "scale";
889 map11["initialValue"] = Vector3(0,0,0);
890 map11["targetValue"] = Vector3(1,1,1);
891 map11["animator"] = Property::Map()
892 .Add("alphaFunction", Property::Array().Add(.23f).Add(.4f).Add(.8f).Add(.2f))
893 .Add("timePeriod", Property::Map()
895 .Add("duration", 1.0f));
898 map12["target"] = "Actor1";
899 map12["property"] = "orientation";
900 map12["targetValue"] = Quaternion( Radian(Math::PI_2), Vector3::ZAXIS );
902 Property::Array array;
903 array.PushBack(map1);
904 array.PushBack(map2);
905 array.PushBack(map3);
906 array.PushBack(map4);
907 array.PushBack(map5);
908 array.PushBack(map6);
909 array.PushBack(map7);
910 array.PushBack(map8);
911 array.PushBack(map9);
912 array.PushBack(map10);
913 array.PushBack(map11);
914 array.PushBack(map12);
916 Dali::Toolkit::TransitionData transition = TransitionData::New( array );
918 DALI_TEST_EQUALS( transition.Count(), array.Count(), TEST_LOCATION );
920 for( unsigned int i=0; i < array.Count(); ++i )
922 Property::Map animatorMap = transition.GetAnimatorAt(i);
923 Property::Value& value = array.GetElementAt(i);
924 Property::Map* inputMap = value.GetMap();
925 DALI_TEST_CHECK( inputMap );
926 CHECK_MAP_EQUALS( *inputMap, animatorMap );