2 * Copyright (c) 2023 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 int desiredWidth = 100, desiredHeight = 150;
194 float cornerRadius = 22.0f;
195 float borderlineWidth = 2.0f;
196 Vector4 borderlineColor = Vector4(1.0f, 1.0f, 1.0f, 1.0f);
197 float borderlineOffset = 0.1f;
198 Property::Array playRange;
199 playRange.PushBack(startFrame);
200 playRange.PushBack(endFrame);
202 Property::Map propertyMap;
203 propertyMap.Add("visualType", DevelVisual::ANIMATED_VECTOR_IMAGE)
204 .Add("url", TEST_VECTOR_IMAGE_FILE_NAME)
206 .Add("playRange", playRange)
207 .Add("stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME)
208 .Add("loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE)
209 .Add("redrawInScalingDown", false)
210 .Add("cornerRadius", cornerRadius)
211 .Add("borderlineWidth", borderlineWidth)
212 .Add("borderlineColor", borderlineColor)
213 .Add("borderlineOffset", borderlineOffset)
214 .Add("desiredWidth", desiredWidth)
215 .Add("desiredHeight", desiredHeight)
216 .Add("useFixedCache", false);
218 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
219 DALI_TEST_CHECK(visual);
221 DummyControl actor = DummyControl::New(true);
222 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
223 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
224 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
225 application.GetScene().Add(actor);
227 application.SendNotification();
228 application.Render();
230 // Trigger count is 1 - render a frame
231 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
233 // renderer is added to actor
234 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
236 Renderer renderer = actor.GetRendererAt(0u);
237 DALI_TEST_CHECK(renderer);
239 Property::Map resultMap;
240 visual.CreatePropertyMap(resultMap);
242 // check the property values from the returned map from a visual
243 Property::Value* value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
244 DALI_TEST_CHECK(value);
245 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
247 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
248 DALI_TEST_CHECK(value);
249 DALI_TEST_CHECK(value->Get<int>() == 3);
251 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
252 DALI_TEST_CHECK(value);
254 Property::Array* result = value->GetArray();
255 DALI_TEST_CHECK(result);
257 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
258 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
260 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
261 DALI_TEST_CHECK(value);
262 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::FIRST_FRAME);
264 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
265 DALI_TEST_CHECK(value);
266 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::AUTO_REVERSE);
268 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
269 DALI_TEST_CHECK(value);
270 DALI_TEST_CHECK(value->Get<bool>() == false);
272 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
273 DALI_TEST_CHECK(value);
274 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius), TEST_LOCATION);
276 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
277 DALI_TEST_CHECK(value);
278 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
280 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT);
281 DALI_TEST_CHECK(value);
282 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
284 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
285 DALI_TEST_CHECK(value);
286 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
288 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
289 DALI_TEST_CHECK(value);
290 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
292 value = resultMap.Find(ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER);
293 DALI_TEST_CHECK(value);
294 DALI_TEST_EQUALS(value->Get<int>(), desiredWidth, TEST_LOCATION);
296 value = resultMap.Find(ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER);
297 DALI_TEST_CHECK(value);
298 DALI_TEST_EQUALS(value->Get<int>(), desiredHeight, TEST_LOCATION);
301 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
306 int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
308 ToolkitTestApplication application;
309 tet_infoline("UtcDaliAnimatedVectorImageVisualGetPropertyMap01");
311 int startFrame = 1, endFrame = 3;
312 int desiredWidth = 100, desiredHeight = 150;
313 Vector4 cornerRadius(50.0f, 22.0f, 0.0f, 3.0f);
314 float borderlineWidth = 2.3f;
315 Vector4 borderlineColor = Vector4(0.3f, 0.3f, 1.0f, 1.0f);
316 float borderlineOffset = 0.3f;
317 Property::Array playRange;
318 playRange.PushBack(startFrame);
319 playRange.PushBack(endFrame);
321 Property::Map propertyMap;
322 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
323 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
324 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
325 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
326 .Add(DevelVisual::Property::CORNER_RADIUS, cornerRadius)
327 .Add(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::RELATIVE)
328 .Add(DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth)
329 .Add(DevelVisual::Property::BORDERLINE_COLOR, borderlineColor)
330 .Add(DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset)
331 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false)
332 .Add(ImageVisual::Property::DESIRED_WIDTH, desiredWidth)
333 .Add(ImageVisual::Property::DESIRED_HEIGHT, desiredHeight);
335 // request AnimatedVectorImageVisual with a property map
336 VisualFactory factory = VisualFactory::Get();
337 Visual::Base visual = factory.CreateVisual(propertyMap);
339 DummyControl actor = DummyControl::New(true);
340 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
341 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
343 Vector2 controlSize(20.f, 30.f);
344 actor.SetProperty(Actor::Property::SIZE, controlSize);
346 application.GetScene().Add(actor);
348 application.SendNotification();
349 application.Render();
351 // Trigger count is 2 - load & render a frame
352 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
354 Property::Map resultMap;
355 resultMap = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
357 // check the property values from the returned map from a visual
358 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
359 DALI_TEST_CHECK(value);
360 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
362 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
363 DALI_TEST_CHECK(value);
364 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
366 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
367 DALI_TEST_CHECK(value);
368 DALI_TEST_CHECK(value->Get<int>() == 3);
370 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
371 DALI_TEST_CHECK(value);
373 Property::Array* result = value->GetArray();
374 DALI_TEST_CHECK(result);
376 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
377 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
379 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
380 DALI_TEST_CHECK(value);
381 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::CURRENT_FRAME);
383 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
384 DALI_TEST_CHECK(value);
385 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::RESTART);
387 value = resultMap.Find(DevelImageVisual::Property::CONTENT_INFO, Property::MAP);
388 DALI_TEST_CHECK(value);
390 value = resultMap.Find(DevelImageVisual::Property::MARKER_INFO, Property::MAP);
391 DALI_TEST_CHECK(value);
393 value = resultMap.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE, Property::BOOLEAN);
394 DALI_TEST_CHECK(value);
395 DALI_TEST_CHECK(value->Get<bool>() == false); // Check default value
397 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
398 DALI_TEST_CHECK(value);
399 DALI_TEST_CHECK(value->Get<bool>() == true); // Check default value
401 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
402 DALI_TEST_CHECK(value);
403 DALI_TEST_EQUALS(value->Get<Vector4>(), cornerRadius, TEST_LOCATION);
405 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
406 DALI_TEST_CHECK(value);
407 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::RELATIVE);
409 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
410 DALI_TEST_CHECK(value);
411 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
413 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
414 DALI_TEST_CHECK(value);
415 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
417 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
418 DALI_TEST_CHECK(value);
419 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
421 value = resultMap.Find(ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER);
422 DALI_TEST_CHECK(value);
423 DALI_TEST_EQUALS(value->Get<int>(), desiredWidth, TEST_LOCATION);
425 value = resultMap.Find(ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER);
426 DALI_TEST_CHECK(value);
427 DALI_TEST_EQUALS(value->Get<int>(), desiredHeight, TEST_LOCATION);
429 // request AnimatedVectorImageVisual with an URL
430 Visual::Base visual2 = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
433 visual2.CreatePropertyMap(resultMap);
435 // check the property values from the returned map from a visual
436 value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
437 DALI_TEST_CHECK(value);
438 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
440 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
441 DALI_TEST_CHECK(value);
442 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
447 int UtcDaliAnimatedVectorImageVisualPlayback(void)
449 ToolkitTestApplication application;
451 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayback");
454 // request AnimatedVectorImageVisual with a property map
455 VisualFactory factory = VisualFactory::Get();
456 Visual::Base visual = factory.CreateVisual(
458 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
459 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
460 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
462 DummyControl dummyControl = DummyControl::New(true);
463 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
464 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
465 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
467 Property::Map attributes;
468 tet_infoline("Test Play action");
469 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
471 application.GetScene().Add(dummyControl);
472 application.SendNotification();
473 application.Render(16);
475 Property::Map map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
476 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
477 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
479 tet_infoline("Test Pause action");
480 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
482 application.SendNotification();
483 application.Render(16);
485 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
486 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
487 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PAUSED);
489 tet_infoline("Test Play action");
490 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
492 application.SendNotification();
493 application.Render(16);
495 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
496 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
497 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
499 tet_infoline("Test Stop action");
500 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
502 application.SendNotification();
503 application.Render(16);
505 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
506 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
507 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
509 tet_infoline("Test Stop action again");
510 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
512 application.SendNotification();
513 application.Render(16);
515 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
516 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
517 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
519 tet_infoline("Test Play action");
520 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
522 application.SendNotification();
523 application.Render(16);
525 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
526 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
527 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
529 tet_infoline("Off stage");
530 dummyControl.Unparent();
532 application.SendNotification();
533 application.Render(16);
535 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
536 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
537 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
539 tet_infoline("On stage again");
540 application.GetScene().Add(dummyControl);
542 application.SendNotification();
543 application.Render(16);
545 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
546 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
547 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
549 tet_infoline("Test Play action");
550 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
552 application.SendNotification();
553 application.Render(16);
555 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
556 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
557 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
560 Vector3 newSize(100.0f, 100.0f, 0.0f);
561 dummyControl.SetProperty(Actor::Property::SIZE, newSize);
563 application.SendNotification();
564 application.Render(16);
566 // Size should be changed
567 Vector3 naturalSize = dummyControl.GetNaturalSize();
568 DALI_TEST_CHECK(naturalSize == newSize);
570 dummyControl.Unparent();
576 int UtcDaliAnimatedVectorImageVisualCustomShader(void)
578 ToolkitTestApplication application;
579 tet_infoline("UtcDaliAnimatedVectorImageVisualCustomShader Test custom shader");
581 VisualFactory factory = VisualFactory::Get();
582 Property::Map properties;
583 Property::Map shader;
584 const std::string vertexShader = "Foobar";
585 const std::string fragmentShader = "Foobar sampler2D Foobar";
586 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
587 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
589 properties[Visual::Property::TYPE] = Visual::IMAGE;
590 properties[Visual::Property::SHADER] = shader;
591 properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
593 Visual::Base visual = factory.CreateVisual(properties);
595 // trigger creation through setting on stage
596 DummyControl dummy = DummyControl::New(true);
597 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
598 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
600 dummy.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
601 dummy.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
602 application.GetScene().Add(dummy);
604 application.SendNotification();
605 application.Render();
607 // Trigger count is 1 - render a frame
608 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
610 Renderer renderer = dummy.GetRendererAt(0);
611 Shader shader2 = renderer.GetShader();
612 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
613 Property::Map* map = value.GetMap();
614 DALI_TEST_CHECK(map);
616 std::string resultFragmentShader, resultVertexShader;
617 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
618 fragment->Get(resultFragmentShader);
619 DALI_TEST_CHECK(resultFragmentShader.find(fragmentShader) != std::string::npos);
621 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
622 vertex->Get(resultVertexShader);
623 DALI_TEST_CHECK(resultVertexShader.find(vertexShader) != std::string::npos);
628 int UtcDaliAnimatedVectorImageVisualNaturalSize(void)
630 ToolkitTestApplication application;
631 tet_infoline("UtcDaliAnimatedVectorImageVisualNaturalSize");
633 VisualFactory factory = VisualFactory::Get();
634 Visual::Base visual = factory.CreateVisual(
636 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
637 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
638 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
639 DALI_TEST_CHECK(visual);
641 DummyControl actor = DummyControl::New(true);
642 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
643 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
645 Vector2 controlSize(20.f, 30.f);
648 application.GetScene().Add(actor);
650 application.SendNotification();
651 application.Render();
653 // Trigger count is 1 - load
654 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
656 visual.GetNaturalSize(naturalSize);
658 DALI_TEST_EQUALS(naturalSize, Vector2(100.0f, 100.0f), TEST_LOCATION); // 100x100 is the content default size.
660 actor.SetProperty(Actor::Property::SIZE, controlSize);
662 application.SendNotification();
663 application.Render();
665 visual.GetNaturalSize(naturalSize);
667 DALI_TEST_EQUALS(naturalSize, controlSize, TEST_LOCATION);
672 int UtcDaliAnimatedVectorImageVisualLoopCount(void)
674 ToolkitTestApplication application;
675 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopCount");
677 Property::Map propertyMap;
678 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
679 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
680 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
681 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
683 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
684 DALI_TEST_CHECK(visual);
686 DummyControl actor = DummyControl::New(true);
687 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
688 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
690 Vector2 controlSize(20.f, 30.f);
691 actor.SetProperty(Actor::Property::SIZE, controlSize);
693 application.GetScene().Add(actor);
695 Property::Map attributes;
696 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
698 application.SendNotification();
699 application.Render();
701 // Trigger count is 2 - load & render a frame
702 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
704 // renderer is added to actor
705 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
706 Renderer renderer = actor.GetRendererAt(0u);
707 DALI_TEST_CHECK(renderer);
712 int UtcDaliAnimatedVectorImageVisualPlayRange(void)
714 ToolkitTestApplication application;
715 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRange");
717 int startFrame = 1, endFrame = 3;
718 Property::Array array;
719 array.PushBack(endFrame);
720 array.PushBack(startFrame);
722 Property::Map propertyMap;
723 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
724 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
725 .Add(DevelImageVisual::Property::PLAY_RANGE, array)
726 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
728 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
729 DALI_TEST_CHECK(visual);
731 DummyControl actor = DummyControl::New(true);
732 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
733 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
735 Vector2 controlSize(20.f, 30.f);
736 actor.SetProperty(Actor::Property::SIZE, controlSize);
738 application.GetScene().Add(actor);
740 Property::Map attributes;
741 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
743 application.SendNotification();
744 application.Render();
746 // Trigger count is 2 - load & render a frame
747 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
749 // renderer is added to actor
750 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
751 Renderer renderer = actor.GetRendererAt(0u);
752 DALI_TEST_CHECK(renderer);
754 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
755 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
756 int totalFrameNumber = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER)->Get<int>();
758 int resultStartFrame, resultEndFrame;
759 Property::Array* result = value->GetArray();
760 result->GetElementAt(0).Get(resultStartFrame);
761 result->GetElementAt(1).Get(resultEndFrame);
763 DALI_TEST_EQUALS(startFrame, resultStartFrame, TEST_LOCATION);
764 DALI_TEST_EQUALS(endFrame, resultEndFrame, TEST_LOCATION);
766 // Set invalid play range
772 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
773 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
775 // To make event trigger
776 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
778 application.SendNotification();
779 application.Render();
781 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
783 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
784 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
786 result = value->GetArray();
787 result->GetElementAt(0).Get(resultStartFrame);
788 result->GetElementAt(1).Get(resultEndFrame);
790 DALI_TEST_EQUALS(resultStartFrame, 1, TEST_LOCATION);
791 DALI_TEST_EQUALS(resultEndFrame, totalFrameNumber - 1, TEST_LOCATION); // Should be clamped
793 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, Property::Map());
795 application.SendNotification();
796 application.Render();
798 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
800 // To make event trigger
801 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
803 application.SendNotification();
804 application.Render();
806 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
808 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
809 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
810 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
817 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
818 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
820 // To make event trigger
821 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
823 application.SendNotification();
824 application.Render();
826 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
828 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
829 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
831 result = value->GetArray();
832 result->GetElementAt(0).Get(resultStartFrame);
833 result->GetElementAt(1).Get(resultEndFrame);
835 DALI_TEST_EQUALS(0, resultStartFrame, TEST_LOCATION);
836 DALI_TEST_EQUALS(2, resultEndFrame, TEST_LOCATION);
838 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
839 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION); // CURRENT_FRAME_NUMBER should be changed also.
844 int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void)
846 ToolkitTestApplication application;
847 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRangeMarker");
849 // Set 1 marker as array
850 Property::Array array;
851 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
853 Property::Map propertyMap;
854 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
855 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
856 .Add(DevelImageVisual::Property::PLAY_RANGE, array)
857 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
859 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
860 DALI_TEST_CHECK(visual);
862 DummyControl actor = DummyControl::New(true);
863 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
864 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
866 Vector2 controlSize(20.f, 30.f);
867 actor.SetProperty(Actor::Property::SIZE, controlSize);
869 application.GetScene().Add(actor);
871 Property::Map attributes;
872 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
874 application.SendNotification();
875 application.Render();
877 // Trigger count is 2 - load & render a frame
878 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
880 // renderer is added to actor
881 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
882 Renderer renderer = actor.GetRendererAt(0u);
883 DALI_TEST_CHECK(renderer);
885 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
886 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
888 int resultStartFrame, resultEndFrame;
889 Property::Array* result = value->GetArray();
890 result->GetElementAt(0).Get(resultStartFrame);
891 result->GetElementAt(1).Get(resultEndFrame);
893 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
894 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
896 // Set 1 marker as string
900 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, VECTOR_ANIMATION_MARKER_NAME_1);
901 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
903 // To make event trigger
904 actor.SetProperty(Actor::Property::SIZE, Vector2(40.0f, 40.0f));
906 application.SendNotification();
907 application.Render();
909 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
911 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
912 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
914 result = value->GetArray();
915 result->GetElementAt(0).Get(resultStartFrame);
916 result->GetElementAt(1).Get(resultEndFrame);
918 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
919 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
923 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
924 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_2);
927 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
928 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
930 // To make event trigger
931 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
933 application.SendNotification();
934 application.Render();
936 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
938 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
939 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
941 result = value->GetArray();
942 result->GetElementAt(0).Get(resultStartFrame);
943 result->GetElementAt(1).Get(resultEndFrame);
945 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
946 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
948 // Set invalid play range
951 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
954 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
955 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
957 // To make event trigger
958 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
960 application.SendNotification();
961 application.Render();
963 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
965 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
966 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
968 result = value->GetArray();
969 result->GetElementAt(0).Get(resultStartFrame);
970 result->GetElementAt(1).Get(resultEndFrame);
972 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION); // Should not be changed
973 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
978 int UtcDaliAnimatedVectorImageVisualMarkerInfo(void)
980 ToolkitTestApplication application;
981 tet_infoline("UtcDaliAnimatedVectorImageVisualMarkerInfo");
983 Property::Map propertyMap;
984 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
985 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
986 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
988 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
989 DALI_TEST_CHECK(visual);
991 DummyControl actor = DummyControl::New(true);
992 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
993 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
995 Vector2 controlSize(20.f, 30.f);
996 actor.SetProperty(Actor::Property::SIZE, controlSize);
998 application.GetScene().Add(actor);
1000 Property::Map attributes;
1001 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1003 application.SendNotification();
1004 application.Render();
1006 // Trigger count is 2 - load & render a frame
1007 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1009 // renderer is added to actor
1010 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1011 Renderer renderer = actor.GetRendererAt(0u);
1012 DALI_TEST_CHECK(renderer);
1014 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1015 Property::Value* value = map.Find(DevelImageVisual::Property::MARKER_INFO);
1017 DALI_TEST_CHECK(value);
1019 Property::Map* result = value->GetMap();
1020 DALI_TEST_CHECK(result);
1022 std::string resultMarkerName;
1023 int resultStartFrame, resultEndFrame;
1024 DALI_TEST_EQUALS(2u, result->Count(), TEST_LOCATION);
1026 for(uint32_t i = 0u; i < result->Count(); ++i)
1028 if(result->GetKeyAt(i).stringKey == VECTOR_ANIMATION_MARKER_NAME_1)
1030 Property::Array* frameArray = result->GetValue(i).GetArray();
1031 DALI_TEST_CHECK(frameArray);
1032 frameArray->GetElementAt(0).Get(resultStartFrame);
1033 frameArray->GetElementAt(1).Get(resultEndFrame);
1035 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
1036 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
1038 else if(result->GetKeyAt(i).stringKey == VECTOR_ANIMATION_MARKER_NAME_2)
1040 Property::Array* frameArray = result->GetValue(i).GetArray();
1041 DALI_TEST_CHECK(frameArray);
1042 frameArray->GetElementAt(0).Get(resultStartFrame);
1043 frameArray->GetElementAt(1).Get(resultEndFrame);
1045 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_2, resultStartFrame, TEST_LOCATION);
1046 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
1050 DALI_TEST_CHECK(false);
1057 int UtcDaliAnimatedVectorImageVisualMarkerInfoFromInvalid(void)
1059 ToolkitTestApplication application;
1060 tet_infoline("UtcDaliAnimatedVectorImageVisualMarkerInfoFromInvalid");
1062 Property::Map propertyMap;
1063 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1064 .Add(ImageVisual::Property::URL, "invalid.json")
1065 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1067 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1068 DALI_TEST_CHECK(visual);
1070 DummyControl actor = DummyControl::New(true);
1071 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1072 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1074 Vector2 controlSize(20.f, 30.f);
1075 actor.SetProperty(Actor::Property::SIZE, controlSize);
1077 application.GetScene().Add(actor);
1079 Property::Map attributes;
1080 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1082 application.SendNotification();
1083 application.Render();
1085 // Trigger count is 1 - load, and failed.
1086 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1088 // renderer is added to actor
1089 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1090 Renderer renderer = actor.GetRendererAt(0u);
1091 DALI_TEST_CHECK(renderer);
1093 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1094 Property::Value* value = map.Find(DevelImageVisual::Property::MARKER_INFO);
1096 // The values when load failed case is invalid.
1097 DALI_TEST_CHECK(value == nullptr || (value->GetMap() == nullptr) || (value->GetMap()->Empty()));
1102 int UtcDaliAnimatedVectorImageVisualUsedFixedCache(void)
1104 ToolkitTestApplication application;
1105 tet_infoline("UtcDaliAnimatedVectorImageVisualUsedFixedCache");
1107 Property::Map propertyMap;
1108 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1109 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1110 .Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, true)
1111 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1113 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1114 DALI_TEST_CHECK(visual);
1116 DummyControl actor = DummyControl::New(true);
1117 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1118 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1119 //actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1120 application.GetScene().Add(actor);
1122 application.SendNotification();
1123 application.Render();
1125 // Trigger count is 1 - render a frame
1126 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1128 Vector2 controlSize(200.f, 200.f);
1129 actor.SetProperty(Actor::Property::SIZE, controlSize);
1131 application.SendNotification();
1132 application.Render();
1134 // Trigger count is 1 - load
1135 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1137 // renderer is added to actor
1138 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1139 Renderer renderer = actor.GetRendererAt(0u);
1140 DALI_TEST_CHECK(renderer);
1142 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1143 Property::Value* value = map.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE);
1144 DALI_TEST_CHECK(value->Get<bool>() == true);
1149 int UtcDaliAnimatedVectorImageVisualUsedFixedCacheFailed(void)
1151 ToolkitTestApplication application;
1152 tet_infoline("UtcDaliAnimatedVectorImageVisualUsedFixedCacheFailed");
1154 Property::Map propertyMap;
1155 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1156 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1157 .Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, true)
1158 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1160 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1161 DALI_TEST_CHECK(visual);
1163 DummyControl actor = DummyControl::New(true);
1164 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1165 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1167 Vector2 controlSize(200.f, 200.f);
1168 actor.SetProperty(Actor::Property::SIZE, controlSize);
1170 application.GetScene().Add(actor);
1171 application.SendNotification();
1172 application.Render();
1174 // Trigger count is 1 - load, and failed.
1175 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1177 // renderer is added to actor
1178 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1179 Renderer renderer = actor.GetRendererAt(0u);
1180 DALI_TEST_CHECK(renderer);
1182 propertyMap.Clear();
1183 propertyMap.Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, true)
1184 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1185 .Add(ImageVisual::Property::DESIRED_WIDTH, 100)
1186 .Add(ImageVisual::Property::DESIRED_HEIGHT, 100);
1187 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1189 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1190 Property::Value* value = map.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE);
1191 DALI_TEST_CHECK(value->Get<bool>() == true);
1196 int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
1198 ToolkitTestApplication application;
1199 tet_infoline("UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal");
1201 Property::Map propertyMap;
1202 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1203 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1205 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1206 DALI_TEST_CHECK(visual);
1208 DummyControl actor = DummyControl::New(true);
1209 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1210 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1212 DevelControl::VisualEventSignal(actor).Connect(&VisualEventSignal);
1214 Vector2 controlSize(20.f, 30.f);
1215 actor.SetProperty(Actor::Property::SIZE, controlSize);
1217 application.GetScene().Add(actor);
1219 application.SendNotification();
1220 application.Render();
1222 // Trigger count is 1 - render a frame
1223 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1225 propertyMap.Clear();
1226 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1227 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1229 Property::Map attributes;
1230 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1232 application.SendNotification();
1233 application.Render();
1235 // Wait for animation finish
1236 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1238 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1239 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
1240 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
1242 DALI_TEST_EQUALS(gAnimationFinishedSignalFired, true, TEST_LOCATION);
1247 int UtcDaliAnimatedVectorImageVisualJumpTo(void)
1249 ToolkitTestApplication application;
1250 tet_infoline("UtcDaliAnimatedVectorImageVisualJumpTo");
1252 Property::Map propertyMap;
1253 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1254 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1255 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1256 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1258 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1259 DALI_TEST_CHECK(visual);
1261 tet_printf("1. Visual is created.\n");
1263 DummyControl actor = DummyControl::New(true);
1264 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1265 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1267 Vector2 controlSize(20.f, 30.f);
1268 actor.SetProperty(Actor::Property::SIZE, controlSize);
1270 application.GetScene().Add(actor);
1272 application.SendNotification();
1273 application.Render();
1275 // Trigger count is 2 - load & render a frame
1276 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1278 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2);
1280 // To make event trigger
1281 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1283 application.SendNotification();
1284 application.Render();
1286 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1288 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1289 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1290 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1292 tet_printf("2. The current frame number is [%d].\n", value->Get<int>());
1294 Property::Array array;
1298 Property::Map attributes;
1299 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1300 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1302 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1304 // To make event trigger
1305 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1307 application.SendNotification();
1308 application.Render();
1310 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1312 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1313 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1314 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1316 tet_printf("3. The current frame number is [%d].\n", value->Get<int>());
1318 // Change play range
1325 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1326 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1329 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1331 application.SendNotification();
1332 application.Render();
1334 // Wait for animation finish
1335 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1338 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1340 // To make event trigger
1341 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1343 application.SendNotification();
1344 application.Render();
1346 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1348 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1349 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1350 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1352 tet_printf("4. The current frame number is [%d].\n", value->Get<int>());
1354 // Jump to the same position
1355 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1357 // To make event trigger
1358 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1360 application.SendNotification();
1361 application.Render();
1363 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1365 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1366 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1367 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1369 tet_printf("5. The current frame number is [%d].\n", value->Get<int>());
1374 int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
1376 ToolkitTestApplication application;
1377 tet_infoline("UtcDaliAnimatedVectorImageVisualUpdateProperty");
1379 int startFrame = 1, endFrame = 3;
1380 Property::Array playRange;
1381 playRange.PushBack(startFrame);
1382 playRange.PushBack(endFrame);
1384 Property::Map propertyMap;
1385 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1386 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1387 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1388 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
1389 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1391 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1392 DALI_TEST_CHECK(visual);
1394 DummyControl actor = DummyControl::New(true);
1395 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1396 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1398 Vector2 controlSize(20.f, 30.f);
1399 actor.SetProperty(Actor::Property::SIZE, controlSize);
1401 application.GetScene().Add(actor);
1403 application.SendNotification();
1404 application.Render();
1406 // Trigger count is 2 - load & render a frame
1407 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1409 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1410 Property::Value* value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1411 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1413 value = map.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
1414 DALI_TEST_CHECK(value);
1416 Property::Array* result = value->GetArray();
1417 DALI_TEST_CHECK(result);
1419 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1420 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1423 playRange.PushBack(0);
1424 playRange.PushBack(2);
1426 Property::Map attributes;
1427 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1428 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 5);
1430 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1432 // To make event trigger
1433 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1435 application.SendNotification();
1436 application.Render();
1438 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1440 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1441 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1442 DALI_TEST_EQUALS(value->Get<int>(), 5, TEST_LOCATION);
1444 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1445 result = value->GetArray();
1446 DALI_TEST_CHECK(result);
1448 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == 0);
1449 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == 2);
1454 playRange.PushBack(startFrame);
1455 playRange.PushBack(endFrame);
1457 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1459 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1461 // To make event trigger
1462 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1464 application.SendNotification();
1465 application.Render();
1467 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1469 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1470 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1472 result = value->GetArray();
1473 DALI_TEST_CHECK(result);
1475 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1476 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1478 // Play and update property
1480 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1482 application.SendNotification();
1483 application.Render();
1485 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 10);
1487 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1489 application.SendNotification();
1490 application.Render();
1492 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1493 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1494 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
1499 int UtcDaliAnimatedVectorImageVisualStopBehavior(void)
1501 ToolkitTestApplication application;
1502 tet_infoline("UtcDaliAnimatedVectorImageVisualStopBehavior");
1504 Property::Map propertyMap;
1505 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1506 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1507 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1509 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1510 DALI_TEST_CHECK(visual);
1512 DummyControl actor = DummyControl::New(true);
1513 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1514 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1516 Vector2 controlSize(20.f, 30.f);
1517 actor.SetProperty(Actor::Property::SIZE, controlSize);
1519 application.GetScene().Add(actor);
1521 application.SendNotification();
1522 application.Render();
1524 // Trigger count is 2 - load & render a frame
1525 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1527 propertyMap.Clear();
1528 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1529 propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
1530 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1532 Property::Map attributes;
1533 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1535 application.SendNotification();
1536 application.Render();
1538 // Trigger count is 1 - animation finished
1539 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1541 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1542 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1543 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1545 // Change stop behavior
1546 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1548 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1553 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1555 application.SendNotification();
1556 application.Render();
1558 // Trigger count is 1 - animation finished
1559 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1561 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1563 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1564 int totalFrameNumber = value1->Get<int>();
1566 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1567 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1569 // Change stop behavior
1570 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1571 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, -1);
1573 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1578 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1580 application.SendNotification();
1581 application.Render();
1584 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
1586 // To make event trigger
1587 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1589 application.SendNotification();
1590 application.Render();
1592 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1594 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1595 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1596 int currentFrameNumber = value->Get<int>();
1599 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
1601 // To make event trigger
1602 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1604 application.SendNotification();
1605 application.Render();
1607 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1609 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1610 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1611 DALI_TEST_EQUALS(value->Get<int>(), currentFrameNumber, TEST_LOCATION); // Should be same with currentFrameNumber
1616 int UtcDaliAnimatedVectorImageVisualLoopingMode(void)
1618 ToolkitTestApplication application;
1619 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopingMode");
1621 Property::Map propertyMap;
1622 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1623 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1624 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1626 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1627 DALI_TEST_CHECK(visual);
1629 DummyControl actor = DummyControl::New(true);
1630 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1631 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1633 Vector2 controlSize(20.f, 30.f);
1634 actor.SetProperty(Actor::Property::SIZE, controlSize);
1636 application.GetScene().Add(actor);
1638 application.SendNotification();
1639 application.Render();
1641 // Trigger count is 2 - load, render
1642 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1644 propertyMap.Clear();
1645 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1646 propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1647 propertyMap.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::AUTO_REVERSE);
1648 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1650 Property::Map attributes;
1651 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1653 application.SendNotification();
1654 application.Render();
1656 // Trigger count is 1 - animation finished
1657 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1659 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1660 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1661 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame because of auto reverse
1663 // Change stop behavior
1664 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1666 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1669 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1671 application.SendNotification();
1672 application.Render();
1674 // Trigger count is 1 - animation finished
1675 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1677 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1678 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1679 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1681 // Change looping mode
1682 attributes.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::RESTART);
1684 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1687 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1689 application.SendNotification();
1690 application.Render();
1692 // Trigger count is 1 - animation finished
1693 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1695 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1696 int totalFrameNumber = value1->Get<int>();
1698 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1699 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1700 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1705 int UtcDaliAnimatedVectorImageVisualPropertyNotification(void)
1707 ToolkitTestApplication application;
1708 tet_infoline("UtcDaliAnimatedVectorImageVisualPropertyNotification");
1710 Property::Map propertyMap;
1711 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1712 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1714 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1715 DALI_TEST_CHECK(visual);
1717 DummyControl actor = DummyControl::New(true);
1718 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1719 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1720 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1722 application.GetScene().Add(actor);
1724 application.SendNotification();
1725 application.Render();
1727 // Trigger count is 1 - render a frame
1728 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1730 Renderer renderer = actor.GetRendererAt(0u);
1731 DALI_TEST_CHECK(renderer);
1733 Vector2 controlSize(20.f, 30.f);
1734 actor.SetProperty(Actor::Property::SIZE, controlSize);
1736 application.SendNotification();
1737 application.Render();
1739 application.SendNotification();
1740 application.Render();
1742 // Trigger count is 1 - render a frame
1743 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1745 auto textureSet = renderer.GetTextures();
1746 auto texture = textureSet.GetTexture(0);
1748 DALI_TEST_EQUALS(controlSize.width, texture.GetWidth(), TEST_LOCATION);
1749 DALI_TEST_EQUALS(controlSize.height, texture.GetHeight(), TEST_LOCATION);
1752 Vector3 controlScale(2.0f, 2.0f, 1.0f);
1753 actor.SetProperty(Actor::Property::SCALE, controlScale);
1755 application.SendNotification();
1756 application.Render();
1758 application.SendNotification();
1759 application.Render();
1761 // Trigger count is 1 - render a frame
1762 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1764 renderer = actor.GetRendererAt(0u);
1765 DALI_TEST_CHECK(renderer);
1767 textureSet = renderer.GetTextures();
1768 texture = textureSet.GetTexture(0);
1770 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1771 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1774 controlSize = Vector2(50.0f, 100.0f);
1775 Animation animation = Animation::New(1.0);
1776 animation.AnimateTo(Property(actor, Actor::Property::SIZE), Vector3(controlSize.x, controlSize.y, 0.0f));
1779 application.SendNotification();
1780 application.Render(1100); // After the animation
1782 application.SendNotification();
1783 application.Render();
1785 // Trigger count is 1 - render a frame
1786 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1788 renderer = actor.GetRendererAt(0u);
1789 DALI_TEST_CHECK(renderer);
1791 textureSet = renderer.GetTextures();
1792 texture = textureSet.GetTexture(0);
1794 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1795 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1800 int UtcDaliAnimatedVectorImageVisualMultipleInstances(void)
1802 ToolkitTestApplication application;
1803 tet_infoline("UtcDaliAnimatedVectorImageVisualMultipleInstances");
1805 Property::Map propertyMap;
1806 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1807 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1808 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1810 Visual::Base visual1 = VisualFactory::Get().CreateVisual(propertyMap);
1811 DALI_TEST_CHECK(visual1);
1813 DummyControl actor1 = DummyControl::New(true);
1814 DummyControlImpl& dummyImpl1 = static_cast<DummyControlImpl&>(actor1.GetImplementation());
1815 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual1);
1817 Vector2 controlSize(20.f, 30.f);
1818 actor1.SetProperty(Actor::Property::SIZE, controlSize);
1820 application.GetScene().Add(actor1);
1822 application.SendNotification();
1823 application.Render();
1825 // Trigger count is 2 - load & render a frame
1826 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1828 propertyMap.Clear();
1829 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1830 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1831 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1833 Visual::Base visual2 = VisualFactory::Get().CreateVisual(propertyMap);
1834 DALI_TEST_CHECK(visual2);
1836 DummyControl actor2 = DummyControl::New(true);
1837 DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor2.GetImplementation());
1838 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
1840 actor2.SetProperty(Actor::Property::SIZE, controlSize);
1842 application.GetScene().Add(actor2);
1844 application.SendNotification();
1845 application.Render();
1847 // Trigger count is 2 - load & render a frame
1848 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1850 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1852 // To make event trigger
1853 actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1855 application.SendNotification();
1856 application.Render();
1858 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1860 Property::Map attributes;
1861 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1863 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1864 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1866 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1868 // renderer is added to actor
1869 DALI_TEST_CHECK(actor1.GetRendererCount() == 1u);
1870 Renderer renderer1 = actor1.GetRendererAt(0u);
1871 DALI_TEST_CHECK(renderer1);
1873 // renderer is added to actor
1874 DALI_TEST_CHECK(actor2.GetRendererCount() == 1u);
1875 Renderer renderer2 = actor2.GetRendererAt(0u);
1876 DALI_TEST_CHECK(renderer2);
1881 int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void)
1883 ToolkitTestApplication application;
1884 tet_infoline("UtcDaliAnimatedVectorImageVisualControlVisibilityChanged");
1886 Property::Map propertyMap;
1887 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1888 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1889 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1891 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1892 DALI_TEST_CHECK(visual);
1894 DummyControl actor = DummyControl::New(true);
1895 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1896 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1898 Vector2 controlSize(20.f, 30.f);
1899 actor.SetProperty(Actor::Property::SIZE, controlSize);
1901 application.GetScene().Add(actor);
1903 application.SendNotification();
1904 application.Render();
1906 // Trigger count is 2 - load & render a frame
1907 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1909 Property::Map attributes;
1910 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1912 application.SendNotification();
1913 application.Render();
1915 // Check rendering behavior
1916 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1917 Renderer renderer = actor.GetRendererAt(0u);
1918 DALI_TEST_CHECK(renderer);
1919 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1921 actor.SetProperty(Actor::Property::VISIBLE, false);
1923 application.SendNotification();
1924 application.Render();
1926 // Check rendering behavior again
1927 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1932 int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void)
1934 ToolkitTestApplication application;
1935 tet_infoline("UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged");
1937 Property::Map propertyMap;
1938 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1939 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1941 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1942 DALI_TEST_CHECK(visual);
1944 DummyControl actor = DummyControl::New(true);
1945 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1946 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1948 Vector2 controlSize(20.f, 30.f);
1949 actor.SetProperty(Actor::Property::SIZE, controlSize);
1951 application.GetScene().Add(actor);
1953 application.SendNotification();
1954 application.Render();
1956 // Trigger count is 1 - render a frame
1957 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1959 Property::Map attributes;
1960 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1962 application.SendNotification();
1963 application.Render();
1965 // Check rendering behavior
1966 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1967 Renderer renderer = actor.GetRendererAt(0u);
1968 DALI_TEST_CHECK(renderer);
1969 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1971 Window window = DevelWindow::Get(actor);
1974 application.SendNotification();
1975 application.Render();
1977 // Check rendering behavior again
1978 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1983 int UtcDaliAnimatedVectorImageVisualInvalidFile01(void)
1985 ToolkitTestApplication application;
1986 tet_infoline("Request loading with invalid file - should draw broken image");
1988 TestGlAbstraction& gl = application.GetGlAbstraction();
1989 TraceCallStack& textureTrace = gl.GetTextureTrace();
1990 textureTrace.Enable(true);
1992 Property::Map propertyMap;
1993 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1994 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1995 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1997 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1998 DALI_TEST_CHECK(visual);
2000 DummyControl actor = DummyControl::New(true);
2001 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2002 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2004 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
2006 application.GetScene().Add(actor);
2008 application.SendNotification();
2009 application.Render();
2011 // Trigger count is 1 - load
2012 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2014 application.SendNotification();
2015 application.Render();
2017 // Check resource status
2018 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2019 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2021 // The broken image should be shown.
2022 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2023 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2028 int UtcDaliAnimatedVectorImageVisualInvalidFile02(void)
2030 ToolkitTestApplication application;
2031 tet_infoline("Request loading with invalid file - should draw broken image");
2033 TestGlAbstraction& gl = application.GetGlAbstraction();
2034 TraceCallStack& textureTrace = gl.GetTextureTrace();
2035 textureTrace.Enable(true);
2037 Property::Map propertyMap;
2038 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2039 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
2041 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2042 DALI_TEST_CHECK(visual);
2044 DummyControl actor = DummyControl::New(true);
2045 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2046 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2048 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
2050 application.SendNotification();
2051 application.Render();
2053 // Add to the Scene after loading
2054 application.GetScene().Add(actor);
2056 application.SendNotification();
2057 application.Render();
2059 // Check resource status
2060 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2061 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2063 // The broken image should be shown.
2064 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2065 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2070 int UtcDaliAnimatedVectorImageVisualInvalidFile03(void)
2072 ToolkitTestApplication application;
2073 tet_infoline("Request loading with invalid file without size set - should draw broken image");
2075 TestGlAbstraction& gl = application.GetGlAbstraction();
2076 TraceCallStack& textureTrace = gl.GetTextureTrace();
2077 textureTrace.Enable(true);
2079 Property::Map propertyMap;
2080 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2081 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
2082 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2084 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2085 DALI_TEST_CHECK(visual);
2087 DummyControl actor = DummyControl::New(true);
2088 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2089 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2091 application.GetScene().Add(actor);
2093 application.SendNotification();
2094 application.Render();
2096 // Trigger count is 1 - load
2097 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2099 application.SendNotification();
2100 application.Render();
2102 // Check resource status
2103 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2104 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2106 // The broken image should be shown.
2107 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2108 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2113 int UtcDaliAnimatedVectorImageVisualFrameDrops(void)
2115 ToolkitTestApplication application;
2116 tet_infoline("UtcDaliAnimatedVectorImageVisualFrameDrops");
2118 Property::Map propertyMap;
2119 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2120 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP)
2121 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2123 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2124 DALI_TEST_CHECK(visual);
2126 DummyControl actor = DummyControl::New(true);
2127 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2128 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2130 Vector2 controlSize(20.f, 30.f);
2131 actor.SetProperty(Actor::Property::SIZE, controlSize);
2133 application.GetScene().Add(actor);
2135 application.SendNotification();
2136 application.Render();
2138 // Trigger count is 2 - load, render the first frame
2139 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2141 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2142 Property::Value* value = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
2143 int totalFrameNumber = value->Get<int>();
2145 Property::Map attributes;
2146 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2148 // Make delay to drop frames
2149 Test::VectorAnimationRenderer::DelayRendering(170); // longer than 16.6 * 10frames
2151 application.SendNotification();
2152 application.Render();
2154 // Trigger count is 1 - calculating frame drops
2155 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2157 // Check dropped frame
2158 uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames();
2159 DALI_TEST_CHECK(frames > 0);
2160 DALI_TEST_CHECK(frames <= static_cast<uint32_t>(totalFrameNumber));
2165 int UtcDaliAnimatedVectorImageVisualSize(void)
2167 ToolkitTestApplication application;
2168 tet_infoline("UtcDaliAnimatedVectorImageVisualSize");
2170 TestGlAbstraction& gl = application.GetGlAbstraction();
2171 TraceCallStack& textureTrace = gl.GetTextureTrace();
2173 VisualFactory factory = VisualFactory::Get();
2174 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
2175 DALI_TEST_CHECK(visual);
2177 DummyControl actor = DummyControl::New(true);
2178 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2179 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2181 application.GetScene().Add(actor);
2183 application.SendNotification();
2184 application.Render();
2186 // Trigger count is 1 - resource ready
2187 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2189 textureTrace.Enable(true);
2191 application.SendNotification();
2192 application.Render();
2195 int width = 100, height = 100; // 100x100 is the content default size.
2196 std::stringstream out;
2197 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
2198 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2201 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
2203 application.SendNotification();
2204 application.Render();
2206 // Trigger count is 1 - resource ready
2207 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2209 textureTrace.Reset();
2211 application.SendNotification();
2212 application.Render();
2215 int width = 200, height = 200;
2216 std::stringstream out;
2217 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
2218 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2226 bool gDynamicPropertyCallbackFired = false;
2228 Property::Value FillColorCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber)
2230 gDynamicPropertyCallbackFired = true;
2234 return Vector3(0, 0, 1);
2238 return Vector3(1, 0, 0);
2243 int UtcDaliAnimatedVectorImageVisualDynamicProperty(void)
2245 ToolkitTestApplication application;
2246 tet_infoline("UtcDaliAnimatedVectorImageVisualDynamicProperty");
2248 VisualFactory factory = VisualFactory::Get();
2249 Visual::Base visual = factory.CreateVisual(
2251 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2252 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2253 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
2254 DALI_TEST_CHECK(visual);
2256 DummyControl actor = DummyControl::New(true);
2257 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2258 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2260 Vector2 controlSize(20.f, 30.f);
2261 actor.SetProperty(Actor::Property::SIZE, controlSize);
2263 application.GetScene().Add(actor);
2265 gDynamicPropertyCallbackFired = false;
2267 // Set dynamic property
2268 DevelAnimatedVectorImageVisual::DynamicPropertyInfo info;
2270 info.keyPath = "Test.Path";
2271 info.property = static_cast<int>(VectorAnimationRenderer::VectorProperty::FILL_COLOR);
2272 info.callback = MakeCallback(FillColorCallback);
2274 DevelControl::DoActionExtension(actor, DummyControl::Property::TEST_VISUAL, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info));
2276 Property::Map attributes;
2277 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2279 application.SendNotification();
2280 application.Render();
2282 // Trigger count is 2 - load & render a frame
2283 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2285 // Test whether the property callback is called
2286 DALI_TEST_EQUALS(gDynamicPropertyCallbackFired, true, TEST_LOCATION);
2291 int UtcDaliAnimatedVectorImageVisualDesiredSize(void)
2293 ToolkitTestApplication application;
2294 tet_infoline("UtcDaliAnimatedVectorImageVisualDesiredSize");
2296 TestGlAbstraction& gl = application.GetGlAbstraction();
2297 TraceCallStack& textureTrace = gl.GetTextureTrace();
2298 int desiredWidth = 150, desiredHeight = 200;
2300 Visual::Base visual = VisualFactory::Get().CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
2301 DALI_TEST_CHECK(visual);
2303 DummyControl actor = DummyControl::New(true);
2304 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2305 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2307 application.GetScene().Add(actor);
2309 application.SendNotification();
2310 application.Render();
2312 // Trigger count is 1 - resource ready
2313 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2315 textureTrace.Enable(true);
2317 application.SendNotification();
2318 application.Render();
2321 std::stringstream out;
2322 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
2323 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2326 // Unparent to make next trigger
2329 application.SendNotification();
2330 application.Render();
2333 actor.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.0f));
2334 application.GetScene().Add(actor);
2336 application.SendNotification();
2337 application.Render();
2339 // Trigger count is 1 - resource ready
2340 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2342 textureTrace.Reset();
2344 application.SendNotification();
2345 application.Render();
2348 std::stringstream out;
2349 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
2350 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str())); // The size should not be changed
2356 int UtcDaliAnimatedVectorImageVisualFlushAction(void)
2358 ToolkitTestApplication application;
2360 tet_infoline("UtcDaliAnimatedVectorImageVisualFlushAction");
2365 int totalFrameCount = 0;
2367 Property::Array playRange;
2368 playRange.PushBack(startFrame);
2369 playRange.PushBack(endFrame);
2371 Property::Map resultMap;
2372 Property::Value* value = nullptr;
2374 // request AnimatedVectorImageVisual with a property map
2375 VisualFactory factory = VisualFactory::Get();
2376 Visual::Base visual = factory.CreateVisual(
2378 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2379 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2380 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
2381 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, true));
2383 DummyControl dummyControl = DummyControl::New(true);
2384 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
2385 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2386 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
2388 application.GetScene().Add(dummyControl);
2390 // Retry function to get playrange until expect values comes.
2391 auto CheckAndRetryPlayRange = [&](int expectStartFrame, int expectEndFrame, std::vector<std::pair<int, int>> retrialFrames) {
2393 int tryCountMax = 30;
2394 while(++tryCount <= tryCountMax)
2396 Property::Map resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2398 Property::Value* value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
2399 DALI_TEST_CHECK(value);
2401 Property::Array* result = value->GetArray();
2402 DALI_TEST_CHECK(result);
2403 DALI_TEST_EQUALS(result->Count(), 2, TEST_LOCATION);
2405 bool tryAgain = false;
2406 for(auto& framePair : retrialFrames)
2408 if(result->GetElementAt(0).Get<int>() == framePair.first && result->GetElementAt(1).Get<int>() == framePair.second)
2416 tet_printf("Retry to get value again! [%d]\n", tryCount);
2417 // Dummy sleep 1 second.
2418 Test::WaitForEventThreadTrigger(1, 1);
2422 DALI_TEST_EQUALS(result->GetElementAt(0).Get<int>(), expectStartFrame, TEST_LOCATION);
2423 DALI_TEST_EQUALS(result->GetElementAt(1).Get<int>(), expectEndFrame, TEST_LOCATION);
2426 DALI_TEST_CHECK(tryCount <= tryCountMax);
2429 tet_printf("Pause lottie first.\n");
2431 Property::Map attributes;
2432 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
2434 application.SendNotification();
2435 application.Render(16);
2439 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2441 value = resultMap.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER, Property::INTEGER);
2442 DALI_TEST_CHECK(value);
2443 totalFrameCount = value->Get<int>();
2444 } while(totalFrameCount == 0);
2446 // Ensure that vector data sended well.
2447 CheckAndRetryPlayRange(startFrame, endFrame, {{0, 0}, {0, totalFrameCount - 1}});
2449 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2451 value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
2452 DALI_TEST_CHECK(value);
2453 DALI_TEST_EQUALS(value->Get<int>(), startFrame, TEST_LOCATION);
2455 tet_printf("Now logically, range : [%d~%d], current : %d\n", startFrame, endFrame, startFrame);
2457 int changedStartFrame1 = startFrame + 2;
2458 int changedEndFrame1 = endFrame + 2;
2461 playRange.Add(changedStartFrame1);
2462 playRange.Add(changedEndFrame1);
2464 tet_printf("Change play range\n");
2465 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
2466 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2468 tet_printf("Jump to changedEndFrame!\n");
2469 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, changedEndFrame1);
2472 tet_infoline("Flush Action!");
2473 tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame1, changedEndFrame1, changedEndFrame1);
2474 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::FLUSH, attributes);
2476 int changedStartFrame2 = startFrame + 1;
2477 int changedEndFrame2 = endFrame + 1;
2480 playRange.Add(changedStartFrame2);
2481 playRange.Add(changedEndFrame2);
2483 tet_printf("Change play range again\n");
2484 tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame2, changedEndFrame2, changedEndFrame2);
2485 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
2486 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2488 application.SendNotification();
2489 application.Render(16);
2491 // Ensure that vector data sended well.
2492 CheckAndRetryPlayRange(changedStartFrame2, changedEndFrame2, {{changedStartFrame1, changedEndFrame1}, {startFrame, endFrame}});
2494 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2496 tet_printf("Test whether current frame number changed well. If Flush not works, current frame become startFrame.");
2497 value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
2498 DALI_TEST_CHECK(value);
2499 DALI_TEST_EQUALS(value->Get<int>(), changedEndFrame2, TEST_LOCATION);
2501 dummyControl.Unparent();