(Vector) Support SYNCHRONOUS_LOADING
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-AnimatedVectorImageVisual.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <stdlib.h>
18 #include <chrono>
19 #include <iostream>
20 #include <thread>
21
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
28 #include <dali-toolkit/dali-toolkit.h>
29
30 #include <dali-toolkit/devel-api/controls/control-devel.h>
31 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
32 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-actions-devel.h>
33 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-signals-devel.h>
34 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
35 #include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
36 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
37
38 #include <dali/devel-api/adaptor-framework/vector-animation-renderer.h>
39 #include <dali/devel-api/adaptor-framework/window-devel.h>
40 #include <dali/devel-api/rendering/renderer-devel.h>
41
42 using namespace Dali;
43 using namespace Dali::Toolkit;
44
45 void dali_animated_vector_image_visual_startup(void)
46 {
47   test_return_value = TET_UNDEF;
48 }
49
50 void dali_animated_vector_image_visual_cleanup(void)
51 {
52   test_return_value = TET_PASS;
53 }
54
55 namespace
56 {
57 const char* TEST_VECTOR_IMAGE_FILE_NAME            = TEST_RESOURCE_DIR "/insta_camera.json";
58 const char* TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP = "framedrop.json";
59 const char* TEST_VECTOR_IMAGE_INVALID_FILE_NAME    = "invalid.json";
60
61 bool gAnimationFinishedSignalFired = false;
62
63 void VisualEventSignal(Control control, Dali::Property::Index visualIndex, Dali::Property::Index signalId)
64 {
65   if(visualIndex == DummyControl::Property::TEST_VISUAL && signalId == DevelAnimatedVectorImageVisual::Signal::ANIMATION_FINISHED)
66   {
67     gAnimationFinishedSignalFired = true;
68   }
69 }
70
71 } // namespace
72
73 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void)
74 {
75   ToolkitTestApplication application;
76   tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual01: Request animated vector image visual with a json url");
77
78   VisualFactory factory = VisualFactory::Get();
79   Visual::Base  visual  = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
80   DALI_TEST_CHECK(visual);
81
82   DummyControl      actor     = DummyControl::New(true);
83   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
84   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
85   actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
86   application.GetScene().Add(actor);
87
88   application.SendNotification();
89   application.Render();
90
91   // Trigger count is 1 - render a frame
92   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
93
94   // renderer is added to actor
95   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
96   Renderer renderer = actor.GetRendererAt(0u);
97   DALI_TEST_CHECK(renderer);
98
99   // Test SetOffScene().
100   actor.Unparent();
101   DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
102
103   END_TEST;
104 }
105
106 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual02(void)
107 {
108   ToolkitTestApplication application;
109   tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual02: Request animated vector image visual with a Property::Map");
110
111   Property::Map propertyMap;
112   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
113     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
114     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
115
116   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
117   DALI_TEST_CHECK(visual);
118
119   DummyControl      actor     = DummyControl::New(true);
120   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
121   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
122   actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
123   application.GetScene().Add(actor);
124
125   application.SendNotification();
126   application.Render();
127
128   // Trigger count is 2 - load & render a frame
129   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
130
131   // renderer is added to actor
132   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
133   Renderer renderer = actor.GetRendererAt(0u);
134   DALI_TEST_CHECK(renderer);
135
136   actor.Unparent();
137   DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
138
139   END_TEST;
140 }
141
142 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void)
143 {
144   ToolkitTestApplication application;
145   tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual03: Request animated vector image visual with a Property::Map");
146
147   int             startFrame = 1, endFrame = 3;
148   Property::Array playRange;
149   playRange.PushBack(startFrame);
150   playRange.PushBack(endFrame);
151
152   Property::Map propertyMap;
153   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
154     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
155     .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
156     .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
157     .Add(DevelVisual::Property::CORNER_RADIUS, 50.0f)
158     .Add(DevelVisual::Property::BORDERLINE_WIDTH, 20.0f)
159     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
160
161   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
162   DALI_TEST_CHECK(visual);
163
164   DummyControl      actor     = DummyControl::New(true);
165   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
166   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
167   actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
168   application.GetScene().Add(actor);
169
170   application.SendNotification();
171   application.Render();
172
173   // Trigger count is 2 - load & render a frame
174   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
175
176   // renderer is added to actor
177   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
178   Renderer renderer = actor.GetRendererAt(0u);
179   DALI_TEST_CHECK(renderer);
180
181   actor.Unparent();
182   DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
183
184   END_TEST;
185 }
186
187 int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void)
188 {
189   ToolkitTestApplication application;
190   tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map");
191
192   int             startFrame = 1, endFrame = 3;
193   float           cornerRadius     = 22.0f;
194   float           borderlineWidth  = 2.0f;
195   Vector4         borderlineColor  = Vector4(1.0f, 1.0f, 1.0f, 1.0f);
196   float           borderlineOffset = 0.1f;
197   Property::Array playRange;
198   playRange.PushBack(startFrame);
199   playRange.PushBack(endFrame);
200
201   Property::Map propertyMap;
202   propertyMap.Add("visualType", DevelVisual::ANIMATED_VECTOR_IMAGE)
203     .Add("url", TEST_VECTOR_IMAGE_FILE_NAME)
204     .Add("loopCount", 3)
205     .Add("playRange", playRange)
206     .Add("stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME)
207     .Add("loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE)
208     .Add("redrawInScalingDown", false)
209     .Add("cornerRadius", cornerRadius)
210     .Add("borderlineWidth", borderlineWidth)
211     .Add("borderlineColor", borderlineColor)
212     .Add("borderlineOffset", borderlineOffset)
213     .Add("synchronousLoading", true);
214
215   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
216   DALI_TEST_CHECK(visual);
217
218   DummyControl      actor     = DummyControl::New(true);
219   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
220   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
221   actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
222   application.GetScene().Add(actor);
223
224   application.SendNotification();
225   application.Render();
226
227   // Trigger count is 1 - render a frame
228   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
229
230   // renderer is added to actor
231   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
232
233   Renderer renderer = actor.GetRendererAt(0u);
234   DALI_TEST_CHECK(renderer);
235
236   Property::Map resultMap;
237   visual.CreatePropertyMap(resultMap);
238
239   // check the property values from the returned map from a visual
240   Property::Value* value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
241   DALI_TEST_CHECK(value);
242   DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
243
244   value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
245   DALI_TEST_CHECK(value);
246   DALI_TEST_CHECK(value->Get<int>() == 3);
247
248   value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
249   DALI_TEST_CHECK(value);
250
251   Property::Array* result = value->GetArray();
252   DALI_TEST_CHECK(result);
253
254   DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
255   DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
256
257   value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
258   DALI_TEST_CHECK(value);
259   DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::FIRST_FRAME);
260
261   value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
262   DALI_TEST_CHECK(value);
263   DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::AUTO_REVERSE);
264
265   value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
266   DALI_TEST_CHECK(value);
267   DALI_TEST_CHECK(value->Get<bool>() == false);
268
269   value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
270   DALI_TEST_CHECK(value);
271   DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius), TEST_LOCATION);
272
273   value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
274   DALI_TEST_CHECK(value);
275   DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
276
277   value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT);
278   DALI_TEST_CHECK(value);
279   DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
280
281   value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
282   DALI_TEST_CHECK(value);
283   DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
284
285   value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
286   DALI_TEST_CHECK(value);
287   DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
288
289   actor.Unparent();
290   DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
291
292   END_TEST;
293 }
294
295 int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
296 {
297   ToolkitTestApplication application;
298   tet_infoline("UtcDaliAnimatedVectorImageVisualGetPropertyMap01");
299
300   int             startFrame = 1, endFrame = 3;
301   Vector4         cornerRadius(50.0f, 22.0f, 0.0f, 3.0f);
302   float           borderlineWidth  = 2.3f;
303   Vector4         borderlineColor  = Vector4(0.3f, 0.3f, 1.0f, 1.0f);
304   float           borderlineOffset = 0.3f;
305   Property::Array playRange;
306   playRange.PushBack(startFrame);
307   playRange.PushBack(endFrame);
308
309   Property::Map propertyMap;
310   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
311     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
312     .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
313     .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
314     .Add(DevelVisual::Property::CORNER_RADIUS, cornerRadius)
315     .Add(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::RELATIVE)
316     .Add(DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth)
317     .Add(DevelVisual::Property::BORDERLINE_COLOR, borderlineColor)
318     .Add(DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset)
319     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
320
321   // request AnimatedVectorImageVisual with a property map
322   VisualFactory factory = VisualFactory::Get();
323   Visual::Base  visual  = factory.CreateVisual(propertyMap);
324
325   DummyControl      actor     = DummyControl::New(true);
326   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
327   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
328
329   Vector2 controlSize(20.f, 30.f);
330   actor.SetProperty(Actor::Property::SIZE, controlSize);
331
332   application.GetScene().Add(actor);
333
334   application.SendNotification();
335   application.Render();
336
337   // Trigger count is 2 - load & render a frame
338   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
339
340   Property::Map resultMap;
341   resultMap = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
342
343   // check the property values from the returned map from a visual
344   Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
345   DALI_TEST_CHECK(value);
346   DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
347
348   value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
349   DALI_TEST_CHECK(value);
350   DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
351
352   value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
353   DALI_TEST_CHECK(value);
354   DALI_TEST_CHECK(value->Get<int>() == 3);
355
356   value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
357   DALI_TEST_CHECK(value);
358
359   Property::Array* result = value->GetArray();
360   DALI_TEST_CHECK(result);
361
362   DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
363   DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
364
365   value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
366   DALI_TEST_CHECK(value);
367   DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::CURRENT_FRAME);
368
369   value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
370   DALI_TEST_CHECK(value);
371   DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::RESTART);
372
373   value = resultMap.Find(DevelImageVisual::Property::CONTENT_INFO, Property::MAP);
374   DALI_TEST_CHECK(value);
375
376   value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
377   DALI_TEST_CHECK(value);
378   DALI_TEST_CHECK(value->Get<bool>() == true); // Check default value
379
380   value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
381   DALI_TEST_CHECK(value);
382   DALI_TEST_EQUALS(value->Get<Vector4>(), cornerRadius, TEST_LOCATION);
383
384   value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
385   DALI_TEST_CHECK(value);
386   DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::RELATIVE);
387
388   value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
389   DALI_TEST_CHECK(value);
390   DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
391
392   value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
393   DALI_TEST_CHECK(value);
394   DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
395
396   value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
397   DALI_TEST_CHECK(value);
398   DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
399
400   // request AnimatedVectorImageVisual with an URL
401   Visual::Base visual2 = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
402
403   resultMap.Clear();
404   visual2.CreatePropertyMap(resultMap);
405
406   // check the property values from the returned map from a visual
407   value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
408   DALI_TEST_CHECK(value);
409   DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
410
411   value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
412   DALI_TEST_CHECK(value);
413   DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
414
415   END_TEST;
416 }
417
418 int UtcDaliAnimatedVectorImageVisualPlayback(void)
419 {
420   ToolkitTestApplication application;
421
422   tet_infoline("UtcDaliAnimatedVectorImageVisualPlayback");
423
424   {
425     // request AnimatedVectorImageVisual with a property map
426     VisualFactory factory = VisualFactory::Get();
427     Visual::Base  visual  = factory.CreateVisual(
428       Property::Map()
429         .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
430         .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
431         .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
432
433     DummyControl        dummyControl = DummyControl::New(true);
434     Impl::DummyControl& dummyImpl    = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
435     dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
436     dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
437
438     Property::Map attributes;
439     tet_infoline("Test Play action");
440     DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
441
442     application.GetScene().Add(dummyControl);
443     application.SendNotification();
444     application.Render(16);
445
446     Property::Map    map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
447     Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
448     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
449
450     tet_infoline("Test Pause action");
451     DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
452
453     application.SendNotification();
454     application.Render(16);
455
456     map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
457     value = map.Find(DevelImageVisual::Property::PLAY_STATE);
458     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PAUSED);
459
460     tet_infoline("Test Play action");
461     DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
462
463     application.SendNotification();
464     application.Render(16);
465
466     map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
467     value = map.Find(DevelImageVisual::Property::PLAY_STATE);
468     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
469
470     tet_infoline("Test Stop action");
471     DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
472
473     application.SendNotification();
474     application.Render(16);
475
476     map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
477     value = map.Find(DevelImageVisual::Property::PLAY_STATE);
478     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
479
480     tet_infoline("Test Stop action again");
481     DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
482
483     application.SendNotification();
484     application.Render(16);
485
486     map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
487     value = map.Find(DevelImageVisual::Property::PLAY_STATE);
488     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
489
490     tet_infoline("Test Play action");
491     DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
492
493     application.SendNotification();
494     application.Render(16);
495
496     map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
497     value = map.Find(DevelImageVisual::Property::PLAY_STATE);
498     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
499
500     tet_infoline("Off stage");
501     dummyControl.Unparent();
502
503     application.SendNotification();
504     application.Render(16);
505
506     map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
507     value = map.Find(DevelImageVisual::Property::PLAY_STATE);
508     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
509
510     tet_infoline("On stage again");
511     application.GetScene().Add(dummyControl);
512
513     application.SendNotification();
514     application.Render(16);
515
516     map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
517     value = map.Find(DevelImageVisual::Property::PLAY_STATE);
518     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
519
520     tet_infoline("Test Play action");
521     DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
522
523     application.SendNotification();
524     application.Render(16);
525
526     map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
527     value = map.Find(DevelImageVisual::Property::PLAY_STATE);
528     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
529
530     // Change Size
531     Vector3 newSize(100.0f, 100.0f, 0.0f);
532     dummyControl.SetProperty(Actor::Property::SIZE, newSize);
533
534     application.SendNotification();
535     application.Render(16);
536
537     // Size should be changed
538     Vector3 naturalSize = dummyControl.GetNaturalSize();
539     DALI_TEST_CHECK(naturalSize == newSize);
540
541     dummyControl.Unparent();
542   }
543
544   END_TEST;
545 }
546
547 int UtcDaliAnimatedVectorImageVisualCustomShader(void)
548 {
549   ToolkitTestApplication application;
550   tet_infoline("UtcDaliAnimatedVectorImageVisualCustomShader Test custom shader");
551
552   VisualFactory     factory = VisualFactory::Get();
553   Property::Map     properties;
554   Property::Map     shader;
555   const std::string vertexShader                    = "Foobar";
556   const std::string fragmentShader                  = "Foobar sampler2D Foobar";
557   shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
558   shader[Visual::Shader::Property::VERTEX_SHADER]   = vertexShader;
559
560   properties[Visual::Property::TYPE]     = Visual::IMAGE;
561   properties[Visual::Property::SHADER]   = shader;
562   properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
563
564   Visual::Base visual = factory.CreateVisual(properties);
565
566   // trigger creation through setting on stage
567   DummyControl        dummy     = DummyControl::New(true);
568   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
569   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
570
571   dummy.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
572   dummy.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
573   application.GetScene().Add(dummy);
574
575   application.SendNotification();
576   application.Render();
577
578   // Trigger count is 1 - render a frame
579   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
580
581   Renderer        renderer = dummy.GetRendererAt(0);
582   Shader          shader2  = renderer.GetShader();
583   Property::Value value    = shader2.GetProperty(Shader::Property::PROGRAM);
584   Property::Map*  map      = value.GetMap();
585   DALI_TEST_CHECK(map);
586
587   std::string      resultFragmentShader, resultVertexShader;
588   Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
589   fragment->Get(resultFragmentShader);
590   DALI_TEST_CHECK(resultFragmentShader.find(fragmentShader) != std::string::npos);
591
592   Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
593   vertex->Get(resultVertexShader);
594   DALI_TEST_CHECK(resultVertexShader.find(vertexShader) != std::string::npos);
595
596   END_TEST;
597 }
598
599 int UtcDaliAnimatedVectorImageVisualNaturalSize(void)
600 {
601   ToolkitTestApplication application;
602   tet_infoline("UtcDaliAnimatedVectorImageVisualNaturalSize");
603
604   VisualFactory factory = VisualFactory::Get();
605   Visual::Base  visual  = factory.CreateVisual(
606     Property::Map()
607       .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
608       .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
609       .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
610   DALI_TEST_CHECK(visual);
611
612   DummyControl      actor     = DummyControl::New(true);
613   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
614   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
615
616   Vector2 controlSize(20.f, 30.f);
617   Vector2 naturalSize;
618
619   application.GetScene().Add(actor);
620
621   application.SendNotification();
622   application.Render();
623
624   // Trigger count is 1 - load
625   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
626
627   visual.GetNaturalSize(naturalSize);
628
629   DALI_TEST_EQUALS(naturalSize, Vector2(100.0f, 100.0f), TEST_LOCATION); // 100x100 is the content default size.
630
631   actor.SetProperty(Actor::Property::SIZE, controlSize);
632
633   application.SendNotification();
634   application.Render();
635
636   visual.GetNaturalSize(naturalSize);
637
638   DALI_TEST_EQUALS(naturalSize, controlSize, TEST_LOCATION);
639
640   END_TEST;
641 }
642
643 int UtcDaliAnimatedVectorImageVisualLoopCount(void)
644 {
645   ToolkitTestApplication application;
646   tet_infoline("UtcDaliAnimatedVectorImageVisualLoopCount");
647
648   Property::Map propertyMap;
649   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
650     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
651     .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
652     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
653
654   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
655   DALI_TEST_CHECK(visual);
656
657   DummyControl      actor     = DummyControl::New(true);
658   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
659   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
660
661   Vector2 controlSize(20.f, 30.f);
662   actor.SetProperty(Actor::Property::SIZE, controlSize);
663
664   application.GetScene().Add(actor);
665
666   Property::Map attributes;
667   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
668
669   application.SendNotification();
670   application.Render();
671
672   // Trigger count is 2 - load & render a frame
673   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
674
675   // renderer is added to actor
676   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
677   Renderer renderer = actor.GetRendererAt(0u);
678   DALI_TEST_CHECK(renderer);
679
680   END_TEST;
681 }
682
683 int UtcDaliAnimatedVectorImageVisualPlayRange(void)
684 {
685   ToolkitTestApplication application;
686   tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRange");
687
688   int             startFrame = 1, endFrame = 3;
689   Property::Array array;
690   array.PushBack(endFrame);
691   array.PushBack(startFrame);
692
693   Property::Map propertyMap;
694   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
695     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
696     .Add(DevelImageVisual::Property::PLAY_RANGE, array)
697     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
698
699   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
700   DALI_TEST_CHECK(visual);
701
702   DummyControl      actor     = DummyControl::New(true);
703   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
704   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
705
706   Vector2 controlSize(20.f, 30.f);
707   actor.SetProperty(Actor::Property::SIZE, controlSize);
708
709   application.GetScene().Add(actor);
710
711   Property::Map attributes;
712   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
713
714   application.SendNotification();
715   application.Render();
716
717   // Trigger count is 2 - load & render a frame
718   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
719
720   // renderer is added to actor
721   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
722   Renderer renderer = actor.GetRendererAt(0u);
723   DALI_TEST_CHECK(renderer);
724
725   Property::Map    map              = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
726   Property::Value* value            = map.Find(DevelImageVisual::Property::PLAY_RANGE);
727   int              totalFrameNumber = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER)->Get<int>();
728
729   int              resultStartFrame, resultEndFrame;
730   Property::Array* result = value->GetArray();
731   result->GetElementAt(0).Get(resultStartFrame);
732   result->GetElementAt(1).Get(resultEndFrame);
733
734   DALI_TEST_EQUALS(startFrame, resultStartFrame, TEST_LOCATION);
735   DALI_TEST_EQUALS(endFrame, resultEndFrame, TEST_LOCATION);
736
737   // Set invalid play range
738   array.Clear();
739   array.PushBack(1);
740   array.PushBack(100);
741
742   attributes.Clear();
743   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
744   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
745
746   // To make event trigger
747   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
748
749   application.SendNotification();
750   application.Render();
751
752   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
753
754   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
755   value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
756
757   result = value->GetArray();
758   result->GetElementAt(0).Get(resultStartFrame);
759   result->GetElementAt(1).Get(resultEndFrame);
760
761   DALI_TEST_EQUALS(resultStartFrame, 1, TEST_LOCATION);
762   DALI_TEST_EQUALS(resultEndFrame, totalFrameNumber - 1, TEST_LOCATION); // Should be clamped
763
764   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, Property::Map());
765
766   application.SendNotification();
767   application.Render();
768
769   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
770
771   // To make event trigger
772   actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
773
774   application.SendNotification();
775   application.Render();
776
777   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
778
779   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
780   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
781   DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
782
783   array.Clear();
784   array.PushBack(0);
785   array.PushBack(2);
786
787   attributes.Clear();
788   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
789   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
790
791   // To make event trigger
792   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
793
794   application.SendNotification();
795   application.Render();
796
797   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
798
799   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
800   value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
801
802   result = value->GetArray();
803   result->GetElementAt(0).Get(resultStartFrame);
804   result->GetElementAt(1).Get(resultEndFrame);
805
806   DALI_TEST_EQUALS(0, resultStartFrame, TEST_LOCATION);
807   DALI_TEST_EQUALS(2, resultEndFrame, TEST_LOCATION);
808
809   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
810   DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION); // CURRENT_FRAME_NUMBER should be changed also.
811
812   END_TEST;
813 }
814
815 int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void)
816 {
817   ToolkitTestApplication application;
818   tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRangeMarker");
819
820   Property::Array array;
821   array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
822
823   Property::Map propertyMap;
824   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
825     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
826     .Add(DevelImageVisual::Property::PLAY_RANGE, array)
827     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
828
829   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
830   DALI_TEST_CHECK(visual);
831
832   DummyControl      actor     = DummyControl::New(true);
833   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
834   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
835
836   Vector2 controlSize(20.f, 30.f);
837   actor.SetProperty(Actor::Property::SIZE, controlSize);
838
839   application.GetScene().Add(actor);
840
841   Property::Map attributes;
842   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
843
844   application.SendNotification();
845   application.Render();
846
847   // Trigger count is 2 - load & render a frame
848   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
849
850   // renderer is added to actor
851   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
852   Renderer renderer = actor.GetRendererAt(0u);
853   DALI_TEST_CHECK(renderer);
854
855   Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
856   Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
857
858   int              resultStartFrame, resultEndFrame;
859   Property::Array* result = value->GetArray();
860   result->GetElementAt(0).Get(resultStartFrame);
861   result->GetElementAt(1).Get(resultEndFrame);
862
863   DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
864   DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
865
866   // Set 2 markers
867   array.Clear();
868   array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
869   array.PushBack(VECTOR_ANIMATION_MARKER_NAME_2);
870
871   attributes.Clear();
872   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
873   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
874
875   // To make event trigger
876   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
877
878   application.SendNotification();
879   application.Render();
880
881   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
882
883   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
884   value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
885
886   result = value->GetArray();
887   result->GetElementAt(0).Get(resultStartFrame);
888   result->GetElementAt(1).Get(resultEndFrame);
889
890   DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
891   DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
892
893   // Set invalid play range
894   array.Clear();
895   array.PushBack(1);
896   array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
897
898   attributes.Clear();
899   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
900   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
901
902   // To make event trigger
903   actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
904
905   application.SendNotification();
906   application.Render();
907
908   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
909
910   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
911   value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
912
913   result = value->GetArray();
914   result->GetElementAt(0).Get(resultStartFrame);
915   result->GetElementAt(1).Get(resultEndFrame);
916
917   DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION); // Should not be changed
918   DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
919
920   END_TEST;
921 }
922
923 int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
924 {
925   ToolkitTestApplication application;
926   tet_infoline("UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal");
927
928   Property::Map propertyMap;
929   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
930     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
931     .Add(DevelImageVisual::Property::LOOP_COUNT, 3);
932
933   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
934   DALI_TEST_CHECK(visual);
935
936   DummyControl      actor     = DummyControl::New(true);
937   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
938   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
939
940   DevelControl::VisualEventSignal(actor).Connect(&VisualEventSignal);
941
942   Vector2 controlSize(20.f, 30.f);
943   actor.SetProperty(Actor::Property::SIZE, controlSize);
944
945   application.GetScene().Add(actor);
946
947   Property::Map attributes;
948   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
949
950   application.SendNotification();
951   application.Render();
952
953   // Wait for animation finish - render, finish
954   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
955
956   Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
957   Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
958   DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
959
960   DALI_TEST_EQUALS(gAnimationFinishedSignalFired, true, TEST_LOCATION);
961
962   END_TEST;
963 }
964
965 int UtcDaliAnimatedVectorImageVisualJumpTo(void)
966 {
967   ToolkitTestApplication application;
968   tet_infoline("UtcDaliAnimatedVectorImageVisualJumpTo");
969
970   Property::Map propertyMap;
971   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
972     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
973     .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
974     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
975
976   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
977   DALI_TEST_CHECK(visual);
978
979   tet_printf("1. Visual is created.\n");
980
981   DummyControl      actor     = DummyControl::New(true);
982   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
983   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
984
985   Vector2 controlSize(20.f, 30.f);
986   actor.SetProperty(Actor::Property::SIZE, controlSize);
987
988   application.GetScene().Add(actor);
989
990   application.SendNotification();
991   application.Render();
992
993   // Trigger count is 2 - load & render a frame
994   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
995
996   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2);
997
998   // To make event trigger
999   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1000
1001   application.SendNotification();
1002   application.Render();
1003
1004   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1005
1006   Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1007   Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1008   DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1009
1010   tet_printf("2. The current frame number is [%d].\n", value->Get<int>());
1011
1012   Property::Array array;
1013   array.PushBack(0);
1014   array.PushBack(2);
1015
1016   Property::Map attributes;
1017   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1018   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1019
1020   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1021
1022   // To make event trigger
1023   actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1024
1025   application.SendNotification();
1026   application.Render();
1027
1028   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1029
1030   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1031   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1032   DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1033
1034   tet_printf("3. The current frame number is [%d].\n", value->Get<int>());
1035
1036   // Change play range
1037   attributes.Clear();
1038   array.Clear();
1039
1040   array.PushBack(0);
1041   array.PushBack(4);
1042
1043   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1044   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1045
1046   attributes.Clear();
1047   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1048
1049   application.SendNotification();
1050   application.Render();
1051
1052   // Wait for animation finish
1053   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1054
1055   // Jump to 3
1056   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1057
1058   // To make event trigger
1059   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1060
1061   application.SendNotification();
1062   application.Render();
1063
1064   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1065
1066   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1067   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1068   DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1069
1070   tet_printf("4. The current frame number is [%d].\n", value->Get<int>());
1071
1072   // Jump to the same position
1073   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1074
1075   // To make event trigger
1076   actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1077
1078   application.SendNotification();
1079   application.Render();
1080
1081   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1082
1083   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1084   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1085   DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1086
1087   tet_printf("5. The current frame number is [%d].\n", value->Get<int>());
1088
1089   END_TEST;
1090 }
1091
1092 int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
1093 {
1094   ToolkitTestApplication application;
1095   tet_infoline("UtcDaliAnimatedVectorImageVisualUpdateProperty");
1096
1097   int             startFrame = 1, endFrame = 3;
1098   Property::Array playRange;
1099   playRange.PushBack(startFrame);
1100   playRange.PushBack(endFrame);
1101
1102   Property::Map propertyMap;
1103   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1104     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1105     .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1106     .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
1107     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1108
1109   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1110   DALI_TEST_CHECK(visual);
1111
1112   DummyControl      actor     = DummyControl::New(true);
1113   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1114   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1115
1116   Vector2 controlSize(20.f, 30.f);
1117   actor.SetProperty(Actor::Property::SIZE, controlSize);
1118
1119   application.GetScene().Add(actor);
1120
1121   application.SendNotification();
1122   application.Render();
1123
1124   // Trigger count is 2 - load & render a frame
1125   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1126
1127   Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1128   Property::Value* value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1129   DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1130
1131   value = map.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
1132   DALI_TEST_CHECK(value);
1133
1134   Property::Array* result = value->GetArray();
1135   DALI_TEST_CHECK(result);
1136
1137   DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1138   DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1139
1140   playRange.Clear();
1141   playRange.PushBack(0);
1142   playRange.PushBack(2);
1143
1144   Property::Map attributes;
1145   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1146   attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 5);
1147
1148   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1149
1150   // To make event trigger
1151   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1152
1153   application.SendNotification();
1154   application.Render();
1155
1156   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1157
1158   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1159   value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1160   DALI_TEST_EQUALS(value->Get<int>(), 5, TEST_LOCATION);
1161
1162   value  = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1163   result = value->GetArray();
1164   DALI_TEST_CHECK(result);
1165
1166   DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == 0);
1167   DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == 2);
1168
1169   attributes.Clear();
1170
1171   playRange.Clear();
1172   playRange.PushBack(startFrame);
1173   playRange.PushBack(endFrame);
1174
1175   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1176
1177   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1178
1179   // To make event trigger
1180   actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1181
1182   application.SendNotification();
1183   application.Render();
1184
1185   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1186
1187   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1188   value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1189
1190   result = value->GetArray();
1191   DALI_TEST_CHECK(result);
1192
1193   DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1194   DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1195
1196   // Play and update property
1197   attributes.Clear();
1198   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1199
1200   application.SendNotification();
1201   application.Render();
1202
1203   attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 10);
1204
1205   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1206
1207   application.SendNotification();
1208   application.Render();
1209
1210   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1211   value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1212   DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
1213
1214   END_TEST;
1215 }
1216
1217 int UtcDaliAnimatedVectorImageVisualStopBehavior(void)
1218 {
1219   ToolkitTestApplication application;
1220   tet_infoline("UtcDaliAnimatedVectorImageVisualStopBehavior");
1221
1222   Property::Map propertyMap;
1223   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1224     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1225     .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1226     .Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME)
1227     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1228
1229   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1230   DALI_TEST_CHECK(visual);
1231
1232   DummyControl      actor     = DummyControl::New(true);
1233   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1234   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1235
1236   Vector2 controlSize(20.f, 30.f);
1237   actor.SetProperty(Actor::Property::SIZE, controlSize);
1238
1239   application.GetScene().Add(actor);
1240
1241   Property::Map attributes;
1242   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1243
1244   application.SendNotification();
1245   application.Render();
1246
1247   // Trigger count is 3 - load, render, animation finished
1248   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1249
1250   Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1251   Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1252   DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1253
1254   // Change stop behavior
1255   attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1256
1257   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1258
1259   attributes.Clear();
1260
1261   // Play again
1262   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1263
1264   application.SendNotification();
1265   application.Render();
1266
1267   // Trigger count is 1 - animation finished
1268   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1269
1270   map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1271
1272   Property::Value* value1           = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1273   int              totalFrameNumber = value1->Get<int>();
1274
1275   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1276   DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1277
1278   // Change stop behavior
1279   attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1280   attributes.Add(DevelImageVisual::Property::LOOP_COUNT, -1);
1281
1282   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1283
1284   attributes.Clear();
1285
1286   // Play again
1287   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1288
1289   application.SendNotification();
1290   application.Render();
1291
1292   // Pause
1293   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
1294
1295   // To make event trigger
1296   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1297
1298   application.SendNotification();
1299   application.Render();
1300
1301   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1302
1303   map                    = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1304   value                  = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1305   int currentFrameNumber = value->Get<int>();
1306
1307   // Stop
1308   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
1309
1310   // To make event trigger
1311   actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1312
1313   application.SendNotification();
1314   application.Render();
1315
1316   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1317
1318   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1319   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1320   DALI_TEST_EQUALS(value->Get<int>(), currentFrameNumber, TEST_LOCATION); // Should be same with currentFrameNumber
1321
1322   END_TEST;
1323 }
1324
1325 int UtcDaliAnimatedVectorImageVisualLoopingMode(void)
1326 {
1327   ToolkitTestApplication application;
1328   tet_infoline("UtcDaliAnimatedVectorImageVisualLoopingMode");
1329
1330   Property::Map propertyMap;
1331   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1332     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1333     .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1334     .Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME)
1335     .Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::AUTO_REVERSE)
1336     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1337
1338   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1339   DALI_TEST_CHECK(visual);
1340
1341   DummyControl      actor     = DummyControl::New(true);
1342   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1343   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1344
1345   Vector2 controlSize(20.f, 30.f);
1346   actor.SetProperty(Actor::Property::SIZE, controlSize);
1347
1348   application.GetScene().Add(actor);
1349
1350   Property::Map attributes;
1351   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1352
1353   application.SendNotification();
1354   application.Render();
1355
1356   // Trigger count is 3 - load, render, animation finished
1357   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1358
1359   Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1360   Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1361   DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame because of auto reverse
1362
1363   // Change stop behavior
1364   attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1365
1366   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1367
1368   // Play again
1369   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1370
1371   application.SendNotification();
1372   application.Render();
1373
1374   // Trigger count is 1 - animation finished
1375   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1376
1377   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1378   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1379   DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1380
1381   // Change looping mode
1382   attributes.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::RESTART);
1383
1384   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1385
1386   // Play again
1387   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1388
1389   application.SendNotification();
1390   application.Render();
1391
1392   // Trigger count is 1 - animation finished
1393   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1394
1395   Property::Value* value1           = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1396   int              totalFrameNumber = value1->Get<int>();
1397
1398   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1399   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1400   DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1401
1402   END_TEST;
1403 }
1404
1405 int UtcDaliAnimatedVectorImageVisualPropertyNotification(void)
1406 {
1407   ToolkitTestApplication application;
1408   tet_infoline("UtcDaliAnimatedVectorImageVisualPropertyNotification");
1409
1410   Property::Map propertyMap;
1411   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1412     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1413
1414   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1415   DALI_TEST_CHECK(visual);
1416
1417   DummyControl      actor     = DummyControl::New(true);
1418   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1419   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1420   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1421
1422   application.GetScene().Add(actor);
1423
1424   application.SendNotification();
1425   application.Render();
1426
1427   // Trigger count is 1 - render a frame
1428   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1429
1430   Renderer renderer = actor.GetRendererAt(0u);
1431   DALI_TEST_CHECK(renderer);
1432
1433   Vector2 controlSize(20.f, 30.f);
1434   actor.SetProperty(Actor::Property::SIZE, controlSize);
1435
1436   application.SendNotification();
1437   application.Render();
1438
1439   application.SendNotification();
1440   application.Render();
1441
1442   // Trigger count is 1 - render a frame
1443   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1444
1445   auto textureSet = renderer.GetTextures();
1446   auto texture    = textureSet.GetTexture(0);
1447
1448   DALI_TEST_EQUALS(controlSize.width, texture.GetWidth(), TEST_LOCATION);
1449   DALI_TEST_EQUALS(controlSize.height, texture.GetHeight(), TEST_LOCATION);
1450
1451   // Change scale
1452   Vector3 controlScale(2.0f, 2.0f, 1.0f);
1453   actor.SetProperty(Actor::Property::SCALE, controlScale);
1454
1455   application.SendNotification();
1456   application.Render();
1457
1458   application.SendNotification();
1459   application.Render();
1460
1461   // Trigger count is 1 - render a frame
1462   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1463
1464   renderer = actor.GetRendererAt(0u);
1465   DALI_TEST_CHECK(renderer);
1466
1467   textureSet = renderer.GetTextures();
1468   texture    = textureSet.GetTexture(0);
1469
1470   DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1471   DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1472
1473   // Size animation
1474   controlSize         = Vector2(50.0f, 100.0f);
1475   Animation animation = Animation::New(1.0);
1476   animation.AnimateTo(Property(actor, Actor::Property::SIZE), Vector3(controlSize.x, controlSize.y, 0.0f));
1477   animation.Play();
1478
1479   application.SendNotification();
1480   application.Render(1100); // After the animation
1481
1482   application.SendNotification();
1483   application.Render();
1484
1485   // Trigger count is 1 - render a frame
1486   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1487
1488   renderer = actor.GetRendererAt(0u);
1489   DALI_TEST_CHECK(renderer);
1490
1491   textureSet = renderer.GetTextures();
1492   texture    = textureSet.GetTexture(0);
1493
1494   DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1495   DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1496
1497   END_TEST;
1498 }
1499
1500 int UtcDaliAnimatedVectorImageVisualMultipleInstances(void)
1501 {
1502   ToolkitTestApplication application;
1503   tet_infoline("UtcDaliAnimatedVectorImageVisualMultipleInstances");
1504
1505   Property::Map propertyMap;
1506   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1507     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1508     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1509
1510   Visual::Base visual1 = VisualFactory::Get().CreateVisual(propertyMap);
1511   DALI_TEST_CHECK(visual1);
1512
1513   DummyControl      actor1     = DummyControl::New(true);
1514   DummyControlImpl& dummyImpl1 = static_cast<DummyControlImpl&>(actor1.GetImplementation());
1515   dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual1);
1516
1517   Vector2 controlSize(20.f, 30.f);
1518   actor1.SetProperty(Actor::Property::SIZE, controlSize);
1519
1520   application.GetScene().Add(actor1);
1521
1522   propertyMap.Clear();
1523   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1524     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1525     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1526
1527   Visual::Base visual2 = VisualFactory::Get().CreateVisual(propertyMap);
1528   DALI_TEST_CHECK(visual2);
1529
1530   DummyControl      actor2     = DummyControl::New(true);
1531   DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor2.GetImplementation());
1532   dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
1533
1534   actor2.SetProperty(Actor::Property::SIZE, controlSize);
1535
1536   application.GetScene().Add(actor2);
1537
1538   application.SendNotification();
1539   application.Render();
1540
1541   // Trigger count is 4 - load & render a frame for each instance
1542   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1543
1544   DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1545
1546   // To make event trigger
1547   actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1548
1549   application.SendNotification();
1550   application.Render();
1551
1552   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1553
1554   Property::Map attributes;
1555   attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1556
1557   DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1558   DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1559
1560   DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1561
1562   // renderer is added to actor
1563   DALI_TEST_CHECK(actor1.GetRendererCount() == 1u);
1564   Renderer renderer1 = actor1.GetRendererAt(0u);
1565   DALI_TEST_CHECK(renderer1);
1566
1567   // renderer is added to actor
1568   DALI_TEST_CHECK(actor2.GetRendererCount() == 1u);
1569   Renderer renderer2 = actor2.GetRendererAt(0u);
1570   DALI_TEST_CHECK(renderer2);
1571
1572   END_TEST;
1573 }
1574
1575 int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void)
1576 {
1577   ToolkitTestApplication application;
1578   tet_infoline("UtcDaliAnimatedVectorImageVisualControlVisibilityChanged");
1579
1580   Property::Map propertyMap;
1581   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1582     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1583     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1584
1585   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1586   DALI_TEST_CHECK(visual);
1587
1588   DummyControl      actor     = DummyControl::New(true);
1589   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1590   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1591
1592   Vector2 controlSize(20.f, 30.f);
1593   actor.SetProperty(Actor::Property::SIZE, controlSize);
1594
1595   application.GetScene().Add(actor);
1596
1597   application.SendNotification();
1598   application.Render();
1599
1600   // Trigger count is 2 - load & render a frame
1601   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1602
1603   Property::Map attributes;
1604   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1605
1606   application.SendNotification();
1607   application.Render();
1608
1609   // Check rendering behavior
1610   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1611   Renderer renderer = actor.GetRendererAt(0u);
1612   DALI_TEST_CHECK(renderer);
1613   DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1614
1615   actor.SetProperty(Actor::Property::VISIBLE, false);
1616
1617   application.SendNotification();
1618   application.Render();
1619
1620   // Check rendering behavior again
1621   DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1622
1623   END_TEST;
1624 }
1625
1626 int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void)
1627 {
1628   ToolkitTestApplication application;
1629   tet_infoline("UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged");
1630
1631   Property::Map propertyMap;
1632   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1633     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1634
1635   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1636   DALI_TEST_CHECK(visual);
1637
1638   DummyControl      actor     = DummyControl::New(true);
1639   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1640   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1641
1642   Vector2 controlSize(20.f, 30.f);
1643   actor.SetProperty(Actor::Property::SIZE, controlSize);
1644
1645   application.GetScene().Add(actor);
1646
1647   application.SendNotification();
1648   application.Render();
1649
1650   // Trigger count is 1 - render a frame
1651   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1652
1653   Property::Map attributes;
1654   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1655
1656   application.SendNotification();
1657   application.Render();
1658
1659   // Check rendering behavior
1660   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1661   Renderer renderer = actor.GetRendererAt(0u);
1662   DALI_TEST_CHECK(renderer);
1663   DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1664
1665   Window window = DevelWindow::Get(actor);
1666   window.Hide();
1667
1668   application.SendNotification();
1669   application.Render();
1670
1671   // Check rendering behavior again
1672   DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1673
1674   END_TEST;
1675 }
1676
1677 int UtcDaliAnimatedVectorImageVisualInvalidFile01(void)
1678 {
1679   ToolkitTestApplication application;
1680   tet_infoline("Request loading with invalid file - should draw broken image");
1681
1682   TestGlAbstraction& gl           = application.GetGlAbstraction();
1683   TraceCallStack&    textureTrace = gl.GetTextureTrace();
1684   textureTrace.Enable(true);
1685
1686   Property::Map propertyMap;
1687   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1688     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1689     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1690
1691   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1692   DALI_TEST_CHECK(visual);
1693
1694   DummyControl      actor     = DummyControl::New(true);
1695   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1696   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1697
1698   actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1699
1700   application.GetScene().Add(actor);
1701
1702   application.SendNotification();
1703   application.Render();
1704
1705   // Trigger count is 1 - load
1706   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1707
1708   application.SendNotification();
1709   application.Render();
1710
1711   // Check resource status
1712   Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1713   DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1714
1715   // The broken image should be shown.
1716   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1717   DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1718
1719   END_TEST;
1720 }
1721
1722 int UtcDaliAnimatedVectorImageVisualInvalidFile02(void)
1723 {
1724   ToolkitTestApplication application;
1725   tet_infoline("Request loading with invalid file - should draw broken image");
1726
1727   TestGlAbstraction& gl           = application.GetGlAbstraction();
1728   TraceCallStack&    textureTrace = gl.GetTextureTrace();
1729   textureTrace.Enable(true);
1730
1731   Property::Map propertyMap;
1732   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1733     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
1734
1735   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1736   DALI_TEST_CHECK(visual);
1737
1738   DummyControl      actor     = DummyControl::New(true);
1739   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1740   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1741
1742   actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1743
1744   application.SendNotification();
1745   application.Render();
1746
1747   // Add to the Scene after loading
1748   application.GetScene().Add(actor);
1749
1750   application.SendNotification();
1751   application.Render();
1752
1753   // Check resource status
1754   Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1755   DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1756
1757   // The broken image should be shown.
1758   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1759   DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1760
1761   END_TEST;
1762 }
1763
1764 int UtcDaliAnimatedVectorImageVisualInvalidFile03(void)
1765 {
1766   ToolkitTestApplication application;
1767   tet_infoline("Request loading with invalid file without size set - should draw broken image");
1768
1769   TestGlAbstraction& gl           = application.GetGlAbstraction();
1770   TraceCallStack&    textureTrace = gl.GetTextureTrace();
1771   textureTrace.Enable(true);
1772
1773   Property::Map propertyMap;
1774   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1775     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1776     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1777
1778   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1779   DALI_TEST_CHECK(visual);
1780
1781   DummyControl      actor     = DummyControl::New(true);
1782   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1783   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1784
1785   application.GetScene().Add(actor);
1786
1787   application.SendNotification();
1788   application.Render();
1789
1790   // Trigger count is 1 - load
1791   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1792
1793   application.SendNotification();
1794   application.Render();
1795
1796   // Check resource status
1797   Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1798   DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1799
1800   // The broken image should be shown.
1801   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1802   DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1803
1804   END_TEST;
1805 }
1806
1807 int UtcDaliAnimatedVectorImageVisualFrameDrops(void)
1808 {
1809   ToolkitTestApplication application;
1810   tet_infoline("UtcDaliAnimatedVectorImageVisualFrameDrops");
1811
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_FRAME_DROP)
1815     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1816
1817   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1818   DALI_TEST_CHECK(visual);
1819
1820   DummyControl      actor     = DummyControl::New(true);
1821   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1822   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1823
1824   Vector2 controlSize(20.f, 30.f);
1825   actor.SetProperty(Actor::Property::SIZE, controlSize);
1826
1827   application.GetScene().Add(actor);
1828
1829   application.SendNotification();
1830   application.Render();
1831
1832   // Trigger count is 2 - load, render the first frame
1833   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1834
1835   Property::Map    map              = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1836   Property::Value* value            = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1837   int              totalFrameNumber = value->Get<int>();
1838
1839   Property::Map attributes;
1840   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1841
1842   // Make delay to drop frames
1843   Test::VectorAnimationRenderer::DelayRendering(170); // longer than 16.6 * 10frames
1844
1845   application.SendNotification();
1846   application.Render();
1847
1848   // Trigger count is 1 - calculating frame drops
1849   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1850
1851   // Check dropped frame
1852   uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames();
1853   DALI_TEST_CHECK(frames > 0);
1854   DALI_TEST_CHECK(frames <= static_cast<uint32_t>(totalFrameNumber));
1855
1856   END_TEST;
1857 }
1858
1859 int UtcDaliAnimatedVectorImageVisualSize(void)
1860 {
1861   ToolkitTestApplication application;
1862   tet_infoline("UtcDaliAnimatedVectorImageVisualSize");
1863
1864   TestGlAbstraction& gl           = application.GetGlAbstraction();
1865   TraceCallStack&    textureTrace = gl.GetTextureTrace();
1866
1867   VisualFactory factory = VisualFactory::Get();
1868   Visual::Base  visual  = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
1869   DALI_TEST_CHECK(visual);
1870
1871   DummyControl      actor     = DummyControl::New(true);
1872   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1873   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1874
1875   application.GetScene().Add(actor);
1876
1877   application.SendNotification();
1878   application.Render();
1879
1880   // Trigger count is 1 - resource ready
1881   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1882
1883   textureTrace.Enable(true);
1884
1885   application.SendNotification();
1886   application.Render();
1887
1888   {
1889     int               width = 100, height = 100; // 100x100 is the content default size.
1890     std::stringstream out;
1891     out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
1892     DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
1893   }
1894
1895   actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
1896
1897   application.SendNotification();
1898   application.Render();
1899
1900   // Trigger count is 1 - resource ready
1901   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1902
1903   textureTrace.Reset();
1904
1905   application.SendNotification();
1906   application.Render();
1907
1908   {
1909     int               width = 200, height = 200;
1910     std::stringstream out;
1911     out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
1912     DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
1913   }
1914
1915   END_TEST;
1916 }
1917
1918 namespace
1919 {
1920 bool gDynamicPropertyCallbackFired = false;
1921
1922 Property::Value FillColorCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber)
1923 {
1924   gDynamicPropertyCallbackFired = true;
1925
1926   if(frameNumber < 3)
1927   {
1928     return Vector3(0, 0, 1);
1929   }
1930   else
1931   {
1932     return Vector3(1, 0, 0);
1933   }
1934 }
1935 } // namespace
1936
1937 int UtcDaliAnimatedVectorImageVisualDynamicProperty(void)
1938 {
1939   ToolkitTestApplication application;
1940   tet_infoline("UtcDaliAnimatedVectorImageVisualDynamicProperty");
1941
1942   VisualFactory factory = VisualFactory::Get();
1943   Visual::Base  visual  = factory.CreateVisual(
1944     Property::Map()
1945       .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1946       .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1947       .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
1948   DALI_TEST_CHECK(visual);
1949
1950   DummyControl      actor     = DummyControl::New(true);
1951   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1952   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1953
1954   application.GetScene().Add(actor);
1955
1956   gDynamicPropertyCallbackFired = false;
1957
1958   // Set dynamic property
1959   DevelAnimatedVectorImageVisual::DynamicPropertyInfo info;
1960   info.id       = 1;
1961   info.keyPath  = "Test.Path";
1962   info.property = static_cast<int>(VectorAnimationRenderer::VectorProperty::FILL_COLOR);
1963   info.callback = MakeCallback(FillColorCallback);
1964
1965   DevelControl::DoActionExtension(actor, DummyControl::Property::TEST_VISUAL, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info));
1966
1967   Property::Map attributes;
1968   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1969
1970   application.SendNotification();
1971   application.Render();
1972
1973   // Trigger count is 2 - load & render a frame
1974   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1975
1976   // Test whether the property callback is called
1977   DALI_TEST_EQUALS(gDynamicPropertyCallbackFired, true, TEST_LOCATION);
1978
1979   END_TEST;
1980 }