3 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
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"
31 using namespace Dali::Toolkit;
33 void dali_animated_image_visual_startup(void)
35 test_return_value = TET_UNDEF;
38 void dali_animated_image_visual_cleanup(void)
40 test_return_value = TET_PASS;
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";
50 void CopyUrlsIntoArray( Property::Array& urls, int startIndex=0 )
52 for( int i=20+startIndex;i<=30;++i)
55 if(asprintf(&url, TEST_IMAGE_FILE_NAME, i) > 0)
57 Property::Value value(url);
64 int UtcDaliAnimatedImageVisualGetPropertyMap01(void)
66 ToolkitTestApplication application;
67 tet_infoline( "UtcDaliAnimatedImageVisualGetPropertyMap" );
69 // request AnimatedImageVisual with a property map
70 VisualFactory factory = VisualFactory::Get();
71 Visual::Base animatedImageVisual = factory.CreateVisual(
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 ));
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 );
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 );
90 // request AnimatedImageVisual with an URL
91 Visual::Base animatedImageVisual2 = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() );
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 );
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 );
107 int UtcDaliAnimatedImageVisualGetPropertyMap02(void)
109 ToolkitTestApplication application;
110 tet_infoline( "UtcDaliAnimatedImageVisualGetPropertyMap for multi image" );
112 // request AnimatedImageVisual with a property map
113 VisualFactory factory = VisualFactory::Get();
114 Property::Array urls;
115 CopyUrlsIntoArray( urls );
117 Visual::Base animatedImageVisual = factory.CreateVisual(
119 .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
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 ));
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 );
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 );
142 value = resultMap.Find( ImageVisual::Property::BATCH_SIZE, "batchSize" );
143 DALI_TEST_CHECK( value );
144 DALI_TEST_EQUALS( value->Get<int>(), 4, TEST_LOCATION );
146 value = resultMap.Find( ImageVisual::Property::CACHE_SIZE, "cacheSize" );
147 DALI_TEST_CHECK( value );
148 DALI_TEST_EQUALS( value->Get<int>(), 8, TEST_LOCATION );
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 );
154 value = resultMap.Find( ImageVisual::Property::FRAME_DELAY, "frameDelay" );
155 DALI_TEST_CHECK( value );
156 DALI_TEST_EQUALS( value->Get<int>(), 200, TEST_LOCATION );
161 int UtcDaliAnimatedImageVisualGetPropertyMap03(void)
163 ToolkitTestApplication application;
164 tet_infoline( "UtcDaliAnimatedImageVisualGetPropertyMap" );
166 // request AnimatedImageVisual with a property map
167 VisualFactory factory = VisualFactory::Get();
168 Visual::Base animatedImageVisual = factory.CreateVisual(
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 ));
176 Property::Map resultMap;
177 animatedImageVisual.CreatePropertyMap( resultMap );
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 );
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 );
188 value = resultMap.Find( ImageVisual::Property::BATCH_SIZE, Property::INTEGER );
189 DALI_TEST_CHECK( value );
190 DALI_TEST_CHECK( value->Get<int>() == 2 );
192 value = resultMap.Find( ImageVisual::Property::CACHE_SIZE, Property::INTEGER );
193 DALI_TEST_CHECK( value );
194 DALI_TEST_CHECK( value->Get<int>() == 2 );
200 int UtcDaliAnimatedImageVisualSynchronousLoading(void)
202 ToolkitTestApplication application;
203 TestGlAbstraction& gl = application.GetGlAbstraction();
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);
214 VisualFactory factory = VisualFactory::Get();
215 Visual::Base visual = factory.CreateVisual( propertyMap );
217 DummyControl dummyControl = DummyControl::New(true);
218 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
219 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
221 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
222 application.GetScene().Add( dummyControl );
224 TraceCallStack& textureTrace = gl.GetTextureTrace();
225 textureTrace.Enable(true);
227 application.SendNotification();
228 application.Render(20);
230 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
232 application.SendNotification();
233 application.Render();
235 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
236 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 2, TEST_LOCATION );
238 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 3 );
240 application.SendNotification();
241 application.Render(20);
243 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
245 application.SendNotification();
246 application.Render();
248 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
250 dummyControl.Unparent();
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 );
261 int UtcDaliAnimatedImageVisualJumpToAction(void)
263 ToolkitTestApplication application;
264 TestGlAbstraction& gl = application.GetGlAbstraction();
266 Property::Array urls;
267 CopyUrlsIntoArray( urls );
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);
277 VisualFactory factory = VisualFactory::Get();
278 Visual::Base visual = factory.CreateVisual( propertyMap );
280 DummyControl dummyControl = DummyControl::New(true);
281 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
282 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
284 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
285 application.GetScene().Add( dummyControl );
286 application.SendNotification();
287 application.Render(20);
289 tet_infoline( "Ready the visual after the visual is on stage" );
290 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
292 tet_infoline( "Test that a timer has been started" );
293 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
295 TraceCallStack& textureTrace = gl.GetTextureTrace();
296 textureTrace.Enable(true);
298 application.SendNotification();
299 application.Render(20);
301 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
303 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map() );
305 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
307 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 20 );
309 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
311 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 6 );
313 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 6 ), true, TEST_LOCATION );
314 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
316 dummyControl.Unparent();
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 );
327 int UtcDaliAnimatedImageVisualStopBehavior(void)
329 ToolkitTestApplication application;
330 TestGlAbstraction& gl = application.GetGlAbstraction();
332 Property::Array urls;
333 CopyUrlsIntoArray( urls );
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);
344 VisualFactory factory = VisualFactory::Get();
345 Visual::Base visual = factory.CreateVisual( propertyMap );
347 // Expect that a batch of 4 textures has been requested. These will be serially loaded
350 DummyControl dummyControl = DummyControl::New(true);
351 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
352 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
354 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
355 application.GetScene().Add( dummyControl );
356 application.SendNotification();
357 application.Render(20);
359 tet_infoline( "Ready the visual after the visual is on stage" );
360 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
362 tet_infoline( "Test that a timer has been started" );
363 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
365 TraceCallStack& textureTrace = gl.GetTextureTrace();
366 textureTrace.Enable(true);
368 application.SendNotification();
369 application.Render(20);
371 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
373 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map() );
375 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
377 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 1 );
379 // Expect the second batch has been requested
380 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
382 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
384 dummyControl.Unparent();
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 );
395 int UtcDaliAnimatedImageVisualAnimatedImage01(void)
397 ToolkitTestApplication application;
398 TestGlAbstraction& gl = application.GetGlAbstraction();
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);
408 VisualFactory factory = VisualFactory::Get();
409 Visual::Base visual = factory.CreateVisual( propertyMap );
411 // Expect that a batch of 4 textures has been requested. These will be serially loaded
414 DummyControl dummyControl = DummyControl::New(true);
415 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
416 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
418 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
419 application.GetScene().Add( dummyControl );
421 application.SendNotification();
422 application.Render();
424 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
426 application.SendNotification();
427 application.Render(20);
429 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 2, TEST_LOCATION );
431 tet_infoline( "Test that a timer has been started" );
433 TraceCallStack& textureTrace = gl.GetTextureTrace();
434 textureTrace.Enable(true);
436 Test::EmitGlobalTimerSignal();
438 application.SendNotification();
439 application.Render();
441 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
443 application.SendNotification();
444 application.Render(20);
446 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
448 dummyControl.Unparent();
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 );
459 int UtcDaliAnimatedImageVisualMultiImage01(void)
461 ToolkitTestApplication application;
462 TestGlAbstraction& gl = application.GetGlAbstraction();
464 Property::Array urls;
465 CopyUrlsIntoArray( urls );
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);
475 VisualFactory factory = VisualFactory::Get();
476 Visual::Base visual = factory.CreateVisual( propertyMap );
478 // Expect that a batch of 4 textures has been requested. These will be serially loaded
481 DummyControl dummyControl = DummyControl::New(true);
482 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
483 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
485 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
486 application.GetScene().Add( dummyControl );
487 application.SendNotification();
488 application.Render(16);
490 tet_infoline( "Ready the visual after the visual is on stage" );
491 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
493 tet_infoline( "Test that a timer has been started" );
494 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
496 TraceCallStack& textureTrace = gl.GetTextureTrace();
497 textureTrace.Enable(true);
499 application.SendNotification();
500 application.Render(16);
502 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
503 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
505 tet_infoline( "Test that after 1 tick, and file loads completed, that we have 7 textures" );
506 Test::EmitGlobalTimerSignal();
508 // Expect the second batch has been requested
509 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
511 application.SendNotification();
512 application.Render(16);
513 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 7, TEST_LOCATION );
516 tet_infoline( "Test that after 2 ticks that we have 6 textures" );
518 Test::EmitGlobalTimerSignal();
519 application.SendNotification();
520 application.Render(16);
521 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 6, TEST_LOCATION );
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 );
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 );
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 );
541 dummyControl.Unparent();
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 );
551 int UtcDaliAnimatedImageVisualMultiImage02(void)
553 ToolkitTestApplication application;
554 TestGlAbstraction& gl = application.GetGlAbstraction();
556 tet_infoline( "Test that the animated visual has different batch and cache size." );
559 Property::Array urls;
560 CopyUrlsIntoArray( urls );
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, 0);
566 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 0);
567 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
569 VisualFactory factory = VisualFactory::Get();
570 Visual::Base visual = factory.CreateVisual( propertyMap ); // TexMgr::Request load tId:0
572 // Check the batch size and cache size need to have minimum 2.
573 Property::Map resultMap;
574 visual.CreatePropertyMap( resultMap );
575 Property::Value* value = resultMap.Find( ImageVisual::Property::BATCH_SIZE, "batchSize" );
576 DALI_TEST_CHECK( value );
577 DALI_TEST_EQUALS( value->Get<int>(), 2, TEST_LOCATION );
578 value = resultMap.Find( ImageVisual::Property::CACHE_SIZE, "cacheSize" );
579 DALI_TEST_CHECK( value );
580 DALI_TEST_EQUALS( value->Get<int>(), 2, TEST_LOCATION );
583 // Batch size is 2 and cache size is 3
585 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
586 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
587 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2);
588 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 3);
589 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
591 visual = factory.CreateVisual( propertyMap ); // TexMgr::Request load tId:0
593 // Expect that each image is loaded each tick
594 DummyControl dummyControl = DummyControl::New(true);
595 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
596 dummyImpl1.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
599 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
600 application.GetScene().Add( dummyControl );
601 application.SendNotification();
602 application.Render(16);
604 tet_infoline( "Ready the visual after the visual is on window" );
605 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
606 application.SendNotification();
607 application.Render(16);//glGenTextures 1 and 2
608 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 2, TEST_LOCATION );
610 tet_infoline( "Test that each tick, a new image is requested" );
611 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
612 application.SendNotification();
613 application.Render(16);
614 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
615 application.SendNotification();
616 application.Render(16);//glGenTextures 3
617 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
619 tet_infoline( "Test that each tick, a new image is requested" );
620 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:1
621 application.SendNotification();
622 application.Render(16);
623 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
624 application.SendNotification();
625 application.Render(16);//glGenTextures 4
626 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
628 dummyImpl1.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
629 dummyControl.Unparent();
632 // Batch size is 9 and cache size is 4
634 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
635 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
636 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 3);
637 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 7);
638 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
640 visual = factory.CreateVisual( propertyMap ); // TexMgr::Request load tId:0
642 // Expect that each image is loaded each tick
643 dummyControl = DummyControl::New(true);
644 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
645 dummyImpl2.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
648 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
649 application.GetScene().Add( dummyControl );
650 application.SendNotification();
651 application.Render(16);
653 tet_infoline( "Ready the visual after the visual is on window" );
654 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
655 application.SendNotification();
656 application.Render(16);//glGenTextures 1, 2, and 3
657 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
659 tet_infoline( "Test that each tick, a new image is requested" );
660 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
661 application.SendNotification();
662 application.Render(16);
663 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
664 application.SendNotification();
665 application.Render(16);//glGenTextures 4, 5, and 6
666 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 5, TEST_LOCATION );
668 tet_infoline( "Test that each tick, a new image is requested" );
669 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:1
670 application.SendNotification();
671 application.Render(16);
672 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
673 application.SendNotification();
674 application.Render(16);//glGenTextures 7, 1, and 2
675 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 7, TEST_LOCATION );
677 tet_infoline( "Test that each tick, a new image is requested" );
678 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:2
679 application.SendNotification();
680 application.Render(16);
681 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
682 application.SendNotification();
683 application.Render(16);//glGenTextures 3
684 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 7, TEST_LOCATION );
686 dummyControl.Unparent();
688 tet_infoline("Test that removing the visual from window deletes all textures");
689 application.SendNotification();
690 application.Render(16);
691 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
696 int UtcDaliAnimatedImageVisualMultiImage03(void)
698 ToolkitTestApplication application;
699 TestGlAbstraction& gl = application.GetGlAbstraction();
702 Property::Array urls1, urls2;
703 CopyUrlsIntoArray( urls1 );
704 CopyUrlsIntoArray( urls2 );
706 Property::Map animatedImageMap1;
707 animatedImageMap1.Insert(Visual::Property::TYPE, Visual::IMAGE );
708 animatedImageMap1.Insert( ImageVisual::Property::URL, Property::Value(urls1) );
709 animatedImageMap1.Insert( ImageVisual::Property::BATCH_SIZE, 3);
710 animatedImageMap1.Insert( ImageVisual::Property::CACHE_SIZE, 3);
711 animatedImageMap1.Insert( ImageVisual::Property::FRAME_DELAY, 100);
713 Property::Map animatedImageMap2;
714 animatedImageMap2.Insert(Visual::Property::TYPE, Visual::IMAGE );
715 animatedImageMap2.Insert( ImageVisual::Property::URL, Property::Value(urls2) );
716 animatedImageMap2.Insert( ImageVisual::Property::BATCH_SIZE, 2);
717 animatedImageMap2.Insert( ImageVisual::Property::CACHE_SIZE, 2);
718 animatedImageMap2.Insert( ImageVisual::Property::FRAME_DELAY, 100);
720 VisualFactory factory = VisualFactory::Get();
721 Visual::Base animatedImageVisual1 = factory.CreateVisual( animatedImageMap1 );
723 tet_infoline( "Create two image views with the same URLs, offset by 1 frame.");
725 DummyControl dummyControl1 = DummyControl::New(true);
726 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl1.GetImplementation());
727 dummyImpl1.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual1 );
728 dummyControl1.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
729 application.GetScene().Add( dummyControl1 );
731 application.SendNotification();
732 application.Render(16);
734 tet_infoline( "Ready the requested image after the first visual is on stage" );
735 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
736 application.SendNotification();
737 application.Render(16);
738 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
740 Visual::Base animatedImageVisual2 = factory.CreateVisual( animatedImageMap2 );
741 DummyControl dummyControl2 = DummyControl::New(true);
742 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl2.GetImplementation());
743 dummyImpl2.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual2 );
744 dummyControl2.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
745 application.GetScene().Add( dummyControl2 );
746 application.SendNotification();
747 application.Render(16);
749 tet_infoline( "The texture cache should be holding the requested images; check that the renderer has a texture" );
750 TextureSet ts = dummyControl2.GetRendererAt(0).GetTextures();
751 Texture t1 = ts.GetTexture( 0 );
752 DALI_TEST_EQUALS( ts.GetTextureCount(), 1, TEST_LOCATION );
754 tet_infoline( "Test that on the first tick, 1 new image is requested" );
755 Test::EmitGlobalTimerSignal(); // Both visuals should tick
757 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
758 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
760 ts = dummyControl2.GetRendererAt(0).GetTextures();
761 Texture t2 = ts.GetTexture( 0 );
762 DALI_TEST_CHECK( t1 != t2 );
764 dummyControl1.Unparent();
765 dummyControl2.Unparent();
767 tet_infoline("Test that removing the visual from stage deletes all textures");
768 application.SendNotification();
769 application.Render(16);
770 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
776 int UtcDaliAnimatedImageVisualMultiImage04(void)
778 ToolkitTestApplication application;
779 TestGlAbstraction& gl = application.GetGlAbstraction();
780 TraceCallStack& textureTrace = gl.GetTextureTrace();
781 textureTrace.Enable(true);
783 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" );
785 Property::Array urls;
786 CopyUrlsIntoArray( urls );
789 Property::Map propertyMap;
790 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
791 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
792 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 6);
793 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 11);
794 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
796 VisualFactory factory = VisualFactory::Get();
797 Visual::Base visual = factory.CreateVisual( propertyMap );
799 tet_infoline( "Expect that a batch of 7 textures has been requested." );
801 DummyControl dummyControl = DummyControl::New(true);
802 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
803 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
805 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
806 application.GetScene().Add( dummyControl );
807 application.SendNotification();
808 application.Render(16);
810 tet_infoline( "Wait for the first batch to complete" );
811 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 6 ), true, TEST_LOCATION );
813 tet_infoline( "Test that a timer has been started" );
814 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
816 application.SendNotification();
817 application.Render(16);
819 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 6, TEST_LOCATION );
820 tet_infoline( "Test that after 1 tick, and 5 file loads completed, that we have 11 textures" );
821 Test::EmitGlobalTimerSignal();
822 application.SendNotification();
823 application.Render(16);
825 // Expect the second batch has been requested
826 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 5 ), true, TEST_LOCATION );
828 application.SendNotification();
829 application.Render(16);
830 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 11, TEST_LOCATION );
832 tet_infoline( "Test that after 2 ticks that we have 11 textures and no requests" );
834 Test::EmitGlobalTimerSignal();
835 application.SendNotification();
836 application.Render(16);
837 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, 5 ), false, TEST_LOCATION );
838 application.SendNotification();
839 application.Render(16);
840 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 11, TEST_LOCATION );
842 tet_infoline( "Test that after 3rd tick that we have 11 textures and no requests" );
843 Test::EmitGlobalTimerSignal();
844 application.SendNotification();
845 application.Render(16);
847 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, 5 ), false, TEST_LOCATION );
848 application.SendNotification();
849 application.Render(16);
850 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 11, TEST_LOCATION );
852 dummyControl.Unparent();
855 tet_infoline("Test that removing the visual from stage deletes all textures");
856 application.SendNotification();
857 application.Render(16);
858 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
864 int UtcDaliAnimatedImageVisualMultiImage05(void)
866 ToolkitTestApplication application;
867 TestGlAbstraction& gl = application.GetGlAbstraction();
869 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" );
871 Property::Array urls;
872 CopyUrlsIntoArray( urls );
875 Property::Map propertyMap;
876 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
877 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
878 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 4);
879 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 11);
880 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
882 VisualFactory factory = VisualFactory::Get();
883 Visual::Base visual = factory.CreateVisual( propertyMap );
885 tet_infoline( "Expect that a batch of 4 textures has been requested." );
887 DummyControl dummyControl = DummyControl::New(true);
888 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
889 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
891 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
892 application.GetScene().Add( dummyControl );
893 application.SendNotification();
894 application.Render(16);
896 tet_infoline( "Wait for the first batch to complete" );
897 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
899 tet_infoline( "Test that a timer has been started" );
900 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
902 application.SendNotification();
903 application.Render(16);
905 tet_infoline( "Test that a timer has been started" );
906 Test::EmitGlobalTimerSignal();
907 application.SendNotification();
908 application.Render(16);
910 dummyControl.Unparent();
913 application.SendNotification();
914 application.Render(16);
915 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
917 tet_infoline( "Test that pending batch of image loads are cancelled instead of uploaded");
918 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
919 application.SendNotification();
920 application.Render(16);
921 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
926 void TestLoopCount( ToolkitTestApplication &application, DummyControl &dummyControl, uint16_t frameCount, uint16_t loopCount, const char * location )
928 TestGlAbstraction& gl = application.GetGlAbstraction();
929 TraceCallStack& textureTrace = gl.GetTextureTrace();
931 textureTrace.Enable(true);
932 application.GetScene().Add( dummyControl );
934 application.SendNotification();
935 application.Render(16);
937 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_INNER_LOCATION( location ) );
939 application.SendNotification();
940 application.Render();
942 tet_infoline( "Test that a timer has been created" );
943 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_INNER_LOCATION( location ) );
945 for ( uint16_t i = 0; i < loopCount; i++ )
947 for ( uint16_t j = 0; j < frameCount; j++ )
949 if( i == 0 && j == 0 )
951 continue; // Because first frame is already showed and we call 2nd frame at the first time of timer animation.
953 tet_printf( "Test that after %u ticks, and we have %u frame \n", j + 1u, j + 1u );
954 Test::EmitGlobalTimerSignal();
955 application.SendNotification();
956 application.Render(16);
958 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_INNER_LOCATION( location ) );
960 application.SendNotification();
961 application.Render();
962 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 2, TEST_INNER_LOCATION( location ) );
963 DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_INNER_LOCATION( location ) );
965 tet_printf( "Test Loop %u \n\n", i + 1u );
968 tet_printf( "Test that after %u loops, and we have no frame. Timer should stop \n", loopCount );
969 Test::EmitGlobalTimerSignal();
970 application.SendNotification();
971 application.Render(16);
972 DALI_TEST_EQUALS( Test::AreTimersRunning(), false, TEST_INNER_LOCATION( location ) );
974 dummyControl.Unparent();
977 int UtcDaliAnimatedImageVisualLoopCount(void)
979 ToolkitTestApplication application;
981 tet_infoline( "UtcDaliAnimatedImageVisualLoopCount" );
984 // request AnimatedImageVisual with a property map
985 // Test with no (0) loop count
986 VisualFactory factory = VisualFactory::Get();
987 Visual::Base animatedImageVisual = factory.CreateVisual(
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, 0 ));
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 );
1001 TestLoopCount( application, dummyControl, 4, 0, TEST_LOCATION );
1003 dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
1004 animatedImageVisual.Reset();
1006 application.SendNotification();
1007 application.Render(16);
1009 // Test with no (1) loop count. Request AnimatedImageVisual with a property map
1010 animatedImageVisual = factory.CreateVisual(
1012 .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
1013 .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
1014 .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
1015 .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
1016 .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
1017 .Add( DevelImageVisual::Property::LOOP_COUNT, 1 ));
1019 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual );
1021 TestLoopCount( application, dummyControl, 4, 1, TEST_LOCATION );
1023 dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
1024 animatedImageVisual.Reset();
1026 application.SendNotification();
1027 application.Render(16);
1029 // Test with no (100) loop count. Request AnimatedImageVisual with a property map
1030 animatedImageVisual = factory.CreateVisual(
1032 .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
1033 .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
1034 .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
1035 .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
1036 .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
1037 .Add( DevelImageVisual::Property::LOOP_COUNT, 100 ));
1039 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual );
1041 TestLoopCount( application, dummyControl, 4, 100, TEST_LOCATION );
1046 int UtcDaliAnimatedImageVisualPlayback(void)
1048 ToolkitTestApplication application;
1049 TestGlAbstraction& gl = application.GetGlAbstraction();
1050 TraceCallStack& textureTrace = gl.GetTextureTrace();
1052 tet_infoline( "UtcDaliAnimatedImageVisualPlayback" );
1055 // request AnimatedImageVisual with a property map
1056 // Test with forever (-1) loop count
1057 VisualFactory factory = VisualFactory::Get();
1058 Visual::Base animatedImageVisual = factory.CreateVisual(
1060 .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
1061 .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
1062 .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
1063 .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
1064 .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
1065 .Add( DevelImageVisual::Property::LOOP_COUNT, -1 ));
1067 DummyControl dummyControl = DummyControl::New(true);
1068 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1069 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual );
1070 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
1072 textureTrace.Enable(true);
1073 application.GetScene().Add( dummyControl );
1074 application.SendNotification();
1075 application.Render(16);
1077 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
1079 application.SendNotification();
1080 application.Render();
1082 tet_infoline( "Test that a timer has been created" );
1083 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
1085 Test::EmitGlobalTimerSignal();
1086 application.SendNotification();
1087 application.Render(16);
1089 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1091 application.SendNotification();
1092 application.Render();
1093 DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_LOCATION );
1095 Property::Map attributes;
1096 tet_infoline( "Test Pause action. Timer should stop after Pause action" );
1097 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PAUSE, attributes );
1098 Test::EmitGlobalTimerSignal();
1099 application.SendNotification();
1100 application.Render(16);
1101 DALI_TEST_EQUALS( Test::AreTimersRunning(), false, TEST_LOCATION );
1103 tet_infoline( "Test Play action. Timer should Restart after Play action" );
1104 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes );
1105 Test::EmitGlobalTimerSignal();
1106 application.SendNotification();
1107 application.Render(16);
1109 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1111 application.SendNotification();
1112 application.Render();
1113 DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_LOCATION );
1115 tet_infoline( "Test Stop action. Timer should stop after Stop action" );
1116 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, attributes );
1117 Test::EmitGlobalTimerSignal();
1118 application.SendNotification();
1119 application.Render(16);
1120 DALI_TEST_EQUALS( Test::AreTimersRunning(), false, TEST_LOCATION );
1122 tet_infoline( "Test Play action. Timer should Restart after Play action" );
1123 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes );
1124 Test::EmitGlobalTimerSignal();
1125 application.SendNotification();
1126 application.Render(16);
1128 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1130 application.SendNotification();
1131 application.Render();
1132 DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_LOCATION );
1134 dummyControl.Unparent();