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 UtcDaliAnimatedImageVisualStopBehavior02(void)
397 ToolkitTestApplication application;
398 TestGlAbstraction& gl = application.GetGlAbstraction();
400 Property::Array urls;
401 CopyUrlsIntoArray( urls );
404 Property::Map propertyMap;
405 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
406 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
407 propertyMap.Insert( DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
408 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2);
409 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 2);
410 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20);
412 VisualFactory factory = VisualFactory::Get();
413 Visual::Base visual = factory.CreateVisual( propertyMap );
415 // Expect that a batch of 4 textures has been requested. These will be serially loaded
418 DummyControl dummyControl = DummyControl::New(true);
419 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
420 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
422 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
423 application.GetScene().Add( dummyControl );
425 tet_infoline( "Ready the visual after the visual is on stage" );
426 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
428 TraceCallStack& textureTrace = gl.GetTextureTrace();
429 textureTrace.Enable(true);
431 application.SendNotification();
432 application.Render(20);
434 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 2, TEST_LOCATION );
436 Test::EmitGlobalTimerSignal();
438 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
440 application.SendNotification();
441 application.Render(20);
443 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 2, TEST_LOCATION );
445 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map() );
447 tet_infoline( "Ready the visual after the visual is on stage" );
448 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
450 application.SendNotification();
451 application.Render(20);
453 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 2, TEST_LOCATION );
455 dummyControl.Unparent();
457 tet_infoline("Test that removing the visual from stage deletes all textures");
458 application.SendNotification();
459 application.Render(16);
460 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
466 int UtcDaliAnimatedImageVisualAnimatedImage01(void)
468 ToolkitTestApplication application;
469 TestGlAbstraction& gl = application.GetGlAbstraction();
472 Property::Map propertyMap;
473 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE );
474 propertyMap.Insert( ImageVisual::Property::URL, TEST_GIF_FILE_NAME );
475 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2);
476 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 4);
477 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20);
479 VisualFactory factory = VisualFactory::Get();
480 Visual::Base visual = factory.CreateVisual( propertyMap );
482 // Expect that a batch of 4 textures has been requested. These will be serially loaded
485 DummyControl dummyControl = DummyControl::New(true);
486 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
487 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
489 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
490 application.GetScene().Add( dummyControl );
492 application.SendNotification();
493 application.Render();
495 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
497 application.SendNotification();
498 application.Render(20);
500 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 2, TEST_LOCATION );
502 tet_infoline( "Test that a timer has been started" );
504 TraceCallStack& textureTrace = gl.GetTextureTrace();
505 textureTrace.Enable(true);
507 Test::EmitGlobalTimerSignal();
509 application.SendNotification();
510 application.Render();
512 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
514 application.SendNotification();
515 application.Render(20);
517 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
519 dummyControl.Unparent();
521 tet_infoline("Test that removing the visual from stage deletes all textures");
522 application.SendNotification();
523 application.Render(20);
524 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
530 int UtcDaliAnimatedImageVisualMultiImage01(void)
532 ToolkitTestApplication application;
533 TestGlAbstraction& gl = application.GetGlAbstraction();
535 Property::Array urls;
536 CopyUrlsIntoArray( urls );
539 Property::Map propertyMap;
540 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
541 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
542 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 4);
543 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 8);
544 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
546 VisualFactory factory = VisualFactory::Get();
547 Visual::Base visual = factory.CreateVisual( propertyMap );
549 // Expect that a batch of 4 textures has been requested. These will be serially loaded
552 DummyControl dummyControl = DummyControl::New(true);
553 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
554 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
556 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
557 application.GetScene().Add( dummyControl );
558 application.SendNotification();
559 application.Render(16);
561 tet_infoline( "Ready the visual after the visual is on stage" );
562 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
564 tet_infoline( "Test that a timer has been started" );
565 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
567 TraceCallStack& textureTrace = gl.GetTextureTrace();
568 textureTrace.Enable(true);
570 application.SendNotification();
571 application.Render(16);
573 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
574 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
576 tet_infoline( "Test that after 1 tick, and file loads completed, that we have 7 textures" );
577 Test::EmitGlobalTimerSignal();
579 // Expect the second batch has been requested
580 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
582 application.SendNotification();
583 application.Render(16);
584 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 7, TEST_LOCATION );
587 tet_infoline( "Test that after 2 ticks that we have 6 textures" );
589 Test::EmitGlobalTimerSignal();
590 application.SendNotification();
591 application.Render(16);
592 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 6, TEST_LOCATION );
594 tet_infoline("And that at least 2 textures were requested");
595 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
596 application.SendNotification();
597 application.Render(16);
598 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 8, TEST_LOCATION );
601 tet_infoline( "Test that after 3rd tick that we have 7 textures and 1 request" );
602 Test::EmitGlobalTimerSignal();
603 application.SendNotification();
604 application.Render(16);
605 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 7, TEST_LOCATION );
607 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
608 application.SendNotification();
609 application.Render(16);
610 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 8, TEST_LOCATION );
612 dummyControl.Unparent();
614 tet_infoline("Test that removing the visual from stage deletes all textures");
615 application.SendNotification();
616 application.Render(16);
617 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
622 int UtcDaliAnimatedImageVisualMultiImage02(void)
624 ToolkitTestApplication application;
625 TestGlAbstraction& gl = application.GetGlAbstraction();
627 tet_infoline( "Test that the animated visual has different batch and cache size." );
630 Property::Array urls;
631 CopyUrlsIntoArray( urls );
633 Property::Map propertyMap;
634 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
635 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
636 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 0);
637 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 0);
638 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
640 VisualFactory factory = VisualFactory::Get();
641 Visual::Base visual = factory.CreateVisual( propertyMap ); // TexMgr::Request load tId:0
643 // Check the batch size and cache size need to have minimum 2.
644 Property::Map resultMap;
645 visual.CreatePropertyMap( resultMap );
646 Property::Value* value = resultMap.Find( ImageVisual::Property::BATCH_SIZE, "batchSize" );
647 DALI_TEST_CHECK( value );
648 DALI_TEST_EQUALS( value->Get<int>(), 2, TEST_LOCATION );
649 value = resultMap.Find( ImageVisual::Property::CACHE_SIZE, "cacheSize" );
650 DALI_TEST_CHECK( value );
651 DALI_TEST_EQUALS( value->Get<int>(), 2, TEST_LOCATION );
654 // Batch size is 2 and cache size is 3
656 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
657 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
658 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2);
659 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 3);
660 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
662 visual = factory.CreateVisual( propertyMap ); // TexMgr::Request load tId:0
664 // Expect that each image is loaded each tick
665 DummyControl dummyControl = DummyControl::New(true);
666 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
667 dummyImpl1.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
670 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
671 application.GetScene().Add( dummyControl );
672 application.SendNotification();
673 application.Render(16);
675 tet_infoline( "Ready the visual after the visual is on window" );
676 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
677 application.SendNotification();
678 application.Render(16);//glGenTextures 1 and 2
679 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 2, TEST_LOCATION );
681 tet_infoline( "Test that each tick, a new image is requested" );
682 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
683 application.SendNotification();
684 application.Render(16);
685 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
686 application.SendNotification();
687 application.Render(16);//glGenTextures 3
688 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
690 tet_infoline( "Test that each tick, a new image is requested" );
691 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:1
692 application.SendNotification();
693 application.Render(16);
694 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
695 application.SendNotification();
696 application.Render(16);//glGenTextures 4
697 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
699 dummyImpl1.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
700 dummyControl.Unparent();
703 // Batch size is 9 and cache size is 4
705 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
706 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
707 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 3);
708 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 7);
709 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
711 visual = factory.CreateVisual( propertyMap ); // TexMgr::Request load tId:0
713 // Expect that each image is loaded each tick
714 dummyControl = DummyControl::New(true);
715 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
716 dummyImpl2.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
719 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
720 application.GetScene().Add( dummyControl );
721 application.SendNotification();
722 application.Render(16);
724 tet_infoline( "Ready the visual after the visual is on window" );
725 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
726 application.SendNotification();
727 application.Render(16);//glGenTextures 1, 2, and 3
728 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
730 tet_infoline( "Test that each tick, a new image is requested" );
731 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
732 application.SendNotification();
733 application.Render(16);
734 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
735 application.SendNotification();
736 application.Render(16);//glGenTextures 4, 5, and 6
737 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 5, TEST_LOCATION );
739 tet_infoline( "Test that each tick, a new image is requested" );
740 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:1
741 application.SendNotification();
742 application.Render(16);
743 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
744 application.SendNotification();
745 application.Render(16);//glGenTextures 7, 1, and 2
746 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 7, TEST_LOCATION );
748 tet_infoline( "Test that each tick, a new image is requested" );
749 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:2
750 application.SendNotification();
751 application.Render(16);
752 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
753 application.SendNotification();
754 application.Render(16);//glGenTextures 3
755 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 7, TEST_LOCATION );
757 dummyControl.Unparent();
759 tet_infoline("Test that removing the visual from window deletes all textures");
760 application.SendNotification();
761 application.Render(16);
762 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
767 int UtcDaliAnimatedImageVisualMultiImage03(void)
769 ToolkitTestApplication application;
770 TestGlAbstraction& gl = application.GetGlAbstraction();
773 Property::Array urls1, urls2;
774 CopyUrlsIntoArray( urls1 );
775 CopyUrlsIntoArray( urls2 );
777 Property::Map animatedImageMap1;
778 animatedImageMap1.Insert(Visual::Property::TYPE, Visual::IMAGE );
779 animatedImageMap1.Insert( ImageVisual::Property::URL, Property::Value(urls1) );
780 animatedImageMap1.Insert( ImageVisual::Property::BATCH_SIZE, 3);
781 animatedImageMap1.Insert( ImageVisual::Property::CACHE_SIZE, 3);
782 animatedImageMap1.Insert( ImageVisual::Property::FRAME_DELAY, 100);
784 Property::Map animatedImageMap2;
785 animatedImageMap2.Insert(Visual::Property::TYPE, Visual::IMAGE );
786 animatedImageMap2.Insert( ImageVisual::Property::URL, Property::Value(urls2) );
787 animatedImageMap2.Insert( ImageVisual::Property::BATCH_SIZE, 2);
788 animatedImageMap2.Insert( ImageVisual::Property::CACHE_SIZE, 2);
789 animatedImageMap2.Insert( ImageVisual::Property::FRAME_DELAY, 100);
791 VisualFactory factory = VisualFactory::Get();
792 Visual::Base animatedImageVisual1 = factory.CreateVisual( animatedImageMap1 );
794 tet_infoline( "Create two image views with the same URLs, offset by 1 frame.");
796 DummyControl dummyControl1 = DummyControl::New(true);
797 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl1.GetImplementation());
798 dummyImpl1.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual1 );
799 dummyControl1.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
800 application.GetScene().Add( dummyControl1 );
802 application.SendNotification();
803 application.Render(16);
805 tet_infoline( "Ready the requested image after the first visual is on stage" );
806 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
807 application.SendNotification();
808 application.Render(16);
809 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
811 Visual::Base animatedImageVisual2 = factory.CreateVisual( animatedImageMap2 );
812 DummyControl dummyControl2 = DummyControl::New(true);
813 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl2.GetImplementation());
814 dummyImpl2.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual2 );
815 dummyControl2.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
816 application.GetScene().Add( dummyControl2 );
817 application.SendNotification();
818 application.Render(16);
820 tet_infoline( "The texture cache should be holding the requested images; check that the renderer has a texture" );
821 TextureSet ts = dummyControl2.GetRendererAt(0).GetTextures();
822 Texture t1 = ts.GetTexture( 0 );
823 DALI_TEST_EQUALS( ts.GetTextureCount(), 1, TEST_LOCATION );
825 tet_infoline( "Test that on the first tick, 1 new image is requested" );
826 Test::EmitGlobalTimerSignal(); // Both visuals should tick
828 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
829 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
831 ts = dummyControl2.GetRendererAt(0).GetTextures();
832 Texture t2 = ts.GetTexture( 0 );
833 DALI_TEST_CHECK( t1 != t2 );
835 dummyControl1.Unparent();
836 dummyControl2.Unparent();
838 tet_infoline("Test that removing the visual from stage deletes all textures");
839 application.SendNotification();
840 application.Render(16);
841 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
847 int UtcDaliAnimatedImageVisualMultiImage04(void)
849 ToolkitTestApplication application;
850 TestGlAbstraction& gl = application.GetGlAbstraction();
851 TraceCallStack& textureTrace = gl.GetTextureTrace();
852 textureTrace.Enable(true);
854 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" );
856 Property::Array urls;
857 CopyUrlsIntoArray( urls );
860 Property::Map propertyMap;
861 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
862 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
863 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 6);
864 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 11);
865 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
867 VisualFactory factory = VisualFactory::Get();
868 Visual::Base visual = factory.CreateVisual( propertyMap );
870 tet_infoline( "Expect that a batch of 7 textures has been requested." );
872 DummyControl dummyControl = DummyControl::New(true);
873 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
874 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
876 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
877 application.GetScene().Add( dummyControl );
878 application.SendNotification();
879 application.Render(16);
881 tet_infoline( "Wait for the first batch to complete" );
882 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 6 ), true, TEST_LOCATION );
884 tet_infoline( "Test that a timer has been started" );
885 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
887 application.SendNotification();
888 application.Render(16);
890 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 6, TEST_LOCATION );
891 tet_infoline( "Test that after 1 tick, and 5 file loads completed, that we have 11 textures" );
892 Test::EmitGlobalTimerSignal();
893 application.SendNotification();
894 application.Render(16);
896 // Expect the second batch has been requested
897 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 5 ), true, TEST_LOCATION );
899 application.SendNotification();
900 application.Render(16);
901 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 11, TEST_LOCATION );
903 tet_infoline( "Test that after 2 ticks that we have 11 textures and no requests" );
905 Test::EmitGlobalTimerSignal();
906 application.SendNotification();
907 application.Render(16);
908 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, 5 ), false, TEST_LOCATION );
909 application.SendNotification();
910 application.Render(16);
911 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 11, TEST_LOCATION );
913 tet_infoline( "Test that after 3rd tick that we have 11 textures and no requests" );
914 Test::EmitGlobalTimerSignal();
915 application.SendNotification();
916 application.Render(16);
918 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, 5 ), false, TEST_LOCATION );
919 application.SendNotification();
920 application.Render(16);
921 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 11, TEST_LOCATION );
923 dummyControl.Unparent();
926 tet_infoline("Test that removing the visual from stage deletes all textures");
927 application.SendNotification();
928 application.Render(16);
929 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
935 int UtcDaliAnimatedImageVisualMultiImage05(void)
937 ToolkitTestApplication application;
938 TestGlAbstraction& gl = application.GetGlAbstraction();
940 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" );
942 Property::Array urls;
943 CopyUrlsIntoArray( urls );
946 Property::Map propertyMap;
947 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
948 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
949 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 4);
950 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 11);
951 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
953 VisualFactory factory = VisualFactory::Get();
954 Visual::Base visual = factory.CreateVisual( propertyMap );
956 tet_infoline( "Expect that a batch of 4 textures has been requested." );
958 DummyControl dummyControl = DummyControl::New(true);
959 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
960 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
962 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
963 application.GetScene().Add( dummyControl );
964 application.SendNotification();
965 application.Render(16);
967 tet_infoline( "Wait for the first batch to complete" );
968 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
970 tet_infoline( "Test that a timer has been started" );
971 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
973 application.SendNotification();
974 application.Render(16);
976 tet_infoline( "Test that a timer has been started" );
977 Test::EmitGlobalTimerSignal();
978 application.SendNotification();
979 application.Render(16);
981 dummyControl.Unparent();
984 application.SendNotification();
985 application.Render(16);
986 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
988 tet_infoline( "Test that pending batch of image loads are cancelled instead of uploaded");
989 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
990 application.SendNotification();
991 application.Render(16);
992 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
997 void TestLoopCount( ToolkitTestApplication &application, DummyControl &dummyControl, uint16_t frameCount, uint16_t loopCount, const char * location )
999 TestGlAbstraction& gl = application.GetGlAbstraction();
1000 TraceCallStack& textureTrace = gl.GetTextureTrace();
1002 textureTrace.Enable(true);
1003 application.GetScene().Add( dummyControl );
1005 application.SendNotification();
1006 application.Render(16);
1008 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_INNER_LOCATION( location ) );
1010 application.SendNotification();
1011 application.Render();
1013 tet_infoline( "Test that a timer has been created" );
1014 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_INNER_LOCATION( location ) );
1016 for ( uint16_t i = 0; i < loopCount; i++ )
1018 for ( uint16_t j = 0; j < frameCount; j++ )
1020 if( i == 0 && j == 0 )
1022 continue; // Because first frame is already showed and we call 2nd frame at the first time of timer animation.
1024 tet_printf( "Test that after %u ticks, and we have %u frame \n", j + 1u, j + 1u );
1025 Test::EmitGlobalTimerSignal();
1026 application.SendNotification();
1027 application.Render(16);
1029 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_INNER_LOCATION( location ) );
1031 application.SendNotification();
1032 application.Render();
1033 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 2, TEST_INNER_LOCATION( location ) );
1034 DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_INNER_LOCATION( location ) );
1036 tet_printf( "Test Loop %u \n\n", i + 1u );
1039 tet_printf( "Test that after %u loops, and we have no frame. Timer should stop \n", loopCount );
1040 Test::EmitGlobalTimerSignal();
1041 application.SendNotification();
1042 application.Render(16);
1043 DALI_TEST_EQUALS( Test::AreTimersRunning(), false, TEST_INNER_LOCATION( location ) );
1045 dummyControl.Unparent();
1048 int UtcDaliAnimatedImageVisualLoopCount(void)
1050 ToolkitTestApplication application;
1052 tet_infoline( "UtcDaliAnimatedImageVisualLoopCount" );
1055 // request AnimatedImageVisual with a property map
1056 // Test with no (0) 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, 0 ));
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 TestLoopCount( application, dummyControl, 4, 0, TEST_LOCATION );
1074 dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
1075 animatedImageVisual.Reset();
1077 application.SendNotification();
1078 application.Render(16);
1080 // Test with no (1) loop count. Request AnimatedImageVisual with a property map
1081 animatedImageVisual = factory.CreateVisual(
1083 .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
1084 .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
1085 .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
1086 .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
1087 .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
1088 .Add( DevelImageVisual::Property::LOOP_COUNT, 1 ));
1090 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual );
1092 TestLoopCount( application, dummyControl, 4, 1, TEST_LOCATION );
1094 dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
1095 animatedImageVisual.Reset();
1097 application.SendNotification();
1098 application.Render(16);
1100 // Test with no (100) loop count. Request AnimatedImageVisual with a property map
1101 animatedImageVisual = factory.CreateVisual(
1103 .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
1104 .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
1105 .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
1106 .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
1107 .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
1108 .Add( DevelImageVisual::Property::LOOP_COUNT, 100 ));
1110 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual );
1112 TestLoopCount( application, dummyControl, 4, 100, TEST_LOCATION );
1117 int UtcDaliAnimatedImageVisualPlayback(void)
1119 ToolkitTestApplication application;
1120 TestGlAbstraction& gl = application.GetGlAbstraction();
1121 TraceCallStack& textureTrace = gl.GetTextureTrace();
1123 tet_infoline( "UtcDaliAnimatedImageVisualPlayback" );
1126 // request AnimatedImageVisual with a property map
1127 // Test with forever (-1) loop count
1128 VisualFactory factory = VisualFactory::Get();
1129 Visual::Base animatedImageVisual = factory.CreateVisual(
1131 .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
1132 .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
1133 .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
1134 .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
1135 .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
1136 .Add( DevelImageVisual::Property::LOOP_COUNT, -1 ));
1138 DummyControl dummyControl = DummyControl::New(true);
1139 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1140 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual );
1141 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
1143 textureTrace.Enable(true);
1144 application.GetScene().Add( dummyControl );
1145 application.SendNotification();
1146 application.Render(16);
1148 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
1150 application.SendNotification();
1151 application.Render();
1153 tet_infoline( "Test that a timer has been created" );
1154 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
1156 Test::EmitGlobalTimerSignal();
1157 application.SendNotification();
1158 application.Render(16);
1160 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1162 application.SendNotification();
1163 application.Render();
1164 DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_LOCATION );
1166 Property::Map attributes;
1167 tet_infoline( "Test Pause action. Timer should stop after Pause action" );
1168 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PAUSE, attributes );
1169 Test::EmitGlobalTimerSignal();
1170 application.SendNotification();
1171 application.Render(16);
1172 DALI_TEST_EQUALS( Test::AreTimersRunning(), false, TEST_LOCATION );
1174 tet_infoline( "Test Play action. Timer should Restart after Play action" );
1175 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes );
1176 Test::EmitGlobalTimerSignal();
1177 application.SendNotification();
1178 application.Render(16);
1180 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1182 application.SendNotification();
1183 application.Render();
1184 DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_LOCATION );
1186 tet_infoline( "Test Stop action. Timer should stop after Stop action" );
1187 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, attributes );
1188 Test::EmitGlobalTimerSignal();
1189 application.SendNotification();
1190 application.Render(16);
1191 DALI_TEST_EQUALS( Test::AreTimersRunning(), false, TEST_LOCATION );
1193 tet_infoline( "Test Play action. Timer should Restart after Play action" );
1194 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes );
1195 Test::EmitGlobalTimerSignal();
1196 application.SendNotification();
1197 application.Render(16);
1199 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1201 application.SendNotification();
1202 application.Render();
1203 DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_LOCATION );
1205 dummyControl.Unparent();