2 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <toolkit-event-thread-callback.h>
24 #include <toolkit-timer.h>
25 #include <toolkit-vector-animation-renderer.h>
26 #include "dummy-control.h"
27 #include "test-native-image-source.h"
29 #include <dali-toolkit/dali-toolkit.h>
31 #include <dali-toolkit/devel-api/controls/control-devel.h>
32 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
33 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-actions-devel.h>
34 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-signals-devel.h>
35 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
36 #include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
37 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
39 #include <dali/devel-api/adaptor-framework/vector-animation-renderer.h>
40 #include <dali/devel-api/adaptor-framework/window-devel.h>
41 #include <dali/devel-api/rendering/renderer-devel.h>
44 using namespace Dali::Toolkit;
46 void dali_animated_vector_image_visual_startup(void)
48 test_return_value = TET_UNDEF;
51 void dali_animated_vector_image_visual_cleanup(void)
53 test_return_value = TET_PASS;
58 const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
59 const char* TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP = "framedrop.json";
60 const char* TEST_VECTOR_IMAGE_INVALID_FILE_NAME = "invalid.json";
62 bool gAnimationFinishedSignalFired = false;
64 void VisualEventSignal(Control control, Dali::Property::Index visualIndex, Dali::Property::Index signalId)
66 if(visualIndex == DummyControl::Property::TEST_VISUAL && signalId == DevelAnimatedVectorImageVisual::Signal::ANIMATION_FINISHED)
68 gAnimationFinishedSignalFired = true;
74 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void)
76 ToolkitTestApplication application;
77 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual01: Request animated vector image visual with a json url");
79 VisualFactory factory = VisualFactory::Get();
80 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
81 DALI_TEST_CHECK(visual);
83 DummyControl actor = DummyControl::New(true);
84 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
85 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
86 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
87 application.GetScene().Add(actor);
89 application.SendNotification();
92 // Trigger count is 1 - render a frame
93 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
95 // renderer is added to actor
96 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
97 Renderer renderer = actor.GetRendererAt(0u);
98 DALI_TEST_CHECK(renderer);
100 // Test SetOffScene().
102 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
107 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual02(void)
109 ToolkitTestApplication application;
110 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual02: Request animated vector image visual with a Property::Map");
112 Property::Map propertyMap;
113 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
114 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
115 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
117 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
118 DALI_TEST_CHECK(visual);
120 DummyControl actor = DummyControl::New(true);
121 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
122 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
123 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
124 application.GetScene().Add(actor);
126 application.SendNotification();
127 application.Render();
129 // Trigger count is 2 - load & render a frame
130 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
132 // renderer is added to actor
133 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
134 Renderer renderer = actor.GetRendererAt(0u);
135 DALI_TEST_CHECK(renderer);
138 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
143 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void)
145 ToolkitTestApplication application;
146 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual03: Request animated vector image visual with a Property::Map");
148 int startFrame = 1, endFrame = 3;
149 Property::Array playRange;
150 playRange.PushBack(startFrame);
151 playRange.PushBack(endFrame);
153 Property::Map propertyMap;
154 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
155 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
156 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
157 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
158 .Add(DevelVisual::Property::CORNER_RADIUS, 50.0f)
159 .Add(DevelVisual::Property::BORDERLINE_WIDTH, 20.0f)
160 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
162 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
163 DALI_TEST_CHECK(visual);
165 DummyControl actor = DummyControl::New(true);
166 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
167 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
168 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
169 application.GetScene().Add(actor);
171 application.SendNotification();
172 application.Render();
174 // Trigger count is 2 - load & render a frame
175 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
177 // renderer is added to actor
178 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
179 Renderer renderer = actor.GetRendererAt(0u);
180 DALI_TEST_CHECK(renderer);
183 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
188 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void)
190 ToolkitTestApplication application;
191 tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map");
193 int startFrame = 1, endFrame = 3;
194 int desiredWidth = 100, desiredHeight = 150;
195 float cornerRadius = 22.0f;
196 float borderlineWidth = 2.0f;
197 Vector4 borderlineColor = Vector4(1.0f, 1.0f, 1.0f, 1.0f);
198 float borderlineOffset = 0.1f;
199 Property::Array playRange;
200 playRange.PushBack(startFrame);
201 playRange.PushBack(endFrame);
203 Property::Map propertyMap;
204 propertyMap.Add("visualType", DevelVisual::ANIMATED_VECTOR_IMAGE)
205 .Add("url", TEST_VECTOR_IMAGE_FILE_NAME)
207 .Add("playRange", playRange)
208 .Add("stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME)
209 .Add("loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE)
210 .Add("redrawInScalingDown", false)
211 .Add("enableFrameCache", false)
212 .Add("notifyAfterRasterization", false)
213 .Add("cornerRadius", cornerRadius)
214 .Add("borderlineWidth", borderlineWidth)
215 .Add("borderlineColor", borderlineColor)
216 .Add("borderlineOffset", borderlineOffset)
217 .Add("desiredWidth", desiredWidth)
218 .Add("desiredHeight", desiredHeight);
220 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
221 DALI_TEST_CHECK(visual);
223 DummyControl actor = DummyControl::New(true);
224 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
225 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
226 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
227 application.GetScene().Add(actor);
229 application.SendNotification();
230 application.Render();
232 // Trigger count is 1 - render a frame
233 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
235 // renderer is added to actor
236 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
238 Renderer renderer = actor.GetRendererAt(0u);
239 DALI_TEST_CHECK(renderer);
241 Property::Map resultMap;
242 visual.CreatePropertyMap(resultMap);
244 // check the property values from the returned map from a visual
245 Property::Value* value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
246 DALI_TEST_CHECK(value);
247 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
249 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
250 DALI_TEST_CHECK(value);
251 DALI_TEST_CHECK(value->Get<int>() == 3);
253 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
254 DALI_TEST_CHECK(value);
256 Property::Array* result = value->GetArray();
257 DALI_TEST_CHECK(result);
259 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
260 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
262 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
263 DALI_TEST_CHECK(value);
264 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::FIRST_FRAME);
266 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
267 DALI_TEST_CHECK(value);
268 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::AUTO_REVERSE);
270 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
271 DALI_TEST_CHECK(value);
272 DALI_TEST_CHECK(value->Get<bool>() == false);
274 value = resultMap.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE, Property::BOOLEAN);
275 DALI_TEST_CHECK(value);
276 DALI_TEST_CHECK(value->Get<bool>() == false);
278 value = resultMap.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, Property::BOOLEAN);
279 DALI_TEST_CHECK(value);
280 DALI_TEST_CHECK(value->Get<bool>() == false);
282 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
283 DALI_TEST_CHECK(value);
284 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius), TEST_LOCATION);
286 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
287 DALI_TEST_CHECK(value);
288 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
290 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT);
291 DALI_TEST_CHECK(value);
292 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
294 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
295 DALI_TEST_CHECK(value);
296 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
298 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
299 DALI_TEST_CHECK(value);
300 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
302 value = resultMap.Find(ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER);
303 DALI_TEST_CHECK(value);
304 DALI_TEST_EQUALS(value->Get<int>(), desiredWidth, TEST_LOCATION);
306 value = resultMap.Find(ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER);
307 DALI_TEST_CHECK(value);
308 DALI_TEST_EQUALS(value->Get<int>(), desiredHeight, TEST_LOCATION);
311 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
316 int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
318 ToolkitTestApplication application;
319 tet_infoline("UtcDaliAnimatedVectorImageVisualGetPropertyMap01");
321 int startFrame = 1, endFrame = 3;
322 int desiredWidth = 100, desiredHeight = 150;
323 Vector4 cornerRadius(50.0f, 22.0f, 0.0f, 3.0f);
324 float borderlineWidth = 2.3f;
325 Vector4 borderlineColor = Vector4(0.3f, 0.3f, 1.0f, 1.0f);
326 float borderlineOffset = 0.3f;
327 Property::Array playRange;
328 playRange.PushBack(startFrame);
329 playRange.PushBack(endFrame);
331 Property::Map propertyMap;
332 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
333 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
334 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
335 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
336 .Add(DevelVisual::Property::CORNER_RADIUS, cornerRadius)
337 .Add(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::RELATIVE)
338 .Add(DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth)
339 .Add(DevelVisual::Property::BORDERLINE_COLOR, borderlineColor)
340 .Add(DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset)
341 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false)
342 .Add(ImageVisual::Property::DESIRED_WIDTH, desiredWidth)
343 .Add(ImageVisual::Property::DESIRED_HEIGHT, desiredHeight);
345 // request AnimatedVectorImageVisual with a property map
346 VisualFactory factory = VisualFactory::Get();
347 Visual::Base visual = factory.CreateVisual(propertyMap);
349 DummyControl actor = DummyControl::New(true);
350 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
351 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
353 Vector2 controlSize(20.f, 30.f);
354 actor.SetProperty(Actor::Property::SIZE, controlSize);
356 application.GetScene().Add(actor);
358 application.SendNotification();
359 application.Render();
361 // Trigger count is 2 - load & render a frame
362 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
364 Property::Map resultMap;
365 resultMap = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
367 // check the property values from the returned map from a visual
368 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
369 DALI_TEST_CHECK(value);
370 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
372 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
373 DALI_TEST_CHECK(value);
374 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
376 value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
377 DALI_TEST_CHECK(value);
378 DALI_TEST_CHECK(value->Get<int>() == 3);
380 value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
381 DALI_TEST_CHECK(value);
383 Property::Array* result = value->GetArray();
384 DALI_TEST_CHECK(result);
386 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
387 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
389 value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
390 DALI_TEST_CHECK(value);
391 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::CURRENT_FRAME);
393 value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
394 DALI_TEST_CHECK(value);
395 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::RESTART);
397 value = resultMap.Find(DevelImageVisual::Property::CONTENT_INFO, Property::MAP);
398 DALI_TEST_CHECK(value);
400 value = resultMap.Find(DevelImageVisual::Property::MARKER_INFO, Property::MAP);
401 DALI_TEST_CHECK(value);
403 value = resultMap.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE, Property::BOOLEAN);
404 DALI_TEST_CHECK(value);
405 DALI_TEST_CHECK(value->Get<bool>() == false); // Check default value
407 value = resultMap.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, Property::BOOLEAN);
408 DALI_TEST_CHECK(value);
409 DALI_TEST_CHECK(value->Get<bool>() == false); // Check default value
411 value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
412 DALI_TEST_CHECK(value);
413 DALI_TEST_CHECK(value->Get<bool>() == true); // Check default value
415 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
416 DALI_TEST_CHECK(value);
417 DALI_TEST_EQUALS(value->Get<Vector4>(), cornerRadius, TEST_LOCATION);
419 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
420 DALI_TEST_CHECK(value);
421 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::RELATIVE);
423 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
424 DALI_TEST_CHECK(value);
425 DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
427 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
428 DALI_TEST_CHECK(value);
429 DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
431 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
432 DALI_TEST_CHECK(value);
433 DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
435 value = resultMap.Find(ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER);
436 DALI_TEST_CHECK(value);
437 DALI_TEST_EQUALS(value->Get<int>(), desiredWidth, TEST_LOCATION);
439 value = resultMap.Find(ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER);
440 DALI_TEST_CHECK(value);
441 DALI_TEST_EQUALS(value->Get<int>(), desiredHeight, TEST_LOCATION);
443 // request AnimatedVectorImageVisual with an URL
444 Visual::Base visual2 = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
447 visual2.CreatePropertyMap(resultMap);
449 // check the property values from the returned map from a visual
450 value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
451 DALI_TEST_CHECK(value);
452 DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
454 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
455 DALI_TEST_CHECK(value);
456 DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
461 int UtcDaliAnimatedVectorImageVisualPlayback(void)
463 ToolkitTestApplication application;
465 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayback");
468 // request AnimatedVectorImageVisual with a property map
469 VisualFactory factory = VisualFactory::Get();
470 Visual::Base visual = factory.CreateVisual(
472 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
473 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
474 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
476 DummyControl dummyControl = DummyControl::New(true);
477 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
478 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
479 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
481 Property::Map attributes;
482 tet_infoline("Test Play action");
483 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
485 application.GetScene().Add(dummyControl);
486 application.SendNotification();
487 application.Render(16);
489 Property::Map map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
490 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
491 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
493 tet_infoline("Test Pause action");
494 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
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::PAUSED);
503 tet_infoline("Test Play action");
504 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
506 application.SendNotification();
507 application.Render(16);
509 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
510 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
511 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
513 tet_infoline("Test Stop action");
514 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, 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::STOPPED);
523 tet_infoline("Test Stop action again");
524 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
526 application.SendNotification();
527 application.Render(16);
529 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
530 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
531 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
533 tet_infoline("Test Play action");
534 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
536 application.SendNotification();
537 application.Render(16);
539 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
540 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
541 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
543 tet_infoline("Off stage");
544 dummyControl.Unparent();
546 application.SendNotification();
547 application.Render(16);
549 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
550 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
551 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
553 tet_infoline("On stage again");
554 application.GetScene().Add(dummyControl);
556 application.SendNotification();
557 application.Render(16);
559 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
560 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
561 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
563 tet_infoline("Test Play action");
564 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
566 application.SendNotification();
567 application.Render(16);
569 map = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
570 value = map.Find(DevelImageVisual::Property::PLAY_STATE);
571 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
574 Vector3 newSize(100.0f, 100.0f, 0.0f);
575 dummyControl.SetProperty(Actor::Property::SIZE, newSize);
577 application.SendNotification();
578 application.Render(16);
580 // Size should be changed
581 Vector3 naturalSize = dummyControl.GetNaturalSize();
582 DALI_TEST_CHECK(naturalSize == newSize);
584 dummyControl.Unparent();
590 int UtcDaliAnimatedVectorImageVisualCustomShader(void)
592 ToolkitTestApplication application;
593 tet_infoline("UtcDaliAnimatedVectorImageVisualCustomShader Test custom shader");
595 VisualFactory factory = VisualFactory::Get();
596 Property::Map properties;
597 Property::Map shader;
598 const std::string vertexShader = "Foobar";
599 const std::string fragmentShader = "Foobar sampler2D Foobar";
600 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
601 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
603 properties[Visual::Property::TYPE] = Visual::IMAGE;
604 properties[Visual::Property::SHADER] = shader;
605 properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
607 Visual::Base visual = factory.CreateVisual(properties);
609 // trigger creation through setting on stage
610 DummyControl dummy = DummyControl::New(true);
611 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
612 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
614 dummy.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
615 dummy.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
616 application.GetScene().Add(dummy);
618 application.SendNotification();
619 application.Render();
621 // Trigger count is 1 - render a frame
622 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
624 Renderer renderer = dummy.GetRendererAt(0);
625 Shader shader2 = renderer.GetShader();
626 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
627 Property::Map* map = value.GetMap();
628 DALI_TEST_CHECK(map);
630 std::string resultFragmentShader, resultVertexShader;
631 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
632 fragment->Get(resultFragmentShader);
633 DALI_TEST_CHECK(resultFragmentShader.find(fragmentShader) != std::string::npos);
635 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
636 vertex->Get(resultVertexShader);
637 DALI_TEST_CHECK(resultVertexShader.find(vertexShader) != std::string::npos);
642 int UtcDaliAnimatedVectorImageVisualNaturalSize(void)
644 ToolkitTestApplication application;
645 tet_infoline("UtcDaliAnimatedVectorImageVisualNaturalSize");
647 VisualFactory factory = VisualFactory::Get();
648 Visual::Base visual = factory.CreateVisual(
650 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
651 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
652 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
653 DALI_TEST_CHECK(visual);
655 DummyControl actor = DummyControl::New(true);
656 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
657 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
659 Vector2 controlSize(20.f, 30.f);
662 application.GetScene().Add(actor);
664 application.SendNotification();
665 application.Render();
667 // Trigger count is 1 - load
668 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
670 visual.GetNaturalSize(naturalSize);
672 DALI_TEST_EQUALS(naturalSize, Vector2(100.0f, 100.0f), TEST_LOCATION); // 100x100 is the content default size.
674 actor.SetProperty(Actor::Property::SIZE, controlSize);
676 application.SendNotification();
677 application.Render();
679 visual.GetNaturalSize(naturalSize);
681 DALI_TEST_EQUALS(naturalSize, controlSize, TEST_LOCATION);
686 int UtcDaliAnimatedVectorImageVisualLoopCount(void)
688 ToolkitTestApplication application;
689 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopCount");
691 Property::Map propertyMap;
692 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
693 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
694 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
695 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
697 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
698 DALI_TEST_CHECK(visual);
700 DummyControl actor = DummyControl::New(true);
701 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
702 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
704 Vector2 controlSize(20.f, 30.f);
705 actor.SetProperty(Actor::Property::SIZE, controlSize);
707 application.GetScene().Add(actor);
709 Property::Map attributes;
710 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
712 application.SendNotification();
713 application.Render();
715 // Trigger count is 2 - load & render a frame
716 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
718 // renderer is added to actor
719 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
720 Renderer renderer = actor.GetRendererAt(0u);
721 DALI_TEST_CHECK(renderer);
726 int UtcDaliAnimatedVectorImageVisualPlayRange(void)
728 ToolkitTestApplication application;
729 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRange");
731 int startFrame = 1, endFrame = 3;
732 Property::Array array;
733 array.PushBack(endFrame);
734 array.PushBack(startFrame);
736 Property::Map propertyMap;
737 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
738 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
739 .Add(DevelImageVisual::Property::PLAY_RANGE, array)
740 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
742 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
743 DALI_TEST_CHECK(visual);
745 DummyControl actor = DummyControl::New(true);
746 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
747 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
749 Vector2 controlSize(20.f, 30.f);
750 actor.SetProperty(Actor::Property::SIZE, controlSize);
752 application.GetScene().Add(actor);
754 Property::Map attributes;
755 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
757 application.SendNotification();
758 application.Render();
760 // Trigger count is 2 - load & render a frame
761 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
763 // renderer is added to actor
764 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
765 Renderer renderer = actor.GetRendererAt(0u);
766 DALI_TEST_CHECK(renderer);
768 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
769 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
770 int totalFrameNumber = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER)->Get<int>();
772 int resultStartFrame, resultEndFrame;
773 Property::Array* result = value->GetArray();
774 result->GetElementAt(0).Get(resultStartFrame);
775 result->GetElementAt(1).Get(resultEndFrame);
777 DALI_TEST_EQUALS(startFrame, resultStartFrame, TEST_LOCATION);
778 DALI_TEST_EQUALS(endFrame, resultEndFrame, TEST_LOCATION);
780 // Set invalid play range
786 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
787 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
789 // To make event trigger
790 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
792 application.SendNotification();
793 application.Render();
795 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
797 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
798 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
800 result = value->GetArray();
801 result->GetElementAt(0).Get(resultStartFrame);
802 result->GetElementAt(1).Get(resultEndFrame);
804 DALI_TEST_EQUALS(resultStartFrame, 1, TEST_LOCATION);
805 DALI_TEST_EQUALS(resultEndFrame, totalFrameNumber - 1, TEST_LOCATION); // Should be clamped
807 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, Property::Map());
809 application.SendNotification();
810 application.Render();
812 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
814 // To make event trigger
815 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
817 application.SendNotification();
818 application.Render();
820 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
822 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
823 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
824 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
831 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
832 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
834 // To make event trigger
835 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
837 application.SendNotification();
838 application.Render();
840 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
842 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
843 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
845 result = value->GetArray();
846 result->GetElementAt(0).Get(resultStartFrame);
847 result->GetElementAt(1).Get(resultEndFrame);
849 DALI_TEST_EQUALS(0, resultStartFrame, TEST_LOCATION);
850 DALI_TEST_EQUALS(2, resultEndFrame, TEST_LOCATION);
852 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
853 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION); // CURRENT_FRAME_NUMBER should be changed also.
858 int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void)
860 ToolkitTestApplication application;
861 tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRangeMarker");
863 // Set 1 marker as array
864 Property::Array array;
865 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
867 Property::Map propertyMap;
868 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
869 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
870 .Add(DevelImageVisual::Property::PLAY_RANGE, array)
871 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
873 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
874 DALI_TEST_CHECK(visual);
876 DummyControl actor = DummyControl::New(true);
877 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
878 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
880 Vector2 controlSize(20.f, 30.f);
881 actor.SetProperty(Actor::Property::SIZE, controlSize);
883 application.GetScene().Add(actor);
885 Property::Map attributes;
886 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
888 application.SendNotification();
889 application.Render();
891 // Trigger count is 2 - load & render a frame
892 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
894 // renderer is added to actor
895 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
896 Renderer renderer = actor.GetRendererAt(0u);
897 DALI_TEST_CHECK(renderer);
899 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
900 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
902 int resultStartFrame, resultEndFrame;
903 Property::Array* result = value->GetArray();
904 result->GetElementAt(0).Get(resultStartFrame);
905 result->GetElementAt(1).Get(resultEndFrame);
907 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
908 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
910 // Set 1 marker as string
914 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, VECTOR_ANIMATION_MARKER_NAME_1);
915 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
917 // To make event trigger
918 actor.SetProperty(Actor::Property::SIZE, Vector2(40.0f, 40.0f));
920 application.SendNotification();
921 application.Render();
923 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
925 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
926 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
928 result = value->GetArray();
929 result->GetElementAt(0).Get(resultStartFrame);
930 result->GetElementAt(1).Get(resultEndFrame);
932 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
933 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
937 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
938 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_2);
941 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
942 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
944 // To make event trigger
945 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
947 application.SendNotification();
948 application.Render();
950 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
952 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
953 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
955 result = value->GetArray();
956 result->GetElementAt(0).Get(resultStartFrame);
957 result->GetElementAt(1).Get(resultEndFrame);
959 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
960 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
962 // Set invalid play range
965 array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
968 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
969 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
971 // To make event trigger
972 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
974 application.SendNotification();
975 application.Render();
977 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
979 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
980 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
982 result = value->GetArray();
983 result->GetElementAt(0).Get(resultStartFrame);
984 result->GetElementAt(1).Get(resultEndFrame);
986 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION); // Should not be changed
987 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
992 int UtcDaliAnimatedVectorImageVisualMarkerInfo(void)
994 ToolkitTestApplication application;
995 tet_infoline("UtcDaliAnimatedVectorImageVisualMarkerInfo");
997 Property::Map propertyMap;
998 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
999 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1000 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1002 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1003 DALI_TEST_CHECK(visual);
1005 DummyControl actor = DummyControl::New(true);
1006 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1007 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1009 Vector2 controlSize(20.f, 30.f);
1010 actor.SetProperty(Actor::Property::SIZE, controlSize);
1012 application.GetScene().Add(actor);
1014 Property::Map attributes;
1015 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1017 application.SendNotification();
1018 application.Render();
1020 // Trigger count is 2 - load & render a frame
1021 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1023 // renderer is added to actor
1024 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1025 Renderer renderer = actor.GetRendererAt(0u);
1026 DALI_TEST_CHECK(renderer);
1028 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1029 Property::Value* value = map.Find(DevelImageVisual::Property::MARKER_INFO);
1031 DALI_TEST_CHECK(value);
1033 Property::Map* result = value->GetMap();
1034 DALI_TEST_CHECK(result);
1036 std::string resultMarkerName;
1037 int resultStartFrame, resultEndFrame;
1038 DALI_TEST_EQUALS(2u, result->Count(), TEST_LOCATION);
1040 for(uint32_t i = 0u; i < result->Count(); ++i)
1042 if(result->GetKeyAt(i).stringKey == VECTOR_ANIMATION_MARKER_NAME_1)
1044 Property::Array* frameArray = result->GetValue(i).GetArray();
1045 DALI_TEST_CHECK(frameArray);
1046 frameArray->GetElementAt(0).Get(resultStartFrame);
1047 frameArray->GetElementAt(1).Get(resultEndFrame);
1049 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
1050 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
1052 else if(result->GetKeyAt(i).stringKey == VECTOR_ANIMATION_MARKER_NAME_2)
1054 Property::Array* frameArray = result->GetValue(i).GetArray();
1055 DALI_TEST_CHECK(frameArray);
1056 frameArray->GetElementAt(0).Get(resultStartFrame);
1057 frameArray->GetElementAt(1).Get(resultEndFrame);
1059 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_2, resultStartFrame, TEST_LOCATION);
1060 DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
1064 DALI_TEST_CHECK(false);
1071 int UtcDaliAnimatedVectorImageVisualMarkerInfoFromInvalid(void)
1073 ToolkitTestApplication application;
1074 tet_infoline("UtcDaliAnimatedVectorImageVisualMarkerInfoFromInvalid");
1076 Property::Map propertyMap;
1077 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1078 .Add(ImageVisual::Property::URL, "invalid.json")
1079 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1081 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1082 DALI_TEST_CHECK(visual);
1084 DummyControl actor = DummyControl::New(true);
1085 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1086 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1088 Vector2 controlSize(20.f, 30.f);
1089 actor.SetProperty(Actor::Property::SIZE, controlSize);
1091 application.GetScene().Add(actor);
1093 Property::Map attributes;
1094 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1096 application.SendNotification();
1097 application.Render();
1099 // Trigger count is 1 - load, and failed.
1100 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1102 // renderer is added to actor
1103 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1104 Renderer renderer = actor.GetRendererAt(0u);
1105 DALI_TEST_CHECK(renderer);
1107 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1108 Property::Value* value = map.Find(DevelImageVisual::Property::MARKER_INFO);
1110 // The values when load failed case is invalid.
1111 DALI_TEST_CHECK(value == nullptr || (value->GetMap() == nullptr) || (value->GetMap()->Empty()));
1116 int UtcDaliAnimatedVectorImageVisualUsedFixedCache(void)
1118 ToolkitTestApplication application;
1119 tet_infoline("UtcDaliAnimatedVectorImageVisualUsedFixedCache");
1121 Property::Map propertyMap;
1122 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1123 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1124 .Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, true)
1125 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1127 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1128 DALI_TEST_CHECK(visual);
1130 DummyControl actor = DummyControl::New(true);
1131 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1132 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1133 //actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1134 application.GetScene().Add(actor);
1136 application.SendNotification();
1137 application.Render();
1139 // Trigger count is 1 - load
1140 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1142 Vector2 controlSize(200.f, 200.f);
1143 actor.SetProperty(Actor::Property::SIZE, controlSize);
1145 application.SendNotification();
1146 application.Render();
1148 // Trigger count is 1 - render a frame
1149 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1151 // renderer is added to actor
1152 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1153 Renderer renderer = actor.GetRendererAt(0u);
1154 DALI_TEST_CHECK(renderer);
1156 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1157 Property::Value* value = map.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE);
1158 DALI_TEST_CHECK(value->Get<bool>() == true);
1163 int UtcDaliAnimatedVectorImageVisualUsedFixedCacheFailed(void)
1165 ToolkitTestApplication application;
1166 tet_infoline("UtcDaliAnimatedVectorImageVisualUsedFixedCacheFailed");
1168 Property::Map propertyMap;
1169 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1170 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1171 .Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, true)
1172 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1174 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1175 DALI_TEST_CHECK(visual);
1177 DummyControl actor = DummyControl::New(true);
1178 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1179 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1181 Vector2 controlSize(200.f, 200.f);
1182 actor.SetProperty(Actor::Property::SIZE, controlSize);
1184 application.GetScene().Add(actor);
1185 application.SendNotification();
1186 application.Render();
1188 // Trigger count is 1 - load, and failed.
1189 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1191 // renderer is added to actor
1192 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1193 Renderer renderer = actor.GetRendererAt(0u);
1194 DALI_TEST_CHECK(renderer);
1196 propertyMap.Clear();
1197 propertyMap.Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, true)
1198 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1199 .Add(ImageVisual::Property::DESIRED_WIDTH, 100)
1200 .Add(ImageVisual::Property::DESIRED_HEIGHT, 100);
1201 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1203 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1204 Property::Value* value = map.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE);
1205 DALI_TEST_CHECK(value->Get<bool>() == true);
1210 int UtcDaliAnimatedVectorImageVisualNotifyAfterRasterization(void)
1212 ToolkitTestApplication application;
1213 tet_infoline("UtcDaliAnimatedVectorImageVisualNotifyAfterRasterization");
1215 Property::Map propertyMap;
1216 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1217 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1218 .Add(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, true)
1219 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1221 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1222 DALI_TEST_CHECK(visual);
1224 DummyControl actor = DummyControl::New(true);
1225 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1226 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1228 application.GetScene().Add(actor);
1230 application.SendNotification();
1231 application.Render();
1233 // Trigger count is 1 - load
1234 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1236 Vector2 controlSize(200.f, 200.f);
1237 actor.SetProperty(Actor::Property::SIZE, controlSize);
1239 application.SendNotification();
1240 application.Render();
1242 // Trigger count is 1 - render a frame
1243 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1246 Property::Map attributes;
1247 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1249 application.SendNotification();
1250 application.Render();
1252 // renderer is added to actor
1253 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1254 Renderer renderer = actor.GetRendererAt(0u);
1255 DALI_TEST_CHECK(renderer);
1257 // Check renderer behavior
1258 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1260 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1261 Property::Value* value = map.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION);
1262 DALI_TEST_CHECK(value->Get<bool>() == true);
1264 propertyMap.Clear();
1265 propertyMap.Add(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, false);
1266 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1268 application.SendNotification();
1269 application.Render();
1271 // Check renderer behavior again
1272 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1274 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1275 value = map.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION);
1276 DALI_TEST_CHECK(value->Get<bool>() == false);
1278 propertyMap.Clear();
1279 propertyMap.Add(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, true);
1280 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1282 application.SendNotification();
1283 application.Render();
1285 // Check renderer behavior again
1286 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1288 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1289 value = map.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION);
1290 DALI_TEST_CHECK(value->Get<bool>() == true);
1295 int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
1297 ToolkitTestApplication application;
1298 tet_infoline("UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal");
1300 Property::Map propertyMap;
1301 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1302 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1304 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1305 DALI_TEST_CHECK(visual);
1307 DummyControl actor = DummyControl::New(true);
1308 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1309 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1311 DevelControl::VisualEventSignal(actor).Connect(&VisualEventSignal);
1313 Vector2 controlSize(20.f, 30.f);
1314 actor.SetProperty(Actor::Property::SIZE, controlSize);
1316 application.GetScene().Add(actor);
1318 application.SendNotification();
1319 application.Render();
1321 // Trigger count is 1 - render a frame
1322 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1324 propertyMap.Clear();
1325 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1326 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1328 Property::Map attributes;
1329 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1331 application.SendNotification();
1332 application.Render();
1334 // Wait for animation finish
1335 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1337 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1338 Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
1339 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
1341 DALI_TEST_EQUALS(gAnimationFinishedSignalFired, true, TEST_LOCATION);
1346 int UtcDaliAnimatedVectorImageVisualJumpTo(void)
1348 ToolkitTestApplication application;
1349 tet_infoline("UtcDaliAnimatedVectorImageVisualJumpTo");
1351 Property::Map propertyMap;
1352 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1353 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1354 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1355 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1357 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1358 DALI_TEST_CHECK(visual);
1360 tet_printf("1. Visual is created.\n");
1362 DummyControl actor = DummyControl::New(true);
1363 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1364 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1366 Vector2 controlSize(20.f, 30.f);
1367 actor.SetProperty(Actor::Property::SIZE, controlSize);
1369 application.GetScene().Add(actor);
1371 application.SendNotification();
1372 application.Render();
1374 // Trigger count is 2 - load & render a frame
1375 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1377 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2);
1379 // To make event trigger
1380 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1382 application.SendNotification();
1383 application.Render();
1385 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1387 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1388 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1389 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1391 tet_printf("2. The current frame number is [%d].\n", value->Get<int>());
1393 Property::Array array;
1397 Property::Map attributes;
1398 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1399 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1401 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1403 // To make event trigger
1404 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1406 application.SendNotification();
1407 application.Render();
1409 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1411 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1412 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1413 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1415 tet_printf("3. The current frame number is [%d].\n", value->Get<int>());
1417 // Change play range
1424 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1425 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1428 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1430 application.SendNotification();
1431 application.Render();
1433 // Wait for animation finish
1434 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1435 // EventThread will be triggered after animation finished (For render forcibly).
1436 // TODO : Is this logic will works well on server-side?
1437 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1440 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1442 // To make event trigger
1443 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1445 application.SendNotification();
1446 application.Render();
1448 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1450 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1451 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1452 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1454 tet_printf("4. The current frame number is [%d].\n", value->Get<int>());
1456 // Jump to the same position
1457 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1459 // To make event trigger
1460 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1462 application.SendNotification();
1463 application.Render();
1465 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1467 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1468 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1469 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1471 tet_printf("5. The current frame number is [%d].\n", value->Get<int>());
1476 int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
1478 ToolkitTestApplication application;
1479 tet_infoline("UtcDaliAnimatedVectorImageVisualUpdateProperty");
1481 int startFrame = 1, endFrame = 3;
1482 Property::Array playRange;
1483 playRange.PushBack(startFrame);
1484 playRange.PushBack(endFrame);
1486 Property::Map propertyMap;
1487 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1488 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1489 .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1490 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
1491 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1493 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1494 DALI_TEST_CHECK(visual);
1496 DummyControl actor = DummyControl::New(true);
1497 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1498 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1500 Vector2 controlSize(20.f, 30.f);
1501 actor.SetProperty(Actor::Property::SIZE, controlSize);
1503 application.GetScene().Add(actor);
1505 application.SendNotification();
1506 application.Render();
1508 // Trigger count is 2 - load & render a frame
1509 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1511 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1512 Property::Value* value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1513 DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1515 value = map.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
1516 DALI_TEST_CHECK(value);
1518 Property::Array* result = value->GetArray();
1519 DALI_TEST_CHECK(result);
1521 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1522 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1525 playRange.PushBack(0);
1526 playRange.PushBack(2);
1528 Property::Map attributes;
1529 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1530 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 5);
1532 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1534 // To make event trigger
1535 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1537 application.SendNotification();
1538 application.Render();
1540 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1542 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1543 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1544 DALI_TEST_EQUALS(value->Get<int>(), 5, TEST_LOCATION);
1546 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1547 result = value->GetArray();
1548 DALI_TEST_CHECK(result);
1550 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == 0);
1551 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == 2);
1556 playRange.PushBack(startFrame);
1557 playRange.PushBack(endFrame);
1559 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1561 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1563 // To make event trigger
1564 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1566 application.SendNotification();
1567 application.Render();
1569 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1571 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1572 value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1574 result = value->GetArray();
1575 DALI_TEST_CHECK(result);
1577 DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1578 DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1580 // Play and update property
1582 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1584 application.SendNotification();
1585 application.Render();
1587 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 10);
1589 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1591 application.SendNotification();
1592 application.Render();
1594 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1595 value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1596 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
1601 int UtcDaliAnimatedVectorImageVisualStopBehavior(void)
1603 ToolkitTestApplication application;
1604 tet_infoline("UtcDaliAnimatedVectorImageVisualStopBehavior");
1606 Property::Map propertyMap;
1607 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1608 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1609 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1611 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1612 DALI_TEST_CHECK(visual);
1614 DummyControl actor = DummyControl::New(true);
1615 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1616 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1618 Vector2 controlSize(20.f, 30.f);
1619 actor.SetProperty(Actor::Property::SIZE, controlSize);
1621 application.GetScene().Add(actor);
1623 application.SendNotification();
1624 application.Render();
1626 // Trigger count is 2 - load & render a frame
1627 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1629 propertyMap.Clear();
1630 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1631 propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
1632 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
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 // Trigger count is 1 - animation finished
1641 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1643 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1644 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1645 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1647 // Change stop behavior
1648 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1650 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1655 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1657 application.SendNotification();
1658 application.Render();
1660 // Trigger count is 1 - animation finished
1661 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1663 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1665 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1666 int totalFrameNumber = value1->Get<int>();
1668 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1669 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1671 // Change stop behavior
1672 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1673 attributes.Add(DevelImageVisual::Property::LOOP_COUNT, -1);
1675 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1680 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1682 application.SendNotification();
1683 application.Render();
1686 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
1688 // To make event trigger
1689 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1691 application.SendNotification();
1692 application.Render();
1694 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1696 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1697 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1698 int currentFrameNumber = value->Get<int>();
1701 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
1703 // To make event trigger
1704 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1706 application.SendNotification();
1707 application.Render();
1709 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1711 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1712 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1713 DALI_TEST_EQUALS(value->Get<int>(), currentFrameNumber, TEST_LOCATION); // Should be same with currentFrameNumber
1718 int UtcDaliAnimatedVectorImageVisualLoopingMode(void)
1720 ToolkitTestApplication application;
1721 tet_infoline("UtcDaliAnimatedVectorImageVisualLoopingMode");
1723 Property::Map propertyMap;
1724 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1725 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1726 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1728 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1729 DALI_TEST_CHECK(visual);
1731 DummyControl actor = DummyControl::New(true);
1732 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1733 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1735 Vector2 controlSize(20.f, 30.f);
1736 actor.SetProperty(Actor::Property::SIZE, controlSize);
1738 application.GetScene().Add(actor);
1740 application.SendNotification();
1741 application.Render();
1743 // Trigger count is 2 - load, render
1744 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1746 propertyMap.Clear();
1747 propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1748 propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1749 propertyMap.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::AUTO_REVERSE);
1750 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1752 Property::Map attributes;
1753 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1755 application.SendNotification();
1756 application.Render();
1758 // Trigger count is 1 - animation finished
1759 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1761 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1762 Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1763 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame because of auto reverse
1765 // Change stop behavior
1766 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1768 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1771 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1773 application.SendNotification();
1774 application.Render();
1776 // Trigger count is 1 - animation finished
1777 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1779 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1780 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1781 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1783 // Change looping mode
1784 attributes.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::RESTART);
1786 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1789 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1791 application.SendNotification();
1792 application.Render();
1794 // Trigger count is 1 - animation finished
1795 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1797 Property::Value* value1 = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1798 int totalFrameNumber = value1->Get<int>();
1800 map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1801 value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1802 DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1807 int UtcDaliAnimatedVectorImageVisualPropertyNotification(void)
1809 ToolkitTestApplication application;
1810 tet_infoline("UtcDaliAnimatedVectorImageVisualPropertyNotification");
1812 Property::Map propertyMap;
1813 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1814 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1816 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1817 DALI_TEST_CHECK(visual);
1819 DummyControl actor = DummyControl::New(true);
1820 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1821 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1822 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1824 application.GetScene().Add(actor);
1826 application.SendNotification();
1827 application.Render();
1829 // Trigger count is 1 - render a frame
1830 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1832 Renderer renderer = actor.GetRendererAt(0u);
1833 DALI_TEST_CHECK(renderer);
1835 Vector2 controlSize(20.f, 30.f);
1836 actor.SetProperty(Actor::Property::SIZE, controlSize);
1838 application.SendNotification();
1839 application.Render();
1841 application.SendNotification();
1842 application.Render();
1844 // Trigger count is 1 - render a frame
1845 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1847 auto textureSet = renderer.GetTextures();
1848 auto texture = textureSet.GetTexture(0);
1850 DALI_TEST_EQUALS(controlSize.width, texture.GetWidth(), TEST_LOCATION);
1851 DALI_TEST_EQUALS(controlSize.height, texture.GetHeight(), TEST_LOCATION);
1854 Vector3 controlScale(2.0f, 2.0f, 1.0f);
1855 actor.SetProperty(Actor::Property::SCALE, controlScale);
1857 application.SendNotification();
1858 application.Render();
1860 application.SendNotification();
1861 application.Render();
1863 // Trigger count is 1 - render a frame
1864 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1866 renderer = actor.GetRendererAt(0u);
1867 DALI_TEST_CHECK(renderer);
1869 textureSet = renderer.GetTextures();
1870 texture = textureSet.GetTexture(0);
1872 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1873 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1876 controlSize = Vector2(50.0f, 100.0f);
1877 Animation animation = Animation::New(1.0);
1878 animation.AnimateTo(Property(actor, Actor::Property::SIZE), Vector3(controlSize.x, controlSize.y, 0.0f));
1881 application.SendNotification();
1882 application.Render(1100); // After the animation
1884 application.SendNotification();
1885 application.Render();
1887 // Trigger count is 1 - render a frame
1888 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1890 renderer = actor.GetRendererAt(0u);
1891 DALI_TEST_CHECK(renderer);
1893 textureSet = renderer.GetTextures();
1894 texture = textureSet.GetTexture(0);
1896 DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1897 DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1902 int UtcDaliAnimatedVectorImageVisualMultipleInstances(void)
1904 ToolkitTestApplication application;
1905 tet_infoline("UtcDaliAnimatedVectorImageVisualMultipleInstances");
1907 Property::Map propertyMap;
1908 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1909 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1910 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1912 Visual::Base visual1 = VisualFactory::Get().CreateVisual(propertyMap);
1913 DALI_TEST_CHECK(visual1);
1915 DummyControl actor1 = DummyControl::New(true);
1916 DummyControlImpl& dummyImpl1 = static_cast<DummyControlImpl&>(actor1.GetImplementation());
1917 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual1);
1919 Vector2 controlSize(20.f, 30.f);
1920 actor1.SetProperty(Actor::Property::SIZE, controlSize);
1922 application.GetScene().Add(actor1);
1924 application.SendNotification();
1925 application.Render();
1927 // Trigger count is 2 - load & render a frame
1928 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1930 propertyMap.Clear();
1931 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1932 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1933 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1935 Visual::Base visual2 = VisualFactory::Get().CreateVisual(propertyMap);
1936 DALI_TEST_CHECK(visual2);
1938 DummyControl actor2 = DummyControl::New(true);
1939 DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor2.GetImplementation());
1940 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
1942 actor2.SetProperty(Actor::Property::SIZE, controlSize);
1944 application.GetScene().Add(actor2);
1946 application.SendNotification();
1947 application.Render();
1949 // Trigger count is 2 - load & render a frame
1950 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1952 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1954 // To make event trigger
1955 actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1957 application.SendNotification();
1958 application.Render();
1960 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1962 Property::Map attributes;
1963 attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1965 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1966 DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1968 DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1970 // renderer is added to actor
1971 DALI_TEST_CHECK(actor1.GetRendererCount() == 1u);
1972 Renderer renderer1 = actor1.GetRendererAt(0u);
1973 DALI_TEST_CHECK(renderer1);
1975 // renderer is added to actor
1976 DALI_TEST_CHECK(actor2.GetRendererCount() == 1u);
1977 Renderer renderer2 = actor2.GetRendererAt(0u);
1978 DALI_TEST_CHECK(renderer2);
1983 int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void)
1985 ToolkitTestApplication application;
1986 tet_infoline("UtcDaliAnimatedVectorImageVisualControlVisibilityChanged");
1988 Property::Map propertyMap;
1989 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1990 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1991 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1993 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1994 DALI_TEST_CHECK(visual);
1996 DummyControl actor = DummyControl::New(true);
1997 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1998 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2000 Vector2 controlSize(20.f, 30.f);
2001 actor.SetProperty(Actor::Property::SIZE, controlSize);
2003 application.GetScene().Add(actor);
2005 application.SendNotification();
2006 application.Render();
2008 // Trigger count is 2 - load & render a frame
2009 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2011 Property::Map attributes;
2012 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2014 application.SendNotification();
2015 application.Render();
2017 // Check rendering behavior
2018 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2019 Renderer renderer = actor.GetRendererAt(0u);
2020 DALI_TEST_CHECK(renderer);
2021 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
2023 actor.SetProperty(Actor::Property::VISIBLE, false);
2025 application.SendNotification();
2026 application.Render();
2028 // Check rendering behavior again
2029 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
2034 int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void)
2036 ToolkitTestApplication application;
2037 tet_infoline("UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged");
2039 Property::Map propertyMap;
2040 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2041 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
2043 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2044 DALI_TEST_CHECK(visual);
2046 DummyControl actor = DummyControl::New(true);
2047 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2048 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2050 Vector2 controlSize(20.f, 30.f);
2051 actor.SetProperty(Actor::Property::SIZE, controlSize);
2053 application.GetScene().Add(actor);
2055 application.SendNotification();
2056 application.Render();
2058 // Trigger count is 1 - render a frame
2059 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2061 Property::Map attributes;
2062 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2064 application.SendNotification();
2065 application.Render();
2067 // Check rendering behavior
2068 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2069 Renderer renderer = actor.GetRendererAt(0u);
2070 DALI_TEST_CHECK(renderer);
2071 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
2073 Window window = DevelWindow::Get(actor);
2076 application.SendNotification();
2077 application.Render();
2079 // Check rendering behavior again
2080 DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
2085 int UtcDaliAnimatedVectorImageVisualInvalidFile01(void)
2087 ToolkitTestApplication application;
2088 tet_infoline("Request loading with invalid file - should draw broken image");
2090 TestGlAbstraction& gl = application.GetGlAbstraction();
2091 TraceCallStack& textureTrace = gl.GetTextureTrace();
2092 textureTrace.Enable(true);
2094 Property::Map propertyMap;
2095 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2096 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
2097 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2099 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2100 DALI_TEST_CHECK(visual);
2102 DummyControl actor = DummyControl::New(true);
2103 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2104 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2106 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
2108 application.GetScene().Add(actor);
2110 application.SendNotification();
2111 application.Render();
2113 // Trigger count is 1 - load
2114 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2116 application.SendNotification();
2117 application.Render();
2119 // Check resource status
2120 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2121 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2123 // The broken image should be shown.
2124 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2125 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2130 int UtcDaliAnimatedVectorImageVisualInvalidFile02(void)
2132 ToolkitTestApplication application;
2133 tet_infoline("Request loading with invalid file - should draw broken image");
2135 TestGlAbstraction& gl = application.GetGlAbstraction();
2136 TraceCallStack& textureTrace = gl.GetTextureTrace();
2137 textureTrace.Enable(true);
2139 Property::Map propertyMap;
2140 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2141 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
2143 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2144 DALI_TEST_CHECK(visual);
2146 DummyControl actor = DummyControl::New(true);
2147 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2148 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2150 actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
2152 application.SendNotification();
2153 application.Render();
2155 // Add to the Scene after loading
2156 application.GetScene().Add(actor);
2158 application.SendNotification();
2159 application.Render();
2161 // Check resource status
2162 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2163 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2165 // The broken image should be shown.
2166 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2167 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2172 int UtcDaliAnimatedVectorImageVisualInvalidFile03(void)
2174 ToolkitTestApplication application;
2175 tet_infoline("Request loading with invalid file without size set - should draw broken image");
2177 TestGlAbstraction& gl = application.GetGlAbstraction();
2178 TraceCallStack& textureTrace = gl.GetTextureTrace();
2179 textureTrace.Enable(true);
2181 Property::Map propertyMap;
2182 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2183 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
2184 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2186 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2187 DALI_TEST_CHECK(visual);
2189 DummyControl actor = DummyControl::New(true);
2190 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2191 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2193 application.GetScene().Add(actor);
2195 application.SendNotification();
2196 application.Render();
2198 // Trigger count is 1 - load
2199 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2201 application.SendNotification();
2202 application.Render();
2204 // Check resource status
2205 Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2206 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2208 // The broken image should be shown.
2209 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2210 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2215 int UtcDaliAnimatedVectorImageVisualFrameDrops(void)
2217 ToolkitTestApplication application;
2218 tet_infoline("UtcDaliAnimatedVectorImageVisualFrameDrops");
2220 Property::Map propertyMap;
2221 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2222 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP)
2223 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2225 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2226 DALI_TEST_CHECK(visual);
2228 DummyControl actor = DummyControl::New(true);
2229 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2230 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2232 Vector2 controlSize(20.f, 30.f);
2233 actor.SetProperty(Actor::Property::SIZE, controlSize);
2235 application.GetScene().Add(actor);
2237 application.SendNotification();
2238 application.Render();
2240 // Trigger count is 2 - load, render the first frame
2241 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2243 Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2244 Property::Value* value = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
2245 int totalFrameNumber = value->Get<int>();
2247 Property::Map attributes;
2248 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2250 // Make delay to drop frames
2251 Test::VectorAnimationRenderer::DelayRendering(170); // longer than 16.6 * 10frames
2253 application.SendNotification();
2254 application.Render();
2256 // Trigger count is 1 - calculating frame drops
2257 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2259 // Check dropped frame
2260 uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames();
2261 DALI_TEST_CHECK(frames > 0);
2262 DALI_TEST_CHECK(frames <= static_cast<uint32_t>(totalFrameNumber));
2267 int UtcDaliAnimatedVectorImageVisualSize(void)
2269 ToolkitTestApplication application;
2270 tet_infoline("UtcDaliAnimatedVectorImageVisualSize");
2272 TestGlAbstraction& gl = application.GetGlAbstraction();
2273 TraceCallStack& textureTrace = gl.GetTextureTrace();
2275 VisualFactory factory = VisualFactory::Get();
2276 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
2277 DALI_TEST_CHECK(visual);
2279 DummyControl actor = DummyControl::New(true);
2280 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2281 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2283 application.GetScene().Add(actor);
2285 application.SendNotification();
2286 application.Render();
2288 // Trigger count is 1 - resource ready
2289 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2291 textureTrace.Enable(true);
2293 application.SendNotification();
2294 application.Render();
2297 int width = 100, height = 100; // 100x100 is the content default size.
2298 std::stringstream out;
2299 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
2300 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2303 actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
2305 application.SendNotification();
2306 application.Render();
2308 // Trigger count is 1 - resource ready
2309 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2311 textureTrace.Reset();
2313 application.SendNotification();
2314 application.Render();
2317 int width = 200, height = 200;
2318 std::stringstream out;
2319 out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
2320 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2328 bool gDynamicPropertyCallbackFired = false;
2330 Property::Value FillColorCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber)
2332 gDynamicPropertyCallbackFired = true;
2336 return Vector3(0, 0, 1);
2340 return Vector3(1, 0, 0);
2345 int UtcDaliAnimatedVectorImageVisualDynamicProperty(void)
2347 ToolkitTestApplication application;
2348 tet_infoline("UtcDaliAnimatedVectorImageVisualDynamicProperty");
2350 VisualFactory factory = VisualFactory::Get();
2351 Visual::Base visual = factory.CreateVisual(
2353 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2354 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2355 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
2356 DALI_TEST_CHECK(visual);
2358 DummyControl actor = DummyControl::New(true);
2359 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2360 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2362 Vector2 controlSize(20.f, 30.f);
2363 actor.SetProperty(Actor::Property::SIZE, controlSize);
2365 application.GetScene().Add(actor);
2367 gDynamicPropertyCallbackFired = false;
2369 // Set dynamic property
2370 DevelAnimatedVectorImageVisual::DynamicPropertyInfo info;
2372 info.keyPath = "Test.Path";
2373 info.property = static_cast<int>(VectorAnimationRenderer::VectorProperty::FILL_COLOR);
2374 info.callback = MakeCallback(FillColorCallback);
2376 DevelControl::DoActionExtension(actor, DummyControl::Property::TEST_VISUAL, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info));
2378 Property::Map attributes;
2379 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2381 application.SendNotification();
2382 application.Render();
2384 // Trigger count is 2 - load & render a frame
2385 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2387 // Test whether the property callback is called
2388 DALI_TEST_EQUALS(gDynamicPropertyCallbackFired, true, TEST_LOCATION);
2393 int UtcDaliAnimatedVectorImageVisualDesiredSize(void)
2395 ToolkitTestApplication application;
2396 tet_infoline("UtcDaliAnimatedVectorImageVisualDesiredSize");
2398 TestGlAbstraction& gl = application.GetGlAbstraction();
2399 TraceCallStack& textureTrace = gl.GetTextureTrace();
2400 int desiredWidth = 150, desiredHeight = 200;
2402 Visual::Base visual = VisualFactory::Get().CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
2403 DALI_TEST_CHECK(visual);
2405 DummyControl actor = DummyControl::New(true);
2406 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2407 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2409 application.GetScene().Add(actor);
2411 application.SendNotification();
2412 application.Render();
2414 // Trigger count is 1 - resource ready
2415 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2417 textureTrace.Enable(true);
2419 application.SendNotification();
2420 application.Render();
2423 std::stringstream out;
2424 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
2425 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2428 // Unparent to make next trigger
2431 application.SendNotification();
2432 application.Render();
2435 actor.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.0f));
2436 application.GetScene().Add(actor);
2438 application.SendNotification();
2439 application.Render();
2441 // Trigger count is 1 - resource ready
2442 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2444 textureTrace.Reset();
2446 application.SendNotification();
2447 application.Render();
2450 std::stringstream out;
2451 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
2452 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str())); // The size should not be changed
2458 int UtcDaliAnimatedVectorImageVisualFlushAction(void)
2460 ToolkitTestApplication application;
2462 tet_infoline("UtcDaliAnimatedVectorImageVisualFlushAction");
2467 int totalFrameCount = 0;
2469 Property::Array playRange;
2470 playRange.PushBack(startFrame);
2471 playRange.PushBack(endFrame);
2473 Property::Map resultMap;
2474 Property::Value* value = nullptr;
2476 // request AnimatedVectorImageVisual with a property map
2477 VisualFactory factory = VisualFactory::Get();
2478 Visual::Base visual = factory.CreateVisual(
2480 .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2481 .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2482 .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
2483 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, true));
2485 DummyControl dummyControl = DummyControl::New(true);
2486 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
2487 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2488 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
2490 application.GetScene().Add(dummyControl);
2492 // Retry function to get playrange until expect values comes.
2493 auto CheckAndRetryPlayRange = [&](int expectStartFrame, int expectEndFrame, std::vector<std::pair<int, int>> retrialFrames) {
2495 int tryCountMax = 30;
2496 while(++tryCount <= tryCountMax)
2498 Property::Map resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2500 Property::Value* value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
2501 DALI_TEST_CHECK(value);
2503 Property::Array* result = value->GetArray();
2504 DALI_TEST_CHECK(result);
2505 DALI_TEST_EQUALS(result->Count(), 2, TEST_LOCATION);
2507 bool tryAgain = false;
2508 for(auto& framePair : retrialFrames)
2510 if(result->GetElementAt(0).Get<int>() == framePair.first && result->GetElementAt(1).Get<int>() == framePair.second)
2518 tet_printf("Retry to get value again! [%d]\n", tryCount);
2519 // Dummy sleep 1 second.
2520 Test::WaitForEventThreadTrigger(1, 1);
2524 DALI_TEST_EQUALS(result->GetElementAt(0).Get<int>(), expectStartFrame, TEST_LOCATION);
2525 DALI_TEST_EQUALS(result->GetElementAt(1).Get<int>(), expectEndFrame, TEST_LOCATION);
2528 DALI_TEST_CHECK(tryCount <= tryCountMax);
2531 tet_printf("Pause lottie first.\n");
2533 Property::Map attributes;
2534 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
2536 application.SendNotification();
2537 application.Render(16);
2541 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2543 value = resultMap.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER, Property::INTEGER);
2544 DALI_TEST_CHECK(value);
2545 totalFrameCount = value->Get<int>();
2546 } while(totalFrameCount == 0);
2548 // Ensure that vector data sended well.
2549 CheckAndRetryPlayRange(startFrame, endFrame, {{0, 0}, {0, totalFrameCount - 1}});
2551 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2553 value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
2554 DALI_TEST_CHECK(value);
2555 DALI_TEST_EQUALS(value->Get<int>(), startFrame, TEST_LOCATION);
2557 tet_printf("Now logically, range : [%d~%d], current : %d\n", startFrame, endFrame, startFrame);
2559 int changedStartFrame1 = startFrame + 2;
2560 int changedEndFrame1 = endFrame + 2;
2563 playRange.Add(changedStartFrame1);
2564 playRange.Add(changedEndFrame1);
2566 tet_printf("Change play range\n");
2567 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
2568 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2570 tet_printf("Jump to changedEndFrame!\n");
2571 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, changedEndFrame1);
2574 tet_infoline("Flush Action!");
2575 tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame1, changedEndFrame1, changedEndFrame1);
2576 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::FLUSH, attributes);
2578 int changedStartFrame2 = startFrame + 1;
2579 int changedEndFrame2 = endFrame + 1;
2582 playRange.Add(changedStartFrame2);
2583 playRange.Add(changedEndFrame2);
2585 tet_printf("Change play range again\n");
2586 tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame2, changedEndFrame2, changedEndFrame2);
2587 attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
2588 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2590 application.SendNotification();
2591 application.Render(16);
2593 // Ensure that vector data sended well.
2594 CheckAndRetryPlayRange(changedStartFrame2, changedEndFrame2, {{changedStartFrame1, changedEndFrame1}, {startFrame, endFrame}});
2596 resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2598 tet_printf("Test whether current frame number changed well. If Flush not works, current frame become startFrame.");
2599 value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
2600 DALI_TEST_CHECK(value);
2601 DALI_TEST_EQUALS(value->Get<int>(), changedEndFrame2, TEST_LOCATION);
2603 dummyControl.Unparent();
2608 int UtcDaliAnimatedVectorImageNativeTextureChangeShader(void)
2610 ToolkitTestApplication application;
2611 tet_infoline("UtcDaliAnimatedVectorImageNativeTextureChangeShader");
2613 VisualFactory factory = VisualFactory::Get();
2614 Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
2615 DALI_TEST_CHECK(visual);
2617 DummyControl actor = DummyControl::New(true);
2618 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2619 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2621 // Make we use native texture now.
2622 Test::VectorAnimationRenderer::UseNativeImageTexture(true);
2624 application.GetScene().Add(actor);
2626 application.SendNotification();
2627 application.Render();
2629 // Trigger count is 1 - resource ready
2630 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2632 application.SendNotification();
2633 application.Render();
2635 Renderer renderer = actor.GetRendererAt(0);
2636 Shader shader = renderer.GetShader();
2637 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
2638 Property::Map* map = value.GetMap();
2639 DALI_TEST_CHECK(map);
2641 std::string resultFragmentShader, resultVertexShader;
2642 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2643 fragment->Get(resultFragmentShader);
2644 DALI_TEST_CHECK(resultFragmentShader.find(NativeImageSourceTest::GetCustomFragmentPrefix()) != std::string::npos);
2646 // Reset to make we use normal texture again.
2647 Test::VectorAnimationRenderer::UseNativeImageTexture(false);