2 * Copyright (c) 2024 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"
27 #include "test-native-image-source.h"
29 #include <dali-toolkit/dali-toolkit.h>
31 #include <dali-toolkit/devel-api/controls/control-devel.h>
32 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
33 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-actions-devel.h>
34 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-signals-devel.h>
35 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
36 #include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
37 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
39 #include <dali/devel-api/adaptor-framework/vector-animation-renderer.h>
40 #include <dali/devel-api/adaptor-framework/window-devel.h>
41 #include <dali/devel-api/rendering/renderer-devel.h>
44 using namespace Dali::Toolkit;
46 void dali_animated_vector_image_visual_startup(void)
48 test_return_value = TET_UNDEF;
51 void dali_animated_vector_image_visual_cleanup(void)
53 test_return_value = TET_PASS;
58 const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
59 const char* TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP = "framedrop.json";
60 const char* TEST_VECTOR_IMAGE_INVALID_FILE_NAME = "invalid.json";
62 bool gAnimationFinishedSignalFired = false;
64 void VisualEventSignal(Control control, Dali::Property::Index visualIndex, Dali::Property::Index signalId)
66 if(visualIndex == DummyControl::Property::TEST_VISUAL && signalId == DevelAnimatedVectorImageVisual::Signal::ANIMATION_FINISHED)
68 gAnimationFinishedSignalFired = true;
73 * @brief Retry function to get playrange until expect values comes.
74 * @note This function might consume EventThreadTrigger.
76 * @param[in] dummyControl The control for test.
77 * @param[in] expectStartFrame Expect start frame.
78 * @param[in] expectEndFrame Expect end frame.
79 * @param[in] retrialFrames Retry required frame value list.
80 * @param[in] testLocation Location info of UTC. It will be used when UTC failed.
82 void CheckAndRetryPlayRange(DummyControl dummyControl, int expectStartFrame, int expectEndFrame, std::vector<std::pair<int, int>> retrialFrames, const char* testLocation)
86 while(++tryCount <= tryCountMax)
88 Property::Map resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
90 Property::Value* value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
91 DALI_TEST_CHECK(value);
93 Property::Array* result = value->GetArray();
94 DALI_TEST_CHECK(result);
95 DALI_TEST_EQUALS(result->Count(), 2, TEST_LOCATION);
97 bool tryAgain = false;
98 for(auto& framePair : retrialFrames)
100 if(result->GetElementAt(0).Get<int>() == framePair.first && result->GetElementAt(1).Get<int>() == framePair.second)
108 tet_printf("Retry to get value again! [%d]\n", tryCount);
109 // Dummy sleep 1 second.
110 Test::WaitForEventThreadTrigger(1, 1);
114 DALI_TEST_EQUALS(result->GetElementAt(0).Get<int>(), expectStartFrame, testLocation);
115 DALI_TEST_EQUALS(result->GetElementAt(1).Get<int>(), expectEndFrame, testLocation);
118 DALI_TEST_CHECK(tryCount <= tryCountMax);
122 * @brief Retry function to get current frame until expect values comes.
123 * @note This function might consume EventThreadTrigger.
125 * @param[in] dummyControl The control for test.
126 * @param[in] expectCurrentFrame Expect current frame.
127 * @param[in] retrialFrames Retry required frame value list.
128 * @param[in] testLocation Location info of UTC. It will be used when UTC failed.
130 void CheckAndRetryCurrentFrame(DummyControl dummyControl, int expectCurrentFrame, std::vector<int> retrialFrames, const char* testLocation)
133 int tryCountMax = 25;
134 while(++tryCount <= tryCountMax)
136 Property::Map resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
138 Property::Value* value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
139 DALI_TEST_CHECK(value);
141 int32_t result = value->Get<int32_t>();
143 bool tryAgain = false;
144 for(auto& frame : retrialFrames)
154 tet_printf("Retry to get value again! [%d]\n", tryCount);
155 // Dummy sleep 1 second.
156 Test::WaitForEventThreadTrigger(1, 1);
160 DALI_TEST_EQUALS(result, expectCurrentFrame, testLocation);
163 DALI_TEST_CHECK(tryCount <= tryCountMax);
168 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void)
170 ToolkitTestApplication application;
171 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual01: Request animated vector image visual with a json url");
173 VisualFactory factory = VisualFactory::Get();
174 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
175 DALI_TEST_CHECK(visual);
177 DummyControl actor = DummyControl::New(true);
178 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
179 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
180 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
181 application.GetScene().Add(actor);
183 application.SendNotification();
184 application.Render();
186 // Trigger count is 1 - render a frame
187 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
189 // renderer is added to actor
190 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
191 Renderer renderer = actor.GetRendererAt(0u);
192 DALI_TEST_CHECK(renderer);
194 // Test SetOffScene().
196 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
201 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual02(void)
203 ToolkitTestApplication application;
204 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual02: Request animated vector image visual with a Property::Map");
206 Property::Map propertyMap;
207 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
208 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
209 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
211 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
212 DALI_TEST_CHECK(visual);
214 DummyControl actor = DummyControl::New(true);
215 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
216 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
217 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
218 application.GetScene().Add(actor);
220 application.SendNotification();
221 application.Render();
223 // Trigger count is 2 - load & render a frame
224 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
226 // renderer is added to actor
227 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
228 Renderer renderer = actor.GetRendererAt(0u);
229 DALI_TEST_CHECK(renderer);
232 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
237 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void)
239 ToolkitTestApplication application;
240 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual03: Request animated vector image visual with a Property::Map");
242 int startFrame = 1, endFrame = 3;
243 Property::Array playRange;
244 playRange.PushBack(startFrame);
245 playRange.PushBack(endFrame);
247 Property::Map propertyMap;
248 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
249 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
250 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
251 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
252 .Add(DevelVisual::Property::CORNER_RADIUS, 50.0f)
253 .Add(DevelVisual::Property::BORDERLINE_WIDTH, 20.0f)
254 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
256 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
257 DALI_TEST_CHECK(visual);
259 DummyControl actor = DummyControl::New(true);
260 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
261 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
262 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
263 application.GetScene().Add(actor);
265 application.SendNotification();
266 application.Render();
268 // Trigger count is 2 - load & render a frame
269 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
271 // There might be 1 event triggered if start frame is not 0, and render frame spend long time.
272 // if ForceRenderOnce triggered before render complete, renderer count could be zero.
273 // Consume it if required.
274 if(actor.GetRendererCount() == 0)
276 tet_printf("Warning! render frame trigger not comes yet. Let we wait one more time.\n");
277 Test::WaitForEventThreadTrigger(1, 1);
280 // renderer is added to actor
281 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
282 Renderer renderer = actor.GetRendererAt(0u);
283 DALI_TEST_CHECK(renderer);
286 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
291 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void)
293 ToolkitTestApplication application;
294 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map");
296 int startFrame = 1, endFrame = 3;
297 int desiredWidth = 100, desiredHeight = 150;
298 float cornerRadius = 22.0f;
299 float borderlineWidth = 2.0f;
300 Vector4 borderlineColor = Vector4(1.0f, 1.0f, 1.0f, 1.0f);
301 float borderlineOffset = 0.1f;
302 Property::Array playRange;
303 playRange.PushBack(startFrame);
304 playRange.PushBack(endFrame);
306 Property::Map propertyMap;
307 propertyMap.Add("visualType", DevelVisual::ANIMATED_VECTOR_IMAGE)
308 .Add("url", TEST_VECTOR_IMAGE_FILE_NAME)
310 .Add("playRange", playRange)
311 .Add("stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME)
312 .Add("loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE)
313 .Add("redrawInScalingDown", false)
314 .Add("enableFrameCache", false)
315 .Add("notifyAfterRasterization", false)
316 .Add("cornerRadius", cornerRadius)
317 .Add("borderlineWidth", borderlineWidth)
318 .Add("borderlineColor", borderlineColor)
319 .Add("borderlineOffset", borderlineOffset)
320 .Add("desiredWidth", desiredWidth)
321 .Add("desiredHeight", desiredHeight);
323 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
324 DALI_TEST_CHECK(visual);
326 DummyControl actor = DummyControl::New(true);
327 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
328 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
329 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
330 application.GetScene().Add(actor);
332 application.SendNotification();
333 application.Render();
335 // Trigger count is 1 - render a frame
336 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
338 // There might be 1 event triggered if start frame is not 0, and render frame spend long time.
339 // if ForceRenderOnce triggered before render complete, renderer count could be zero.
340 // Consume it if required.
341 if(actor.GetRendererCount() == 0)
343 tet_printf("Warning! render frame trigger not comes yet. Let we wait one more time.\n");
344 Test::WaitForEventThreadTrigger(1, 1);
347 // renderer is added to actor
348 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
350 Renderer renderer = actor.GetRendererAt(0u);
351 DALI_TEST_CHECK(renderer);
353 Property::Map resultMap;
354 visual.CreatePropertyMap(resultMap);
356 // check the property values from the returned map from a visual
357 Property::Value* value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
358 DALI_TEST_CHECK(value);
359 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
361 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
362 DALI_TEST_CHECK(value);
363 DALI_TEST_CHECK(value->Get<int>() == 3);
365 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
366 DALI_TEST_CHECK(value);
368 Property::Array* result = value->GetArray();
369 DALI_TEST_CHECK(result);
371 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
372 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
374 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
375 DALI_TEST_CHECK(value);
376 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::FIRST_FRAME);
378 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
379 DALI_TEST_CHECK(value);
380 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::AUTO_REVERSE);
382 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
383 DALI_TEST_CHECK(value);
384 DALI_TEST_CHECK(value->Get<bool>() == false);
386 value = resultMap.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE, Property::BOOLEAN);
387 DALI_TEST_CHECK(value);
388 DALI_TEST_CHECK(value->Get<bool>() == false);
390 value = resultMap.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, Property::BOOLEAN);
391 DALI_TEST_CHECK(value);
392 DALI_TEST_CHECK(value->Get<bool>() == false);
394 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
395 DALI_TEST_CHECK(value);
396 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius), TEST_LOCATION);
398 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
399 DALI_TEST_CHECK(value);
400 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
402 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT);
403 DALI_TEST_CHECK(value);
404 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
406 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
407 DALI_TEST_CHECK(value);
408 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
410 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
411 DALI_TEST_CHECK(value);
412 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
414 value = resultMap.Find(ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER);
415 DALI_TEST_CHECK(value);
416 DALI_TEST_EQUALS(value->Get<int>(), desiredWidth, TEST_LOCATION);
418 value = resultMap.Find(ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER);
419 DALI_TEST_CHECK(value);
420 DALI_TEST_EQUALS(value->Get<int>(), desiredHeight, TEST_LOCATION);
423 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
428 int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
430 ToolkitTestApplication application;
431 tet_infoline("UtcDaliAnimatedVectorImageVisualGetPropertyMap01");
433 int startFrame = 1, endFrame = 3;
434 int desiredWidth = 100, desiredHeight = 150;
435 Vector4 cornerRadius(50.0f, 22.0f, 0.0f, 3.0f);
436 float borderlineWidth = 2.3f;
437 Vector4 borderlineColor = Vector4(0.3f, 0.3f, 1.0f, 1.0f);
438 float borderlineOffset = 0.3f;
439 Property::Array playRange;
440 playRange.PushBack(startFrame);
441 playRange.PushBack(endFrame);
443 Property::Map propertyMap;
444 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
445 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
446 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
447 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
448 .Add(DevelVisual::Property::CORNER_RADIUS, cornerRadius)
449 .Add(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::RELATIVE)
450 .Add(DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth)
451 .Add(DevelVisual::Property::BORDERLINE_COLOR, borderlineColor)
452 .Add(DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset)
453 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false)
454 .Add(ImageVisual::Property::DESIRED_WIDTH, desiredWidth)
455 .Add(ImageVisual::Property::DESIRED_HEIGHT, desiredHeight);
457 // request AnimatedVectorImageVisual with a property map
458 VisualFactory factory = VisualFactory::Get();
459 Visual::Base visual = factory.CreateVisual(propertyMap);
461 DummyControl actor = DummyControl::New(true);
462 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
463 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
465 Vector2 controlSize(20.f, 30.f);
466 actor.SetProperty(Actor::Property::SIZE, controlSize);
468 application.GetScene().Add(actor);
470 application.SendNotification();
471 application.Render();
473 // Trigger count is 2 - load & render a frame
474 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
476 Property::Map resultMap;
477 resultMap = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
479 // check the property values from the returned map from a visual
480 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
481 DALI_TEST_CHECK(value);
482 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
484 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
485 DALI_TEST_CHECK(value);
486 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
488 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
489 DALI_TEST_CHECK(value);
490 DALI_TEST_CHECK(value->Get<int>() == 3);
492 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
493 DALI_TEST_CHECK(value);
495 Property::Array* result = value->GetArray();
496 DALI_TEST_CHECK(result);
498 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
499 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
501 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
502 DALI_TEST_CHECK(value);
503 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::CURRENT_FRAME);
505 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
506 DALI_TEST_CHECK(value);
507 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::RESTART);
509 value = resultMap.Find(DevelImageVisual::Property::CONTENT_INFO, Property::MAP);
510 DALI_TEST_CHECK(value);
512 value = resultMap.Find(DevelImageVisual::Property::MARKER_INFO, Property::MAP);
513 DALI_TEST_CHECK(value);
515 value = resultMap.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE, Property::BOOLEAN);
516 DALI_TEST_CHECK(value);
517 DALI_TEST_CHECK(value->Get<bool>() == false); // Check default value
519 value = resultMap.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, Property::BOOLEAN);
520 DALI_TEST_CHECK(value);
521 DALI_TEST_CHECK(value->Get<bool>() == false); // Check default value
523 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
524 DALI_TEST_CHECK(value);
525 DALI_TEST_CHECK(value->Get<bool>() == true); // Check default value
527 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
528 DALI_TEST_CHECK(value);
529 DALI_TEST_EQUALS(value->Get<Vector4>(), cornerRadius, TEST_LOCATION);
531 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
532 DALI_TEST_CHECK(value);
533 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::RELATIVE);
535 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
536 DALI_TEST_CHECK(value);
537 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
539 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
540 DALI_TEST_CHECK(value);
541 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
543 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
544 DALI_TEST_CHECK(value);
545 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
547 value = resultMap.Find(ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER);
548 DALI_TEST_CHECK(value);
549 DALI_TEST_EQUALS(value->Get<int>(), desiredWidth, TEST_LOCATION);
551 value = resultMap.Find(ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER);
552 DALI_TEST_CHECK(value);
553 DALI_TEST_EQUALS(value->Get<int>(), desiredHeight, TEST_LOCATION);
555 // request AnimatedVectorImageVisual with an URL
556 Visual::Base visual2 = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
559 visual2.CreatePropertyMap(resultMap);
561 // check the property values from the returned map from a visual
562 value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
563 DALI_TEST_CHECK(value);
564 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
566 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
567 DALI_TEST_CHECK(value);
568 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
573 int UtcDaliAnimatedVectorImageVisualPlayback(void)
575 ToolkitTestApplication application;
577 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayback");
580 // request AnimatedVectorImageVisual with a property map
581 VisualFactory factory = VisualFactory::Get();
582 Visual::Base visual = factory.CreateVisual(
584 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
585 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
586 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
588 DummyControl dummyControl = DummyControl::New(true);
589 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
590 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
591 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
593 Property::Map attributes;
594 tet_infoline("Test Play action");
595 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
597 application.GetScene().Add(dummyControl);
598 application.SendNotification();
599 application.Render(16);
601 Property::Map map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
602 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
603 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
605 tet_infoline("Test Pause action");
606 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
608 application.SendNotification();
609 application.Render(16);
611 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
612 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
613 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PAUSED);
615 tet_infoline("Test Play action");
616 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
618 application.SendNotification();
619 application.Render(16);
621 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
622 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
623 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
625 tet_infoline("Test Stop action");
626 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
628 application.SendNotification();
629 application.Render(16);
631 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
632 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
633 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
635 tet_infoline("Test Stop action again");
636 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
638 application.SendNotification();
639 application.Render(16);
641 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
642 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
643 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
645 tet_infoline("Test Play action");
646 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
648 application.SendNotification();
649 application.Render(16);
651 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
652 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
653 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
655 tet_infoline("Off stage");
656 dummyControl.Unparent();
658 application.SendNotification();
659 application.Render(16);
661 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
662 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
663 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
665 tet_infoline("On stage again");
666 application.GetScene().Add(dummyControl);
668 application.SendNotification();
669 application.Render(16);
671 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
672 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
673 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
675 tet_infoline("Test Play action");
676 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
678 application.SendNotification();
679 application.Render(16);
681 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
682 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
683 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
686 Vector3 newSize(100.0f, 100.0f, 0.0f);
687 dummyControl.SetProperty(Actor::Property::SIZE, newSize);
689 application.SendNotification();
690 application.Render(16);
692 // Size should be changed
693 Vector3 naturalSize = dummyControl.GetNaturalSize();
694 DALI_TEST_CHECK(naturalSize == newSize);
696 dummyControl.Unparent();
702 int UtcDaliAnimatedVectorImageVisualCustomShader(void)
704 ToolkitTestApplication application;
705 tet_infoline("UtcDaliAnimatedVectorImageVisualCustomShader Test custom shader");
707 VisualFactory factory = VisualFactory::Get();
708 Property::Map properties;
709 Property::Map shader;
710 const std::string vertexShader = "Foobar";
711 const std::string fragmentShader = "Foobar sampler2D Foobar";
712 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
713 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
715 properties[Visual::Property::TYPE] = Visual::IMAGE;
716 properties[Visual::Property::SHADER] = shader;
717 properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
719 Visual::Base visual = factory.CreateVisual(properties);
721 // trigger creation through setting on stage
722 DummyControl dummy = DummyControl::New(true);
723 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
724 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
726 dummy.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
727 dummy.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
728 application.GetScene().Add(dummy);
730 application.SendNotification();
731 application.Render();
733 // Trigger count is 1 - render a frame
734 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
736 Renderer renderer = dummy.GetRendererAt(0);
737 Shader shader2 = renderer.GetShader();
738 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
739 Property::Map* map = value.GetMap();
740 DALI_TEST_CHECK(map);
742 std::string resultFragmentShader, resultVertexShader;
743 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
744 fragment->Get(resultFragmentShader);
745 DALI_TEST_CHECK(resultFragmentShader.find(fragmentShader) != std::string::npos);
747 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
748 vertex->Get(resultVertexShader);
749 DALI_TEST_CHECK(resultVertexShader.find(vertexShader) != std::string::npos);
754 int UtcDaliAnimatedVectorImageVisualNaturalSize(void)
756 ToolkitTestApplication application;
757 tet_infoline("UtcDaliAnimatedVectorImageVisualNaturalSize");
759 VisualFactory factory = VisualFactory::Get();
760 Visual::Base visual = factory.CreateVisual(
762 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
763 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
764 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
765 DALI_TEST_CHECK(visual);
767 DummyControl actor = DummyControl::New(true);
768 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
769 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
771 Vector2 controlSize(20.f, 30.f);
774 application.GetScene().Add(actor);
776 application.SendNotification();
777 application.Render();
779 // Trigger count is 1 - load
780 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
782 visual.GetNaturalSize(naturalSize);
784 DALI_TEST_EQUALS(naturalSize, Vector2(100.0f, 100.0f), TEST_LOCATION); // 100x100 is the content default size.
786 actor.SetProperty(Actor::Property::SIZE, controlSize);
788 application.SendNotification();
789 application.Render();
791 visual.GetNaturalSize(naturalSize);
793 DALI_TEST_EQUALS(naturalSize, controlSize, TEST_LOCATION);
798 int UtcDaliAnimatedVectorImageVisualLoopCount(void)
800 ToolkitTestApplication application;
801 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopCount");
803 Property::Map propertyMap;
804 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
805 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
806 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
807 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
809 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
810 DALI_TEST_CHECK(visual);
812 DummyControl actor = DummyControl::New(true);
813 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
814 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
816 Vector2 controlSize(20.f, 30.f);
817 actor.SetProperty(Actor::Property::SIZE, controlSize);
819 application.GetScene().Add(actor);
821 Property::Map attributes;
822 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
824 application.SendNotification();
825 application.Render();
827 // Trigger count is 2 - load & render a frame
828 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
830 // renderer is added to actor
831 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
832 Renderer renderer = actor.GetRendererAt(0u);
833 DALI_TEST_CHECK(renderer);
838 int UtcDaliAnimatedVectorImageVisualPlayRange(void)
840 ToolkitTestApplication application;
841 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRange");
843 int startFrame = 1, endFrame = 3;
844 Property::Array array;
845 array.PushBack(endFrame);
846 array.PushBack(startFrame);
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 // There might be 1 event triggered if start frame is not 0, and render frame spend long time.
876 // if ForceRenderOnce triggered before render complete, renderer count could be zero.
877 // Consume it if required.
878 if(actor.GetRendererCount() == 0)
880 tet_printf("Warning! render frame trigger not comes yet. Let we wait one more time.\n");
881 Test::WaitForEventThreadTrigger(1, 1);
884 // renderer is added to actor
885 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
886 Renderer renderer = actor.GetRendererAt(0u);
887 DALI_TEST_CHECK(renderer);
889 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
890 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
891 int totalFrameNumber = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER)->Get<int>();
893 int resultStartFrame, resultEndFrame;
894 Property::Array* result = value->GetArray();
895 result->GetElementAt(0).Get(resultStartFrame);
896 result->GetElementAt(1).Get(resultEndFrame);
898 DALI_TEST_EQUALS(startFrame, resultStartFrame, TEST_LOCATION);
899 DALI_TEST_EQUALS(endFrame, resultEndFrame, TEST_LOCATION);
901 // Set invalid play range
904 array.PushBack(totalFrameNumber + 100);
907 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
908 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
910 // To make event trigger
911 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
913 application.SendNotification();
914 application.Render();
916 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
918 // Should be clamped.
919 CheckAndRetryPlayRange(actor, 1, totalFrameNumber - 1, {{startFrame, endFrame}}, TEST_LOCATION);
921 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, Property::Map());
923 application.SendNotification();
924 application.Render();
926 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
928 application.SendNotification();
929 application.Render();
931 // Jump to action when paused, will make one or more event trigger
932 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
934 // Test whether current frame is 3.
935 CheckAndRetryCurrentFrame(actor, 3, {0, 1}, TEST_LOCATION);
942 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
943 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
945 // To make event trigger
946 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
948 application.SendNotification();
949 application.Render();
951 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
953 CheckAndRetryPlayRange(actor, 0, 2, {{1, totalFrameNumber - 1}}, TEST_LOCATION);
955 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
956 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
957 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION); // CURRENT_FRAME_NUMBER should be changed also.
962 int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void)
964 ToolkitTestApplication application;
965 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRangeMarker");
967 // Set 1 marker as array
968 Property::Array array;
969 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
971 Property::Map propertyMap;
972 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
973 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
974 .Add(DevelImageVisual::Property::PLAY_RANGE, array)
975 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
977 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
978 DALI_TEST_CHECK(visual);
980 DummyControl actor = DummyControl::New(true);
981 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
982 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
984 Vector2 controlSize(20.f, 30.f);
985 actor.SetProperty(Actor::Property::SIZE, controlSize);
987 application.GetScene().Add(actor);
989 Property::Map attributes;
990 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
992 application.SendNotification();
993 application.Render();
995 // Trigger count is 2 - load & render a frame
996 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
998 // There might be 1 event triggered if start frame is not 0, and render frame spend long time.
999 // if ForceRenderOnce triggered before render complete, renderer count could be zero.
1000 // Consume it if required.
1001 if(actor.GetRendererCount() == 0)
1003 tet_printf("Warning! render frame trigger not comes yet. Let we wait one more time.\n");
1004 Test::WaitForEventThreadTrigger(1, 1);
1007 // renderer is added to actor
1008 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1009 Renderer renderer = actor.GetRendererAt(0u);
1010 DALI_TEST_CHECK(renderer);
1012 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1013 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1015 int resultStartFrame, resultEndFrame;
1016 Property::Array* result = value->GetArray();
1017 result->GetElementAt(0).Get(resultStartFrame);
1018 result->GetElementAt(1).Get(resultEndFrame);
1020 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
1021 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
1023 // Set 1 marker as string
1027 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, VECTOR_ANIMATION_MARKER_NAME_1);
1028 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1030 // To make event trigger
1031 actor.SetProperty(Actor::Property::SIZE, Vector2(40.0f, 40.0f));
1033 application.SendNotification();
1034 application.Render();
1036 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1038 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1039 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1041 result = value->GetArray();
1042 result->GetElementAt(0).Get(resultStartFrame);
1043 result->GetElementAt(1).Get(resultEndFrame);
1045 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
1046 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
1050 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
1051 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_2);
1054 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1055 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1057 // To make event trigger
1058 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1060 application.SendNotification();
1061 application.Render();
1063 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1065 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1066 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1068 result = value->GetArray();
1069 result->GetElementAt(0).Get(resultStartFrame);
1070 result->GetElementAt(1).Get(resultEndFrame);
1072 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
1073 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
1075 // Set invalid play range
1078 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
1081 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1082 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1084 // To make event trigger
1085 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1087 application.SendNotification();
1088 application.Render();
1090 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1092 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1093 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1095 result = value->GetArray();
1096 result->GetElementAt(0).Get(resultStartFrame);
1097 result->GetElementAt(1).Get(resultEndFrame);
1099 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION); // Should not be changed
1100 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
1105 int UtcDaliAnimatedVectorImageVisualMarkerInfo(void)
1107 ToolkitTestApplication application;
1108 tet_infoline("UtcDaliAnimatedVectorImageVisualMarkerInfo");
1110 Property::Map propertyMap;
1111 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1112 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1113 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1115 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1116 DALI_TEST_CHECK(visual);
1118 DummyControl actor = DummyControl::New(true);
1119 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1120 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1122 Vector2 controlSize(20.f, 30.f);
1123 actor.SetProperty(Actor::Property::SIZE, controlSize);
1125 application.GetScene().Add(actor);
1127 Property::Map attributes;
1128 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1130 application.SendNotification();
1131 application.Render();
1133 // Trigger count is 2 - load & render a frame
1134 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1136 // renderer is added to actor
1137 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1138 Renderer renderer = actor.GetRendererAt(0u);
1139 DALI_TEST_CHECK(renderer);
1141 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1142 Property::Value* value = map.Find(DevelImageVisual::Property::MARKER_INFO);
1144 DALI_TEST_CHECK(value);
1146 Property::Map* result = value->GetMap();
1147 DALI_TEST_CHECK(result);
1149 std::string resultMarkerName;
1150 int resultStartFrame, resultEndFrame;
1151 DALI_TEST_EQUALS(2u, result->Count(), TEST_LOCATION);
1153 for(uint32_t i = 0u; i < result->Count(); ++i)
1155 if(result->GetKeyAt(i).stringKey == VECTOR_ANIMATION_MARKER_NAME_1)
1157 Property::Array* frameArray = result->GetValue(i).GetArray();
1158 DALI_TEST_CHECK(frameArray);
1159 frameArray->GetElementAt(0).Get(resultStartFrame);
1160 frameArray->GetElementAt(1).Get(resultEndFrame);
1162 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
1163 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
1165 else if(result->GetKeyAt(i).stringKey == VECTOR_ANIMATION_MARKER_NAME_2)
1167 Property::Array* frameArray = result->GetValue(i).GetArray();
1168 DALI_TEST_CHECK(frameArray);
1169 frameArray->GetElementAt(0).Get(resultStartFrame);
1170 frameArray->GetElementAt(1).Get(resultEndFrame);
1172 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_2, resultStartFrame, TEST_LOCATION);
1173 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
1177 DALI_TEST_CHECK(false);
1184 int UtcDaliAnimatedVectorImageVisualMarkerInfoFromInvalid(void)
1186 ToolkitTestApplication application;
1187 tet_infoline("UtcDaliAnimatedVectorImageVisualMarkerInfoFromInvalid");
1189 Property::Map propertyMap;
1190 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1191 .Add(ImageVisual::Property::URL, "invalid.json")
1192 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1194 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1195 DALI_TEST_CHECK(visual);
1197 DummyControl actor = DummyControl::New(true);
1198 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1199 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1201 Vector2 controlSize(20.f, 30.f);
1202 actor.SetProperty(Actor::Property::SIZE, controlSize);
1204 application.GetScene().Add(actor);
1206 Property::Map attributes;
1207 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1209 application.SendNotification();
1210 application.Render();
1212 // Trigger count is 1 - load, and failed.
1213 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1215 // renderer is added to actor
1216 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1217 Renderer renderer = actor.GetRendererAt(0u);
1218 DALI_TEST_CHECK(renderer);
1220 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1221 Property::Value* value = map.Find(DevelImageVisual::Property::MARKER_INFO);
1223 // The values when load failed case is invalid.
1224 DALI_TEST_CHECK(value == nullptr || (value->GetMap() == nullptr) || (value->GetMap()->Empty()));
1229 int UtcDaliAnimatedVectorImageVisualEnableFrameCache(void)
1231 ToolkitTestApplication application;
1232 tet_infoline("UtcDaliAnimatedVectorImageVisualEnableFrameCache");
1234 Property::Map propertyMap;
1235 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1236 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1237 .Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, true)
1238 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1240 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1241 DALI_TEST_CHECK(visual);
1243 DummyControl actor = DummyControl::New(true);
1244 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1245 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1246 application.GetScene().Add(actor);
1248 application.SendNotification();
1249 application.Render();
1251 // Trigger count is 1 - load
1252 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1254 Vector2 controlSize(200.f, 200.f);
1255 actor.SetProperty(Actor::Property::SIZE, controlSize);
1257 application.SendNotification();
1258 application.Render();
1260 // Trigger count is 1 - render a frame
1261 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1263 // renderer is added to actor
1264 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1265 Renderer renderer = actor.GetRendererAt(0u);
1266 DALI_TEST_CHECK(renderer);
1268 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1269 Property::Value* value = map.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE);
1270 DALI_TEST_CHECK(value->Get<bool>() == true);
1275 int UtcDaliAnimatedVectorImageVisualEnableFrameCacheFailed(void)
1277 ToolkitTestApplication application;
1278 tet_infoline("UtcDaliAnimatedVectorImageVisualEnableFrameCacheFailed");
1280 Property::Map propertyMap;
1281 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1282 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1283 .Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, true)
1284 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1286 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1287 DALI_TEST_CHECK(visual);
1289 DummyControl actor = DummyControl::New(true);
1290 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1291 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1293 Vector2 controlSize(200.f, 200.f);
1294 actor.SetProperty(Actor::Property::SIZE, controlSize);
1296 application.GetScene().Add(actor);
1297 application.SendNotification();
1298 application.Render();
1300 // Trigger count is 1 - load, and failed.
1301 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1303 // renderer is added to actor
1304 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1305 Renderer renderer = actor.GetRendererAt(0u);
1306 DALI_TEST_CHECK(renderer);
1308 propertyMap.Clear();
1309 propertyMap.Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, true)
1310 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1311 .Add(ImageVisual::Property::DESIRED_WIDTH, 100)
1312 .Add(ImageVisual::Property::DESIRED_HEIGHT, 100);
1313 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1315 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1316 Property::Value* value = map.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE);
1317 DALI_TEST_CHECK(value->Get<bool>() == true);
1322 int UtcDaliAnimatedVectorImageVisualNotifyAfterRasterization(void)
1324 ToolkitTestApplication application;
1325 tet_infoline("UtcDaliAnimatedVectorImageVisualNotifyAfterRasterization");
1327 Property::Map propertyMap;
1328 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1329 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1330 .Add(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, true)
1331 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1333 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1334 DALI_TEST_CHECK(visual);
1336 DummyControl actor = DummyControl::New(true);
1337 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1338 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1340 application.GetScene().Add(actor);
1342 application.SendNotification();
1343 application.Render();
1345 // Trigger count is 1 - load
1346 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1348 Vector2 controlSize(200.f, 200.f);
1349 actor.SetProperty(Actor::Property::SIZE, controlSize);
1351 application.SendNotification();
1352 application.Render();
1354 // Trigger count is 1 - render a frame
1355 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1358 Property::Map attributes;
1359 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1361 application.SendNotification();
1362 application.Render();
1364 // There might be 1 event triggered if render frame spend long time.
1365 // if ForceRenderOnce triggered before render complete, renderer count could be zero.
1366 // Consume it if required.
1367 if(actor.GetRendererCount() == 0)
1369 tet_printf("Warning! render frame trigger not comes yet. Let we wait one more time.\n");
1370 Test::WaitForEventThreadTrigger(1, 1);
1373 // renderer is added to actor
1374 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1375 Renderer renderer = actor.GetRendererAt(0u);
1376 DALI_TEST_CHECK(renderer);
1378 // Check renderer behavior
1379 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1381 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1382 Property::Value* value = map.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION);
1383 DALI_TEST_CHECK(value->Get<bool>() == true);
1385 propertyMap.Clear();
1386 propertyMap.Add(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, false);
1387 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1389 application.SendNotification();
1390 application.Render();
1392 // Check renderer behavior again
1393 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1395 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1396 value = map.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION);
1397 DALI_TEST_CHECK(value->Get<bool>() == false);
1399 propertyMap.Clear();
1400 propertyMap.Add(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, true);
1401 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1403 application.SendNotification();
1404 application.Render();
1406 // Check renderer behavior again
1407 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1409 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1410 value = map.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION);
1411 DALI_TEST_CHECK(value->Get<bool>() == true);
1416 int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
1418 ToolkitTestApplication application;
1419 tet_infoline("UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal");
1421 Property::Map propertyMap;
1422 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1423 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1425 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1426 DALI_TEST_CHECK(visual);
1428 DummyControl actor = DummyControl::New(true);
1429 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1430 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1432 DevelControl::VisualEventSignal(actor).Connect(&VisualEventSignal);
1434 Vector2 controlSize(20.f, 30.f);
1435 actor.SetProperty(Actor::Property::SIZE, controlSize);
1437 application.GetScene().Add(actor);
1439 application.SendNotification();
1440 application.Render();
1442 // Trigger count is 1 - render a frame
1443 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1445 propertyMap.Clear();
1446 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1447 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1449 Property::Map attributes;
1450 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1452 application.SendNotification();
1453 application.Render();
1455 // Wait for animation finish
1456 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1458 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1459 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
1460 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
1462 DALI_TEST_EQUALS(gAnimationFinishedSignalFired, true, TEST_LOCATION);
1467 int UtcDaliAnimatedVectorImageVisualJumpTo(void)
1469 ToolkitTestApplication application;
1470 tet_infoline("UtcDaliAnimatedVectorImageVisualJumpTo");
1472 Property::Map propertyMap;
1473 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1474 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1475 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1476 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1478 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1479 DALI_TEST_CHECK(visual);
1481 tet_printf("1. Visual is created.\n");
1483 DummyControl actor = DummyControl::New(true);
1484 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1485 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1487 Vector2 controlSize(20.f, 30.f);
1488 actor.SetProperty(Actor::Property::SIZE, controlSize);
1490 application.GetScene().Add(actor);
1492 application.SendNotification();
1493 application.Render();
1495 // Trigger count is 2 - load & render a frame
1496 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1498 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2);
1500 application.SendNotification();
1501 application.Render();
1503 // Trigger count is 1 - Jump to during stopped
1504 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1506 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1507 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1508 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1510 tet_printf("2. The current frame number is [%d].\n", value->Get<int>());
1512 Property::Array array;
1516 Property::Map attributes;
1517 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1518 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1520 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1522 // To make event trigger
1523 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1525 application.SendNotification();
1526 application.Render();
1528 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1530 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1531 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1532 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1534 tet_printf("3. The current frame number is [%d].\n", value->Get<int>());
1536 // Change play range
1543 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1544 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1547 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1549 application.SendNotification();
1550 application.Render();
1552 // Wait for animation finish
1553 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1554 // Note : AnimationFinished will occure force-render, and it might required another trigger. Test one more trigger now.
1555 Test::WaitForEventThreadTrigger(1, 1);
1558 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1560 application.SendNotification();
1561 application.Render();
1563 // Trigger count is 1 - Jump to during stopped.
1564 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1566 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1567 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1568 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1570 tet_printf("4. The current frame number is [%d].\n", value->Get<int>());
1572 // Jump to the same position
1573 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1575 // To make event trigger
1576 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1578 application.SendNotification();
1579 application.Render();
1581 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1583 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1584 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1585 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1587 tet_printf("5. The current frame number is [%d].\n", value->Get<int>());
1592 int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
1594 ToolkitTestApplication application;
1595 tet_infoline("UtcDaliAnimatedVectorImageVisualUpdateProperty");
1597 int startFrame = 1, endFrame = 3;
1598 Property::Array playRange;
1599 playRange.PushBack(startFrame);
1600 playRange.PushBack(endFrame);
1602 Property::Map propertyMap;
1603 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1604 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1605 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1606 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
1607 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1609 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1610 DALI_TEST_CHECK(visual);
1612 DummyControl actor = DummyControl::New(true);
1613 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1614 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1616 Vector2 controlSize(20.f, 30.f);
1617 actor.SetProperty(Actor::Property::SIZE, controlSize);
1619 application.GetScene().Add(actor);
1621 application.SendNotification();
1622 application.Render();
1624 // Trigger count is 2 - load & render a frame
1625 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1627 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1628 Property::Value* value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1629 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1631 value = map.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
1632 DALI_TEST_CHECK(value);
1634 Property::Array* result = value->GetArray();
1635 DALI_TEST_CHECK(result);
1637 DALI_TEST_EQUALS(result->GetElementAt(0).Get<int>(), startFrame, TEST_LOCATION);
1638 DALI_TEST_EQUALS(result->GetElementAt(1).Get<int>(), endFrame, TEST_LOCATION);
1641 playRange.PushBack(0);
1642 playRange.PushBack(2);
1644 Property::Map attributes;
1645 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1646 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 5);
1648 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1650 // To make event trigger
1651 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1653 application.SendNotification();
1654 application.Render();
1656 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1658 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1659 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1660 DALI_TEST_EQUALS(value->Get<int>(), 5, TEST_LOCATION);
1662 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1663 result = value->GetArray();
1664 DALI_TEST_CHECK(result);
1666 // Ensure that vector data sended well.
1667 CheckAndRetryPlayRange(actor, 0, 2, {{startFrame, endFrame}}, TEST_LOCATION);
1672 playRange.PushBack(startFrame);
1673 playRange.PushBack(endFrame);
1675 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1677 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1679 // To make event trigger
1680 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1682 application.SendNotification();
1683 application.Render();
1685 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1687 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1688 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1690 result = value->GetArray();
1691 DALI_TEST_CHECK(result);
1693 // Ensure that vector data sended well.
1694 CheckAndRetryPlayRange(actor, startFrame, endFrame, {{0, 2}}, TEST_LOCATION);
1696 // Play and update property
1698 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1700 application.SendNotification();
1701 application.Render();
1703 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 10);
1705 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1707 application.SendNotification();
1708 application.Render();
1710 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1711 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1712 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
1717 int UtcDaliAnimatedVectorImageVisualStopBehavior(void)
1719 ToolkitTestApplication application;
1720 tet_infoline("UtcDaliAnimatedVectorImageVisualStopBehavior");
1722 Property::Map propertyMap;
1723 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1724 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1725 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1727 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1728 DALI_TEST_CHECK(visual);
1730 DummyControl actor = DummyControl::New(true);
1731 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1732 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1734 Vector2 controlSize(20.f, 30.f);
1735 actor.SetProperty(Actor::Property::SIZE, controlSize);
1737 application.GetScene().Add(actor);
1739 application.SendNotification();
1740 application.Render();
1742 // Trigger count is 2 - load & render a frame
1743 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1745 propertyMap.Clear();
1746 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1747 propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
1748 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1750 Property::Map attributes;
1751 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1753 application.SendNotification();
1754 application.Render();
1756 // Trigger count is 1 - animation finished
1757 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1759 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1760 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1761 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1763 // Change stop behavior
1764 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1766 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1771 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1773 application.SendNotification();
1774 application.Render();
1776 // Trigger count is 1 - animation finished
1777 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1779 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1781 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1782 int totalFrameNumber = value1->Get<int>();
1784 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1785 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1787 // Change stop behavior
1788 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1789 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, -1);
1791 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1796 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1798 application.SendNotification();
1799 application.Render();
1802 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
1804 // To make event trigger
1805 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1807 application.SendNotification();
1808 application.Render();
1810 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1812 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1813 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1814 int currentFrameNumber = value->Get<int>();
1817 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
1819 // To make event trigger
1820 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1822 application.SendNotification();
1823 application.Render();
1825 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1827 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1828 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1829 DALI_TEST_EQUALS(value->Get<int>(), currentFrameNumber, TEST_LOCATION); // Should be same with currentFrameNumber
1834 int UtcDaliAnimatedVectorImageVisualLoopingMode(void)
1836 ToolkitTestApplication application;
1837 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopingMode");
1839 Property::Map propertyMap;
1840 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1841 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1842 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1844 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1845 DALI_TEST_CHECK(visual);
1847 DummyControl actor = DummyControl::New(true);
1848 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1849 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1851 Vector2 controlSize(20.f, 30.f);
1852 actor.SetProperty(Actor::Property::SIZE, controlSize);
1854 application.GetScene().Add(actor);
1856 application.SendNotification();
1857 application.Render();
1859 // Trigger count is 2 - load, render
1860 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1862 propertyMap.Clear();
1863 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1864 propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1865 propertyMap.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::AUTO_REVERSE);
1866 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1868 Property::Map attributes;
1869 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1871 application.SendNotification();
1872 application.Render();
1874 // Trigger count is 1 - animation finished
1875 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1877 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1878 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1879 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame because of auto reverse
1881 // Change stop behavior
1882 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1884 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1887 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1889 application.SendNotification();
1890 application.Render();
1892 // Trigger count is 1 - animation finished
1893 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1895 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1896 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1897 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1899 // Change looping mode
1900 attributes.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::RESTART);
1902 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1905 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1907 application.SendNotification();
1908 application.Render();
1910 // Trigger count is 1 - animation finished
1911 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1913 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1914 int totalFrameNumber = value1->Get<int>();
1916 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1917 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1918 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1923 int UtcDaliAnimatedVectorImageVisualPropertyNotification(void)
1925 ToolkitTestApplication application;
1926 tet_infoline("UtcDaliAnimatedVectorImageVisualPropertyNotification");
1928 Property::Map propertyMap;
1929 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1930 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1932 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1933 DALI_TEST_CHECK(visual);
1935 DummyControl actor = DummyControl::New(true);
1936 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1937 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1938 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1940 application.GetScene().Add(actor);
1942 application.SendNotification();
1943 application.Render();
1945 // Trigger count is 1 - render a frame
1946 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1948 Renderer renderer = actor.GetRendererAt(0u);
1949 DALI_TEST_CHECK(renderer);
1951 Vector2 controlSize(20.f, 30.f);
1952 actor.SetProperty(Actor::Property::SIZE, controlSize);
1954 application.SendNotification();
1955 application.Render();
1957 application.SendNotification();
1958 application.Render();
1960 // Trigger count is 1 - render a frame
1961 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1963 auto textureSet = renderer.GetTextures();
1964 auto texture = textureSet.GetTexture(0);
1966 DALI_TEST_EQUALS(controlSize.width, texture.GetWidth(), TEST_LOCATION);
1967 DALI_TEST_EQUALS(controlSize.height, texture.GetHeight(), TEST_LOCATION);
1970 Vector3 controlScale(2.0f, 2.0f, 1.0f);
1971 actor.SetProperty(Actor::Property::SCALE, controlScale);
1973 application.SendNotification();
1974 application.Render();
1976 application.SendNotification();
1977 application.Render();
1979 // Trigger count is 1 - render a frame
1980 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1982 renderer = actor.GetRendererAt(0u);
1983 DALI_TEST_CHECK(renderer);
1985 textureSet = renderer.GetTextures();
1986 texture = textureSet.GetTexture(0);
1988 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1989 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1992 controlSize = Vector2(50.0f, 100.0f);
1993 Animation animation = Animation::New(1.0);
1994 animation.AnimateTo(Property(actor, Actor::Property::SIZE), Vector3(controlSize.x, controlSize.y, 0.0f));
1997 application.SendNotification();
1998 application.Render(1100); // After the animation
2000 application.SendNotification();
2001 application.Render();
2003 // Trigger count is 1 - render a frame
2004 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2006 renderer = actor.GetRendererAt(0u);
2007 DALI_TEST_CHECK(renderer);
2009 textureSet = renderer.GetTextures();
2010 texture = textureSet.GetTexture(0);
2012 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
2013 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
2018 int UtcDaliAnimatedVectorImageVisualMultipleInstances(void)
2020 ToolkitTestApplication application;
2021 tet_infoline("UtcDaliAnimatedVectorImageVisualMultipleInstances");
2023 Property::Map propertyMap;
2024 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2025 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2026 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2028 Visual::Base visual1 = VisualFactory::Get().CreateVisual(propertyMap);
2029 DALI_TEST_CHECK(visual1);
2031 DummyControl actor1 = DummyControl::New(true);
2032 DummyControlImpl& dummyImpl1 = static_cast<DummyControlImpl&>(actor1.GetImplementation());
2033 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual1);
2035 Vector2 controlSize(20.f, 30.f);
2036 actor1.SetProperty(Actor::Property::SIZE, controlSize);
2038 application.GetScene().Add(actor1);
2040 application.SendNotification();
2041 application.Render();
2043 // Trigger count is 2 - load & render a frame
2044 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2046 propertyMap.Clear();
2047 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2048 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2049 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2051 Visual::Base visual2 = VisualFactory::Get().CreateVisual(propertyMap);
2052 DALI_TEST_CHECK(visual2);
2054 DummyControl actor2 = DummyControl::New(true);
2055 DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor2.GetImplementation());
2056 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
2058 actor2.SetProperty(Actor::Property::SIZE, controlSize);
2060 application.GetScene().Add(actor2);
2062 application.SendNotification();
2063 application.Render();
2065 // Trigger count is 2 - load & render a frame
2066 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2068 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
2070 // To make event trigger
2071 actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
2073 application.SendNotification();
2074 application.Render();
2076 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2078 Property::Map attributes;
2079 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
2081 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2082 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2084 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
2086 // renderer is added to actor
2087 DALI_TEST_CHECK(actor1.GetRendererCount() == 1u);
2088 Renderer renderer1 = actor1.GetRendererAt(0u);
2089 DALI_TEST_CHECK(renderer1);
2091 // renderer is added to actor
2092 DALI_TEST_CHECK(actor2.GetRendererCount() == 1u);
2093 Renderer renderer2 = actor2.GetRendererAt(0u);
2094 DALI_TEST_CHECK(renderer2);
2099 int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void)
2101 ToolkitTestApplication application;
2102 tet_infoline("UtcDaliAnimatedVectorImageVisualControlVisibilityChanged");
2104 Property::Map propertyMap;
2105 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2106 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2107 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2109 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
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 application.SendNotification();
2122 application.Render();
2124 // Trigger count is 2 - load & render a frame
2125 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2127 Property::Map attributes;
2128 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2130 application.SendNotification();
2131 application.Render();
2133 // Check rendering behavior
2134 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2135 Renderer renderer = actor.GetRendererAt(0u);
2136 DALI_TEST_CHECK(renderer);
2137 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
2139 actor.SetProperty(Actor::Property::VISIBLE, false);
2141 application.SendNotification();
2142 application.Render();
2144 // Check rendering behavior again
2145 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
2150 int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void)
2152 ToolkitTestApplication application;
2153 tet_infoline("UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged");
2155 Property::Map propertyMap;
2156 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2157 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
2159 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2160 DALI_TEST_CHECK(visual);
2162 DummyControl actor = DummyControl::New(true);
2163 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2164 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2166 Vector2 controlSize(20.f, 30.f);
2167 actor.SetProperty(Actor::Property::SIZE, controlSize);
2169 application.GetScene().Add(actor);
2171 application.SendNotification();
2172 application.Render();
2174 // Trigger count is 1 - render a frame
2175 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
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 // Check rendering behavior
2184 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2185 Renderer renderer = actor.GetRendererAt(0u);
2186 DALI_TEST_CHECK(renderer);
2187 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
2189 Window window = DevelWindow::Get(actor);
2192 application.SendNotification();
2193 application.Render();
2195 // Check rendering behavior again
2196 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
2201 int UtcDaliAnimatedVectorImageVisualInvalidFile01(void)
2203 ToolkitTestApplication application;
2204 tet_infoline("Request loading with invalid file - should draw broken image");
2206 TestGlAbstraction& gl = application.GetGlAbstraction();
2207 TraceCallStack& textureTrace = gl.GetTextureTrace();
2208 textureTrace.Enable(true);
2210 Property::Map propertyMap;
2211 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2212 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
2213 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2215 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2216 DALI_TEST_CHECK(visual);
2218 DummyControl actor = DummyControl::New(true);
2219 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2220 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2222 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
2224 application.GetScene().Add(actor);
2226 application.SendNotification();
2227 application.Render();
2229 // Trigger count is 1 - load
2230 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2232 application.SendNotification();
2233 application.Render();
2235 // Check resource status
2236 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2237 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2239 // The broken image should be shown.
2240 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2241 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2246 int UtcDaliAnimatedVectorImageVisualInvalidFile02(void)
2248 ToolkitTestApplication application;
2249 tet_infoline("Request loading with invalid file - should draw broken image");
2251 TestGlAbstraction& gl = application.GetGlAbstraction();
2252 TraceCallStack& textureTrace = gl.GetTextureTrace();
2253 textureTrace.Enable(true);
2255 Property::Map propertyMap;
2256 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2257 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
2259 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2260 DALI_TEST_CHECK(visual);
2262 DummyControl actor = DummyControl::New(true);
2263 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2264 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2266 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
2268 application.SendNotification();
2269 application.Render();
2271 // Add to the Scene after loading
2272 application.GetScene().Add(actor);
2274 application.SendNotification();
2275 application.Render();
2277 // Check resource status
2278 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2279 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2281 // The broken image should be shown.
2282 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2283 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2288 int UtcDaliAnimatedVectorImageVisualInvalidFile03(void)
2290 ToolkitTestApplication application;
2291 tet_infoline("Request loading with invalid file without size set - should draw broken image");
2293 TestGlAbstraction& gl = application.GetGlAbstraction();
2294 TraceCallStack& textureTrace = gl.GetTextureTrace();
2295 textureTrace.Enable(true);
2297 Property::Map propertyMap;
2298 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2299 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
2300 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2302 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2303 DALI_TEST_CHECK(visual);
2305 DummyControl actor = DummyControl::New(true);
2306 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2307 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2309 application.GetScene().Add(actor);
2311 application.SendNotification();
2312 application.Render();
2314 // Trigger count is 1 - load
2315 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2317 application.SendNotification();
2318 application.Render();
2320 // Check resource status
2321 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2322 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2324 // The broken image should be shown.
2325 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2326 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2331 int UtcDaliAnimatedVectorImageVisualFrameDrops(void)
2333 ToolkitTestApplication application;
2334 tet_infoline("UtcDaliAnimatedVectorImageVisualFrameDrops");
2336 Property::Map propertyMap;
2337 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2338 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP)
2339 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2341 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2342 DALI_TEST_CHECK(visual);
2344 DummyControl actor = DummyControl::New(true);
2345 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2346 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2348 Vector2 controlSize(20.f, 30.f);
2349 actor.SetProperty(Actor::Property::SIZE, controlSize);
2351 application.GetScene().Add(actor);
2353 application.SendNotification();
2354 application.Render();
2356 // Trigger count is 2 - load, render the first frame
2357 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2359 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2360 Property::Value* value = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
2361 int totalFrameNumber = value->Get<int>();
2363 Property::Map attributes;
2364 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2366 // Make delay to drop frames
2367 Test::VectorAnimationRenderer::DelayRendering(170); // longer than 16.6 * 10frames
2369 application.SendNotification();
2370 application.Render();
2372 // Trigger count is 1 - calculating frame drops
2373 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2375 // Check dropped frame
2376 uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames();
2377 DALI_TEST_CHECK(frames > 0);
2378 DALI_TEST_CHECK(frames <= static_cast<uint32_t>(totalFrameNumber));
2383 int UtcDaliAnimatedVectorImageVisualSize(void)
2385 ToolkitTestApplication application;
2386 tet_infoline("UtcDaliAnimatedVectorImageVisualSize");
2388 TestGlAbstraction& gl = application.GetGlAbstraction();
2389 TraceCallStack& textureTrace = gl.GetTextureTrace();
2391 VisualFactory factory = VisualFactory::Get();
2392 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
2393 DALI_TEST_CHECK(visual);
2395 DummyControl actor = DummyControl::New(true);
2396 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2397 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2399 application.GetScene().Add(actor);
2401 application.SendNotification();
2402 application.Render();
2404 // Trigger count is 1 - resource ready
2405 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2407 textureTrace.Enable(true);
2409 application.SendNotification();
2410 application.Render();
2413 int width = 100, height = 100; // 100x100 is the content default size.
2414 std::stringstream out;
2415 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
2416 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2419 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
2421 application.SendNotification();
2422 application.Render();
2424 // Trigger count is 1 - resource ready
2425 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2427 textureTrace.Reset();
2429 application.SendNotification();
2430 application.Render();
2433 int width = 200, height = 200;
2434 std::stringstream out;
2435 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
2436 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2444 bool gDynamicPropertyCallbackFired = false;
2446 Property::Value FillColorCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber)
2448 gDynamicPropertyCallbackFired = true;
2452 return Vector3(0, 0, 1);
2456 return Vector3(1, 0, 0);
2461 int UtcDaliAnimatedVectorImageVisualDynamicProperty(void)
2463 ToolkitTestApplication application;
2464 tet_infoline("UtcDaliAnimatedVectorImageVisualDynamicProperty");
2466 VisualFactory factory = VisualFactory::Get();
2467 Visual::Base visual = factory.CreateVisual(
2469 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2470 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2471 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
2472 DALI_TEST_CHECK(visual);
2474 DummyControl actor = DummyControl::New(true);
2475 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2476 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2478 Vector2 controlSize(20.f, 30.f);
2479 actor.SetProperty(Actor::Property::SIZE, controlSize);
2481 application.GetScene().Add(actor);
2483 gDynamicPropertyCallbackFired = false;
2485 // Set dynamic property
2486 DevelAnimatedVectorImageVisual::DynamicPropertyInfo info;
2488 info.keyPath = "Test.Path";
2489 info.property = static_cast<int>(VectorAnimationRenderer::VectorProperty::FILL_COLOR);
2490 info.callback = MakeCallback(FillColorCallback);
2492 DevelControl::DoActionExtension(actor, DummyControl::Property::TEST_VISUAL, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info));
2494 Property::Map attributes;
2495 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2497 application.SendNotification();
2498 application.Render();
2500 // Trigger count is 2 - load & render a frame
2501 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2503 // Test whether the property callback is called
2504 DALI_TEST_EQUALS(gDynamicPropertyCallbackFired, true, TEST_LOCATION);
2509 int UtcDaliAnimatedVectorImageVisualDesiredSize(void)
2511 ToolkitTestApplication application;
2512 tet_infoline("UtcDaliAnimatedVectorImageVisualDesiredSize");
2514 TestGlAbstraction& gl = application.GetGlAbstraction();
2515 TraceCallStack& textureTrace = gl.GetTextureTrace();
2516 int desiredWidth = 150, desiredHeight = 200;
2518 Visual::Base visual = VisualFactory::Get().CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
2519 DALI_TEST_CHECK(visual);
2521 DummyControl actor = DummyControl::New(true);
2522 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2523 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2525 application.GetScene().Add(actor);
2527 application.SendNotification();
2528 application.Render();
2530 // Trigger count is 1 - resource ready
2531 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2533 textureTrace.Enable(true);
2535 application.SendNotification();
2536 application.Render();
2539 std::stringstream out;
2540 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
2541 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2544 // Unparent to make next trigger
2547 application.SendNotification();
2548 application.Render();
2551 actor.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.0f));
2552 application.GetScene().Add(actor);
2554 application.SendNotification();
2555 application.Render();
2557 // Trigger count is 1 - resource ready
2558 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2560 textureTrace.Reset();
2562 application.SendNotification();
2563 application.Render();
2566 std::stringstream out;
2567 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
2568 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str())); // The size should not be changed
2574 int UtcDaliAnimatedVectorImageVisualFlushAction(void)
2576 ToolkitTestApplication application;
2578 tet_infoline("UtcDaliAnimatedVectorImageVisualFlushAction");
2583 int totalFrameCount = 0;
2585 Property::Array playRange;
2586 playRange.PushBack(startFrame);
2587 playRange.PushBack(endFrame);
2589 Property::Map resultMap;
2590 Property::Value* value = nullptr;
2592 // request AnimatedVectorImageVisual with a property map
2593 VisualFactory factory = VisualFactory::Get();
2594 Visual::Base visual = factory.CreateVisual(
2596 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2597 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2598 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
2599 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, true));
2601 DummyControl dummyControl = DummyControl::New(true);
2602 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
2603 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2604 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
2606 application.GetScene().Add(dummyControl);
2608 tet_printf("Pause lottie first.\n");
2610 Property::Map attributes;
2611 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
2613 application.SendNotification();
2614 application.Render(16);
2618 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2620 value = resultMap.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER, Property::INTEGER);
2621 DALI_TEST_CHECK(value);
2622 totalFrameCount = value->Get<int>();
2623 } while(totalFrameCount == 0);
2625 // Ensure that vector data sended well.
2626 CheckAndRetryPlayRange(dummyControl, startFrame, endFrame, {{0, 0}, {0, totalFrameCount - 1}}, TEST_LOCATION);
2628 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2630 value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
2631 DALI_TEST_CHECK(value);
2632 DALI_TEST_EQUALS(value->Get<int>(), startFrame, TEST_LOCATION);
2634 tet_printf("Now logically, range : [%d~%d], current : %d\n", startFrame, endFrame, startFrame);
2636 int changedStartFrame1 = startFrame + 2;
2637 int changedEndFrame1 = endFrame + 2;
2640 playRange.Add(changedStartFrame1);
2641 playRange.Add(changedEndFrame1);
2643 tet_printf("Change play range\n");
2644 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
2645 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2647 tet_printf("Jump to changedEndFrame!\n");
2648 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, changedEndFrame1);
2651 tet_infoline("Flush Action!");
2652 tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame1, changedEndFrame1, changedEndFrame1);
2653 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::FLUSH, attributes);
2655 int changedStartFrame2 = startFrame + 1;
2656 int changedEndFrame2 = endFrame + 1;
2659 playRange.Add(changedStartFrame2);
2660 playRange.Add(changedEndFrame2);
2662 tet_printf("Change play range again\n");
2663 tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame2, changedEndFrame2, changedEndFrame2);
2664 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
2665 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2667 application.SendNotification();
2668 application.Render(16);
2670 // Ensure that vector data sended well.
2671 CheckAndRetryPlayRange(dummyControl, changedStartFrame2, changedEndFrame2, {{changedStartFrame1, changedEndFrame1}, {startFrame, endFrame}}, TEST_LOCATION);
2673 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2675 tet_printf("Test whether current frame number changed well. If Flush not works, current frame become startFrame.");
2676 value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
2677 DALI_TEST_CHECK(value);
2678 DALI_TEST_EQUALS(value->Get<int>(), changedEndFrame2, TEST_LOCATION);
2680 dummyControl.Unparent();
2685 int UtcDaliAnimatedVectorImageNativeTextureChangeShader(void)
2687 ToolkitTestApplication application;
2688 tet_infoline("UtcDaliAnimatedVectorImageNativeTextureChangeShader");
2690 VisualFactory factory = VisualFactory::Get();
2691 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
2692 DALI_TEST_CHECK(visual);
2694 DummyControl actor = DummyControl::New(true);
2695 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2696 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2698 // Make we use native texture now.
2699 Test::VectorAnimationRenderer::UseNativeImageTexture(true);
2701 application.GetScene().Add(actor);
2703 application.SendNotification();
2704 application.Render();
2706 // Trigger count is 1 - resource ready
2707 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2709 application.SendNotification();
2710 application.Render();
2712 Renderer renderer = actor.GetRendererAt(0);
2713 Shader shader = renderer.GetShader();
2714 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
2715 Property::Map* map = value.GetMap();
2716 DALI_TEST_CHECK(map);
2718 std::string resultFragmentShader, resultVertexShader;
2719 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2720 fragment->Get(resultFragmentShader);
2721 DALI_TEST_CHECK(resultFragmentShader.find(NativeImageSourceTest::GetCustomFragmentPrefix()) != std::string::npos);
2723 // Reset to make we use normal texture again.
2724 Test::VectorAnimationRenderer::UseNativeImageTexture(false);