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);
217 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
218 DALI_TEST_CHECK(visual);
220 DummyControl actor = DummyControl::New(true);
221 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
222 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
223 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
224 application.GetScene().Add(actor);
226 application.SendNotification();
227 application.Render();
229 // Trigger count is 1 - render a frame
230 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
232 // renderer is added to actor
233 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
235 Renderer renderer = actor.GetRendererAt(0u);
236 DALI_TEST_CHECK(renderer);
238 Property::Map resultMap;
239 visual.CreatePropertyMap(resultMap);
241 // check the property values from the returned map from a visual
242 Property::Value* value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
243 DALI_TEST_CHECK(value);
244 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
246 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
247 DALI_TEST_CHECK(value);
248 DALI_TEST_CHECK(value->Get<int>() == 3);
250 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
251 DALI_TEST_CHECK(value);
253 Property::Array* result = value->GetArray();
254 DALI_TEST_CHECK(result);
256 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
257 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
259 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
260 DALI_TEST_CHECK(value);
261 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::FIRST_FRAME);
263 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
264 DALI_TEST_CHECK(value);
265 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::AUTO_REVERSE);
267 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
268 DALI_TEST_CHECK(value);
269 DALI_TEST_CHECK(value->Get<bool>() == false);
271 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
272 DALI_TEST_CHECK(value);
273 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius), TEST_LOCATION);
275 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
276 DALI_TEST_CHECK(value);
277 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
279 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT);
280 DALI_TEST_CHECK(value);
281 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
283 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
284 DALI_TEST_CHECK(value);
285 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
287 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
288 DALI_TEST_CHECK(value);
289 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
291 value = resultMap.Find(ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER);
292 DALI_TEST_CHECK(value);
293 DALI_TEST_EQUALS(value->Get<int>(), desiredWidth, TEST_LOCATION);
295 value = resultMap.Find(ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER);
296 DALI_TEST_CHECK(value);
297 DALI_TEST_EQUALS(value->Get<int>(), desiredHeight, TEST_LOCATION);
300 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
305 int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
307 ToolkitTestApplication application;
308 tet_infoline("UtcDaliAnimatedVectorImageVisualGetPropertyMap01");
310 int startFrame = 1, endFrame = 3;
311 int desiredWidth = 100, desiredHeight = 150;
312 Vector4 cornerRadius(50.0f, 22.0f, 0.0f, 3.0f);
313 float borderlineWidth = 2.3f;
314 Vector4 borderlineColor = Vector4(0.3f, 0.3f, 1.0f, 1.0f);
315 float borderlineOffset = 0.3f;
316 Property::Array playRange;
317 playRange.PushBack(startFrame);
318 playRange.PushBack(endFrame);
320 Property::Map propertyMap;
321 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
322 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
323 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
324 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
325 .Add(DevelVisual::Property::CORNER_RADIUS, cornerRadius)
326 .Add(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::RELATIVE)
327 .Add(DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth)
328 .Add(DevelVisual::Property::BORDERLINE_COLOR, borderlineColor)
329 .Add(DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset)
330 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false)
331 .Add(ImageVisual::Property::DESIRED_WIDTH, desiredWidth)
332 .Add(ImageVisual::Property::DESIRED_HEIGHT, desiredHeight);
334 // request AnimatedVectorImageVisual with a property map
335 VisualFactory factory = VisualFactory::Get();
336 Visual::Base visual = factory.CreateVisual(propertyMap);
338 DummyControl actor = DummyControl::New(true);
339 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
340 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
342 Vector2 controlSize(20.f, 30.f);
343 actor.SetProperty(Actor::Property::SIZE, controlSize);
345 application.GetScene().Add(actor);
347 application.SendNotification();
348 application.Render();
350 // Trigger count is 2 - load & render a frame
351 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
353 Property::Map resultMap;
354 resultMap = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
356 // check the property values from the returned map from a visual
357 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
358 DALI_TEST_CHECK(value);
359 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
361 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
362 DALI_TEST_CHECK(value);
363 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
365 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
366 DALI_TEST_CHECK(value);
367 DALI_TEST_CHECK(value->Get<int>() == 3);
369 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
370 DALI_TEST_CHECK(value);
372 Property::Array* result = value->GetArray();
373 DALI_TEST_CHECK(result);
375 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
376 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
378 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
379 DALI_TEST_CHECK(value);
380 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::CURRENT_FRAME);
382 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
383 DALI_TEST_CHECK(value);
384 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::RESTART);
386 value = resultMap.Find(DevelImageVisual::Property::CONTENT_INFO, Property::MAP);
387 DALI_TEST_CHECK(value);
389 value = resultMap.Find(DevelImageVisual::Property::MARKER_INFO, Property::MAP);
390 DALI_TEST_CHECK(value);
392 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
393 DALI_TEST_CHECK(value);
394 DALI_TEST_CHECK(value->Get<bool>() == true); // Check default value
396 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
397 DALI_TEST_CHECK(value);
398 DALI_TEST_EQUALS(value->Get<Vector4>(), cornerRadius, TEST_LOCATION);
400 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
401 DALI_TEST_CHECK(value);
402 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::RELATIVE);
404 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
405 DALI_TEST_CHECK(value);
406 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
408 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
409 DALI_TEST_CHECK(value);
410 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
412 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
413 DALI_TEST_CHECK(value);
414 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
416 value = resultMap.Find(ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER);
417 DALI_TEST_CHECK(value);
418 DALI_TEST_EQUALS(value->Get<int>(), desiredWidth, TEST_LOCATION);
420 value = resultMap.Find(ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER);
421 DALI_TEST_CHECK(value);
422 DALI_TEST_EQUALS(value->Get<int>(), desiredHeight, TEST_LOCATION);
424 // request AnimatedVectorImageVisual with an URL
425 Visual::Base visual2 = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
428 visual2.CreatePropertyMap(resultMap);
430 // check the property values from the returned map from a visual
431 value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
432 DALI_TEST_CHECK(value);
433 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
435 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
436 DALI_TEST_CHECK(value);
437 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
442 int UtcDaliAnimatedVectorImageVisualPlayback(void)
444 ToolkitTestApplication application;
446 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayback");
449 // request AnimatedVectorImageVisual with a property map
450 VisualFactory factory = VisualFactory::Get();
451 Visual::Base visual = factory.CreateVisual(
453 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
454 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
455 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
457 DummyControl dummyControl = DummyControl::New(true);
458 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
459 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
460 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
462 Property::Map attributes;
463 tet_infoline("Test Play action");
464 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
466 application.GetScene().Add(dummyControl);
467 application.SendNotification();
468 application.Render(16);
470 Property::Map map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
471 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
472 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
474 tet_infoline("Test Pause action");
475 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
477 application.SendNotification();
478 application.Render(16);
480 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
481 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
482 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PAUSED);
484 tet_infoline("Test Play action");
485 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
487 application.SendNotification();
488 application.Render(16);
490 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
491 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
492 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
494 tet_infoline("Test Stop action");
495 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
497 application.SendNotification();
498 application.Render(16);
500 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
501 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
502 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
504 tet_infoline("Test Stop action again");
505 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
507 application.SendNotification();
508 application.Render(16);
510 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
511 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
512 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
514 tet_infoline("Test Play action");
515 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
517 application.SendNotification();
518 application.Render(16);
520 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
521 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
522 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
524 tet_infoline("Off stage");
525 dummyControl.Unparent();
527 application.SendNotification();
528 application.Render(16);
530 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
531 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
532 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
534 tet_infoline("On stage again");
535 application.GetScene().Add(dummyControl);
537 application.SendNotification();
538 application.Render(16);
540 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
541 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
542 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
544 tet_infoline("Test Play action");
545 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
547 application.SendNotification();
548 application.Render(16);
550 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
551 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
552 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
555 Vector3 newSize(100.0f, 100.0f, 0.0f);
556 dummyControl.SetProperty(Actor::Property::SIZE, newSize);
558 application.SendNotification();
559 application.Render(16);
561 // Size should be changed
562 Vector3 naturalSize = dummyControl.GetNaturalSize();
563 DALI_TEST_CHECK(naturalSize == newSize);
565 dummyControl.Unparent();
571 int UtcDaliAnimatedVectorImageVisualCustomShader(void)
573 ToolkitTestApplication application;
574 tet_infoline("UtcDaliAnimatedVectorImageVisualCustomShader Test custom shader");
576 VisualFactory factory = VisualFactory::Get();
577 Property::Map properties;
578 Property::Map shader;
579 const std::string vertexShader = "Foobar";
580 const std::string fragmentShader = "Foobar sampler2D Foobar";
581 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
582 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
584 properties[Visual::Property::TYPE] = Visual::IMAGE;
585 properties[Visual::Property::SHADER] = shader;
586 properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
588 Visual::Base visual = factory.CreateVisual(properties);
590 // trigger creation through setting on stage
591 DummyControl dummy = DummyControl::New(true);
592 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
593 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
595 dummy.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
596 dummy.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
597 application.GetScene().Add(dummy);
599 application.SendNotification();
600 application.Render();
602 // Trigger count is 1 - render a frame
603 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
605 Renderer renderer = dummy.GetRendererAt(0);
606 Shader shader2 = renderer.GetShader();
607 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
608 Property::Map* map = value.GetMap();
609 DALI_TEST_CHECK(map);
611 std::string resultFragmentShader, resultVertexShader;
612 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
613 fragment->Get(resultFragmentShader);
614 DALI_TEST_CHECK(resultFragmentShader.find(fragmentShader) != std::string::npos);
616 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
617 vertex->Get(resultVertexShader);
618 DALI_TEST_CHECK(resultVertexShader.find(vertexShader) != std::string::npos);
623 int UtcDaliAnimatedVectorImageVisualNaturalSize(void)
625 ToolkitTestApplication application;
626 tet_infoline("UtcDaliAnimatedVectorImageVisualNaturalSize");
628 VisualFactory factory = VisualFactory::Get();
629 Visual::Base visual = factory.CreateVisual(
631 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
632 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
633 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
634 DALI_TEST_CHECK(visual);
636 DummyControl actor = DummyControl::New(true);
637 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
638 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
640 Vector2 controlSize(20.f, 30.f);
643 application.GetScene().Add(actor);
645 application.SendNotification();
646 application.Render();
648 // Trigger count is 1 - load
649 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
651 visual.GetNaturalSize(naturalSize);
653 DALI_TEST_EQUALS(naturalSize, Vector2(100.0f, 100.0f), TEST_LOCATION); // 100x100 is the content default size.
655 actor.SetProperty(Actor::Property::SIZE, controlSize);
657 application.SendNotification();
658 application.Render();
660 visual.GetNaturalSize(naturalSize);
662 DALI_TEST_EQUALS(naturalSize, controlSize, TEST_LOCATION);
667 int UtcDaliAnimatedVectorImageVisualLoopCount(void)
669 ToolkitTestApplication application;
670 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopCount");
672 Property::Map propertyMap;
673 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
674 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
675 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
676 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
678 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
679 DALI_TEST_CHECK(visual);
681 DummyControl actor = DummyControl::New(true);
682 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
683 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
685 Vector2 controlSize(20.f, 30.f);
686 actor.SetProperty(Actor::Property::SIZE, controlSize);
688 application.GetScene().Add(actor);
690 Property::Map attributes;
691 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
693 application.SendNotification();
694 application.Render();
696 // Trigger count is 2 - load & render a frame
697 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
699 // renderer is added to actor
700 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
701 Renderer renderer = actor.GetRendererAt(0u);
702 DALI_TEST_CHECK(renderer);
707 int UtcDaliAnimatedVectorImageVisualPlayRange(void)
709 ToolkitTestApplication application;
710 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRange");
712 int startFrame = 1, endFrame = 3;
713 Property::Array array;
714 array.PushBack(endFrame);
715 array.PushBack(startFrame);
717 Property::Map propertyMap;
718 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
719 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
720 .Add(DevelImageVisual::Property::PLAY_RANGE, array)
721 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
723 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
724 DALI_TEST_CHECK(visual);
726 DummyControl actor = DummyControl::New(true);
727 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
728 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
730 Vector2 controlSize(20.f, 30.f);
731 actor.SetProperty(Actor::Property::SIZE, controlSize);
733 application.GetScene().Add(actor);
735 Property::Map attributes;
736 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
738 application.SendNotification();
739 application.Render();
741 // Trigger count is 2 - load & render a frame
742 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
744 // renderer is added to actor
745 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
746 Renderer renderer = actor.GetRendererAt(0u);
747 DALI_TEST_CHECK(renderer);
749 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
750 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
751 int totalFrameNumber = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER)->Get<int>();
753 int resultStartFrame, resultEndFrame;
754 Property::Array* result = value->GetArray();
755 result->GetElementAt(0).Get(resultStartFrame);
756 result->GetElementAt(1).Get(resultEndFrame);
758 DALI_TEST_EQUALS(startFrame, resultStartFrame, TEST_LOCATION);
759 DALI_TEST_EQUALS(endFrame, resultEndFrame, TEST_LOCATION);
761 // Set invalid play range
767 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
768 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
770 // To make event trigger
771 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
773 application.SendNotification();
774 application.Render();
776 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
778 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
779 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
781 result = value->GetArray();
782 result->GetElementAt(0).Get(resultStartFrame);
783 result->GetElementAt(1).Get(resultEndFrame);
785 DALI_TEST_EQUALS(resultStartFrame, 1, TEST_LOCATION);
786 DALI_TEST_EQUALS(resultEndFrame, totalFrameNumber - 1, TEST_LOCATION); // Should be clamped
788 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, Property::Map());
790 application.SendNotification();
791 application.Render();
793 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
795 // To make event trigger
796 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
798 application.SendNotification();
799 application.Render();
801 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
803 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
804 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
805 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
812 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
813 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
815 // To make event trigger
816 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
818 application.SendNotification();
819 application.Render();
821 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
823 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
824 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
826 result = value->GetArray();
827 result->GetElementAt(0).Get(resultStartFrame);
828 result->GetElementAt(1).Get(resultEndFrame);
830 DALI_TEST_EQUALS(0, resultStartFrame, TEST_LOCATION);
831 DALI_TEST_EQUALS(2, resultEndFrame, TEST_LOCATION);
833 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
834 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION); // CURRENT_FRAME_NUMBER should be changed also.
839 int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void)
841 ToolkitTestApplication application;
842 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRangeMarker");
844 // Set 1 marker as array
845 Property::Array array;
846 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
848 Property::Map propertyMap;
849 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
850 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
851 .Add(DevelImageVisual::Property::PLAY_RANGE, array)
852 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
854 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
855 DALI_TEST_CHECK(visual);
857 DummyControl actor = DummyControl::New(true);
858 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
859 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
861 Vector2 controlSize(20.f, 30.f);
862 actor.SetProperty(Actor::Property::SIZE, controlSize);
864 application.GetScene().Add(actor);
866 Property::Map attributes;
867 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
869 application.SendNotification();
870 application.Render();
872 // Trigger count is 2 - load & render a frame
873 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
875 // renderer is added to actor
876 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
877 Renderer renderer = actor.GetRendererAt(0u);
878 DALI_TEST_CHECK(renderer);
880 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
881 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
883 int resultStartFrame, resultEndFrame;
884 Property::Array* result = value->GetArray();
885 result->GetElementAt(0).Get(resultStartFrame);
886 result->GetElementAt(1).Get(resultEndFrame);
888 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
889 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
891 // Set 1 marker as string
895 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, VECTOR_ANIMATION_MARKER_NAME_1);
896 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
898 // To make event trigger
899 actor.SetProperty(Actor::Property::SIZE, Vector2(40.0f, 40.0f));
901 application.SendNotification();
902 application.Render();
904 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
906 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
907 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
909 result = value->GetArray();
910 result->GetElementAt(0).Get(resultStartFrame);
911 result->GetElementAt(1).Get(resultEndFrame);
913 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
914 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
918 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
919 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_2);
922 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
923 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
925 // To make event trigger
926 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
928 application.SendNotification();
929 application.Render();
931 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
933 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
934 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
936 result = value->GetArray();
937 result->GetElementAt(0).Get(resultStartFrame);
938 result->GetElementAt(1).Get(resultEndFrame);
940 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
941 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
943 // Set invalid play range
946 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
949 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
950 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
952 // To make event trigger
953 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
955 application.SendNotification();
956 application.Render();
958 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
960 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
961 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
963 result = value->GetArray();
964 result->GetElementAt(0).Get(resultStartFrame);
965 result->GetElementAt(1).Get(resultEndFrame);
967 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION); // Should not be changed
968 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
973 int UtcDaliAnimatedVectorImageVisualMarkerInfo(void)
975 ToolkitTestApplication application;
976 tet_infoline("UtcDaliAnimatedVectorImageVisualMarkerInfo");
978 Property::Map propertyMap;
979 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
980 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
981 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
983 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
984 DALI_TEST_CHECK(visual);
986 DummyControl actor = DummyControl::New(true);
987 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
988 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
990 Vector2 controlSize(20.f, 30.f);
991 actor.SetProperty(Actor::Property::SIZE, controlSize);
993 application.GetScene().Add(actor);
995 Property::Map attributes;
996 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
998 application.SendNotification();
999 application.Render();
1001 // Trigger count is 2 - load & render a frame
1002 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1004 // renderer is added to actor
1005 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1006 Renderer renderer = actor.GetRendererAt(0u);
1007 DALI_TEST_CHECK(renderer);
1009 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1010 Property::Value* value = map.Find(DevelImageVisual::Property::MARKER_INFO);
1012 DALI_TEST_CHECK(value);
1014 Property::Map* result = value->GetMap();
1015 DALI_TEST_CHECK(result);
1017 std::string resultMarkerName;
1018 int resultStartFrame, resultEndFrame;
1019 DALI_TEST_EQUALS(2u, result->Count(), TEST_LOCATION);
1021 for(uint32_t i = 0u; i < result->Count(); ++i)
1023 if(result->GetKeyAt(i).stringKey == VECTOR_ANIMATION_MARKER_NAME_1)
1025 Property::Array* frameArray = result->GetValue(i).GetArray();
1026 DALI_TEST_CHECK(frameArray);
1027 frameArray->GetElementAt(0).Get(resultStartFrame);
1028 frameArray->GetElementAt(1).Get(resultEndFrame);
1030 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
1031 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
1033 else if(result->GetKeyAt(i).stringKey == VECTOR_ANIMATION_MARKER_NAME_2)
1035 Property::Array* frameArray = result->GetValue(i).GetArray();
1036 DALI_TEST_CHECK(frameArray);
1037 frameArray->GetElementAt(0).Get(resultStartFrame);
1038 frameArray->GetElementAt(1).Get(resultEndFrame);
1040 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_2, resultStartFrame, TEST_LOCATION);
1041 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
1045 DALI_TEST_CHECK(false);
1052 int UtcDaliAnimatedVectorImageVisualMarkerInfoFromInvalid(void)
1054 ToolkitTestApplication application;
1055 tet_infoline("UtcDaliAnimatedVectorImageVisualMarkerInfoFromInvalid");
1057 Property::Map propertyMap;
1058 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1059 .Add(ImageVisual::Property::URL, "invalid.json")
1060 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1062 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1063 DALI_TEST_CHECK(visual);
1065 DummyControl actor = DummyControl::New(true);
1066 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1067 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1069 Vector2 controlSize(20.f, 30.f);
1070 actor.SetProperty(Actor::Property::SIZE, controlSize);
1072 application.GetScene().Add(actor);
1074 Property::Map attributes;
1075 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1077 application.SendNotification();
1078 application.Render();
1080 // Trigger count is 1 - load, and failed.
1081 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1083 // renderer is added to actor
1084 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1085 Renderer renderer = actor.GetRendererAt(0u);
1086 DALI_TEST_CHECK(renderer);
1088 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1089 Property::Value* value = map.Find(DevelImageVisual::Property::MARKER_INFO);
1091 // The values when load failed case is invalid.
1092 DALI_TEST_CHECK(value == nullptr || (value->GetMap() == nullptr) || (value->GetMap()->Empty()));
1097 int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
1099 ToolkitTestApplication application;
1100 tet_infoline("UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal");
1102 Property::Map propertyMap;
1103 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1104 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1106 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1107 DALI_TEST_CHECK(visual);
1109 DummyControl actor = DummyControl::New(true);
1110 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1111 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1113 DevelControl::VisualEventSignal(actor).Connect(&VisualEventSignal);
1115 Vector2 controlSize(20.f, 30.f);
1116 actor.SetProperty(Actor::Property::SIZE, controlSize);
1118 application.GetScene().Add(actor);
1120 application.SendNotification();
1121 application.Render();
1123 // Trigger count is 1 - render a frame
1124 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1126 propertyMap.Clear();
1127 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1128 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1130 Property::Map attributes;
1131 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1133 application.SendNotification();
1134 application.Render();
1136 // Wait for animation finish
1137 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1139 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1140 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
1141 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
1143 DALI_TEST_EQUALS(gAnimationFinishedSignalFired, true, TEST_LOCATION);
1148 int UtcDaliAnimatedVectorImageVisualJumpTo(void)
1150 ToolkitTestApplication application;
1151 tet_infoline("UtcDaliAnimatedVectorImageVisualJumpTo");
1153 Property::Map propertyMap;
1154 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1155 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1156 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1157 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1159 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1160 DALI_TEST_CHECK(visual);
1162 tet_printf("1. Visual is created.\n");
1164 DummyControl actor = DummyControl::New(true);
1165 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1166 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1168 Vector2 controlSize(20.f, 30.f);
1169 actor.SetProperty(Actor::Property::SIZE, controlSize);
1171 application.GetScene().Add(actor);
1173 application.SendNotification();
1174 application.Render();
1176 // Trigger count is 2 - load & render a frame
1177 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1179 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2);
1181 // To make event trigger
1182 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1184 application.SendNotification();
1185 application.Render();
1187 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1189 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1190 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1191 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1193 tet_printf("2. The current frame number is [%d].\n", value->Get<int>());
1195 Property::Array array;
1199 Property::Map attributes;
1200 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1201 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1203 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1205 // To make event trigger
1206 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1208 application.SendNotification();
1209 application.Render();
1211 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1213 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1214 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1215 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1217 tet_printf("3. The current frame number is [%d].\n", value->Get<int>());
1219 // Change play range
1226 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1227 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, 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);
1239 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1241 // To make event trigger
1242 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1244 application.SendNotification();
1245 application.Render();
1247 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1249 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1250 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1251 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1253 tet_printf("4. The current frame number is [%d].\n", value->Get<int>());
1255 // Jump to the same position
1256 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1258 // To make event trigger
1259 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1261 application.SendNotification();
1262 application.Render();
1264 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1266 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1267 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1268 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1270 tet_printf("5. The current frame number is [%d].\n", value->Get<int>());
1275 int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
1277 ToolkitTestApplication application;
1278 tet_infoline("UtcDaliAnimatedVectorImageVisualUpdateProperty");
1280 int startFrame = 1, endFrame = 3;
1281 Property::Array playRange;
1282 playRange.PushBack(startFrame);
1283 playRange.PushBack(endFrame);
1285 Property::Map propertyMap;
1286 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1287 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1288 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1289 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
1290 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1292 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1293 DALI_TEST_CHECK(visual);
1295 DummyControl actor = DummyControl::New(true);
1296 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1297 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1299 Vector2 controlSize(20.f, 30.f);
1300 actor.SetProperty(Actor::Property::SIZE, controlSize);
1302 application.GetScene().Add(actor);
1304 application.SendNotification();
1305 application.Render();
1307 // Trigger count is 2 - load & render a frame
1308 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1310 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1311 Property::Value* value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1312 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1314 value = map.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
1315 DALI_TEST_CHECK(value);
1317 Property::Array* result = value->GetArray();
1318 DALI_TEST_CHECK(result);
1320 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1321 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1324 playRange.PushBack(0);
1325 playRange.PushBack(2);
1327 Property::Map attributes;
1328 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1329 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 5);
1331 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1333 // To make event trigger
1334 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1336 application.SendNotification();
1337 application.Render();
1339 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1341 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1342 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1343 DALI_TEST_EQUALS(value->Get<int>(), 5, TEST_LOCATION);
1345 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1346 result = value->GetArray();
1347 DALI_TEST_CHECK(result);
1349 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == 0);
1350 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == 2);
1355 playRange.PushBack(startFrame);
1356 playRange.PushBack(endFrame);
1358 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1360 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1362 // To make event trigger
1363 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1365 application.SendNotification();
1366 application.Render();
1368 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1370 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1371 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1373 result = value->GetArray();
1374 DALI_TEST_CHECK(result);
1376 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1377 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1379 // Play and update property
1381 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1383 application.SendNotification();
1384 application.Render();
1386 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 10);
1388 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1390 application.SendNotification();
1391 application.Render();
1393 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1394 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1395 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
1400 int UtcDaliAnimatedVectorImageVisualStopBehavior(void)
1402 ToolkitTestApplication application;
1403 tet_infoline("UtcDaliAnimatedVectorImageVisualStopBehavior");
1405 Property::Map propertyMap;
1406 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1407 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1408 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1410 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1411 DALI_TEST_CHECK(visual);
1413 DummyControl actor = DummyControl::New(true);
1414 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1415 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1417 Vector2 controlSize(20.f, 30.f);
1418 actor.SetProperty(Actor::Property::SIZE, controlSize);
1420 application.GetScene().Add(actor);
1422 application.SendNotification();
1423 application.Render();
1425 // Trigger count is 2 - load & render a frame
1426 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1428 propertyMap.Clear();
1429 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1430 propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
1431 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1433 Property::Map attributes;
1434 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1436 application.SendNotification();
1437 application.Render();
1439 // Trigger count is 1 - animation finished
1440 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1442 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1443 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1444 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1446 // Change stop behavior
1447 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1449 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1454 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1456 application.SendNotification();
1457 application.Render();
1459 // Trigger count is 1 - animation finished
1460 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1462 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1464 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1465 int totalFrameNumber = value1->Get<int>();
1467 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1468 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1470 // Change stop behavior
1471 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1472 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, -1);
1474 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1479 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1481 application.SendNotification();
1482 application.Render();
1485 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
1487 // To make event trigger
1488 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1490 application.SendNotification();
1491 application.Render();
1493 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1495 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1496 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1497 int currentFrameNumber = value->Get<int>();
1500 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
1502 // To make event trigger
1503 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1505 application.SendNotification();
1506 application.Render();
1508 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1510 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1511 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1512 DALI_TEST_EQUALS(value->Get<int>(), currentFrameNumber, TEST_LOCATION); // Should be same with currentFrameNumber
1517 int UtcDaliAnimatedVectorImageVisualLoopingMode(void)
1519 ToolkitTestApplication application;
1520 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopingMode");
1522 Property::Map propertyMap;
1523 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1524 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1525 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1527 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1528 DALI_TEST_CHECK(visual);
1530 DummyControl actor = DummyControl::New(true);
1531 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1532 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1534 Vector2 controlSize(20.f, 30.f);
1535 actor.SetProperty(Actor::Property::SIZE, controlSize);
1537 application.GetScene().Add(actor);
1539 application.SendNotification();
1540 application.Render();
1542 // Trigger count is 2 - load, render
1543 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1545 propertyMap.Clear();
1546 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1547 propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1548 propertyMap.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::AUTO_REVERSE);
1549 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1551 Property::Map attributes;
1552 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1554 application.SendNotification();
1555 application.Render();
1557 // Trigger count is 1 - animation finished
1558 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1560 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1561 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1562 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame because of auto reverse
1564 // Change stop behavior
1565 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1567 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1570 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1572 application.SendNotification();
1573 application.Render();
1575 // Trigger count is 1 - animation finished
1576 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1578 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1579 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1580 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1582 // Change looping mode
1583 attributes.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::RESTART);
1585 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1588 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1590 application.SendNotification();
1591 application.Render();
1593 // Trigger count is 1 - animation finished
1594 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1596 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1597 int totalFrameNumber = value1->Get<int>();
1599 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1600 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1601 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1606 int UtcDaliAnimatedVectorImageVisualPropertyNotification(void)
1608 ToolkitTestApplication application;
1609 tet_infoline("UtcDaliAnimatedVectorImageVisualPropertyNotification");
1611 Property::Map propertyMap;
1612 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1613 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1615 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1616 DALI_TEST_CHECK(visual);
1618 DummyControl actor = DummyControl::New(true);
1619 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1620 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1621 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1623 application.GetScene().Add(actor);
1625 application.SendNotification();
1626 application.Render();
1628 // Trigger count is 1 - render a frame
1629 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1631 Renderer renderer = actor.GetRendererAt(0u);
1632 DALI_TEST_CHECK(renderer);
1634 Vector2 controlSize(20.f, 30.f);
1635 actor.SetProperty(Actor::Property::SIZE, controlSize);
1637 application.SendNotification();
1638 application.Render();
1640 application.SendNotification();
1641 application.Render();
1643 // Trigger count is 1 - render a frame
1644 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1646 auto textureSet = renderer.GetTextures();
1647 auto texture = textureSet.GetTexture(0);
1649 DALI_TEST_EQUALS(controlSize.width, texture.GetWidth(), TEST_LOCATION);
1650 DALI_TEST_EQUALS(controlSize.height, texture.GetHeight(), TEST_LOCATION);
1653 Vector3 controlScale(2.0f, 2.0f, 1.0f);
1654 actor.SetProperty(Actor::Property::SCALE, controlScale);
1656 application.SendNotification();
1657 application.Render();
1659 application.SendNotification();
1660 application.Render();
1662 // Trigger count is 1 - render a frame
1663 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1665 renderer = actor.GetRendererAt(0u);
1666 DALI_TEST_CHECK(renderer);
1668 textureSet = renderer.GetTextures();
1669 texture = textureSet.GetTexture(0);
1671 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1672 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1675 controlSize = Vector2(50.0f, 100.0f);
1676 Animation animation = Animation::New(1.0);
1677 animation.AnimateTo(Property(actor, Actor::Property::SIZE), Vector3(controlSize.x, controlSize.y, 0.0f));
1680 application.SendNotification();
1681 application.Render(1100); // After the animation
1683 application.SendNotification();
1684 application.Render();
1686 // Trigger count is 1 - render a frame
1687 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1689 renderer = actor.GetRendererAt(0u);
1690 DALI_TEST_CHECK(renderer);
1692 textureSet = renderer.GetTextures();
1693 texture = textureSet.GetTexture(0);
1695 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1696 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1701 int UtcDaliAnimatedVectorImageVisualMultipleInstances(void)
1703 ToolkitTestApplication application;
1704 tet_infoline("UtcDaliAnimatedVectorImageVisualMultipleInstances");
1706 Property::Map propertyMap;
1707 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1708 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1709 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1711 Visual::Base visual1 = VisualFactory::Get().CreateVisual(propertyMap);
1712 DALI_TEST_CHECK(visual1);
1714 DummyControl actor1 = DummyControl::New(true);
1715 DummyControlImpl& dummyImpl1 = static_cast<DummyControlImpl&>(actor1.GetImplementation());
1716 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual1);
1718 Vector2 controlSize(20.f, 30.f);
1719 actor1.SetProperty(Actor::Property::SIZE, controlSize);
1721 application.GetScene().Add(actor1);
1723 application.SendNotification();
1724 application.Render();
1726 // Trigger count is 2 - load & render a frame
1727 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1729 propertyMap.Clear();
1730 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1731 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1732 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1734 Visual::Base visual2 = VisualFactory::Get().CreateVisual(propertyMap);
1735 DALI_TEST_CHECK(visual2);
1737 DummyControl actor2 = DummyControl::New(true);
1738 DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor2.GetImplementation());
1739 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
1741 actor2.SetProperty(Actor::Property::SIZE, controlSize);
1743 application.GetScene().Add(actor2);
1745 application.SendNotification();
1746 application.Render();
1748 // Trigger count is 2 - load & render a frame
1749 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1751 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1753 // To make event trigger
1754 actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1756 application.SendNotification();
1757 application.Render();
1759 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1761 Property::Map attributes;
1762 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1764 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1765 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1767 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1769 // renderer is added to actor
1770 DALI_TEST_CHECK(actor1.GetRendererCount() == 1u);
1771 Renderer renderer1 = actor1.GetRendererAt(0u);
1772 DALI_TEST_CHECK(renderer1);
1774 // renderer is added to actor
1775 DALI_TEST_CHECK(actor2.GetRendererCount() == 1u);
1776 Renderer renderer2 = actor2.GetRendererAt(0u);
1777 DALI_TEST_CHECK(renderer2);
1782 int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void)
1784 ToolkitTestApplication application;
1785 tet_infoline("UtcDaliAnimatedVectorImageVisualControlVisibilityChanged");
1787 Property::Map propertyMap;
1788 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1789 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1790 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1792 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1793 DALI_TEST_CHECK(visual);
1795 DummyControl actor = DummyControl::New(true);
1796 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1797 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1799 Vector2 controlSize(20.f, 30.f);
1800 actor.SetProperty(Actor::Property::SIZE, controlSize);
1802 application.GetScene().Add(actor);
1804 application.SendNotification();
1805 application.Render();
1807 // Trigger count is 2 - load & render a frame
1808 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1810 Property::Map attributes;
1811 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1813 application.SendNotification();
1814 application.Render();
1816 // Check rendering behavior
1817 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1818 Renderer renderer = actor.GetRendererAt(0u);
1819 DALI_TEST_CHECK(renderer);
1820 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1822 actor.SetProperty(Actor::Property::VISIBLE, false);
1824 application.SendNotification();
1825 application.Render();
1827 // Check rendering behavior again
1828 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1833 int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void)
1835 ToolkitTestApplication application;
1836 tet_infoline("UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged");
1838 Property::Map propertyMap;
1839 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1840 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1842 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1843 DALI_TEST_CHECK(visual);
1845 DummyControl actor = DummyControl::New(true);
1846 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1847 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1849 Vector2 controlSize(20.f, 30.f);
1850 actor.SetProperty(Actor::Property::SIZE, controlSize);
1852 application.GetScene().Add(actor);
1854 application.SendNotification();
1855 application.Render();
1857 // Trigger count is 1 - render a frame
1858 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1860 Property::Map attributes;
1861 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1863 application.SendNotification();
1864 application.Render();
1866 // Check rendering behavior
1867 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1868 Renderer renderer = actor.GetRendererAt(0u);
1869 DALI_TEST_CHECK(renderer);
1870 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1872 Window window = DevelWindow::Get(actor);
1875 application.SendNotification();
1876 application.Render();
1878 // Check rendering behavior again
1879 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1884 int UtcDaliAnimatedVectorImageVisualInvalidFile01(void)
1886 ToolkitTestApplication application;
1887 tet_infoline("Request loading with invalid file - should draw broken image");
1889 TestGlAbstraction& gl = application.GetGlAbstraction();
1890 TraceCallStack& textureTrace = gl.GetTextureTrace();
1891 textureTrace.Enable(true);
1893 Property::Map propertyMap;
1894 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1895 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1896 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1898 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1899 DALI_TEST_CHECK(visual);
1901 DummyControl actor = DummyControl::New(true);
1902 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1903 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1905 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1907 application.GetScene().Add(actor);
1909 application.SendNotification();
1910 application.Render();
1912 // Trigger count is 1 - load
1913 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1915 application.SendNotification();
1916 application.Render();
1918 // Check resource status
1919 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1920 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1922 // The broken image should be shown.
1923 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1924 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1929 int UtcDaliAnimatedVectorImageVisualInvalidFile02(void)
1931 ToolkitTestApplication application;
1932 tet_infoline("Request loading with invalid file - should draw broken image");
1934 TestGlAbstraction& gl = application.GetGlAbstraction();
1935 TraceCallStack& textureTrace = gl.GetTextureTrace();
1936 textureTrace.Enable(true);
1938 Property::Map propertyMap;
1939 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1940 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
1942 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1943 DALI_TEST_CHECK(visual);
1945 DummyControl actor = DummyControl::New(true);
1946 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1947 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1949 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1951 application.SendNotification();
1952 application.Render();
1954 // Add to the Scene after loading
1955 application.GetScene().Add(actor);
1957 application.SendNotification();
1958 application.Render();
1960 // Check resource status
1961 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1962 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1964 // The broken image should be shown.
1965 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1966 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1971 int UtcDaliAnimatedVectorImageVisualInvalidFile03(void)
1973 ToolkitTestApplication application;
1974 tet_infoline("Request loading with invalid file without size set - should draw broken image");
1976 TestGlAbstraction& gl = application.GetGlAbstraction();
1977 TraceCallStack& textureTrace = gl.GetTextureTrace();
1978 textureTrace.Enable(true);
1980 Property::Map propertyMap;
1981 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1982 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1983 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1985 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1986 DALI_TEST_CHECK(visual);
1988 DummyControl actor = DummyControl::New(true);
1989 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1990 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1992 application.GetScene().Add(actor);
1994 application.SendNotification();
1995 application.Render();
1997 // Trigger count is 1 - load
1998 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2000 application.SendNotification();
2001 application.Render();
2003 // Check resource status
2004 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2005 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2007 // The broken image should be shown.
2008 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2009 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2014 int UtcDaliAnimatedVectorImageVisualFrameDrops(void)
2016 ToolkitTestApplication application;
2017 tet_infoline("UtcDaliAnimatedVectorImageVisualFrameDrops");
2019 Property::Map propertyMap;
2020 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2021 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP)
2022 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2024 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2025 DALI_TEST_CHECK(visual);
2027 DummyControl actor = DummyControl::New(true);
2028 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2029 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2031 Vector2 controlSize(20.f, 30.f);
2032 actor.SetProperty(Actor::Property::SIZE, controlSize);
2034 application.GetScene().Add(actor);
2036 application.SendNotification();
2037 application.Render();
2039 // Trigger count is 2 - load, render the first frame
2040 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2042 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2043 Property::Value* value = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
2044 int totalFrameNumber = value->Get<int>();
2046 Property::Map attributes;
2047 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2049 // Make delay to drop frames
2050 Test::VectorAnimationRenderer::DelayRendering(170); // longer than 16.6 * 10frames
2052 application.SendNotification();
2053 application.Render();
2055 // Trigger count is 1 - calculating frame drops
2056 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2058 // Check dropped frame
2059 uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames();
2060 DALI_TEST_CHECK(frames > 0);
2061 DALI_TEST_CHECK(frames <= static_cast<uint32_t>(totalFrameNumber));
2066 int UtcDaliAnimatedVectorImageVisualSize(void)
2068 ToolkitTestApplication application;
2069 tet_infoline("UtcDaliAnimatedVectorImageVisualSize");
2071 TestGlAbstraction& gl = application.GetGlAbstraction();
2072 TraceCallStack& textureTrace = gl.GetTextureTrace();
2074 VisualFactory factory = VisualFactory::Get();
2075 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
2076 DALI_TEST_CHECK(visual);
2078 DummyControl actor = DummyControl::New(true);
2079 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2080 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2082 application.GetScene().Add(actor);
2084 application.SendNotification();
2085 application.Render();
2087 // Trigger count is 1 - resource ready
2088 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2090 textureTrace.Enable(true);
2092 application.SendNotification();
2093 application.Render();
2096 int width = 100, height = 100; // 100x100 is the content default size.
2097 std::stringstream out;
2098 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
2099 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2102 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
2104 application.SendNotification();
2105 application.Render();
2107 // Trigger count is 1 - resource ready
2108 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2110 textureTrace.Reset();
2112 application.SendNotification();
2113 application.Render();
2116 int width = 200, height = 200;
2117 std::stringstream out;
2118 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
2119 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2127 bool gDynamicPropertyCallbackFired = false;
2129 Property::Value FillColorCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber)
2131 gDynamicPropertyCallbackFired = true;
2135 return Vector3(0, 0, 1);
2139 return Vector3(1, 0, 0);
2144 int UtcDaliAnimatedVectorImageVisualDynamicProperty(void)
2146 ToolkitTestApplication application;
2147 tet_infoline("UtcDaliAnimatedVectorImageVisualDynamicProperty");
2149 VisualFactory factory = VisualFactory::Get();
2150 Visual::Base visual = factory.CreateVisual(
2152 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2153 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2154 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
2155 DALI_TEST_CHECK(visual);
2157 DummyControl actor = DummyControl::New(true);
2158 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2159 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2161 Vector2 controlSize(20.f, 30.f);
2162 actor.SetProperty(Actor::Property::SIZE, controlSize);
2164 application.GetScene().Add(actor);
2166 gDynamicPropertyCallbackFired = false;
2168 // Set dynamic property
2169 DevelAnimatedVectorImageVisual::DynamicPropertyInfo info;
2171 info.keyPath = "Test.Path";
2172 info.property = static_cast<int>(VectorAnimationRenderer::VectorProperty::FILL_COLOR);
2173 info.callback = MakeCallback(FillColorCallback);
2175 DevelControl::DoActionExtension(actor, DummyControl::Property::TEST_VISUAL, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info));
2177 Property::Map attributes;
2178 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2180 application.SendNotification();
2181 application.Render();
2183 // Trigger count is 2 - load & render a frame
2184 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2186 // Test whether the property callback is called
2187 DALI_TEST_EQUALS(gDynamicPropertyCallbackFired, true, TEST_LOCATION);
2192 int UtcDaliAnimatedVectorImageVisualDesiredSize(void)
2194 ToolkitTestApplication application;
2195 tet_infoline("UtcDaliAnimatedVectorImageVisualDesiredSize");
2197 TestGlAbstraction& gl = application.GetGlAbstraction();
2198 TraceCallStack& textureTrace = gl.GetTextureTrace();
2199 int desiredWidth = 150, desiredHeight = 200;
2201 Visual::Base visual = VisualFactory::Get().CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
2202 DALI_TEST_CHECK(visual);
2204 DummyControl actor = DummyControl::New(true);
2205 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2206 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2208 application.GetScene().Add(actor);
2210 application.SendNotification();
2211 application.Render();
2213 // Trigger count is 1 - resource ready
2214 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2216 textureTrace.Enable(true);
2218 application.SendNotification();
2219 application.Render();
2222 std::stringstream out;
2223 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
2224 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2227 // Unparent to make next trigger
2230 application.SendNotification();
2231 application.Render();
2234 actor.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.0f));
2235 application.GetScene().Add(actor);
2237 application.SendNotification();
2238 application.Render();
2240 // Trigger count is 1 - resource ready
2241 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2243 textureTrace.Reset();
2245 application.SendNotification();
2246 application.Render();
2249 std::stringstream out;
2250 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
2251 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str())); // The size should not be changed
2257 int UtcDaliAnimatedVectorImageVisualFlushAction(void)
2259 ToolkitTestApplication application;
2261 tet_infoline("UtcDaliAnimatedVectorImageVisualFlushAction");
2266 int totalFrameCount = 0;
2268 Property::Array playRange;
2269 playRange.PushBack(startFrame);
2270 playRange.PushBack(endFrame);
2272 Property::Map resultMap;
2273 Property::Value* value = nullptr;
2275 // request AnimatedVectorImageVisual with a property map
2276 VisualFactory factory = VisualFactory::Get();
2277 Visual::Base visual = factory.CreateVisual(
2279 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2280 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2281 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
2282 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, true));
2284 DummyControl dummyControl = DummyControl::New(true);
2285 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
2286 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2287 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
2289 application.GetScene().Add(dummyControl);
2291 // Retry function to get playrange until expect values comes.
2292 auto CheckAndRetryPlayRange = [&](int expectStartFrame, int expectEndFrame, std::vector<std::pair<int, int>> retrialFrames) {
2294 int tryCountMax = 30;
2295 while(++tryCount <= tryCountMax)
2297 Property::Map resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2299 Property::Value* value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
2300 DALI_TEST_CHECK(value);
2302 Property::Array* result = value->GetArray();
2303 DALI_TEST_CHECK(result);
2304 DALI_TEST_EQUALS(result->Count(), 2, TEST_LOCATION);
2306 bool tryAgain = false;
2307 for(auto& framePair : retrialFrames)
2309 if(result->GetElementAt(0).Get<int>() == framePair.first && result->GetElementAt(1).Get<int>() == framePair.second)
2317 tet_printf("Retry to get value again! [%d]\n", tryCount);
2318 // Dummy sleep 1 second.
2319 Test::WaitForEventThreadTrigger(1, 1);
2323 DALI_TEST_EQUALS(result->GetElementAt(0).Get<int>(), expectStartFrame, TEST_LOCATION);
2324 DALI_TEST_EQUALS(result->GetElementAt(1).Get<int>(), expectEndFrame, TEST_LOCATION);
2327 DALI_TEST_CHECK(tryCount <= tryCountMax);
2330 tet_printf("Pause lottie first.\n");
2332 Property::Map attributes;
2333 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
2335 application.SendNotification();
2336 application.Render(16);
2340 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2342 value = resultMap.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER, Property::INTEGER);
2343 DALI_TEST_CHECK(value);
2344 totalFrameCount = value->Get<int>();
2345 } while(totalFrameCount == 0);
2347 // Ensure that vector data sended well.
2348 CheckAndRetryPlayRange(startFrame, endFrame, {{0, 0}, {0, totalFrameCount - 1}});
2350 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2352 value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
2353 DALI_TEST_CHECK(value);
2354 DALI_TEST_EQUALS(value->Get<int>(), startFrame, TEST_LOCATION);
2356 tet_printf("Now logically, range : [%d~%d], current : %d\n", startFrame, endFrame, startFrame);
2358 int changedStartFrame1 = startFrame + 2;
2359 int changedEndFrame1 = endFrame + 2;
2362 playRange.Add(changedStartFrame1);
2363 playRange.Add(changedEndFrame1);
2365 tet_printf("Change play range\n");
2366 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
2367 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2369 tet_printf("Jump to changedEndFrame!\n");
2370 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, changedEndFrame1);
2373 tet_infoline("Flush Action!");
2374 tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame1, changedEndFrame1, changedEndFrame1);
2375 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::FLUSH, attributes);
2377 int changedStartFrame2 = startFrame + 1;
2378 int changedEndFrame2 = endFrame + 1;
2381 playRange.Add(changedStartFrame2);
2382 playRange.Add(changedEndFrame2);
2384 tet_printf("Change play range again\n");
2385 tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame2, changedEndFrame2, changedEndFrame2);
2386 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
2387 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2389 application.SendNotification();
2390 application.Render(16);
2392 // Ensure that vector data sended well.
2393 CheckAndRetryPlayRange(changedStartFrame2, changedEndFrame2, {{changedStartFrame1, changedEndFrame1}, {startFrame, endFrame}});
2395 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2397 tet_printf("Test whether current frame number changed well. If Flush not works, current frame become startFrame.");
2398 value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
2399 DALI_TEST_CHECK(value);
2400 DALI_TEST_EQUALS(value->Get<int>(), changedEndFrame2, TEST_LOCATION);
2402 dummyControl.Unparent();