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