2 * Copyright (c) 2022 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.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <toolkit-event-thread-callback.h>
24 #include <toolkit-timer.h>
25 #include <toolkit-vector-animation-renderer.h>
26 #include "dummy-control.h"
28 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/control-devel.h>
31 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
32 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-actions-devel.h>
33 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-signals-devel.h>
34 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
35 #include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
36 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
38 #include <dali/devel-api/adaptor-framework/vector-animation-renderer.h>
39 #include <dali/devel-api/adaptor-framework/window-devel.h>
40 #include <dali/devel-api/rendering/renderer-devel.h>
43 using namespace Dali::Toolkit;
45 void dali_animated_vector_image_visual_startup(void)
47 test_return_value = TET_UNDEF;
50 void dali_animated_vector_image_visual_cleanup(void)
52 test_return_value = TET_PASS;
57 const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
58 const char* TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP = "framedrop.json";
59 const char* TEST_VECTOR_IMAGE_INVALID_FILE_NAME = "invalid.json";
61 bool gAnimationFinishedSignalFired = false;
63 void VisualEventSignal(Control control, Dali::Property::Index visualIndex, Dali::Property::Index signalId)
65 if(visualIndex == DummyControl::Property::TEST_VISUAL && signalId == DevelAnimatedVectorImageVisual::Signal::ANIMATION_FINISHED)
67 gAnimationFinishedSignalFired = true;
73 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void)
75 ToolkitTestApplication application;
76 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual01: Request animated vector image visual with a json url");
78 VisualFactory factory = VisualFactory::Get();
79 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
80 DALI_TEST_CHECK(visual);
82 DummyControl actor = DummyControl::New(true);
83 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
84 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
85 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
86 application.GetScene().Add(actor);
88 application.SendNotification();
91 // Trigger count is 1 - render a frame
92 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
94 // renderer is added to actor
95 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
96 Renderer renderer = actor.GetRendererAt(0u);
97 DALI_TEST_CHECK(renderer);
99 // Test SetOffScene().
101 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
106 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual02(void)
108 ToolkitTestApplication application;
109 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual02: Request animated vector image visual with a Property::Map");
111 Property::Map propertyMap;
112 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
113 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
114 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
116 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
117 DALI_TEST_CHECK(visual);
119 DummyControl actor = DummyControl::New(true);
120 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
121 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
122 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
123 application.GetScene().Add(actor);
125 application.SendNotification();
126 application.Render();
128 // Trigger count is 2 - load & render a frame
129 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
131 // renderer is added to actor
132 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
133 Renderer renderer = actor.GetRendererAt(0u);
134 DALI_TEST_CHECK(renderer);
137 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
142 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void)
144 ToolkitTestApplication application;
145 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual03: Request animated vector image visual with a Property::Map");
147 int startFrame = 1, endFrame = 3;
148 Property::Array playRange;
149 playRange.PushBack(startFrame);
150 playRange.PushBack(endFrame);
152 Property::Map propertyMap;
153 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
154 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
155 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
156 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
157 .Add(DevelVisual::Property::CORNER_RADIUS, 50.0f)
158 .Add(DevelVisual::Property::BORDERLINE_WIDTH, 20.0f)
159 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
161 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
162 DALI_TEST_CHECK(visual);
164 DummyControl actor = DummyControl::New(true);
165 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
166 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
167 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
168 application.GetScene().Add(actor);
170 application.SendNotification();
171 application.Render();
173 // Trigger count is 2 - load & render a frame
174 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
176 // renderer is added to actor
177 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
178 Renderer renderer = actor.GetRendererAt(0u);
179 DALI_TEST_CHECK(renderer);
182 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
187 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void)
189 ToolkitTestApplication application;
190 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map");
192 int startFrame = 1, endFrame = 3;
193 float cornerRadius = 22.0f;
194 float borderlineWidth = 2.0f;
195 Vector4 borderlineColor = Vector4(1.0f, 1.0f, 1.0f, 1.0f);
196 float borderlineOffset = 0.1f;
197 Property::Array playRange;
198 playRange.PushBack(startFrame);
199 playRange.PushBack(endFrame);
201 Property::Map propertyMap;
202 propertyMap.Add("visualType", DevelVisual::ANIMATED_VECTOR_IMAGE)
203 .Add("url", TEST_VECTOR_IMAGE_FILE_NAME)
205 .Add("playRange", playRange)
206 .Add("stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME)
207 .Add("loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE)
208 .Add("redrawInScalingDown", false)
209 .Add("cornerRadius", cornerRadius)
210 .Add("borderlineWidth", borderlineWidth)
211 .Add("borderlineColor", borderlineColor)
212 .Add("borderlineOffset", borderlineOffset)
213 .Add("synchronousLoading", true);
215 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
216 DALI_TEST_CHECK(visual);
218 DummyControl actor = DummyControl::New(true);
219 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
220 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
221 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
222 application.GetScene().Add(actor);
224 application.SendNotification();
225 application.Render();
227 // Trigger count is 1 - render a frame
228 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
230 // renderer is added to actor
231 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
233 Renderer renderer = actor.GetRendererAt(0u);
234 DALI_TEST_CHECK(renderer);
236 Property::Map resultMap;
237 visual.CreatePropertyMap(resultMap);
239 // check the property values from the returned map from a visual
240 Property::Value* value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
241 DALI_TEST_CHECK(value);
242 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
244 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
245 DALI_TEST_CHECK(value);
246 DALI_TEST_CHECK(value->Get<int>() == 3);
248 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
249 DALI_TEST_CHECK(value);
251 Property::Array* result = value->GetArray();
252 DALI_TEST_CHECK(result);
254 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
255 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
257 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
258 DALI_TEST_CHECK(value);
259 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::FIRST_FRAME);
261 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
262 DALI_TEST_CHECK(value);
263 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::AUTO_REVERSE);
265 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
266 DALI_TEST_CHECK(value);
267 DALI_TEST_CHECK(value->Get<bool>() == false);
269 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
270 DALI_TEST_CHECK(value);
271 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius), TEST_LOCATION);
273 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
274 DALI_TEST_CHECK(value);
275 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
277 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT);
278 DALI_TEST_CHECK(value);
279 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
281 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
282 DALI_TEST_CHECK(value);
283 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
285 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
286 DALI_TEST_CHECK(value);
287 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
290 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
295 int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
297 ToolkitTestApplication application;
298 tet_infoline("UtcDaliAnimatedVectorImageVisualGetPropertyMap01");
300 int startFrame = 1, endFrame = 3;
301 Vector4 cornerRadius(50.0f, 22.0f, 0.0f, 3.0f);
302 float borderlineWidth = 2.3f;
303 Vector4 borderlineColor = Vector4(0.3f, 0.3f, 1.0f, 1.0f);
304 float borderlineOffset = 0.3f;
305 Property::Array playRange;
306 playRange.PushBack(startFrame);
307 playRange.PushBack(endFrame);
309 Property::Map propertyMap;
310 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
311 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
312 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
313 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
314 .Add(DevelVisual::Property::CORNER_RADIUS, cornerRadius)
315 .Add(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::RELATIVE)
316 .Add(DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth)
317 .Add(DevelVisual::Property::BORDERLINE_COLOR, borderlineColor)
318 .Add(DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset)
319 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
321 // request AnimatedVectorImageVisual with a property map
322 VisualFactory factory = VisualFactory::Get();
323 Visual::Base visual = factory.CreateVisual(propertyMap);
325 DummyControl actor = DummyControl::New(true);
326 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
327 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
329 Vector2 controlSize(20.f, 30.f);
330 actor.SetProperty(Actor::Property::SIZE, controlSize);
332 application.GetScene().Add(actor);
334 application.SendNotification();
335 application.Render();
337 // Trigger count is 2 - load & render a frame
338 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
340 Property::Map resultMap;
341 resultMap = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
343 // check the property values from the returned map from a visual
344 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
345 DALI_TEST_CHECK(value);
346 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
348 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
349 DALI_TEST_CHECK(value);
350 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
352 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
353 DALI_TEST_CHECK(value);
354 DALI_TEST_CHECK(value->Get<int>() == 3);
356 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
357 DALI_TEST_CHECK(value);
359 Property::Array* result = value->GetArray();
360 DALI_TEST_CHECK(result);
362 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
363 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
365 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
366 DALI_TEST_CHECK(value);
367 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::CURRENT_FRAME);
369 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
370 DALI_TEST_CHECK(value);
371 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::RESTART);
373 value = resultMap.Find(DevelImageVisual::Property::CONTENT_INFO, Property::MAP);
374 DALI_TEST_CHECK(value);
376 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
377 DALI_TEST_CHECK(value);
378 DALI_TEST_CHECK(value->Get<bool>() == true); // Check default value
380 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
381 DALI_TEST_CHECK(value);
382 DALI_TEST_EQUALS(value->Get<Vector4>(), cornerRadius, TEST_LOCATION);
384 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
385 DALI_TEST_CHECK(value);
386 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::RELATIVE);
388 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
389 DALI_TEST_CHECK(value);
390 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
392 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
393 DALI_TEST_CHECK(value);
394 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
396 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
397 DALI_TEST_CHECK(value);
398 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
400 // request AnimatedVectorImageVisual with an URL
401 Visual::Base visual2 = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
404 visual2.CreatePropertyMap(resultMap);
406 // check the property values from the returned map from a visual
407 value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
408 DALI_TEST_CHECK(value);
409 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
411 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
412 DALI_TEST_CHECK(value);
413 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
418 int UtcDaliAnimatedVectorImageVisualPlayback(void)
420 ToolkitTestApplication application;
422 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayback");
425 // request AnimatedVectorImageVisual with a property map
426 VisualFactory factory = VisualFactory::Get();
427 Visual::Base visual = factory.CreateVisual(
429 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
430 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
431 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
433 DummyControl dummyControl = DummyControl::New(true);
434 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
435 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
436 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
438 Property::Map attributes;
439 tet_infoline("Test Play action");
440 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
442 application.GetScene().Add(dummyControl);
443 application.SendNotification();
444 application.Render(16);
446 Property::Map map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
447 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
448 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
450 tet_infoline("Test Pause action");
451 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
453 application.SendNotification();
454 application.Render(16);
456 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
457 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
458 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PAUSED);
460 tet_infoline("Test Play action");
461 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
463 application.SendNotification();
464 application.Render(16);
466 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
467 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
468 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
470 tet_infoline("Test Stop action");
471 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
473 application.SendNotification();
474 application.Render(16);
476 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
477 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
478 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
480 tet_infoline("Test Stop action again");
481 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
483 application.SendNotification();
484 application.Render(16);
486 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
487 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
488 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
490 tet_infoline("Test Play action");
491 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
493 application.SendNotification();
494 application.Render(16);
496 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
497 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
498 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
500 tet_infoline("Off stage");
501 dummyControl.Unparent();
503 application.SendNotification();
504 application.Render(16);
506 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
507 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
508 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
510 tet_infoline("On stage again");
511 application.GetScene().Add(dummyControl);
513 application.SendNotification();
514 application.Render(16);
516 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
517 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
518 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
520 tet_infoline("Test Play action");
521 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
523 application.SendNotification();
524 application.Render(16);
526 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
527 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
528 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
531 Vector3 newSize(100.0f, 100.0f, 0.0f);
532 dummyControl.SetProperty(Actor::Property::SIZE, newSize);
534 application.SendNotification();
535 application.Render(16);
537 // Size should be changed
538 Vector3 naturalSize = dummyControl.GetNaturalSize();
539 DALI_TEST_CHECK(naturalSize == newSize);
541 dummyControl.Unparent();
547 int UtcDaliAnimatedVectorImageVisualCustomShader(void)
549 ToolkitTestApplication application;
550 tet_infoline("UtcDaliAnimatedVectorImageVisualCustomShader Test custom shader");
552 VisualFactory factory = VisualFactory::Get();
553 Property::Map properties;
554 Property::Map shader;
555 const std::string vertexShader = "Foobar";
556 const std::string fragmentShader = "Foobar sampler2D Foobar";
557 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
558 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
560 properties[Visual::Property::TYPE] = Visual::IMAGE;
561 properties[Visual::Property::SHADER] = shader;
562 properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
564 Visual::Base visual = factory.CreateVisual(properties);
566 // trigger creation through setting on stage
567 DummyControl dummy = DummyControl::New(true);
568 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
569 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
571 dummy.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
572 dummy.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
573 application.GetScene().Add(dummy);
575 application.SendNotification();
576 application.Render();
578 // Trigger count is 1 - render a frame
579 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
581 Renderer renderer = dummy.GetRendererAt(0);
582 Shader shader2 = renderer.GetShader();
583 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
584 Property::Map* map = value.GetMap();
585 DALI_TEST_CHECK(map);
587 std::string resultFragmentShader, resultVertexShader;
588 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
589 fragment->Get(resultFragmentShader);
590 DALI_TEST_CHECK(resultFragmentShader.find(fragmentShader) != std::string::npos);
592 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
593 vertex->Get(resultVertexShader);
594 DALI_TEST_CHECK(resultVertexShader.find(vertexShader) != std::string::npos);
599 int UtcDaliAnimatedVectorImageVisualNaturalSize(void)
601 ToolkitTestApplication application;
602 tet_infoline("UtcDaliAnimatedVectorImageVisualNaturalSize");
604 VisualFactory factory = VisualFactory::Get();
605 Visual::Base visual = factory.CreateVisual(
607 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
608 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
609 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
610 DALI_TEST_CHECK(visual);
612 DummyControl actor = DummyControl::New(true);
613 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
614 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
616 Vector2 controlSize(20.f, 30.f);
619 application.GetScene().Add(actor);
621 application.SendNotification();
622 application.Render();
624 // Trigger count is 1 - load
625 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
627 visual.GetNaturalSize(naturalSize);
629 DALI_TEST_EQUALS(naturalSize, Vector2(100.0f, 100.0f), TEST_LOCATION); // 100x100 is the content default size.
631 actor.SetProperty(Actor::Property::SIZE, controlSize);
633 application.SendNotification();
634 application.Render();
636 visual.GetNaturalSize(naturalSize);
638 DALI_TEST_EQUALS(naturalSize, controlSize, TEST_LOCATION);
643 int UtcDaliAnimatedVectorImageVisualLoopCount(void)
645 ToolkitTestApplication application;
646 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopCount");
648 Property::Map propertyMap;
649 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
650 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
651 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
652 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
654 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
655 DALI_TEST_CHECK(visual);
657 DummyControl actor = DummyControl::New(true);
658 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
659 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
661 Vector2 controlSize(20.f, 30.f);
662 actor.SetProperty(Actor::Property::SIZE, controlSize);
664 application.GetScene().Add(actor);
666 Property::Map attributes;
667 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
669 application.SendNotification();
670 application.Render();
672 // Trigger count is 2 - load & render a frame
673 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
675 // renderer is added to actor
676 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
677 Renderer renderer = actor.GetRendererAt(0u);
678 DALI_TEST_CHECK(renderer);
683 int UtcDaliAnimatedVectorImageVisualPlayRange(void)
685 ToolkitTestApplication application;
686 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRange");
688 int startFrame = 1, endFrame = 3;
689 Property::Array array;
690 array.PushBack(endFrame);
691 array.PushBack(startFrame);
693 Property::Map propertyMap;
694 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
695 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
696 .Add(DevelImageVisual::Property::PLAY_RANGE, array)
697 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
699 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
700 DALI_TEST_CHECK(visual);
702 DummyControl actor = DummyControl::New(true);
703 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
704 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
706 Vector2 controlSize(20.f, 30.f);
707 actor.SetProperty(Actor::Property::SIZE, controlSize);
709 application.GetScene().Add(actor);
711 Property::Map attributes;
712 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
714 application.SendNotification();
715 application.Render();
717 // Trigger count is 2 - load & render a frame
718 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
720 // renderer is added to actor
721 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
722 Renderer renderer = actor.GetRendererAt(0u);
723 DALI_TEST_CHECK(renderer);
725 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
726 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
727 int totalFrameNumber = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER)->Get<int>();
729 int resultStartFrame, resultEndFrame;
730 Property::Array* result = value->GetArray();
731 result->GetElementAt(0).Get(resultStartFrame);
732 result->GetElementAt(1).Get(resultEndFrame);
734 DALI_TEST_EQUALS(startFrame, resultStartFrame, TEST_LOCATION);
735 DALI_TEST_EQUALS(endFrame, resultEndFrame, TEST_LOCATION);
737 // Set invalid play range
743 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
744 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
746 // To make event trigger
747 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
749 application.SendNotification();
750 application.Render();
752 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
754 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
755 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
757 result = value->GetArray();
758 result->GetElementAt(0).Get(resultStartFrame);
759 result->GetElementAt(1).Get(resultEndFrame);
761 DALI_TEST_EQUALS(resultStartFrame, 1, TEST_LOCATION);
762 DALI_TEST_EQUALS(resultEndFrame, totalFrameNumber - 1, TEST_LOCATION); // Should be clamped
764 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, Property::Map());
766 application.SendNotification();
767 application.Render();
769 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
771 // To make event trigger
772 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
774 application.SendNotification();
775 application.Render();
777 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
779 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
780 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
781 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
788 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
789 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
791 // To make event trigger
792 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
794 application.SendNotification();
795 application.Render();
797 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
799 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
800 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
802 result = value->GetArray();
803 result->GetElementAt(0).Get(resultStartFrame);
804 result->GetElementAt(1).Get(resultEndFrame);
806 DALI_TEST_EQUALS(0, resultStartFrame, TEST_LOCATION);
807 DALI_TEST_EQUALS(2, resultEndFrame, TEST_LOCATION);
809 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
810 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION); // CURRENT_FRAME_NUMBER should be changed also.
815 int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void)
817 ToolkitTestApplication application;
818 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRangeMarker");
820 Property::Array array;
821 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
823 Property::Map propertyMap;
824 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
825 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
826 .Add(DevelImageVisual::Property::PLAY_RANGE, array)
827 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
829 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
830 DALI_TEST_CHECK(visual);
832 DummyControl actor = DummyControl::New(true);
833 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
834 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
836 Vector2 controlSize(20.f, 30.f);
837 actor.SetProperty(Actor::Property::SIZE, controlSize);
839 application.GetScene().Add(actor);
841 Property::Map attributes;
842 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
844 application.SendNotification();
845 application.Render();
847 // Trigger count is 2 - load & render a frame
848 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
850 // renderer is added to actor
851 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
852 Renderer renderer = actor.GetRendererAt(0u);
853 DALI_TEST_CHECK(renderer);
855 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
856 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
858 int resultStartFrame, resultEndFrame;
859 Property::Array* result = value->GetArray();
860 result->GetElementAt(0).Get(resultStartFrame);
861 result->GetElementAt(1).Get(resultEndFrame);
863 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
864 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
868 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
869 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_2);
872 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
873 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
875 // To make event trigger
876 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
878 application.SendNotification();
879 application.Render();
881 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
883 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
884 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
886 result = value->GetArray();
887 result->GetElementAt(0).Get(resultStartFrame);
888 result->GetElementAt(1).Get(resultEndFrame);
890 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
891 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
893 // Set invalid play range
896 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
899 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
900 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
902 // To make event trigger
903 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
905 application.SendNotification();
906 application.Render();
908 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
910 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
911 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
913 result = value->GetArray();
914 result->GetElementAt(0).Get(resultStartFrame);
915 result->GetElementAt(1).Get(resultEndFrame);
917 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION); // Should not be changed
918 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
923 int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
925 ToolkitTestApplication application;
926 tet_infoline("UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal");
928 Property::Map propertyMap;
929 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
930 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
931 .Add(DevelImageVisual::Property::LOOP_COUNT, 3);
933 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
934 DALI_TEST_CHECK(visual);
936 DummyControl actor = DummyControl::New(true);
937 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
938 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
940 DevelControl::VisualEventSignal(actor).Connect(&VisualEventSignal);
942 Vector2 controlSize(20.f, 30.f);
943 actor.SetProperty(Actor::Property::SIZE, controlSize);
945 application.GetScene().Add(actor);
947 Property::Map attributes;
948 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
950 application.SendNotification();
951 application.Render();
953 // Wait for animation finish - render, finish
954 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
956 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
957 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
958 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
960 DALI_TEST_EQUALS(gAnimationFinishedSignalFired, true, TEST_LOCATION);
965 int UtcDaliAnimatedVectorImageVisualJumpTo(void)
967 ToolkitTestApplication application;
968 tet_infoline("UtcDaliAnimatedVectorImageVisualJumpTo");
970 Property::Map propertyMap;
971 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
972 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
973 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
974 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
976 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
977 DALI_TEST_CHECK(visual);
979 tet_printf("1. Visual is created.\n");
981 DummyControl actor = DummyControl::New(true);
982 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
983 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
985 Vector2 controlSize(20.f, 30.f);
986 actor.SetProperty(Actor::Property::SIZE, controlSize);
988 application.GetScene().Add(actor);
990 application.SendNotification();
991 application.Render();
993 // Trigger count is 2 - load & render a frame
994 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
996 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2);
998 // To make event trigger
999 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1001 application.SendNotification();
1002 application.Render();
1004 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1006 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1007 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1008 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1010 tet_printf("2. The current frame number is [%d].\n", value->Get<int>());
1012 Property::Array array;
1016 Property::Map attributes;
1017 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1018 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1020 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1022 // To make event trigger
1023 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1025 application.SendNotification();
1026 application.Render();
1028 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1030 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1031 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1032 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1034 tet_printf("3. The current frame number is [%d].\n", value->Get<int>());
1036 // Change play range
1043 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1044 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1047 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1049 application.SendNotification();
1050 application.Render();
1052 // Wait for animation finish
1053 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1056 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1058 // To make event trigger
1059 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1061 application.SendNotification();
1062 application.Render();
1064 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1066 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1067 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1068 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1070 tet_printf("4. The current frame number is [%d].\n", value->Get<int>());
1072 // Jump to the same position
1073 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1075 // To make event trigger
1076 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1078 application.SendNotification();
1079 application.Render();
1081 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1083 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1084 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1085 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1087 tet_printf("5. The current frame number is [%d].\n", value->Get<int>());
1092 int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
1094 ToolkitTestApplication application;
1095 tet_infoline("UtcDaliAnimatedVectorImageVisualUpdateProperty");
1097 int startFrame = 1, endFrame = 3;
1098 Property::Array playRange;
1099 playRange.PushBack(startFrame);
1100 playRange.PushBack(endFrame);
1102 Property::Map propertyMap;
1103 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1104 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1105 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1106 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
1107 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1109 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1110 DALI_TEST_CHECK(visual);
1112 DummyControl actor = DummyControl::New(true);
1113 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1114 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1116 Vector2 controlSize(20.f, 30.f);
1117 actor.SetProperty(Actor::Property::SIZE, controlSize);
1119 application.GetScene().Add(actor);
1121 application.SendNotification();
1122 application.Render();
1124 // Trigger count is 2 - load & render a frame
1125 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1127 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1128 Property::Value* value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1129 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1131 value = map.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
1132 DALI_TEST_CHECK(value);
1134 Property::Array* result = value->GetArray();
1135 DALI_TEST_CHECK(result);
1137 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1138 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1141 playRange.PushBack(0);
1142 playRange.PushBack(2);
1144 Property::Map attributes;
1145 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1146 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 5);
1148 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1150 // To make event trigger
1151 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1153 application.SendNotification();
1154 application.Render();
1156 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1158 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1159 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1160 DALI_TEST_EQUALS(value->Get<int>(), 5, TEST_LOCATION);
1162 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1163 result = value->GetArray();
1164 DALI_TEST_CHECK(result);
1166 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == 0);
1167 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == 2);
1172 playRange.PushBack(startFrame);
1173 playRange.PushBack(endFrame);
1175 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1177 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1179 // To make event trigger
1180 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1182 application.SendNotification();
1183 application.Render();
1185 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1187 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1188 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1190 result = value->GetArray();
1191 DALI_TEST_CHECK(result);
1193 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1194 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1196 // Play and update property
1198 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1200 application.SendNotification();
1201 application.Render();
1203 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 10);
1205 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1207 application.SendNotification();
1208 application.Render();
1210 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1211 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1212 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
1217 int UtcDaliAnimatedVectorImageVisualStopBehavior(void)
1219 ToolkitTestApplication application;
1220 tet_infoline("UtcDaliAnimatedVectorImageVisualStopBehavior");
1222 Property::Map propertyMap;
1223 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1224 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1225 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1226 .Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME)
1227 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1229 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1230 DALI_TEST_CHECK(visual);
1232 DummyControl actor = DummyControl::New(true);
1233 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1234 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1236 Vector2 controlSize(20.f, 30.f);
1237 actor.SetProperty(Actor::Property::SIZE, controlSize);
1239 application.GetScene().Add(actor);
1241 Property::Map 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 3 - load, render, animation finished
1248 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1250 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1251 Property::Value* 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 stop behavior
1255 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1257 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1262 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1264 application.SendNotification();
1265 application.Render();
1267 // Trigger count is 1 - animation finished
1268 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1270 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1272 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1273 int totalFrameNumber = value1->Get<int>();
1275 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1276 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1278 // Change stop behavior
1279 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1280 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, -1);
1282 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1287 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1289 application.SendNotification();
1290 application.Render();
1293 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
1295 // To make event trigger
1296 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1298 application.SendNotification();
1299 application.Render();
1301 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1303 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1304 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1305 int currentFrameNumber = value->Get<int>();
1308 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
1310 // To make event trigger
1311 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1313 application.SendNotification();
1314 application.Render();
1316 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1318 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1319 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1320 DALI_TEST_EQUALS(value->Get<int>(), currentFrameNumber, TEST_LOCATION); // Should be same with currentFrameNumber
1325 int UtcDaliAnimatedVectorImageVisualLoopingMode(void)
1327 ToolkitTestApplication application;
1328 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopingMode");
1330 Property::Map propertyMap;
1331 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1332 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1333 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1334 .Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME)
1335 .Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::AUTO_REVERSE)
1336 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1338 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1339 DALI_TEST_CHECK(visual);
1341 DummyControl actor = DummyControl::New(true);
1342 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1343 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1345 Vector2 controlSize(20.f, 30.f);
1346 actor.SetProperty(Actor::Property::SIZE, controlSize);
1348 application.GetScene().Add(actor);
1350 Property::Map attributes;
1351 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1353 application.SendNotification();
1354 application.Render();
1356 // Trigger count is 3 - load, render, animation finished
1357 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1359 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1360 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1361 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame because of auto reverse
1363 // Change stop behavior
1364 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1366 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1369 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1371 application.SendNotification();
1372 application.Render();
1374 // Trigger count is 1 - animation finished
1375 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1377 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1378 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1379 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1381 // Change looping mode
1382 attributes.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::RESTART);
1384 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1387 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1389 application.SendNotification();
1390 application.Render();
1392 // Trigger count is 1 - animation finished
1393 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1395 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1396 int totalFrameNumber = value1->Get<int>();
1398 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1399 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1400 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1405 int UtcDaliAnimatedVectorImageVisualPropertyNotification(void)
1407 ToolkitTestApplication application;
1408 tet_infoline("UtcDaliAnimatedVectorImageVisualPropertyNotification");
1410 Property::Map propertyMap;
1411 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1412 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1414 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1415 DALI_TEST_CHECK(visual);
1417 DummyControl actor = DummyControl::New(true);
1418 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1419 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1420 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1422 application.GetScene().Add(actor);
1424 application.SendNotification();
1425 application.Render();
1427 // Trigger count is 1 - render a frame
1428 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1430 Renderer renderer = actor.GetRendererAt(0u);
1431 DALI_TEST_CHECK(renderer);
1433 Vector2 controlSize(20.f, 30.f);
1434 actor.SetProperty(Actor::Property::SIZE, controlSize);
1436 application.SendNotification();
1437 application.Render();
1439 application.SendNotification();
1440 application.Render();
1442 // Trigger count is 1 - render a frame
1443 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1445 auto textureSet = renderer.GetTextures();
1446 auto texture = textureSet.GetTexture(0);
1448 DALI_TEST_EQUALS(controlSize.width, texture.GetWidth(), TEST_LOCATION);
1449 DALI_TEST_EQUALS(controlSize.height, texture.GetHeight(), TEST_LOCATION);
1452 Vector3 controlScale(2.0f, 2.0f, 1.0f);
1453 actor.SetProperty(Actor::Property::SCALE, controlScale);
1455 application.SendNotification();
1456 application.Render();
1458 application.SendNotification();
1459 application.Render();
1461 // Trigger count is 1 - render a frame
1462 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1464 renderer = actor.GetRendererAt(0u);
1465 DALI_TEST_CHECK(renderer);
1467 textureSet = renderer.GetTextures();
1468 texture = textureSet.GetTexture(0);
1470 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1471 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1474 controlSize = Vector2(50.0f, 100.0f);
1475 Animation animation = Animation::New(1.0);
1476 animation.AnimateTo(Property(actor, Actor::Property::SIZE), Vector3(controlSize.x, controlSize.y, 0.0f));
1479 application.SendNotification();
1480 application.Render(1100); // After the animation
1482 application.SendNotification();
1483 application.Render();
1485 // Trigger count is 1 - render a frame
1486 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1488 renderer = actor.GetRendererAt(0u);
1489 DALI_TEST_CHECK(renderer);
1491 textureSet = renderer.GetTextures();
1492 texture = textureSet.GetTexture(0);
1494 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1495 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1500 int UtcDaliAnimatedVectorImageVisualMultipleInstances(void)
1502 ToolkitTestApplication application;
1503 tet_infoline("UtcDaliAnimatedVectorImageVisualMultipleInstances");
1505 Property::Map propertyMap;
1506 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1507 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1508 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1510 Visual::Base visual1 = VisualFactory::Get().CreateVisual(propertyMap);
1511 DALI_TEST_CHECK(visual1);
1513 DummyControl actor1 = DummyControl::New(true);
1514 DummyControlImpl& dummyImpl1 = static_cast<DummyControlImpl&>(actor1.GetImplementation());
1515 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual1);
1517 Vector2 controlSize(20.f, 30.f);
1518 actor1.SetProperty(Actor::Property::SIZE, controlSize);
1520 application.GetScene().Add(actor1);
1522 propertyMap.Clear();
1523 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1524 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1525 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1527 Visual::Base visual2 = VisualFactory::Get().CreateVisual(propertyMap);
1528 DALI_TEST_CHECK(visual2);
1530 DummyControl actor2 = DummyControl::New(true);
1531 DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor2.GetImplementation());
1532 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
1534 actor2.SetProperty(Actor::Property::SIZE, controlSize);
1536 application.GetScene().Add(actor2);
1538 application.SendNotification();
1539 application.Render();
1541 // Trigger count is 4 - load & render a frame for each instance
1542 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1544 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1546 // To make event trigger
1547 actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1549 application.SendNotification();
1550 application.Render();
1552 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1554 Property::Map attributes;
1555 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1557 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1558 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1560 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1562 // renderer is added to actor
1563 DALI_TEST_CHECK(actor1.GetRendererCount() == 1u);
1564 Renderer renderer1 = actor1.GetRendererAt(0u);
1565 DALI_TEST_CHECK(renderer1);
1567 // renderer is added to actor
1568 DALI_TEST_CHECK(actor2.GetRendererCount() == 1u);
1569 Renderer renderer2 = actor2.GetRendererAt(0u);
1570 DALI_TEST_CHECK(renderer2);
1575 int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void)
1577 ToolkitTestApplication application;
1578 tet_infoline("UtcDaliAnimatedVectorImageVisualControlVisibilityChanged");
1580 Property::Map propertyMap;
1581 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1582 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1583 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1585 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1586 DALI_TEST_CHECK(visual);
1588 DummyControl actor = DummyControl::New(true);
1589 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1590 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1592 Vector2 controlSize(20.f, 30.f);
1593 actor.SetProperty(Actor::Property::SIZE, controlSize);
1595 application.GetScene().Add(actor);
1597 application.SendNotification();
1598 application.Render();
1600 // Trigger count is 2 - load & render a frame
1601 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1603 Property::Map attributes;
1604 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1606 application.SendNotification();
1607 application.Render();
1609 // Check rendering behavior
1610 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1611 Renderer renderer = actor.GetRendererAt(0u);
1612 DALI_TEST_CHECK(renderer);
1613 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1615 actor.SetProperty(Actor::Property::VISIBLE, false);
1617 application.SendNotification();
1618 application.Render();
1620 // Check rendering behavior again
1621 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1626 int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void)
1628 ToolkitTestApplication application;
1629 tet_infoline("UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged");
1631 Property::Map propertyMap;
1632 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1633 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1635 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1636 DALI_TEST_CHECK(visual);
1638 DummyControl actor = DummyControl::New(true);
1639 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1640 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1642 Vector2 controlSize(20.f, 30.f);
1643 actor.SetProperty(Actor::Property::SIZE, controlSize);
1645 application.GetScene().Add(actor);
1647 application.SendNotification();
1648 application.Render();
1650 // Trigger count is 1 - render a frame
1651 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1653 Property::Map attributes;
1654 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1656 application.SendNotification();
1657 application.Render();
1659 // Check rendering behavior
1660 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1661 Renderer renderer = actor.GetRendererAt(0u);
1662 DALI_TEST_CHECK(renderer);
1663 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1665 Window window = DevelWindow::Get(actor);
1668 application.SendNotification();
1669 application.Render();
1671 // Check rendering behavior again
1672 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1677 int UtcDaliAnimatedVectorImageVisualInvalidFile01(void)
1679 ToolkitTestApplication application;
1680 tet_infoline("Request loading with invalid file - should draw broken image");
1682 TestGlAbstraction& gl = application.GetGlAbstraction();
1683 TraceCallStack& textureTrace = gl.GetTextureTrace();
1684 textureTrace.Enable(true);
1686 Property::Map propertyMap;
1687 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1688 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1689 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1691 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1692 DALI_TEST_CHECK(visual);
1694 DummyControl actor = DummyControl::New(true);
1695 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1696 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1698 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1700 application.GetScene().Add(actor);
1702 application.SendNotification();
1703 application.Render();
1705 // Trigger count is 1 - load
1706 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1708 application.SendNotification();
1709 application.Render();
1711 // Check resource status
1712 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1713 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1715 // The broken image should be shown.
1716 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1717 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1722 int UtcDaliAnimatedVectorImageVisualInvalidFile02(void)
1724 ToolkitTestApplication application;
1725 tet_infoline("Request loading with invalid file - should draw broken image");
1727 TestGlAbstraction& gl = application.GetGlAbstraction();
1728 TraceCallStack& textureTrace = gl.GetTextureTrace();
1729 textureTrace.Enable(true);
1731 Property::Map propertyMap;
1732 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1733 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
1735 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1736 DALI_TEST_CHECK(visual);
1738 DummyControl actor = DummyControl::New(true);
1739 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1740 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1742 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1744 application.SendNotification();
1745 application.Render();
1747 // Add to the Scene after loading
1748 application.GetScene().Add(actor);
1750 application.SendNotification();
1751 application.Render();
1753 // Check resource status
1754 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1755 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1757 // The broken image should be shown.
1758 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1759 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1764 int UtcDaliAnimatedVectorImageVisualInvalidFile03(void)
1766 ToolkitTestApplication application;
1767 tet_infoline("Request loading with invalid file without size set - should draw broken image");
1769 TestGlAbstraction& gl = application.GetGlAbstraction();
1770 TraceCallStack& textureTrace = gl.GetTextureTrace();
1771 textureTrace.Enable(true);
1773 Property::Map propertyMap;
1774 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1775 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1776 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1778 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1779 DALI_TEST_CHECK(visual);
1781 DummyControl actor = DummyControl::New(true);
1782 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1783 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1785 application.GetScene().Add(actor);
1787 application.SendNotification();
1788 application.Render();
1790 // Trigger count is 1 - load
1791 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1793 application.SendNotification();
1794 application.Render();
1796 // Check resource status
1797 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1798 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1800 // The broken image should be shown.
1801 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1802 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1807 int UtcDaliAnimatedVectorImageVisualFrameDrops(void)
1809 ToolkitTestApplication application;
1810 tet_infoline("UtcDaliAnimatedVectorImageVisualFrameDrops");
1812 Property::Map propertyMap;
1813 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1814 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP)
1815 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1817 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1818 DALI_TEST_CHECK(visual);
1820 DummyControl actor = DummyControl::New(true);
1821 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1822 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1824 Vector2 controlSize(20.f, 30.f);
1825 actor.SetProperty(Actor::Property::SIZE, controlSize);
1827 application.GetScene().Add(actor);
1829 application.SendNotification();
1830 application.Render();
1832 // Trigger count is 2 - load, render the first frame
1833 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1835 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1836 Property::Value* value = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1837 int totalFrameNumber = value->Get<int>();
1839 Property::Map attributes;
1840 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1842 // Make delay to drop frames
1843 Test::VectorAnimationRenderer::DelayRendering(170); // longer than 16.6 * 10frames
1845 application.SendNotification();
1846 application.Render();
1848 // Trigger count is 1 - calculating frame drops
1849 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1851 // Check dropped frame
1852 uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames();
1853 DALI_TEST_CHECK(frames > 0);
1854 DALI_TEST_CHECK(frames <= static_cast<uint32_t>(totalFrameNumber));
1859 int UtcDaliAnimatedVectorImageVisualSize(void)
1861 ToolkitTestApplication application;
1862 tet_infoline("UtcDaliAnimatedVectorImageVisualSize");
1864 TestGlAbstraction& gl = application.GetGlAbstraction();
1865 TraceCallStack& textureTrace = gl.GetTextureTrace();
1867 VisualFactory factory = VisualFactory::Get();
1868 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
1869 DALI_TEST_CHECK(visual);
1871 DummyControl actor = DummyControl::New(true);
1872 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1873 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1875 application.GetScene().Add(actor);
1877 application.SendNotification();
1878 application.Render();
1880 // Trigger count is 1 - resource ready
1881 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1883 textureTrace.Enable(true);
1885 application.SendNotification();
1886 application.Render();
1889 int width = 100, height = 100; // 100x100 is the content default size.
1890 std::stringstream out;
1891 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
1892 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
1895 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
1897 application.SendNotification();
1898 application.Render();
1900 // Trigger count is 1 - resource ready
1901 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1903 textureTrace.Reset();
1905 application.SendNotification();
1906 application.Render();
1909 int width = 200, height = 200;
1910 std::stringstream out;
1911 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
1912 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
1920 bool gDynamicPropertyCallbackFired = false;
1922 Property::Value FillColorCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber)
1924 gDynamicPropertyCallbackFired = true;
1928 return Vector3(0, 0, 1);
1932 return Vector3(1, 0, 0);
1937 int UtcDaliAnimatedVectorImageVisualDynamicProperty(void)
1939 ToolkitTestApplication application;
1940 tet_infoline("UtcDaliAnimatedVectorImageVisualDynamicProperty");
1942 VisualFactory factory = VisualFactory::Get();
1943 Visual::Base visual = factory.CreateVisual(
1945 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1946 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1947 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
1948 DALI_TEST_CHECK(visual);
1950 DummyControl actor = DummyControl::New(true);
1951 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1952 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1954 application.GetScene().Add(actor);
1956 gDynamicPropertyCallbackFired = false;
1958 // Set dynamic property
1959 DevelAnimatedVectorImageVisual::DynamicPropertyInfo info;
1961 info.keyPath = "Test.Path";
1962 info.property = static_cast<int>(VectorAnimationRenderer::VectorProperty::FILL_COLOR);
1963 info.callback = MakeCallback(FillColorCallback);
1965 DevelControl::DoActionExtension(actor, DummyControl::Property::TEST_VISUAL, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info));
1967 Property::Map attributes;
1968 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1970 application.SendNotification();
1971 application.Render();
1973 // Trigger count is 2 - load & render a frame
1974 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1976 // Test whether the property callback is called
1977 DALI_TEST_EQUALS(gDynamicPropertyCallbackFired, true, TEST_LOCATION);