Merge "Adding support for multiple images in AnimatedImageVisual" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-AnimatedImageVisual.cpp
1
2 /*
3  * Copyright (c) 2017 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/visuals/visual-properties-devel.h>
25 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
26 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
27 #include <dali-toolkit/devel-api/controls/control-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( Visual::Property::TYPE, DevelVisual::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( Visual::Property::TYPE,  Property::INTEGER );
83   DALI_TEST_CHECK( value );
84   DALI_TEST_CHECK( value->Get<int>() == DevelVisual::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( Visual::Property::TYPE,  Property::INTEGER );
96   DALI_TEST_CHECK( value );
97   DALI_TEST_CHECK( value->Get<int>() == DevelVisual::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( Visual::Property::TYPE, DevelVisual::ANIMATED_IMAGE )
120     .Add( "url", urls )
121     .Add( "batchSize", 4 )
122     .Add( "cacheSize", 8 )
123     .Add( "frameDelay", 200 )
124     .Add( "pixelArea", Vector4() )
125     .Add( "wrapModeU", WrapMode::REPEAT )
126     .Add( "wrapModeV", WrapMode::DEFAULT ));
127
128   Property::Map resultMap;
129   animatedImageVisual.CreatePropertyMap( resultMap );
130   // check the property values from the returned map from a visual
131   Property::Value* value = resultMap.Find( Visual::Property::TYPE,  Property::INTEGER );
132   DALI_TEST_CHECK( value );
133   DALI_TEST_CHECK( value->Get<int>() == DevelVisual::ANIMATED_IMAGE );
134
135   value = resultMap.Find( DevelImageVisual::Property::URL, "url" );
136   DALI_TEST_CHECK( value );
137   Property::Array* resultUrls = value->GetArray();
138   DALI_TEST_CHECK( resultUrls );
139   DALI_TEST_EQUALS( resultUrls->Count(), urls.Count(), TEST_LOCATION );
140
141   value = resultMap.Find( DevelImageVisual::Property::BATCH_SIZE, "batchSize" );
142   DALI_TEST_CHECK( value );
143   DALI_TEST_EQUALS( value->Get<int>(), 4, TEST_LOCATION );
144
145   value = resultMap.Find( DevelImageVisual::Property::CACHE_SIZE, "cacheSize" );
146   DALI_TEST_CHECK( value );
147   DALI_TEST_EQUALS( value->Get<int>(), 8, TEST_LOCATION );
148
149   value = resultMap.Find( DevelImageVisual::Property::FRAME_DELAY, "frameDelay" );
150   DALI_TEST_CHECK( value );
151   DALI_TEST_EQUALS( value->Get<int>(), 200, TEST_LOCATION );
152
153   END_TEST;
154 }
155
156
157
158
159 int UtcDaliAnimatedImageVisualMultiImage01(void)
160 {
161   ToolkitTestApplication application;
162   TestGlAbstraction& gl = application.GetGlAbstraction();
163
164   Property::Array urls;
165   CopyUrlsIntoArray( urls );
166
167   {
168     Property::Map propertyMap;
169     propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
170     propertyMap.Insert( DevelImageVisual::Property::URL, Property::Value(urls) );
171     propertyMap.Insert( DevelImageVisual::Property::BATCH_SIZE, 4);
172     propertyMap.Insert( DevelImageVisual::Property::CACHE_SIZE, 8);
173     propertyMap.Insert( DevelImageVisual::Property::FRAME_DELAY, 100);
174
175     VisualFactory factory = VisualFactory::Get();
176     Visual::Base visual = factory.CreateVisual( propertyMap );
177
178     // Expect that a batch of 4 textures has been requested. These will be serially loaded
179     // below.
180
181     DummyControl dummyControl = DummyControl::New(true);
182     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
183     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
184
185     dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
186     Stage::GetCurrent().Add( dummyControl );
187     application.SendNotification();
188     application.Render(16);
189
190     tet_infoline( "Ready the visual after the visual is on stage" );
191     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
192
193     tet_infoline( "Test that a timer has been started" );
194     DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
195
196     TraceCallStack& textureTrace = gl.GetTextureTrace();
197     textureTrace.Enable(true);
198
199     application.SendNotification();
200     application.Render(16);
201
202     DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
203     DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
204
205     tet_infoline( "Test that after 1 tick, and file loads completed, that we have 7 textures" );
206     Test::EmitGlobalTimerSignal();
207
208     // Expect the second batch has been requested
209     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
210
211     application.SendNotification();
212     application.Render(16);
213     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 7, TEST_LOCATION );
214
215
216     tet_infoline( "Test that after 2 ticks that we have 6 textures" );
217
218     Test::EmitGlobalTimerSignal();
219     application.SendNotification();
220     application.Render(16);
221     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 6, TEST_LOCATION );
222
223     tet_infoline("And that at least 2 textures were requested");
224     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
225     application.SendNotification();
226     application.Render(16);
227     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 8, TEST_LOCATION );
228
229
230     tet_infoline( "Test that after 3rd tick that we have 7 textures and 1 request" );
231     Test::EmitGlobalTimerSignal();
232     application.SendNotification();
233     application.Render(16);
234     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 7, TEST_LOCATION );
235
236     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
237     application.SendNotification();
238     application.Render(16);
239     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 8, TEST_LOCATION );
240
241     dummyControl.Unparent();
242   }
243   tet_infoline("Test that removing the visual from stage deletes all textures");
244   application.SendNotification();
245   application.Render(16);
246   DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
247
248   END_TEST;
249 }
250
251 int UtcDaliAnimatedImageVisualMultiImage02(void)
252 {
253   ToolkitTestApplication application;
254   TestGlAbstraction& gl = application.GetGlAbstraction();
255
256   tet_infoline( "Test that the animated visual still works with zero sized cache" );
257
258   {
259     Property::Array urls;
260     CopyUrlsIntoArray( urls );
261
262     Property::Map propertyMap;
263     propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
264     propertyMap.Insert( DevelImageVisual::Property::URL, Property::Value(urls) );
265     propertyMap.Insert( DevelImageVisual::Property::BATCH_SIZE, 0);
266     propertyMap.Insert( DevelImageVisual::Property::CACHE_SIZE, 0);
267     propertyMap.Insert( DevelImageVisual::Property::FRAME_DELAY, 100);
268
269     VisualFactory factory = VisualFactory::Get();
270     Visual::Base visual = factory.CreateVisual( propertyMap ); // TexMgr::Request load tId:0
271
272     // Expect that each image is loaded each tick
273
274     DummyControl dummyControl = DummyControl::New(true);
275     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
276     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
277
278     dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
279     Stage::GetCurrent().Add( dummyControl );
280     application.SendNotification();
281     application.Render(16);
282
283     tet_infoline( "Ready the visual after the visual is on stage" );
284     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
285     application.SendNotification();
286     application.Render(16);//glGenTextures 1
287     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 1, TEST_LOCATION );
288
289     tet_infoline( "Test that each tick, a new image is requested" );
290     Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
291     application.SendNotification();
292     application.Render(16);
293     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, 10 ), true, TEST_LOCATION );
294     application.SendNotification();
295     application.Render(16);//glGenTextures 2
296     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 1, TEST_LOCATION );
297
298     tet_infoline( "Test that each tick, a new image is requested" );
299     Test::EmitGlobalTimerSignal(); // Internal::~TextureSet()
300     application.SendNotification();
301     application.Render(16);//glDeleteTextures 2
302     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, 10 ), true, TEST_LOCATION );
303     application.SendNotification();
304     application.Render(16);//glGenTextures 3
305     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 1, TEST_LOCATION );
306
307     tet_infoline( "Test that each tick, a new image is requested" );
308     Test::EmitGlobalTimerSignal();
309     application.SendNotification();
310     application.Render(16);//glDeleteTextures 3
311     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, 10 ), true, TEST_LOCATION );
312     application.SendNotification();
313     application.Render(16);//Gen4
314     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 1, TEST_LOCATION );
315     dummyControl.Unparent();
316   }
317   tet_infoline("Test that removing the visual from stage deletes all textures");
318   application.SendNotification();
319   application.Render(16);
320   DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
321
322   END_TEST;
323 }
324
325 int UtcDaliAnimatedImageVisualMultiImage03(void)
326 {
327   ToolkitTestApplication application;
328   TestGlAbstraction& gl = application.GetGlAbstraction();
329
330   {
331     Property::Array urls1, urls2;
332     CopyUrlsIntoArray( urls1 );
333     CopyUrlsIntoArray( urls2 );
334
335     Property::Map animatedImageMap1;
336     animatedImageMap1.Insert(Visual::Property::TYPE, Visual::IMAGE );
337     animatedImageMap1.Insert( DevelImageVisual::Property::URL, Property::Value(urls1) );
338     animatedImageMap1.Insert( DevelImageVisual::Property::BATCH_SIZE, 3);
339     animatedImageMap1.Insert( DevelImageVisual::Property::CACHE_SIZE, 3);
340     animatedImageMap1.Insert( DevelImageVisual::Property::FRAME_DELAY, 100);
341
342     Property::Map animatedImageMap2;
343     animatedImageMap2.Insert(Visual::Property::TYPE, Visual::IMAGE );
344     animatedImageMap2.Insert( DevelImageVisual::Property::URL, Property::Value(urls2) );
345     animatedImageMap2.Insert( DevelImageVisual::Property::BATCH_SIZE, 2);
346     animatedImageMap2.Insert( DevelImageVisual::Property::CACHE_SIZE, 2);
347     animatedImageMap2.Insert( DevelImageVisual::Property::FRAME_DELAY, 100);
348
349     VisualFactory factory = VisualFactory::Get();
350     Visual::Base animatedImageVisual1 = factory.CreateVisual( animatedImageMap1 );
351
352     tet_infoline( "Create two image views with the same URLs, offset by 1 frame.");
353
354     DummyControl dummyControl1 = DummyControl::New(true);
355     Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl1.GetImplementation());
356     dummyImpl1.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual1 );
357     dummyControl1.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
358     Stage::GetCurrent().Add( dummyControl1 );
359
360     application.SendNotification();
361     application.Render(16);
362
363     tet_infoline( "Ready the requested image after the first visual is on stage" );
364     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
365     application.SendNotification();
366     application.Render(16);
367     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
368
369     Visual::Base animatedImageVisual2 = factory.CreateVisual( animatedImageMap2 );
370     DummyControl dummyControl2 = DummyControl::New(true);
371     Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl2.GetImplementation());
372     dummyImpl2.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual2 );
373     dummyControl2.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
374     Stage::GetCurrent().Add( dummyControl2 );
375     application.SendNotification();
376     application.Render(16);
377
378     tet_infoline( "The texture cache should be holding the requested images; check that the renderer has a texture" );
379     TextureSet ts = dummyControl2.GetRendererAt(0).GetTextures();
380     Texture t1 = ts.GetTexture( 0 );
381     DALI_TEST_EQUALS( ts.GetTextureCount(), 1, TEST_LOCATION );
382
383     tet_infoline( "Test that on the first tick, 1 new image is requested" );
384     Test::EmitGlobalTimerSignal(); // Both visuals should tick
385
386     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
387     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
388
389     ts = dummyControl2.GetRendererAt(0).GetTextures();
390     Texture t2 = ts.GetTexture( 0 );
391     DALI_TEST_CHECK( t1 != t2 );
392
393     dummyControl1.Unparent();
394     dummyControl2.Unparent();
395   }
396   tet_infoline("Test that removing the visual from stage deletes all textures");
397   application.SendNotification();
398   application.Render(16);
399   DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
400
401   END_TEST;
402 }
403
404
405 int UtcDaliAnimatedImageVisualMultiImage04(void)
406 {
407   ToolkitTestApplication application;
408   TestGlAbstraction& gl = application.GetGlAbstraction();
409   TraceCallStack& textureTrace = gl.GetTextureTrace();
410   textureTrace.Enable(true);
411
412   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" );
413
414   Property::Array urls;
415   CopyUrlsIntoArray( urls );
416
417   {
418     Property::Map propertyMap;
419     propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
420     propertyMap.Insert( DevelImageVisual::Property::URL, Property::Value(urls) );
421     propertyMap.Insert( DevelImageVisual::Property::BATCH_SIZE, 6);
422     propertyMap.Insert( DevelImageVisual::Property::CACHE_SIZE, 11);
423     propertyMap.Insert( DevelImageVisual::Property::FRAME_DELAY, 100);
424
425     VisualFactory factory = VisualFactory::Get();
426     Visual::Base visual = factory.CreateVisual( propertyMap );
427
428     tet_infoline( "Expect that a batch of 7 textures has been requested." );
429
430     DummyControl dummyControl = DummyControl::New(true);
431     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
432     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
433
434     dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
435     Stage::GetCurrent().Add( dummyControl );
436     application.SendNotification();
437     application.Render(16);
438
439     tet_infoline( "Wait for the first batch to complete" );
440     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 6 ), true, TEST_LOCATION );
441
442     tet_infoline( "Test that a timer has been started" );
443     DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
444
445     application.SendNotification();
446     application.Render(16);
447
448     DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 6, TEST_LOCATION );
449     tet_infoline( "Test that after 1 tick, and 5 file loads completed, that we have 11 textures" );
450     Test::EmitGlobalTimerSignal();
451     application.SendNotification();
452     application.Render(16);
453
454     // Expect the second batch has been requested
455     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 5 ), true, TEST_LOCATION );
456
457     application.SendNotification();
458     application.Render(16);
459     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 11, TEST_LOCATION );
460
461     tet_infoline( "Test that after 2 ticks that we have 11 textures and no requests" );
462
463     Test::EmitGlobalTimerSignal();
464     application.SendNotification();
465     application.Render(16);
466     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, 5 ), false, TEST_LOCATION );
467     application.SendNotification();
468     application.Render(16);
469     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 11, TEST_LOCATION );
470
471     tet_infoline( "Test that after 3rd tick that we have 11 textures and no requests" );
472     Test::EmitGlobalTimerSignal();
473     application.SendNotification();
474     application.Render(16);
475
476     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, 5 ), false, TEST_LOCATION );
477     application.SendNotification();
478     application.Render(16);
479     DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 11, TEST_LOCATION );
480
481     dummyControl.Unparent();
482   }
483
484   tet_infoline("Test that removing the visual from stage deletes all textures");
485   application.SendNotification();
486   application.Render(16);
487   DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
488
489   END_TEST;
490 }
491
492
493 int UtcDaliAnimatedImageVisualMultiImage05(void)
494 {
495   ToolkitTestApplication application;
496   TestGlAbstraction& gl = application.GetGlAbstraction();
497
498   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" );
499
500   Property::Array urls;
501   CopyUrlsIntoArray( urls );
502
503   {
504     Property::Map propertyMap;
505     propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
506     propertyMap.Insert( DevelImageVisual::Property::URL, Property::Value(urls) );
507     propertyMap.Insert( DevelImageVisual::Property::BATCH_SIZE, 4);
508     propertyMap.Insert( DevelImageVisual::Property::CACHE_SIZE, 11);
509     propertyMap.Insert( DevelImageVisual::Property::FRAME_DELAY, 100);
510
511     VisualFactory factory = VisualFactory::Get();
512     Visual::Base visual = factory.CreateVisual( propertyMap );
513
514     tet_infoline( "Expect that a batch of 4 textures has been requested." );
515
516     DummyControl dummyControl = DummyControl::New(true);
517     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
518     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
519
520     dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
521     Stage::GetCurrent().Add( dummyControl );
522     application.SendNotification();
523     application.Render(16);
524
525     tet_infoline( "Wait for the first batch to complete" );
526     DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
527
528     tet_infoline( "Test that a timer has been started" );
529     DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
530
531     application.SendNotification();
532     application.Render(16);
533
534     tet_infoline( "Test that a timer has been started" );
535     Test::EmitGlobalTimerSignal();
536     application.SendNotification();
537     application.Render(16);
538
539     dummyControl.Unparent();
540   }
541
542   application.SendNotification();
543   application.Render(16);
544   DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
545
546   tet_infoline( "Test that pending batch of image loads are cancelled instead of uploaded");
547   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
548   application.SendNotification();
549   application.Render(16);
550   DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
551
552   END_TEST;
553 }