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);
1339 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1341 // To make event trigger
1342 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1344 application.SendNotification();
1345 application.Render();
1347 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1349 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1350 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1351 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1353 tet_printf("4. The current frame number is [%d].\n", value->Get<int>());
1355 // Jump to the same position
1356 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1358 // To make event trigger
1359 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1361 application.SendNotification();
1362 application.Render();
1364 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1366 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1367 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1368 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1370 tet_printf("5. The current frame number is [%d].\n", value->Get<int>());
1375 int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
1377 ToolkitTestApplication application;
1378 tet_infoline("UtcDaliAnimatedVectorImageVisualUpdateProperty");
1380 int startFrame = 1, endFrame = 3;
1381 Property::Array playRange;
1382 playRange.PushBack(startFrame);
1383 playRange.PushBack(endFrame);
1385 Property::Map propertyMap;
1386 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1387 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1388 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1389 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
1390 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1392 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1393 DALI_TEST_CHECK(visual);
1395 DummyControl actor = DummyControl::New(true);
1396 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1397 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1399 Vector2 controlSize(20.f, 30.f);
1400 actor.SetProperty(Actor::Property::SIZE, controlSize);
1402 application.GetScene().Add(actor);
1404 application.SendNotification();
1405 application.Render();
1407 // Trigger count is 2 - load & render a frame
1408 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1410 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1411 Property::Value* value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1412 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1414 value = map.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
1415 DALI_TEST_CHECK(value);
1417 Property::Array* result = value->GetArray();
1418 DALI_TEST_CHECK(result);
1420 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1421 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1424 playRange.PushBack(0);
1425 playRange.PushBack(2);
1427 Property::Map attributes;
1428 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1429 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 5);
1431 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1433 // To make event trigger
1434 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1436 application.SendNotification();
1437 application.Render();
1439 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1441 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1442 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1443 DALI_TEST_EQUALS(value->Get<int>(), 5, TEST_LOCATION);
1445 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1446 result = value->GetArray();
1447 DALI_TEST_CHECK(result);
1449 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == 0);
1450 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == 2);
1455 playRange.PushBack(startFrame);
1456 playRange.PushBack(endFrame);
1458 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1460 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1462 // To make event trigger
1463 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1465 application.SendNotification();
1466 application.Render();
1468 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1470 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1471 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1473 result = value->GetArray();
1474 DALI_TEST_CHECK(result);
1476 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1477 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1479 // Play and update property
1481 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1483 application.SendNotification();
1484 application.Render();
1486 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 10);
1488 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1490 application.SendNotification();
1491 application.Render();
1493 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1494 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1495 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
1500 int UtcDaliAnimatedVectorImageVisualStopBehavior(void)
1502 ToolkitTestApplication application;
1503 tet_infoline("UtcDaliAnimatedVectorImageVisualStopBehavior");
1505 Property::Map propertyMap;
1506 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1507 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1508 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1510 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1511 DALI_TEST_CHECK(visual);
1513 DummyControl actor = DummyControl::New(true);
1514 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1515 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1517 Vector2 controlSize(20.f, 30.f);
1518 actor.SetProperty(Actor::Property::SIZE, controlSize);
1520 application.GetScene().Add(actor);
1522 application.SendNotification();
1523 application.Render();
1525 // Trigger count is 2 - load & render a frame
1526 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1528 propertyMap.Clear();
1529 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1530 propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
1531 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1533 Property::Map attributes;
1534 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1536 application.SendNotification();
1537 application.Render();
1539 // Trigger count is 1 - animation finished
1540 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1542 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1543 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1544 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1546 // Change stop behavior
1547 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1549 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1554 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1556 application.SendNotification();
1557 application.Render();
1559 // Trigger count is 1 - animation finished
1560 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1562 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1564 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1565 int totalFrameNumber = value1->Get<int>();
1567 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1568 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1570 // Change stop behavior
1571 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1572 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, -1);
1574 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1579 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1581 application.SendNotification();
1582 application.Render();
1585 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
1587 // To make event trigger
1588 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1590 application.SendNotification();
1591 application.Render();
1593 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1595 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1596 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1597 int currentFrameNumber = value->Get<int>();
1600 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
1602 // To make event trigger
1603 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1605 application.SendNotification();
1606 application.Render();
1608 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1610 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1611 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1612 DALI_TEST_EQUALS(value->Get<int>(), currentFrameNumber, TEST_LOCATION); // Should be same with currentFrameNumber
1617 int UtcDaliAnimatedVectorImageVisualLoopingMode(void)
1619 ToolkitTestApplication application;
1620 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopingMode");
1622 Property::Map propertyMap;
1623 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1624 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1625 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1627 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1628 DALI_TEST_CHECK(visual);
1630 DummyControl actor = DummyControl::New(true);
1631 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1632 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1634 Vector2 controlSize(20.f, 30.f);
1635 actor.SetProperty(Actor::Property::SIZE, controlSize);
1637 application.GetScene().Add(actor);
1639 application.SendNotification();
1640 application.Render();
1642 // Trigger count is 2 - load, render
1643 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1645 propertyMap.Clear();
1646 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1647 propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1648 propertyMap.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::AUTO_REVERSE);
1649 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1651 Property::Map attributes;
1652 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1654 application.SendNotification();
1655 application.Render();
1657 // Trigger count is 1 - animation finished
1658 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1660 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1661 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1662 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame because of auto reverse
1664 // Change stop behavior
1665 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1667 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1670 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1672 application.SendNotification();
1673 application.Render();
1675 // Trigger count is 1 - animation finished
1676 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1678 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1679 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1680 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1682 // Change looping mode
1683 attributes.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::RESTART);
1685 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1688 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1690 application.SendNotification();
1691 application.Render();
1693 // Trigger count is 1 - animation finished
1694 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1696 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1697 int totalFrameNumber = value1->Get<int>();
1699 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1700 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1701 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1706 int UtcDaliAnimatedVectorImageVisualPropertyNotification(void)
1708 ToolkitTestApplication application;
1709 tet_infoline("UtcDaliAnimatedVectorImageVisualPropertyNotification");
1711 Property::Map propertyMap;
1712 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1713 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1715 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1716 DALI_TEST_CHECK(visual);
1718 DummyControl actor = DummyControl::New(true);
1719 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1720 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1721 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1723 application.GetScene().Add(actor);
1725 application.SendNotification();
1726 application.Render();
1728 // Trigger count is 1 - render a frame
1729 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1731 Renderer renderer = actor.GetRendererAt(0u);
1732 DALI_TEST_CHECK(renderer);
1734 Vector2 controlSize(20.f, 30.f);
1735 actor.SetProperty(Actor::Property::SIZE, controlSize);
1737 application.SendNotification();
1738 application.Render();
1740 application.SendNotification();
1741 application.Render();
1743 // Trigger count is 1 - render a frame
1744 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1746 auto textureSet = renderer.GetTextures();
1747 auto texture = textureSet.GetTexture(0);
1749 DALI_TEST_EQUALS(controlSize.width, texture.GetWidth(), TEST_LOCATION);
1750 DALI_TEST_EQUALS(controlSize.height, texture.GetHeight(), TEST_LOCATION);
1753 Vector3 controlScale(2.0f, 2.0f, 1.0f);
1754 actor.SetProperty(Actor::Property::SCALE, controlScale);
1756 application.SendNotification();
1757 application.Render();
1759 application.SendNotification();
1760 application.Render();
1762 // Trigger count is 1 - render a frame
1763 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1765 renderer = actor.GetRendererAt(0u);
1766 DALI_TEST_CHECK(renderer);
1768 textureSet = renderer.GetTextures();
1769 texture = textureSet.GetTexture(0);
1771 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1772 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1775 controlSize = Vector2(50.0f, 100.0f);
1776 Animation animation = Animation::New(1.0);
1777 animation.AnimateTo(Property(actor, Actor::Property::SIZE), Vector3(controlSize.x, controlSize.y, 0.0f));
1780 application.SendNotification();
1781 application.Render(1100); // After the animation
1783 application.SendNotification();
1784 application.Render();
1786 // Trigger count is 1 - render a frame
1787 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1789 renderer = actor.GetRendererAt(0u);
1790 DALI_TEST_CHECK(renderer);
1792 textureSet = renderer.GetTextures();
1793 texture = textureSet.GetTexture(0);
1795 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1796 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1801 int UtcDaliAnimatedVectorImageVisualMultipleInstances(void)
1803 ToolkitTestApplication application;
1804 tet_infoline("UtcDaliAnimatedVectorImageVisualMultipleInstances");
1806 Property::Map propertyMap;
1807 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1808 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1809 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1811 Visual::Base visual1 = VisualFactory::Get().CreateVisual(propertyMap);
1812 DALI_TEST_CHECK(visual1);
1814 DummyControl actor1 = DummyControl::New(true);
1815 DummyControlImpl& dummyImpl1 = static_cast<DummyControlImpl&>(actor1.GetImplementation());
1816 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual1);
1818 Vector2 controlSize(20.f, 30.f);
1819 actor1.SetProperty(Actor::Property::SIZE, controlSize);
1821 application.GetScene().Add(actor1);
1823 application.SendNotification();
1824 application.Render();
1826 // Trigger count is 2 - load & render a frame
1827 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1829 propertyMap.Clear();
1830 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1831 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1832 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1834 Visual::Base visual2 = VisualFactory::Get().CreateVisual(propertyMap);
1835 DALI_TEST_CHECK(visual2);
1837 DummyControl actor2 = DummyControl::New(true);
1838 DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor2.GetImplementation());
1839 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
1841 actor2.SetProperty(Actor::Property::SIZE, controlSize);
1843 application.GetScene().Add(actor2);
1845 application.SendNotification();
1846 application.Render();
1848 // Trigger count is 2 - load & render a frame
1849 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1851 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1853 // To make event trigger
1854 actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1856 application.SendNotification();
1857 application.Render();
1859 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1861 Property::Map attributes;
1862 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1864 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1865 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1867 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1869 // renderer is added to actor
1870 DALI_TEST_CHECK(actor1.GetRendererCount() == 1u);
1871 Renderer renderer1 = actor1.GetRendererAt(0u);
1872 DALI_TEST_CHECK(renderer1);
1874 // renderer is added to actor
1875 DALI_TEST_CHECK(actor2.GetRendererCount() == 1u);
1876 Renderer renderer2 = actor2.GetRendererAt(0u);
1877 DALI_TEST_CHECK(renderer2);
1882 int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void)
1884 ToolkitTestApplication application;
1885 tet_infoline("UtcDaliAnimatedVectorImageVisualControlVisibilityChanged");
1887 Property::Map propertyMap;
1888 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1889 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1890 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1892 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1893 DALI_TEST_CHECK(visual);
1895 DummyControl actor = DummyControl::New(true);
1896 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1897 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1899 Vector2 controlSize(20.f, 30.f);
1900 actor.SetProperty(Actor::Property::SIZE, controlSize);
1902 application.GetScene().Add(actor);
1904 application.SendNotification();
1905 application.Render();
1907 // Trigger count is 2 - load & render a frame
1908 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1910 Property::Map attributes;
1911 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1913 application.SendNotification();
1914 application.Render();
1916 // Check rendering behavior
1917 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1918 Renderer renderer = actor.GetRendererAt(0u);
1919 DALI_TEST_CHECK(renderer);
1920 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1922 actor.SetProperty(Actor::Property::VISIBLE, false);
1924 application.SendNotification();
1925 application.Render();
1927 // Check rendering behavior again
1928 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1933 int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void)
1935 ToolkitTestApplication application;
1936 tet_infoline("UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged");
1938 Property::Map propertyMap;
1939 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1940 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1942 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1943 DALI_TEST_CHECK(visual);
1945 DummyControl actor = DummyControl::New(true);
1946 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1947 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1949 Vector2 controlSize(20.f, 30.f);
1950 actor.SetProperty(Actor::Property::SIZE, controlSize);
1952 application.GetScene().Add(actor);
1954 application.SendNotification();
1955 application.Render();
1957 // Trigger count is 1 - render a frame
1958 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1960 Property::Map attributes;
1961 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1963 application.SendNotification();
1964 application.Render();
1966 // Check rendering behavior
1967 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1968 Renderer renderer = actor.GetRendererAt(0u);
1969 DALI_TEST_CHECK(renderer);
1970 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1972 Window window = DevelWindow::Get(actor);
1975 application.SendNotification();
1976 application.Render();
1978 // Check rendering behavior again
1979 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1984 int UtcDaliAnimatedVectorImageVisualInvalidFile01(void)
1986 ToolkitTestApplication application;
1987 tet_infoline("Request loading with invalid file - should draw broken image");
1989 TestGlAbstraction& gl = application.GetGlAbstraction();
1990 TraceCallStack& textureTrace = gl.GetTextureTrace();
1991 textureTrace.Enable(true);
1993 Property::Map propertyMap;
1994 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1995 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1996 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1998 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1999 DALI_TEST_CHECK(visual);
2001 DummyControl actor = DummyControl::New(true);
2002 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2003 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2005 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
2007 application.GetScene().Add(actor);
2009 application.SendNotification();
2010 application.Render();
2012 // Trigger count is 1 - load
2013 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2015 application.SendNotification();
2016 application.Render();
2018 // Check resource status
2019 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2020 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2022 // The broken image should be shown.
2023 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2024 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2029 int UtcDaliAnimatedVectorImageVisualInvalidFile02(void)
2031 ToolkitTestApplication application;
2032 tet_infoline("Request loading with invalid file - should draw broken image");
2034 TestGlAbstraction& gl = application.GetGlAbstraction();
2035 TraceCallStack& textureTrace = gl.GetTextureTrace();
2036 textureTrace.Enable(true);
2038 Property::Map propertyMap;
2039 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2040 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
2042 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2043 DALI_TEST_CHECK(visual);
2045 DummyControl actor = DummyControl::New(true);
2046 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2047 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2049 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
2051 application.SendNotification();
2052 application.Render();
2054 // Add to the Scene after loading
2055 application.GetScene().Add(actor);
2057 application.SendNotification();
2058 application.Render();
2060 // Check resource status
2061 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2062 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2064 // The broken image should be shown.
2065 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2066 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2071 int UtcDaliAnimatedVectorImageVisualInvalidFile03(void)
2073 ToolkitTestApplication application;
2074 tet_infoline("Request loading with invalid file without size set - should draw broken image");
2076 TestGlAbstraction& gl = application.GetGlAbstraction();
2077 TraceCallStack& textureTrace = gl.GetTextureTrace();
2078 textureTrace.Enable(true);
2080 Property::Map propertyMap;
2081 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2082 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
2083 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2085 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2086 DALI_TEST_CHECK(visual);
2088 DummyControl actor = DummyControl::New(true);
2089 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2090 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2092 application.GetScene().Add(actor);
2094 application.SendNotification();
2095 application.Render();
2097 // Trigger count is 1 - load
2098 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2100 application.SendNotification();
2101 application.Render();
2103 // Check resource status
2104 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2105 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2107 // The broken image should be shown.
2108 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2109 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2114 int UtcDaliAnimatedVectorImageVisualFrameDrops(void)
2116 ToolkitTestApplication application;
2117 tet_infoline("UtcDaliAnimatedVectorImageVisualFrameDrops");
2119 Property::Map propertyMap;
2120 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2121 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP)
2122 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2124 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2125 DALI_TEST_CHECK(visual);
2127 DummyControl actor = DummyControl::New(true);
2128 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2129 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2131 Vector2 controlSize(20.f, 30.f);
2132 actor.SetProperty(Actor::Property::SIZE, controlSize);
2134 application.GetScene().Add(actor);
2136 application.SendNotification();
2137 application.Render();
2139 // Trigger count is 2 - load, render the first frame
2140 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2142 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2143 Property::Value* value = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
2144 int totalFrameNumber = value->Get<int>();
2146 Property::Map attributes;
2147 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2149 // Make delay to drop frames
2150 Test::VectorAnimationRenderer::DelayRendering(170); // longer than 16.6 * 10frames
2152 application.SendNotification();
2153 application.Render();
2155 // Trigger count is 1 - calculating frame drops
2156 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2158 // Check dropped frame
2159 uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames();
2160 DALI_TEST_CHECK(frames > 0);
2161 DALI_TEST_CHECK(frames <= static_cast<uint32_t>(totalFrameNumber));
2166 int UtcDaliAnimatedVectorImageVisualSize(void)
2168 ToolkitTestApplication application;
2169 tet_infoline("UtcDaliAnimatedVectorImageVisualSize");
2171 TestGlAbstraction& gl = application.GetGlAbstraction();
2172 TraceCallStack& textureTrace = gl.GetTextureTrace();
2174 VisualFactory factory = VisualFactory::Get();
2175 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
2176 DALI_TEST_CHECK(visual);
2178 DummyControl actor = DummyControl::New(true);
2179 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2180 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2182 application.GetScene().Add(actor);
2184 application.SendNotification();
2185 application.Render();
2187 // Trigger count is 1 - resource ready
2188 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2190 textureTrace.Enable(true);
2192 application.SendNotification();
2193 application.Render();
2196 int width = 100, height = 100; // 100x100 is the content default size.
2197 std::stringstream out;
2198 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
2199 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2202 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
2204 application.SendNotification();
2205 application.Render();
2207 // Trigger count is 1 - resource ready
2208 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2210 textureTrace.Reset();
2212 application.SendNotification();
2213 application.Render();
2216 int width = 200, height = 200;
2217 std::stringstream out;
2218 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
2219 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2227 bool gDynamicPropertyCallbackFired = false;
2229 Property::Value FillColorCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber)
2231 gDynamicPropertyCallbackFired = true;
2235 return Vector3(0, 0, 1);
2239 return Vector3(1, 0, 0);
2244 int UtcDaliAnimatedVectorImageVisualDynamicProperty(void)
2246 ToolkitTestApplication application;
2247 tet_infoline("UtcDaliAnimatedVectorImageVisualDynamicProperty");
2249 VisualFactory factory = VisualFactory::Get();
2250 Visual::Base visual = factory.CreateVisual(
2252 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2253 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2254 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
2255 DALI_TEST_CHECK(visual);
2257 DummyControl actor = DummyControl::New(true);
2258 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2259 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2261 Vector2 controlSize(20.f, 30.f);
2262 actor.SetProperty(Actor::Property::SIZE, controlSize);
2264 application.GetScene().Add(actor);
2266 gDynamicPropertyCallbackFired = false;
2268 // Set dynamic property
2269 DevelAnimatedVectorImageVisual::DynamicPropertyInfo info;
2271 info.keyPath = "Test.Path";
2272 info.property = static_cast<int>(VectorAnimationRenderer::VectorProperty::FILL_COLOR);
2273 info.callback = MakeCallback(FillColorCallback);
2275 DevelControl::DoActionExtension(actor, DummyControl::Property::TEST_VISUAL, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info));
2277 Property::Map attributes;
2278 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2280 application.SendNotification();
2281 application.Render();
2283 // Trigger count is 2 - load & render a frame
2284 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2286 // Test whether the property callback is called
2287 DALI_TEST_EQUALS(gDynamicPropertyCallbackFired, true, TEST_LOCATION);
2292 int UtcDaliAnimatedVectorImageVisualDesiredSize(void)
2294 ToolkitTestApplication application;
2295 tet_infoline("UtcDaliAnimatedVectorImageVisualDesiredSize");
2297 TestGlAbstraction& gl = application.GetGlAbstraction();
2298 TraceCallStack& textureTrace = gl.GetTextureTrace();
2299 int desiredWidth = 150, desiredHeight = 200;
2301 Visual::Base visual = VisualFactory::Get().CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
2302 DALI_TEST_CHECK(visual);
2304 DummyControl actor = DummyControl::New(true);
2305 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2306 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2308 application.GetScene().Add(actor);
2310 application.SendNotification();
2311 application.Render();
2313 // Trigger count is 1 - resource ready
2314 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2316 textureTrace.Enable(true);
2318 application.SendNotification();
2319 application.Render();
2322 std::stringstream out;
2323 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
2324 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2327 // Unparent to make next trigger
2330 application.SendNotification();
2331 application.Render();
2334 actor.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.0f));
2335 application.GetScene().Add(actor);
2337 application.SendNotification();
2338 application.Render();
2340 // Trigger count is 1 - resource ready
2341 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2343 textureTrace.Reset();
2345 application.SendNotification();
2346 application.Render();
2349 std::stringstream out;
2350 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
2351 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str())); // The size should not be changed
2357 int UtcDaliAnimatedVectorImageVisualFlushAction(void)
2359 ToolkitTestApplication application;
2361 tet_infoline("UtcDaliAnimatedVectorImageVisualFlushAction");
2366 int totalFrameCount = 0;
2368 Property::Array playRange;
2369 playRange.PushBack(startFrame);
2370 playRange.PushBack(endFrame);
2372 Property::Map resultMap;
2373 Property::Value* value = nullptr;
2375 // request AnimatedVectorImageVisual with a property map
2376 VisualFactory factory = VisualFactory::Get();
2377 Visual::Base visual = factory.CreateVisual(
2379 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2380 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2381 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
2382 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, true));
2384 DummyControl dummyControl = DummyControl::New(true);
2385 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
2386 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2387 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
2389 application.GetScene().Add(dummyControl);
2391 // Retry function to get playrange until expect values comes.
2392 auto CheckAndRetryPlayRange = [&](int expectStartFrame, int expectEndFrame, std::vector<std::pair<int, int>> retrialFrames) {
2394 int tryCountMax = 30;
2395 while(++tryCount <= tryCountMax)
2397 Property::Map resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2399 Property::Value* value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
2400 DALI_TEST_CHECK(value);
2402 Property::Array* result = value->GetArray();
2403 DALI_TEST_CHECK(result);
2404 DALI_TEST_EQUALS(result->Count(), 2, TEST_LOCATION);
2406 bool tryAgain = false;
2407 for(auto& framePair : retrialFrames)
2409 if(result->GetElementAt(0).Get<int>() == framePair.first && result->GetElementAt(1).Get<int>() == framePair.second)
2417 tet_printf("Retry to get value again! [%d]\n", tryCount);
2418 // Dummy sleep 1 second.
2419 Test::WaitForEventThreadTrigger(1, 1);
2423 DALI_TEST_EQUALS(result->GetElementAt(0).Get<int>(), expectStartFrame, TEST_LOCATION);
2424 DALI_TEST_EQUALS(result->GetElementAt(1).Get<int>(), expectEndFrame, TEST_LOCATION);
2427 DALI_TEST_CHECK(tryCount <= tryCountMax);
2430 tet_printf("Pause lottie first.\n");
2432 Property::Map attributes;
2433 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
2435 application.SendNotification();
2436 application.Render(16);
2440 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2442 value = resultMap.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER, Property::INTEGER);
2443 DALI_TEST_CHECK(value);
2444 totalFrameCount = value->Get<int>();
2445 } while(totalFrameCount == 0);
2447 // Ensure that vector data sended well.
2448 CheckAndRetryPlayRange(startFrame, endFrame, {{0, 0}, {0, totalFrameCount - 1}});
2450 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2452 value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
2453 DALI_TEST_CHECK(value);
2454 DALI_TEST_EQUALS(value->Get<int>(), startFrame, TEST_LOCATION);
2456 tet_printf("Now logically, range : [%d~%d], current : %d\n", startFrame, endFrame, startFrame);
2458 int changedStartFrame1 = startFrame + 2;
2459 int changedEndFrame1 = endFrame + 2;
2462 playRange.Add(changedStartFrame1);
2463 playRange.Add(changedEndFrame1);
2465 tet_printf("Change play range\n");
2466 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
2467 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2469 tet_printf("Jump to changedEndFrame!\n");
2470 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, changedEndFrame1);
2473 tet_infoline("Flush Action!");
2474 tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame1, changedEndFrame1, changedEndFrame1);
2475 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::FLUSH, attributes);
2477 int changedStartFrame2 = startFrame + 1;
2478 int changedEndFrame2 = endFrame + 1;
2481 playRange.Add(changedStartFrame2);
2482 playRange.Add(changedEndFrame2);
2484 tet_printf("Change play range again\n");
2485 tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame2, changedEndFrame2, changedEndFrame2);
2486 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
2487 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2489 application.SendNotification();
2490 application.Render(16);
2492 // Ensure that vector data sended well.
2493 CheckAndRetryPlayRange(changedStartFrame2, changedEndFrame2, {{changedStartFrame1, changedEndFrame1}, {startFrame, endFrame}});
2495 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2497 tet_printf("Test whether current frame number changed well. If Flush not works, current frame become startFrame.");
2498 value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
2499 DALI_TEST_CHECK(value);
2500 DALI_TEST_EQUALS(value->Get<int>(), changedEndFrame2, TEST_LOCATION);
2502 dummyControl.Unparent();
2507 int UtcDaliAnimatedVectorImageNativeTextureChangeShader(void)
2509 ToolkitTestApplication application;
2510 tet_infoline("UtcDaliAnimatedVectorImageNativeTextureChangeShader");
2512 VisualFactory factory = VisualFactory::Get();
2513 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
2514 DALI_TEST_CHECK(visual);
2516 DummyControl actor = DummyControl::New(true);
2517 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2518 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2520 // Make we use native texture now.
2521 Test::VectorAnimationRenderer::UseNativeImageTexture(true);
2523 application.GetScene().Add(actor);
2525 application.SendNotification();
2526 application.Render();
2528 // Trigger count is 1 - resource ready
2529 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2531 application.SendNotification();
2532 application.Render();
2534 Renderer renderer = actor.GetRendererAt(0);
2535 Shader shader = renderer.GetShader();
2536 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
2537 Property::Map* map = value.GetMap();
2538 DALI_TEST_CHECK(map);
2540 std::string resultFragmentShader, resultVertexShader;
2541 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2542 fragment->Get(resultFragmentShader);
2543 DALI_TEST_CHECK(resultFragmentShader.find(NativeImageSourceTest::GetCustomFragmentPrefix()) != std::string::npos);
2545 // Reset to make we use normal texture again.
2546 Test::VectorAnimationRenderer::UseNativeImageTexture(false);