2 * Copyright (c) 2021 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.
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <toolkit-timer.h>
23 #include <toolkit-event-thread-callback.h>
24 #include <toolkit-vector-animation-renderer.h>
25 #include <dali-toolkit/dali-toolkit.h>
26 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
27 #include <dali-toolkit/devel-api/controls/control-devel.h>
28 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
29 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
30 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-actions-devel.h>
31 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-signals-devel.h>
32 #include <dali/devel-api/rendering/renderer-devel.h>
33 #include <dali/devel-api/adaptor-framework/window-devel.h>
34 #include "dummy-control.h"
37 using namespace Dali::Toolkit;
39 void dali_animated_vector_image_visual_startup(void)
41 test_return_value = TET_UNDEF;
44 void dali_animated_vector_image_visual_cleanup(void)
46 test_return_value = TET_PASS;
52 const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
53 const char* TEST_VECTOR_IMAGE_INVALID_FILE_NAME = "invalid.json";
55 const char* TEST_VECTOR_IMAGE_RIVE_FILE_NAME = TEST_RESOURCE_DIR "/juice.riv";
56 const char* TEST_VECTOR_IMAGE_INVALID_RIVE_FILE_NAME = "invalid.riv";
58 bool gAnimationFinishedSignalFired = false;
60 void VisualEventSignal( Control control, Dali::Property::Index visualIndex, Dali::Property::Index signalId )
62 if( visualIndex == DummyControl::Property::TEST_VISUAL && signalId == DevelAnimatedVectorImageVisual::Signal::ANIMATION_FINISHED )
64 gAnimationFinishedSignalFired = true;
70 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void)
72 ToolkitTestApplication application;
73 tet_infoline( "UtcDaliVisualFactoryGetAnimatedVectorImageVisual01: Request animated vector image visual with a json url" );
75 VisualFactory factory = VisualFactory::Get();
76 Visual::Base visual = factory.CreateVisual( TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions() );
77 DALI_TEST_CHECK( visual );
79 DummyControl actor = DummyControl::New( true );
80 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
81 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
82 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 200.0f ) );
83 application.GetScene().Add( actor );
85 application.SendNotification();
88 // renderer is added to actor
89 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
90 Renderer renderer = actor.GetRendererAt( 0u );
91 DALI_TEST_CHECK( renderer );
93 // Test SetOffScene().
95 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
100 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual02(void)
102 ToolkitTestApplication application;
103 tet_infoline( "UtcDaliVisualFactoryGetAnimatedVectorImageVisual02: Request animated vector image visual with a Property::Map" );
105 Property::Map propertyMap;
106 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
107 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME );
109 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
110 DALI_TEST_CHECK( visual );
112 DummyControl actor = DummyControl::New( true );
113 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
114 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
115 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 200.0f ) );
116 application.GetScene().Add( actor );
118 application.SendNotification();
119 application.Render();
121 // renderer is added to actor
122 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
123 Renderer renderer = actor.GetRendererAt( 0u );
124 DALI_TEST_CHECK( renderer );
127 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
132 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void)
134 ToolkitTestApplication application;
135 tet_infoline( "UtcDaliVisualFactoryGetAnimatedVectorImageVisual03: Request animated vector image visual with a Property::Map" );
137 int startFrame = 1, endFrame = 3;
138 Property::Array playRange;
139 playRange.PushBack( startFrame );
140 playRange.PushBack( endFrame );
142 Property::Map propertyMap;
143 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
144 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
145 .Add( DevelImageVisual::Property::LOOP_COUNT, 3 )
146 .Add( DevelImageVisual::Property::PLAY_RANGE, playRange )
147 .Add( DevelVisual::Property::CORNER_RADIUS, 50.0f );
149 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
150 DALI_TEST_CHECK( visual );
152 DummyControl actor = DummyControl::New( true );
153 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
154 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
155 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 200.0f ) );
156 application.GetScene().Add( actor );
158 application.SendNotification();
159 application.Render();
161 // renderer is added to actor
162 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
163 Renderer renderer = actor.GetRendererAt( 0u );
164 DALI_TEST_CHECK( renderer );
167 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
172 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void)
174 ToolkitTestApplication application;
175 tet_infoline( "UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map" );
177 int startFrame = 1, endFrame = 3;
178 float cornerRadius = 22.0f;
179 Property::Array playRange;
180 playRange.PushBack( startFrame );
181 playRange.PushBack( endFrame );
183 Property::Map propertyMap;
184 propertyMap.Add( "visualType", DevelVisual::ANIMATED_VECTOR_IMAGE )
185 .Add( "url", TEST_VECTOR_IMAGE_FILE_NAME )
186 .Add( "loopCount", 3 )
187 .Add( "playRange", playRange )
188 .Add( "stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME )
189 .Add( "loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE )
190 .Add( "redrawInScalingDown", false )
191 .Add( "cornerRadius", cornerRadius );
193 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
194 DALI_TEST_CHECK( visual );
196 DummyControl actor = DummyControl::New( true );
197 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
198 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
199 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 200.0f ) );
200 application.GetScene().Add( actor );
202 application.SendNotification();
203 application.Render();
205 // Trigger count is 1 - render a frame
206 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
208 // renderer is added to actor
209 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
211 Renderer renderer = actor.GetRendererAt( 0u );
212 DALI_TEST_CHECK( renderer );
214 Property::Map resultMap;
215 visual.CreatePropertyMap( resultMap );
217 // check the property values from the returned map from a visual
218 Property::Value* value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
219 DALI_TEST_CHECK( value );
220 DALI_TEST_CHECK( value->Get< std::string >() == TEST_VECTOR_IMAGE_FILE_NAME );
222 value = resultMap.Find( DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER );
223 DALI_TEST_CHECK( value );
224 DALI_TEST_CHECK( value->Get< int >() == 3 );
226 value = resultMap.Find( DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY );
227 DALI_TEST_CHECK( value );
229 Property::Array* result = value->GetArray();
230 DALI_TEST_CHECK( result );
232 DALI_TEST_CHECK( result->GetElementAt( 0 ).Get< int >() == startFrame );
233 DALI_TEST_CHECK( result->GetElementAt( 1 ).Get< int >() == endFrame );
235 value = resultMap.Find( DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER );
236 DALI_TEST_CHECK( value );
237 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::StopBehavior::FIRST_FRAME );
239 value = resultMap.Find( DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER );
240 DALI_TEST_CHECK( value );
241 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::LoopingMode::AUTO_REVERSE );
243 value = resultMap.Find( DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN );
244 DALI_TEST_CHECK( value );
245 DALI_TEST_CHECK( value->Get< bool >() == false );
247 value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4 );
248 DALI_TEST_CHECK( value );
249 DALI_TEST_EQUALS( value->Get< Vector4 >(), Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius), TEST_LOCATION );
251 value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" );
252 DALI_TEST_CHECK( value );
253 DALI_TEST_CHECK( value->Get< int >() == Visual::Transform::Policy::ABSOLUTE );
256 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
261 int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
263 ToolkitTestApplication application;
264 tet_infoline( "UtcDaliAnimatedVectorImageVisualGetPropertyMap01" );
266 int startFrame = 1, endFrame = 3;
267 Vector4 cornerRadius(50.0f, 22.0f, 0.0f, 3.0f);
268 Property::Array playRange;
269 playRange.PushBack( startFrame );
270 playRange.PushBack( endFrame );
272 Property::Map propertyMap;
273 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
274 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
275 .Add( DevelImageVisual::Property::LOOP_COUNT, 3 )
276 .Add( DevelImageVisual::Property::PLAY_RANGE, playRange )
277 .Add( DevelVisual::Property::CORNER_RADIUS, cornerRadius )
278 .Add( DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::RELATIVE);
280 // request AnimatedVectorImageVisual with a property map
281 VisualFactory factory = VisualFactory::Get();
282 Visual::Base visual = factory.CreateVisual( propertyMap );
284 DummyControl actor = DummyControl::New( true );
285 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
286 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
288 Vector2 controlSize( 20.f, 30.f );
289 actor.SetProperty( Actor::Property::SIZE, controlSize );
291 application.GetScene().Add( actor );
293 application.SendNotification();
294 application.Render();
296 std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
298 Property::Map resultMap;
299 resultMap = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
301 // check the property values from the returned map from a visual
302 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
303 DALI_TEST_CHECK( value );
304 DALI_TEST_CHECK( value->Get< int >() == DevelVisual::ANIMATED_VECTOR_IMAGE );
306 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
307 DALI_TEST_CHECK( value );
308 DALI_TEST_CHECK( value->Get< std::string >() == TEST_VECTOR_IMAGE_FILE_NAME );
310 value = resultMap.Find( DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER );
311 DALI_TEST_CHECK( value );
312 DALI_TEST_CHECK( value->Get< int >() == 3 );
314 value = resultMap.Find( DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY );
315 DALI_TEST_CHECK( value );
317 Property::Array* result = value->GetArray();
318 DALI_TEST_CHECK( result );
320 DALI_TEST_CHECK( result->GetElementAt( 0 ).Get< int >() == startFrame );
321 DALI_TEST_CHECK( result->GetElementAt( 1 ).Get< int >() == endFrame );
323 value = resultMap.Find( DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER );
324 DALI_TEST_CHECK( value );
325 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::StopBehavior::CURRENT_FRAME );
327 value = resultMap.Find( DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER );
328 DALI_TEST_CHECK( value );
329 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::LoopingMode::RESTART );
331 value = resultMap.Find( DevelImageVisual::Property::CONTENT_INFO, Property::MAP );
332 DALI_TEST_CHECK( value );
334 value = resultMap.Find( DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN );
335 DALI_TEST_CHECK( value );
336 DALI_TEST_CHECK( value->Get< bool >() == true ); // Check default value
338 value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4 );
339 DALI_TEST_CHECK( value );
340 DALI_TEST_EQUALS( value->Get< Vector4 >(), cornerRadius, TEST_LOCATION );
342 value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" );
343 DALI_TEST_CHECK( value );
344 DALI_TEST_CHECK( value->Get< int >() == Visual::Transform::Policy::RELATIVE );
346 // request AnimatedVectorImageVisual with an URL
347 Visual::Base visual2 = factory.CreateVisual( TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions() );
350 visual2.CreatePropertyMap( resultMap );
352 // check the property values from the returned map from a visual
353 value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
354 DALI_TEST_CHECK( value );
355 DALI_TEST_CHECK( value->Get< int >() == DevelVisual::ANIMATED_VECTOR_IMAGE );
357 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
358 DALI_TEST_CHECK( value );
359 DALI_TEST_CHECK( value->Get< std::string >() == TEST_VECTOR_IMAGE_FILE_NAME );
364 int UtcDaliAnimatedVectorImageVisualPlayback(void)
366 ToolkitTestApplication application;
368 tet_infoline( "UtcDaliAnimatedVectorImageVisualPlayback" );
371 // request AnimatedVectorImageVisual with a property map
372 VisualFactory factory = VisualFactory::Get();
373 Visual::Base visual = factory.CreateVisual(
375 .Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
376 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME ) );
378 DummyControl dummyControl = DummyControl::New( true );
379 Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummyControl.GetImplementation() );
380 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
381 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
383 Property::Map attributes;
384 tet_infoline( "Test Play action" );
385 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
387 application.GetScene().Add( dummyControl );
388 application.SendNotification();
389 application.Render( 16 );
391 Property::Map map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
392 Property::Value* value = map.Find( DevelImageVisual::Property::PLAY_STATE );
393 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING );
395 tet_infoline( "Test Pause action" );
396 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes );
398 application.SendNotification();
399 application.Render(16);
401 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
402 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
403 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PAUSED );
405 tet_infoline( "Test Play action" );
406 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
408 application.SendNotification();
409 application.Render(16);
411 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
412 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
413 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING );
415 tet_infoline( "Test Stop action" );
416 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes );
418 application.SendNotification();
419 application.Render(16);
421 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
422 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
423 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED );
425 tet_infoline( "Test Stop action again" );
426 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes );
428 application.SendNotification();
429 application.Render(16);
431 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
432 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
433 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED );
435 tet_infoline( "Test Play action" );
436 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
438 application.SendNotification();
439 application.Render(16);
441 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
442 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
443 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING );
445 tet_infoline( "Off stage" );
446 dummyControl.Unparent();
448 application.SendNotification();
449 application.Render(16);
451 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
452 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
453 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED );
455 tet_infoline( "On stage again" );
456 application.GetScene().Add( dummyControl );
458 application.SendNotification();
459 application.Render(16);
461 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
462 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
463 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED );
465 tet_infoline( "Test Play action" );
466 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
468 application.SendNotification();
469 application.Render(16);
471 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
472 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
473 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING );
476 Vector3 newSize( 100.0f, 100.0f, 0.0f );
477 dummyControl.SetProperty( Actor::Property::SIZE, newSize );
479 application.SendNotification();
480 application.Render(16);
482 // Size should be changed
483 Vector3 naturalSize = dummyControl.GetNaturalSize();
484 DALI_TEST_CHECK( naturalSize == newSize );
486 dummyControl.Unparent();
492 int UtcDaliAnimatedVectorImageVisualCustomShader(void)
494 ToolkitTestApplication application;
495 tet_infoline( "UtcDaliAnimatedVectorImageVisualCustomShader Test custom shader" );
497 VisualFactory factory = VisualFactory::Get();
498 Property::Map properties;
499 Property::Map shader;
500 const std::string vertexShader = "Foobar";
501 const std::string fragmentShader = "Foobar sampler2D Foobar";
502 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
503 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
505 properties[Visual::Property::TYPE] = Visual::IMAGE;
506 properties[Visual::Property::SHADER] = shader;
507 properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
509 Visual::Base visual = factory.CreateVisual( properties );
511 // trigger creation through setting on stage
512 DummyControl dummy = DummyControl::New( true );
513 Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
514 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
516 dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
517 dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
518 application.GetScene().Add( dummy );
520 application.SendNotification();
521 application.Render();
523 Renderer renderer = dummy.GetRendererAt( 0 );
524 Shader shader2 = renderer.GetShader();
525 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
526 Property::Map* map = value.GetMap();
527 DALI_TEST_CHECK( map );
529 std::string resultFragmentShader, resultVertexShader;
530 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
531 fragment->Get( resultFragmentShader );
532 DALI_TEST_CHECK( resultFragmentShader.find( fragmentShader ) != std::string::npos );
534 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
535 vertex->Get( resultVertexShader );
536 DALI_TEST_CHECK( resultVertexShader.find( vertexShader ) != std::string::npos );
541 int UtcDaliAnimatedVectorImageVisualNaturalSize(void)
543 ToolkitTestApplication application;
544 tet_infoline( "UtcDaliAnimatedVectorImageVisualNaturalSize" );
546 VisualFactory factory = VisualFactory::Get();
547 Visual::Base visual = factory.CreateVisual( TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions() );
548 DALI_TEST_CHECK( visual );
550 DummyControl actor = DummyControl::New( true );
551 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
552 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
554 Vector2 controlSize( 20.f, 30.f );
557 application.GetScene().Add( actor );
559 application.SendNotification();
560 application.Render();
562 visual.GetNaturalSize( naturalSize );
564 DALI_TEST_EQUALS( naturalSize, Vector2( 100.0f, 100.0f ), TEST_LOCATION ); // 100x100 is the content default size.
566 actor.SetProperty( Actor::Property::SIZE, controlSize );
568 application.SendNotification();
569 application.Render();
571 visual.GetNaturalSize( naturalSize );
573 DALI_TEST_EQUALS( naturalSize, controlSize, TEST_LOCATION );
578 int UtcDaliAnimatedVectorImageVisualLoopCount(void)
580 ToolkitTestApplication application;
581 tet_infoline( "UtcDaliAnimatedVectorImageVisualLoopCount" );
583 Property::Map propertyMap;
584 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
585 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
586 .Add( DevelImageVisual::Property::LOOP_COUNT, 3 );
588 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
589 DALI_TEST_CHECK( visual );
591 DummyControl actor = DummyControl::New( true );
592 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
593 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
595 Vector2 controlSize( 20.f, 30.f );
596 actor.SetProperty( Actor::Property::SIZE, controlSize );
598 application.GetScene().Add( actor );
600 Property::Map attributes;
601 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
603 application.SendNotification();
604 application.Render();
606 // Trigger count is 1 - render a frame
607 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
609 // renderer is added to actor
610 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
611 Renderer renderer = actor.GetRendererAt( 0u );
612 DALI_TEST_CHECK( renderer );
617 int UtcDaliAnimatedVectorImageVisualPlayRange(void)
619 ToolkitTestApplication application;
620 tet_infoline( "UtcDaliAnimatedVectorImageVisualPlayRange" );
622 int startFrame = 1, endFrame = 3;
623 Property::Array array;
624 array.PushBack( endFrame );
625 array.PushBack( startFrame );
627 Property::Map propertyMap;
628 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
629 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
630 .Add( DevelImageVisual::Property::PLAY_RANGE, array );
632 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
633 DALI_TEST_CHECK( visual );
635 DummyControl actor = DummyControl::New( true );
636 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
637 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
639 Vector2 controlSize( 20.f, 30.f );
640 actor.SetProperty( Actor::Property::SIZE, controlSize );
642 application.GetScene().Add( actor );
644 Property::Map attributes;
645 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
647 application.SendNotification();
648 application.Render();
650 std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
652 // renderer is added to actor
653 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
654 Renderer renderer = actor.GetRendererAt( 0u );
655 DALI_TEST_CHECK( renderer );
657 Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
658 Property::Value* value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
660 int resultStartFrame, resultEndFrame;
661 Property::Array* result = value->GetArray();
662 result->GetElementAt( 0 ).Get( resultStartFrame );
663 result->GetElementAt( 1 ).Get( resultEndFrame );
665 DALI_TEST_EQUALS( startFrame, resultStartFrame, TEST_LOCATION );
666 DALI_TEST_EQUALS( endFrame, resultEndFrame, TEST_LOCATION );
668 // Set invalid play range
671 array.PushBack( 100 );
674 attributes.Add( DevelImageVisual::Property::PLAY_RANGE, array );
675 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
677 application.SendNotification();
678 application.Render();
680 std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
682 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
683 value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
685 result = value->GetArray();
686 result->GetElementAt( 0 ).Get( resultStartFrame );
687 result->GetElementAt( 1 ).Get( resultEndFrame );
689 DALI_TEST_EQUALS( startFrame, resultStartFrame, TEST_LOCATION ); // Should not be changed
690 DALI_TEST_EQUALS( endFrame, resultEndFrame, TEST_LOCATION );
692 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, Property::Map() );
694 application.SendNotification();
695 application.Render();
697 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3 );
699 application.SendNotification();
700 application.Render();
702 std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
704 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
705 value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
706 DALI_TEST_EQUALS( value->Get< int >(), 3, TEST_LOCATION );
713 attributes.Add( DevelImageVisual::Property::PLAY_RANGE, array );
714 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
716 application.SendNotification();
717 application.Render();
719 std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
721 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
722 value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
724 result = value->GetArray();
725 result->GetElementAt( 0 ).Get( resultStartFrame );
726 result->GetElementAt( 1 ).Get( resultEndFrame );
728 DALI_TEST_EQUALS( 0, resultStartFrame, TEST_LOCATION );
729 DALI_TEST_EQUALS( 2, resultEndFrame, TEST_LOCATION );
731 value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
732 DALI_TEST_EQUALS( value->Get< int >(), 2, TEST_LOCATION ); // CURRENT_FRAME_NUMBER should be changed also.
737 int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void)
739 ToolkitTestApplication application;
740 tet_infoline( "UtcDaliAnimatedVectorImageVisualPlayRangeMarker" );
742 Property::Array array;
743 array.PushBack( VECTOR_ANIMATION_MARKER_NAME_1 );
745 Property::Map propertyMap;
746 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
747 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
748 .Add( DevelImageVisual::Property::PLAY_RANGE, array );
750 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
751 DALI_TEST_CHECK( visual );
753 DummyControl actor = DummyControl::New( true );
754 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
755 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
757 Vector2 controlSize( 20.f, 30.f );
758 actor.SetProperty( Actor::Property::SIZE, controlSize );
760 application.GetScene().Add( actor );
762 Property::Map attributes;
763 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
765 application.SendNotification();
766 application.Render();
768 std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
770 // renderer is added to actor
771 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
772 Renderer renderer = actor.GetRendererAt( 0u );
773 DALI_TEST_CHECK( renderer );
775 Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
776 Property::Value* value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
778 int resultStartFrame, resultEndFrame;
779 Property::Array* result = value->GetArray();
780 result->GetElementAt( 0 ).Get( resultStartFrame );
781 result->GetElementAt( 1 ).Get( resultEndFrame );
783 DALI_TEST_EQUALS( VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION );
784 DALI_TEST_EQUALS( VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION );
788 array.PushBack( VECTOR_ANIMATION_MARKER_NAME_1 );
789 array.PushBack( VECTOR_ANIMATION_MARKER_NAME_2 );
792 attributes.Add( DevelImageVisual::Property::PLAY_RANGE, array );
793 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
795 application.SendNotification();
796 application.Render();
798 std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
800 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
801 value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
803 result = value->GetArray();
804 result->GetElementAt( 0 ).Get( resultStartFrame );
805 result->GetElementAt( 1 ).Get( resultEndFrame );
807 DALI_TEST_EQUALS( VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION );
808 DALI_TEST_EQUALS( VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION );
810 // Set invalid play range
813 array.PushBack( VECTOR_ANIMATION_MARKER_NAME_1 );
816 attributes.Add( DevelImageVisual::Property::PLAY_RANGE, array );
817 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
819 application.SendNotification();
820 application.Render();
822 std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
824 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
825 value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
827 result = value->GetArray();
828 result->GetElementAt( 0 ).Get( resultStartFrame );
829 result->GetElementAt( 1 ).Get( resultEndFrame );
831 DALI_TEST_EQUALS( VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION ); // Should not be changed
832 DALI_TEST_EQUALS( VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION );
837 int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
839 ToolkitTestApplication application;
840 tet_infoline( "UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal" );
842 Property::Map propertyMap;
843 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
844 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
845 .Add( DevelImageVisual::Property::LOOP_COUNT, 3 );
847 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
848 DALI_TEST_CHECK( visual );
850 DummyControl actor = DummyControl::New( true );
851 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
852 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
854 DevelControl::VisualEventSignal( actor ).Connect( &VisualEventSignal );
856 Vector2 controlSize( 20.f, 30.f );
857 actor.SetProperty( Actor::Property::SIZE, controlSize );
859 application.GetScene().Add( actor );
861 Property::Map attributes;
862 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
864 application.SendNotification();
865 application.Render();
867 // Wait for animation finish
868 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
870 Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
871 Property::Value* value = map.Find( DevelImageVisual::Property::PLAY_STATE );
872 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED );
874 DALI_TEST_EQUALS( gAnimationFinishedSignalFired, true, TEST_LOCATION );
879 int UtcDaliAnimatedVectorImageVisualJumpTo(void)
881 ToolkitTestApplication application;
882 tet_infoline( "UtcDaliAnimatedVectorImageVisualJumpTo" );
884 Property::Map propertyMap;
885 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
886 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME );
888 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
889 DALI_TEST_CHECK( visual );
891 tet_printf( "1. Visual is created.\n" );
893 DummyControl actor = DummyControl::New( true );
894 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
895 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
897 Vector2 controlSize( 20.f, 30.f );
898 actor.SetProperty( Actor::Property::SIZE, controlSize );
900 application.GetScene().Add( actor );
902 application.SendNotification();
903 application.Render();
905 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2 );
907 application.SendNotification();
908 application.Render();
910 std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
912 Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
913 Property::Value* value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
914 DALI_TEST_EQUALS( value->Get< int >(), 2, TEST_LOCATION );
916 tet_printf( "2. The current frame number is [%d].\n", value->Get< int >() );
918 Property::Array array;
922 Property::Map attributes;
923 attributes.Add( DevelImageVisual::Property::PLAY_RANGE, array );
924 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
926 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3 );
928 application.SendNotification();
929 application.Render();
931 std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
933 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
934 value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
935 DALI_TEST_EQUALS( value->Get< int >(), 2, TEST_LOCATION );
937 tet_printf( "3. The current frame number is [%d].\n", value->Get< int >() );
946 attributes.Add( DevelImageVisual::Property::PLAY_RANGE, array );
947 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
950 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
952 application.SendNotification();
953 application.Render();
955 // Stop and jump to 3
956 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes );
958 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3 );
960 application.SendNotification();
961 application.Render();
963 std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
965 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
966 value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
967 DALI_TEST_EQUALS( value->Get< int >(), 3, TEST_LOCATION );
969 tet_printf( "4. The current frame number is [%d].\n", value->Get< int >() );
971 // Jump to the same position
972 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3 );
974 application.SendNotification();
975 application.Render();
977 std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
979 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
980 value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
981 DALI_TEST_EQUALS( value->Get< int >(), 3, TEST_LOCATION );
983 tet_printf( "5. The current frame number is [%d].\n", value->Get< int >() );
988 int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
990 ToolkitTestApplication application;
991 tet_infoline( "UtcDaliAnimatedVectorImageVisualUpdateProperty" );
993 int startFrame = 1, endFrame = 3;
994 Property::Array playRange;
995 playRange.PushBack( startFrame );
996 playRange.PushBack( endFrame );
998 Property::Map propertyMap;
999 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
1000 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
1001 .Add( DevelImageVisual::Property::LOOP_COUNT, 3 )
1002 .Add( DevelImageVisual::Property::PLAY_RANGE, playRange );
1004 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
1005 DALI_TEST_CHECK( visual );
1007 DummyControl actor = DummyControl::New( true );
1008 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
1009 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1011 Vector2 controlSize( 20.f, 30.f );
1012 actor.SetProperty( Actor::Property::SIZE, controlSize );
1014 application.GetScene().Add( actor );
1016 application.SendNotification();
1017 application.Render();
1019 std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
1021 Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1022 Property::Value* value = map.Find( DevelImageVisual::Property::LOOP_COUNT );
1023 DALI_TEST_EQUALS( value->Get< int >(), 3, TEST_LOCATION );
1025 value = map.Find( DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY );
1026 DALI_TEST_CHECK( value );
1028 Property::Array* result = value->GetArray();
1029 DALI_TEST_CHECK( result );
1031 DALI_TEST_CHECK( result->GetElementAt( 0 ).Get< int >() == startFrame );
1032 DALI_TEST_CHECK( result->GetElementAt( 1 ).Get< int >() == endFrame );
1035 playRange.PushBack( 0 );
1036 playRange.PushBack( 2 );
1038 Property::Map attributes;
1039 attributes.Add( DevelImageVisual::Property::PLAY_RANGE, playRange );
1040 attributes.Add( DevelImageVisual::Property::LOOP_COUNT, 5 );
1042 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
1044 application.SendNotification();
1045 application.Render();
1047 std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
1049 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1050 value = map.Find( DevelImageVisual::Property::LOOP_COUNT );
1051 DALI_TEST_EQUALS( value->Get< int >(), 5, TEST_LOCATION );
1053 value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
1054 result = value->GetArray();
1055 DALI_TEST_CHECK( result );
1057 DALI_TEST_CHECK( result->GetElementAt( 0 ).Get< int >() == 0 );
1058 DALI_TEST_CHECK( result->GetElementAt( 1 ).Get< int >() == 2 );
1063 playRange.PushBack( startFrame );
1064 playRange.PushBack( endFrame );
1066 attributes.Add( DevelImageVisual::Property::PLAY_RANGE, playRange );
1068 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
1070 application.SendNotification();
1071 application.Render();
1073 std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
1075 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1076 value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
1078 result = value->GetArray();
1079 DALI_TEST_CHECK( result );
1081 DALI_TEST_CHECK( result->GetElementAt( 0 ).Get< int >() == startFrame );
1082 DALI_TEST_CHECK( result->GetElementAt( 1 ).Get< int >() == endFrame );
1084 // Play and update property
1086 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
1088 application.SendNotification();
1089 application.Render();
1091 attributes.Add( DevelImageVisual::Property::LOOP_COUNT, 10 );
1093 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
1095 application.SendNotification();
1096 application.Render();
1098 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1099 value = map.Find( DevelImageVisual::Property::LOOP_COUNT );
1100 DALI_TEST_EQUALS( value->Get< int >(), 10, TEST_LOCATION );
1105 int UtcDaliAnimatedVectorImageVisualStopBehavior(void)
1107 ToolkitTestApplication application;
1108 tet_infoline( "UtcDaliAnimatedVectorImageVisualStopBehavior" );
1110 Property::Map propertyMap;
1111 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
1112 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
1113 .Add( DevelImageVisual::Property::LOOP_COUNT, 3 )
1114 .Add( DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME );
1116 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
1117 DALI_TEST_CHECK( visual );
1119 DummyControl actor = DummyControl::New( true );
1120 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
1121 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1123 Vector2 controlSize( 20.f, 30.f );
1124 actor.SetProperty( Actor::Property::SIZE, controlSize );
1126 application.GetScene().Add( actor );
1128 Property::Map attributes;
1129 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
1131 application.SendNotification();
1132 application.Render();
1134 // Trigger count is 1 - animation finished
1135 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
1137 Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1138 Property::Value* value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
1139 DALI_TEST_EQUALS( value->Get< int >(), 0, TEST_LOCATION ); // Should be the first frame
1141 // Change stop behavior
1142 attributes.Add( DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME );
1144 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
1149 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
1151 application.SendNotification();
1152 application.Render();
1154 // Trigger count is 1 - animation finished
1155 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1157 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1159 Property::Value* value1 = map.Find( DevelImageVisual::Property::TOTAL_FRAME_NUMBER );
1160 int totalFrameNumber = value1->Get< int >();
1162 value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
1163 DALI_TEST_EQUALS( value->Get< int >(), totalFrameNumber - 1, TEST_LOCATION ); // Should be the last frame
1165 // Change stop behavior
1166 attributes.Add( DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME );
1167 attributes.Add( DevelImageVisual::Property::LOOP_COUNT, -1 );
1169 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
1174 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
1176 application.SendNotification();
1177 application.Render();
1180 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes );
1182 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1183 value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
1184 int currentFrameNumber = value->Get< int >();
1187 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes );
1189 application.SendNotification();
1190 application.Render( 16 );
1192 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1193 value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
1194 DALI_TEST_EQUALS( value->Get< int >(), currentFrameNumber, TEST_LOCATION ); // Should be same with currentFrameNumber
1199 int UtcDaliAnimatedVectorImageVisualLoopingMode(void)
1201 ToolkitTestApplication application;
1202 tet_infoline( "UtcDaliAnimatedVectorImageVisualLoopingMode" );
1204 Property::Map propertyMap;
1205 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
1206 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
1207 .Add( DevelImageVisual::Property::LOOP_COUNT, 3 )
1208 .Add( DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME )
1209 .Add( DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::AUTO_REVERSE );
1211 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
1212 DALI_TEST_CHECK( visual );
1214 DummyControl actor = DummyControl::New( true );
1215 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
1216 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1218 Vector2 controlSize( 20.f, 30.f );
1219 actor.SetProperty( Actor::Property::SIZE, controlSize );
1221 application.GetScene().Add( actor );
1223 Property::Map attributes;
1224 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
1226 application.SendNotification();
1227 application.Render();
1229 // Trigger count is 1 - animation finished
1230 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
1232 Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1233 Property::Value* value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
1234 DALI_TEST_EQUALS( value->Get< int >(), 0, TEST_LOCATION ); // Should be the first frame because of auto reverse
1236 // Change stop behavior
1237 attributes.Add( DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME );
1239 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
1242 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
1244 application.SendNotification();
1245 application.Render();
1247 // Trigger count is 1 - animation finished
1248 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1250 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1251 value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
1252 DALI_TEST_EQUALS( value->Get< int >(), 0, TEST_LOCATION ); // Should be the first frame
1254 // Change looping mode
1255 attributes.Add( DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::RESTART );
1257 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
1260 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
1262 application.SendNotification();
1263 application.Render();
1265 // Trigger count is 1 - animation finished
1266 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1268 Property::Value* value1 = map.Find( DevelImageVisual::Property::TOTAL_FRAME_NUMBER );
1269 int totalFrameNumber = value1->Get< int >();
1271 map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1272 value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
1273 DALI_TEST_EQUALS( value->Get< int >(), totalFrameNumber - 1, TEST_LOCATION ); // Should be the last frame
1278 int UtcDaliAnimatedVectorImageVisualPropertyNotification(void)
1280 ToolkitTestApplication application;
1281 tet_infoline( "UtcDaliAnimatedVectorImageVisualPropertyNotification" );
1283 Property::Map propertyMap;
1284 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
1285 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME );
1287 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
1288 DALI_TEST_CHECK( visual );
1290 DummyControl actor = DummyControl::New( true );
1291 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
1292 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1294 Vector2 controlSize( 20.f, 30.f );
1295 Vector3 controlScale( 2.0f, 2.0f, 1.0f );
1296 actor.SetProperty( Actor::Property::SIZE, controlSize );
1297 actor.SetProperty( Actor::Property::SCALE, controlScale );
1299 application.GetScene().Add( actor );
1301 application.SendNotification();
1302 application.Render();
1304 application.SendNotification();
1305 application.Render();
1307 Renderer renderer = actor.GetRendererAt( 0u );
1308 DALI_TEST_CHECK( renderer );
1310 auto textureSet = renderer.GetTextures();
1311 auto texture = textureSet.GetTexture(0);
1313 DALI_TEST_EQUALS( controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION );
1314 DALI_TEST_EQUALS( controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION );
1316 // Change scale and size
1317 controlSize = Vector2( 50.f, 40.f );
1318 controlScale= Vector3( 0.5f, 0.5f, 1.0f );
1319 actor.SetProperty( Actor::Property::SIZE, controlSize );
1320 actor.SetProperty( Actor::Property::SCALE, controlScale );
1322 application.SendNotification();
1323 application.Render();
1325 application.SendNotification();
1326 application.Render();
1328 renderer = actor.GetRendererAt( 0u );
1329 DALI_TEST_CHECK( renderer );
1331 textureSet = renderer.GetTextures();
1332 texture = textureSet.GetTexture(0);
1334 DALI_TEST_EQUALS( controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION );
1335 DALI_TEST_EQUALS( controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION );
1340 int UtcDaliAnimatedVectorImageVisualMultipleInstances(void)
1342 ToolkitTestApplication application;
1343 tet_infoline( "UtcDaliAnimatedVectorImageVisualMultipleInstances" );
1345 Property::Map propertyMap;
1346 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
1347 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME );
1349 Visual::Base visual1 = VisualFactory::Get().CreateVisual( propertyMap );
1350 DALI_TEST_CHECK( visual1 );
1352 DummyControl actor1 = DummyControl::New( true );
1353 DummyControlImpl& dummyImpl1 = static_cast< DummyControlImpl& >( actor1.GetImplementation() );
1354 dummyImpl1.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual1 );
1356 Vector2 controlSize( 20.f, 30.f );
1357 actor1.SetProperty( Actor::Property::SIZE, controlSize );
1359 application.GetScene().Add( actor1 );
1361 propertyMap.Clear();
1362 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
1363 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME );
1365 Visual::Base visual2 = VisualFactory::Get().CreateVisual( propertyMap );
1366 DALI_TEST_CHECK( visual2 );
1368 DummyControl actor2 = DummyControl::New( true );
1369 DummyControlImpl& dummyImpl2 = static_cast< DummyControlImpl& >( actor2.GetImplementation() );
1370 dummyImpl2.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual2 );
1372 actor2.SetProperty( Actor::Property::SIZE, controlSize );
1374 application.GetScene().Add( actor2 );
1376 DevelControl::DoAction( actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map() );
1378 application.SendNotification();
1379 application.Render();
1381 std::this_thread::sleep_for( std::chrono::milliseconds( 200 ) );
1383 Property::Map attributes;
1384 attributes.Add( DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME );
1386 DevelControl::DoAction( actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
1387 DevelControl::DoAction( actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY, attributes );
1389 DevelControl::DoAction( actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map() );
1391 // renderer is added to actor
1392 DALI_TEST_CHECK( actor1.GetRendererCount() == 1u );
1393 Renderer renderer1 = actor1.GetRendererAt( 0u );
1394 DALI_TEST_CHECK( renderer1 );
1396 // renderer is added to actor
1397 DALI_TEST_CHECK( actor2.GetRendererCount() == 1u );
1398 Renderer renderer2 = actor2.GetRendererAt( 0u );
1399 DALI_TEST_CHECK( renderer2 );
1404 int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void)
1406 ToolkitTestApplication application;
1407 tet_infoline( "UtcDaliAnimatedVectorImageVisualControlVisibilityChanged" );
1409 Property::Map propertyMap;
1410 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
1411 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME );
1413 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
1414 DALI_TEST_CHECK( visual );
1416 DummyControl actor = DummyControl::New( true );
1417 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
1418 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1420 Vector2 controlSize( 20.f, 30.f );
1421 actor.SetProperty( Actor::Property::SIZE, controlSize );
1423 application.GetScene().Add( actor );
1425 application.SendNotification();
1426 application.Render();
1428 Property::Map attributes;
1429 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
1431 application.SendNotification();
1432 application.Render();
1434 // Check rendering behavior
1435 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1436 Renderer renderer = actor.GetRendererAt( 0u );
1437 DALI_TEST_CHECK( renderer );
1438 DALI_TEST_CHECK( renderer.GetProperty< int >( DevelRenderer::Property::RENDERING_BEHAVIOR ) == DevelRenderer::Rendering::CONTINUOUSLY );
1440 actor.SetProperty( Actor::Property::VISIBLE, false );
1442 application.SendNotification();
1443 application.Render();
1445 // Check rendering behavior again
1446 DALI_TEST_CHECK( renderer.GetProperty< int >( DevelRenderer::Property::RENDERING_BEHAVIOR ) == DevelRenderer::Rendering::IF_REQUIRED );
1451 int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void)
1453 ToolkitTestApplication application;
1454 tet_infoline( "UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged" );
1456 Property::Map propertyMap;
1457 propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
1458 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME );
1460 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
1461 DALI_TEST_CHECK( visual );
1463 DummyControl actor = DummyControl::New( true );
1464 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
1465 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1467 Vector2 controlSize( 20.f, 30.f );
1468 actor.SetProperty( Actor::Property::SIZE, controlSize );
1470 application.GetScene().Add( actor );
1472 application.SendNotification();
1473 application.Render();
1475 Property::Map attributes;
1476 DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
1478 application.SendNotification();
1479 application.Render();
1481 // Check rendering behavior
1482 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1483 Renderer renderer = actor.GetRendererAt( 0u );
1484 DALI_TEST_CHECK( renderer );
1485 DALI_TEST_CHECK( renderer.GetProperty< int >( DevelRenderer::Property::RENDERING_BEHAVIOR ) == DevelRenderer::Rendering::CONTINUOUSLY );
1487 Window window = DevelWindow::Get( actor );
1490 application.SendNotification();
1491 application.Render();
1493 // Check rendering behavior again
1494 DALI_TEST_CHECK( renderer.GetProperty< int >( DevelRenderer::Property::RENDERING_BEHAVIOR ) == DevelRenderer::Rendering::IF_REQUIRED );
1499 int UtcDaliAnimatedVectorImageVisualInvalidFile(void)
1501 ToolkitTestApplication application;
1502 tet_infoline("Request loading with invalid file - should draw broken image");
1504 TestGlAbstraction& gl = application.GetGlAbstraction();
1505 TraceCallStack& textureTrace = gl.GetTextureTrace();
1506 textureTrace.Enable(true);
1508 Property::Map propertyMap;
1509 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1510 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
1512 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1513 DALI_TEST_CHECK(visual);
1515 DummyControl actor = DummyControl::New(true);
1516 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >(actor.GetImplementation());
1517 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1519 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1521 application.GetScene().Add(actor);
1523 application.SendNotification();
1524 application.Render();
1526 // Check resource status
1527 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1528 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1530 // The broken image should be shown.
1531 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1532 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1537 int UtcDaliAnimatedVectorImageVisualLoadRiveFileP(void)
1539 ToolkitTestApplication application;
1540 tet_infoline( "UtcDaliAnimatedVectorImageVisualLoadRiveFile: Request animated vector image visual with a rive url" );
1542 VisualFactory factory = VisualFactory::Get();
1543 Visual::Base visual = factory.CreateVisual( TEST_VECTOR_IMAGE_RIVE_FILE_NAME, ImageDimensions() );
1544 DALI_TEST_CHECK( visual );
1546 DummyControl actor = DummyControl::New( true );
1547 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
1548 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1549 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 200.0f ) );
1550 application.GetScene().Add( actor );
1552 application.SendNotification();
1553 application.Render();
1555 // renderer is added to actor
1556 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1557 Renderer renderer = actor.GetRendererAt( 0u );
1558 DALI_TEST_CHECK( renderer );
1560 // Test SetOffScene().
1562 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1567 int UtcDaliAnimatedVectorImageVisualLoadRiveFileN(void)
1569 ToolkitTestApplication application;
1570 tet_infoline("Request loading with invalid rive file - should draw broken image");
1572 TestGlAbstraction& gl = application.GetGlAbstraction();
1573 TraceCallStack& textureTrace = gl.GetTextureTrace();
1574 textureTrace.Enable(true);
1576 Property::Map propertyMap;
1577 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1578 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_RIVE_FILE_NAME);
1580 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1581 DALI_TEST_CHECK(visual);
1583 DummyControl actor = DummyControl::New(true);
1584 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >(actor.GetImplementation());
1585 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1587 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1589 application.GetScene().Add(actor);
1591 application.SendNotification();
1592 application.Render();
1594 // Check resource status
1595 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1596 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1598 // The broken image should be shown.
1599 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1600 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1605 int UtcDaliAnimatedVectorImageVisualPlaybackRiveFile(void)
1607 ToolkitTestApplication application;
1609 tet_infoline( "UtcDaliAnimatedVectorImageVisualPlaybackRiveFile" );
1612 // request AnimatedVectorImageVisual for Rive with a property map
1613 VisualFactory factory = VisualFactory::Get();
1614 Visual::Base visual = factory.CreateVisual(
1616 .Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
1617 .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_RIVE_FILE_NAME ) );
1619 DummyControl dummyControl = DummyControl::New( true );
1620 Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummyControl.GetImplementation() );
1621 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1622 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
1624 Property::Map attributes;
1625 tet_infoline( "Test Play action" );
1626 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
1628 application.GetScene().Add( dummyControl );
1629 application.SendNotification();
1630 application.Render( 16 );
1632 Property::Map map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1633 Property::Value* value = map.Find( DevelImageVisual::Property::PLAY_STATE );
1634 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING );
1636 tet_infoline( "Test Pause action" );
1637 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes );
1639 application.SendNotification();
1640 application.Render(16);
1642 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1643 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
1644 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PAUSED );
1646 tet_infoline( "Test Play action" );
1647 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
1649 application.SendNotification();
1650 application.Render(16);
1652 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1653 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
1654 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING );
1656 tet_infoline( "Test Stop action" );
1657 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes );
1659 application.SendNotification();
1660 application.Render(16);
1662 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1663 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
1664 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED );
1666 tet_infoline( "Test Stop action again" );
1667 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes );
1669 application.SendNotification();
1670 application.Render(16);
1672 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1673 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
1674 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED );
1676 tet_infoline( "Test Play action" );
1677 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
1679 application.SendNotification();
1680 application.Render(16);
1682 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1683 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
1684 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING );
1686 tet_infoline( "Off stage" );
1687 dummyControl.Unparent();
1689 application.SendNotification();
1690 application.Render(16);
1692 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1693 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
1694 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED );
1696 tet_infoline( "On stage again" );
1697 application.GetScene().Add( dummyControl );
1699 application.SendNotification();
1700 application.Render(16);
1702 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1703 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
1704 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED );
1706 tet_infoline( "Test Play action" );
1707 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
1709 application.SendNotification();
1710 application.Render(16);
1712 map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
1713 value = map.Find( DevelImageVisual::Property::PLAY_STATE );
1714 DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING );
1717 Vector3 newSize( 100.0f, 100.0f, 0.0f );
1718 dummyControl.SetProperty( Actor::Property::SIZE, newSize );
1720 application.SendNotification();
1721 application.Render(16);
1723 // Size should be changed
1724 Vector3 naturalSize = dummyControl.GetNaturalSize();
1725 DALI_TEST_CHECK( naturalSize == newSize );
1727 dummyControl.Unparent();