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;
74 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void)
76 ToolkitTestApplication application;
77 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual01: Request animated vector image visual with a json url");
79 VisualFactory factory = VisualFactory::Get();
80 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
81 DALI_TEST_CHECK(visual);
83 DummyControl actor = DummyControl::New(true);
84 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
85 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
86 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
87 application.GetScene().Add(actor);
89 application.SendNotification();
92 // Trigger count is 1 - render a frame
93 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
95 // renderer is added to actor
96 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
97 Renderer renderer = actor.GetRendererAt(0u);
98 DALI_TEST_CHECK(renderer);
100 // Test SetOffScene().
102 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
107 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual02(void)
109 ToolkitTestApplication application;
110 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual02: Request animated vector image visual with a Property::Map");
112 Property::Map propertyMap;
113 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
114 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
115 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
117 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
118 DALI_TEST_CHECK(visual);
120 DummyControl actor = DummyControl::New(true);
121 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
122 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
123 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
124 application.GetScene().Add(actor);
126 application.SendNotification();
127 application.Render();
129 // Trigger count is 2 - load & render a frame
130 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
132 // renderer is added to actor
133 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
134 Renderer renderer = actor.GetRendererAt(0u);
135 DALI_TEST_CHECK(renderer);
138 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
143 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void)
145 ToolkitTestApplication application;
146 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual03: Request animated vector image visual with a Property::Map");
148 int startFrame = 1, endFrame = 3;
149 Property::Array playRange;
150 playRange.PushBack(startFrame);
151 playRange.PushBack(endFrame);
153 Property::Map propertyMap;
154 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
155 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
156 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
157 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
158 .Add(DevelVisual::Property::CORNER_RADIUS, 50.0f)
159 .Add(DevelVisual::Property::BORDERLINE_WIDTH, 20.0f)
160 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
162 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
163 DALI_TEST_CHECK(visual);
165 DummyControl actor = DummyControl::New(true);
166 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
167 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
168 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
169 application.GetScene().Add(actor);
171 application.SendNotification();
172 application.Render();
174 // Trigger count is 2 - load & render a frame
175 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
177 // renderer is added to actor
178 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
179 Renderer renderer = actor.GetRendererAt(0u);
180 DALI_TEST_CHECK(renderer);
183 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
188 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void)
190 ToolkitTestApplication application;
191 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map");
193 int startFrame = 1, endFrame = 3;
194 int desiredWidth = 100, desiredHeight = 150;
195 float cornerRadius = 22.0f;
196 float borderlineWidth = 2.0f;
197 Vector4 borderlineColor = Vector4(1.0f, 1.0f, 1.0f, 1.0f);
198 float borderlineOffset = 0.1f;
199 Property::Array playRange;
200 playRange.PushBack(startFrame);
201 playRange.PushBack(endFrame);
203 Property::Map propertyMap;
204 propertyMap.Add("visualType", DevelVisual::ANIMATED_VECTOR_IMAGE)
205 .Add("url", TEST_VECTOR_IMAGE_FILE_NAME)
207 .Add("playRange", playRange)
208 .Add("stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME)
209 .Add("loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE)
210 .Add("redrawInScalingDown", false)
211 .Add("cornerRadius", cornerRadius)
212 .Add("borderlineWidth", borderlineWidth)
213 .Add("borderlineColor", borderlineColor)
214 .Add("borderlineOffset", borderlineOffset)
215 .Add("desiredWidth", desiredWidth)
216 .Add("desiredHeight", desiredHeight)
217 .Add("useFixedCache", false);
219 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
220 DALI_TEST_CHECK(visual);
222 DummyControl actor = DummyControl::New(true);
223 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
224 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
225 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
226 application.GetScene().Add(actor);
228 application.SendNotification();
229 application.Render();
231 // Trigger count is 1 - render a frame
232 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
234 // renderer is added to actor
235 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
237 Renderer renderer = actor.GetRendererAt(0u);
238 DALI_TEST_CHECK(renderer);
240 Property::Map resultMap;
241 visual.CreatePropertyMap(resultMap);
243 // check the property values from the returned map from a visual
244 Property::Value* value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
245 DALI_TEST_CHECK(value);
246 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
248 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
249 DALI_TEST_CHECK(value);
250 DALI_TEST_CHECK(value->Get<int>() == 3);
252 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
253 DALI_TEST_CHECK(value);
255 Property::Array* result = value->GetArray();
256 DALI_TEST_CHECK(result);
258 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
259 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
261 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
262 DALI_TEST_CHECK(value);
263 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::FIRST_FRAME);
265 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
266 DALI_TEST_CHECK(value);
267 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::AUTO_REVERSE);
269 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
270 DALI_TEST_CHECK(value);
271 DALI_TEST_CHECK(value->Get<bool>() == false);
273 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
274 DALI_TEST_CHECK(value);
275 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius), TEST_LOCATION);
277 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
278 DALI_TEST_CHECK(value);
279 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
281 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT);
282 DALI_TEST_CHECK(value);
283 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
285 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
286 DALI_TEST_CHECK(value);
287 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
289 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
290 DALI_TEST_CHECK(value);
291 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
293 value = resultMap.Find(ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER);
294 DALI_TEST_CHECK(value);
295 DALI_TEST_EQUALS(value->Get<int>(), desiredWidth, TEST_LOCATION);
297 value = resultMap.Find(ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER);
298 DALI_TEST_CHECK(value);
299 DALI_TEST_EQUALS(value->Get<int>(), desiredHeight, TEST_LOCATION);
302 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
307 int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
309 ToolkitTestApplication application;
310 tet_infoline("UtcDaliAnimatedVectorImageVisualGetPropertyMap01");
312 int startFrame = 1, endFrame = 3;
313 int desiredWidth = 100, desiredHeight = 150;
314 Vector4 cornerRadius(50.0f, 22.0f, 0.0f, 3.0f);
315 float borderlineWidth = 2.3f;
316 Vector4 borderlineColor = Vector4(0.3f, 0.3f, 1.0f, 1.0f);
317 float borderlineOffset = 0.3f;
318 Property::Array playRange;
319 playRange.PushBack(startFrame);
320 playRange.PushBack(endFrame);
322 Property::Map propertyMap;
323 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
324 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
325 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
326 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
327 .Add(DevelVisual::Property::CORNER_RADIUS, cornerRadius)
328 .Add(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::RELATIVE)
329 .Add(DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth)
330 .Add(DevelVisual::Property::BORDERLINE_COLOR, borderlineColor)
331 .Add(DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset)
332 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false)
333 .Add(ImageVisual::Property::DESIRED_WIDTH, desiredWidth)
334 .Add(ImageVisual::Property::DESIRED_HEIGHT, desiredHeight);
336 // request AnimatedVectorImageVisual with a property map
337 VisualFactory factory = VisualFactory::Get();
338 Visual::Base visual = factory.CreateVisual(propertyMap);
340 DummyControl actor = DummyControl::New(true);
341 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
342 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
344 Vector2 controlSize(20.f, 30.f);
345 actor.SetProperty(Actor::Property::SIZE, controlSize);
347 application.GetScene().Add(actor);
349 application.SendNotification();
350 application.Render();
352 // Trigger count is 2 - load & render a frame
353 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
355 Property::Map resultMap;
356 resultMap = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
358 // check the property values from the returned map from a visual
359 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
360 DALI_TEST_CHECK(value);
361 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
363 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
364 DALI_TEST_CHECK(value);
365 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
367 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
368 DALI_TEST_CHECK(value);
369 DALI_TEST_CHECK(value->Get<int>() == 3);
371 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
372 DALI_TEST_CHECK(value);
374 Property::Array* result = value->GetArray();
375 DALI_TEST_CHECK(result);
377 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
378 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
380 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
381 DALI_TEST_CHECK(value);
382 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::CURRENT_FRAME);
384 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
385 DALI_TEST_CHECK(value);
386 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::RESTART);
388 value = resultMap.Find(DevelImageVisual::Property::CONTENT_INFO, Property::MAP);
389 DALI_TEST_CHECK(value);
391 value = resultMap.Find(DevelImageVisual::Property::MARKER_INFO, Property::MAP);
392 DALI_TEST_CHECK(value);
394 value = resultMap.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE, Property::BOOLEAN);
395 DALI_TEST_CHECK(value);
396 DALI_TEST_CHECK(value->Get<bool>() == false); // Check default value
398 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
399 DALI_TEST_CHECK(value);
400 DALI_TEST_CHECK(value->Get<bool>() == true); // Check default value
402 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
403 DALI_TEST_CHECK(value);
404 DALI_TEST_EQUALS(value->Get<Vector4>(), cornerRadius, TEST_LOCATION);
406 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
407 DALI_TEST_CHECK(value);
408 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::RELATIVE);
410 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
411 DALI_TEST_CHECK(value);
412 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
414 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
415 DALI_TEST_CHECK(value);
416 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
418 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
419 DALI_TEST_CHECK(value);
420 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
422 value = resultMap.Find(ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER);
423 DALI_TEST_CHECK(value);
424 DALI_TEST_EQUALS(value->Get<int>(), desiredWidth, TEST_LOCATION);
426 value = resultMap.Find(ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER);
427 DALI_TEST_CHECK(value);
428 DALI_TEST_EQUALS(value->Get<int>(), desiredHeight, TEST_LOCATION);
430 // request AnimatedVectorImageVisual with an URL
431 Visual::Base visual2 = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
434 visual2.CreatePropertyMap(resultMap);
436 // check the property values from the returned map from a visual
437 value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
438 DALI_TEST_CHECK(value);
439 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
441 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
442 DALI_TEST_CHECK(value);
443 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
448 int UtcDaliAnimatedVectorImageVisualPlayback(void)
450 ToolkitTestApplication application;
452 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayback");
455 // request AnimatedVectorImageVisual with a property map
456 VisualFactory factory = VisualFactory::Get();
457 Visual::Base visual = factory.CreateVisual(
459 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
460 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
461 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
463 DummyControl dummyControl = DummyControl::New(true);
464 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
465 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
466 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
468 Property::Map attributes;
469 tet_infoline("Test Play action");
470 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
472 application.GetScene().Add(dummyControl);
473 application.SendNotification();
474 application.Render(16);
476 Property::Map map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
477 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
478 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
480 tet_infoline("Test Pause action");
481 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
483 application.SendNotification();
484 application.Render(16);
486 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
487 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
488 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PAUSED);
490 tet_infoline("Test Play action");
491 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
493 application.SendNotification();
494 application.Render(16);
496 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
497 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
498 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
500 tet_infoline("Test Stop action");
501 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
503 application.SendNotification();
504 application.Render(16);
506 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
507 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
508 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
510 tet_infoline("Test Stop action again");
511 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
513 application.SendNotification();
514 application.Render(16);
516 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
517 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
518 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
520 tet_infoline("Test Play action");
521 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
523 application.SendNotification();
524 application.Render(16);
526 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
527 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
528 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
530 tet_infoline("Off stage");
531 dummyControl.Unparent();
533 application.SendNotification();
534 application.Render(16);
536 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
537 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
538 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
540 tet_infoline("On stage again");
541 application.GetScene().Add(dummyControl);
543 application.SendNotification();
544 application.Render(16);
546 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
547 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
548 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
550 tet_infoline("Test Play action");
551 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
553 application.SendNotification();
554 application.Render(16);
556 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
557 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
558 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
561 Vector3 newSize(100.0f, 100.0f, 0.0f);
562 dummyControl.SetProperty(Actor::Property::SIZE, newSize);
564 application.SendNotification();
565 application.Render(16);
567 // Size should be changed
568 Vector3 naturalSize = dummyControl.GetNaturalSize();
569 DALI_TEST_CHECK(naturalSize == newSize);
571 dummyControl.Unparent();
577 int UtcDaliAnimatedVectorImageVisualCustomShader(void)
579 ToolkitTestApplication application;
580 tet_infoline("UtcDaliAnimatedVectorImageVisualCustomShader Test custom shader");
582 VisualFactory factory = VisualFactory::Get();
583 Property::Map properties;
584 Property::Map shader;
585 const std::string vertexShader = "Foobar";
586 const std::string fragmentShader = "Foobar sampler2D Foobar";
587 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
588 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
590 properties[Visual::Property::TYPE] = Visual::IMAGE;
591 properties[Visual::Property::SHADER] = shader;
592 properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
594 Visual::Base visual = factory.CreateVisual(properties);
596 // trigger creation through setting on stage
597 DummyControl dummy = DummyControl::New(true);
598 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
599 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
601 dummy.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
602 dummy.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
603 application.GetScene().Add(dummy);
605 application.SendNotification();
606 application.Render();
608 // Trigger count is 1 - render a frame
609 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
611 Renderer renderer = dummy.GetRendererAt(0);
612 Shader shader2 = renderer.GetShader();
613 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
614 Property::Map* map = value.GetMap();
615 DALI_TEST_CHECK(map);
617 std::string resultFragmentShader, resultVertexShader;
618 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
619 fragment->Get(resultFragmentShader);
620 DALI_TEST_CHECK(resultFragmentShader.find(fragmentShader) != std::string::npos);
622 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
623 vertex->Get(resultVertexShader);
624 DALI_TEST_CHECK(resultVertexShader.find(vertexShader) != std::string::npos);
629 int UtcDaliAnimatedVectorImageVisualNaturalSize(void)
631 ToolkitTestApplication application;
632 tet_infoline("UtcDaliAnimatedVectorImageVisualNaturalSize");
634 VisualFactory factory = VisualFactory::Get();
635 Visual::Base visual = factory.CreateVisual(
637 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
638 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
639 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
640 DALI_TEST_CHECK(visual);
642 DummyControl actor = DummyControl::New(true);
643 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
644 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
646 Vector2 controlSize(20.f, 30.f);
649 application.GetScene().Add(actor);
651 application.SendNotification();
652 application.Render();
654 // Trigger count is 1 - load
655 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
657 visual.GetNaturalSize(naturalSize);
659 DALI_TEST_EQUALS(naturalSize, Vector2(100.0f, 100.0f), TEST_LOCATION); // 100x100 is the content default size.
661 actor.SetProperty(Actor::Property::SIZE, controlSize);
663 application.SendNotification();
664 application.Render();
666 visual.GetNaturalSize(naturalSize);
668 DALI_TEST_EQUALS(naturalSize, controlSize, TEST_LOCATION);
673 int UtcDaliAnimatedVectorImageVisualLoopCount(void)
675 ToolkitTestApplication application;
676 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopCount");
678 Property::Map propertyMap;
679 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
680 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
681 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
682 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
684 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
685 DALI_TEST_CHECK(visual);
687 DummyControl actor = DummyControl::New(true);
688 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
689 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
691 Vector2 controlSize(20.f, 30.f);
692 actor.SetProperty(Actor::Property::SIZE, controlSize);
694 application.GetScene().Add(actor);
696 Property::Map attributes;
697 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
699 application.SendNotification();
700 application.Render();
702 // Trigger count is 2 - load & render a frame
703 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
705 // renderer is added to actor
706 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
707 Renderer renderer = actor.GetRendererAt(0u);
708 DALI_TEST_CHECK(renderer);
713 int UtcDaliAnimatedVectorImageVisualPlayRange(void)
715 ToolkitTestApplication application;
716 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRange");
718 int startFrame = 1, endFrame = 3;
719 Property::Array array;
720 array.PushBack(endFrame);
721 array.PushBack(startFrame);
723 Property::Map propertyMap;
724 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
725 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
726 .Add(DevelImageVisual::Property::PLAY_RANGE, array)
727 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
729 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
730 DALI_TEST_CHECK(visual);
732 DummyControl actor = DummyControl::New(true);
733 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
734 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
736 Vector2 controlSize(20.f, 30.f);
737 actor.SetProperty(Actor::Property::SIZE, controlSize);
739 application.GetScene().Add(actor);
741 Property::Map attributes;
742 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
744 application.SendNotification();
745 application.Render();
747 // Trigger count is 2 - load & render a frame
748 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
750 // renderer is added to actor
751 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
752 Renderer renderer = actor.GetRendererAt(0u);
753 DALI_TEST_CHECK(renderer);
755 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
756 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
757 int totalFrameNumber = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER)->Get<int>();
759 int resultStartFrame, resultEndFrame;
760 Property::Array* result = value->GetArray();
761 result->GetElementAt(0).Get(resultStartFrame);
762 result->GetElementAt(1).Get(resultEndFrame);
764 DALI_TEST_EQUALS(startFrame, resultStartFrame, TEST_LOCATION);
765 DALI_TEST_EQUALS(endFrame, resultEndFrame, TEST_LOCATION);
767 // Set invalid play range
773 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
774 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
776 // To make event trigger
777 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
779 application.SendNotification();
780 application.Render();
782 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
784 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
785 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
787 result = value->GetArray();
788 result->GetElementAt(0).Get(resultStartFrame);
789 result->GetElementAt(1).Get(resultEndFrame);
791 DALI_TEST_EQUALS(resultStartFrame, 1, TEST_LOCATION);
792 DALI_TEST_EQUALS(resultEndFrame, totalFrameNumber - 1, TEST_LOCATION); // Should be clamped
794 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, Property::Map());
796 application.SendNotification();
797 application.Render();
799 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
801 // To make event trigger
802 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
804 application.SendNotification();
805 application.Render();
807 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
809 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
810 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
811 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
818 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
819 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
821 // To make event trigger
822 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
824 application.SendNotification();
825 application.Render();
827 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
829 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
830 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
832 result = value->GetArray();
833 result->GetElementAt(0).Get(resultStartFrame);
834 result->GetElementAt(1).Get(resultEndFrame);
836 DALI_TEST_EQUALS(0, resultStartFrame, TEST_LOCATION);
837 DALI_TEST_EQUALS(2, resultEndFrame, TEST_LOCATION);
839 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
840 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION); // CURRENT_FRAME_NUMBER should be changed also.
845 int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void)
847 ToolkitTestApplication application;
848 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRangeMarker");
850 // Set 1 marker as array
851 Property::Array array;
852 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
854 Property::Map propertyMap;
855 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
856 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
857 .Add(DevelImageVisual::Property::PLAY_RANGE, array)
858 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
860 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
861 DALI_TEST_CHECK(visual);
863 DummyControl actor = DummyControl::New(true);
864 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
865 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
867 Vector2 controlSize(20.f, 30.f);
868 actor.SetProperty(Actor::Property::SIZE, controlSize);
870 application.GetScene().Add(actor);
872 Property::Map attributes;
873 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
875 application.SendNotification();
876 application.Render();
878 // Trigger count is 2 - load & render a frame
879 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
881 // renderer is added to actor
882 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
883 Renderer renderer = actor.GetRendererAt(0u);
884 DALI_TEST_CHECK(renderer);
886 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
887 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
889 int resultStartFrame, resultEndFrame;
890 Property::Array* result = value->GetArray();
891 result->GetElementAt(0).Get(resultStartFrame);
892 result->GetElementAt(1).Get(resultEndFrame);
894 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
895 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
897 // Set 1 marker as string
901 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, VECTOR_ANIMATION_MARKER_NAME_1);
902 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
904 // To make event trigger
905 actor.SetProperty(Actor::Property::SIZE, Vector2(40.0f, 40.0f));
907 application.SendNotification();
908 application.Render();
910 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
912 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
913 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
915 result = value->GetArray();
916 result->GetElementAt(0).Get(resultStartFrame);
917 result->GetElementAt(1).Get(resultEndFrame);
919 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
920 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
924 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
925 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_2);
928 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
929 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
931 // To make event trigger
932 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
934 application.SendNotification();
935 application.Render();
937 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
939 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
940 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
942 result = value->GetArray();
943 result->GetElementAt(0).Get(resultStartFrame);
944 result->GetElementAt(1).Get(resultEndFrame);
946 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
947 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
949 // Set invalid play range
952 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
955 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
956 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
958 // To make event trigger
959 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
961 application.SendNotification();
962 application.Render();
964 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
966 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
967 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
969 result = value->GetArray();
970 result->GetElementAt(0).Get(resultStartFrame);
971 result->GetElementAt(1).Get(resultEndFrame);
973 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION); // Should not be changed
974 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
979 int UtcDaliAnimatedVectorImageVisualMarkerInfo(void)
981 ToolkitTestApplication application;
982 tet_infoline("UtcDaliAnimatedVectorImageVisualMarkerInfo");
984 Property::Map propertyMap;
985 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
986 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
987 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
989 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
990 DALI_TEST_CHECK(visual);
992 DummyControl actor = DummyControl::New(true);
993 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
994 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
996 Vector2 controlSize(20.f, 30.f);
997 actor.SetProperty(Actor::Property::SIZE, controlSize);
999 application.GetScene().Add(actor);
1001 Property::Map attributes;
1002 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1004 application.SendNotification();
1005 application.Render();
1007 // Trigger count is 2 - load & render a frame
1008 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1010 // renderer is added to actor
1011 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1012 Renderer renderer = actor.GetRendererAt(0u);
1013 DALI_TEST_CHECK(renderer);
1015 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1016 Property::Value* value = map.Find(DevelImageVisual::Property::MARKER_INFO);
1018 DALI_TEST_CHECK(value);
1020 Property::Map* result = value->GetMap();
1021 DALI_TEST_CHECK(result);
1023 std::string resultMarkerName;
1024 int resultStartFrame, resultEndFrame;
1025 DALI_TEST_EQUALS(2u, result->Count(), TEST_LOCATION);
1027 for(uint32_t i = 0u; i < result->Count(); ++i)
1029 if(result->GetKeyAt(i).stringKey == VECTOR_ANIMATION_MARKER_NAME_1)
1031 Property::Array* frameArray = result->GetValue(i).GetArray();
1032 DALI_TEST_CHECK(frameArray);
1033 frameArray->GetElementAt(0).Get(resultStartFrame);
1034 frameArray->GetElementAt(1).Get(resultEndFrame);
1036 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
1037 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
1039 else if(result->GetKeyAt(i).stringKey == VECTOR_ANIMATION_MARKER_NAME_2)
1041 Property::Array* frameArray = result->GetValue(i).GetArray();
1042 DALI_TEST_CHECK(frameArray);
1043 frameArray->GetElementAt(0).Get(resultStartFrame);
1044 frameArray->GetElementAt(1).Get(resultEndFrame);
1046 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_2, resultStartFrame, TEST_LOCATION);
1047 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
1051 DALI_TEST_CHECK(false);
1058 int UtcDaliAnimatedVectorImageVisualMarkerInfoFromInvalid(void)
1060 ToolkitTestApplication application;
1061 tet_infoline("UtcDaliAnimatedVectorImageVisualMarkerInfoFromInvalid");
1063 Property::Map propertyMap;
1064 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1065 .Add(ImageVisual::Property::URL, "invalid.json")
1066 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1068 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1069 DALI_TEST_CHECK(visual);
1071 DummyControl actor = DummyControl::New(true);
1072 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1073 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1075 Vector2 controlSize(20.f, 30.f);
1076 actor.SetProperty(Actor::Property::SIZE, controlSize);
1078 application.GetScene().Add(actor);
1080 Property::Map attributes;
1081 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1083 application.SendNotification();
1084 application.Render();
1086 // Trigger count is 1 - load, and failed.
1087 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1089 // renderer is added to actor
1090 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1091 Renderer renderer = actor.GetRendererAt(0u);
1092 DALI_TEST_CHECK(renderer);
1094 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1095 Property::Value* value = map.Find(DevelImageVisual::Property::MARKER_INFO);
1097 // The values when load failed case is invalid.
1098 DALI_TEST_CHECK(value == nullptr || (value->GetMap() == nullptr) || (value->GetMap()->Empty()));
1103 int UtcDaliAnimatedVectorImageVisualUsedFixedCache(void)
1105 ToolkitTestApplication application;
1106 tet_infoline("UtcDaliAnimatedVectorImageVisualUsedFixedCache");
1108 Property::Map propertyMap;
1109 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1110 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1111 .Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, true)
1112 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1114 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1115 DALI_TEST_CHECK(visual);
1117 DummyControl actor = DummyControl::New(true);
1118 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1119 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1120 //actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1121 application.GetScene().Add(actor);
1123 application.SendNotification();
1124 application.Render();
1126 // Trigger count is 1 - render a frame
1127 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1129 Vector2 controlSize(200.f, 200.f);
1130 actor.SetProperty(Actor::Property::SIZE, controlSize);
1132 application.SendNotification();
1133 application.Render();
1135 // Trigger count is 1 - load
1136 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1138 // renderer is added to actor
1139 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1140 Renderer renderer = actor.GetRendererAt(0u);
1141 DALI_TEST_CHECK(renderer);
1143 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1144 Property::Value* value = map.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE);
1145 DALI_TEST_CHECK(value->Get<bool>() == true);
1150 int UtcDaliAnimatedVectorImageVisualUsedFixedCacheFailed(void)
1152 ToolkitTestApplication application;
1153 tet_infoline("UtcDaliAnimatedVectorImageVisualUsedFixedCacheFailed");
1155 Property::Map propertyMap;
1156 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1157 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1158 .Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, true)
1159 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1161 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1162 DALI_TEST_CHECK(visual);
1164 DummyControl actor = DummyControl::New(true);
1165 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1166 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1168 Vector2 controlSize(200.f, 200.f);
1169 actor.SetProperty(Actor::Property::SIZE, controlSize);
1171 application.GetScene().Add(actor);
1172 application.SendNotification();
1173 application.Render();
1175 // Trigger count is 1 - load, and failed.
1176 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1178 // renderer is added to actor
1179 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1180 Renderer renderer = actor.GetRendererAt(0u);
1181 DALI_TEST_CHECK(renderer);
1183 propertyMap.Clear();
1184 propertyMap.Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, true)
1185 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1186 .Add(ImageVisual::Property::DESIRED_WIDTH, 100)
1187 .Add(ImageVisual::Property::DESIRED_HEIGHT, 100);
1188 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1190 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1191 Property::Value* value = map.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE);
1192 DALI_TEST_CHECK(value->Get<bool>() == true);
1197 int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
1199 ToolkitTestApplication application;
1200 tet_infoline("UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal");
1202 Property::Map propertyMap;
1203 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1204 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1206 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1207 DALI_TEST_CHECK(visual);
1209 DummyControl actor = DummyControl::New(true);
1210 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1211 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1213 DevelControl::VisualEventSignal(actor).Connect(&VisualEventSignal);
1215 Vector2 controlSize(20.f, 30.f);
1216 actor.SetProperty(Actor::Property::SIZE, controlSize);
1218 application.GetScene().Add(actor);
1220 application.SendNotification();
1221 application.Render();
1223 // Trigger count is 1 - render a frame
1224 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1226 propertyMap.Clear();
1227 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1228 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1230 Property::Map attributes;
1231 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1233 application.SendNotification();
1234 application.Render();
1236 // Wait for animation finish
1237 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1239 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1240 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
1241 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
1243 DALI_TEST_EQUALS(gAnimationFinishedSignalFired, true, TEST_LOCATION);
1248 int UtcDaliAnimatedVectorImageVisualJumpTo(void)
1250 ToolkitTestApplication application;
1251 tet_infoline("UtcDaliAnimatedVectorImageVisualJumpTo");
1253 Property::Map propertyMap;
1254 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1255 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1256 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1257 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1259 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1260 DALI_TEST_CHECK(visual);
1262 tet_printf("1. Visual is created.\n");
1264 DummyControl actor = DummyControl::New(true);
1265 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1266 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1268 Vector2 controlSize(20.f, 30.f);
1269 actor.SetProperty(Actor::Property::SIZE, controlSize);
1271 application.GetScene().Add(actor);
1273 application.SendNotification();
1274 application.Render();
1276 // Trigger count is 2 - load & render a frame
1277 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1279 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2);
1281 // To make event trigger
1282 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1284 application.SendNotification();
1285 application.Render();
1287 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1289 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1290 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1291 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1293 tet_printf("2. The current frame number is [%d].\n", value->Get<int>());
1295 Property::Array array;
1299 Property::Map attributes;
1300 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1301 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1303 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1305 // To make event trigger
1306 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1308 application.SendNotification();
1309 application.Render();
1311 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1313 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1314 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1315 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1317 tet_printf("3. The current frame number is [%d].\n", value->Get<int>());
1319 // Change play range
1326 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1327 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1330 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1332 application.SendNotification();
1333 application.Render();
1335 // Wait for animation finish
1336 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1337 // EventThread will be triggered after animation finished (For render forcibly).
1338 // TODO : Is this logic will works well on server-side?
1339 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1342 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1344 // To make event trigger
1345 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1347 application.SendNotification();
1348 application.Render();
1350 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1352 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1353 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1354 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1356 tet_printf("4. The current frame number is [%d].\n", value->Get<int>());
1358 // Jump to the same position
1359 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1361 // To make event trigger
1362 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1364 application.SendNotification();
1365 application.Render();
1367 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1369 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1370 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1371 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1373 tet_printf("5. The current frame number is [%d].\n", value->Get<int>());
1378 int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
1380 ToolkitTestApplication application;
1381 tet_infoline("UtcDaliAnimatedVectorImageVisualUpdateProperty");
1383 int startFrame = 1, endFrame = 3;
1384 Property::Array playRange;
1385 playRange.PushBack(startFrame);
1386 playRange.PushBack(endFrame);
1388 Property::Map propertyMap;
1389 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1390 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1391 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1392 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
1393 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1395 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1396 DALI_TEST_CHECK(visual);
1398 DummyControl actor = DummyControl::New(true);
1399 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1400 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1402 Vector2 controlSize(20.f, 30.f);
1403 actor.SetProperty(Actor::Property::SIZE, controlSize);
1405 application.GetScene().Add(actor);
1407 application.SendNotification();
1408 application.Render();
1410 // Trigger count is 2 - load & render a frame
1411 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1413 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1414 Property::Value* value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1415 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1417 value = map.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
1418 DALI_TEST_CHECK(value);
1420 Property::Array* result = value->GetArray();
1421 DALI_TEST_CHECK(result);
1423 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1424 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1427 playRange.PushBack(0);
1428 playRange.PushBack(2);
1430 Property::Map attributes;
1431 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1432 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 5);
1434 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1436 // To make event trigger
1437 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1439 application.SendNotification();
1440 application.Render();
1442 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1444 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1445 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1446 DALI_TEST_EQUALS(value->Get<int>(), 5, TEST_LOCATION);
1448 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1449 result = value->GetArray();
1450 DALI_TEST_CHECK(result);
1452 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == 0);
1453 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == 2);
1458 playRange.PushBack(startFrame);
1459 playRange.PushBack(endFrame);
1461 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1463 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1465 // To make event trigger
1466 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1468 application.SendNotification();
1469 application.Render();
1471 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1473 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1474 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1476 result = value->GetArray();
1477 DALI_TEST_CHECK(result);
1479 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1480 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1482 // Play and update property
1484 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1486 application.SendNotification();
1487 application.Render();
1489 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 10);
1491 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1493 application.SendNotification();
1494 application.Render();
1496 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1497 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1498 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
1503 int UtcDaliAnimatedVectorImageVisualStopBehavior(void)
1505 ToolkitTestApplication application;
1506 tet_infoline("UtcDaliAnimatedVectorImageVisualStopBehavior");
1508 Property::Map propertyMap;
1509 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1510 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1511 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1513 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1514 DALI_TEST_CHECK(visual);
1516 DummyControl actor = DummyControl::New(true);
1517 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1518 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1520 Vector2 controlSize(20.f, 30.f);
1521 actor.SetProperty(Actor::Property::SIZE, controlSize);
1523 application.GetScene().Add(actor);
1525 application.SendNotification();
1526 application.Render();
1528 // Trigger count is 2 - load & render a frame
1529 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1531 propertyMap.Clear();
1532 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1533 propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
1534 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1536 Property::Map attributes;
1537 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1539 application.SendNotification();
1540 application.Render();
1542 // Trigger count is 1 - animation finished
1543 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1545 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1546 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1547 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1549 // Change stop behavior
1550 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1552 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1557 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1559 application.SendNotification();
1560 application.Render();
1562 // Trigger count is 1 - animation finished
1563 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1565 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1567 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1568 int totalFrameNumber = value1->Get<int>();
1570 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1571 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1573 // Change stop behavior
1574 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1575 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, -1);
1577 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1582 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1584 application.SendNotification();
1585 application.Render();
1588 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
1590 // To make event trigger
1591 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1593 application.SendNotification();
1594 application.Render();
1596 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1598 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1599 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1600 int currentFrameNumber = value->Get<int>();
1603 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
1605 // To make event trigger
1606 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1608 application.SendNotification();
1609 application.Render();
1611 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1613 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1614 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1615 DALI_TEST_EQUALS(value->Get<int>(), currentFrameNumber, TEST_LOCATION); // Should be same with currentFrameNumber
1620 int UtcDaliAnimatedVectorImageVisualLoopingMode(void)
1622 ToolkitTestApplication application;
1623 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopingMode");
1625 Property::Map propertyMap;
1626 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1627 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1628 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1630 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1631 DALI_TEST_CHECK(visual);
1633 DummyControl actor = DummyControl::New(true);
1634 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1635 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1637 Vector2 controlSize(20.f, 30.f);
1638 actor.SetProperty(Actor::Property::SIZE, controlSize);
1640 application.GetScene().Add(actor);
1642 application.SendNotification();
1643 application.Render();
1645 // Trigger count is 2 - load, render
1646 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1648 propertyMap.Clear();
1649 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1650 propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1651 propertyMap.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::AUTO_REVERSE);
1652 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1654 Property::Map attributes;
1655 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1657 application.SendNotification();
1658 application.Render();
1660 // Trigger count is 1 - animation finished
1661 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1663 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1664 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1665 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame because of auto reverse
1667 // Change stop behavior
1668 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1670 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1673 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1675 application.SendNotification();
1676 application.Render();
1678 // Trigger count is 1 - animation finished
1679 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1681 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1682 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1683 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1685 // Change looping mode
1686 attributes.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::RESTART);
1688 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1691 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1693 application.SendNotification();
1694 application.Render();
1696 // Trigger count is 1 - animation finished
1697 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1699 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1700 int totalFrameNumber = value1->Get<int>();
1702 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1703 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1704 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1709 int UtcDaliAnimatedVectorImageVisualPropertyNotification(void)
1711 ToolkitTestApplication application;
1712 tet_infoline("UtcDaliAnimatedVectorImageVisualPropertyNotification");
1714 Property::Map propertyMap;
1715 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1716 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1718 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1719 DALI_TEST_CHECK(visual);
1721 DummyControl actor = DummyControl::New(true);
1722 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1723 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1724 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1726 application.GetScene().Add(actor);
1728 application.SendNotification();
1729 application.Render();
1731 // Trigger count is 1 - render a frame
1732 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1734 Renderer renderer = actor.GetRendererAt(0u);
1735 DALI_TEST_CHECK(renderer);
1737 Vector2 controlSize(20.f, 30.f);
1738 actor.SetProperty(Actor::Property::SIZE, controlSize);
1740 application.SendNotification();
1741 application.Render();
1743 application.SendNotification();
1744 application.Render();
1746 // Trigger count is 1 - render a frame
1747 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1749 auto textureSet = renderer.GetTextures();
1750 auto texture = textureSet.GetTexture(0);
1752 DALI_TEST_EQUALS(controlSize.width, texture.GetWidth(), TEST_LOCATION);
1753 DALI_TEST_EQUALS(controlSize.height, texture.GetHeight(), TEST_LOCATION);
1756 Vector3 controlScale(2.0f, 2.0f, 1.0f);
1757 actor.SetProperty(Actor::Property::SCALE, controlScale);
1759 application.SendNotification();
1760 application.Render();
1762 application.SendNotification();
1763 application.Render();
1765 // Trigger count is 1 - render a frame
1766 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1768 renderer = actor.GetRendererAt(0u);
1769 DALI_TEST_CHECK(renderer);
1771 textureSet = renderer.GetTextures();
1772 texture = textureSet.GetTexture(0);
1774 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1775 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1778 controlSize = Vector2(50.0f, 100.0f);
1779 Animation animation = Animation::New(1.0);
1780 animation.AnimateTo(Property(actor, Actor::Property::SIZE), Vector3(controlSize.x, controlSize.y, 0.0f));
1783 application.SendNotification();
1784 application.Render(1100); // After the animation
1786 application.SendNotification();
1787 application.Render();
1789 // Trigger count is 1 - render a frame
1790 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1792 renderer = actor.GetRendererAt(0u);
1793 DALI_TEST_CHECK(renderer);
1795 textureSet = renderer.GetTextures();
1796 texture = textureSet.GetTexture(0);
1798 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1799 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1804 int UtcDaliAnimatedVectorImageVisualMultipleInstances(void)
1806 ToolkitTestApplication application;
1807 tet_infoline("UtcDaliAnimatedVectorImageVisualMultipleInstances");
1809 Property::Map propertyMap;
1810 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1811 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1812 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1814 Visual::Base visual1 = VisualFactory::Get().CreateVisual(propertyMap);
1815 DALI_TEST_CHECK(visual1);
1817 DummyControl actor1 = DummyControl::New(true);
1818 DummyControlImpl& dummyImpl1 = static_cast<DummyControlImpl&>(actor1.GetImplementation());
1819 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual1);
1821 Vector2 controlSize(20.f, 30.f);
1822 actor1.SetProperty(Actor::Property::SIZE, controlSize);
1824 application.GetScene().Add(actor1);
1826 application.SendNotification();
1827 application.Render();
1829 // Trigger count is 2 - load & render a frame
1830 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1832 propertyMap.Clear();
1833 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1834 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1835 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1837 Visual::Base visual2 = VisualFactory::Get().CreateVisual(propertyMap);
1838 DALI_TEST_CHECK(visual2);
1840 DummyControl actor2 = DummyControl::New(true);
1841 DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor2.GetImplementation());
1842 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
1844 actor2.SetProperty(Actor::Property::SIZE, controlSize);
1846 application.GetScene().Add(actor2);
1848 application.SendNotification();
1849 application.Render();
1851 // Trigger count is 2 - load & render a frame
1852 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1854 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1856 // To make event trigger
1857 actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1859 application.SendNotification();
1860 application.Render();
1862 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1864 Property::Map attributes;
1865 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1867 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1868 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1870 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1872 // renderer is added to actor
1873 DALI_TEST_CHECK(actor1.GetRendererCount() == 1u);
1874 Renderer renderer1 = actor1.GetRendererAt(0u);
1875 DALI_TEST_CHECK(renderer1);
1877 // renderer is added to actor
1878 DALI_TEST_CHECK(actor2.GetRendererCount() == 1u);
1879 Renderer renderer2 = actor2.GetRendererAt(0u);
1880 DALI_TEST_CHECK(renderer2);
1885 int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void)
1887 ToolkitTestApplication application;
1888 tet_infoline("UtcDaliAnimatedVectorImageVisualControlVisibilityChanged");
1890 Property::Map propertyMap;
1891 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1892 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1893 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1895 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1896 DALI_TEST_CHECK(visual);
1898 DummyControl actor = DummyControl::New(true);
1899 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1900 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1902 Vector2 controlSize(20.f, 30.f);
1903 actor.SetProperty(Actor::Property::SIZE, controlSize);
1905 application.GetScene().Add(actor);
1907 application.SendNotification();
1908 application.Render();
1910 // Trigger count is 2 - load & render a frame
1911 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1913 Property::Map attributes;
1914 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1916 application.SendNotification();
1917 application.Render();
1919 // Check rendering behavior
1920 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1921 Renderer renderer = actor.GetRendererAt(0u);
1922 DALI_TEST_CHECK(renderer);
1923 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1925 actor.SetProperty(Actor::Property::VISIBLE, false);
1927 application.SendNotification();
1928 application.Render();
1930 // Check rendering behavior again
1931 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1936 int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void)
1938 ToolkitTestApplication application;
1939 tet_infoline("UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged");
1941 Property::Map propertyMap;
1942 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1943 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1945 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1946 DALI_TEST_CHECK(visual);
1948 DummyControl actor = DummyControl::New(true);
1949 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1950 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1952 Vector2 controlSize(20.f, 30.f);
1953 actor.SetProperty(Actor::Property::SIZE, controlSize);
1955 application.GetScene().Add(actor);
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 Property::Map attributes;
1964 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1966 application.SendNotification();
1967 application.Render();
1969 // Check rendering behavior
1970 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1971 Renderer renderer = actor.GetRendererAt(0u);
1972 DALI_TEST_CHECK(renderer);
1973 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1975 Window window = DevelWindow::Get(actor);
1978 application.SendNotification();
1979 application.Render();
1981 // Check rendering behavior again
1982 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1987 int UtcDaliAnimatedVectorImageVisualInvalidFile01(void)
1989 ToolkitTestApplication application;
1990 tet_infoline("Request loading with invalid file - should draw broken image");
1992 TestGlAbstraction& gl = application.GetGlAbstraction();
1993 TraceCallStack& textureTrace = gl.GetTextureTrace();
1994 textureTrace.Enable(true);
1996 Property::Map propertyMap;
1997 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1998 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1999 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2001 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2002 DALI_TEST_CHECK(visual);
2004 DummyControl actor = DummyControl::New(true);
2005 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2006 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2008 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
2010 application.GetScene().Add(actor);
2012 application.SendNotification();
2013 application.Render();
2015 // Trigger count is 1 - load
2016 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2018 application.SendNotification();
2019 application.Render();
2021 // Check resource status
2022 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2023 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2025 // The broken image should be shown.
2026 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2027 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2032 int UtcDaliAnimatedVectorImageVisualInvalidFile02(void)
2034 ToolkitTestApplication application;
2035 tet_infoline("Request loading with invalid file - should draw broken image");
2037 TestGlAbstraction& gl = application.GetGlAbstraction();
2038 TraceCallStack& textureTrace = gl.GetTextureTrace();
2039 textureTrace.Enable(true);
2041 Property::Map propertyMap;
2042 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2043 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
2045 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2046 DALI_TEST_CHECK(visual);
2048 DummyControl actor = DummyControl::New(true);
2049 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2050 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2052 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
2054 application.SendNotification();
2055 application.Render();
2057 // Add to the Scene after loading
2058 application.GetScene().Add(actor);
2060 application.SendNotification();
2061 application.Render();
2063 // Check resource status
2064 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2065 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2067 // The broken image should be shown.
2068 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2069 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2074 int UtcDaliAnimatedVectorImageVisualInvalidFile03(void)
2076 ToolkitTestApplication application;
2077 tet_infoline("Request loading with invalid file without size set - should draw broken image");
2079 TestGlAbstraction& gl = application.GetGlAbstraction();
2080 TraceCallStack& textureTrace = gl.GetTextureTrace();
2081 textureTrace.Enable(true);
2083 Property::Map propertyMap;
2084 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2085 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
2086 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2088 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2089 DALI_TEST_CHECK(visual);
2091 DummyControl actor = DummyControl::New(true);
2092 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2093 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2095 application.GetScene().Add(actor);
2097 application.SendNotification();
2098 application.Render();
2100 // Trigger count is 1 - load
2101 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2103 application.SendNotification();
2104 application.Render();
2106 // Check resource status
2107 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2108 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2110 // The broken image should be shown.
2111 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2112 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2117 int UtcDaliAnimatedVectorImageVisualFrameDrops(void)
2119 ToolkitTestApplication application;
2120 tet_infoline("UtcDaliAnimatedVectorImageVisualFrameDrops");
2122 Property::Map propertyMap;
2123 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2124 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP)
2125 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2127 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2128 DALI_TEST_CHECK(visual);
2130 DummyControl actor = DummyControl::New(true);
2131 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2132 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2134 Vector2 controlSize(20.f, 30.f);
2135 actor.SetProperty(Actor::Property::SIZE, controlSize);
2137 application.GetScene().Add(actor);
2139 application.SendNotification();
2140 application.Render();
2142 // Trigger count is 2 - load, render the first frame
2143 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2145 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2146 Property::Value* value = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
2147 int totalFrameNumber = value->Get<int>();
2149 Property::Map attributes;
2150 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2152 // Make delay to drop frames
2153 Test::VectorAnimationRenderer::DelayRendering(170); // longer than 16.6 * 10frames
2155 application.SendNotification();
2156 application.Render();
2158 // Trigger count is 1 - calculating frame drops
2159 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2161 // Check dropped frame
2162 uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames();
2163 DALI_TEST_CHECK(frames > 0);
2164 DALI_TEST_CHECK(frames <= static_cast<uint32_t>(totalFrameNumber));
2169 int UtcDaliAnimatedVectorImageVisualSize(void)
2171 ToolkitTestApplication application;
2172 tet_infoline("UtcDaliAnimatedVectorImageVisualSize");
2174 TestGlAbstraction& gl = application.GetGlAbstraction();
2175 TraceCallStack& textureTrace = gl.GetTextureTrace();
2177 VisualFactory factory = VisualFactory::Get();
2178 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
2179 DALI_TEST_CHECK(visual);
2181 DummyControl actor = DummyControl::New(true);
2182 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2183 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2185 application.GetScene().Add(actor);
2187 application.SendNotification();
2188 application.Render();
2190 // Trigger count is 1 - resource ready
2191 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2193 textureTrace.Enable(true);
2195 application.SendNotification();
2196 application.Render();
2199 int width = 100, height = 100; // 100x100 is the content default size.
2200 std::stringstream out;
2201 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
2202 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2205 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
2207 application.SendNotification();
2208 application.Render();
2210 // Trigger count is 1 - resource ready
2211 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2213 textureTrace.Reset();
2215 application.SendNotification();
2216 application.Render();
2219 int width = 200, height = 200;
2220 std::stringstream out;
2221 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
2222 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2230 bool gDynamicPropertyCallbackFired = false;
2232 Property::Value FillColorCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber)
2234 gDynamicPropertyCallbackFired = true;
2238 return Vector3(0, 0, 1);
2242 return Vector3(1, 0, 0);
2247 int UtcDaliAnimatedVectorImageVisualDynamicProperty(void)
2249 ToolkitTestApplication application;
2250 tet_infoline("UtcDaliAnimatedVectorImageVisualDynamicProperty");
2252 VisualFactory factory = VisualFactory::Get();
2253 Visual::Base visual = factory.CreateVisual(
2255 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2256 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2257 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
2258 DALI_TEST_CHECK(visual);
2260 DummyControl actor = DummyControl::New(true);
2261 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2262 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2264 Vector2 controlSize(20.f, 30.f);
2265 actor.SetProperty(Actor::Property::SIZE, controlSize);
2267 application.GetScene().Add(actor);
2269 gDynamicPropertyCallbackFired = false;
2271 // Set dynamic property
2272 DevelAnimatedVectorImageVisual::DynamicPropertyInfo info;
2274 info.keyPath = "Test.Path";
2275 info.property = static_cast<int>(VectorAnimationRenderer::VectorProperty::FILL_COLOR);
2276 info.callback = MakeCallback(FillColorCallback);
2278 DevelControl::DoActionExtension(actor, DummyControl::Property::TEST_VISUAL, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info));
2280 Property::Map attributes;
2281 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2283 application.SendNotification();
2284 application.Render();
2286 // Trigger count is 2 - load & render a frame
2287 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2289 // Test whether the property callback is called
2290 DALI_TEST_EQUALS(gDynamicPropertyCallbackFired, true, TEST_LOCATION);
2295 int UtcDaliAnimatedVectorImageVisualDesiredSize(void)
2297 ToolkitTestApplication application;
2298 tet_infoline("UtcDaliAnimatedVectorImageVisualDesiredSize");
2300 TestGlAbstraction& gl = application.GetGlAbstraction();
2301 TraceCallStack& textureTrace = gl.GetTextureTrace();
2302 int desiredWidth = 150, desiredHeight = 200;
2304 Visual::Base visual = VisualFactory::Get().CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
2305 DALI_TEST_CHECK(visual);
2307 DummyControl actor = DummyControl::New(true);
2308 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2309 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2311 application.GetScene().Add(actor);
2313 application.SendNotification();
2314 application.Render();
2316 // Trigger count is 1 - resource ready
2317 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2319 textureTrace.Enable(true);
2321 application.SendNotification();
2322 application.Render();
2325 std::stringstream out;
2326 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
2327 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2330 // Unparent to make next trigger
2333 application.SendNotification();
2334 application.Render();
2337 actor.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.0f));
2338 application.GetScene().Add(actor);
2340 application.SendNotification();
2341 application.Render();
2343 // Trigger count is 1 - resource ready
2344 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2346 textureTrace.Reset();
2348 application.SendNotification();
2349 application.Render();
2352 std::stringstream out;
2353 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
2354 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str())); // The size should not be changed
2360 int UtcDaliAnimatedVectorImageVisualFlushAction(void)
2362 ToolkitTestApplication application;
2364 tet_infoline("UtcDaliAnimatedVectorImageVisualFlushAction");
2369 int totalFrameCount = 0;
2371 Property::Array playRange;
2372 playRange.PushBack(startFrame);
2373 playRange.PushBack(endFrame);
2375 Property::Map resultMap;
2376 Property::Value* value = nullptr;
2378 // request AnimatedVectorImageVisual with a property map
2379 VisualFactory factory = VisualFactory::Get();
2380 Visual::Base visual = factory.CreateVisual(
2382 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2383 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2384 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
2385 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, true));
2387 DummyControl dummyControl = DummyControl::New(true);
2388 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
2389 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2390 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
2392 application.GetScene().Add(dummyControl);
2394 // Retry function to get playrange until expect values comes.
2395 auto CheckAndRetryPlayRange = [&](int expectStartFrame, int expectEndFrame, std::vector<std::pair<int, int>> retrialFrames) {
2397 int tryCountMax = 30;
2398 while(++tryCount <= tryCountMax)
2400 Property::Map resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2402 Property::Value* value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
2403 DALI_TEST_CHECK(value);
2405 Property::Array* result = value->GetArray();
2406 DALI_TEST_CHECK(result);
2407 DALI_TEST_EQUALS(result->Count(), 2, TEST_LOCATION);
2409 bool tryAgain = false;
2410 for(auto& framePair : retrialFrames)
2412 if(result->GetElementAt(0).Get<int>() == framePair.first && result->GetElementAt(1).Get<int>() == framePair.second)
2420 tet_printf("Retry to get value again! [%d]\n", tryCount);
2421 // Dummy sleep 1 second.
2422 Test::WaitForEventThreadTrigger(1, 1);
2426 DALI_TEST_EQUALS(result->GetElementAt(0).Get<int>(), expectStartFrame, TEST_LOCATION);
2427 DALI_TEST_EQUALS(result->GetElementAt(1).Get<int>(), expectEndFrame, TEST_LOCATION);
2430 DALI_TEST_CHECK(tryCount <= tryCountMax);
2433 tet_printf("Pause lottie first.\n");
2435 Property::Map attributes;
2436 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
2438 application.SendNotification();
2439 application.Render(16);
2443 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2445 value = resultMap.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER, Property::INTEGER);
2446 DALI_TEST_CHECK(value);
2447 totalFrameCount = value->Get<int>();
2448 } while(totalFrameCount == 0);
2450 // Ensure that vector data sended well.
2451 CheckAndRetryPlayRange(startFrame, endFrame, {{0, 0}, {0, totalFrameCount - 1}});
2453 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2455 value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
2456 DALI_TEST_CHECK(value);
2457 DALI_TEST_EQUALS(value->Get<int>(), startFrame, TEST_LOCATION);
2459 tet_printf("Now logically, range : [%d~%d], current : %d\n", startFrame, endFrame, startFrame);
2461 int changedStartFrame1 = startFrame + 2;
2462 int changedEndFrame1 = endFrame + 2;
2465 playRange.Add(changedStartFrame1);
2466 playRange.Add(changedEndFrame1);
2468 tet_printf("Change play range\n");
2469 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
2470 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2472 tet_printf("Jump to changedEndFrame!\n");
2473 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, changedEndFrame1);
2476 tet_infoline("Flush Action!");
2477 tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame1, changedEndFrame1, changedEndFrame1);
2478 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::FLUSH, attributes);
2480 int changedStartFrame2 = startFrame + 1;
2481 int changedEndFrame2 = endFrame + 1;
2484 playRange.Add(changedStartFrame2);
2485 playRange.Add(changedEndFrame2);
2487 tet_printf("Change play range again\n");
2488 tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame2, changedEndFrame2, changedEndFrame2);
2489 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
2490 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2492 application.SendNotification();
2493 application.Render(16);
2495 // Ensure that vector data sended well.
2496 CheckAndRetryPlayRange(changedStartFrame2, changedEndFrame2, {{changedStartFrame1, changedEndFrame1}, {startFrame, endFrame}});
2498 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2500 tet_printf("Test whether current frame number changed well. If Flush not works, current frame become startFrame.");
2501 value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
2502 DALI_TEST_CHECK(value);
2503 DALI_TEST_EQUALS(value->Get<int>(), changedEndFrame2, TEST_LOCATION);
2505 dummyControl.Unparent();
2510 int UtcDaliAnimatedVectorImageNativeTextureChangeShader(void)
2512 ToolkitTestApplication application;
2513 tet_infoline("UtcDaliAnimatedVectorImageNativeTextureChangeShader");
2515 VisualFactory factory = VisualFactory::Get();
2516 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
2517 DALI_TEST_CHECK(visual);
2519 DummyControl actor = DummyControl::New(true);
2520 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2521 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2523 // Make we use native texture now.
2524 Test::VectorAnimationRenderer::UseNativeImageTexture(true);
2526 application.GetScene().Add(actor);
2528 application.SendNotification();
2529 application.Render();
2531 // Trigger count is 1 - resource ready
2532 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2534 application.SendNotification();
2535 application.Render();
2537 Renderer renderer = actor.GetRendererAt(0);
2538 Shader shader = renderer.GetShader();
2539 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
2540 Property::Map* map = value.GetMap();
2541 DALI_TEST_CHECK(map);
2543 std::string resultFragmentShader, resultVertexShader;
2544 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2545 fragment->Get(resultFragmentShader);
2546 DALI_TEST_CHECK(resultFragmentShader.find(NativeImageSourceTest::GetCustomFragmentPrefix()) != std::string::npos);
2548 // Reset to make we use normal texture again.
2549 Test::VectorAnimationRenderer::UseNativeImageTexture(false);