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 // Trigger count is 2 - load & render a frame
90 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
92 // renderer is added to actor
93 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
94 Renderer renderer = actor.GetRendererAt(0u);
95 DALI_TEST_CHECK(renderer);
97 // Test SetOffScene().
99 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
104 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual02(void)
106 ToolkitTestApplication application;
107 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual02: Request animated vector image visual with a Property::Map");
109 Property::Map propertyMap;
110 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
111 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
113 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
114 DALI_TEST_CHECK(visual);
116 DummyControl actor = DummyControl::New(true);
117 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
118 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
119 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
120 application.GetScene().Add(actor);
122 application.SendNotification();
123 application.Render();
125 // Trigger count is 2 - load & render a frame
126 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
128 // renderer is added to actor
129 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
130 Renderer renderer = actor.GetRendererAt(0u);
131 DALI_TEST_CHECK(renderer);
134 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
139 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void)
141 ToolkitTestApplication application;
142 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual03: Request animated vector image visual with a Property::Map");
144 int startFrame = 1, endFrame = 3;
145 Property::Array playRange;
146 playRange.PushBack(startFrame);
147 playRange.PushBack(endFrame);
149 Property::Map propertyMap;
150 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
151 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
152 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
153 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
154 .Add(DevelVisual::Property::CORNER_RADIUS, 50.0f)
155 .Add(DevelVisual::Property::BORDERLINE_WIDTH, 20.0f);
157 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
158 DALI_TEST_CHECK(visual);
160 DummyControl actor = DummyControl::New(true);
161 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
162 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
163 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
164 application.GetScene().Add(actor);
166 application.SendNotification();
167 application.Render();
169 // Trigger count is 2 - load & render a frame
170 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
172 // renderer is added to actor
173 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
174 Renderer renderer = actor.GetRendererAt(0u);
175 DALI_TEST_CHECK(renderer);
178 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
183 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void)
185 ToolkitTestApplication application;
186 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map");
188 int startFrame = 1, endFrame = 3;
189 float cornerRadius = 22.0f;
190 float borderlineWidth = 2.0f;
191 Vector4 borderlineColor = Vector4(1.0f, 1.0f, 1.0f, 1.0f);
192 float borderlineOffset = 0.1f;
193 Property::Array playRange;
194 playRange.PushBack(startFrame);
195 playRange.PushBack(endFrame);
197 Property::Map propertyMap;
198 propertyMap.Add("visualType", DevelVisual::ANIMATED_VECTOR_IMAGE)
199 .Add("url", TEST_VECTOR_IMAGE_FILE_NAME)
201 .Add("playRange", playRange)
202 .Add("stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME)
203 .Add("loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE)
204 .Add("redrawInScalingDown", false)
205 .Add("cornerRadius", cornerRadius)
206 .Add("borderlineWidth", borderlineWidth)
207 .Add("borderlineColor", borderlineColor)
208 .Add("borderlineOffset", borderlineOffset);
210 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
211 DALI_TEST_CHECK(visual);
213 DummyControl actor = DummyControl::New(true);
214 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
215 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
216 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
217 application.GetScene().Add(actor);
219 application.SendNotification();
220 application.Render();
222 // Trigger count is 2 - load & render a frame
223 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
225 // renderer is added to actor
226 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
228 Renderer renderer = actor.GetRendererAt(0u);
229 DALI_TEST_CHECK(renderer);
231 Property::Map resultMap;
232 visual.CreatePropertyMap(resultMap);
234 // check the property values from the returned map from a visual
235 Property::Value* value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
236 DALI_TEST_CHECK(value);
237 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
239 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
240 DALI_TEST_CHECK(value);
241 DALI_TEST_CHECK(value->Get<int>() == 3);
243 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
244 DALI_TEST_CHECK(value);
246 Property::Array* result = value->GetArray();
247 DALI_TEST_CHECK(result);
249 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
250 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
252 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
253 DALI_TEST_CHECK(value);
254 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::FIRST_FRAME);
256 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
257 DALI_TEST_CHECK(value);
258 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::AUTO_REVERSE);
260 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
261 DALI_TEST_CHECK(value);
262 DALI_TEST_CHECK(value->Get<bool>() == false);
264 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
265 DALI_TEST_CHECK(value);
266 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius), TEST_LOCATION);
268 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
269 DALI_TEST_CHECK(value);
270 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
272 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT);
273 DALI_TEST_CHECK(value);
274 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
276 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
277 DALI_TEST_CHECK(value);
278 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
280 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
281 DALI_TEST_CHECK(value);
282 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
285 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
290 int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
292 ToolkitTestApplication application;
293 tet_infoline("UtcDaliAnimatedVectorImageVisualGetPropertyMap01");
295 int startFrame = 1, endFrame = 3;
296 Vector4 cornerRadius(50.0f, 22.0f, 0.0f, 3.0f);
297 float borderlineWidth = 2.3f;
298 Vector4 borderlineColor = Vector4(0.3f, 0.3f, 1.0f, 1.0f);
299 float borderlineOffset = 0.3f;
300 Property::Array playRange;
301 playRange.PushBack(startFrame);
302 playRange.PushBack(endFrame);
304 Property::Map propertyMap;
305 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
306 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
307 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
308 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
309 .Add(DevelVisual::Property::CORNER_RADIUS, cornerRadius)
310 .Add(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::RELATIVE)
311 .Add(DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth)
312 .Add(DevelVisual::Property::BORDERLINE_COLOR, borderlineColor)
313 .Add(DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset);
315 // request AnimatedVectorImageVisual with a property map
316 VisualFactory factory = VisualFactory::Get();
317 Visual::Base visual = factory.CreateVisual(propertyMap);
319 DummyControl actor = DummyControl::New(true);
320 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
321 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
323 Vector2 controlSize(20.f, 30.f);
324 actor.SetProperty(Actor::Property::SIZE, controlSize);
326 application.GetScene().Add(actor);
328 application.SendNotification();
329 application.Render();
331 // Trigger count is 2 - load & render a frame
332 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
334 Property::Map resultMap;
335 resultMap = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
337 // check the property values from the returned map from a visual
338 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
339 DALI_TEST_CHECK(value);
340 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
342 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
343 DALI_TEST_CHECK(value);
344 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
346 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
347 DALI_TEST_CHECK(value);
348 DALI_TEST_CHECK(value->Get<int>() == 3);
350 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
351 DALI_TEST_CHECK(value);
353 Property::Array* result = value->GetArray();
354 DALI_TEST_CHECK(result);
356 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
357 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
359 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
360 DALI_TEST_CHECK(value);
361 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::CURRENT_FRAME);
363 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
364 DALI_TEST_CHECK(value);
365 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::RESTART);
367 value = resultMap.Find(DevelImageVisual::Property::CONTENT_INFO, Property::MAP);
368 DALI_TEST_CHECK(value);
370 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
371 DALI_TEST_CHECK(value);
372 DALI_TEST_CHECK(value->Get<bool>() == true); // Check default value
374 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
375 DALI_TEST_CHECK(value);
376 DALI_TEST_EQUALS(value->Get<Vector4>(), cornerRadius, TEST_LOCATION);
378 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
379 DALI_TEST_CHECK(value);
380 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::RELATIVE);
382 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
383 DALI_TEST_CHECK(value);
384 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
386 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
387 DALI_TEST_CHECK(value);
388 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
390 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
391 DALI_TEST_CHECK(value);
392 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
394 // request AnimatedVectorImageVisual with an URL
395 Visual::Base visual2 = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
398 visual2.CreatePropertyMap(resultMap);
400 // check the property values from the returned map from a visual
401 value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
402 DALI_TEST_CHECK(value);
403 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
405 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
406 DALI_TEST_CHECK(value);
407 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
412 int UtcDaliAnimatedVectorImageVisualPlayback(void)
414 ToolkitTestApplication application;
416 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayback");
419 // request AnimatedVectorImageVisual with a property map
420 VisualFactory factory = VisualFactory::Get();
421 Visual::Base visual = factory.CreateVisual(
423 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
424 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME));
426 DummyControl dummyControl = DummyControl::New(true);
427 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
428 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
429 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
431 Property::Map attributes;
432 tet_infoline("Test Play action");
433 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
435 application.GetScene().Add(dummyControl);
436 application.SendNotification();
437 application.Render(16);
439 Property::Map map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
440 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
441 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
443 tet_infoline("Test Pause action");
444 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, 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::PAUSED);
453 tet_infoline("Test Play action");
454 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, 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::PLAYING);
463 tet_infoline("Test Stop action");
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 Stop action again");
474 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, 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::STOPPED);
483 tet_infoline("Test Play action");
484 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
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::PLAYING);
493 tet_infoline("Off stage");
494 dummyControl.Unparent();
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("On stage again");
504 application.GetScene().Add(dummyControl);
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::STOPPED);
513 tet_infoline("Test Play action");
514 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
516 application.SendNotification();
517 application.Render(16);
519 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
520 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
521 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
524 Vector3 newSize(100.0f, 100.0f, 0.0f);
525 dummyControl.SetProperty(Actor::Property::SIZE, newSize);
527 application.SendNotification();
528 application.Render(16);
530 // Size should be changed
531 Vector3 naturalSize = dummyControl.GetNaturalSize();
532 DALI_TEST_CHECK(naturalSize == newSize);
534 dummyControl.Unparent();
540 int UtcDaliAnimatedVectorImageVisualCustomShader(void)
542 ToolkitTestApplication application;
543 tet_infoline("UtcDaliAnimatedVectorImageVisualCustomShader Test custom shader");
545 VisualFactory factory = VisualFactory::Get();
546 Property::Map properties;
547 Property::Map shader;
548 const std::string vertexShader = "Foobar";
549 const std::string fragmentShader = "Foobar sampler2D Foobar";
550 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
551 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
553 properties[Visual::Property::TYPE] = Visual::IMAGE;
554 properties[Visual::Property::SHADER] = shader;
555 properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
557 Visual::Base visual = factory.CreateVisual(properties);
559 // trigger creation through setting on stage
560 DummyControl dummy = DummyControl::New(true);
561 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
562 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
564 dummy.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
565 dummy.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
566 application.GetScene().Add(dummy);
568 application.SendNotification();
569 application.Render();
571 // Trigger count is 2 - load & render a frame
572 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
574 Renderer renderer = dummy.GetRendererAt(0);
575 Shader shader2 = renderer.GetShader();
576 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
577 Property::Map* map = value.GetMap();
578 DALI_TEST_CHECK(map);
580 std::string resultFragmentShader, resultVertexShader;
581 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
582 fragment->Get(resultFragmentShader);
583 DALI_TEST_CHECK(resultFragmentShader.find(fragmentShader) != std::string::npos);
585 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
586 vertex->Get(resultVertexShader);
587 DALI_TEST_CHECK(resultVertexShader.find(vertexShader) != std::string::npos);
592 int UtcDaliAnimatedVectorImageVisualNaturalSize(void)
594 ToolkitTestApplication application;
595 tet_infoline("UtcDaliAnimatedVectorImageVisualNaturalSize");
597 VisualFactory factory = VisualFactory::Get();
598 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
599 DALI_TEST_CHECK(visual);
601 DummyControl actor = DummyControl::New(true);
602 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
603 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
605 Vector2 controlSize(20.f, 30.f);
608 application.GetScene().Add(actor);
610 application.SendNotification();
611 application.Render();
613 // Trigger count is 1 - load
614 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
616 visual.GetNaturalSize(naturalSize);
618 DALI_TEST_EQUALS(naturalSize, Vector2(100.0f, 100.0f), TEST_LOCATION); // 100x100 is the content default size.
620 actor.SetProperty(Actor::Property::SIZE, controlSize);
622 application.SendNotification();
623 application.Render();
625 visual.GetNaturalSize(naturalSize);
627 DALI_TEST_EQUALS(naturalSize, controlSize, TEST_LOCATION);
632 int UtcDaliAnimatedVectorImageVisualLoopCount(void)
634 ToolkitTestApplication application;
635 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopCount");
637 Property::Map propertyMap;
638 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
639 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
640 .Add(DevelImageVisual::Property::LOOP_COUNT, 3);
642 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
643 DALI_TEST_CHECK(visual);
645 DummyControl actor = DummyControl::New(true);
646 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
647 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
649 Vector2 controlSize(20.f, 30.f);
650 actor.SetProperty(Actor::Property::SIZE, controlSize);
652 application.GetScene().Add(actor);
654 Property::Map attributes;
655 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
657 application.SendNotification();
658 application.Render();
660 // Trigger count is 2 - load & render a frame
661 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
663 // renderer is added to actor
664 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
665 Renderer renderer = actor.GetRendererAt(0u);
666 DALI_TEST_CHECK(renderer);
671 int UtcDaliAnimatedVectorImageVisualPlayRange(void)
673 ToolkitTestApplication application;
674 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRange");
676 int startFrame = 1, endFrame = 3;
677 Property::Array array;
678 array.PushBack(endFrame);
679 array.PushBack(startFrame);
681 Property::Map propertyMap;
682 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
683 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
684 .Add(DevelImageVisual::Property::PLAY_RANGE, array);
686 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
687 DALI_TEST_CHECK(visual);
689 DummyControl actor = DummyControl::New(true);
690 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
691 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
693 Vector2 controlSize(20.f, 30.f);
694 actor.SetProperty(Actor::Property::SIZE, controlSize);
696 application.GetScene().Add(actor);
698 Property::Map attributes;
699 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
701 application.SendNotification();
702 application.Render();
704 // Trigger count is 2 - load & render a frame
705 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
707 // renderer is added to actor
708 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
709 Renderer renderer = actor.GetRendererAt(0u);
710 DALI_TEST_CHECK(renderer);
712 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
713 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
714 int totalFrameNumber = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER)->Get<int>();
716 int resultStartFrame, resultEndFrame;
717 Property::Array* result = value->GetArray();
718 result->GetElementAt(0).Get(resultStartFrame);
719 result->GetElementAt(1).Get(resultEndFrame);
721 DALI_TEST_EQUALS(startFrame, resultStartFrame, TEST_LOCATION);
722 DALI_TEST_EQUALS(endFrame, resultEndFrame, TEST_LOCATION);
724 // Set invalid play range
730 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
731 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
733 // To make event trigger
734 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
736 application.SendNotification();
737 application.Render();
739 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
741 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
742 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
744 result = value->GetArray();
745 result->GetElementAt(0).Get(resultStartFrame);
746 result->GetElementAt(1).Get(resultEndFrame);
748 DALI_TEST_EQUALS(resultStartFrame, 1, TEST_LOCATION);
749 DALI_TEST_EQUALS(resultEndFrame, totalFrameNumber - 1, TEST_LOCATION); // Should be clamped
751 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, Property::Map());
753 application.SendNotification();
754 application.Render();
756 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
758 // To make event trigger
759 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
761 application.SendNotification();
762 application.Render();
764 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
766 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
767 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
768 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
775 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
776 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
778 // To make event trigger
779 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
781 application.SendNotification();
782 application.Render();
784 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
786 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
787 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
789 result = value->GetArray();
790 result->GetElementAt(0).Get(resultStartFrame);
791 result->GetElementAt(1).Get(resultEndFrame);
793 DALI_TEST_EQUALS(0, resultStartFrame, TEST_LOCATION);
794 DALI_TEST_EQUALS(2, resultEndFrame, TEST_LOCATION);
796 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
797 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION); // CURRENT_FRAME_NUMBER should be changed also.
802 int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void)
804 ToolkitTestApplication application;
805 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRangeMarker");
807 Property::Array array;
808 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
810 Property::Map propertyMap;
811 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
812 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
813 .Add(DevelImageVisual::Property::PLAY_RANGE, array);
815 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
816 DALI_TEST_CHECK(visual);
818 DummyControl actor = DummyControl::New(true);
819 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
820 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
822 Vector2 controlSize(20.f, 30.f);
823 actor.SetProperty(Actor::Property::SIZE, controlSize);
825 application.GetScene().Add(actor);
827 Property::Map attributes;
828 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
830 application.SendNotification();
831 application.Render();
833 // Trigger count is 2 - load & render a frame
834 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
836 // renderer is added to actor
837 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
838 Renderer renderer = actor.GetRendererAt(0u);
839 DALI_TEST_CHECK(renderer);
841 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
842 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
844 int resultStartFrame, resultEndFrame;
845 Property::Array* result = value->GetArray();
846 result->GetElementAt(0).Get(resultStartFrame);
847 result->GetElementAt(1).Get(resultEndFrame);
849 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
850 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
854 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
855 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_2);
858 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
859 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
861 // To make event trigger
862 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
864 application.SendNotification();
865 application.Render();
867 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
869 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
870 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
872 result = value->GetArray();
873 result->GetElementAt(0).Get(resultStartFrame);
874 result->GetElementAt(1).Get(resultEndFrame);
876 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
877 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
879 // Set invalid play range
882 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
885 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
886 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
888 // To make event trigger
889 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
891 application.SendNotification();
892 application.Render();
894 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
896 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
897 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
899 result = value->GetArray();
900 result->GetElementAt(0).Get(resultStartFrame);
901 result->GetElementAt(1).Get(resultEndFrame);
903 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION); // Should not be changed
904 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
909 int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
911 ToolkitTestApplication application;
912 tet_infoline("UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal");
914 Property::Map propertyMap;
915 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
916 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
917 .Add(DevelImageVisual::Property::LOOP_COUNT, 3);
919 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
920 DALI_TEST_CHECK(visual);
922 DummyControl actor = DummyControl::New(true);
923 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
924 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
926 DevelControl::VisualEventSignal(actor).Connect(&VisualEventSignal);
928 Vector2 controlSize(20.f, 30.f);
929 actor.SetProperty(Actor::Property::SIZE, controlSize);
931 application.GetScene().Add(actor);
933 Property::Map attributes;
934 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
936 application.SendNotification();
937 application.Render();
939 // Wait for animation finish - load, render, finish
940 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
942 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
943 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
944 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
946 DALI_TEST_EQUALS(gAnimationFinishedSignalFired, true, TEST_LOCATION);
951 int UtcDaliAnimatedVectorImageVisualJumpTo(void)
953 ToolkitTestApplication application;
954 tet_infoline("UtcDaliAnimatedVectorImageVisualJumpTo");
956 Property::Map propertyMap;
957 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
958 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
959 .Add(DevelImageVisual::Property::LOOP_COUNT, 3);
961 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
962 DALI_TEST_CHECK(visual);
964 tet_printf("1. Visual is created.\n");
966 DummyControl actor = DummyControl::New(true);
967 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
968 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
970 Vector2 controlSize(20.f, 30.f);
971 actor.SetProperty(Actor::Property::SIZE, controlSize);
973 application.GetScene().Add(actor);
975 application.SendNotification();
976 application.Render();
978 // Trigger count is 2 - load & render a frame
979 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
981 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2);
983 // To make event trigger
984 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
986 application.SendNotification();
987 application.Render();
989 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
991 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
992 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
993 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
995 tet_printf("2. The current frame number is [%d].\n", value->Get<int>());
997 Property::Array array;
1001 Property::Map attributes;
1002 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1003 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1005 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1007 // To make event trigger
1008 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1010 application.SendNotification();
1011 application.Render();
1013 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1015 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1016 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1017 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1019 tet_printf("3. The current frame number is [%d].\n", value->Get<int>());
1021 // Change play range
1028 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1029 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1032 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1034 application.SendNotification();
1035 application.Render();
1037 // Wait for animation finish
1038 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1041 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1043 // To make event trigger
1044 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1046 application.SendNotification();
1047 application.Render();
1049 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1051 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1052 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1053 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1055 tet_printf("4. The current frame number is [%d].\n", value->Get<int>());
1057 // Jump to the same position
1058 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1060 // To make event trigger
1061 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1063 application.SendNotification();
1064 application.Render();
1066 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1068 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1069 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1070 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1072 tet_printf("5. The current frame number is [%d].\n", value->Get<int>());
1077 int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
1079 ToolkitTestApplication application;
1080 tet_infoline("UtcDaliAnimatedVectorImageVisualUpdateProperty");
1082 int startFrame = 1, endFrame = 3;
1083 Property::Array playRange;
1084 playRange.PushBack(startFrame);
1085 playRange.PushBack(endFrame);
1087 Property::Map propertyMap;
1088 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1089 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1090 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1091 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1093 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1094 DALI_TEST_CHECK(visual);
1096 DummyControl actor = DummyControl::New(true);
1097 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1098 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1100 Vector2 controlSize(20.f, 30.f);
1101 actor.SetProperty(Actor::Property::SIZE, controlSize);
1103 application.GetScene().Add(actor);
1105 application.SendNotification();
1106 application.Render();
1108 // Trigger count is 2 - load & render a frame
1109 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1111 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1112 Property::Value* value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1113 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1115 value = map.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
1116 DALI_TEST_CHECK(value);
1118 Property::Array* result = value->GetArray();
1119 DALI_TEST_CHECK(result);
1121 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1122 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1125 playRange.PushBack(0);
1126 playRange.PushBack(2);
1128 Property::Map attributes;
1129 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1130 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 5);
1132 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1134 // To make event trigger
1135 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1137 application.SendNotification();
1138 application.Render();
1140 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1142 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1143 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1144 DALI_TEST_EQUALS(value->Get<int>(), 5, TEST_LOCATION);
1146 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1147 result = value->GetArray();
1148 DALI_TEST_CHECK(result);
1150 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == 0);
1151 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == 2);
1156 playRange.PushBack(startFrame);
1157 playRange.PushBack(endFrame);
1159 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1161 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1163 // To make event trigger
1164 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1166 application.SendNotification();
1167 application.Render();
1169 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1171 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1172 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1174 result = value->GetArray();
1175 DALI_TEST_CHECK(result);
1177 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1178 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1180 // Play and update property
1182 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1184 application.SendNotification();
1185 application.Render();
1187 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 10);
1189 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1191 application.SendNotification();
1192 application.Render();
1194 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1195 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1196 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
1201 int UtcDaliAnimatedVectorImageVisualStopBehavior(void)
1203 ToolkitTestApplication application;
1204 tet_infoline("UtcDaliAnimatedVectorImageVisualStopBehavior");
1206 Property::Map propertyMap;
1207 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1208 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1209 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1210 .Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
1212 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1213 DALI_TEST_CHECK(visual);
1215 DummyControl actor = DummyControl::New(true);
1216 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1217 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1219 Vector2 controlSize(20.f, 30.f);
1220 actor.SetProperty(Actor::Property::SIZE, controlSize);
1222 application.GetScene().Add(actor);
1224 Property::Map attributes;
1225 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1227 application.SendNotification();
1228 application.Render();
1230 // Trigger count is 3 - load, render, animation finished
1231 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1233 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1234 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1235 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1237 // Change stop behavior
1238 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1240 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1245 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1247 application.SendNotification();
1248 application.Render();
1250 // Trigger count is 1 - animation finished
1251 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1253 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1255 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1256 int totalFrameNumber = value1->Get<int>();
1258 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1259 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1261 // Change stop behavior
1262 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1263 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, -1);
1265 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1270 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1272 application.SendNotification();
1273 application.Render();
1276 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
1278 // To make event trigger
1279 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1281 application.SendNotification();
1282 application.Render();
1284 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1286 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1287 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1288 int currentFrameNumber = value->Get<int>();
1291 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
1293 // To make event trigger
1294 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1296 application.SendNotification();
1297 application.Render();
1299 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1301 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1302 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1303 DALI_TEST_EQUALS(value->Get<int>(), currentFrameNumber, TEST_LOCATION); // Should be same with currentFrameNumber
1308 int UtcDaliAnimatedVectorImageVisualLoopingMode(void)
1310 ToolkitTestApplication application;
1311 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopingMode");
1313 Property::Map propertyMap;
1314 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1315 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1316 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1317 .Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME)
1318 .Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::AUTO_REVERSE);
1320 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1321 DALI_TEST_CHECK(visual);
1323 DummyControl actor = DummyControl::New(true);
1324 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1325 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1327 Vector2 controlSize(20.f, 30.f);
1328 actor.SetProperty(Actor::Property::SIZE, controlSize);
1330 application.GetScene().Add(actor);
1332 Property::Map attributes;
1333 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1335 application.SendNotification();
1336 application.Render();
1338 // Trigger count is 3 - load, render, animation finished
1339 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1341 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1342 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1343 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame because of auto reverse
1345 // Change stop behavior
1346 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1348 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1351 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1353 application.SendNotification();
1354 application.Render();
1356 // Trigger count is 1 - animation finished
1357 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1359 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1360 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1361 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1363 // Change looping mode
1364 attributes.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::RESTART);
1366 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1369 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1371 application.SendNotification();
1372 application.Render();
1374 // Trigger count is 1 - animation finished
1375 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1377 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1378 int totalFrameNumber = value1->Get<int>();
1380 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1381 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1382 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1387 int UtcDaliAnimatedVectorImageVisualPropertyNotification(void)
1389 ToolkitTestApplication application;
1390 tet_infoline("UtcDaliAnimatedVectorImageVisualPropertyNotification");
1392 Property::Map propertyMap;
1393 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1394 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1396 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1397 DALI_TEST_CHECK(visual);
1399 DummyControl actor = DummyControl::New(true);
1400 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1401 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1402 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1404 application.GetScene().Add(actor);
1406 application.SendNotification();
1407 application.Render();
1409 // Trigger count is 2 - load & render a frame
1410 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1412 Renderer renderer = actor.GetRendererAt(0u);
1413 DALI_TEST_CHECK(renderer);
1415 Vector2 controlSize(20.f, 30.f);
1416 actor.SetProperty(Actor::Property::SIZE, controlSize);
1418 application.SendNotification();
1419 application.Render();
1421 application.SendNotification();
1422 application.Render();
1424 // Trigger count is 1 - render a frame
1425 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1427 auto textureSet = renderer.GetTextures();
1428 auto texture = textureSet.GetTexture(0);
1430 DALI_TEST_EQUALS(controlSize.width, texture.GetWidth(), TEST_LOCATION);
1431 DALI_TEST_EQUALS(controlSize.height, texture.GetHeight(), TEST_LOCATION);
1434 Vector3 controlScale(2.0f, 2.0f, 1.0f);
1435 actor.SetProperty(Actor::Property::SCALE, controlScale);
1437 application.SendNotification();
1438 application.Render();
1440 application.SendNotification();
1441 application.Render();
1443 // Trigger count is 1 - render a frame
1444 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1446 renderer = actor.GetRendererAt(0u);
1447 DALI_TEST_CHECK(renderer);
1449 textureSet = renderer.GetTextures();
1450 texture = textureSet.GetTexture(0);
1452 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1453 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1456 controlSize = Vector2(50.0f, 100.0f);
1457 Animation animation = Animation::New(1.0);
1458 animation.AnimateTo(Property(actor, Actor::Property::SIZE), Vector3(controlSize.x, controlSize.y, 0.0f));
1461 application.SendNotification();
1462 application.Render(1100); // After the animation
1464 application.SendNotification();
1465 application.Render();
1467 // Trigger count is 1 - render a frame
1468 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1470 renderer = actor.GetRendererAt(0u);
1471 DALI_TEST_CHECK(renderer);
1473 textureSet = renderer.GetTextures();
1474 texture = textureSet.GetTexture(0);
1476 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1477 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1482 int UtcDaliAnimatedVectorImageVisualMultipleInstances(void)
1484 ToolkitTestApplication application;
1485 tet_infoline("UtcDaliAnimatedVectorImageVisualMultipleInstances");
1487 Property::Map propertyMap;
1488 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1489 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1491 Visual::Base visual1 = VisualFactory::Get().CreateVisual(propertyMap);
1492 DALI_TEST_CHECK(visual1);
1494 DummyControl actor1 = DummyControl::New(true);
1495 DummyControlImpl& dummyImpl1 = static_cast<DummyControlImpl&>(actor1.GetImplementation());
1496 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual1);
1498 Vector2 controlSize(20.f, 30.f);
1499 actor1.SetProperty(Actor::Property::SIZE, controlSize);
1501 application.GetScene().Add(actor1);
1503 propertyMap.Clear();
1504 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1505 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1507 Visual::Base visual2 = VisualFactory::Get().CreateVisual(propertyMap);
1508 DALI_TEST_CHECK(visual2);
1510 DummyControl actor2 = DummyControl::New(true);
1511 DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor2.GetImplementation());
1512 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
1514 actor2.SetProperty(Actor::Property::SIZE, controlSize);
1516 application.GetScene().Add(actor2);
1518 application.SendNotification();
1519 application.Render();
1521 // Trigger count is 4 - load & render a frame for each instance
1522 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1524 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1526 // To make event trigger
1527 actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1529 application.SendNotification();
1530 application.Render();
1532 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1534 Property::Map attributes;
1535 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1537 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1538 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1540 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1542 // renderer is added to actor
1543 DALI_TEST_CHECK(actor1.GetRendererCount() == 1u);
1544 Renderer renderer1 = actor1.GetRendererAt(0u);
1545 DALI_TEST_CHECK(renderer1);
1547 // renderer is added to actor
1548 DALI_TEST_CHECK(actor2.GetRendererCount() == 1u);
1549 Renderer renderer2 = actor2.GetRendererAt(0u);
1550 DALI_TEST_CHECK(renderer2);
1555 int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void)
1557 ToolkitTestApplication application;
1558 tet_infoline("UtcDaliAnimatedVectorImageVisualControlVisibilityChanged");
1560 Property::Map propertyMap;
1561 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1562 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1564 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1565 DALI_TEST_CHECK(visual);
1567 DummyControl actor = DummyControl::New(true);
1568 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1569 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1571 Vector2 controlSize(20.f, 30.f);
1572 actor.SetProperty(Actor::Property::SIZE, controlSize);
1574 application.GetScene().Add(actor);
1576 application.SendNotification();
1577 application.Render();
1579 // Trigger count is 2 - load & render a frame
1580 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1582 Property::Map attributes;
1583 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1585 application.SendNotification();
1586 application.Render();
1588 // Check rendering behavior
1589 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1590 Renderer renderer = actor.GetRendererAt(0u);
1591 DALI_TEST_CHECK(renderer);
1592 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1594 actor.SetProperty(Actor::Property::VISIBLE, false);
1596 application.SendNotification();
1597 application.Render();
1599 // Check rendering behavior again
1600 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1605 int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void)
1607 ToolkitTestApplication application;
1608 tet_infoline("UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged");
1610 Property::Map propertyMap;
1611 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1612 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1614 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1615 DALI_TEST_CHECK(visual);
1617 DummyControl actor = DummyControl::New(true);
1618 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1619 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1621 Vector2 controlSize(20.f, 30.f);
1622 actor.SetProperty(Actor::Property::SIZE, controlSize);
1624 application.GetScene().Add(actor);
1626 application.SendNotification();
1627 application.Render();
1629 // Trigger count is 2 - load & render a frame
1630 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1632 Property::Map attributes;
1633 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1635 application.SendNotification();
1636 application.Render();
1638 // Check rendering behavior
1639 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1640 Renderer renderer = actor.GetRendererAt(0u);
1641 DALI_TEST_CHECK(renderer);
1642 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1644 Window window = DevelWindow::Get(actor);
1647 application.SendNotification();
1648 application.Render();
1650 // Check rendering behavior again
1651 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1656 int UtcDaliAnimatedVectorImageVisualInvalidFile01(void)
1658 ToolkitTestApplication application;
1659 tet_infoline("Request loading with invalid file - should draw broken image");
1661 TestGlAbstraction& gl = application.GetGlAbstraction();
1662 TraceCallStack& textureTrace = gl.GetTextureTrace();
1663 textureTrace.Enable(true);
1665 Property::Map propertyMap;
1666 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1667 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
1669 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1670 DALI_TEST_CHECK(visual);
1672 DummyControl actor = DummyControl::New(true);
1673 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1674 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1676 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1678 application.GetScene().Add(actor);
1680 application.SendNotification();
1681 application.Render();
1683 // Trigger count is 1 - load
1684 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1686 application.SendNotification();
1687 application.Render();
1689 // Check resource status
1690 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1691 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1693 // The broken image should be shown.
1694 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1695 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1700 int UtcDaliAnimatedVectorImageVisualInvalidFile02(void)
1702 ToolkitTestApplication application;
1703 tet_infoline("Request loading with invalid file - should draw broken image");
1705 TestGlAbstraction& gl = application.GetGlAbstraction();
1706 TraceCallStack& textureTrace = gl.GetTextureTrace();
1707 textureTrace.Enable(true);
1709 Property::Map propertyMap;
1710 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1711 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
1713 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1714 DALI_TEST_CHECK(visual);
1716 DummyControl actor = DummyControl::New(true);
1717 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1718 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1720 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1722 application.SendNotification();
1723 application.Render();
1725 // Trigger count is 1 - load
1726 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1728 // Add to the Scene after loading
1729 application.GetScene().Add(actor);
1731 application.SendNotification();
1732 application.Render();
1734 // Check resource status
1735 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1736 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1738 // The broken image should be shown.
1739 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1740 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1745 int UtcDaliAnimatedVectorImageVisualInvalidFile03(void)
1747 ToolkitTestApplication application;
1748 tet_infoline("Request loading with invalid file without size set - should draw broken image");
1750 TestGlAbstraction& gl = application.GetGlAbstraction();
1751 TraceCallStack& textureTrace = gl.GetTextureTrace();
1752 textureTrace.Enable(true);
1754 Property::Map propertyMap;
1755 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1756 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
1758 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1759 DALI_TEST_CHECK(visual);
1761 DummyControl actor = DummyControl::New(true);
1762 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1763 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1765 application.GetScene().Add(actor);
1767 application.SendNotification();
1768 application.Render();
1770 // Trigger count is 1 - load
1771 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1773 application.SendNotification();
1774 application.Render();
1776 // Check resource status
1777 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1778 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1780 // The broken image should be shown.
1781 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1782 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1787 int UtcDaliAnimatedVectorImageVisualFrameDrops(void)
1789 ToolkitTestApplication application;
1790 tet_infoline("UtcDaliAnimatedVectorImageVisualFrameDrops");
1792 Property::Map propertyMap;
1793 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1794 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP);
1796 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1797 DALI_TEST_CHECK(visual);
1799 DummyControl actor = DummyControl::New(true);
1800 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1801 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1803 Vector2 controlSize(20.f, 30.f);
1804 actor.SetProperty(Actor::Property::SIZE, controlSize);
1806 application.GetScene().Add(actor);
1808 application.SendNotification();
1809 application.Render();
1811 // Trigger count is 2 - load, render the first frame
1812 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1814 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1815 Property::Value* value = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1816 int totalFrameNumber = value->Get<int>();
1818 Property::Map attributes;
1819 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1821 // Make delay to drop frames
1822 Test::VectorAnimationRenderer::DelayRendering(170); // longer than 16.6 * 10frames
1824 application.SendNotification();
1825 application.Render();
1827 // Trigger count is 1 - calculating frame drops
1828 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1830 // Check dropped frame
1831 uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames();
1832 DALI_TEST_CHECK(frames > 0);
1833 DALI_TEST_CHECK(frames <= static_cast<uint32_t>(totalFrameNumber));
1838 int UtcDaliAnimatedVectorImageVisualSize(void)
1840 ToolkitTestApplication application;
1841 tet_infoline("UtcDaliAnimatedVectorImageVisualSize");
1843 TestGlAbstraction& gl = application.GetGlAbstraction();
1844 TraceCallStack& textureTrace = gl.GetTextureTrace();
1846 VisualFactory factory = VisualFactory::Get();
1847 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
1848 DALI_TEST_CHECK(visual);
1850 DummyControl actor = DummyControl::New(true);
1851 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1852 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1854 application.GetScene().Add(actor);
1856 application.SendNotification();
1858 // Trigger count is 1 - load
1859 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1861 application.SendNotification();
1862 application.Render();
1864 // Trigger count is 1 - resource ready
1865 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1867 textureTrace.Enable(true);
1869 application.SendNotification();
1870 application.Render();
1873 int width = 100, height = 100; // 100x100 is the content default size.
1874 std::stringstream out;
1875 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
1876 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
1879 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
1881 application.SendNotification();
1882 application.Render();
1884 // Trigger count is 1 - resource ready
1885 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1887 textureTrace.Reset();
1889 application.SendNotification();
1890 application.Render();
1893 int width = 200, height = 200;
1894 std::stringstream out;
1895 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
1896 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));