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 with fixed cache" );
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", 20 )
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>(), 20, 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 );
158 value = resultMap.Find( Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber" );
159 DALI_TEST_CHECK( value );
160 DALI_TEST_EQUALS( value->Get<int>(), 11, TEST_LOCATION );
166 int UtcDaliAnimatedImageVisualGetPropertyMap03(void)
168 ToolkitTestApplication application;
169 tet_infoline( "UtcDaliAnimatedImageVisualGetPropertyMap for multi image rolling cache" );
171 // request AnimatedImageVisual with a property map
172 VisualFactory factory = VisualFactory::Get();
173 Property::Array urls;
174 CopyUrlsIntoArray( urls );
176 Visual::Base animatedImageVisual = factory.CreateVisual(
178 .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
180 .Add( "batchSize", 4 )
181 .Add( "cacheSize", 8 )
182 .Add( "loopCount", 10 )
183 .Add( "frameDelay", 200 )
184 .Add( "pixelArea", Vector4() )
185 .Add( "wrapModeU", WrapMode::REPEAT )
186 .Add( "wrapModeV", WrapMode::DEFAULT ));
188 Property::Map resultMap;
189 animatedImageVisual.CreatePropertyMap( resultMap );
190 // check the property values from the returned map from a visual
191 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
192 DALI_TEST_CHECK( value );
193 DALI_TEST_CHECK( value->Get<int>() == Visual::ANIMATED_IMAGE );
195 value = resultMap.Find( ImageVisual::Property::URL, "url" );
196 DALI_TEST_CHECK( value );
197 Property::Array* resultUrls = value->GetArray();
198 DALI_TEST_CHECK( resultUrls );
199 DALI_TEST_EQUALS( resultUrls->Count(), urls.Count(), TEST_LOCATION );
201 value = resultMap.Find( ImageVisual::Property::BATCH_SIZE, "batchSize" );
202 DALI_TEST_CHECK( value );
203 DALI_TEST_EQUALS( value->Get<int>(), 4, TEST_LOCATION );
205 value = resultMap.Find( ImageVisual::Property::CACHE_SIZE, "cacheSize" );
206 DALI_TEST_CHECK( value );
207 DALI_TEST_EQUALS( value->Get<int>(), 8, TEST_LOCATION );
209 value = resultMap.Find( Toolkit::DevelImageVisual::Property::LOOP_COUNT, "loopCount" );
210 DALI_TEST_CHECK( value );
211 DALI_TEST_EQUALS( value->Get<int>(), 10, TEST_LOCATION );
213 value = resultMap.Find( ImageVisual::Property::FRAME_DELAY, "frameDelay" );
214 DALI_TEST_CHECK( value );
215 DALI_TEST_EQUALS( value->Get<int>(), 200, TEST_LOCATION );
217 value = resultMap.Find( Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber" );
218 DALI_TEST_CHECK( value );
219 DALI_TEST_EQUALS( value->Get<int>(), 11, TEST_LOCATION );
224 int UtcDaliAnimatedImageVisualGetPropertyMap04(void)
226 ToolkitTestApplication application;
227 tet_infoline( "UtcDaliAnimatedImageVisualGetPropertyMap" );
229 // request AnimatedImageVisual with a property map
230 VisualFactory factory = VisualFactory::Get();
231 Visual::Base animatedImageVisual = factory.CreateVisual(
233 .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
234 .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
235 .Add( ImageVisual::Property::BATCH_SIZE, 1 )
236 .Add( ImageVisual::Property::CACHE_SIZE, 1 )
237 .Add( ImageVisual::Property::SYNCHRONOUS_LOADING, false ));
239 Property::Map resultMap;
240 animatedImageVisual.CreatePropertyMap( resultMap );
242 // check the property values from the returned map from a visual
243 Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
244 DALI_TEST_CHECK( value );
245 DALI_TEST_CHECK( value->Get<int>() == Visual::ANIMATED_IMAGE );
247 value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
248 DALI_TEST_CHECK( value );
249 DALI_TEST_CHECK( value->Get<std::string>() == TEST_GIF_FILE_NAME );
251 value = resultMap.Find( ImageVisual::Property::BATCH_SIZE, Property::INTEGER );
252 DALI_TEST_CHECK( value );
253 DALI_TEST_CHECK( value->Get<int>() == 2 );
255 value = resultMap.Find( ImageVisual::Property::CACHE_SIZE, Property::INTEGER );
256 DALI_TEST_CHECK( value );
257 DALI_TEST_CHECK( value->Get<int>() == 2 );
259 value = resultMap.Find( Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber" );
260 DALI_TEST_CHECK( value );
261 DALI_TEST_EQUALS( value->Get<int>(), 4, TEST_LOCATION );
267 int UtcDaliAnimatedImageVisualSynchronousLoading(void)
269 ToolkitTestApplication application;
270 TestGlAbstraction& gl = application.GetGlAbstraction();
273 Property::Map propertyMap;
274 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE );
275 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME );
276 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2);
277 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 2);
278 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20);
279 propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true);
281 VisualFactory factory = VisualFactory::Get();
282 Visual::Base visual = factory.CreateVisual( propertyMap );
284 DummyControl dummyControl = DummyControl::New(true);
285 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
286 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
288 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
289 application.GetScene().Add( dummyControl );
291 TraceCallStack& textureTrace = gl.GetTextureTrace();
292 textureTrace.Enable(true);
294 application.SendNotification();
295 application.Render(20);
297 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
299 application.SendNotification();
300 application.Render();
302 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
303 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 2, TEST_LOCATION );
305 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 3 );
307 application.SendNotification();
308 application.Render(20);
310 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
312 application.SendNotification();
313 application.Render();
315 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
317 dummyControl.Unparent();
319 tet_infoline("Test that removing the visual from stage deletes all textures");
320 application.SendNotification();
321 application.Render(16);
322 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
328 int UtcDaliAnimatedImageVisualJumpToAction(void)
330 ToolkitTestApplication application;
331 TestGlAbstraction& gl = application.GetGlAbstraction();
333 Property::Array urls;
334 CopyUrlsIntoArray( urls );
337 Property::Map propertyMap;
338 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
339 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
340 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 4);
341 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 12);
342 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20);
344 VisualFactory factory = VisualFactory::Get();
345 Visual::Base visual = factory.CreateVisual( propertyMap );
347 DummyControl dummyControl = DummyControl::New(true);
348 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
349 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
351 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
352 application.GetScene().Add( dummyControl );
353 application.SendNotification();
354 application.Render(20);
356 tet_infoline( "Ready the visual after the visual is on stage" );
357 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
359 tet_infoline( "Test that a timer has been started" );
360 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
362 TraceCallStack& textureTrace = gl.GetTextureTrace();
363 textureTrace.Enable(true);
365 application.SendNotification();
366 application.Render(20);
368 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
370 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map() );
372 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
374 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 20 );
376 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
378 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 6 );
380 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 6 ), true, TEST_LOCATION );
381 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
383 dummyControl.Unparent();
385 tet_infoline("Test that removing the visual from stage deletes all textures");
386 application.SendNotification();
387 application.Render(16);
388 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
394 int UtcDaliAnimatedImageVisualStopBehavior(void)
396 ToolkitTestApplication application;
397 TestGlAbstraction& gl = application.GetGlAbstraction();
399 Property::Array urls;
400 CopyUrlsIntoArray( urls );
403 Property::Map propertyMap;
404 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
405 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
406 propertyMap.Insert( DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
407 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 4);
408 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 8);
409 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20);
411 VisualFactory factory = VisualFactory::Get();
412 Visual::Base visual = factory.CreateVisual( propertyMap );
414 // Expect that a batch of 4 textures has been requested. These will be serially loaded
417 DummyControl dummyControl = DummyControl::New(true);
418 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
419 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
421 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
422 application.GetScene().Add( dummyControl );
423 application.SendNotification();
424 application.Render(20);
426 tet_infoline( "Ready the visual after the visual is on stage" );
427 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
429 tet_infoline( "Test that a timer has been started" );
430 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
432 TraceCallStack& textureTrace = gl.GetTextureTrace();
433 textureTrace.Enable(true);
435 application.SendNotification();
436 application.Render(20);
438 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
440 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map() );
442 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
444 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 1 );
446 // Expect the second batch has been requested
447 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
449 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
451 dummyControl.Unparent();
453 tet_infoline("Test that removing the visual from stage deletes all textures");
454 application.SendNotification();
455 application.Render(16);
456 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
462 int UtcDaliAnimatedImageVisualStopBehavior02(void)
464 ToolkitTestApplication application;
465 TestGlAbstraction& gl = application.GetGlAbstraction();
467 Property::Array urls;
468 CopyUrlsIntoArray( urls );
471 Property::Map propertyMap;
472 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
473 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
474 propertyMap.Insert( DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
475 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2);
476 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 2);
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 tet_infoline( "Ready the visual after the visual is on stage" );
493 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
495 TraceCallStack& textureTrace = gl.GetTextureTrace();
496 textureTrace.Enable(true);
498 application.SendNotification();
499 application.Render(20);
501 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 2, TEST_LOCATION );
503 Test::EmitGlobalTimerSignal();
505 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
507 application.SendNotification();
508 application.Render(20);
510 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 2, TEST_LOCATION );
512 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map() );
514 tet_infoline( "Ready the visual after the visual is on stage" );
515 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
517 application.SendNotification();
518 application.Render(20);
520 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 2, TEST_LOCATION );
522 dummyControl.Unparent();
524 tet_infoline("Test that removing the visual from stage deletes all textures");
525 application.SendNotification();
526 application.Render(16);
527 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
533 int UtcDaliAnimatedImageVisualAnimatedImage01(void)
535 ToolkitTestApplication application;
536 TestGlAbstraction& gl = application.GetGlAbstraction();
539 Property::Map propertyMap;
540 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE );
541 propertyMap.Insert( ImageVisual::Property::URL, TEST_GIF_FILE_NAME );
542 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2);
543 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 4);
544 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20);
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 );
559 application.SendNotification();
560 application.Render();
562 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
564 application.SendNotification();
565 application.Render(20);
567 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 2, TEST_LOCATION );
569 tet_infoline( "Test that a timer has been started" );
571 TraceCallStack& textureTrace = gl.GetTextureTrace();
572 textureTrace.Enable(true);
574 Test::EmitGlobalTimerSignal();
576 application.SendNotification();
577 application.Render();
579 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
581 application.SendNotification();
582 application.Render(20);
584 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
586 dummyControl.Unparent();
588 tet_infoline("Test that removing the visual from stage deletes all textures");
589 application.SendNotification();
590 application.Render(20);
591 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
597 int UtcDaliAnimatedImageVisualMultiImage01(void)
599 ToolkitTestApplication application;
600 TestGlAbstraction& gl = application.GetGlAbstraction();
602 Property::Array urls;
603 CopyUrlsIntoArray( urls );
606 Property::Map propertyMap;
607 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
608 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
609 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 4);
610 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 8);
611 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
613 VisualFactory factory = VisualFactory::Get();
614 Visual::Base visual = factory.CreateVisual( propertyMap );
616 // Expect that a batch of 4 textures has been requested. These will be serially loaded
619 DummyControl dummyControl = DummyControl::New(true);
620 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
621 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
623 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
624 application.GetScene().Add( dummyControl );
625 application.SendNotification();
626 application.Render(16);
628 tet_infoline( "Ready the visual after the visual is on stage" );
629 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
631 tet_infoline( "Test that a timer has been started" );
632 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
634 TraceCallStack& textureTrace = gl.GetTextureTrace();
635 textureTrace.Enable(true);
637 application.SendNotification();
638 application.Render(16);
640 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
641 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
643 tet_infoline( "Test that after 1 tick, and file loads completed, that we have 7 textures" );
644 Test::EmitGlobalTimerSignal();
646 // Expect the second batch has been requested
647 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
649 application.SendNotification();
650 application.Render(16);
651 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 7, TEST_LOCATION );
654 tet_infoline( "Test that after 2 ticks that we have 6 textures" );
656 Test::EmitGlobalTimerSignal();
657 application.SendNotification();
658 application.Render(16);
659 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 6, TEST_LOCATION );
661 tet_infoline("And that at least 2 textures were requested");
662 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
663 application.SendNotification();
664 application.Render(16);
665 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 8, TEST_LOCATION );
668 tet_infoline( "Test that after 3rd tick that we have 7 textures and 1 request" );
669 Test::EmitGlobalTimerSignal();
670 application.SendNotification();
671 application.Render(16);
672 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 7, TEST_LOCATION );
674 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
675 application.SendNotification();
676 application.Render(16);
677 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 8, TEST_LOCATION );
679 dummyControl.Unparent();
681 tet_infoline("Test that removing the visual from stage deletes all textures");
682 application.SendNotification();
683 application.Render(16);
684 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
689 int UtcDaliAnimatedImageVisualMultiImage02(void)
691 ToolkitTestApplication application;
692 TestGlAbstraction& gl = application.GetGlAbstraction();
694 tet_infoline( "Test that the animated visual has different batch and cache size." );
697 Property::Array urls;
698 CopyUrlsIntoArray( urls );
700 Property::Map propertyMap;
701 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
702 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
703 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 0);
704 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 0);
705 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
707 VisualFactory factory = VisualFactory::Get();
708 Visual::Base visual = factory.CreateVisual( propertyMap ); // TexMgr::Request load tId:0
710 // Check the batch size and cache size need to have minimum 2.
711 Property::Map resultMap;
712 visual.CreatePropertyMap( resultMap );
713 Property::Value* value = resultMap.Find( ImageVisual::Property::BATCH_SIZE, "batchSize" );
714 DALI_TEST_CHECK( value );
715 DALI_TEST_EQUALS( value->Get<int>(), 2, TEST_LOCATION );
716 value = resultMap.Find( ImageVisual::Property::CACHE_SIZE, "cacheSize" );
717 DALI_TEST_CHECK( value );
718 DALI_TEST_EQUALS( value->Get<int>(), 2, TEST_LOCATION );
721 // Batch size is 2 and cache size is 3
723 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
724 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
725 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2);
726 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 3);
727 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
729 visual = factory.CreateVisual( propertyMap ); // TexMgr::Request load tId:0
731 // Expect that each image is loaded each tick
732 DummyControl dummyControl = DummyControl::New(true);
733 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
734 dummyImpl1.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
737 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
738 application.GetScene().Add( dummyControl );
739 application.SendNotification();
740 application.Render(16);
742 tet_infoline( "Ready the visual after the visual is on window" );
743 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
744 application.SendNotification();
745 application.Render(16);//glGenTextures 1 and 2
746 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 2, TEST_LOCATION );
748 tet_infoline( "Test that each tick, a new image is requested" );
749 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
750 application.SendNotification();
751 application.Render(16);
752 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
753 application.SendNotification();
754 application.Render(16);//glGenTextures 3
755 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
757 tet_infoline( "Test that each tick, a new image is requested" );
758 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:1
759 application.SendNotification();
760 application.Render(16);
761 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
762 application.SendNotification();
763 application.Render(16);//glGenTextures 4
764 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
766 dummyImpl1.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
767 dummyControl.Unparent();
770 // Batch size is 9 and cache size is 4
772 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
773 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
774 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 3);
775 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 7);
776 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
778 visual = factory.CreateVisual( propertyMap ); // TexMgr::Request load tId:0
780 // Expect that each image is loaded each tick
781 dummyControl = DummyControl::New(true);
782 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
783 dummyImpl2.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
786 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
787 application.GetScene().Add( dummyControl );
788 application.SendNotification();
789 application.Render(16);
791 tet_infoline( "Ready the visual after the visual is on window" );
792 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
793 application.SendNotification();
794 application.Render(16);//glGenTextures 1, 2, and 3
795 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
797 tet_infoline( "Test that each tick, a new image is requested" );
798 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
799 application.SendNotification();
800 application.Render(16);
801 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
802 application.SendNotification();
803 application.Render(16);//glGenTextures 4, 5, and 6
804 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 5, TEST_LOCATION );
806 tet_infoline( "Test that each tick, a new image is requested" );
807 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:1
808 application.SendNotification();
809 application.Render(16);
810 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
811 application.SendNotification();
812 application.Render(16);//glGenTextures 7, 1, and 2
813 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 7, TEST_LOCATION );
815 tet_infoline( "Test that each tick, a new image is requested" );
816 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:2
817 application.SendNotification();
818 application.Render(16);
819 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
820 application.SendNotification();
821 application.Render(16);//glGenTextures 3
822 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 7, TEST_LOCATION );
824 dummyControl.Unparent();
826 tet_infoline("Test that removing the visual from window deletes all textures");
827 application.SendNotification();
828 application.Render(16);
829 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
834 int UtcDaliAnimatedImageVisualMultiImage03(void)
836 ToolkitTestApplication application;
837 TestGlAbstraction& gl = application.GetGlAbstraction();
840 Property::Array urls1, urls2;
841 CopyUrlsIntoArray( urls1 );
842 CopyUrlsIntoArray( urls2 );
844 Property::Map animatedImageMap1;
845 animatedImageMap1.Insert(Visual::Property::TYPE, Visual::IMAGE );
846 animatedImageMap1.Insert( ImageVisual::Property::URL, Property::Value(urls1) );
847 animatedImageMap1.Insert( ImageVisual::Property::BATCH_SIZE, 3);
848 animatedImageMap1.Insert( ImageVisual::Property::CACHE_SIZE, 3);
849 animatedImageMap1.Insert( ImageVisual::Property::FRAME_DELAY, 100);
851 Property::Map animatedImageMap2;
852 animatedImageMap2.Insert(Visual::Property::TYPE, Visual::IMAGE );
853 animatedImageMap2.Insert( ImageVisual::Property::URL, Property::Value(urls2) );
854 animatedImageMap2.Insert( ImageVisual::Property::BATCH_SIZE, 2);
855 animatedImageMap2.Insert( ImageVisual::Property::CACHE_SIZE, 2);
856 animatedImageMap2.Insert( ImageVisual::Property::FRAME_DELAY, 100);
858 VisualFactory factory = VisualFactory::Get();
859 Visual::Base animatedImageVisual1 = factory.CreateVisual( animatedImageMap1 );
861 tet_infoline( "Create two image views with the same URLs, offset by 1 frame.");
863 DummyControl dummyControl1 = DummyControl::New(true);
864 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl1.GetImplementation());
865 dummyImpl1.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual1 );
866 dummyControl1.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
867 application.GetScene().Add( dummyControl1 );
869 application.SendNotification();
870 application.Render(16);
872 tet_infoline( "Ready the requested image after the first visual is on stage" );
873 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
874 application.SendNotification();
875 application.Render(16);
876 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
878 Visual::Base animatedImageVisual2 = factory.CreateVisual( animatedImageMap2 );
879 DummyControl dummyControl2 = DummyControl::New(true);
880 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl2.GetImplementation());
881 dummyImpl2.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual2 );
882 dummyControl2.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
883 application.GetScene().Add( dummyControl2 );
884 application.SendNotification();
885 application.Render(16);
887 tet_infoline( "The texture cache should be holding the requested images; check that the renderer has a texture" );
888 TextureSet ts = dummyControl2.GetRendererAt(0).GetTextures();
889 Texture t1 = ts.GetTexture( 0 );
890 DALI_TEST_EQUALS( ts.GetTextureCount(), 1, TEST_LOCATION );
892 tet_infoline( "Test that on the first tick, 1 new image is requested" );
893 Test::EmitGlobalTimerSignal(); // Both visuals should tick
895 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
896 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 3, TEST_LOCATION );
898 ts = dummyControl2.GetRendererAt(0).GetTextures();
899 Texture t2 = ts.GetTexture( 0 );
900 DALI_TEST_CHECK( t1 != t2 );
902 dummyControl1.Unparent();
903 dummyControl2.Unparent();
905 tet_infoline("Test that removing the visual from stage deletes all textures");
906 application.SendNotification();
907 application.Render(16);
908 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
914 int UtcDaliAnimatedImageVisualMultiImage04(void)
916 ToolkitTestApplication application;
917 TestGlAbstraction& gl = application.GetGlAbstraction();
918 TraceCallStack& textureTrace = gl.GetTextureTrace();
919 textureTrace.Enable(true);
921 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" );
923 Property::Array urls;
924 CopyUrlsIntoArray( urls );
927 Property::Map propertyMap;
928 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
929 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
930 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 6);
931 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 11);
932 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
934 VisualFactory factory = VisualFactory::Get();
935 Visual::Base visual = factory.CreateVisual( propertyMap );
937 tet_infoline( "Expect that a batch of 7 textures has been requested." );
939 DummyControl dummyControl = DummyControl::New(true);
940 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
941 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
943 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
944 application.GetScene().Add( dummyControl );
945 application.SendNotification();
946 application.Render(16);
948 tet_infoline( "Wait for the first batch to complete" );
949 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 6 ), true, TEST_LOCATION );
951 tet_infoline( "Test that a timer has been started" );
952 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
954 application.SendNotification();
955 application.Render(16);
957 DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 6, TEST_LOCATION );
958 tet_infoline( "Test that after 1 tick, and 5 file loads completed, that we have 11 textures" );
959 Test::EmitGlobalTimerSignal();
960 application.SendNotification();
961 application.Render(16);
963 // Expect the second batch has been requested
964 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 5 ), true, TEST_LOCATION );
966 application.SendNotification();
967 application.Render(16);
968 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 11, TEST_LOCATION );
970 tet_infoline( "Test that after 2 ticks that we have 11 textures and no requests" );
972 Test::EmitGlobalTimerSignal();
973 application.SendNotification();
974 application.Render(16);
975 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, 5 ), false, TEST_LOCATION );
976 application.SendNotification();
977 application.Render(16);
978 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 11, TEST_LOCATION );
980 tet_infoline( "Test that after 3rd tick that we have 11 textures and no requests" );
981 Test::EmitGlobalTimerSignal();
982 application.SendNotification();
983 application.Render(16);
985 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, 5 ), false, TEST_LOCATION );
986 application.SendNotification();
987 application.Render(16);
988 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 11, TEST_LOCATION );
990 dummyControl.Unparent();
993 tet_infoline("Test that removing the visual from stage deletes all textures");
994 application.SendNotification();
995 application.Render(16);
996 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
1002 int UtcDaliAnimatedImageVisualMultiImage05(void)
1004 ToolkitTestApplication application;
1005 TestGlAbstraction& gl = application.GetGlAbstraction();
1007 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" );
1009 Property::Array urls;
1010 CopyUrlsIntoArray( urls );
1013 Property::Map propertyMap;
1014 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
1015 propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
1016 propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 4);
1017 propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 11);
1018 propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 100);
1020 VisualFactory factory = VisualFactory::Get();
1021 Visual::Base visual = factory.CreateVisual( propertyMap );
1023 tet_infoline( "Expect that a batch of 4 textures has been requested." );
1025 DummyControl dummyControl = DummyControl::New(true);
1026 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1027 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1029 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
1030 application.GetScene().Add( dummyControl );
1031 application.SendNotification();
1032 application.Render(16);
1034 tet_infoline( "Wait for the first batch to complete" );
1035 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
1037 tet_infoline( "Test that a timer has been started" );
1038 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
1040 application.SendNotification();
1041 application.Render(16);
1043 tet_infoline( "Test that a timer has been started" );
1044 Test::EmitGlobalTimerSignal();
1045 application.SendNotification();
1046 application.Render(16);
1048 dummyControl.Unparent();
1051 application.SendNotification();
1052 application.Render(16);
1053 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
1055 tet_infoline( "Test that pending batch of image loads are cancelled instead of uploaded");
1056 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
1057 application.SendNotification();
1058 application.Render(16);
1059 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
1064 void TestLoopCount( ToolkitTestApplication &application, DummyControl &dummyControl, uint16_t frameCount, uint16_t loopCount, const char * location )
1066 TestGlAbstraction& gl = application.GetGlAbstraction();
1067 TraceCallStack& textureTrace = gl.GetTextureTrace();
1069 textureTrace.Enable(true);
1070 application.GetScene().Add( dummyControl );
1072 application.SendNotification();
1073 application.Render(16);
1075 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_INNER_LOCATION( location ) );
1077 application.SendNotification();
1078 application.Render();
1080 tet_infoline( "Test that a timer has been created" );
1081 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_INNER_LOCATION( location ) );
1083 for ( uint16_t i = 0; i < loopCount; i++ )
1085 for ( uint16_t j = 0; j < frameCount; j++ )
1087 if( i == 0 && j == 0 )
1089 continue; // Because first frame is already showed and we call 2nd frame at the first time of timer animation.
1091 tet_printf( "Test that after %u ticks, and we have %u frame \n", j + 1u, j + 1u );
1092 Test::EmitGlobalTimerSignal();
1093 application.SendNotification();
1094 application.Render(16);
1096 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_INNER_LOCATION( location ) );
1098 application.SendNotification();
1099 application.Render();
1100 DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 2, TEST_INNER_LOCATION( location ) );
1101 DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_INNER_LOCATION( location ) );
1103 tet_printf( "Test Loop %u \n\n", i + 1u );
1106 tet_printf( "Test that after %u loops, and we have no frame. Timer should stop \n", loopCount );
1107 Test::EmitGlobalTimerSignal();
1108 application.SendNotification();
1109 application.Render(16);
1110 DALI_TEST_EQUALS( Test::AreTimersRunning(), false, TEST_INNER_LOCATION( location ) );
1112 dummyControl.Unparent();
1115 int UtcDaliAnimatedImageVisualLoopCount(void)
1117 ToolkitTestApplication application;
1119 tet_infoline( "UtcDaliAnimatedImageVisualLoopCount" );
1122 // request AnimatedImageVisual with a property map
1123 // Test with no (0) loop count
1124 VisualFactory factory = VisualFactory::Get();
1125 Visual::Base animatedImageVisual = factory.CreateVisual(
1127 .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
1128 .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
1129 .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
1130 .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
1131 .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
1132 .Add( DevelImageVisual::Property::LOOP_COUNT, 0 ));
1134 DummyControl dummyControl = DummyControl::New(true);
1135 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1136 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual );
1137 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
1139 TestLoopCount( application, dummyControl, 4, 0, TEST_LOCATION );
1141 dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
1142 animatedImageVisual.Reset();
1144 application.SendNotification();
1145 application.Render(16);
1147 // Test with no (1) loop count. Request AnimatedImageVisual with a property map
1148 animatedImageVisual = factory.CreateVisual(
1150 .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
1151 .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
1152 .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
1153 .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
1154 .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
1155 .Add( DevelImageVisual::Property::LOOP_COUNT, 1 ));
1157 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual );
1159 TestLoopCount( application, dummyControl, 4, 1, TEST_LOCATION );
1161 dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
1162 animatedImageVisual.Reset();
1164 application.SendNotification();
1165 application.Render(16);
1167 // Test with no (100) loop count. Request AnimatedImageVisual with a property map
1168 animatedImageVisual = factory.CreateVisual(
1170 .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
1171 .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
1172 .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
1173 .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
1174 .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
1175 .Add( DevelImageVisual::Property::LOOP_COUNT, 100 ));
1177 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual );
1179 TestLoopCount( application, dummyControl, 4, 100, TEST_LOCATION );
1184 int UtcDaliAnimatedImageVisualPlayback(void)
1186 ToolkitTestApplication application;
1187 TestGlAbstraction& gl = application.GetGlAbstraction();
1188 TraceCallStack& textureTrace = gl.GetTextureTrace();
1190 tet_infoline( "UtcDaliAnimatedImageVisualPlayback" );
1193 // request AnimatedImageVisual with a property map
1194 // Test with forever (-1) loop count
1195 VisualFactory factory = VisualFactory::Get();
1196 Visual::Base animatedImageVisual = factory.CreateVisual(
1198 .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
1199 .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
1200 .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
1201 .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
1202 .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
1203 .Add( DevelImageVisual::Property::LOOP_COUNT, -1 ));
1205 DummyControl dummyControl = DummyControl::New(true);
1206 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1207 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual );
1208 dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
1210 textureTrace.Enable(true);
1211 application.GetScene().Add( dummyControl );
1212 application.SendNotification();
1213 application.Render(16);
1215 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
1217 application.SendNotification();
1218 application.Render();
1220 tet_infoline( "Test that a timer has been created" );
1221 DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
1223 Test::EmitGlobalTimerSignal();
1224 application.SendNotification();
1225 application.Render(16);
1227 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1229 application.SendNotification();
1230 application.Render();
1231 DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_LOCATION );
1233 Property::Map attributes;
1234 tet_infoline( "Test Pause action. Timer should stop after Pause action" );
1235 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PAUSE, attributes );
1236 Test::EmitGlobalTimerSignal();
1237 application.SendNotification();
1238 application.Render(16);
1239 DALI_TEST_EQUALS( Test::AreTimersRunning(), false, TEST_LOCATION );
1241 tet_infoline( "Test Play action. Timer should Restart after Play action" );
1242 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes );
1243 Test::EmitGlobalTimerSignal();
1244 application.SendNotification();
1245 application.Render(16);
1247 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1249 application.SendNotification();
1250 application.Render();
1251 DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_LOCATION );
1253 tet_infoline( "Test Stop action. Timer should stop after Stop action" );
1254 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, attributes );
1255 Test::EmitGlobalTimerSignal();
1256 application.SendNotification();
1257 application.Render(16);
1258 DALI_TEST_EQUALS( Test::AreTimersRunning(), false, TEST_LOCATION );
1260 tet_infoline( "Test Play action. Timer should Restart after Play action" );
1261 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes );
1262 Test::EmitGlobalTimerSignal();
1263 application.SendNotification();
1264 application.Render(16);
1266 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1268 application.SendNotification();
1269 application.Render();
1270 DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_LOCATION );
1272 dummyControl.Unparent();