Merge "Change Property name USE_FIXED_CACHE to ENABLE_FRAME_CACHE" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-AnimatedVectorImageVisual.cpp
1 /*
2  * Copyright (c) 2023 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   int             desiredWidth = 100, desiredHeight = 150;
194   float           cornerRadius     = 22.0f;
195   float           borderlineWidth  = 2.0f;
196   Vector4         borderlineColor  = Vector4(1.0f, 1.0f, 1.0f, 1.0f);
197   float           borderlineOffset = 0.1f;
198   Property::Array playRange;
199   playRange.PushBack(startFrame);
200   playRange.PushBack(endFrame);
201
202   Property::Map propertyMap;
203   propertyMap.Add("visualType", DevelVisual::ANIMATED_VECTOR_IMAGE)
204     .Add("url", TEST_VECTOR_IMAGE_FILE_NAME)
205     .Add("loopCount", 3)
206     .Add("playRange", playRange)
207     .Add("stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME)
208     .Add("loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE)
209     .Add("redrawInScalingDown", false)
210     .Add("cornerRadius", cornerRadius)
211     .Add("borderlineWidth", borderlineWidth)
212     .Add("borderlineColor", borderlineColor)
213     .Add("borderlineOffset", borderlineOffset)
214     .Add("desiredWidth", desiredWidth)
215     .Add("desiredHeight", desiredHeight)
216     .Add("useFixedCache", false);
217
218   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
219   DALI_TEST_CHECK(visual);
220
221   DummyControl      actor     = DummyControl::New(true);
222   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
223   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
224   actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
225   application.GetScene().Add(actor);
226
227   application.SendNotification();
228   application.Render();
229
230   // Trigger count is 1 - render a frame
231   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
232
233   // renderer is added to actor
234   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
235
236   Renderer renderer = actor.GetRendererAt(0u);
237   DALI_TEST_CHECK(renderer);
238
239   Property::Map resultMap;
240   visual.CreatePropertyMap(resultMap);
241
242   // check the property values from the returned map from a visual
243   Property::Value* value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
244   DALI_TEST_CHECK(value);
245   DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
246
247   value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
248   DALI_TEST_CHECK(value);
249   DALI_TEST_CHECK(value->Get<int>() == 3);
250
251   value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
252   DALI_TEST_CHECK(value);
253
254   Property::Array* result = value->GetArray();
255   DALI_TEST_CHECK(result);
256
257   DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
258   DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
259
260   value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
261   DALI_TEST_CHECK(value);
262   DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::FIRST_FRAME);
263
264   value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
265   DALI_TEST_CHECK(value);
266   DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::AUTO_REVERSE);
267
268   value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
269   DALI_TEST_CHECK(value);
270   DALI_TEST_CHECK(value->Get<bool>() == false);
271
272   value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
273   DALI_TEST_CHECK(value);
274   DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius), TEST_LOCATION);
275
276   value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
277   DALI_TEST_CHECK(value);
278   DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
279
280   value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT);
281   DALI_TEST_CHECK(value);
282   DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
283
284   value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
285   DALI_TEST_CHECK(value);
286   DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
287
288   value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
289   DALI_TEST_CHECK(value);
290   DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
291
292   value = resultMap.Find(ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER);
293   DALI_TEST_CHECK(value);
294   DALI_TEST_EQUALS(value->Get<int>(), desiredWidth, TEST_LOCATION);
295
296   value = resultMap.Find(ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER);
297   DALI_TEST_CHECK(value);
298   DALI_TEST_EQUALS(value->Get<int>(), desiredHeight, TEST_LOCATION);
299
300   actor.Unparent();
301   DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
302
303   END_TEST;
304 }
305
306 int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
307 {
308   ToolkitTestApplication application;
309   tet_infoline("UtcDaliAnimatedVectorImageVisualGetPropertyMap01");
310
311   int             startFrame = 1, endFrame = 3;
312   int             desiredWidth = 100, desiredHeight = 150;
313   Vector4         cornerRadius(50.0f, 22.0f, 0.0f, 3.0f);
314   float           borderlineWidth  = 2.3f;
315   Vector4         borderlineColor  = Vector4(0.3f, 0.3f, 1.0f, 1.0f);
316   float           borderlineOffset = 0.3f;
317   Property::Array playRange;
318   playRange.PushBack(startFrame);
319   playRange.PushBack(endFrame);
320
321   Property::Map propertyMap;
322   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
323     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
324     .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
325     .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
326     .Add(DevelVisual::Property::CORNER_RADIUS, cornerRadius)
327     .Add(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::RELATIVE)
328     .Add(DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth)
329     .Add(DevelVisual::Property::BORDERLINE_COLOR, borderlineColor)
330     .Add(DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset)
331     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false)
332     .Add(ImageVisual::Property::DESIRED_WIDTH, desiredWidth)
333     .Add(ImageVisual::Property::DESIRED_HEIGHT, desiredHeight);
334
335   // request AnimatedVectorImageVisual with a property map
336   VisualFactory factory = VisualFactory::Get();
337   Visual::Base  visual  = factory.CreateVisual(propertyMap);
338
339   DummyControl      actor     = DummyControl::New(true);
340   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
341   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
342
343   Vector2 controlSize(20.f, 30.f);
344   actor.SetProperty(Actor::Property::SIZE, controlSize);
345
346   application.GetScene().Add(actor);
347
348   application.SendNotification();
349   application.Render();
350
351   // Trigger count is 2 - load & render a frame
352   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
353
354   Property::Map resultMap;
355   resultMap = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
356
357   // check the property values from the returned map from a visual
358   Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
359   DALI_TEST_CHECK(value);
360   DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
361
362   value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
363   DALI_TEST_CHECK(value);
364   DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
365
366   value = resultMap.Find(DevelImageVisual::Property::LOOP_COUNT, Property::INTEGER);
367   DALI_TEST_CHECK(value);
368   DALI_TEST_CHECK(value->Get<int>() == 3);
369
370   value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
371   DALI_TEST_CHECK(value);
372
373   Property::Array* result = value->GetArray();
374   DALI_TEST_CHECK(result);
375
376   DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
377   DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
378
379   value = resultMap.Find(DevelImageVisual::Property::STOP_BEHAVIOR, Property::INTEGER);
380   DALI_TEST_CHECK(value);
381   DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::StopBehavior::CURRENT_FRAME);
382
383   value = resultMap.Find(DevelImageVisual::Property::LOOPING_MODE, Property::INTEGER);
384   DALI_TEST_CHECK(value);
385   DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::LoopingMode::RESTART);
386
387   value = resultMap.Find(DevelImageVisual::Property::CONTENT_INFO, Property::MAP);
388   DALI_TEST_CHECK(value);
389
390   value = resultMap.Find(DevelImageVisual::Property::MARKER_INFO, Property::MAP);
391   DALI_TEST_CHECK(value);
392
393   value = resultMap.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE, Property::BOOLEAN);
394   DALI_TEST_CHECK(value);
395   DALI_TEST_CHECK(value->Get<bool>() == false); // Check default value
396
397   value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
398   DALI_TEST_CHECK(value);
399   DALI_TEST_CHECK(value->Get<bool>() == true); // Check default value
400
401   value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
402   DALI_TEST_CHECK(value);
403   DALI_TEST_EQUALS(value->Get<Vector4>(), cornerRadius, TEST_LOCATION);
404
405   value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
406   DALI_TEST_CHECK(value);
407   DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::RELATIVE);
408
409   value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
410   DALI_TEST_CHECK(value);
411   DALI_TEST_EQUALS(value->Get<float>(), borderlineWidth, TEST_LOCATION);
412
413   value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
414   DALI_TEST_CHECK(value);
415   DALI_TEST_EQUALS(value->Get<Vector4>(), borderlineColor, TEST_LOCATION);
416
417   value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
418   DALI_TEST_CHECK(value);
419   DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
420
421   value = resultMap.Find(ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER);
422   DALI_TEST_CHECK(value);
423   DALI_TEST_EQUALS(value->Get<int>(), desiredWidth, TEST_LOCATION);
424
425   value = resultMap.Find(ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER);
426   DALI_TEST_CHECK(value);
427   DALI_TEST_EQUALS(value->Get<int>(), desiredHeight, TEST_LOCATION);
428
429   // request AnimatedVectorImageVisual with an URL
430   Visual::Base visual2 = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
431
432   resultMap.Clear();
433   visual2.CreatePropertyMap(resultMap);
434
435   // check the property values from the returned map from a visual
436   value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
437   DALI_TEST_CHECK(value);
438   DALI_TEST_CHECK(value->Get<int>() == DevelVisual::ANIMATED_VECTOR_IMAGE);
439
440   value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
441   DALI_TEST_CHECK(value);
442   DALI_TEST_CHECK(value->Get<std::string>() == TEST_VECTOR_IMAGE_FILE_NAME);
443
444   END_TEST;
445 }
446
447 int UtcDaliAnimatedVectorImageVisualPlayback(void)
448 {
449   ToolkitTestApplication application;
450
451   tet_infoline("UtcDaliAnimatedVectorImageVisualPlayback");
452
453   {
454     // request AnimatedVectorImageVisual with a property map
455     VisualFactory factory = VisualFactory::Get();
456     Visual::Base  visual  = factory.CreateVisual(
457       Property::Map()
458         .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
459         .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
460         .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
461
462     DummyControl        dummyControl = DummyControl::New(true);
463     Impl::DummyControl& dummyImpl    = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
464     dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
465     dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
466
467     Property::Map attributes;
468     tet_infoline("Test Play action");
469     DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
470
471     application.GetScene().Add(dummyControl);
472     application.SendNotification();
473     application.Render(16);
474
475     Property::Map    map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
476     Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
477     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
478
479     tet_infoline("Test Pause action");
480     DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
481
482     application.SendNotification();
483     application.Render(16);
484
485     map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
486     value = map.Find(DevelImageVisual::Property::PLAY_STATE);
487     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PAUSED);
488
489     tet_infoline("Test Play action");
490     DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
491
492     application.SendNotification();
493     application.Render(16);
494
495     map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
496     value = map.Find(DevelImageVisual::Property::PLAY_STATE);
497     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
498
499     tet_infoline("Test Stop action");
500     DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
501
502     application.SendNotification();
503     application.Render(16);
504
505     map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
506     value = map.Find(DevelImageVisual::Property::PLAY_STATE);
507     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
508
509     tet_infoline("Test Stop action again");
510     DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
511
512     application.SendNotification();
513     application.Render(16);
514
515     map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
516     value = map.Find(DevelImageVisual::Property::PLAY_STATE);
517     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
518
519     tet_infoline("Test Play action");
520     DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
521
522     application.SendNotification();
523     application.Render(16);
524
525     map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
526     value = map.Find(DevelImageVisual::Property::PLAY_STATE);
527     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
528
529     tet_infoline("Off stage");
530     dummyControl.Unparent();
531
532     application.SendNotification();
533     application.Render(16);
534
535     map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
536     value = map.Find(DevelImageVisual::Property::PLAY_STATE);
537     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
538
539     tet_infoline("On stage again");
540     application.GetScene().Add(dummyControl);
541
542     application.SendNotification();
543     application.Render(16);
544
545     map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
546     value = map.Find(DevelImageVisual::Property::PLAY_STATE);
547     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
548
549     tet_infoline("Test Play action");
550     DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
551
552     application.SendNotification();
553     application.Render(16);
554
555     map   = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
556     value = map.Find(DevelImageVisual::Property::PLAY_STATE);
557     DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::PLAYING);
558
559     // Change Size
560     Vector3 newSize(100.0f, 100.0f, 0.0f);
561     dummyControl.SetProperty(Actor::Property::SIZE, newSize);
562
563     application.SendNotification();
564     application.Render(16);
565
566     // Size should be changed
567     Vector3 naturalSize = dummyControl.GetNaturalSize();
568     DALI_TEST_CHECK(naturalSize == newSize);
569
570     dummyControl.Unparent();
571   }
572
573   END_TEST;
574 }
575
576 int UtcDaliAnimatedVectorImageVisualCustomShader(void)
577 {
578   ToolkitTestApplication application;
579   tet_infoline("UtcDaliAnimatedVectorImageVisualCustomShader Test custom shader");
580
581   VisualFactory     factory = VisualFactory::Get();
582   Property::Map     properties;
583   Property::Map     shader;
584   const std::string vertexShader                    = "Foobar";
585   const std::string fragmentShader                  = "Foobar sampler2D Foobar";
586   shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
587   shader[Visual::Shader::Property::VERTEX_SHADER]   = vertexShader;
588
589   properties[Visual::Property::TYPE]     = Visual::IMAGE;
590   properties[Visual::Property::SHADER]   = shader;
591   properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
592
593   Visual::Base visual = factory.CreateVisual(properties);
594
595   // trigger creation through setting on stage
596   DummyControl        dummy     = DummyControl::New(true);
597   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
598   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
599
600   dummy.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
601   dummy.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
602   application.GetScene().Add(dummy);
603
604   application.SendNotification();
605   application.Render();
606
607   // Trigger count is 1 - render a frame
608   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
609
610   Renderer        renderer = dummy.GetRendererAt(0);
611   Shader          shader2  = renderer.GetShader();
612   Property::Value value    = shader2.GetProperty(Shader::Property::PROGRAM);
613   Property::Map*  map      = value.GetMap();
614   DALI_TEST_CHECK(map);
615
616   std::string      resultFragmentShader, resultVertexShader;
617   Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
618   fragment->Get(resultFragmentShader);
619   DALI_TEST_CHECK(resultFragmentShader.find(fragmentShader) != std::string::npos);
620
621   Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
622   vertex->Get(resultVertexShader);
623   DALI_TEST_CHECK(resultVertexShader.find(vertexShader) != std::string::npos);
624
625   END_TEST;
626 }
627
628 int UtcDaliAnimatedVectorImageVisualNaturalSize(void)
629 {
630   ToolkitTestApplication application;
631   tet_infoline("UtcDaliAnimatedVectorImageVisualNaturalSize");
632
633   VisualFactory factory = VisualFactory::Get();
634   Visual::Base  visual  = factory.CreateVisual(
635     Property::Map()
636       .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
637       .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
638       .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
639   DALI_TEST_CHECK(visual);
640
641   DummyControl      actor     = DummyControl::New(true);
642   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
643   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
644
645   Vector2 controlSize(20.f, 30.f);
646   Vector2 naturalSize;
647
648   application.GetScene().Add(actor);
649
650   application.SendNotification();
651   application.Render();
652
653   // Trigger count is 1 - load
654   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
655
656   visual.GetNaturalSize(naturalSize);
657
658   DALI_TEST_EQUALS(naturalSize, Vector2(100.0f, 100.0f), TEST_LOCATION); // 100x100 is the content default size.
659
660   actor.SetProperty(Actor::Property::SIZE, controlSize);
661
662   application.SendNotification();
663   application.Render();
664
665   visual.GetNaturalSize(naturalSize);
666
667   DALI_TEST_EQUALS(naturalSize, controlSize, TEST_LOCATION);
668
669   END_TEST;
670 }
671
672 int UtcDaliAnimatedVectorImageVisualLoopCount(void)
673 {
674   ToolkitTestApplication application;
675   tet_infoline("UtcDaliAnimatedVectorImageVisualLoopCount");
676
677   Property::Map propertyMap;
678   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
679     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
680     .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
681     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
682
683   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
684   DALI_TEST_CHECK(visual);
685
686   DummyControl      actor     = DummyControl::New(true);
687   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
688   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
689
690   Vector2 controlSize(20.f, 30.f);
691   actor.SetProperty(Actor::Property::SIZE, controlSize);
692
693   application.GetScene().Add(actor);
694
695   Property::Map attributes;
696   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
697
698   application.SendNotification();
699   application.Render();
700
701   // Trigger count is 2 - load & render a frame
702   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
703
704   // renderer is added to actor
705   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
706   Renderer renderer = actor.GetRendererAt(0u);
707   DALI_TEST_CHECK(renderer);
708
709   END_TEST;
710 }
711
712 int UtcDaliAnimatedVectorImageVisualPlayRange(void)
713 {
714   ToolkitTestApplication application;
715   tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRange");
716
717   int             startFrame = 1, endFrame = 3;
718   Property::Array array;
719   array.PushBack(endFrame);
720   array.PushBack(startFrame);
721
722   Property::Map propertyMap;
723   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
724     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
725     .Add(DevelImageVisual::Property::PLAY_RANGE, array)
726     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
727
728   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
729   DALI_TEST_CHECK(visual);
730
731   DummyControl      actor     = DummyControl::New(true);
732   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
733   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
734
735   Vector2 controlSize(20.f, 30.f);
736   actor.SetProperty(Actor::Property::SIZE, controlSize);
737
738   application.GetScene().Add(actor);
739
740   Property::Map attributes;
741   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
742
743   application.SendNotification();
744   application.Render();
745
746   // Trigger count is 2 - load & render a frame
747   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
748
749   // renderer is added to actor
750   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
751   Renderer renderer = actor.GetRendererAt(0u);
752   DALI_TEST_CHECK(renderer);
753
754   Property::Map    map              = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
755   Property::Value* value            = map.Find(DevelImageVisual::Property::PLAY_RANGE);
756   int              totalFrameNumber = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER)->Get<int>();
757
758   int              resultStartFrame, resultEndFrame;
759   Property::Array* result = value->GetArray();
760   result->GetElementAt(0).Get(resultStartFrame);
761   result->GetElementAt(1).Get(resultEndFrame);
762
763   DALI_TEST_EQUALS(startFrame, resultStartFrame, TEST_LOCATION);
764   DALI_TEST_EQUALS(endFrame, resultEndFrame, TEST_LOCATION);
765
766   // Set invalid play range
767   array.Clear();
768   array.PushBack(1);
769   array.PushBack(100);
770
771   attributes.Clear();
772   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
773   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
774
775   // To make event trigger
776   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
777
778   application.SendNotification();
779   application.Render();
780
781   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
782
783   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
784   value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
785
786   result = value->GetArray();
787   result->GetElementAt(0).Get(resultStartFrame);
788   result->GetElementAt(1).Get(resultEndFrame);
789
790   DALI_TEST_EQUALS(resultStartFrame, 1, TEST_LOCATION);
791   DALI_TEST_EQUALS(resultEndFrame, totalFrameNumber - 1, TEST_LOCATION); // Should be clamped
792
793   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, Property::Map());
794
795   application.SendNotification();
796   application.Render();
797
798   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
799
800   // To make event trigger
801   actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
802
803   application.SendNotification();
804   application.Render();
805
806   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
807
808   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
809   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
810   DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
811
812   array.Clear();
813   array.PushBack(0);
814   array.PushBack(2);
815
816   attributes.Clear();
817   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
818   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
819
820   // To make event trigger
821   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
822
823   application.SendNotification();
824   application.Render();
825
826   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
827
828   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
829   value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
830
831   result = value->GetArray();
832   result->GetElementAt(0).Get(resultStartFrame);
833   result->GetElementAt(1).Get(resultEndFrame);
834
835   DALI_TEST_EQUALS(0, resultStartFrame, TEST_LOCATION);
836   DALI_TEST_EQUALS(2, resultEndFrame, TEST_LOCATION);
837
838   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
839   DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION); // CURRENT_FRAME_NUMBER should be changed also.
840
841   END_TEST;
842 }
843
844 int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void)
845 {
846   ToolkitTestApplication application;
847   tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRangeMarker");
848
849   // Set 1 marker as array
850   Property::Array array;
851   array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
852
853   Property::Map propertyMap;
854   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
855     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
856     .Add(DevelImageVisual::Property::PLAY_RANGE, array)
857     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
858
859   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
860   DALI_TEST_CHECK(visual);
861
862   DummyControl      actor     = DummyControl::New(true);
863   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
864   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
865
866   Vector2 controlSize(20.f, 30.f);
867   actor.SetProperty(Actor::Property::SIZE, controlSize);
868
869   application.GetScene().Add(actor);
870
871   Property::Map attributes;
872   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
873
874   application.SendNotification();
875   application.Render();
876
877   // Trigger count is 2 - load & render a frame
878   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
879
880   // renderer is added to actor
881   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
882   Renderer renderer = actor.GetRendererAt(0u);
883   DALI_TEST_CHECK(renderer);
884
885   Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
886   Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
887
888   int              resultStartFrame, resultEndFrame;
889   Property::Array* result = value->GetArray();
890   result->GetElementAt(0).Get(resultStartFrame);
891   result->GetElementAt(1).Get(resultEndFrame);
892
893   DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
894   DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
895
896   // Set 1 marker as string
897   array.Clear();
898
899   attributes.Clear();
900   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, VECTOR_ANIMATION_MARKER_NAME_1);
901   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
902
903   // To make event trigger
904   actor.SetProperty(Actor::Property::SIZE, Vector2(40.0f, 40.0f));
905
906   application.SendNotification();
907   application.Render();
908
909   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
910
911   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
912   value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
913
914   result = value->GetArray();
915   result->GetElementAt(0).Get(resultStartFrame);
916   result->GetElementAt(1).Get(resultEndFrame);
917
918   DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
919   DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
920
921   // Set 2 markers
922   array.Clear();
923   array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
924   array.PushBack(VECTOR_ANIMATION_MARKER_NAME_2);
925
926   attributes.Clear();
927   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
928   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
929
930   // To make event trigger
931   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
932
933   application.SendNotification();
934   application.Render();
935
936   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
937
938   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
939   value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
940
941   result = value->GetArray();
942   result->GetElementAt(0).Get(resultStartFrame);
943   result->GetElementAt(1).Get(resultEndFrame);
944
945   DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
946   DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
947
948   // Set invalid play range
949   array.Clear();
950   array.PushBack(1);
951   array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1);
952
953   attributes.Clear();
954   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
955   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
956
957   // To make event trigger
958   actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
959
960   application.SendNotification();
961   application.Render();
962
963   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
964
965   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
966   value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
967
968   result = value->GetArray();
969   result->GetElementAt(0).Get(resultStartFrame);
970   result->GetElementAt(1).Get(resultEndFrame);
971
972   DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION); // Should not be changed
973   DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
974
975   END_TEST;
976 }
977
978 int UtcDaliAnimatedVectorImageVisualMarkerInfo(void)
979 {
980   ToolkitTestApplication application;
981   tet_infoline("UtcDaliAnimatedVectorImageVisualMarkerInfo");
982
983   Property::Map propertyMap;
984   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
985     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
986     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
987
988   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
989   DALI_TEST_CHECK(visual);
990
991   DummyControl      actor     = DummyControl::New(true);
992   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
993   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
994
995   Vector2 controlSize(20.f, 30.f);
996   actor.SetProperty(Actor::Property::SIZE, controlSize);
997
998   application.GetScene().Add(actor);
999
1000   Property::Map attributes;
1001   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1002
1003   application.SendNotification();
1004   application.Render();
1005
1006   // Trigger count is 2 - load & render a frame
1007   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1008
1009   // renderer is added to actor
1010   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1011   Renderer renderer = actor.GetRendererAt(0u);
1012   DALI_TEST_CHECK(renderer);
1013
1014   Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1015   Property::Value* value = map.Find(DevelImageVisual::Property::MARKER_INFO);
1016
1017   DALI_TEST_CHECK(value);
1018
1019   Property::Map* result = value->GetMap();
1020   DALI_TEST_CHECK(result);
1021
1022   std::string resultMarkerName;
1023   int         resultStartFrame, resultEndFrame;
1024   DALI_TEST_EQUALS(2u, result->Count(), TEST_LOCATION);
1025
1026   for(uint32_t i = 0u; i < result->Count(); ++i)
1027   {
1028     if(result->GetKeyAt(i).stringKey == VECTOR_ANIMATION_MARKER_NAME_1)
1029     {
1030       Property::Array* frameArray = result->GetValue(i).GetArray();
1031       DALI_TEST_CHECK(frameArray);
1032       frameArray->GetElementAt(0).Get(resultStartFrame);
1033       frameArray->GetElementAt(1).Get(resultEndFrame);
1034
1035       DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
1036       DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
1037     }
1038     else if(result->GetKeyAt(i).stringKey == VECTOR_ANIMATION_MARKER_NAME_2)
1039     {
1040       Property::Array* frameArray = result->GetValue(i).GetArray();
1041       DALI_TEST_CHECK(frameArray);
1042       frameArray->GetElementAt(0).Get(resultStartFrame);
1043       frameArray->GetElementAt(1).Get(resultEndFrame);
1044
1045       DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_2, resultStartFrame, TEST_LOCATION);
1046       DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
1047     }
1048     else
1049     {
1050       DALI_TEST_CHECK(false);
1051     }
1052   }
1053
1054   END_TEST;
1055 }
1056
1057 int UtcDaliAnimatedVectorImageVisualMarkerInfoFromInvalid(void)
1058 {
1059   ToolkitTestApplication application;
1060   tet_infoline("UtcDaliAnimatedVectorImageVisualMarkerInfoFromInvalid");
1061
1062   Property::Map propertyMap;
1063   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1064     .Add(ImageVisual::Property::URL, "invalid.json")
1065     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1066
1067   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1068   DALI_TEST_CHECK(visual);
1069
1070   DummyControl      actor     = DummyControl::New(true);
1071   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1072   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1073
1074   Vector2 controlSize(20.f, 30.f);
1075   actor.SetProperty(Actor::Property::SIZE, controlSize);
1076
1077   application.GetScene().Add(actor);
1078
1079   Property::Map attributes;
1080   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1081
1082   application.SendNotification();
1083   application.Render();
1084
1085   // Trigger count is 1 - load, and failed.
1086   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1087
1088   // renderer is added to actor
1089   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1090   Renderer renderer = actor.GetRendererAt(0u);
1091   DALI_TEST_CHECK(renderer);
1092
1093   Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1094   Property::Value* value = map.Find(DevelImageVisual::Property::MARKER_INFO);
1095
1096   // The values when load failed case is invalid.
1097   DALI_TEST_CHECK(value == nullptr || (value->GetMap() == nullptr) || (value->GetMap()->Empty()));
1098
1099   END_TEST;
1100 }
1101
1102 int UtcDaliAnimatedVectorImageVisualUsedFixedCache(void)
1103 {
1104   ToolkitTestApplication application;
1105   tet_infoline("UtcDaliAnimatedVectorImageVisualUsedFixedCache");
1106
1107   Property::Map propertyMap;
1108   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1109     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1110     .Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, true)
1111     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1112
1113   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1114   DALI_TEST_CHECK(visual);
1115
1116   DummyControl      actor     = DummyControl::New(true);
1117   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1118   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1119   //actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1120   application.GetScene().Add(actor);
1121
1122   application.SendNotification();
1123   application.Render();
1124
1125   // Trigger count is 1 - render a frame
1126   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1127
1128   Vector2 controlSize(200.f, 200.f);
1129   actor.SetProperty(Actor::Property::SIZE, controlSize);
1130
1131   application.SendNotification();
1132   application.Render();
1133
1134   // Trigger count is 1 - load
1135   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1136
1137   // renderer is added to actor
1138   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1139   Renderer renderer = actor.GetRendererAt(0u);
1140   DALI_TEST_CHECK(renderer);
1141
1142   Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1143   Property::Value* value = map.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE);
1144   DALI_TEST_CHECK(value->Get<bool>() == true);
1145
1146   END_TEST;
1147 }
1148
1149 int UtcDaliAnimatedVectorImageVisualUsedFixedCacheFailed(void)
1150 {
1151   ToolkitTestApplication application;
1152   tet_infoline("UtcDaliAnimatedVectorImageVisualUsedFixedCacheFailed");
1153
1154   Property::Map propertyMap;
1155   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1156     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1157     .Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, true)
1158     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1159
1160   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1161   DALI_TEST_CHECK(visual);
1162
1163   DummyControl      actor     = DummyControl::New(true);
1164   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1165   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1166
1167   Vector2 controlSize(200.f, 200.f);
1168   actor.SetProperty(Actor::Property::SIZE, controlSize);
1169
1170   application.GetScene().Add(actor);
1171   application.SendNotification();
1172   application.Render();
1173
1174   // Trigger count is 1 - load, and failed.
1175   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1176
1177   // renderer is added to actor
1178   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1179   Renderer renderer = actor.GetRendererAt(0u);
1180   DALI_TEST_CHECK(renderer);
1181
1182   propertyMap.Clear();
1183   propertyMap.Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, true)
1184     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1185     .Add(ImageVisual::Property::DESIRED_WIDTH, 100)
1186     .Add(ImageVisual::Property::DESIRED_HEIGHT, 100);
1187   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1188
1189   Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1190   Property::Value* value = map.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE);
1191   DALI_TEST_CHECK(value->Get<bool>() == true);
1192
1193   END_TEST;
1194 }
1195
1196 int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
1197 {
1198   ToolkitTestApplication application;
1199   tet_infoline("UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal");
1200
1201   Property::Map propertyMap;
1202   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1203     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1204
1205   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1206   DALI_TEST_CHECK(visual);
1207
1208   DummyControl      actor     = DummyControl::New(true);
1209   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1210   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1211
1212   DevelControl::VisualEventSignal(actor).Connect(&VisualEventSignal);
1213
1214   Vector2 controlSize(20.f, 30.f);
1215   actor.SetProperty(Actor::Property::SIZE, controlSize);
1216
1217   application.GetScene().Add(actor);
1218
1219   application.SendNotification();
1220   application.Render();
1221
1222   // Trigger count is 1 - render a frame
1223   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1224
1225   propertyMap.Clear();
1226   propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1227   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1228
1229   Property::Map attributes;
1230   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1231
1232   application.SendNotification();
1233   application.Render();
1234
1235   // Wait for animation finish
1236   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1237
1238   Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1239   Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE);
1240   DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::PlayState::STOPPED);
1241
1242   DALI_TEST_EQUALS(gAnimationFinishedSignalFired, true, TEST_LOCATION);
1243
1244   END_TEST;
1245 }
1246
1247 int UtcDaliAnimatedVectorImageVisualJumpTo(void)
1248 {
1249   ToolkitTestApplication application;
1250   tet_infoline("UtcDaliAnimatedVectorImageVisualJumpTo");
1251
1252   Property::Map propertyMap;
1253   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1254     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1255     .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1256     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1257
1258   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1259   DALI_TEST_CHECK(visual);
1260
1261   tet_printf("1. Visual is created.\n");
1262
1263   DummyControl      actor     = DummyControl::New(true);
1264   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1265   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1266
1267   Vector2 controlSize(20.f, 30.f);
1268   actor.SetProperty(Actor::Property::SIZE, controlSize);
1269
1270   application.GetScene().Add(actor);
1271
1272   application.SendNotification();
1273   application.Render();
1274
1275   // Trigger count is 2 - load & render a frame
1276   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1277
1278   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2);
1279
1280   // To make event trigger
1281   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1282
1283   application.SendNotification();
1284   application.Render();
1285
1286   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1287
1288   Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1289   Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1290   DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1291
1292   tet_printf("2. The current frame number is [%d].\n", value->Get<int>());
1293
1294   Property::Array array;
1295   array.PushBack(0);
1296   array.PushBack(2);
1297
1298   Property::Map attributes;
1299   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1300   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1301
1302   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1303
1304   // To make event trigger
1305   actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1306
1307   application.SendNotification();
1308   application.Render();
1309
1310   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1311
1312   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1313   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1314   DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1315
1316   tet_printf("3. The current frame number is [%d].\n", value->Get<int>());
1317
1318   // Change play range
1319   attributes.Clear();
1320   array.Clear();
1321
1322   array.PushBack(0);
1323   array.PushBack(4);
1324
1325   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
1326   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1327
1328   attributes.Clear();
1329   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1330
1331   application.SendNotification();
1332   application.Render();
1333
1334   // Wait for animation finish
1335   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1336
1337   // Jump to 3
1338   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1339
1340   // To make event trigger
1341   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1342
1343   application.SendNotification();
1344   application.Render();
1345
1346   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1347
1348   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1349   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1350   DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1351
1352   tet_printf("4. The current frame number is [%d].\n", value->Get<int>());
1353
1354   // Jump to the same position
1355   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
1356
1357   // To make event trigger
1358   actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1359
1360   application.SendNotification();
1361   application.Render();
1362
1363   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1364
1365   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1366   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1367   DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1368
1369   tet_printf("5. The current frame number is [%d].\n", value->Get<int>());
1370
1371   END_TEST;
1372 }
1373
1374 int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
1375 {
1376   ToolkitTestApplication application;
1377   tet_infoline("UtcDaliAnimatedVectorImageVisualUpdateProperty");
1378
1379   int             startFrame = 1, endFrame = 3;
1380   Property::Array playRange;
1381   playRange.PushBack(startFrame);
1382   playRange.PushBack(endFrame);
1383
1384   Property::Map propertyMap;
1385   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1386     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1387     .Add(DevelImageVisual::Property::LOOP_COUNT, 3)
1388     .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
1389     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1390
1391   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1392   DALI_TEST_CHECK(visual);
1393
1394   DummyControl      actor     = DummyControl::New(true);
1395   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1396   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1397
1398   Vector2 controlSize(20.f, 30.f);
1399   actor.SetProperty(Actor::Property::SIZE, controlSize);
1400
1401   application.GetScene().Add(actor);
1402
1403   application.SendNotification();
1404   application.Render();
1405
1406   // Trigger count is 2 - load & render a frame
1407   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1408
1409   Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1410   Property::Value* value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1411   DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
1412
1413   value = map.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
1414   DALI_TEST_CHECK(value);
1415
1416   Property::Array* result = value->GetArray();
1417   DALI_TEST_CHECK(result);
1418
1419   DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1420   DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1421
1422   playRange.Clear();
1423   playRange.PushBack(0);
1424   playRange.PushBack(2);
1425
1426   Property::Map attributes;
1427   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1428   attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 5);
1429
1430   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1431
1432   // To make event trigger
1433   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1434
1435   application.SendNotification();
1436   application.Render();
1437
1438   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1439
1440   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1441   value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1442   DALI_TEST_EQUALS(value->Get<int>(), 5, TEST_LOCATION);
1443
1444   value  = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1445   result = value->GetArray();
1446   DALI_TEST_CHECK(result);
1447
1448   DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == 0);
1449   DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == 2);
1450
1451   attributes.Clear();
1452
1453   playRange.Clear();
1454   playRange.PushBack(startFrame);
1455   playRange.PushBack(endFrame);
1456
1457   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
1458
1459   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1460
1461   // To make event trigger
1462   actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1463
1464   application.SendNotification();
1465   application.Render();
1466
1467   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1468
1469   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1470   value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
1471
1472   result = value->GetArray();
1473   DALI_TEST_CHECK(result);
1474
1475   DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
1476   DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
1477
1478   // Play and update property
1479   attributes.Clear();
1480   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1481
1482   application.SendNotification();
1483   application.Render();
1484
1485   attributes.Add(DevelImageVisual::Property::LOOP_COUNT, 10);
1486
1487   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1488
1489   application.SendNotification();
1490   application.Render();
1491
1492   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1493   value = map.Find(DevelImageVisual::Property::LOOP_COUNT);
1494   DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
1495
1496   END_TEST;
1497 }
1498
1499 int UtcDaliAnimatedVectorImageVisualStopBehavior(void)
1500 {
1501   ToolkitTestApplication application;
1502   tet_infoline("UtcDaliAnimatedVectorImageVisualStopBehavior");
1503
1504   Property::Map propertyMap;
1505   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1506     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1507     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1508
1509   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1510   DALI_TEST_CHECK(visual);
1511
1512   DummyControl      actor     = DummyControl::New(true);
1513   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1514   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1515
1516   Vector2 controlSize(20.f, 30.f);
1517   actor.SetProperty(Actor::Property::SIZE, controlSize);
1518
1519   application.GetScene().Add(actor);
1520
1521   application.SendNotification();
1522   application.Render();
1523
1524   // Trigger count is 2 - load & render a frame
1525   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1526
1527   propertyMap.Clear();
1528   propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1529   propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
1530   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1531
1532   Property::Map attributes;
1533   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1534
1535   application.SendNotification();
1536   application.Render();
1537
1538   // Trigger count is 1 - animation finished
1539   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1540
1541   Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1542   Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1543   DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1544
1545   // Change stop behavior
1546   attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1547
1548   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1549
1550   attributes.Clear();
1551
1552   // Play again
1553   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1554
1555   application.SendNotification();
1556   application.Render();
1557
1558   // Trigger count is 1 - animation finished
1559   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1560
1561   map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1562
1563   Property::Value* value1           = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1564   int              totalFrameNumber = value1->Get<int>();
1565
1566   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1567   DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1568
1569   // Change stop behavior
1570   attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1571   attributes.Add(DevelImageVisual::Property::LOOP_COUNT, -1);
1572
1573   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1574
1575   attributes.Clear();
1576
1577   // Play again
1578   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1579
1580   application.SendNotification();
1581   application.Render();
1582
1583   // Pause
1584   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
1585
1586   // To make event trigger
1587   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1588
1589   application.SendNotification();
1590   application.Render();
1591
1592   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1593
1594   map                    = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1595   value                  = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1596   int currentFrameNumber = value->Get<int>();
1597
1598   // Stop
1599   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes);
1600
1601   // To make event trigger
1602   actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
1603
1604   application.SendNotification();
1605   application.Render();
1606
1607   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1608
1609   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1610   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1611   DALI_TEST_EQUALS(value->Get<int>(), currentFrameNumber, TEST_LOCATION); // Should be same with currentFrameNumber
1612
1613   END_TEST;
1614 }
1615
1616 int UtcDaliAnimatedVectorImageVisualLoopingMode(void)
1617 {
1618   ToolkitTestApplication application;
1619   tet_infoline("UtcDaliAnimatedVectorImageVisualLoopingMode");
1620
1621   Property::Map propertyMap;
1622   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1623     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1624     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1625
1626   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1627   DALI_TEST_CHECK(visual);
1628
1629   DummyControl      actor     = DummyControl::New(true);
1630   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1631   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1632
1633   Vector2 controlSize(20.f, 30.f);
1634   actor.SetProperty(Actor::Property::SIZE, controlSize);
1635
1636   application.GetScene().Add(actor);
1637
1638   application.SendNotification();
1639   application.Render();
1640
1641   // Trigger count is 2 - load, render
1642   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1643
1644   propertyMap.Clear();
1645   propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3);
1646   propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1647   propertyMap.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::AUTO_REVERSE);
1648   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
1649
1650   Property::Map attributes;
1651   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1652
1653   application.SendNotification();
1654   application.Render();
1655
1656   // Trigger count is 1 - animation finished
1657   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1658
1659   Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1660   Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1661   DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame because of auto reverse
1662
1663   // Change stop behavior
1664   attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::CURRENT_FRAME);
1665
1666   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1667
1668   // Play again
1669   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1670
1671   application.SendNotification();
1672   application.Render();
1673
1674   // Trigger count is 1 - animation finished
1675   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1676
1677   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1678   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1679   DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION); // Should be the first frame
1680
1681   // Change looping mode
1682   attributes.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::RESTART);
1683
1684   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1685
1686   // Play again
1687   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1688
1689   application.SendNotification();
1690   application.Render();
1691
1692   // Trigger count is 1 - animation finished
1693   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1694
1695   Property::Value* value1           = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
1696   int              totalFrameNumber = value1->Get<int>();
1697
1698   map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
1699   value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
1700   DALI_TEST_EQUALS(value->Get<int>(), totalFrameNumber - 1, TEST_LOCATION); // Should be the last frame
1701
1702   END_TEST;
1703 }
1704
1705 int UtcDaliAnimatedVectorImageVisualPropertyNotification(void)
1706 {
1707   ToolkitTestApplication application;
1708   tet_infoline("UtcDaliAnimatedVectorImageVisualPropertyNotification");
1709
1710   Property::Map propertyMap;
1711   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1712     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1713
1714   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1715   DALI_TEST_CHECK(visual);
1716
1717   DummyControl      actor     = DummyControl::New(true);
1718   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1719   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1720   actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1721
1722   application.GetScene().Add(actor);
1723
1724   application.SendNotification();
1725   application.Render();
1726
1727   // Trigger count is 1 - render a frame
1728   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1729
1730   Renderer renderer = actor.GetRendererAt(0u);
1731   DALI_TEST_CHECK(renderer);
1732
1733   Vector2 controlSize(20.f, 30.f);
1734   actor.SetProperty(Actor::Property::SIZE, controlSize);
1735
1736   application.SendNotification();
1737   application.Render();
1738
1739   application.SendNotification();
1740   application.Render();
1741
1742   // Trigger count is 1 - render a frame
1743   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1744
1745   auto textureSet = renderer.GetTextures();
1746   auto texture    = textureSet.GetTexture(0);
1747
1748   DALI_TEST_EQUALS(controlSize.width, texture.GetWidth(), TEST_LOCATION);
1749   DALI_TEST_EQUALS(controlSize.height, texture.GetHeight(), TEST_LOCATION);
1750
1751   // Change scale
1752   Vector3 controlScale(2.0f, 2.0f, 1.0f);
1753   actor.SetProperty(Actor::Property::SCALE, controlScale);
1754
1755   application.SendNotification();
1756   application.Render();
1757
1758   application.SendNotification();
1759   application.Render();
1760
1761   // Trigger count is 1 - render a frame
1762   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1763
1764   renderer = actor.GetRendererAt(0u);
1765   DALI_TEST_CHECK(renderer);
1766
1767   textureSet = renderer.GetTextures();
1768   texture    = textureSet.GetTexture(0);
1769
1770   DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1771   DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1772
1773   // Size animation
1774   controlSize         = Vector2(50.0f, 100.0f);
1775   Animation animation = Animation::New(1.0);
1776   animation.AnimateTo(Property(actor, Actor::Property::SIZE), Vector3(controlSize.x, controlSize.y, 0.0f));
1777   animation.Play();
1778
1779   application.SendNotification();
1780   application.Render(1100); // After the animation
1781
1782   application.SendNotification();
1783   application.Render();
1784
1785   // Trigger count is 1 - render a frame
1786   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1787
1788   renderer = actor.GetRendererAt(0u);
1789   DALI_TEST_CHECK(renderer);
1790
1791   textureSet = renderer.GetTextures();
1792   texture    = textureSet.GetTexture(0);
1793
1794   DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION);
1795   DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION);
1796
1797   END_TEST;
1798 }
1799
1800 int UtcDaliAnimatedVectorImageVisualMultipleInstances(void)
1801 {
1802   ToolkitTestApplication application;
1803   tet_infoline("UtcDaliAnimatedVectorImageVisualMultipleInstances");
1804
1805   Property::Map propertyMap;
1806   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1807     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1808     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1809
1810   Visual::Base visual1 = VisualFactory::Get().CreateVisual(propertyMap);
1811   DALI_TEST_CHECK(visual1);
1812
1813   DummyControl      actor1     = DummyControl::New(true);
1814   DummyControlImpl& dummyImpl1 = static_cast<DummyControlImpl&>(actor1.GetImplementation());
1815   dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual1);
1816
1817   Vector2 controlSize(20.f, 30.f);
1818   actor1.SetProperty(Actor::Property::SIZE, controlSize);
1819
1820   application.GetScene().Add(actor1);
1821
1822   application.SendNotification();
1823   application.Render();
1824
1825   // Trigger count is 2 - load & render a frame
1826   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1827
1828   propertyMap.Clear();
1829   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1830     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1831     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1832
1833   Visual::Base visual2 = VisualFactory::Get().CreateVisual(propertyMap);
1834   DALI_TEST_CHECK(visual2);
1835
1836   DummyControl      actor2     = DummyControl::New(true);
1837   DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor2.GetImplementation());
1838   dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
1839
1840   actor2.SetProperty(Actor::Property::SIZE, controlSize);
1841
1842   application.GetScene().Add(actor2);
1843
1844   application.SendNotification();
1845   application.Render();
1846
1847   // Trigger count is 2 - load & render a frame
1848   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1849
1850   DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1851
1852   // To make event trigger
1853   actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
1854
1855   application.SendNotification();
1856   application.Render();
1857
1858   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1859
1860   Property::Map attributes;
1861   attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
1862
1863   DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1864   DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
1865
1866   DevelControl::DoAction(actor1, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map());
1867
1868   // renderer is added to actor
1869   DALI_TEST_CHECK(actor1.GetRendererCount() == 1u);
1870   Renderer renderer1 = actor1.GetRendererAt(0u);
1871   DALI_TEST_CHECK(renderer1);
1872
1873   // renderer is added to actor
1874   DALI_TEST_CHECK(actor2.GetRendererCount() == 1u);
1875   Renderer renderer2 = actor2.GetRendererAt(0u);
1876   DALI_TEST_CHECK(renderer2);
1877
1878   END_TEST;
1879 }
1880
1881 int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void)
1882 {
1883   ToolkitTestApplication application;
1884   tet_infoline("UtcDaliAnimatedVectorImageVisualControlVisibilityChanged");
1885
1886   Property::Map propertyMap;
1887   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1888     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
1889     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1890
1891   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1892   DALI_TEST_CHECK(visual);
1893
1894   DummyControl      actor     = DummyControl::New(true);
1895   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1896   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1897
1898   Vector2 controlSize(20.f, 30.f);
1899   actor.SetProperty(Actor::Property::SIZE, controlSize);
1900
1901   application.GetScene().Add(actor);
1902
1903   application.SendNotification();
1904   application.Render();
1905
1906   // Trigger count is 2 - load & render a frame
1907   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1908
1909   Property::Map attributes;
1910   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1911
1912   application.SendNotification();
1913   application.Render();
1914
1915   // Check rendering behavior
1916   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1917   Renderer renderer = actor.GetRendererAt(0u);
1918   DALI_TEST_CHECK(renderer);
1919   DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1920
1921   actor.SetProperty(Actor::Property::VISIBLE, false);
1922
1923   application.SendNotification();
1924   application.Render();
1925
1926   // Check rendering behavior again
1927   DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1928
1929   END_TEST;
1930 }
1931
1932 int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void)
1933 {
1934   ToolkitTestApplication application;
1935   tet_infoline("UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged");
1936
1937   Property::Map propertyMap;
1938   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1939     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME);
1940
1941   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1942   DALI_TEST_CHECK(visual);
1943
1944   DummyControl      actor     = DummyControl::New(true);
1945   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1946   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1947
1948   Vector2 controlSize(20.f, 30.f);
1949   actor.SetProperty(Actor::Property::SIZE, controlSize);
1950
1951   application.GetScene().Add(actor);
1952
1953   application.SendNotification();
1954   application.Render();
1955
1956   // Trigger count is 1 - render a frame
1957   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1958
1959   Property::Map attributes;
1960   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
1961
1962   application.SendNotification();
1963   application.Render();
1964
1965   // Check rendering behavior
1966   DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1967   Renderer renderer = actor.GetRendererAt(0u);
1968   DALI_TEST_CHECK(renderer);
1969   DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
1970
1971   Window window = DevelWindow::Get(actor);
1972   window.Hide();
1973
1974   application.SendNotification();
1975   application.Render();
1976
1977   // Check rendering behavior again
1978   DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
1979
1980   END_TEST;
1981 }
1982
1983 int UtcDaliAnimatedVectorImageVisualInvalidFile01(void)
1984 {
1985   ToolkitTestApplication application;
1986   tet_infoline("Request loading with invalid file - should draw broken image");
1987
1988   TestGlAbstraction& gl           = application.GetGlAbstraction();
1989   TraceCallStack&    textureTrace = gl.GetTextureTrace();
1990   textureTrace.Enable(true);
1991
1992   Property::Map propertyMap;
1993   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
1994     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
1995     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
1996
1997   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
1998   DALI_TEST_CHECK(visual);
1999
2000   DummyControl      actor     = DummyControl::New(true);
2001   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2002   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2003
2004   actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
2005
2006   application.GetScene().Add(actor);
2007
2008   application.SendNotification();
2009   application.Render();
2010
2011   // Trigger count is 1 - load
2012   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2013
2014   application.SendNotification();
2015   application.Render();
2016
2017   // Check resource status
2018   Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2019   DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2020
2021   // The broken image should be shown.
2022   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2023   DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2024
2025   END_TEST;
2026 }
2027
2028 int UtcDaliAnimatedVectorImageVisualInvalidFile02(void)
2029 {
2030   ToolkitTestApplication application;
2031   tet_infoline("Request loading with invalid file - should draw broken image");
2032
2033   TestGlAbstraction& gl           = application.GetGlAbstraction();
2034   TraceCallStack&    textureTrace = gl.GetTextureTrace();
2035   textureTrace.Enable(true);
2036
2037   Property::Map propertyMap;
2038   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2039     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME);
2040
2041   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2042   DALI_TEST_CHECK(visual);
2043
2044   DummyControl      actor     = DummyControl::New(true);
2045   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2046   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2047
2048   actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
2049
2050   application.SendNotification();
2051   application.Render();
2052
2053   // Add to the Scene after loading
2054   application.GetScene().Add(actor);
2055
2056   application.SendNotification();
2057   application.Render();
2058
2059   // Check resource status
2060   Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2061   DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2062
2063   // The broken image should be shown.
2064   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2065   DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2066
2067   END_TEST;
2068 }
2069
2070 int UtcDaliAnimatedVectorImageVisualInvalidFile03(void)
2071 {
2072   ToolkitTestApplication application;
2073   tet_infoline("Request loading with invalid file without size set - should draw broken image");
2074
2075   TestGlAbstraction& gl           = application.GetGlAbstraction();
2076   TraceCallStack&    textureTrace = gl.GetTextureTrace();
2077   textureTrace.Enable(true);
2078
2079   Property::Map propertyMap;
2080   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2081     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME)
2082     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2083
2084   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2085   DALI_TEST_CHECK(visual);
2086
2087   DummyControl      actor     = DummyControl::New(true);
2088   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2089   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2090
2091   application.GetScene().Add(actor);
2092
2093   application.SendNotification();
2094   application.Render();
2095
2096   // Trigger count is 1 - load
2097   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2098
2099   application.SendNotification();
2100   application.Render();
2101
2102   // Check resource status
2103   Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
2104   DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
2105
2106   // The broken image should be shown.
2107   DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2108   DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2109
2110   END_TEST;
2111 }
2112
2113 int UtcDaliAnimatedVectorImageVisualFrameDrops(void)
2114 {
2115   ToolkitTestApplication application;
2116   tet_infoline("UtcDaliAnimatedVectorImageVisualFrameDrops");
2117
2118   Property::Map propertyMap;
2119   propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2120     .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP)
2121     .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2122
2123   Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2124   DALI_TEST_CHECK(visual);
2125
2126   DummyControl      actor     = DummyControl::New(true);
2127   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2128   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2129
2130   Vector2 controlSize(20.f, 30.f);
2131   actor.SetProperty(Actor::Property::SIZE, controlSize);
2132
2133   application.GetScene().Add(actor);
2134
2135   application.SendNotification();
2136   application.Render();
2137
2138   // Trigger count is 2 - load, render the first frame
2139   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2140
2141   Property::Map    map              = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2142   Property::Value* value            = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER);
2143   int              totalFrameNumber = value->Get<int>();
2144
2145   Property::Map attributes;
2146   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2147
2148   // Make delay to drop frames
2149   Test::VectorAnimationRenderer::DelayRendering(170); // longer than 16.6 * 10frames
2150
2151   application.SendNotification();
2152   application.Render();
2153
2154   // Trigger count is 1 - calculating frame drops
2155   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2156
2157   // Check dropped frame
2158   uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames();
2159   DALI_TEST_CHECK(frames > 0);
2160   DALI_TEST_CHECK(frames <= static_cast<uint32_t>(totalFrameNumber));
2161
2162   END_TEST;
2163 }
2164
2165 int UtcDaliAnimatedVectorImageVisualSize(void)
2166 {
2167   ToolkitTestApplication application;
2168   tet_infoline("UtcDaliAnimatedVectorImageVisualSize");
2169
2170   TestGlAbstraction& gl           = application.GetGlAbstraction();
2171   TraceCallStack&    textureTrace = gl.GetTextureTrace();
2172
2173   VisualFactory factory = VisualFactory::Get();
2174   Visual::Base  visual  = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
2175   DALI_TEST_CHECK(visual);
2176
2177   DummyControl      actor     = DummyControl::New(true);
2178   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2179   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2180
2181   application.GetScene().Add(actor);
2182
2183   application.SendNotification();
2184   application.Render();
2185
2186   // Trigger count is 1 - resource ready
2187   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2188
2189   textureTrace.Enable(true);
2190
2191   application.SendNotification();
2192   application.Render();
2193
2194   {
2195     int               width = 100, height = 100; // 100x100 is the content default size.
2196     std::stringstream out;
2197     out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
2198     DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2199   }
2200
2201   actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f));
2202
2203   application.SendNotification();
2204   application.Render();
2205
2206   // Trigger count is 1 - resource ready
2207   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2208
2209   textureTrace.Reset();
2210
2211   application.SendNotification();
2212   application.Render();
2213
2214   {
2215     int               width = 200, height = 200;
2216     std::stringstream out;
2217     out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
2218     DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2219   }
2220
2221   END_TEST;
2222 }
2223
2224 namespace
2225 {
2226 bool gDynamicPropertyCallbackFired = false;
2227
2228 Property::Value FillColorCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber)
2229 {
2230   gDynamicPropertyCallbackFired = true;
2231
2232   if(frameNumber < 3)
2233   {
2234     return Vector3(0, 0, 1);
2235   }
2236   else
2237   {
2238     return Vector3(1, 0, 0);
2239   }
2240 }
2241 } // namespace
2242
2243 int UtcDaliAnimatedVectorImageVisualDynamicProperty(void)
2244 {
2245   ToolkitTestApplication application;
2246   tet_infoline("UtcDaliAnimatedVectorImageVisualDynamicProperty");
2247
2248   VisualFactory factory = VisualFactory::Get();
2249   Visual::Base  visual  = factory.CreateVisual(
2250     Property::Map()
2251       .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2252       .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2253       .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false));
2254   DALI_TEST_CHECK(visual);
2255
2256   DummyControl      actor     = DummyControl::New(true);
2257   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2258   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2259
2260   Vector2 controlSize(20.f, 30.f);
2261   actor.SetProperty(Actor::Property::SIZE, controlSize);
2262
2263   application.GetScene().Add(actor);
2264
2265   gDynamicPropertyCallbackFired = false;
2266
2267   // Set dynamic property
2268   DevelAnimatedVectorImageVisual::DynamicPropertyInfo info;
2269   info.id       = 1;
2270   info.keyPath  = "Test.Path";
2271   info.property = static_cast<int>(VectorAnimationRenderer::VectorProperty::FILL_COLOR);
2272   info.callback = MakeCallback(FillColorCallback);
2273
2274   DevelControl::DoActionExtension(actor, DummyControl::Property::TEST_VISUAL, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info));
2275
2276   Property::Map attributes;
2277   DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
2278
2279   application.SendNotification();
2280   application.Render();
2281
2282   // Trigger count is 2 - load & render a frame
2283   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2284
2285   // Test whether the property callback is called
2286   DALI_TEST_EQUALS(gDynamicPropertyCallbackFired, true, TEST_LOCATION);
2287
2288   END_TEST;
2289 }
2290
2291 int UtcDaliAnimatedVectorImageVisualDesiredSize(void)
2292 {
2293   ToolkitTestApplication application;
2294   tet_infoline("UtcDaliAnimatedVectorImageVisualDesiredSize");
2295
2296   TestGlAbstraction& gl           = application.GetGlAbstraction();
2297   TraceCallStack&    textureTrace = gl.GetTextureTrace();
2298   int                desiredWidth = 150, desiredHeight = 200;
2299
2300   Visual::Base visual = VisualFactory::Get().CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
2301   DALI_TEST_CHECK(visual);
2302
2303   DummyControl      actor     = DummyControl::New(true);
2304   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2305   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2306
2307   application.GetScene().Add(actor);
2308
2309   application.SendNotification();
2310   application.Render();
2311
2312   // Trigger count is 1 - resource ready
2313   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2314
2315   textureTrace.Enable(true);
2316
2317   application.SendNotification();
2318   application.Render();
2319
2320   {
2321     std::stringstream out;
2322     out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
2323     DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
2324   }
2325
2326   // Unparent to make next trigger
2327   actor.Unparent();
2328
2329   application.SendNotification();
2330   application.Render();
2331
2332   // Set visual size
2333   actor.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.0f));
2334   application.GetScene().Add(actor);
2335
2336   application.SendNotification();
2337   application.Render();
2338
2339   // Trigger count is 1 - resource ready
2340   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2341
2342   textureTrace.Reset();
2343
2344   application.SendNotification();
2345   application.Render();
2346
2347   {
2348     std::stringstream out;
2349     out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
2350     DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str())); // The size should not be changed
2351   }
2352
2353   END_TEST;
2354 }
2355
2356 int UtcDaliAnimatedVectorImageVisualFlushAction(void)
2357 {
2358   ToolkitTestApplication application;
2359
2360   tet_infoline("UtcDaliAnimatedVectorImageVisualFlushAction");
2361
2362   int startFrame = 1;
2363   int endFrame   = 2;
2364
2365   int totalFrameCount = 0;
2366
2367   Property::Array playRange;
2368   playRange.PushBack(startFrame);
2369   playRange.PushBack(endFrame);
2370
2371   Property::Map    resultMap;
2372   Property::Value* value = nullptr;
2373
2374   // request AnimatedVectorImageVisual with a property map
2375   VisualFactory factory = VisualFactory::Get();
2376   Visual::Base  visual  = factory.CreateVisual(
2377     Property::Map()
2378       .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
2379       .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
2380       .Add(DevelImageVisual::Property::PLAY_RANGE, playRange)
2381       .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, true));
2382
2383   DummyControl        dummyControl = DummyControl::New(true);
2384   Impl::DummyControl& dummyImpl    = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
2385   dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2386   dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
2387
2388   application.GetScene().Add(dummyControl);
2389
2390   // Retry function to get playrange until expect values comes.
2391   auto CheckAndRetryPlayRange = [&](int expectStartFrame, int expectEndFrame, std::vector<std::pair<int, int>> retrialFrames) {
2392     int tryCount    = 0;
2393     int tryCountMax = 30;
2394     while(++tryCount <= tryCountMax)
2395     {
2396       Property::Map resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2397
2398       Property::Value* value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
2399       DALI_TEST_CHECK(value);
2400
2401       Property::Array* result = value->GetArray();
2402       DALI_TEST_CHECK(result);
2403       DALI_TEST_EQUALS(result->Count(), 2, TEST_LOCATION);
2404
2405       bool tryAgain = false;
2406       for(auto& framePair : retrialFrames)
2407       {
2408         if(result->GetElementAt(0).Get<int>() == framePair.first && result->GetElementAt(1).Get<int>() == framePair.second)
2409         {
2410           tryAgain = true;
2411           break;
2412         }
2413       }
2414       if(tryAgain)
2415       {
2416         tet_printf("Retry to get value again! [%d]\n", tryCount);
2417         // Dummy sleep 1 second.
2418         Test::WaitForEventThreadTrigger(1, 1);
2419         continue;
2420       }
2421
2422       DALI_TEST_EQUALS(result->GetElementAt(0).Get<int>(), expectStartFrame, TEST_LOCATION);
2423       DALI_TEST_EQUALS(result->GetElementAt(1).Get<int>(), expectEndFrame, TEST_LOCATION);
2424       break;
2425     }
2426     DALI_TEST_CHECK(tryCount <= tryCountMax);
2427   };
2428
2429   tet_printf("Pause lottie first.\n");
2430
2431   Property::Map attributes;
2432   DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes);
2433
2434   application.SendNotification();
2435   application.Render(16);
2436
2437   do
2438   {
2439     resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2440
2441     value = resultMap.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER, Property::INTEGER);
2442     DALI_TEST_CHECK(value);
2443     totalFrameCount = value->Get<int>();
2444   } while(totalFrameCount == 0);
2445
2446   // Ensure that vector data sended well.
2447   CheckAndRetryPlayRange(startFrame, endFrame, {{0, 0}, {0, totalFrameCount - 1}});
2448
2449   resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2450
2451   value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
2452   DALI_TEST_CHECK(value);
2453   DALI_TEST_EQUALS(value->Get<int>(), startFrame, TEST_LOCATION);
2454
2455   tet_printf("Now logically, range : [%d~%d], current : %d\n", startFrame, endFrame, startFrame);
2456
2457   int changedStartFrame1 = startFrame + 2;
2458   int changedEndFrame1   = endFrame + 2;
2459
2460   playRange.Clear();
2461   playRange.Add(changedStartFrame1);
2462   playRange.Add(changedEndFrame1);
2463
2464   tet_printf("Change play range\n");
2465   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
2466   DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2467
2468   tet_printf("Jump to changedEndFrame!\n");
2469   DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, changedEndFrame1);
2470
2471   attributes.Clear();
2472   tet_infoline("Flush Action!");
2473   tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame1, changedEndFrame1, changedEndFrame1);
2474   DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::FLUSH, attributes);
2475
2476   int changedStartFrame2 = startFrame + 1;
2477   int changedEndFrame2   = endFrame + 1;
2478
2479   playRange.Clear();
2480   playRange.Add(changedStartFrame2);
2481   playRange.Add(changedEndFrame2);
2482
2483   tet_printf("Change play range again\n");
2484   tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame2, changedEndFrame2, changedEndFrame2);
2485   attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange);
2486   DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
2487
2488   application.SendNotification();
2489   application.Render(16);
2490
2491   // Ensure that vector data sended well.
2492   CheckAndRetryPlayRange(changedStartFrame2, changedEndFrame2, {{changedStartFrame1, changedEndFrame1}, {startFrame, endFrame}});
2493
2494   resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
2495
2496   tet_printf("Test whether current frame number changed well. If Flush not works, current frame become startFrame.");
2497   value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
2498   DALI_TEST_CHECK(value);
2499   DALI_TEST_EQUALS(value->Get<int>(), changedEndFrame2, TEST_LOCATION);
2500
2501   dummyControl.Unparent();
2502
2503   END_TEST;
2504 }