2 * Copyright (c) 2018 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>
20 #include <toolkit-timer.h>
21 #include <toolkit-event-thread-callback.h>
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
24 #include <dali-toolkit/devel-api/controls/control-devel.h>
25 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
26 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
27 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-actions-devel.h>
28 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-signals-devel.h>
29 #include "dummy-control.h"
32 using namespace Dali::Toolkit;
34 void dali_animated_vector_image_visual_startup(void)
36 test_return_value = TET_UNDEF;
39 void dali_animated_vector_image_visual_cleanup(void)
41 test_return_value = TET_PASS;
47 const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
49 bool gAnimationFinishedSignalFired = false;
51 void VisualEventSignal( Control control, Dali::Property::Index visualIndex, Dali::Property::Index signalId )
53 if( visualIndex == DummyControl::Property::TEST_VISUAL && signalId == DevelAnimatedVectorImageVisual::Signal::ANIMATION_FINISHED )
55 gAnimationFinishedSignalFired = true;
61 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void)
63 ToolkitTestApplication application;
64 tet_infoline( "UtcDaliVisualFactoryGetAnimatedVectorImageVisual01: Request animated vector image visual with a json url" );
66 VisualFactory factory = VisualFactory::Get();
67 Visual::Base visual = factory.CreateVisual( TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions() );
68 DALI_TEST_CHECK( visual );
70 DummyControl actor = DummyControl::New( true );
71 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
72 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
73 actor.SetSize( 200.0f, 200.0f );
74 Stage::GetCurrent().Add( actor );
76 application.SendNotification();
79 // Wait for resource ready event callback
80 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
82 // renderer is added to actor
83 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
84 Renderer renderer = actor.GetRendererAt( 0u );
85 DALI_TEST_CHECK( renderer );
87 // Test SetOffStage().
89 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
94 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual02(void)
96 ToolkitTestApplication application;
97 tet_infoline( "UtcDaliVisualFactoryGetAnimatedVectorImageVisual02: Request animated vector image visual with a Property::Map" );
99 Property::Map propertyMap;
100 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
101 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME );
103 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
104 DALI_TEST_CHECK( visual );
106 DummyControl actor = DummyControl::New( true );
107 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
108 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
109 actor.SetSize( 200.0f, 200.0f );
110 Stage::GetCurrent().Add( actor );
112 application.SendNotification();
113 application.Render();
115 // Wait for resource ready event callback
116 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
118 // renderer is added to actor
119 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
120 Renderer renderer = actor.GetRendererAt( 0u );
121 DALI_TEST_CHECK( renderer );
124 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
129 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void)
131 ToolkitTestApplication application;
132 tet_infoline( "UtcDaliVisualFactoryGetAnimatedVectorImageVisual03: Request animated vector image visual with a Property::Map" );
134 Property::Map propertyMap;
135 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
136 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
137 .Add( DevelImageVisual::Property::LOOP_COUNT, 3 )
138 .Add( DevelImageVisual::Property::PLAY_RANGE, Vector2( 0.2f, 0.8f ) );
140 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
141 DALI_TEST_CHECK( visual );
143 DummyControl actor = DummyControl::New( true );
144 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
145 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
146 actor.SetSize( 200.0f, 200.0f );
147 Stage::GetCurrent().Add( actor );
149 application.SendNotification();
150 application.Render();
152 // Wait for resource ready event callback
153 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
155 // renderer is added to actor
156 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
157 Renderer renderer = actor.GetRendererAt( 0u );
158 DALI_TEST_CHECK( renderer );
161 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
166 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void)
168 ToolkitTestApplication application;
169 tet_infoline( "UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map" );
171 Property::Map propertyMap;
172 propertyMap.Add( "visualType", DevelVisual::ANIMATED_VECTOR_IMAGE )
173 .Add( "url", TEST_VECTOR_IMAGE_FILE_NAME )
174 .Add( "loopCount", 3 )
175 .Add( "playRange", Vector2( 0.2f, 0.8f ) );
177 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
178 DALI_TEST_CHECK( visual );
180 DummyControl actor = DummyControl::New( true );
181 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
182 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
183 actor.SetSize( 200.0f, 200.0f );
184 Stage::GetCurrent().Add( actor );
186 application.SendNotification();
187 application.Render();
189 // Wait for resource ready event callback
190 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
192 // renderer is added to actor
193 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
194 Renderer renderer = actor.GetRendererAt( 0u );
195 DALI_TEST_CHECK( renderer );
198 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
203 int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
205 ToolkitTestApplication application;
206 tet_infoline( "UtcDaliAnimatedVectorImageVisualGetPropertyMap01" );
208 Vector2 playRange( 0.2f, 0.8f );
210 Property::Map propertyMap;
211 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
212 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
213 .Add( DevelImageVisual::Property::LOOP_COUNT, 3 )
214 .Add( DevelImageVisual::Property::PLAY_RANGE, playRange );
216 // request AnimatedVectorImageVisual with a property map
217 VisualFactory factory = VisualFactory::Get();
218 Visual::Base visual = factory.CreateVisual( propertyMap );
220 Property::Map resultMap;
221 visual.CreatePropertyMap( resultMap );
223 // check the property values from the returned map from a visual
224 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
225 DALI_TEST_CHECK( value );
226 DALI_TEST_CHECK( value->Get< int >() == DevelVisual::ANIMATED_VECTOR_IMAGE );
228 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
229 DALI_TEST_CHECK( value );
230 DALI_TEST_CHECK( value->Get< std::string >() == TEST_VECTOR_IMAGE_FILE_NAME );
232 value = resultMap.Find( DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER );
233 DALI_TEST_CHECK( value );
234 DALI_TEST_CHECK( value->Get< int >() == 3 );
236 value = resultMap.Find( DevelImageVisual::Property::PLAY_RANGE, Property::VECTOR2 );
237 DALI_TEST_CHECK( value );
238 DALI_TEST_CHECK( value->Get< Vector2 >() == playRange );
240 // request AnimatedVectorImageVisual with an URL
241 Visual::Base visual2 = factory.CreateVisual( TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions() );
244 visual2.CreatePropertyMap( resultMap );
246 // check the property values from the returned map from a visual
247 value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
248 DALI_TEST_CHECK( value );
249 DALI_TEST_CHECK( value->Get< int >() == DevelVisual::ANIMATED_VECTOR_IMAGE );
251 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
252 DALI_TEST_CHECK( value );
253 DALI_TEST_CHECK( value->Get< std::string >() == TEST_VECTOR_IMAGE_FILE_NAME );
258 int UtcDaliAnimatedVectorImageVisualPlayback(void)
260 ToolkitTestApplication application;
262 tet_infoline( "UtcDaliAnimatedVectorImageVisualPlayback" );
265 // request AnimatedVectorImageVisual with a property map
266 VisualFactory factory = VisualFactory::Get();
267 Visual::Base visual = factory.CreateVisual(
269 .Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
270 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME ) );
272 DummyControl dummyControl = DummyControl::New( true );
273 Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummyControl.GetImplementation() );
274 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
275 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
277 Property::Map attributes;
278 tet_infoline( "Test Play action" );
279 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
281 Stage::GetCurrent().Add( dummyControl );
282 application.SendNotification();
283 application.Render( 16 );
285 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
287 Property::Map map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
288 Property::Value* value = map.Find( DevelImageVisual::Property::PLAY_STATE );
289 DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::PLAYING ) );
291 tet_infoline( "Test Pause action" );
292 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes );
294 application.SendNotification();
295 application.Render(16);
297 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
298 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
299 DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::PAUSED ) );
301 tet_infoline( "Test Play action" );
302 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
304 application.SendNotification();
305 application.Render(16);
307 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
308 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
309 DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::PLAYING ) );
311 tet_infoline( "Test Stop action" );
312 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes );
314 application.SendNotification();
315 application.Render(16);
317 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
318 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
319 DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::STOPPED ) );
321 tet_infoline( "Test Stop action again" );
322 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes );
324 application.SendNotification();
325 application.Render(16);
327 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
328 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
329 DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::STOPPED ) );
331 tet_infoline( "Test Play action" );
332 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
334 application.SendNotification();
335 application.Render(16);
337 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
338 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
339 DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::PLAYING ) );
341 tet_infoline( "Off stage" );
342 dummyControl.Unparent();
344 application.SendNotification();
345 application.Render(16);
347 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
348 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
349 DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::PAUSED ) );
351 tet_infoline( "On stage again" );
352 Stage::GetCurrent().Add( dummyControl );
354 application.SendNotification();
355 application.Render(16);
357 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
358 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
359 DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::PAUSED ) );
361 tet_infoline( "Test Play action" );
362 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
364 application.SendNotification();
365 application.Render(16);
367 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
368 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
369 DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::PLAYING ) );
372 Vector3 newSize( 100.0f, 100.0f, 0.0f );
373 dummyControl.SetSize( newSize );
375 application.SendNotification();
376 application.Render(16);
378 // Size should be changed
379 Vector3 naturalSize = dummyControl.GetNaturalSize();
380 DALI_TEST_CHECK( naturalSize == newSize );
382 dummyControl.Unparent();
388 int UtcDaliAnimatedVectorImageVisualCustomShader(void)
390 ToolkitTestApplication application;
391 tet_infoline( "UtcDaliAnimatedVectorImageVisualCustomShader Test custom shader" );
393 VisualFactory factory = VisualFactory::Get();
394 Property::Map properties;
395 Property::Map shader;
396 const std::string vertexShader = "Foobar";
397 const std::string fragmentShader = "Foobar sampler2D Foobar";
398 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
399 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
401 properties[Visual::Property::TYPE] = Visual::IMAGE;
402 properties[Visual::Property::SHADER] = shader;
403 properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
405 Visual::Base visual = factory.CreateVisual( properties );
407 // trigger creation through setting on stage
408 DummyControl dummy = DummyControl::New( true );
409 Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
410 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
412 dummy.SetSize( 200.f, 200.f );
413 dummy.SetParentOrigin( ParentOrigin::CENTER );
414 Stage::GetCurrent().Add( dummy );
416 application.SendNotification();
417 application.Render();
419 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
421 Renderer renderer = dummy.GetRendererAt( 0 );
422 Shader shader2 = renderer.GetShader();
423 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
424 Property::Map* map = value.GetMap();
425 DALI_TEST_CHECK( map );
427 std::string resultFragmentShader, resultVertexShader;
428 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
429 fragment->Get( resultFragmentShader );
430 DALI_TEST_CHECK( resultFragmentShader.find( fragmentShader ) != std::string::npos );
432 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
433 vertex->Get( resultVertexShader );
434 DALI_TEST_CHECK( resultVertexShader.find( vertexShader ) != std::string::npos );
439 int UtcDaliAnimatedVectorImageVisualNaturalSize(void)
441 ToolkitTestApplication application;
442 tet_infoline( "UtcDaliAnimatedVectorImageVisualNaturalSize" );
444 VisualFactory factory = VisualFactory::Get();
445 Visual::Base visual = factory.CreateVisual( TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions() );
446 DALI_TEST_CHECK( visual );
448 DummyControl actor = DummyControl::New( true );
449 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
450 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
452 Vector2 controlSize( 20.f, 30.f );
455 actor.SetSize( controlSize );
456 Stage::GetCurrent().Add( actor );
458 application.SendNotification();
459 application.Render();
461 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
463 visual.GetNaturalSize( naturalSize );
465 DALI_TEST_EQUALS( naturalSize, controlSize, TEST_LOCATION );
470 int UtcDaliAnimatedVectorImageVisualLoopCount(void)
472 ToolkitTestApplication application;
473 tet_infoline( "UtcDaliAnimatedVectorImageVisualLoopCount" );
475 Property::Map propertyMap;
476 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
477 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
478 .Add( DevelImageVisual::Property::LOOP_COUNT, 3 );
480 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
481 DALI_TEST_CHECK( visual );
483 DummyControl actor = DummyControl::New( true );
484 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
485 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
487 Vector2 controlSize( 20.f, 30.f );
488 actor.SetSize( controlSize );
490 Stage::GetCurrent().Add( actor );
492 Property::Map attributes;
493 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
495 application.SendNotification();
496 application.Render();
498 // Trigger count is 2 - resource ready and animation finished
499 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
501 // renderer is added to actor
502 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
503 Renderer renderer = actor.GetRendererAt( 0u );
504 DALI_TEST_CHECK( renderer );
509 int UtcDaliAnimatedVectorImageVisualPlayRange(void)
511 ToolkitTestApplication application;
512 tet_infoline( "UtcDaliAnimatedVectorImageVisualPlayRange" );
514 Vector2 playRange( 0.8f, 0.2f );
516 Property::Map propertyMap;
517 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
518 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
519 .Add( DevelImageVisual::Property::PLAY_RANGE, playRange );
521 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
522 DALI_TEST_CHECK( visual );
524 DummyControl actor = DummyControl::New( true );
525 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
526 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
528 Vector2 controlSize( 20.f, 30.f );
529 actor.SetSize( controlSize );
531 Stage::GetCurrent().Add( actor );
533 Property::Map attributes;
534 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
536 application.SendNotification();
537 application.Render();
539 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
541 // renderer is added to actor
542 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
543 Renderer renderer = actor.GetRendererAt( 0u );
544 DALI_TEST_CHECK( renderer );
546 Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
547 Property::Value* value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
548 DALI_TEST_EQUALS( value->Get< Vector2 >(), playRange, TEST_LOCATION );
553 int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
555 ToolkitTestApplication application;
556 tet_infoline( "UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal" );
558 Property::Map propertyMap;
559 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
560 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
561 .Add( DevelImageVisual::Property::LOOP_COUNT, 3 );
563 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
564 DALI_TEST_CHECK( visual );
566 DummyControl actor = DummyControl::New( true );
567 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
568 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
570 DevelControl::VisualEventSignal( actor ).Connect( &VisualEventSignal );
572 Vector2 controlSize( 20.f, 30.f );
573 actor.SetSize( controlSize );
575 Stage::GetCurrent().Add( actor );
577 Property::Map attributes;
578 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
580 application.SendNotification();
581 application.Render();
583 // Wait for animation finish
584 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
586 Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
587 Property::Value* value = map.Find( DevelImageVisual::Property::PLAY_STATE );
588 DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::STOPPED ) );
590 DALI_TEST_EQUALS( gAnimationFinishedSignalFired, true, TEST_LOCATION );
595 int UtcDaliAnimatedVectorImageVisualJumpToCurrentProgress(void)
597 ToolkitTestApplication application;
598 tet_infoline( "UtcDaliAnimatedVectorImageVisualJumpToCurrentProgress" );
600 Property::Map propertyMap;
601 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
602 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME );
604 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
605 DALI_TEST_CHECK( visual );
607 DummyControl actor = DummyControl::New( true );
608 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
609 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
611 Vector2 controlSize( 20.f, 30.f );
612 actor.SetSize( controlSize );
614 Stage::GetCurrent().Add( actor );
616 application.SendNotification();
617 application.Render();
619 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
621 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 0.6f );
623 application.SendNotification();
624 application.Render();
626 Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
627 Property::Value* value = map.Find( DevelImageVisual::Property::CURRENT_PROGRESS );
628 DALI_TEST_EQUALS( value->Get< float >(), 0.6f, TEST_LOCATION );
630 Vector2 playRange( 0.0f, 0.4f );
632 Property::Map attributes;
633 attributes.Add( DevelImageVisual::Property::PLAY_RANGE, playRange );
634 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
636 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 0.8f );
638 application.SendNotification();
639 application.Render();
641 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
642 value = map.Find( DevelImageVisual::Property::CURRENT_PROGRESS );
643 DALI_TEST_EQUALS( value->Get< float >(), 0.4f, TEST_LOCATION );
648 int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
650 ToolkitTestApplication application;
651 tet_infoline( "UtcDaliAnimatedVectorImageVisualJumpToCurrentProgress" );
653 Vector2 playRange( 0.2f, 0.8f );
655 Property::Map propertyMap;
656 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
657 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
658 .Add( DevelImageVisual::Property::LOOP_COUNT, 3 )
659 .Add( DevelImageVisual::Property::PLAY_RANGE, playRange );
661 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
662 DALI_TEST_CHECK( visual );
664 DummyControl actor = DummyControl::New( true );
665 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
666 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
668 Vector2 controlSize( 20.f, 30.f );
669 actor.SetSize( controlSize );
671 Stage::GetCurrent().Add( actor );
673 application.SendNotification();
674 application.Render();
676 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
678 Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
679 Property::Value* value = map.Find( DevelImageVisual::Property::LOOP_COUNT );
680 DALI_TEST_EQUALS( value->Get< int >(), 3, TEST_LOCATION );
682 value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
683 DALI_TEST_EQUALS( value->Get< Vector2 >(), playRange, TEST_LOCATION );
685 Vector2 newPlayRange( 0.4f, 1.0f );
687 Property::Map attributes;
688 attributes.Add( DevelImageVisual::Property::PLAY_RANGE, newPlayRange );
689 attributes.Add( DevelImageVisual::Property::LOOP_COUNT, 5 );
691 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
693 application.SendNotification();
694 application.Render();
696 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
697 value = map.Find( DevelImageVisual::Property::LOOP_COUNT );
698 DALI_TEST_EQUALS( value->Get< int >(), 5, TEST_LOCATION );
700 value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
701 DALI_TEST_EQUALS( value->Get< Vector2 >(), newPlayRange, TEST_LOCATION );