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>
38 #include <dali/devel-api/adaptor-framework/vector-animation-renderer.h>
39 #include <dali/devel-api/adaptor-framework/window-devel.h>
40 #include <dali/devel-api/rendering/renderer-devel.h>
43 using namespace Dali::Toolkit;
45 void dali_animated_vector_image_visual_startup(void)
47 test_return_value = TET_UNDEF;
50 void dali_animated_vector_image_visual_cleanup(void)
52 test_return_value = TET_PASS;
57 const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
58 const char* TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP = "framedrop.json";
59 const char* TEST_VECTOR_IMAGE_INVALID_FILE_NAME = "invalid.json";
61 bool gAnimationFinishedSignalFired = false;
63 void VisualEventSignal(Control control, Dali::Property::Index visualIndex, Dali::Property::Index signalId)
65 if(visualIndex == DummyControl::Property::TEST_VISUAL && signalId == DevelAnimatedVectorImageVisual::Signal::ANIMATION_FINISHED)
67 gAnimationFinishedSignalFired = true;
73 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void)
75 ToolkitTestApplication application;
76 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual01: Request animated vector image visual with a json url");
78 VisualFactory factory = VisualFactory::Get();
79 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
80 DALI_TEST_CHECK(visual);
82 DummyControl actor = DummyControl::New(true);
83 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
84 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
85 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
86 application.GetScene().Add(actor);
88 application.SendNotification();
91 // Trigger count is 2 - load & render a frame
92 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
94 // renderer is added to actor
95 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
96 Renderer renderer = actor.GetRendererAt(0u);
97 DALI_TEST_CHECK(renderer);
99 // Test SetOffScene().
101 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
106 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual02(void)
108 ToolkitTestApplication application;
109 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual02: Request animated vector image visual with a Property::Map");
111 Property::Map propertyMap;
112 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
113 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
115 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
116 DALI_TEST_CHECK(visual);
118 DummyControl actor = DummyControl::New(true);
119 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
120 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
121 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
122 application.GetScene().Add(actor);
124 application.SendNotification();
125 application.Render();
127 // Trigger count is 2 - load & render a frame
128 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
130 // renderer is added to actor
131 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
132 Renderer renderer = actor.GetRendererAt(0u);
133 DALI_TEST_CHECK(renderer);
136 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
141 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void)
143 ToolkitTestApplication application;
144 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual03: Request animated vector image visual with a Property::Map");
146 int startFrame = 1, endFrame = 3;
147 Property::Array playRange;
148 playRange.PushBack(startFrame);
149 playRange.PushBack(endFrame);
151 Property::Map propertyMap;
152 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
153 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
154 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
155 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
156 .Add(DevelVisual::Property::CORNER_RADIUS, 50.0f)
157 .Add(DevelVisual::Property::BORDERLINE_WIDTH, 20.0f);
159 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
160 DALI_TEST_CHECK(visual);
162 DummyControl actor = DummyControl::New(true);
163 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
164 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
165 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
166 application.GetScene().Add(actor);
168 application.SendNotification();
169 application.Render();
171 // Trigger count is 2 - load & render a frame
172 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
174 // renderer is added to actor
175 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
176 Renderer renderer = actor.GetRendererAt(0u);
177 DALI_TEST_CHECK(renderer);
180 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
185 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void)
187 ToolkitTestApplication application;
188 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map");
190 int startFrame = 1, endFrame = 3;
191 float cornerRadius = 22.0f;
192 float borderlineWidth = 2.0f;
193 Vector4 borderlineColor = Vector4(1.0f, 1.0f, 1.0f, 1.0f);
194 float borderlineOffset = 0.1f;
195 Property::Array playRange;
196 playRange.PushBack(startFrame);
197 playRange.PushBack(endFrame);
199 Property::Map propertyMap;
200 propertyMap.Add("visualType", DevelVisual::ANIMATED_VECTOR_IMAGE)
201 .Add("url", TEST_VECTOR_IMAGE_FILE_NAME)
203 .Add("playRange", playRange)
204 .Add("stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME)
205 .Add("loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE)
206 .Add("redrawInScalingDown", false)
207 .Add("cornerRadius", cornerRadius)
208 .Add("borderlineWidth", borderlineWidth)
209 .Add("borderlineColor", borderlineColor)
210 .Add("borderlineOffset", borderlineOffset);
212 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
213 DALI_TEST_CHECK(visual);
215 DummyControl actor = DummyControl::New(true);
216 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
217 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
218 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
219 application.GetScene().Add(actor);
221 application.SendNotification();
222 application.Render();
224 // Trigger count is 2 - load & render a frame
225 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
227 // renderer is added to actor
228 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
230 Renderer renderer = actor.GetRendererAt(0u);
231 DALI_TEST_CHECK(renderer);
233 Property::Map resultMap;
234 visual.CreatePropertyMap(resultMap);
236 // check the property values from the returned map from a visual
237 Property::Value* value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
238 DALI_TEST_CHECK(value);
239 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
241 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
242 DALI_TEST_CHECK(value);
243 DALI_TEST_CHECK(value->Get<int>() == 3);
245 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
246 DALI_TEST_CHECK(value);
248 Property::Array* result = value->GetArray();
249 DALI_TEST_CHECK(result);
251 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
252 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
254 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
255 DALI_TEST_CHECK(value);
256 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::FIRST_FRAME);
258 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
259 DALI_TEST_CHECK(value);
260 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::AUTO_REVERSE);
262 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
263 DALI_TEST_CHECK(value);
264 DALI_TEST_CHECK(value->Get<bool>() == false);
266 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
267 DALI_TEST_CHECK(value);
268 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius), TEST_LOCATION);
270 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
271 DALI_TEST_CHECK(value);
272 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
274 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT);
275 DALI_TEST_CHECK(value);
276 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
278 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
279 DALI_TEST_CHECK(value);
280 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
282 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
283 DALI_TEST_CHECK(value);
284 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
287 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
292 int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
294 ToolkitTestApplication application;
295 tet_infoline("UtcDaliAnimatedVectorImageVisualGetPropertyMap01");
297 int startFrame = 1, endFrame = 3;
298 Vector4 cornerRadius(50.0f, 22.0f, 0.0f, 3.0f);
299 float borderlineWidth = 2.3f;
300 Vector4 borderlineColor = Vector4(0.3f, 0.3f, 1.0f, 1.0f);
301 float borderlineOffset = 0.3f;
302 Property::Array playRange;
303 playRange.PushBack(startFrame);
304 playRange.PushBack(endFrame);
306 Property::Map propertyMap;
307 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
308 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
309 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
310 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
311 .Add(DevelVisual::Property::CORNER_RADIUS, cornerRadius)
312 .Add(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::RELATIVE)
313 .Add(DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth)
314 .Add(DevelVisual::Property::BORDERLINE_COLOR, borderlineColor)
315 .Add(DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset);
317 // request AnimatedVectorImageVisual with a property map
318 VisualFactory factory = VisualFactory::Get();
319 Visual::Base visual = factory.CreateVisual(propertyMap);
321 DummyControl actor = DummyControl::New(true);
322 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
323 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
325 Vector2 controlSize(20.f, 30.f);
326 actor.SetProperty(Actor::Property::SIZE, controlSize);
328 application.GetScene().Add(actor);
330 application.SendNotification();
331 application.Render();
333 // Trigger count is 2 - load & render a frame
334 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
336 Property::Map resultMap;
337 resultMap = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
339 // check the property values from the returned map from a visual
340 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
341 DALI_TEST_CHECK(value);
342 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
344 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
345 DALI_TEST_CHECK(value);
346 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
348 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
349 DALI_TEST_CHECK(value);
350 DALI_TEST_CHECK(value->Get<int>() == 3);
352 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
353 DALI_TEST_CHECK(value);
355 Property::Array* result = value->GetArray();
356 DALI_TEST_CHECK(result);
358 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
359 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
361 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
362 DALI_TEST_CHECK(value);
363 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::CURRENT_FRAME);
365 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
366 DALI_TEST_CHECK(value);
367 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::RESTART);
369 value = resultMap.Find(DevelImageVisual::Property::CONTENT_INFO, Property::MAP);
370 DALI_TEST_CHECK(value);
372 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
373 DALI_TEST_CHECK(value);
374 DALI_TEST_CHECK(value->Get<bool>() == true); // Check default value
376 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
377 DALI_TEST_CHECK(value);
378 DALI_TEST_EQUALS(value->Get<Vector4>(), cornerRadius, TEST_LOCATION);
380 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
381 DALI_TEST_CHECK(value);
382 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::RELATIVE);
384 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
385 DALI_TEST_CHECK(value);
386 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
388 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
389 DALI_TEST_CHECK(value);
390 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
392 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
393 DALI_TEST_CHECK(value);
394 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
396 // request AnimatedVectorImageVisual with an URL
397 Visual::Base visual2 = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
400 visual2.CreatePropertyMap(resultMap);
402 // check the property values from the returned map from a visual
403 value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
404 DALI_TEST_CHECK(value);
405 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
407 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
408 DALI_TEST_CHECK(value);
409 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
414 int UtcDaliAnimatedVectorImageVisualPlayback(void)
416 ToolkitTestApplication application;
418 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayback");
421 // request AnimatedVectorImageVisual with a property map
422 VisualFactory factory = VisualFactory::Get();
423 Visual::Base visual = factory.CreateVisual(
425 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
426 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME));
428 DummyControl dummyControl = DummyControl::New(true);
429 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
430 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
431 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
433 Property::Map attributes;
434 tet_infoline("Test Play action");
435 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
437 application.GetScene().Add(dummyControl);
438 application.SendNotification();
439 application.Render(16);
441 Property::Map map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
442 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
443 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
445 tet_infoline("Test Pause action");
446 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
448 application.SendNotification();
449 application.Render(16);
451 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
452 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
453 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PAUSED);
455 tet_infoline("Test Play action");
456 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
458 application.SendNotification();
459 application.Render(16);
461 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
462 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
463 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
465 tet_infoline("Test Stop action");
466 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
468 application.SendNotification();
469 application.Render(16);
471 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
472 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
473 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
475 tet_infoline("Test Stop action again");
476 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
478 application.SendNotification();
479 application.Render(16);
481 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
482 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
483 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
485 tet_infoline("Test Play action");
486 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
488 application.SendNotification();
489 application.Render(16);
491 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
492 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
493 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
495 tet_infoline("Off stage");
496 dummyControl.Unparent();
498 application.SendNotification();
499 application.Render(16);
501 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
502 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
503 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
505 tet_infoline("On stage again");
506 application.GetScene().Add(dummyControl);
508 application.SendNotification();
509 application.Render(16);
511 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
512 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
513 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
515 tet_infoline("Test Play action");
516 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
518 application.SendNotification();
519 application.Render(16);
521 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
522 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
523 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
526 Vector3 newSize(100.0f, 100.0f, 0.0f);
527 dummyControl.SetProperty(Actor::Property::SIZE, newSize);
529 application.SendNotification();
530 application.Render(16);
532 // Size should be changed
533 Vector3 naturalSize = dummyControl.GetNaturalSize();
534 DALI_TEST_CHECK(naturalSize == newSize);
536 dummyControl.Unparent();
542 int UtcDaliAnimatedVectorImageVisualCustomShader(void)
544 ToolkitTestApplication application;
545 tet_infoline("UtcDaliAnimatedVectorImageVisualCustomShader Test custom shader");
547 VisualFactory factory = VisualFactory::Get();
548 Property::Map properties;
549 Property::Map shader;
550 const std::string vertexShader = "Foobar";
551 const std::string fragmentShader = "Foobar sampler2D Foobar";
552 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
553 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
555 properties[Visual::Property::TYPE] = Visual::IMAGE;
556 properties[Visual::Property::SHADER] = shader;
557 properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
559 Visual::Base visual = factory.CreateVisual(properties);
561 // trigger creation through setting on stage
562 DummyControl dummy = DummyControl::New(true);
563 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
564 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
566 dummy.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
567 dummy.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
568 application.GetScene().Add(dummy);
570 application.SendNotification();
571 application.Render();
573 // Trigger count is 2 - load & render a frame
574 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
576 Renderer renderer = dummy.GetRendererAt(0);
577 Shader shader2 = renderer.GetShader();
578 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
579 Property::Map* map = value.GetMap();
580 DALI_TEST_CHECK(map);
582 std::string resultFragmentShader, resultVertexShader;
583 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
584 fragment->Get(resultFragmentShader);
585 DALI_TEST_CHECK(resultFragmentShader.find(fragmentShader) != std::string::npos);
587 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
588 vertex->Get(resultVertexShader);
589 DALI_TEST_CHECK(resultVertexShader.find(vertexShader) != std::string::npos);
594 int UtcDaliAnimatedVectorImageVisualNaturalSize(void)
596 ToolkitTestApplication application;
597 tet_infoline("UtcDaliAnimatedVectorImageVisualNaturalSize");
599 VisualFactory factory = VisualFactory::Get();
600 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
601 DALI_TEST_CHECK(visual);
603 DummyControl actor = DummyControl::New(true);
604 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
605 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
607 Vector2 controlSize(20.f, 30.f);
610 application.GetScene().Add(actor);
612 application.SendNotification();
613 application.Render();
615 // Trigger count is 1 - load
616 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
618 visual.GetNaturalSize(naturalSize);
620 DALI_TEST_EQUALS(naturalSize, Vector2(100.0f, 100.0f), TEST_LOCATION); // 100x100 is the content default size.
622 actor.SetProperty(Actor::Property::SIZE, controlSize);
624 application.SendNotification();
625 application.Render();
627 visual.GetNaturalSize(naturalSize);
629 DALI_TEST_EQUALS(naturalSize, controlSize, TEST_LOCATION);
634 int UtcDaliAnimatedVectorImageVisualLoopCount(void)
636 ToolkitTestApplication application;
637 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopCount");
639 Property::Map propertyMap;
640 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
641 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
642 .Add(DevelImageVisual::Property::LOOP_COUNT, 3);
644 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
645 DALI_TEST_CHECK(visual);
647 DummyControl actor = DummyControl::New(true);
648 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
649 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
651 Vector2 controlSize(20.f, 30.f);
652 actor.SetProperty(Actor::Property::SIZE, controlSize);
654 application.GetScene().Add(actor);
656 Property::Map attributes;
657 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
659 application.SendNotification();
660 application.Render();
662 // Trigger count is 2 - load & render a frame
663 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
665 // renderer is added to actor
666 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
667 Renderer renderer = actor.GetRendererAt(0u);
668 DALI_TEST_CHECK(renderer);
673 int UtcDaliAnimatedVectorImageVisualPlayRange(void)
675 ToolkitTestApplication application;
676 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRange");
678 int startFrame = 1, endFrame = 3;
679 Property::Array array;
680 array.PushBack(endFrame);
681 array.PushBack(startFrame);
683 Property::Map propertyMap;
684 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
685 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
686 .Add(DevelImageVisual::Property::PLAY_RANGE, array);
688 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
689 DALI_TEST_CHECK(visual);
691 DummyControl actor = DummyControl::New(true);
692 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
693 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
695 Vector2 controlSize(20.f, 30.f);
696 actor.SetProperty(Actor::Property::SIZE, controlSize);
698 application.GetScene().Add(actor);
700 Property::Map attributes;
701 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
703 application.SendNotification();
704 application.Render();
706 // Trigger count is 2 - load & render a frame
707 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
709 // renderer is added to actor
710 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
711 Renderer renderer = actor.GetRendererAt(0u);
712 DALI_TEST_CHECK(renderer);
714 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
715 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
716 int totalFrameNumber = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER)->Get<int>();
718 int resultStartFrame, resultEndFrame;
719 Property::Array* result = value->GetArray();
720 result->GetElementAt(0).Get(resultStartFrame);
721 result->GetElementAt(1).Get(resultEndFrame);
723 DALI_TEST_EQUALS(startFrame, resultStartFrame, TEST_LOCATION);
724 DALI_TEST_EQUALS(endFrame, resultEndFrame, TEST_LOCATION);
726 // Set invalid play range
732 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
733 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
735 // To make event trigger
736 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
738 application.SendNotification();
739 application.Render();
741 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
743 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
744 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
746 result = value->GetArray();
747 result->GetElementAt(0).Get(resultStartFrame);
748 result->GetElementAt(1).Get(resultEndFrame);
750 DALI_TEST_EQUALS(resultStartFrame, 1, TEST_LOCATION);
751 DALI_TEST_EQUALS(resultEndFrame, totalFrameNumber - 1, TEST_LOCATION); // Should be clamped
753 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, Property::Map());
755 application.SendNotification();
756 application.Render();
758 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
760 // To make event trigger
761 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
763 application.SendNotification();
764 application.Render();
766 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
768 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
769 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
770 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
777 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
778 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
780 // To make event trigger
781 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
783 application.SendNotification();
784 application.Render();
786 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
788 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
789 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
791 result = value->GetArray();
792 result->GetElementAt(0).Get(resultStartFrame);
793 result->GetElementAt(1).Get(resultEndFrame);
795 DALI_TEST_EQUALS(0, resultStartFrame, TEST_LOCATION);
796 DALI_TEST_EQUALS(2, resultEndFrame, TEST_LOCATION);
798 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
799 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION); // CURRENT_FRAME_NUMBER should be changed also.
804 int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void)
806 ToolkitTestApplication application;
807 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRangeMarker");
809 Property::Array array;
810 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
812 Property::Map propertyMap;
813 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
814 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
815 .Add(DevelImageVisual::Property::PLAY_RANGE, array);
817 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
818 DALI_TEST_CHECK(visual);
820 DummyControl actor = DummyControl::New(true);
821 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
822 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
824 Vector2 controlSize(20.f, 30.f);
825 actor.SetProperty(Actor::Property::SIZE, controlSize);
827 application.GetScene().Add(actor);
829 Property::Map attributes;
830 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
832 application.SendNotification();
833 application.Render();
835 // Trigger count is 2 - load & render a frame
836 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
838 // renderer is added to actor
839 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
840 Renderer renderer = actor.GetRendererAt(0u);
841 DALI_TEST_CHECK(renderer);
843 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
844 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
846 int resultStartFrame, resultEndFrame;
847 Property::Array* result = value->GetArray();
848 result->GetElementAt(0).Get(resultStartFrame);
849 result->GetElementAt(1).Get(resultEndFrame);
851 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
852 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
856 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
857 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_2);
860 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
861 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
863 // To make event trigger
864 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
866 application.SendNotification();
867 application.Render();
869 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
871 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
872 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
874 result = value->GetArray();
875 result->GetElementAt(0).Get(resultStartFrame);
876 result->GetElementAt(1).Get(resultEndFrame);
878 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
879 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
881 // Set invalid play range
884 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
887 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
888 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
890 // To make event trigger
891 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
893 application.SendNotification();
894 application.Render();
896 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
898 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
899 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
901 result = value->GetArray();
902 result->GetElementAt(0).Get(resultStartFrame);
903 result->GetElementAt(1).Get(resultEndFrame);
905 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION); // Should not be changed
906 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
911 int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
913 ToolkitTestApplication application;
914 tet_infoline("UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal");
916 Property::Map propertyMap;
917 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
918 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
919 .Add(DevelImageVisual::Property::LOOP_COUNT, 3);
921 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
922 DALI_TEST_CHECK(visual);
924 DummyControl actor = DummyControl::New(true);
925 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
926 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
928 DevelControl::VisualEventSignal(actor).Connect(&VisualEventSignal);
930 Vector2 controlSize(20.f, 30.f);
931 actor.SetProperty(Actor::Property::SIZE, controlSize);
933 application.GetScene().Add(actor);
935 Property::Map attributes;
936 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
938 application.SendNotification();
939 application.Render();
941 // Wait for animation finish - load, render, finish
942 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
944 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
945 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
946 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
948 DALI_TEST_EQUALS(gAnimationFinishedSignalFired, true, TEST_LOCATION);
953 int UtcDaliAnimatedVectorImageVisualJumpTo(void)
955 ToolkitTestApplication application;
956 tet_infoline("UtcDaliAnimatedVectorImageVisualJumpTo");
958 Property::Map propertyMap;
959 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
960 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
961 .Add(DevelImageVisual::Property::LOOP_COUNT, 3);
963 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
964 DALI_TEST_CHECK(visual);
966 tet_printf("1. Visual is created.\n");
968 DummyControl actor = DummyControl::New(true);
969 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
970 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
972 Vector2 controlSize(20.f, 30.f);
973 actor.SetProperty(Actor::Property::SIZE, controlSize);
975 application.GetScene().Add(actor);
977 application.SendNotification();
978 application.Render();
980 // Trigger count is 2 - load & render a frame
981 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
983 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2);
985 // To make event trigger
986 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
988 application.SendNotification();
989 application.Render();
991 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
993 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
994 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
995 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
997 tet_printf("2. The current frame number is [%d].\n", value->Get<int>());
999 Property::Array array;
1003 Property::Map attributes;
1004 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1005 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1007 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1009 // To make event trigger
1010 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1012 application.SendNotification();
1013 application.Render();
1015 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
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>(), 2, TEST_LOCATION);
1021 tet_printf("3. The current frame number is [%d].\n", value->Get<int>());
1023 // Change play range
1030 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1031 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1034 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1036 application.SendNotification();
1037 application.Render();
1039 // Wait for animation finish
1040 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1043 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1045 // To make event trigger
1046 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1048 application.SendNotification();
1049 application.Render();
1051 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1053 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1054 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1055 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1057 tet_printf("4. The current frame number is [%d].\n", value->Get<int>());
1059 // Jump to the same position
1060 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1062 // To make event trigger
1063 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1065 application.SendNotification();
1066 application.Render();
1068 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1070 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1071 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1072 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1074 tet_printf("5. The current frame number is [%d].\n", value->Get<int>());
1079 int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
1081 ToolkitTestApplication application;
1082 tet_infoline("UtcDaliAnimatedVectorImageVisualUpdateProperty");
1084 int startFrame = 1, endFrame = 3;
1085 Property::Array playRange;
1086 playRange.PushBack(startFrame);
1087 playRange.PushBack(endFrame);
1089 Property::Map propertyMap;
1090 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1091 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1092 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1093 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1095 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1096 DALI_TEST_CHECK(visual);
1098 DummyControl actor = DummyControl::New(true);
1099 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1100 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1102 Vector2 controlSize(20.f, 30.f);
1103 actor.SetProperty(Actor::Property::SIZE, controlSize);
1105 application.GetScene().Add(actor);
1107 application.SendNotification();
1108 application.Render();
1110 // Trigger count is 2 - load & render a frame
1111 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1113 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1114 Property::Value* value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1115 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1117 value = map.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
1118 DALI_TEST_CHECK(value);
1120 Property::Array* result = value->GetArray();
1121 DALI_TEST_CHECK(result);
1123 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1124 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1127 playRange.PushBack(0);
1128 playRange.PushBack(2);
1130 Property::Map attributes;
1131 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1132 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 5);
1134 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1136 // To make event trigger
1137 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1139 application.SendNotification();
1140 application.Render();
1142 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1144 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1145 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1146 DALI_TEST_EQUALS(value->Get<int>(), 5, TEST_LOCATION);
1148 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1149 result = value->GetArray();
1150 DALI_TEST_CHECK(result);
1152 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == 0);
1153 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == 2);
1158 playRange.PushBack(startFrame);
1159 playRange.PushBack(endFrame);
1161 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1163 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1165 // To make event trigger
1166 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1168 application.SendNotification();
1169 application.Render();
1171 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1173 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1174 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1176 result = value->GetArray();
1177 DALI_TEST_CHECK(result);
1179 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1180 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1182 // Play and update property
1184 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1186 application.SendNotification();
1187 application.Render();
1189 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 10);
1191 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1193 application.SendNotification();
1194 application.Render();
1196 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1197 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1198 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
1203 int UtcDaliAnimatedVectorImageVisualStopBehavior(void)
1205 ToolkitTestApplication application;
1206 tet_infoline("UtcDaliAnimatedVectorImageVisualStopBehavior");
1208 Property::Map propertyMap;
1209 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1210 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1211 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1212 .Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
1214 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1215 DALI_TEST_CHECK(visual);
1217 DummyControl actor = DummyControl::New(true);
1218 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1219 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1221 Vector2 controlSize(20.f, 30.f);
1222 actor.SetProperty(Actor::Property::SIZE, controlSize);
1224 application.GetScene().Add(actor);
1226 Property::Map attributes;
1227 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1229 application.SendNotification();
1230 application.Render();
1232 // Trigger count is 3 - load, render, animation finished
1233 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1235 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1236 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1237 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1239 // Change stop behavior
1240 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1242 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1247 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1249 application.SendNotification();
1250 application.Render();
1252 // Trigger count is 1 - animation finished
1253 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1255 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1257 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1258 int totalFrameNumber = value1->Get<int>();
1260 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1261 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1263 // Change stop behavior
1264 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1265 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, -1);
1267 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1272 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1274 application.SendNotification();
1275 application.Render();
1278 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
1280 // To make event trigger
1281 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1283 application.SendNotification();
1284 application.Render();
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 int currentFrameNumber = value->Get<int>();
1293 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
1295 // To make event trigger
1296 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1298 application.SendNotification();
1299 application.Render();
1301 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1303 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1304 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1305 DALI_TEST_EQUALS(value->Get<int>(), currentFrameNumber, TEST_LOCATION); // Should be same with currentFrameNumber
1310 int UtcDaliAnimatedVectorImageVisualLoopingMode(void)
1312 ToolkitTestApplication application;
1313 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopingMode");
1315 Property::Map propertyMap;
1316 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1317 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1318 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1319 .Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME)
1320 .Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::AUTO_REVERSE);
1322 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1323 DALI_TEST_CHECK(visual);
1325 DummyControl actor = DummyControl::New(true);
1326 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1327 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1329 Vector2 controlSize(20.f, 30.f);
1330 actor.SetProperty(Actor::Property::SIZE, controlSize);
1332 application.GetScene().Add(actor);
1334 Property::Map attributes;
1335 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1337 application.SendNotification();
1338 application.Render();
1340 // Trigger count is 3 - load, render, animation finished
1341 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1343 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1344 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1345 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame because of auto reverse
1347 // Change stop behavior
1348 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1350 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1353 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1355 application.SendNotification();
1356 application.Render();
1358 // Trigger count is 1 - animation finished
1359 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1361 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1362 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1363 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1365 // Change looping mode
1366 attributes.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::RESTART);
1368 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1371 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1373 application.SendNotification();
1374 application.Render();
1376 // Trigger count is 1 - animation finished
1377 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1379 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1380 int totalFrameNumber = value1->Get<int>();
1382 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1383 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1384 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1389 int UtcDaliAnimatedVectorImageVisualPropertyNotification(void)
1391 ToolkitTestApplication application;
1392 tet_infoline("UtcDaliAnimatedVectorImageVisualPropertyNotification");
1394 Property::Map propertyMap;
1395 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1396 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1398 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1399 DALI_TEST_CHECK(visual);
1401 DummyControl actor = DummyControl::New(true);
1402 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1403 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1404 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1406 application.GetScene().Add(actor);
1408 application.SendNotification();
1409 application.Render();
1411 // Trigger count is 2 - load & render a frame
1412 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1414 Renderer renderer = actor.GetRendererAt(0u);
1415 DALI_TEST_CHECK(renderer);
1417 Vector2 controlSize(20.f, 30.f);
1418 actor.SetProperty(Actor::Property::SIZE, controlSize);
1420 application.SendNotification();
1421 application.Render();
1423 application.SendNotification();
1424 application.Render();
1426 // Trigger count is 1 - render a frame
1427 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1429 auto textureSet = renderer.GetTextures();
1430 auto texture = textureSet.GetTexture(0);
1432 DALI_TEST_EQUALS(controlSize.width, texture.GetWidth(), TEST_LOCATION);
1433 DALI_TEST_EQUALS(controlSize.height, texture.GetHeight(), TEST_LOCATION);
1436 Vector3 controlScale(2.0f, 2.0f, 1.0f);
1437 actor.SetProperty(Actor::Property::SCALE, controlScale);
1439 application.SendNotification();
1440 application.Render();
1442 application.SendNotification();
1443 application.Render();
1445 // Trigger count is 1 - render a frame
1446 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1448 renderer = actor.GetRendererAt(0u);
1449 DALI_TEST_CHECK(renderer);
1451 textureSet = renderer.GetTextures();
1452 texture = textureSet.GetTexture(0);
1454 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1455 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1458 controlSize = Vector2(50.0f, 100.0f);
1459 Animation animation = Animation::New(1.0);
1460 animation.AnimateTo(Property(actor, Actor::Property::SIZE), Vector3(controlSize.x, controlSize.y, 0.0f));
1463 application.SendNotification();
1464 application.Render(1100); // After the animation
1466 application.SendNotification();
1467 application.Render();
1469 // Trigger count is 1 - render a frame
1470 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1472 renderer = actor.GetRendererAt(0u);
1473 DALI_TEST_CHECK(renderer);
1475 textureSet = renderer.GetTextures();
1476 texture = textureSet.GetTexture(0);
1478 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1479 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1484 int UtcDaliAnimatedVectorImageVisualMultipleInstances(void)
1486 ToolkitTestApplication application;
1487 tet_infoline("UtcDaliAnimatedVectorImageVisualMultipleInstances");
1489 Property::Map propertyMap;
1490 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1491 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1493 Visual::Base visual1 = VisualFactory::Get().CreateVisual(propertyMap);
1494 DALI_TEST_CHECK(visual1);
1496 DummyControl actor1 = DummyControl::New(true);
1497 DummyControlImpl& dummyImpl1 = static_cast<DummyControlImpl&>(actor1.GetImplementation());
1498 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual1);
1500 Vector2 controlSize(20.f, 30.f);
1501 actor1.SetProperty(Actor::Property::SIZE, controlSize);
1503 application.GetScene().Add(actor1);
1505 propertyMap.Clear();
1506 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1507 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1509 Visual::Base visual2 = VisualFactory::Get().CreateVisual(propertyMap);
1510 DALI_TEST_CHECK(visual2);
1512 DummyControl actor2 = DummyControl::New(true);
1513 DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor2.GetImplementation());
1514 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
1516 actor2.SetProperty(Actor::Property::SIZE, controlSize);
1518 application.GetScene().Add(actor2);
1520 application.SendNotification();
1521 application.Render();
1523 // Trigger count is 4 - load & render a frame for each instance
1524 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1526 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1528 // To make event trigger
1529 actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1531 application.SendNotification();
1532 application.Render();
1534 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1536 Property::Map attributes;
1537 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1539 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1540 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1542 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1544 // renderer is added to actor
1545 DALI_TEST_CHECK(actor1.GetRendererCount() == 1u);
1546 Renderer renderer1 = actor1.GetRendererAt(0u);
1547 DALI_TEST_CHECK(renderer1);
1549 // renderer is added to actor
1550 DALI_TEST_CHECK(actor2.GetRendererCount() == 1u);
1551 Renderer renderer2 = actor2.GetRendererAt(0u);
1552 DALI_TEST_CHECK(renderer2);
1557 int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void)
1559 ToolkitTestApplication application;
1560 tet_infoline("UtcDaliAnimatedVectorImageVisualControlVisibilityChanged");
1562 Property::Map propertyMap;
1563 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1564 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1566 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1567 DALI_TEST_CHECK(visual);
1569 DummyControl actor = DummyControl::New(true);
1570 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1571 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1573 Vector2 controlSize(20.f, 30.f);
1574 actor.SetProperty(Actor::Property::SIZE, controlSize);
1576 application.GetScene().Add(actor);
1578 application.SendNotification();
1579 application.Render();
1581 // Trigger count is 2 - load & render a frame
1582 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1584 Property::Map attributes;
1585 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1587 application.SendNotification();
1588 application.Render();
1590 // Check rendering behavior
1591 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1592 Renderer renderer = actor.GetRendererAt(0u);
1593 DALI_TEST_CHECK(renderer);
1594 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1596 actor.SetProperty(Actor::Property::VISIBLE, false);
1598 application.SendNotification();
1599 application.Render();
1601 // Check rendering behavior again
1602 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1607 int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void)
1609 ToolkitTestApplication application;
1610 tet_infoline("UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged");
1612 Property::Map propertyMap;
1613 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1614 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1616 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1617 DALI_TEST_CHECK(visual);
1619 DummyControl actor = DummyControl::New(true);
1620 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1621 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1623 Vector2 controlSize(20.f, 30.f);
1624 actor.SetProperty(Actor::Property::SIZE, controlSize);
1626 application.GetScene().Add(actor);
1628 application.SendNotification();
1629 application.Render();
1631 // Trigger count is 2 - load & render a frame
1632 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1634 Property::Map attributes;
1635 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1637 application.SendNotification();
1638 application.Render();
1640 // Check rendering behavior
1641 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1642 Renderer renderer = actor.GetRendererAt(0u);
1643 DALI_TEST_CHECK(renderer);
1644 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1646 Window window = DevelWindow::Get(actor);
1649 application.SendNotification();
1650 application.Render();
1652 // Check rendering behavior again
1653 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1658 int UtcDaliAnimatedVectorImageVisualInvalidFile01(void)
1660 ToolkitTestApplication application;
1661 tet_infoline("Request loading with invalid file - should draw broken image");
1663 TestGlAbstraction& gl = application.GetGlAbstraction();
1664 TraceCallStack& textureTrace = gl.GetTextureTrace();
1665 textureTrace.Enable(true);
1667 Property::Map propertyMap;
1668 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1669 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
1671 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1672 DALI_TEST_CHECK(visual);
1674 DummyControl actor = DummyControl::New(true);
1675 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1676 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1678 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1680 application.GetScene().Add(actor);
1682 application.SendNotification();
1683 application.Render();
1685 // Trigger count is 1 - load
1686 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1688 application.SendNotification();
1689 application.Render();
1691 // Check resource status
1692 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1693 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1695 // The broken image should be shown.
1696 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1697 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1702 int UtcDaliAnimatedVectorImageVisualInvalidFile02(void)
1704 ToolkitTestApplication application;
1705 tet_infoline("Request loading with invalid file - should draw broken image");
1707 TestGlAbstraction& gl = application.GetGlAbstraction();
1708 TraceCallStack& textureTrace = gl.GetTextureTrace();
1709 textureTrace.Enable(true);
1711 Property::Map propertyMap;
1712 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1713 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
1715 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1716 DALI_TEST_CHECK(visual);
1718 DummyControl actor = DummyControl::New(true);
1719 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1720 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1722 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1724 application.SendNotification();
1725 application.Render();
1727 // Trigger count is 1 - load
1728 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1730 // Add to the Scene after loading
1731 application.GetScene().Add(actor);
1733 application.SendNotification();
1734 application.Render();
1736 // Check resource status
1737 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1738 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1740 // The broken image should be shown.
1741 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1742 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1747 int UtcDaliAnimatedVectorImageVisualInvalidFile03(void)
1749 ToolkitTestApplication application;
1750 tet_infoline("Request loading with invalid file without size set - should draw broken image");
1752 TestGlAbstraction& gl = application.GetGlAbstraction();
1753 TraceCallStack& textureTrace = gl.GetTextureTrace();
1754 textureTrace.Enable(true);
1756 Property::Map propertyMap;
1757 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1758 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
1760 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1761 DALI_TEST_CHECK(visual);
1763 DummyControl actor = DummyControl::New(true);
1764 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1765 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1767 application.GetScene().Add(actor);
1769 application.SendNotification();
1770 application.Render();
1772 // Trigger count is 1 - load
1773 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1775 application.SendNotification();
1776 application.Render();
1778 // Check resource status
1779 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1780 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1782 // The broken image should be shown.
1783 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1784 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1789 int UtcDaliAnimatedVectorImageVisualFrameDrops(void)
1791 ToolkitTestApplication application;
1792 tet_infoline("UtcDaliAnimatedVectorImageVisualFrameDrops");
1794 Property::Map propertyMap;
1795 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1796 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP);
1798 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1799 DALI_TEST_CHECK(visual);
1801 DummyControl actor = DummyControl::New(true);
1802 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1803 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1805 Vector2 controlSize(20.f, 30.f);
1806 actor.SetProperty(Actor::Property::SIZE, controlSize);
1808 application.GetScene().Add(actor);
1810 application.SendNotification();
1811 application.Render();
1813 // Trigger count is 2 - load, render the first frame
1814 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1816 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1817 Property::Value* value = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1818 int totalFrameNumber = value->Get<int>();
1820 Property::Map attributes;
1821 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1823 // Make delay to drop frames
1824 Test::VectorAnimationRenderer::DelayRendering(170); // longer than 16.6 * 10frames
1826 application.SendNotification();
1827 application.Render();
1829 // Trigger count is 1 - calculating frame drops
1830 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1832 // Check dropped frame
1833 uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames();
1834 DALI_TEST_CHECK(frames > 0);
1835 DALI_TEST_CHECK(frames <= static_cast<uint32_t>(totalFrameNumber));
1840 int UtcDaliAnimatedVectorImageVisualSize(void)
1842 ToolkitTestApplication application;
1843 tet_infoline("UtcDaliAnimatedVectorImageVisualSize");
1845 TestGlAbstraction& gl = application.GetGlAbstraction();
1846 TraceCallStack& textureTrace = gl.GetTextureTrace();
1848 VisualFactory factory = VisualFactory::Get();
1849 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
1850 DALI_TEST_CHECK(visual);
1852 DummyControl actor = DummyControl::New(true);
1853 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1854 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1856 application.GetScene().Add(actor);
1858 application.SendNotification();
1860 // Trigger count is 1 - load
1861 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1863 application.SendNotification();
1864 application.Render();
1866 // Trigger count is 1 - resource ready
1867 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1869 textureTrace.Enable(true);
1871 application.SendNotification();
1872 application.Render();
1875 int width = 100, height = 100; // 100x100 is the content default size.
1876 std::stringstream out;
1877 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
1878 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
1881 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
1883 application.SendNotification();
1884 application.Render();
1886 // Trigger count is 1 - resource ready
1887 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1889 textureTrace.Reset();
1891 application.SendNotification();
1892 application.Render();
1895 int width = 200, height = 200;
1896 std::stringstream out;
1897 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
1898 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
1906 bool gDynamicPropertyCallbackFired = false;
1908 Property::Value FillColorCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber)
1910 gDynamicPropertyCallbackFired = true;
1914 return Vector3(0, 0, 1);
1918 return Vector3(1, 0, 0);
1923 int UtcDaliAnimatedVectorImageVisualDynamicProperty(void)
1925 ToolkitTestApplication application;
1926 tet_infoline("UtcDaliAnimatedVectorImageVisualDynamicProperty");
1928 VisualFactory factory = VisualFactory::Get();
1929 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
1930 DALI_TEST_CHECK(visual);
1932 DummyControl actor = DummyControl::New(true);
1933 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1934 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1936 application.GetScene().Add(actor);
1938 gDynamicPropertyCallbackFired = false;
1940 // Set dynamic property
1941 DevelAnimatedVectorImageVisual::DynamicPropertyInfo info;
1943 info.keyPath = "Test.Path";
1944 info.property = static_cast<int>(VectorAnimationRenderer::VectorProperty::FILL_COLOR);
1945 info.callback = MakeCallback(FillColorCallback);
1947 DevelControl::DoActionExtension(actor, DummyControl::Property::TEST_VISUAL, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info));
1949 Property::Map attributes;
1950 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1952 application.SendNotification();
1953 application.Render();
1955 // Trigger count is 2 - load & render a frame
1956 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1958 // Test whether the property callback is called
1959 DALI_TEST_EQUALS(gDynamicPropertyCallbackFired, true, TEST_LOCATION);