[dali_1.9.20] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-AnimatedImageVisual.cpp
1
2 /*
3  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <toolkit-timer.h>
22 #include <toolkit-event-thread-callback.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
25 #include <dali-toolkit/devel-api/controls/control-devel.h>
26 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
27 #include <dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h>
28 #include "dummy-control.h"
29
30 using namespace Dali;
31 using namespace Dali::Toolkit;
32
33 void dali_animated_image_visual_startup(void)
34 {
35   test_return_value = TET_UNDEF;
36 }
37
38 void dali_animated_image_visual_cleanup(void)
39 {
40   test_return_value = TET_PASS;
41 }
42
43 namespace
44 {
45 const char* TEST_IMAGE_FILE_NAME =  TEST_RESOURCE_DIR  "/application-icon-%02d.png";
46 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
47 }
48
49
50 void CopyUrlsIntoArray( Property::Array& urls, int startIndex=0 )
51 {
52   for( int i=20+startIndex;i<=30;++i)
53   {
54     char* url;
55     if(asprintf(&url, TEST_IMAGE_FILE_NAME, i) > 0)
56     {
57       Property::Value value(url);
58       urls.Add(value);
59       free(url);
60     }
61   }
62 }
63
64 int UtcDaliAnimatedImageVisualGetPropertyMap01(void)
65 {
66   ToolkitTestApplication application;
67   tet_infoline( "UtcDaliAnimatedImageVisualGetPropertyMap" );
68
69   // request AnimatedImageVisual with a property map
70   VisualFactory factory = VisualFactory::Get();
71   Visual::Base animatedImageVisual = factory.CreateVisual(
72     Property::Map()
73     .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
74     .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
75     .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
76     .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
77     .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT ));
78
79   Property::Map resultMap;
80   animatedImageVisual.CreatePropertyMap( resultMap );
81   // check the property values from the returned map from a visual
82   Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
83   DALI_TEST_CHECK( value );
84   DALI_TEST_CHECK( value->Get<int>() == Visual::ANIMATED_IMAGE );
85
86   value = resultMap.Find( ImageVisual::Property::URL,  Property::STRING );
87   DALI_TEST_CHECK( value );
88   DALI_TEST_CHECK( value->Get<std::string>() == TEST_GIF_FILE_NAME );
89
90   // request AnimatedImageVisual with an URL
91   Visual::Base animatedImageVisual2 = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() );
92   resultMap.Clear();
93   animatedImageVisual2.CreatePropertyMap( resultMap );
94   // check the property values from the returned map from a visual
95   value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
96   DALI_TEST_CHECK( value );
97   DALI_TEST_CHECK( value->Get<int>() == Visual::ANIMATED_IMAGE );
98
99   value = resultMap.Find( ImageVisual::Property::URL,  Property::STRING );
100   DALI_TEST_CHECK( value );
101   DALI_TEST_CHECK( value->Get<std::string>() == TEST_GIF_FILE_NAME );
102
103   END_TEST;
104 }
105
106
107 int UtcDaliAnimatedImageVisualGetPropertyMap02(void)
108 {
109   ToolkitTestApplication application;
110   tet_infoline( "UtcDaliAnimatedImageVisualGetPropertyMap for multi image" );
111
112   // request AnimatedImageVisual with a property map
113   VisualFactory factory = VisualFactory::Get();
114   Property::Array urls;
115   CopyUrlsIntoArray( urls );
116
117   Visual::Base animatedImageVisual = factory.CreateVisual(
118     Property::Map()
119     .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
120     .Add( "url", urls )
121     .Add( "batchSize", 4 )
122     .Add( "cacheSize", 8 )
123     .Add( "loopCount", 10 )
124     .Add( "frameDelay", 200 )
125     .Add( "pixelArea", Vector4() )
126     .Add( "wrapModeU", WrapMode::REPEAT )
127     .Add( "wrapModeV", WrapMode::DEFAULT ));
128
129   Property::Map resultMap;
130   animatedImageVisual.CreatePropertyMap( resultMap );
131   // check the property values from the returned map from a visual
132   Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
133   DALI_TEST_CHECK( value );
134   DALI_TEST_CHECK( value->Get<int>() == Visual::ANIMATED_IMAGE );
135
136   value = resultMap.Find( ImageVisual::Property::URL, "url" );
137   DALI_TEST_CHECK( value );
138   Property::Array* resultUrls = value->GetArray();
139   DALI_TEST_CHECK( resultUrls );
140   DALI_TEST_EQUALS( resultUrls->Count(), urls.Count(), TEST_LOCATION );
141
142   value = resultMap.Find( ImageVisual::Property::BATCH_SIZE, "batchSize" );
143   DALI_TEST_CHECK( value );
144   DALI_TEST_EQUALS( value->Get<int>(), 4, TEST_LOCATION );
145
146   value = resultMap.Find( ImageVisual::Property::CACHE_SIZE, "cacheSize" );
147   DALI_TEST_CHECK( value );
148   DALI_TEST_EQUALS( value->Get<int>(), 8, TEST_LOCATION );
149
150   value = resultMap.Find( Toolkit::DevelImageVisual::Property::LOOP_COUNT, "loopCount" );
151   DALI_TEST_CHECK( value );
152   DALI_TEST_EQUALS( value->Get<int>(), 10, TEST_LOCATION );
153
154   value = resultMap.Find( ImageVisual::Property::FRAME_DELAY, "frameDelay" );
155   DALI_TEST_CHECK( value );
156   DALI_TEST_EQUALS( value->Get<int>(), 200, TEST_LOCATION );
157
158   END_TEST;
159 }
160
161 int UtcDaliAnimatedImageVisualGetPropertyMap03(void)
162 {
163   ToolkitTestApplication application;
164   tet_infoline( "UtcDaliAnimatedImageVisualGetPropertyMap" );
165
166   // request AnimatedImageVisual with a property map
167   VisualFactory factory = VisualFactory::Get();
168   Visual::Base animatedImageVisual = factory.CreateVisual(
169     Property::Map()
170     .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
171     .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
172     .Add( ImageVisual::Property::BATCH_SIZE, 1 )
173     .Add( ImageVisual::Property::CACHE_SIZE, 1 )
174     .Add( ImageVisual::Property::SYNCHRONOUS_LOADING, false ));
175
176   Property::Map resultMap;
177   animatedImageVisual.CreatePropertyMap( resultMap );
178
179   // check the property values from the returned map from a visual
180   Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
181   DALI_TEST_CHECK( value );
182   DALI_TEST_CHECK( value->Get<int>() == Visual::ANIMATED_IMAGE );
183
184   value = resultMap.Find( ImageVisual::Property::URL,  Property::STRING );
185   DALI_TEST_CHECK( value );
186   DALI_TEST_CHECK( value->Get<std::string>() == TEST_GIF_FILE_NAME );
187
188   value = resultMap.Find( ImageVisual::Property::BATCH_SIZE,  Property::INTEGER );
189   DALI_TEST_CHECK( value );
190   DALI_TEST_CHECK( value->Get<int>() == 2 );
191
192   value = resultMap.Find( ImageVisual::Property::CACHE_SIZE,  Property::INTEGER );
193   DALI_TEST_CHECK( value );
194   DALI_TEST_CHECK( value->Get<int>() == 2 );
195
196   END_TEST;
197 }
198
199
200 int UtcDaliAnimatedImageVisualSynchronousLoading(void)
201 {
202   ToolkitTestApplication application;
203   TestGlAbstraction& gl = application.GetGlAbstraction();
204
205   {
206     Property::Map propertyMap;
207     propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE );
208     propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME );
209     propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2);
210     propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 2);
211     propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20);
212     propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true);
213
214     VisualFactory factory = VisualFactory::Get();
215     Visual::Base visual = factory.CreateVisual( propertyMap );
216
217     DummyControl dummyControl = DummyControl::New(true);
218     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
219     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
220
221     dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
222     Stage::GetCurrent().Add( dummyControl );
223
224     TraceCallStack& textureTrace = gl.GetTextureTrace();
225     textureTrace.Enable(true);
226
227     application.SendNotification();
228     application.Render(20);
229
230     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
231
232     application.SendNotification();
233     application.Render();
234
235     DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
236     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 2, TEST_LOCATION );
237
238     DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 3 );
239
240     application.SendNotification();
241     application.Render(20);
242
243     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
244
245     application.SendNotification();
246     application.Render();
247
248     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
249
250     dummyControl.Unparent();
251   }
252   tet_infoline("Test that removing the visual from stage deletes all textures");
253   application.SendNotification();
254   application.Render(16);
255   DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
256
257   END_TEST;
258 }
259
260
261 int UtcDaliAnimatedImageVisualJumpToAction(void)
262 {
263   ToolkitTestApplication application;
264   TestGlAbstraction& gl = application.GetGlAbstraction();
265
266   Property::Array urls;
267   CopyUrlsIntoArray( urls );
268
269   {
270     Property::Map propertyMap;
271     propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
272     propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
273     propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 4);
274     propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 12);
275     propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20);
276
277     VisualFactory factory = VisualFactory::Get();
278     Visual::Base visual = factory.CreateVisual( propertyMap );
279
280     DummyControl dummyControl = DummyControl::New(true);
281     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
282     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
283
284     dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
285     Stage::GetCurrent().Add( dummyControl );
286     application.SendNotification();
287     application.Render(20);
288
289     tet_infoline( "Ready the visual after the visual is on stage" );
290     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
291
292     tet_infoline( "Test that a timer has been started" );
293     DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
294
295     TraceCallStack& textureTrace = gl.GetTextureTrace();
296     textureTrace.Enable(true);
297
298     application.SendNotification();
299     application.Render(20);
300
301     DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
302
303     DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map() );
304
305     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
306
307     DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 20 );
308
309     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
310
311     DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 6 );
312
313     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 6 ), true, TEST_LOCATION );
314     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
315
316     dummyControl.Unparent();
317   }
318   tet_infoline("Test that removing the visual from stage deletes all textures");
319   application.SendNotification();
320   application.Render(16);
321   DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
322
323   END_TEST;
324 }
325
326
327 int UtcDaliAnimatedImageVisualStopBehavior(void)
328 {
329   ToolkitTestApplication application;
330   TestGlAbstraction& gl = application.GetGlAbstraction();
331
332   Property::Array urls;
333   CopyUrlsIntoArray( urls );
334
335   {
336     Property::Map propertyMap;
337     propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
338     propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
339     propertyMap.Insert( DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
340     propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 4);
341     propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 8);
342     propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20);
343
344     VisualFactory factory = VisualFactory::Get();
345     Visual::Base visual = factory.CreateVisual( propertyMap );
346
347     // Expect that a batch of 4 textures has been requested. These will be serially loaded
348     // below.
349
350     DummyControl dummyControl = DummyControl::New(true);
351     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
352     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
353
354     dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
355     Stage::GetCurrent().Add( dummyControl );
356     application.SendNotification();
357     application.Render(20);
358
359     tet_infoline( "Ready the visual after the visual is on stage" );
360     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
361
362     tet_infoline( "Test that a timer has been started" );
363     DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
364
365     TraceCallStack& textureTrace = gl.GetTextureTrace();
366     textureTrace.Enable(true);
367
368     application.SendNotification();
369     application.Render(20);
370
371     DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
372
373     DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map() );
374
375     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
376
377     DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 1 );
378
379     // Expect the second batch has been requested
380     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
381
382     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
383
384     dummyControl.Unparent();
385   }
386   tet_infoline("Test that removing the visual from stage deletes all textures");
387   application.SendNotification();
388   application.Render(16);
389   DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
390
391   END_TEST;
392 }
393
394
395 int UtcDaliAnimatedImageVisualAnimatedImage01(void)
396 {
397   ToolkitTestApplication application;
398   TestGlAbstraction& gl = application.GetGlAbstraction();
399
400   {
401     Property::Map propertyMap;
402     propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE );
403     propertyMap.Insert( ImageVisual::Property::URL, TEST_GIF_FILE_NAME );
404     propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2);
405     propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 4);
406     propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20);
407
408     VisualFactory factory = VisualFactory::Get();
409     Visual::Base visual = factory.CreateVisual( propertyMap );
410
411     // Expect that a batch of 4 textures has been requested. These will be serially loaded
412     // below.
413
414     DummyControl dummyControl = DummyControl::New(true);
415     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
416     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
417
418     dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
419     Stage::GetCurrent().Add( dummyControl );
420
421     application.SendNotification();
422     application.Render();
423
424     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
425
426     application.SendNotification();
427     application.Render(20);
428
429     DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 2, TEST_LOCATION );
430
431     tet_infoline( "Test that a timer has been started" );
432
433     TraceCallStack& textureTrace = gl.GetTextureTrace();
434     textureTrace.Enable(true);
435
436     Test::EmitGlobalTimerSignal();
437
438     application.SendNotification();
439     application.Render();
440
441     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
442
443     application.SendNotification();
444     application.Render(20);
445
446     DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
447
448     dummyControl.Unparent();
449   }
450   tet_infoline("Test that removing the visual from stage deletes all textures");
451   application.SendNotification();
452   application.Render(20);
453   DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
454
455   END_TEST;
456 }
457
458
459 int UtcDaliAnimatedImageVisualMultiImage01(void)
460 {
461   ToolkitTestApplication application;
462   TestGlAbstraction& gl = application.GetGlAbstraction();
463
464   Property::Array urls;
465   CopyUrlsIntoArray( urls );
466
467   {
468     Property::Map propertyMap;
469     propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
470     propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
471     propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 4);
472     propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 8);
473     propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
474
475     VisualFactory factory = VisualFactory::Get();
476     Visual::Base visual = factory.CreateVisual( propertyMap );
477
478     // Expect that a batch of 4 textures has been requested. These will be serially loaded
479     // below.
480
481     DummyControl dummyControl = DummyControl::New(true);
482     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
483     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
484
485     dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
486     Stage::GetCurrent().Add( dummyControl );
487     application.SendNotification();
488     application.Render(16);
489
490     tet_infoline( "Ready the visual after the visual is on stage" );
491     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
492
493     tet_infoline( "Test that a timer has been started" );
494     DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
495
496     TraceCallStack& textureTrace = gl.GetTextureTrace();
497     textureTrace.Enable(true);
498
499     application.SendNotification();
500     application.Render(16);
501
502     DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
503     DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
504
505     tet_infoline( "Test that after 1 tick, and file loads completed, that we have 7 textures" );
506     Test::EmitGlobalTimerSignal();
507
508     // Expect the second batch has been requested
509     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
510
511     application.SendNotification();
512     application.Render(16);
513     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 7, TEST_LOCATION );
514
515
516     tet_infoline( "Test that after 2 ticks that we have 6 textures" );
517
518     Test::EmitGlobalTimerSignal();
519     application.SendNotification();
520     application.Render(16);
521     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 6, TEST_LOCATION );
522
523     tet_infoline("And that at least 2 textures were requested");
524     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
525     application.SendNotification();
526     application.Render(16);
527     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 8, TEST_LOCATION );
528
529
530     tet_infoline( "Test that after 3rd tick that we have 7 textures and 1 request" );
531     Test::EmitGlobalTimerSignal();
532     application.SendNotification();
533     application.Render(16);
534     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 7, TEST_LOCATION );
535
536     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
537     application.SendNotification();
538     application.Render(16);
539     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 8, TEST_LOCATION );
540
541     dummyControl.Unparent();
542   }
543   tet_infoline("Test that removing the visual from stage deletes all textures");
544   application.SendNotification();
545   application.Render(16);
546   DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
547
548   END_TEST;
549 }
550
551 int UtcDaliAnimatedImageVisualMultiImage02(void)
552 {
553   ToolkitTestApplication application;
554   TestGlAbstraction& gl = application.GetGlAbstraction();
555
556   tet_infoline( "Test that the animated visual still works with zero sized cache" );
557
558   {
559     Property::Array urls;
560     CopyUrlsIntoArray( urls );
561
562     Property::Map propertyMap;
563     propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
564     propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
565     propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2);
566     propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 2);
567     propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
568
569     VisualFactory factory = VisualFactory::Get();
570     Visual::Base visual = factory.CreateVisual( propertyMap ); // TexMgr::Request load tId:0
571
572     // Expect that each image is loaded each tick
573
574     DummyControl dummyControl = DummyControl::New(true);
575     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
576     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
577
578     dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
579     Stage::GetCurrent().Add( dummyControl );
580     application.SendNotification();
581     application.Render(16);
582
583     tet_infoline( "Ready the visual after the visual is on stage" );
584     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
585     application.SendNotification();
586     application.Render(16);//glGenTextures 1
587     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 1, TEST_LOCATION );
588
589     tet_infoline( "Test that each tick, a new image is requested" );
590     Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
591     application.SendNotification();
592     application.Render(16);
593     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, 10 ), true, TEST_LOCATION );
594     application.SendNotification();
595     application.Render(16);//glGenTextures 2
596     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 1, TEST_LOCATION );
597
598     tet_infoline( "Test that each tick, a new image is requested" );
599     Test::EmitGlobalTimerSignal(); // Internal::~TextureSet()
600     application.SendNotification();
601     application.Render(16);//glDeleteTextures 2
602     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, 10 ), true, TEST_LOCATION );
603     application.SendNotification();
604     application.Render(16);//glGenTextures 3
605     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 1, TEST_LOCATION );
606
607     tet_infoline( "Test that each tick, a new image is requested" );
608     Test::EmitGlobalTimerSignal();
609     application.SendNotification();
610     application.Render(16);//glDeleteTextures 3
611     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, 10 ), true, TEST_LOCATION );
612     application.SendNotification();
613     application.Render(16);//Gen4
614     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 1, TEST_LOCATION );
615     dummyControl.Unparent();
616   }
617   tet_infoline("Test that removing the visual from stage deletes all textures");
618   application.SendNotification();
619   application.Render(16);
620   DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
621
622   END_TEST;
623 }
624
625 int UtcDaliAnimatedImageVisualMultiImage03(void)
626 {
627   ToolkitTestApplication application;
628   TestGlAbstraction& gl = application.GetGlAbstraction();
629
630   {
631     Property::Array urls1, urls2;
632     CopyUrlsIntoArray( urls1 );
633     CopyUrlsIntoArray( urls2 );
634
635     Property::Map animatedImageMap1;
636     animatedImageMap1.Insert(Visual::Property::TYPE, Visual::IMAGE );
637     animatedImageMap1.Insert( ImageVisual::Property::URL, Property::Value(urls1) );
638     animatedImageMap1.Insert( ImageVisual::Property::BATCH_SIZE, 3);
639     animatedImageMap1.Insert( ImageVisual::Property::CACHE_SIZE, 3);
640     animatedImageMap1.Insert( ImageVisual::Property::FRAME_DELAY, 100);
641
642     Property::Map animatedImageMap2;
643     animatedImageMap2.Insert(Visual::Property::TYPE, Visual::IMAGE );
644     animatedImageMap2.Insert( ImageVisual::Property::URL, Property::Value(urls2) );
645     animatedImageMap2.Insert( ImageVisual::Property::BATCH_SIZE, 2);
646     animatedImageMap2.Insert( ImageVisual::Property::CACHE_SIZE, 2);
647     animatedImageMap2.Insert( ImageVisual::Property::FRAME_DELAY, 100);
648
649     VisualFactory factory = VisualFactory::Get();
650     Visual::Base animatedImageVisual1 = factory.CreateVisual( animatedImageMap1 );
651
652     tet_infoline( "Create two image views with the same URLs, offset by 1 frame.");
653
654     DummyControl dummyControl1 = DummyControl::New(true);
655     Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl1.GetImplementation());
656     dummyImpl1.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual1 );
657     dummyControl1.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
658     Stage::GetCurrent().Add( dummyControl1 );
659
660     application.SendNotification();
661     application.Render(16);
662
663     tet_infoline( "Ready the requested image after the first visual is on stage" );
664     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
665     application.SendNotification();
666     application.Render(16);
667     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
668
669     Visual::Base animatedImageVisual2 = factory.CreateVisual( animatedImageMap2 );
670     DummyControl dummyControl2 = DummyControl::New(true);
671     Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl2.GetImplementation());
672     dummyImpl2.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual2 );
673     dummyControl2.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
674     Stage::GetCurrent().Add( dummyControl2 );
675     application.SendNotification();
676     application.Render(16);
677
678     tet_infoline( "The texture cache should be holding the requested images; check that the renderer has a texture" );
679     TextureSet ts = dummyControl2.GetRendererAt(0).GetTextures();
680     Texture t1 = ts.GetTexture( 0 );
681     DALI_TEST_EQUALS( ts.GetTextureCount(), 1, TEST_LOCATION );
682
683     tet_infoline( "Test that on the first tick, 1 new image is requested" );
684     Test::EmitGlobalTimerSignal(); // Both visuals should tick
685
686     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
687     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
688
689     ts = dummyControl2.GetRendererAt(0).GetTextures();
690     Texture t2 = ts.GetTexture( 0 );
691     DALI_TEST_CHECK( t1 != t2 );
692
693     dummyControl1.Unparent();
694     dummyControl2.Unparent();
695   }
696   tet_infoline("Test that removing the visual from stage deletes all textures");
697   application.SendNotification();
698   application.Render(16);
699   DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
700
701   END_TEST;
702 }
703
704
705 int UtcDaliAnimatedImageVisualMultiImage04(void)
706 {
707   ToolkitTestApplication application;
708   TestGlAbstraction& gl = application.GetGlAbstraction();
709   TraceCallStack& textureTrace = gl.GetTextureTrace();
710   textureTrace.Enable(true);
711
712   tet_infoline( "Test that if the cache size is the same as the number of urls, that once the cache is full, no new images are loaded" );
713
714   Property::Array urls;
715   CopyUrlsIntoArray( urls );
716
717   {
718     Property::Map propertyMap;
719     propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
720     propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
721     propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 6);
722     propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 11);
723     propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
724
725     VisualFactory factory = VisualFactory::Get();
726     Visual::Base visual = factory.CreateVisual( propertyMap );
727
728     tet_infoline( "Expect that a batch of 7 textures has been requested." );
729
730     DummyControl dummyControl = DummyControl::New(true);
731     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
732     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
733
734     dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
735     Stage::GetCurrent().Add( dummyControl );
736     application.SendNotification();
737     application.Render(16);
738
739     tet_infoline( "Wait for the first batch to complete" );
740     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 6 ), true, TEST_LOCATION );
741
742     tet_infoline( "Test that a timer has been started" );
743     DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
744
745     application.SendNotification();
746     application.Render(16);
747
748     DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 6, TEST_LOCATION );
749     tet_infoline( "Test that after 1 tick, and 5 file loads completed, that we have 11 textures" );
750     Test::EmitGlobalTimerSignal();
751     application.SendNotification();
752     application.Render(16);
753
754     // Expect the second batch has been requested
755     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 5 ), true, TEST_LOCATION );
756
757     application.SendNotification();
758     application.Render(16);
759     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 11, TEST_LOCATION );
760
761     tet_infoline( "Test that after 2 ticks that we have 11 textures and no requests" );
762
763     Test::EmitGlobalTimerSignal();
764     application.SendNotification();
765     application.Render(16);
766     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, 5 ), false, TEST_LOCATION );
767     application.SendNotification();
768     application.Render(16);
769     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 11, TEST_LOCATION );
770
771     tet_infoline( "Test that after 3rd tick that we have 11 textures and no requests" );
772     Test::EmitGlobalTimerSignal();
773     application.SendNotification();
774     application.Render(16);
775
776     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, 5 ), false, TEST_LOCATION );
777     application.SendNotification();
778     application.Render(16);
779     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 11, TEST_LOCATION );
780
781     dummyControl.Unparent();
782   }
783
784   tet_infoline("Test that removing the visual from stage deletes all textures");
785   application.SendNotification();
786   application.Render(16);
787   DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
788
789   END_TEST;
790 }
791
792
793 int UtcDaliAnimatedImageVisualMultiImage05(void)
794 {
795   ToolkitTestApplication application;
796   TestGlAbstraction& gl = application.GetGlAbstraction();
797
798   tet_infoline( "Test that if the cache size is the same as the number of urls, that removing a partially loaded visual removes all textures" );
799
800   Property::Array urls;
801   CopyUrlsIntoArray( urls );
802
803   {
804     Property::Map propertyMap;
805     propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
806     propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
807     propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 4);
808     propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 11);
809     propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
810
811     VisualFactory factory = VisualFactory::Get();
812     Visual::Base visual = factory.CreateVisual( propertyMap );
813
814     tet_infoline( "Expect that a batch of 4 textures has been requested." );
815
816     DummyControl dummyControl = DummyControl::New(true);
817     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
818     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
819
820     dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
821     Stage::GetCurrent().Add( dummyControl );
822     application.SendNotification();
823     application.Render(16);
824
825     tet_infoline( "Wait for the first batch to complete" );
826     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
827
828     tet_infoline( "Test that a timer has been started" );
829     DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
830
831     application.SendNotification();
832     application.Render(16);
833
834     tet_infoline( "Test that a timer has been started" );
835     Test::EmitGlobalTimerSignal();
836     application.SendNotification();
837     application.Render(16);
838
839     dummyControl.Unparent();
840   }
841
842   application.SendNotification();
843   application.Render(16);
844   DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
845
846   tet_infoline( "Test that pending batch of image loads are cancelled instead of uploaded");
847   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
848   application.SendNotification();
849   application.Render(16);
850   DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
851
852   END_TEST;
853 }
854
855 void TestLoopCount( ToolkitTestApplication &application, DummyControl &dummyControl, uint16_t frameCount, uint16_t loopCount, const char * location )
856 {
857   TestGlAbstraction& gl = application.GetGlAbstraction();
858   TraceCallStack& textureTrace = gl.GetTextureTrace();
859
860   textureTrace.Enable(true);
861   Stage::GetCurrent().Add( dummyControl );
862
863   application.SendNotification();
864   application.Render(16);
865
866   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_INNER_LOCATION( location ) );
867
868   application.SendNotification();
869   application.Render();
870
871   tet_infoline( "Test that a timer has been created" );
872   DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_INNER_LOCATION( location ) );
873
874   for ( uint16_t i = 0; i < loopCount; i++ )
875   {
876     for ( uint16_t j = 0; j < frameCount; j++ )
877     {
878       if( i == 0 && j == 0 )
879       {
880         continue; // Because first frame is already showed and we call 2nd frame at the first time of timer animation.
881       }
882       tet_printf( "Test that after %u ticks, and we have %u frame \n", j + 1u, j + 1u );
883       Test::EmitGlobalTimerSignal();
884       application.SendNotification();
885       application.Render(16);
886
887       DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_INNER_LOCATION( location ) );
888
889       application.SendNotification();
890       application.Render();
891       DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 2, TEST_INNER_LOCATION( location ) );
892       DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_INNER_LOCATION( location ) );
893     }
894     tet_printf( "Test Loop %u \n\n", i + 1u );
895   }
896
897   tet_printf( "Test that after %u loops, and we have no frame. Timer should stop \n", loopCount );
898   Test::EmitGlobalTimerSignal();
899   application.SendNotification();
900   application.Render(16);
901   DALI_TEST_EQUALS( Test::AreTimersRunning(), false, TEST_INNER_LOCATION( location ) );
902
903   dummyControl.Unparent();
904 }
905
906 int UtcDaliAnimatedImageVisualLoopCount(void)
907 {
908   ToolkitTestApplication application;
909
910   tet_infoline( "UtcDaliAnimatedImageVisualLoopCount" );
911
912   {
913     // request AnimatedImageVisual with a property map
914     // Test with no (0) loop count
915     VisualFactory factory = VisualFactory::Get();
916     Visual::Base animatedImageVisual = factory.CreateVisual(
917       Property::Map()
918       .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
919       .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
920       .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
921       .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
922       .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
923       .Add( DevelImageVisual::Property::LOOP_COUNT, 0 ));
924
925     DummyControl dummyControl = DummyControl::New(true);
926     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
927     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual );
928     dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
929
930     TestLoopCount( application, dummyControl, 4, 0, TEST_LOCATION );
931
932     dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
933     animatedImageVisual.Reset();
934
935     application.SendNotification();
936     application.Render(16);
937
938     // Test with no (1) loop count. Request AnimatedImageVisual with a property map
939     animatedImageVisual = factory.CreateVisual(
940       Property::Map()
941       .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
942       .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
943       .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
944       .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
945       .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
946       .Add( DevelImageVisual::Property::LOOP_COUNT, 1 ));
947
948     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual );
949
950     TestLoopCount( application, dummyControl, 4, 1, TEST_LOCATION );
951
952     dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
953     animatedImageVisual.Reset();
954
955     application.SendNotification();
956     application.Render(16);
957
958     // Test with no (100) loop count. Request AnimatedImageVisual with a property map
959     animatedImageVisual = factory.CreateVisual(
960       Property::Map()
961       .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
962       .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
963       .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
964       .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
965       .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
966       .Add( DevelImageVisual::Property::LOOP_COUNT, 100 ));
967
968     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual );
969
970     TestLoopCount( application, dummyControl, 4, 100, TEST_LOCATION );
971   }
972   END_TEST;
973 }
974
975 int UtcDaliAnimatedImageVisualPlayback(void)
976 {
977   ToolkitTestApplication application;
978   TestGlAbstraction& gl = application.GetGlAbstraction();
979   TraceCallStack& textureTrace = gl.GetTextureTrace();
980
981   tet_infoline( "UtcDaliAnimatedImageVisualPlayback" );
982
983   {
984     // request AnimatedImageVisual with a property map
985     // Test with forever (-1) loop count
986     VisualFactory factory = VisualFactory::Get();
987     Visual::Base animatedImageVisual = factory.CreateVisual(
988       Property::Map()
989       .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
990       .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
991       .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
992       .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
993       .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
994       .Add( DevelImageVisual::Property::LOOP_COUNT, -1 ));
995
996     DummyControl dummyControl = DummyControl::New(true);
997     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
998     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual );
999     dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
1000
1001     textureTrace.Enable(true);
1002     Stage::GetCurrent().Add( dummyControl );
1003     application.SendNotification();
1004     application.Render(16);
1005
1006     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
1007
1008     application.SendNotification();
1009     application.Render();
1010
1011     tet_infoline( "Test that a timer has been created" );
1012     DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
1013
1014     Test::EmitGlobalTimerSignal();
1015     application.SendNotification();
1016     application.Render(16);
1017
1018     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1019
1020     application.SendNotification();
1021     application.Render();
1022     DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_LOCATION );
1023
1024     Property::Map attributes;
1025     tet_infoline( "Test Pause action. Timer should stop after Pause action" );
1026     DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PAUSE, attributes );
1027     Test::EmitGlobalTimerSignal();
1028     application.SendNotification();
1029     application.Render(16);
1030     DALI_TEST_EQUALS( Test::AreTimersRunning(), false, TEST_LOCATION );
1031
1032     tet_infoline( "Test Play action. Timer should Restart after Play action" );
1033     DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes );
1034     Test::EmitGlobalTimerSignal();
1035     application.SendNotification();
1036     application.Render(16);
1037
1038     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1039
1040     application.SendNotification();
1041     application.Render();
1042     DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_LOCATION );
1043
1044     tet_infoline( "Test Stop action. Timer should stop after Stop action" );
1045     DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, attributes );
1046     Test::EmitGlobalTimerSignal();
1047     application.SendNotification();
1048     application.Render(16);
1049     DALI_TEST_EQUALS( Test::AreTimersRunning(), false, TEST_LOCATION );
1050
1051     tet_infoline( "Test Play action. Timer should Restart after Play action" );
1052     DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes );
1053     Test::EmitGlobalTimerSignal();
1054     application.SendNotification();
1055     application.Render(16);
1056
1057     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1058
1059     application.SendNotification();
1060     application.Render();
1061     DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_LOCATION );
1062
1063     dummyControl.Unparent();
1064   }
1065
1066   END_TEST;
1067 }