2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <toolkit-event-thread-callback.h>
24 #include <toolkit-timer.h>
25 #include <toolkit-vector-animation-renderer.h>
26 #include "dummy-control.h"
28 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/control-devel.h>
31 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
32 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-actions-devel.h>
33 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-signals-devel.h>
34 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
35 #include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
36 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
37 #include <dali/devel-api/adaptor-framework/window-devel.h>
38 #include <dali/devel-api/rendering/renderer-devel.h>
41 using namespace Dali::Toolkit;
43 void dali_animated_vector_image_visual_startup(void)
45 test_return_value = TET_UNDEF;
48 void dali_animated_vector_image_visual_cleanup(void)
50 test_return_value = TET_PASS;
55 const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
56 const char* TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP = "framedrop.json";
57 const char* TEST_VECTOR_IMAGE_INVALID_FILE_NAME = "invalid.json";
59 bool gAnimationFinishedSignalFired = false;
61 void VisualEventSignal(Control control, Dali::Property::Index visualIndex, Dali::Property::Index signalId)
63 if(visualIndex == DummyControl::Property::TEST_VISUAL && signalId == DevelAnimatedVectorImageVisual::Signal::ANIMATION_FINISHED)
65 gAnimationFinishedSignalFired = true;
71 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void)
73 ToolkitTestApplication application;
74 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual01: Request animated vector image visual with a json url");
76 VisualFactory factory = VisualFactory::Get();
77 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
78 DALI_TEST_CHECK(visual);
80 DummyControl actor = DummyControl::New(true);
81 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
82 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
83 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
84 application.GetScene().Add(actor);
86 application.SendNotification();
89 // renderer is added to actor
90 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
91 Renderer renderer = actor.GetRendererAt(0u);
92 DALI_TEST_CHECK(renderer);
94 // Test SetOffScene().
96 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
101 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual02(void)
103 ToolkitTestApplication application;
104 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual02: Request animated vector image visual with a Property::Map");
106 Property::Map propertyMap;
107 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
108 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
110 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
111 DALI_TEST_CHECK(visual);
113 DummyControl actor = DummyControl::New(true);
114 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
115 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
116 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
117 application.GetScene().Add(actor);
119 application.SendNotification();
120 application.Render();
122 // renderer is added to actor
123 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
124 Renderer renderer = actor.GetRendererAt(0u);
125 DALI_TEST_CHECK(renderer);
128 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
133 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void)
135 ToolkitTestApplication application;
136 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual03: Request animated vector image visual with a Property::Map");
138 int startFrame = 1, endFrame = 3;
139 Property::Array playRange;
140 playRange.PushBack(startFrame);
141 playRange.PushBack(endFrame);
143 Property::Map propertyMap;
144 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
145 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
146 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
147 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
148 .Add(DevelVisual::Property::CORNER_RADIUS, 50.0f)
149 .Add(DevelVisual::Property::BORDERLINE_WIDTH, 20.0f);
151 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
152 DALI_TEST_CHECK(visual);
154 DummyControl actor = DummyControl::New(true);
155 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
156 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
157 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
158 application.GetScene().Add(actor);
160 application.SendNotification();
161 application.Render();
163 // renderer is added to actor
164 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
165 Renderer renderer = actor.GetRendererAt(0u);
166 DALI_TEST_CHECK(renderer);
169 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
174 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void)
176 ToolkitTestApplication application;
177 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map");
179 int startFrame = 1, endFrame = 3;
180 float cornerRadius = 22.0f;
181 float borderlineWidth = 2.0f;
182 Vector4 borderlineColor = Vector4(1.0f, 1.0f, 1.0f, 1.0f);
183 float borderlineOffset = 0.1f;
184 Property::Array playRange;
185 playRange.PushBack(startFrame);
186 playRange.PushBack(endFrame);
188 Property::Map propertyMap;
189 propertyMap.Add("visualType", DevelVisual::ANIMATED_VECTOR_IMAGE)
190 .Add("url", TEST_VECTOR_IMAGE_FILE_NAME)
192 .Add("playRange", playRange)
193 .Add("stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME)
194 .Add("loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE)
195 .Add("redrawInScalingDown", false)
196 .Add("cornerRadius", cornerRadius)
197 .Add("borderlineWidth", borderlineWidth)
198 .Add("borderlineColor", borderlineColor)
199 .Add("borderlineOffset", borderlineOffset);
201 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
202 DALI_TEST_CHECK(visual);
204 DummyControl actor = DummyControl::New(true);
205 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
206 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
207 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
208 application.GetScene().Add(actor);
210 application.SendNotification();
211 application.Render();
213 // Trigger count is 1 - render a frame
214 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
216 // renderer is added to actor
217 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
219 Renderer renderer = actor.GetRendererAt(0u);
220 DALI_TEST_CHECK(renderer);
222 Property::Map resultMap;
223 visual.CreatePropertyMap(resultMap);
225 // check the property values from the returned map from a visual
226 Property::Value* value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
227 DALI_TEST_CHECK(value);
228 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
230 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
231 DALI_TEST_CHECK(value);
232 DALI_TEST_CHECK(value->Get<int>() == 3);
234 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
235 DALI_TEST_CHECK(value);
237 Property::Array* result = value->GetArray();
238 DALI_TEST_CHECK(result);
240 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
241 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
243 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
244 DALI_TEST_CHECK(value);
245 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::FIRST_FRAME);
247 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
248 DALI_TEST_CHECK(value);
249 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::AUTO_REVERSE);
251 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
252 DALI_TEST_CHECK(value);
253 DALI_TEST_CHECK(value->Get<bool>() == false);
255 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
256 DALI_TEST_CHECK(value);
257 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius), TEST_LOCATION);
259 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
260 DALI_TEST_CHECK(value);
261 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
263 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT);
264 DALI_TEST_CHECK(value);
265 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
267 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
268 DALI_TEST_CHECK(value);
269 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
271 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
272 DALI_TEST_CHECK(value);
273 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
276 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
281 int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
283 ToolkitTestApplication application;
284 tet_infoline("UtcDaliAnimatedVectorImageVisualGetPropertyMap01");
286 int startFrame = 1, endFrame = 3;
287 Vector4 cornerRadius(50.0f, 22.0f, 0.0f, 3.0f);
288 float borderlineWidth = 2.3f;
289 Vector4 borderlineColor = Vector4(0.3f, 0.3f, 1.0f, 1.0f);
290 float borderlineOffset = 0.3f;
291 Property::Array playRange;
292 playRange.PushBack(startFrame);
293 playRange.PushBack(endFrame);
295 Property::Map propertyMap;
296 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
297 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
298 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
299 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
300 .Add(DevelVisual::Property::CORNER_RADIUS, cornerRadius)
301 .Add(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::RELATIVE)
302 .Add(DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth)
303 .Add(DevelVisual::Property::BORDERLINE_COLOR, borderlineColor)
304 .Add(DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset);
306 // request AnimatedVectorImageVisual with a property map
307 VisualFactory factory = VisualFactory::Get();
308 Visual::Base visual = factory.CreateVisual(propertyMap);
310 DummyControl actor = DummyControl::New(true);
311 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
312 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
314 Vector2 controlSize(20.f, 30.f);
315 actor.SetProperty(Actor::Property::SIZE, controlSize);
317 application.GetScene().Add(actor);
319 application.SendNotification();
320 application.Render();
322 std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run
324 Property::Map resultMap;
325 resultMap = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
327 // check the property values from the returned map from a visual
328 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
329 DALI_TEST_CHECK(value);
330 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
332 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
333 DALI_TEST_CHECK(value);
334 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
336 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
337 DALI_TEST_CHECK(value);
338 DALI_TEST_CHECK(value->Get<int>() == 3);
340 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
341 DALI_TEST_CHECK(value);
343 Property::Array* result = value->GetArray();
344 DALI_TEST_CHECK(result);
346 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
347 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
349 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
350 DALI_TEST_CHECK(value);
351 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::CURRENT_FRAME);
353 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
354 DALI_TEST_CHECK(value);
355 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::RESTART);
357 value = resultMap.Find(DevelImageVisual::Property::CONTENT_INFO, Property::MAP);
358 DALI_TEST_CHECK(value);
360 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
361 DALI_TEST_CHECK(value);
362 DALI_TEST_CHECK(value->Get<bool>() == true); // Check default value
364 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
365 DALI_TEST_CHECK(value);
366 DALI_TEST_EQUALS(value->Get<Vector4>(), cornerRadius, TEST_LOCATION);
368 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
369 DALI_TEST_CHECK(value);
370 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::RELATIVE);
372 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
373 DALI_TEST_CHECK(value);
374 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
376 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
377 DALI_TEST_CHECK(value);
378 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
380 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
381 DALI_TEST_CHECK(value);
382 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
384 // request AnimatedVectorImageVisual with an URL
385 Visual::Base visual2 = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
388 visual2.CreatePropertyMap(resultMap);
390 // check the property values from the returned map from a visual
391 value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
392 DALI_TEST_CHECK(value);
393 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
395 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
396 DALI_TEST_CHECK(value);
397 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
402 int UtcDaliAnimatedVectorImageVisualPlayback(void)
404 ToolkitTestApplication application;
406 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayback");
409 // request AnimatedVectorImageVisual with a property map
410 VisualFactory factory = VisualFactory::Get();
411 Visual::Base visual = factory.CreateVisual(
413 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
414 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME));
416 DummyControl dummyControl = DummyControl::New(true);
417 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
418 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
419 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
421 Property::Map attributes;
422 tet_infoline("Test Play action");
423 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
425 application.GetScene().Add(dummyControl);
426 application.SendNotification();
427 application.Render(16);
429 Property::Map map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
430 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
431 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
433 tet_infoline("Test Pause action");
434 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
436 application.SendNotification();
437 application.Render(16);
439 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
440 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
441 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PAUSED);
443 tet_infoline("Test Play action");
444 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
446 application.SendNotification();
447 application.Render(16);
449 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
450 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
451 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
453 tet_infoline("Test Stop action");
454 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
456 application.SendNotification();
457 application.Render(16);
459 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
460 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
461 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
463 tet_infoline("Test Stop action again");
464 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
466 application.SendNotification();
467 application.Render(16);
469 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
470 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
471 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
473 tet_infoline("Test Play action");
474 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
476 application.SendNotification();
477 application.Render(16);
479 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
480 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
481 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
483 tet_infoline("Off stage");
484 dummyControl.Unparent();
486 application.SendNotification();
487 application.Render(16);
489 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
490 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
491 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
493 tet_infoline("On stage again");
494 application.GetScene().Add(dummyControl);
496 application.SendNotification();
497 application.Render(16);
499 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
500 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
501 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
503 tet_infoline("Test Play action");
504 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
506 application.SendNotification();
507 application.Render(16);
509 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
510 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
511 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
514 Vector3 newSize(100.0f, 100.0f, 0.0f);
515 dummyControl.SetProperty(Actor::Property::SIZE, newSize);
517 application.SendNotification();
518 application.Render(16);
520 // Size should be changed
521 Vector3 naturalSize = dummyControl.GetNaturalSize();
522 DALI_TEST_CHECK(naturalSize == newSize);
524 dummyControl.Unparent();
530 int UtcDaliAnimatedVectorImageVisualCustomShader(void)
532 ToolkitTestApplication application;
533 tet_infoline("UtcDaliAnimatedVectorImageVisualCustomShader Test custom shader");
535 VisualFactory factory = VisualFactory::Get();
536 Property::Map properties;
537 Property::Map shader;
538 const std::string vertexShader = "Foobar";
539 const std::string fragmentShader = "Foobar sampler2D Foobar";
540 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
541 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
543 properties[Visual::Property::TYPE] = Visual::IMAGE;
544 properties[Visual::Property::SHADER] = shader;
545 properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
547 Visual::Base visual = factory.CreateVisual(properties);
549 // trigger creation through setting on stage
550 DummyControl dummy = DummyControl::New(true);
551 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
552 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
554 dummy.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
555 dummy.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
556 application.GetScene().Add(dummy);
558 application.SendNotification();
559 application.Render();
561 Renderer renderer = dummy.GetRendererAt(0);
562 Shader shader2 = renderer.GetShader();
563 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
564 Property::Map* map = value.GetMap();
565 DALI_TEST_CHECK(map);
567 std::string resultFragmentShader, resultVertexShader;
568 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
569 fragment->Get(resultFragmentShader);
570 DALI_TEST_CHECK(resultFragmentShader.find(fragmentShader) != std::string::npos);
572 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
573 vertex->Get(resultVertexShader);
574 DALI_TEST_CHECK(resultVertexShader.find(vertexShader) != std::string::npos);
579 int UtcDaliAnimatedVectorImageVisualNaturalSize(void)
581 ToolkitTestApplication application;
582 tet_infoline("UtcDaliAnimatedVectorImageVisualNaturalSize");
584 VisualFactory factory = VisualFactory::Get();
585 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
586 DALI_TEST_CHECK(visual);
588 DummyControl actor = DummyControl::New(true);
589 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
590 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
592 Vector2 controlSize(20.f, 30.f);
595 application.GetScene().Add(actor);
597 application.SendNotification();
598 application.Render();
600 visual.GetNaturalSize(naturalSize);
602 DALI_TEST_EQUALS(naturalSize, Vector2(100.0f, 100.0f), TEST_LOCATION); // 100x100 is the content default size.
604 actor.SetProperty(Actor::Property::SIZE, controlSize);
606 application.SendNotification();
607 application.Render();
609 visual.GetNaturalSize(naturalSize);
611 DALI_TEST_EQUALS(naturalSize, controlSize, TEST_LOCATION);
616 int UtcDaliAnimatedVectorImageVisualLoopCount(void)
618 ToolkitTestApplication application;
619 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopCount");
621 Property::Map propertyMap;
622 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
623 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
624 .Add(DevelImageVisual::Property::LOOP_COUNT, 3);
626 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
627 DALI_TEST_CHECK(visual);
629 DummyControl actor = DummyControl::New(true);
630 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
631 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
633 Vector2 controlSize(20.f, 30.f);
634 actor.SetProperty(Actor::Property::SIZE, controlSize);
636 application.GetScene().Add(actor);
638 Property::Map attributes;
639 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
641 application.SendNotification();
642 application.Render();
644 // Trigger count is 1 - render a frame
645 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
647 // renderer is added to actor
648 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
649 Renderer renderer = actor.GetRendererAt(0u);
650 DALI_TEST_CHECK(renderer);
655 int UtcDaliAnimatedVectorImageVisualPlayRange(void)
657 ToolkitTestApplication application;
658 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRange");
660 int startFrame = 1, endFrame = 3;
661 Property::Array array;
662 array.PushBack(endFrame);
663 array.PushBack(startFrame);
665 Property::Map propertyMap;
666 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
667 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
668 .Add(DevelImageVisual::Property::PLAY_RANGE, array);
670 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
671 DALI_TEST_CHECK(visual);
673 DummyControl actor = DummyControl::New(true);
674 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
675 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
677 Vector2 controlSize(20.f, 30.f);
678 actor.SetProperty(Actor::Property::SIZE, controlSize);
680 application.GetScene().Add(actor);
682 Property::Map attributes;
683 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
685 application.SendNotification();
686 application.Render();
688 std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run
690 // renderer is added to actor
691 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
692 Renderer renderer = actor.GetRendererAt(0u);
693 DALI_TEST_CHECK(renderer);
695 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
696 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
698 int resultStartFrame, resultEndFrame;
699 Property::Array* result = value->GetArray();
700 result->GetElementAt(0).Get(resultStartFrame);
701 result->GetElementAt(1).Get(resultEndFrame);
703 DALI_TEST_EQUALS(startFrame, resultStartFrame, TEST_LOCATION);
704 DALI_TEST_EQUALS(endFrame, resultEndFrame, TEST_LOCATION);
706 // Set invalid play range
712 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
713 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
715 application.SendNotification();
716 application.Render();
718 std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run
720 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
721 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
723 result = value->GetArray();
724 result->GetElementAt(0).Get(resultStartFrame);
725 result->GetElementAt(1).Get(resultEndFrame);
727 DALI_TEST_EQUALS(startFrame, resultStartFrame, TEST_LOCATION); // Should not be changed
728 DALI_TEST_EQUALS(endFrame, resultEndFrame, TEST_LOCATION);
730 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, Property::Map());
732 application.SendNotification();
733 application.Render();
735 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
737 application.SendNotification();
738 application.Render();
740 std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run
742 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
743 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
744 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
751 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
752 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
754 application.SendNotification();
755 application.Render();
757 std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run
759 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
760 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
762 result = value->GetArray();
763 result->GetElementAt(0).Get(resultStartFrame);
764 result->GetElementAt(1).Get(resultEndFrame);
766 DALI_TEST_EQUALS(0, resultStartFrame, TEST_LOCATION);
767 DALI_TEST_EQUALS(2, resultEndFrame, TEST_LOCATION);
769 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
770 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION); // CURRENT_FRAME_NUMBER should be changed also.
775 int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void)
777 ToolkitTestApplication application;
778 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRangeMarker");
780 Property::Array array;
781 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
783 Property::Map propertyMap;
784 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
785 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
786 .Add(DevelImageVisual::Property::PLAY_RANGE, array);
788 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
789 DALI_TEST_CHECK(visual);
791 DummyControl actor = DummyControl::New(true);
792 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
793 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
795 Vector2 controlSize(20.f, 30.f);
796 actor.SetProperty(Actor::Property::SIZE, controlSize);
798 application.GetScene().Add(actor);
800 Property::Map attributes;
801 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
803 application.SendNotification();
804 application.Render();
806 std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run
808 // renderer is added to actor
809 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
810 Renderer renderer = actor.GetRendererAt(0u);
811 DALI_TEST_CHECK(renderer);
813 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
814 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
816 int resultStartFrame, resultEndFrame;
817 Property::Array* result = value->GetArray();
818 result->GetElementAt(0).Get(resultStartFrame);
819 result->GetElementAt(1).Get(resultEndFrame);
821 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
822 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
826 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
827 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_2);
830 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
831 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
833 application.SendNotification();
834 application.Render();
836 std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run
838 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
839 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
841 result = value->GetArray();
842 result->GetElementAt(0).Get(resultStartFrame);
843 result->GetElementAt(1).Get(resultEndFrame);
845 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
846 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
848 // Set invalid play range
851 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
854 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
855 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
857 application.SendNotification();
858 application.Render();
860 std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run
862 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
863 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
865 result = value->GetArray();
866 result->GetElementAt(0).Get(resultStartFrame);
867 result->GetElementAt(1).Get(resultEndFrame);
869 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION); // Should not be changed
870 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
875 int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
877 ToolkitTestApplication application;
878 tet_infoline("UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal");
880 Property::Map propertyMap;
881 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
882 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
883 .Add(DevelImageVisual::Property::LOOP_COUNT, 3);
885 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
886 DALI_TEST_CHECK(visual);
888 DummyControl actor = DummyControl::New(true);
889 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
890 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
892 DevelControl::VisualEventSignal(actor).Connect(&VisualEventSignal);
894 Vector2 controlSize(20.f, 30.f);
895 actor.SetProperty(Actor::Property::SIZE, controlSize);
897 application.GetScene().Add(actor);
899 Property::Map attributes;
900 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
902 application.SendNotification();
903 application.Render();
905 // Wait for animation finish
906 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
908 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
909 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
910 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
912 DALI_TEST_EQUALS(gAnimationFinishedSignalFired, true, TEST_LOCATION);
917 int UtcDaliAnimatedVectorImageVisualJumpTo(void)
919 ToolkitTestApplication application;
920 tet_infoline("UtcDaliAnimatedVectorImageVisualJumpTo");
922 Property::Map propertyMap;
923 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
924 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
926 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
927 DALI_TEST_CHECK(visual);
929 tet_printf("1. Visual is created.\n");
931 DummyControl actor = DummyControl::New(true);
932 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
933 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
935 Vector2 controlSize(20.f, 30.f);
936 actor.SetProperty(Actor::Property::SIZE, controlSize);
938 application.GetScene().Add(actor);
940 application.SendNotification();
941 application.Render();
943 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2);
945 application.SendNotification();
946 application.Render();
948 std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run
950 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
951 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
952 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
954 tet_printf("2. The current frame number is [%d].\n", value->Get<int>());
956 Property::Array array;
960 Property::Map attributes;
961 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
962 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
964 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
966 application.SendNotification();
967 application.Render();
969 std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run
971 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
972 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
973 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
975 tet_printf("3. The current frame number is [%d].\n", value->Get<int>());
984 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
985 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
988 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
990 application.SendNotification();
991 application.Render();
993 // Stop and jump to 3
994 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
996 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
998 application.SendNotification();
999 application.Render();
1001 std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run
1003 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1004 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1005 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1007 tet_printf("4. The current frame number is [%d].\n", value->Get<int>());
1009 // Jump to the same position
1010 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1012 application.SendNotification();
1013 application.Render();
1015 std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run
1017 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1018 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1019 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1021 tet_printf("5. The current frame number is [%d].\n", value->Get<int>());
1026 int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
1028 ToolkitTestApplication application;
1029 tet_infoline("UtcDaliAnimatedVectorImageVisualUpdateProperty");
1031 int startFrame = 1, endFrame = 3;
1032 Property::Array playRange;
1033 playRange.PushBack(startFrame);
1034 playRange.PushBack(endFrame);
1036 Property::Map propertyMap;
1037 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1038 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1039 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1040 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1042 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1043 DALI_TEST_CHECK(visual);
1045 DummyControl actor = DummyControl::New(true);
1046 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1047 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1049 Vector2 controlSize(20.f, 30.f);
1050 actor.SetProperty(Actor::Property::SIZE, controlSize);
1052 application.GetScene().Add(actor);
1054 application.SendNotification();
1055 application.Render();
1057 std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run
1059 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1060 Property::Value* value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1061 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1063 value = map.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
1064 DALI_TEST_CHECK(value);
1066 Property::Array* result = value->GetArray();
1067 DALI_TEST_CHECK(result);
1069 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1070 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1073 playRange.PushBack(0);
1074 playRange.PushBack(2);
1076 Property::Map attributes;
1077 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1078 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 5);
1080 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1082 application.SendNotification();
1083 application.Render();
1085 std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run
1087 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1088 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1089 DALI_TEST_EQUALS(value->Get<int>(), 5, TEST_LOCATION);
1091 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1092 result = value->GetArray();
1093 DALI_TEST_CHECK(result);
1095 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == 0);
1096 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == 2);
1101 playRange.PushBack(startFrame);
1102 playRange.PushBack(endFrame);
1104 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1106 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1108 application.SendNotification();
1109 application.Render();
1111 std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run
1113 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1114 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1116 result = value->GetArray();
1117 DALI_TEST_CHECK(result);
1119 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1120 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1122 // Play and update property
1124 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1126 application.SendNotification();
1127 application.Render();
1129 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 10);
1131 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1133 application.SendNotification();
1134 application.Render();
1136 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1137 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1138 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
1143 int UtcDaliAnimatedVectorImageVisualStopBehavior(void)
1145 ToolkitTestApplication application;
1146 tet_infoline("UtcDaliAnimatedVectorImageVisualStopBehavior");
1148 Property::Map propertyMap;
1149 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1150 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1151 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1152 .Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
1154 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1155 DALI_TEST_CHECK(visual);
1157 DummyControl actor = DummyControl::New(true);
1158 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1159 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1161 Vector2 controlSize(20.f, 30.f);
1162 actor.SetProperty(Actor::Property::SIZE, controlSize);
1164 application.GetScene().Add(actor);
1166 Property::Map attributes;
1167 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1169 application.SendNotification();
1170 application.Render();
1172 // Trigger count is 1 - animation finished
1173 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1175 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1176 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1177 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1179 // Change stop behavior
1180 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1182 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1187 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1189 application.SendNotification();
1190 application.Render();
1192 // Trigger count is 1 - animation finished
1193 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1195 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1197 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1198 int totalFrameNumber = value1->Get<int>();
1200 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1201 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1203 // Change stop behavior
1204 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1205 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, -1);
1207 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1212 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1214 application.SendNotification();
1215 application.Render();
1218 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
1220 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1221 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1222 int currentFrameNumber = value->Get<int>();
1225 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
1227 application.SendNotification();
1228 application.Render(16);
1230 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1231 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1232 DALI_TEST_EQUALS(value->Get<int>(), currentFrameNumber, TEST_LOCATION); // Should be same with currentFrameNumber
1237 int UtcDaliAnimatedVectorImageVisualLoopingMode(void)
1239 ToolkitTestApplication application;
1240 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopingMode");
1242 Property::Map propertyMap;
1243 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1244 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1245 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1246 .Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME)
1247 .Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::AUTO_REVERSE);
1249 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1250 DALI_TEST_CHECK(visual);
1252 DummyControl actor = DummyControl::New(true);
1253 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1254 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1256 Vector2 controlSize(20.f, 30.f);
1257 actor.SetProperty(Actor::Property::SIZE, controlSize);
1259 application.GetScene().Add(actor);
1261 Property::Map attributes;
1262 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1264 application.SendNotification();
1265 application.Render();
1267 // Trigger count is 1 - animation finished
1268 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1270 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1271 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1272 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame because of auto reverse
1274 // Change stop behavior
1275 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1277 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1280 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1282 application.SendNotification();
1283 application.Render();
1285 // Trigger count is 1 - animation finished
1286 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1288 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1289 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1290 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1292 // Change looping mode
1293 attributes.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::RESTART);
1295 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1298 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1300 application.SendNotification();
1301 application.Render();
1303 // Trigger count is 1 - animation finished
1304 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1306 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1307 int totalFrameNumber = value1->Get<int>();
1309 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1310 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1311 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1316 int UtcDaliAnimatedVectorImageVisualPropertyNotification(void)
1318 ToolkitTestApplication application;
1319 tet_infoline("UtcDaliAnimatedVectorImageVisualPropertyNotification");
1321 Property::Map propertyMap;
1322 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1323 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1325 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1326 DALI_TEST_CHECK(visual);
1328 DummyControl actor = DummyControl::New(true);
1329 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1330 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1332 Vector2 controlSize(20.f, 30.f);
1333 Vector3 controlScale(2.0f, 2.0f, 1.0f);
1334 actor.SetProperty(Actor::Property::SIZE, controlSize);
1335 actor.SetProperty(Actor::Property::SCALE, controlScale);
1337 application.GetScene().Add(actor);
1339 application.SendNotification();
1340 application.Render();
1342 application.SendNotification();
1343 application.Render();
1345 Renderer renderer = actor.GetRendererAt(0u);
1346 DALI_TEST_CHECK(renderer);
1348 auto textureSet = renderer.GetTextures();
1349 auto texture = textureSet.GetTexture(0);
1351 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1352 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1354 // Change scale and size
1355 controlSize = Vector2(50.f, 40.f);
1356 controlScale = Vector3(0.5f, 0.5f, 1.0f);
1357 actor.SetProperty(Actor::Property::SIZE, controlSize);
1358 actor.SetProperty(Actor::Property::SCALE, controlScale);
1360 application.SendNotification();
1361 application.Render();
1363 application.SendNotification();
1364 application.Render();
1366 renderer = actor.GetRendererAt(0u);
1367 DALI_TEST_CHECK(renderer);
1369 textureSet = renderer.GetTextures();
1370 texture = textureSet.GetTexture(0);
1372 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1373 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1378 int UtcDaliAnimatedVectorImageVisualMultipleInstances(void)
1380 ToolkitTestApplication application;
1381 tet_infoline("UtcDaliAnimatedVectorImageVisualMultipleInstances");
1383 Property::Map propertyMap;
1384 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1385 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1387 Visual::Base visual1 = VisualFactory::Get().CreateVisual(propertyMap);
1388 DALI_TEST_CHECK(visual1);
1390 DummyControl actor1 = DummyControl::New(true);
1391 DummyControlImpl& dummyImpl1 = static_cast<DummyControlImpl&>(actor1.GetImplementation());
1392 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual1);
1394 Vector2 controlSize(20.f, 30.f);
1395 actor1.SetProperty(Actor::Property::SIZE, controlSize);
1397 application.GetScene().Add(actor1);
1399 propertyMap.Clear();
1400 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1401 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1403 Visual::Base visual2 = VisualFactory::Get().CreateVisual(propertyMap);
1404 DALI_TEST_CHECK(visual2);
1406 DummyControl actor2 = DummyControl::New(true);
1407 DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor2.GetImplementation());
1408 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
1410 actor2.SetProperty(Actor::Property::SIZE, controlSize);
1412 application.GetScene().Add(actor2);
1414 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1416 application.SendNotification();
1417 application.Render();
1419 std::this_thread::sleep_for(std::chrono::milliseconds(200));
1421 Property::Map attributes;
1422 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1424 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1425 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1427 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1429 // renderer is added to actor
1430 DALI_TEST_CHECK(actor1.GetRendererCount() == 1u);
1431 Renderer renderer1 = actor1.GetRendererAt(0u);
1432 DALI_TEST_CHECK(renderer1);
1434 // renderer is added to actor
1435 DALI_TEST_CHECK(actor2.GetRendererCount() == 1u);
1436 Renderer renderer2 = actor2.GetRendererAt(0u);
1437 DALI_TEST_CHECK(renderer2);
1442 int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void)
1444 ToolkitTestApplication application;
1445 tet_infoline("UtcDaliAnimatedVectorImageVisualControlVisibilityChanged");
1447 Property::Map propertyMap;
1448 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1449 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1451 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1452 DALI_TEST_CHECK(visual);
1454 DummyControl actor = DummyControl::New(true);
1455 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1456 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1458 Vector2 controlSize(20.f, 30.f);
1459 actor.SetProperty(Actor::Property::SIZE, controlSize);
1461 application.GetScene().Add(actor);
1463 application.SendNotification();
1464 application.Render();
1466 Property::Map attributes;
1467 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1469 application.SendNotification();
1470 application.Render();
1472 // Check rendering behavior
1473 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1474 Renderer renderer = actor.GetRendererAt(0u);
1475 DALI_TEST_CHECK(renderer);
1476 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1478 actor.SetProperty(Actor::Property::VISIBLE, false);
1480 application.SendNotification();
1481 application.Render();
1483 // Check rendering behavior again
1484 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1489 int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void)
1491 ToolkitTestApplication application;
1492 tet_infoline("UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged");
1494 Property::Map propertyMap;
1495 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1496 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1498 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1499 DALI_TEST_CHECK(visual);
1501 DummyControl actor = DummyControl::New(true);
1502 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1503 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1505 Vector2 controlSize(20.f, 30.f);
1506 actor.SetProperty(Actor::Property::SIZE, controlSize);
1508 application.GetScene().Add(actor);
1510 application.SendNotification();
1511 application.Render();
1513 Property::Map attributes;
1514 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1516 application.SendNotification();
1517 application.Render();
1519 // Check rendering behavior
1520 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1521 Renderer renderer = actor.GetRendererAt(0u);
1522 DALI_TEST_CHECK(renderer);
1523 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1525 Window window = DevelWindow::Get(actor);
1528 application.SendNotification();
1529 application.Render();
1531 // Check rendering behavior again
1532 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1537 int UtcDaliAnimatedVectorImageVisualInvalidFile(void)
1539 ToolkitTestApplication application;
1540 tet_infoline("Request loading with invalid file - should draw broken image");
1542 TestGlAbstraction& gl = application.GetGlAbstraction();
1543 TraceCallStack& textureTrace = gl.GetTextureTrace();
1544 textureTrace.Enable(true);
1546 Property::Map propertyMap;
1547 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1548 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
1550 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1551 DALI_TEST_CHECK(visual);
1553 DummyControl actor = DummyControl::New(true);
1554 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1555 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1557 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1559 application.GetScene().Add(actor);
1561 application.SendNotification();
1562 application.Render();
1564 // Check resource status
1565 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1566 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1568 // The broken image should be shown.
1569 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1570 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1575 int UtcDaliAnimatedVectorImageVisualFrameDrops(void)
1577 ToolkitTestApplication application;
1578 tet_infoline("UtcDaliAnimatedVectorImageVisualFrameDrops");
1580 Property::Map propertyMap;
1581 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1582 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP);
1584 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1585 DALI_TEST_CHECK(visual);
1587 DummyControl actor = DummyControl::New(true);
1588 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1589 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1591 Vector2 controlSize(20.f, 30.f);
1592 actor.SetProperty(Actor::Property::SIZE, controlSize);
1594 application.GetScene().Add(actor);
1596 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1597 Property::Value* value = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1598 int totalFrameNumber = value->Get<int>();
1600 Property::Map attributes;
1601 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1603 // Make delay to drop frames
1604 Test::VectorAnimationRenderer::DelayRendering(170); // longer than 16.6 * 10frames
1606 application.SendNotification();
1607 application.Render();
1609 // Trigger count is 2 - render the first frame & calculating frame drops
1610 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1612 // Check dropped frame
1613 uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames();
1614 DALI_TEST_CHECK(frames > 0);
1615 DALI_TEST_CHECK(frames <= static_cast<uint32_t>(totalFrameNumber));