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 UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
1054 ToolkitTestApplication application;
1055 tet_infoline("UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal");
1057 Property::Map propertyMap;
1058 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1059 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1061 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1062 DALI_TEST_CHECK(visual);
1064 DummyControl actor = DummyControl::New(true);
1065 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1066 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1068 DevelControl::VisualEventSignal(actor).Connect(&VisualEventSignal);
1070 Vector2 controlSize(20.f, 30.f);
1071 actor.SetProperty(Actor::Property::SIZE, controlSize);
1073 application.GetScene().Add(actor);
1075 application.SendNotification();
1076 application.Render();
1078 // Trigger count is 1 - render a frame
1079 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1081 propertyMap.Clear();
1082 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1083 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1085 Property::Map attributes;
1086 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1088 application.SendNotification();
1089 application.Render();
1091 // Wait for animation finish
1092 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1094 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1095 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
1096 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
1098 DALI_TEST_EQUALS(gAnimationFinishedSignalFired, true, TEST_LOCATION);
1103 int UtcDaliAnimatedVectorImageVisualJumpTo(void)
1105 ToolkitTestApplication application;
1106 tet_infoline("UtcDaliAnimatedVectorImageVisualJumpTo");
1108 Property::Map propertyMap;
1109 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1110 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1111 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1112 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1114 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1115 DALI_TEST_CHECK(visual);
1117 tet_printf("1. Visual is created.\n");
1119 DummyControl actor = DummyControl::New(true);
1120 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1121 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1123 Vector2 controlSize(20.f, 30.f);
1124 actor.SetProperty(Actor::Property::SIZE, controlSize);
1126 application.GetScene().Add(actor);
1128 application.SendNotification();
1129 application.Render();
1131 // Trigger count is 2 - load & render a frame
1132 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1134 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2);
1136 // To make event trigger
1137 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1139 application.SendNotification();
1140 application.Render();
1142 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1144 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1145 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1146 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1148 tet_printf("2. The current frame number is [%d].\n", value->Get<int>());
1150 Property::Array array;
1154 Property::Map attributes;
1155 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1156 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1158 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1160 // To make event trigger
1161 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1163 application.SendNotification();
1164 application.Render();
1166 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1168 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1169 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1170 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1172 tet_printf("3. The current frame number is [%d].\n", value->Get<int>());
1174 // Change play range
1181 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1182 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1185 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1187 application.SendNotification();
1188 application.Render();
1190 // Wait for animation finish
1191 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1194 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1196 // To make event trigger
1197 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1199 application.SendNotification();
1200 application.Render();
1202 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1204 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1205 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1206 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1208 tet_printf("4. The current frame number is [%d].\n", value->Get<int>());
1210 // Jump to the same position
1211 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1213 // To make event trigger
1214 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1216 application.SendNotification();
1217 application.Render();
1219 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1221 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1222 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1223 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1225 tet_printf("5. The current frame number is [%d].\n", value->Get<int>());
1230 int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
1232 ToolkitTestApplication application;
1233 tet_infoline("UtcDaliAnimatedVectorImageVisualUpdateProperty");
1235 int startFrame = 1, endFrame = 3;
1236 Property::Array playRange;
1237 playRange.PushBack(startFrame);
1238 playRange.PushBack(endFrame);
1240 Property::Map propertyMap;
1241 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1242 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1243 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1244 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
1245 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1247 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1248 DALI_TEST_CHECK(visual);
1250 DummyControl actor = DummyControl::New(true);
1251 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1252 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1254 Vector2 controlSize(20.f, 30.f);
1255 actor.SetProperty(Actor::Property::SIZE, controlSize);
1257 application.GetScene().Add(actor);
1259 application.SendNotification();
1260 application.Render();
1262 // Trigger count is 2 - load & render a frame
1263 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1265 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1266 Property::Value* value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1267 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1269 value = map.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
1270 DALI_TEST_CHECK(value);
1272 Property::Array* result = value->GetArray();
1273 DALI_TEST_CHECK(result);
1275 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1276 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1279 playRange.PushBack(0);
1280 playRange.PushBack(2);
1282 Property::Map attributes;
1283 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1284 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 5);
1286 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1288 // To make event trigger
1289 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1291 application.SendNotification();
1292 application.Render();
1294 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1296 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1297 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1298 DALI_TEST_EQUALS(value->Get<int>(), 5, TEST_LOCATION);
1300 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1301 result = value->GetArray();
1302 DALI_TEST_CHECK(result);
1304 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == 0);
1305 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == 2);
1310 playRange.PushBack(startFrame);
1311 playRange.PushBack(endFrame);
1313 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1315 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1317 // To make event trigger
1318 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1320 application.SendNotification();
1321 application.Render();
1323 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1325 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1326 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1328 result = value->GetArray();
1329 DALI_TEST_CHECK(result);
1331 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1332 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1334 // Play and update property
1336 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1338 application.SendNotification();
1339 application.Render();
1341 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 10);
1343 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1345 application.SendNotification();
1346 application.Render();
1348 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1349 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1350 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
1355 int UtcDaliAnimatedVectorImageVisualStopBehavior(void)
1357 ToolkitTestApplication application;
1358 tet_infoline("UtcDaliAnimatedVectorImageVisualStopBehavior");
1360 Property::Map propertyMap;
1361 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1362 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1363 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1365 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1366 DALI_TEST_CHECK(visual);
1368 DummyControl actor = DummyControl::New(true);
1369 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1370 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1372 Vector2 controlSize(20.f, 30.f);
1373 actor.SetProperty(Actor::Property::SIZE, controlSize);
1375 application.GetScene().Add(actor);
1377 application.SendNotification();
1378 application.Render();
1380 // Trigger count is 2 - load & render a frame
1381 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1383 propertyMap.Clear();
1384 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1385 propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
1386 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1388 Property::Map attributes;
1389 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1391 application.SendNotification();
1392 application.Render();
1394 // Trigger count is 1 - animation finished
1395 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1397 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1398 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1399 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1401 // Change stop behavior
1402 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1404 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1409 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1411 application.SendNotification();
1412 application.Render();
1414 // Trigger count is 1 - animation finished
1415 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1417 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1419 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1420 int totalFrameNumber = value1->Get<int>();
1422 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1423 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1425 // Change stop behavior
1426 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1427 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, -1);
1429 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1434 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1436 application.SendNotification();
1437 application.Render();
1440 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
1442 // To make event trigger
1443 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1445 application.SendNotification();
1446 application.Render();
1448 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1450 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1451 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1452 int currentFrameNumber = value->Get<int>();
1455 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
1457 // To make event trigger
1458 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1460 application.SendNotification();
1461 application.Render();
1463 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1465 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1466 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1467 DALI_TEST_EQUALS(value->Get<int>(), currentFrameNumber, TEST_LOCATION); // Should be same with currentFrameNumber
1472 int UtcDaliAnimatedVectorImageVisualLoopingMode(void)
1474 ToolkitTestApplication application;
1475 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopingMode");
1477 Property::Map propertyMap;
1478 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1479 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1480 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1482 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1483 DALI_TEST_CHECK(visual);
1485 DummyControl actor = DummyControl::New(true);
1486 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1487 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1489 Vector2 controlSize(20.f, 30.f);
1490 actor.SetProperty(Actor::Property::SIZE, controlSize);
1492 application.GetScene().Add(actor);
1494 application.SendNotification();
1495 application.Render();
1497 // Trigger count is 2 - load, render
1498 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1500 propertyMap.Clear();
1501 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1502 propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1503 propertyMap.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::AUTO_REVERSE);
1504 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1506 Property::Map attributes;
1507 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1509 application.SendNotification();
1510 application.Render();
1512 // Trigger count is 1 - animation finished
1513 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1515 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1516 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1517 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame because of auto reverse
1519 // Change stop behavior
1520 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1522 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1525 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1527 application.SendNotification();
1528 application.Render();
1530 // Trigger count is 1 - animation finished
1531 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1533 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1534 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1535 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1537 // Change looping mode
1538 attributes.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::RESTART);
1540 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1543 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1545 application.SendNotification();
1546 application.Render();
1548 // Trigger count is 1 - animation finished
1549 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1551 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1552 int totalFrameNumber = value1->Get<int>();
1554 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1555 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1556 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1561 int UtcDaliAnimatedVectorImageVisualPropertyNotification(void)
1563 ToolkitTestApplication application;
1564 tet_infoline("UtcDaliAnimatedVectorImageVisualPropertyNotification");
1566 Property::Map propertyMap;
1567 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1568 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1570 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1571 DALI_TEST_CHECK(visual);
1573 DummyControl actor = DummyControl::New(true);
1574 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1575 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1576 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1578 application.GetScene().Add(actor);
1580 application.SendNotification();
1581 application.Render();
1583 // Trigger count is 1 - render a frame
1584 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1586 Renderer renderer = actor.GetRendererAt(0u);
1587 DALI_TEST_CHECK(renderer);
1589 Vector2 controlSize(20.f, 30.f);
1590 actor.SetProperty(Actor::Property::SIZE, controlSize);
1592 application.SendNotification();
1593 application.Render();
1595 application.SendNotification();
1596 application.Render();
1598 // Trigger count is 1 - render a frame
1599 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1601 auto textureSet = renderer.GetTextures();
1602 auto texture = textureSet.GetTexture(0);
1604 DALI_TEST_EQUALS(controlSize.width, texture.GetWidth(), TEST_LOCATION);
1605 DALI_TEST_EQUALS(controlSize.height, texture.GetHeight(), TEST_LOCATION);
1608 Vector3 controlScale(2.0f, 2.0f, 1.0f);
1609 actor.SetProperty(Actor::Property::SCALE, controlScale);
1611 application.SendNotification();
1612 application.Render();
1614 application.SendNotification();
1615 application.Render();
1617 // Trigger count is 1 - render a frame
1618 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1620 renderer = actor.GetRendererAt(0u);
1621 DALI_TEST_CHECK(renderer);
1623 textureSet = renderer.GetTextures();
1624 texture = textureSet.GetTexture(0);
1626 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1627 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1630 controlSize = Vector2(50.0f, 100.0f);
1631 Animation animation = Animation::New(1.0);
1632 animation.AnimateTo(Property(actor, Actor::Property::SIZE), Vector3(controlSize.x, controlSize.y, 0.0f));
1635 application.SendNotification();
1636 application.Render(1100); // After the animation
1638 application.SendNotification();
1639 application.Render();
1641 // Trigger count is 1 - render a frame
1642 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1644 renderer = actor.GetRendererAt(0u);
1645 DALI_TEST_CHECK(renderer);
1647 textureSet = renderer.GetTextures();
1648 texture = textureSet.GetTexture(0);
1650 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1651 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1656 int UtcDaliAnimatedVectorImageVisualMultipleInstances(void)
1658 ToolkitTestApplication application;
1659 tet_infoline("UtcDaliAnimatedVectorImageVisualMultipleInstances");
1661 Property::Map propertyMap;
1662 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1663 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1664 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1666 Visual::Base visual1 = VisualFactory::Get().CreateVisual(propertyMap);
1667 DALI_TEST_CHECK(visual1);
1669 DummyControl actor1 = DummyControl::New(true);
1670 DummyControlImpl& dummyImpl1 = static_cast<DummyControlImpl&>(actor1.GetImplementation());
1671 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual1);
1673 Vector2 controlSize(20.f, 30.f);
1674 actor1.SetProperty(Actor::Property::SIZE, controlSize);
1676 application.GetScene().Add(actor1);
1678 application.SendNotification();
1679 application.Render();
1681 // Trigger count is 2 - load & render a frame
1682 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1684 propertyMap.Clear();
1685 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1686 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1687 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1689 Visual::Base visual2 = VisualFactory::Get().CreateVisual(propertyMap);
1690 DALI_TEST_CHECK(visual2);
1692 DummyControl actor2 = DummyControl::New(true);
1693 DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor2.GetImplementation());
1694 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
1696 actor2.SetProperty(Actor::Property::SIZE, controlSize);
1698 application.GetScene().Add(actor2);
1700 application.SendNotification();
1701 application.Render();
1703 // Trigger count is 2 - load & render a frame
1704 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1706 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1708 // To make event trigger
1709 actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1711 application.SendNotification();
1712 application.Render();
1714 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1716 Property::Map attributes;
1717 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1719 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1720 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1722 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1724 // renderer is added to actor
1725 DALI_TEST_CHECK(actor1.GetRendererCount() == 1u);
1726 Renderer renderer1 = actor1.GetRendererAt(0u);
1727 DALI_TEST_CHECK(renderer1);
1729 // renderer is added to actor
1730 DALI_TEST_CHECK(actor2.GetRendererCount() == 1u);
1731 Renderer renderer2 = actor2.GetRendererAt(0u);
1732 DALI_TEST_CHECK(renderer2);
1737 int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void)
1739 ToolkitTestApplication application;
1740 tet_infoline("UtcDaliAnimatedVectorImageVisualControlVisibilityChanged");
1742 Property::Map propertyMap;
1743 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1744 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1745 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1747 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1748 DALI_TEST_CHECK(visual);
1750 DummyControl actor = DummyControl::New(true);
1751 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1752 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1754 Vector2 controlSize(20.f, 30.f);
1755 actor.SetProperty(Actor::Property::SIZE, controlSize);
1757 application.GetScene().Add(actor);
1759 application.SendNotification();
1760 application.Render();
1762 // Trigger count is 2 - load & render a frame
1763 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1765 Property::Map attributes;
1766 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1768 application.SendNotification();
1769 application.Render();
1771 // Check rendering behavior
1772 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1773 Renderer renderer = actor.GetRendererAt(0u);
1774 DALI_TEST_CHECK(renderer);
1775 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1777 actor.SetProperty(Actor::Property::VISIBLE, false);
1779 application.SendNotification();
1780 application.Render();
1782 // Check rendering behavior again
1783 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1788 int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void)
1790 ToolkitTestApplication application;
1791 tet_infoline("UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged");
1793 Property::Map propertyMap;
1794 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1795 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1797 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1798 DALI_TEST_CHECK(visual);
1800 DummyControl actor = DummyControl::New(true);
1801 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1802 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1804 Vector2 controlSize(20.f, 30.f);
1805 actor.SetProperty(Actor::Property::SIZE, controlSize);
1807 application.GetScene().Add(actor);
1809 application.SendNotification();
1810 application.Render();
1812 // Trigger count is 1 - render a frame
1813 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1815 Property::Map attributes;
1816 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1818 application.SendNotification();
1819 application.Render();
1821 // Check rendering behavior
1822 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1823 Renderer renderer = actor.GetRendererAt(0u);
1824 DALI_TEST_CHECK(renderer);
1825 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1827 Window window = DevelWindow::Get(actor);
1830 application.SendNotification();
1831 application.Render();
1833 // Check rendering behavior again
1834 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1839 int UtcDaliAnimatedVectorImageVisualInvalidFile01(void)
1841 ToolkitTestApplication application;
1842 tet_infoline("Request loading with invalid file - should draw broken image");
1844 TestGlAbstraction& gl = application.GetGlAbstraction();
1845 TraceCallStack& textureTrace = gl.GetTextureTrace();
1846 textureTrace.Enable(true);
1848 Property::Map propertyMap;
1849 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1850 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1851 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1853 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1854 DALI_TEST_CHECK(visual);
1856 DummyControl actor = DummyControl::New(true);
1857 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1858 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1860 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1862 application.GetScene().Add(actor);
1864 application.SendNotification();
1865 application.Render();
1867 // Trigger count is 1 - load
1868 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1870 application.SendNotification();
1871 application.Render();
1873 // Check resource status
1874 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1875 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1877 // The broken image should be shown.
1878 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1879 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1884 int UtcDaliAnimatedVectorImageVisualInvalidFile02(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);
1897 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1898 DALI_TEST_CHECK(visual);
1900 DummyControl actor = DummyControl::New(true);
1901 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1902 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1904 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1906 application.SendNotification();
1907 application.Render();
1909 // Add to the Scene after loading
1910 application.GetScene().Add(actor);
1912 application.SendNotification();
1913 application.Render();
1915 // Check resource status
1916 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1917 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1919 // The broken image should be shown.
1920 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1921 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1926 int UtcDaliAnimatedVectorImageVisualInvalidFile03(void)
1928 ToolkitTestApplication application;
1929 tet_infoline("Request loading with invalid file without size set - should draw broken image");
1931 TestGlAbstraction& gl = application.GetGlAbstraction();
1932 TraceCallStack& textureTrace = gl.GetTextureTrace();
1933 textureTrace.Enable(true);
1935 Property::Map propertyMap;
1936 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1937 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1938 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1940 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1941 DALI_TEST_CHECK(visual);
1943 DummyControl actor = DummyControl::New(true);
1944 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1945 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1947 application.GetScene().Add(actor);
1949 application.SendNotification();
1950 application.Render();
1952 // Trigger count is 1 - load
1953 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1955 application.SendNotification();
1956 application.Render();
1958 // Check resource status
1959 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1960 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1962 // The broken image should be shown.
1963 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1964 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1969 int UtcDaliAnimatedVectorImageVisualFrameDrops(void)
1971 ToolkitTestApplication application;
1972 tet_infoline("UtcDaliAnimatedVectorImageVisualFrameDrops");
1974 Property::Map propertyMap;
1975 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1976 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP)
1977 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1979 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1980 DALI_TEST_CHECK(visual);
1982 DummyControl actor = DummyControl::New(true);
1983 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1984 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1986 Vector2 controlSize(20.f, 30.f);
1987 actor.SetProperty(Actor::Property::SIZE, controlSize);
1989 application.GetScene().Add(actor);
1991 application.SendNotification();
1992 application.Render();
1994 // Trigger count is 2 - load, render the first frame
1995 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1997 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1998 Property::Value* value = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1999 int totalFrameNumber = value->Get<int>();
2001 Property::Map attributes;
2002 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2004 // Make delay to drop frames
2005 Test::VectorAnimationRenderer::DelayRendering(170); // longer than 16.6 * 10frames
2007 application.SendNotification();
2008 application.Render();
2010 // Trigger count is 1 - calculating frame drops
2011 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2013 // Check dropped frame
2014 uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames();
2015 DALI_TEST_CHECK(frames > 0);
2016 DALI_TEST_CHECK(frames <= static_cast<uint32_t>(totalFrameNumber));
2021 int UtcDaliAnimatedVectorImageVisualSize(void)
2023 ToolkitTestApplication application;
2024 tet_infoline("UtcDaliAnimatedVectorImageVisualSize");
2026 TestGlAbstraction& gl = application.GetGlAbstraction();
2027 TraceCallStack& textureTrace = gl.GetTextureTrace();
2029 VisualFactory factory = VisualFactory::Get();
2030 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
2031 DALI_TEST_CHECK(visual);
2033 DummyControl actor = DummyControl::New(true);
2034 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2035 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2037 application.GetScene().Add(actor);
2039 application.SendNotification();
2040 application.Render();
2042 // Trigger count is 1 - resource ready
2043 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2045 textureTrace.Enable(true);
2047 application.SendNotification();
2048 application.Render();
2051 int width = 100, height = 100; // 100x100 is the content default size.
2052 std::stringstream out;
2053 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
2054 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2057 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
2059 application.SendNotification();
2060 application.Render();
2062 // Trigger count is 1 - resource ready
2063 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2065 textureTrace.Reset();
2067 application.SendNotification();
2068 application.Render();
2071 int width = 200, height = 200;
2072 std::stringstream out;
2073 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
2074 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2082 bool gDynamicPropertyCallbackFired = false;
2084 Property::Value FillColorCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber)
2086 gDynamicPropertyCallbackFired = true;
2090 return Vector3(0, 0, 1);
2094 return Vector3(1, 0, 0);
2099 int UtcDaliAnimatedVectorImageVisualDynamicProperty(void)
2101 ToolkitTestApplication application;
2102 tet_infoline("UtcDaliAnimatedVectorImageVisualDynamicProperty");
2104 VisualFactory factory = VisualFactory::Get();
2105 Visual::Base visual = factory.CreateVisual(
2107 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2108 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2109 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
2110 DALI_TEST_CHECK(visual);
2112 DummyControl actor = DummyControl::New(true);
2113 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2114 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2116 Vector2 controlSize(20.f, 30.f);
2117 actor.SetProperty(Actor::Property::SIZE, controlSize);
2119 application.GetScene().Add(actor);
2121 gDynamicPropertyCallbackFired = false;
2123 // Set dynamic property
2124 DevelAnimatedVectorImageVisual::DynamicPropertyInfo info;
2126 info.keyPath = "Test.Path";
2127 info.property = static_cast<int>(VectorAnimationRenderer::VectorProperty::FILL_COLOR);
2128 info.callback = MakeCallback(FillColorCallback);
2130 DevelControl::DoActionExtension(actor, DummyControl::Property::TEST_VISUAL, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info));
2132 Property::Map attributes;
2133 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2135 application.SendNotification();
2136 application.Render();
2138 // Trigger count is 2 - load & render a frame
2139 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2141 // Test whether the property callback is called
2142 DALI_TEST_EQUALS(gDynamicPropertyCallbackFired, true, TEST_LOCATION);
2147 int UtcDaliAnimatedVectorImageVisualDesiredSize(void)
2149 ToolkitTestApplication application;
2150 tet_infoline("UtcDaliAnimatedVectorImageVisualDesiredSize");
2152 TestGlAbstraction& gl = application.GetGlAbstraction();
2153 TraceCallStack& textureTrace = gl.GetTextureTrace();
2154 int desiredWidth = 150, desiredHeight = 200;
2156 Visual::Base visual = VisualFactory::Get().CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
2157 DALI_TEST_CHECK(visual);
2159 DummyControl actor = DummyControl::New(true);
2160 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2161 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2163 application.GetScene().Add(actor);
2165 application.SendNotification();
2166 application.Render();
2168 // Trigger count is 1 - resource ready
2169 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2171 textureTrace.Enable(true);
2173 application.SendNotification();
2174 application.Render();
2177 std::stringstream out;
2178 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
2179 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2182 // Unparent to make next trigger
2185 application.SendNotification();
2186 application.Render();
2189 actor.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.0f));
2190 application.GetScene().Add(actor);
2192 application.SendNotification();
2193 application.Render();
2195 // Trigger count is 1 - resource ready
2196 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2198 textureTrace.Reset();
2200 application.SendNotification();
2201 application.Render();
2204 std::stringstream out;
2205 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
2206 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str())); // The size should not be changed
2212 int UtcDaliAnimatedVectorImageVisualFlushAction(void)
2214 ToolkitTestApplication application;
2216 tet_infoline("UtcDaliAnimatedVectorImageVisualFlushAction");
2221 int totalFrameCount = 0;
2223 Property::Array playRange;
2224 playRange.PushBack(startFrame);
2225 playRange.PushBack(endFrame);
2227 Property::Map resultMap;
2228 Property::Value* value = nullptr;
2230 // request AnimatedVectorImageVisual with a property map
2231 VisualFactory factory = VisualFactory::Get();
2232 Visual::Base visual = factory.CreateVisual(
2234 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2235 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2236 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
2237 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, true));
2239 DummyControl dummyControl = DummyControl::New(true);
2240 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
2241 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2242 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
2244 application.GetScene().Add(dummyControl);
2246 // Retry function to get playrange until expect values comes.
2247 auto CheckAndRetryPlayRange = [&](int expectStartFrame, int expectEndFrame, std::vector<std::pair<int, int>> retrialFrames) {
2249 int tryCountMax = 30;
2250 while(++tryCount <= tryCountMax)
2252 Property::Map resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2254 Property::Value* value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
2255 DALI_TEST_CHECK(value);
2257 Property::Array* result = value->GetArray();
2258 DALI_TEST_CHECK(result);
2259 DALI_TEST_EQUALS(result->Count(), 2, TEST_LOCATION);
2261 bool tryAgain = false;
2262 for(auto& framePair : retrialFrames)
2264 if(result->GetElementAt(0).Get<int>() == framePair.first && result->GetElementAt(1).Get<int>() == framePair.second)
2272 tet_printf("Retry to get value again! [%d]\n", tryCount);
2273 // Dummy sleep 1 second.
2274 Test::WaitForEventThreadTrigger(1, 1);
2278 DALI_TEST_EQUALS(result->GetElementAt(0).Get<int>(), expectStartFrame, TEST_LOCATION);
2279 DALI_TEST_EQUALS(result->GetElementAt(1).Get<int>(), expectEndFrame, TEST_LOCATION);
2282 DALI_TEST_CHECK(tryCount <= tryCountMax);
2285 tet_printf("Pause lottie first.\n");
2287 Property::Map attributes;
2288 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
2290 application.SendNotification();
2291 application.Render(16);
2295 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2297 value = resultMap.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER, Property::INTEGER);
2298 DALI_TEST_CHECK(value);
2299 totalFrameCount = value->Get<int>();
2300 } while(totalFrameCount == 0);
2302 // Ensure that vector data sended well.
2303 CheckAndRetryPlayRange(startFrame, endFrame, {{0, 0}, {0, totalFrameCount - 1}});
2305 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2307 value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
2308 DALI_TEST_CHECK(value);
2309 DALI_TEST_EQUALS(value->Get<int>(), startFrame, TEST_LOCATION);
2311 tet_printf("Now logically, range : [%d~%d], current : %d\n", startFrame, endFrame, startFrame);
2313 int changedStartFrame1 = startFrame + 2;
2314 int changedEndFrame1 = endFrame + 2;
2317 playRange.Add(changedStartFrame1);
2318 playRange.Add(changedEndFrame1);
2320 tet_printf("Change play range\n");
2321 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
2322 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2324 tet_printf("Jump to changedEndFrame!\n");
2325 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, changedEndFrame1);
2328 tet_infoline("Flush Action!");
2329 tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame1, changedEndFrame1, changedEndFrame1);
2330 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::FLUSH, attributes);
2332 int changedStartFrame2 = startFrame + 1;
2333 int changedEndFrame2 = endFrame + 1;
2336 playRange.Add(changedStartFrame2);
2337 playRange.Add(changedEndFrame2);
2339 tet_printf("Change play range again\n");
2340 tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame2, changedEndFrame2, changedEndFrame2);
2341 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
2342 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2344 application.SendNotification();
2345 application.Render(16);
2347 // Ensure that vector data sended well.
2348 CheckAndRetryPlayRange(changedStartFrame2, changedEndFrame2, {{changedStartFrame1, changedEndFrame1}, {startFrame, endFrame}});
2350 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2352 tet_printf("Test whether current frame number changed well. If Flush not works, current frame become startFrame.");
2353 value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
2354 DALI_TEST_CHECK(value);
2355 DALI_TEST_EQUALS(value->Get<int>(), changedEndFrame2, TEST_LOCATION);
2357 dummyControl.Unparent();