2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <dali-toolkit-test-suite-utils.h>
22 #include <toolkit-event-thread-callback.h>
23 #include <toolkit-timer.h>
25 #include <dali-toolkit/dali-toolkit.h>
26 #include <dali-toolkit/devel-api/controls/control-devel.h>
27 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
28 #include <dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h>
29 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
30 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
32 #include "dummy-control.h"
35 using namespace Dali::Toolkit;
37 void dali_animated_image_visual_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_animated_image_visual_cleanup(void)
44 test_return_value = TET_PASS;
49 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/application-icon-%02d.png";
50 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
51 const char* TEST_MASK_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/mask.png";
54 void CopyUrlsIntoArray(Property::Array& urls, int startIndex = 0)
56 for(int i = 20 + startIndex; i <= 30; ++i)
59 if(asprintf(&url, TEST_IMAGE_FILE_NAME, i) > 0)
61 Property::Value value(url);
68 int UtcDaliAnimatedImageVisualGetPropertyMap01(void)
70 ToolkitTestApplication application;
71 tet_infoline("UtcDaliAnimatedImageVisualGetPropertyMap");
73 // request AnimatedImageVisual with a property map
74 VisualFactory factory = VisualFactory::Get();
75 Visual::Base animatedImageVisual = factory.CreateVisual(
77 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
78 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
79 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
80 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
81 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
82 .Add(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME)
83 .Add(ImageVisual::Property::MASK_CONTENT_SCALE, 1.6f)
84 .Add(ImageVisual::Property::CROP_TO_MASK, true)
85 .Add(DevelVisual::Property::CORNER_RADIUS, 22.2f)
86 .Add(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE)
87 .Add(DevelVisual::Property::BORDERLINE_WIDTH, 33.3f)
88 .Add(DevelVisual::Property::BORDERLINE_COLOR, Color::RED)
89 .Add(DevelVisual::Property::BORDERLINE_OFFSET, 0.3f));
91 Property::Map resultMap;
92 animatedImageVisual.CreatePropertyMap(resultMap);
93 // check the property values from the returned map from a visual
94 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
95 DALI_TEST_CHECK(value);
96 DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
98 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
99 DALI_TEST_CHECK(value);
100 DALI_TEST_CHECK(value->Get<std::string>() == TEST_GIF_FILE_NAME);
102 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
103 DALI_TEST_CHECK(value);
104 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(22.2f, 22.2f, 22.2f, 22.2f), TEST_LOCATION);
106 value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, Property::INTEGER);
107 DALI_TEST_CHECK(value);
108 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
110 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT);
111 DALI_TEST_CHECK(value);
112 DALI_TEST_EQUALS(value->Get<float>(), 33.3f, TEST_LOCATION);
114 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
115 DALI_TEST_CHECK(value);
116 DALI_TEST_EQUALS(value->Get<Vector4>(), Color::RED, TEST_LOCATION);
118 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
119 DALI_TEST_CHECK(value);
120 DALI_TEST_EQUALS(value->Get<float>(), 0.3f, TEST_LOCATION);
122 // Check mask properties
123 value = resultMap.Find(ImageVisual::Property::ALPHA_MASK_URL, Property::STRING);
124 DALI_TEST_CHECK(value);
125 DALI_TEST_CHECK(value->Get<std::string>() == TEST_MASK_IMAGE_FILE_NAME);
127 value = resultMap.Find(ImageVisual::Property::MASK_CONTENT_SCALE, Property::FLOAT);
128 DALI_TEST_CHECK(value);
129 DALI_TEST_EQUALS(value->Get<float>(), 1.6f, TEST_LOCATION);
131 value = resultMap.Find(ImageVisual::Property::CROP_TO_MASK, Property::BOOLEAN);
132 DALI_TEST_CHECK(value);
133 DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
136 animatedImageVisual.GetNaturalSize(naturalSize);
137 DALI_TEST_EQUALS(naturalSize, Vector2(100, 100), TEST_LOCATION);
139 // request AnimatedImageVisual with an URL
140 Visual::Base animatedImageVisual2 = factory.CreateVisual(TEST_GIF_FILE_NAME, ImageDimensions());
142 animatedImageVisual2.CreatePropertyMap(resultMap);
143 // check the property values from the returned map from a visual
144 value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
145 DALI_TEST_CHECK(value);
146 DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
148 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
149 DALI_TEST_CHECK(value);
150 DALI_TEST_CHECK(value->Get<std::string>() == TEST_GIF_FILE_NAME);
155 int UtcDaliAnimatedImageVisualGetPropertyMap02(void)
157 ToolkitTestApplication application;
158 tet_infoline("UtcDaliAnimatedImageVisualGetPropertyMap for multi image with fixed cache");
160 // request AnimatedImageVisual with a property map
161 VisualFactory factory = VisualFactory::Get();
162 Property::Array urls;
163 CopyUrlsIntoArray(urls);
165 Visual::Base animatedImageVisual = factory.CreateVisual(
167 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
170 .Add("cacheSize", 20)
171 .Add("loopCount", 10)
172 .Add("frameDelay", 200)
173 .Add("pixelArea", Vector4())
174 .Add("wrapModeU", WrapMode::REPEAT)
175 .Add("wrapModeV", WrapMode::DEFAULT)
176 .Add("alphaMaskUrl", TEST_MASK_IMAGE_FILE_NAME)
177 .Add("maskContentScale", 1.6f)
178 .Add("cropToMask", true)
179 .Add("cornerRadius", Vector4(50.0f, 25.0f, 12.5f, 33.0f))
180 .Add("cornerRadiusPolicy", Visual::Transform::Policy::RELATIVE)
181 .Add("borderlineWidth", 20.0f)
182 .Add("borderlineColor", Vector4())
183 .Add("borderlineOffset", -1.0f));
185 Property::Map resultMap;
186 animatedImageVisual.CreatePropertyMap(resultMap);
187 // check the property values from the returned map from a visual
188 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
189 DALI_TEST_CHECK(value);
190 DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
192 value = resultMap.Find(ImageVisual::Property::URL, "url");
193 DALI_TEST_CHECK(value);
194 Property::Array* resultUrls = value->GetArray();
195 DALI_TEST_CHECK(resultUrls);
196 DALI_TEST_EQUALS(resultUrls->Count(), urls.Count(), TEST_LOCATION);
198 value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, "batchSize");
199 DALI_TEST_CHECK(value);
200 DALI_TEST_EQUALS(value->Get<int>(), 4, TEST_LOCATION);
202 value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, "cacheSize");
203 DALI_TEST_CHECK(value);
204 DALI_TEST_EQUALS(value->Get<int>(), 20, TEST_LOCATION);
206 value = resultMap.Find(Toolkit::DevelImageVisual::Property::LOOP_COUNT, "loopCount");
207 DALI_TEST_CHECK(value);
208 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
210 value = resultMap.Find(ImageVisual::Property::FRAME_DELAY, "frameDelay");
211 DALI_TEST_CHECK(value);
212 DALI_TEST_EQUALS(value->Get<int>(), 200, TEST_LOCATION);
214 value = resultMap.Find(Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber");
215 DALI_TEST_CHECK(value);
216 DALI_TEST_EQUALS(value->Get<int>(), 11, TEST_LOCATION);
218 value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS, "cornerRadius");
219 DALI_TEST_CHECK(value);
220 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(50.0f, 25.0f, 12.5f, 33.0f), TEST_LOCATION);
222 value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
223 DALI_TEST_CHECK(value);
224 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::RELATIVE);
226 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
227 DALI_TEST_CHECK(value);
228 DALI_TEST_EQUALS(value->Get<float>(), 20.0f, TEST_LOCATION);
230 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, "borderlineColor");
231 DALI_TEST_CHECK(value);
232 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4::ZERO, TEST_LOCATION);
234 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, "borderlineOffset");
235 DALI_TEST_CHECK(value);
236 DALI_TEST_EQUALS(value->Get<float>(), -1.0f, TEST_LOCATION);
238 // Check mask properties
239 value = resultMap.Find(ImageVisual::Property::ALPHA_MASK_URL, "alphaMaskUrl");
240 DALI_TEST_CHECK(value);
241 DALI_TEST_CHECK(value->Get<std::string>() == TEST_MASK_IMAGE_FILE_NAME);
243 value = resultMap.Find(ImageVisual::Property::MASK_CONTENT_SCALE, "maskContentScale");
244 DALI_TEST_CHECK(value);
245 DALI_TEST_EQUALS(value->Get<float>(), 1.6f, TEST_LOCATION);
247 value = resultMap.Find(ImageVisual::Property::CROP_TO_MASK, "cropToMask");
248 DALI_TEST_CHECK(value);
249 DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
254 int UtcDaliAnimatedImageVisualGetPropertyMap03(void)
256 ToolkitTestApplication application;
257 tet_infoline("UtcDaliAnimatedImageVisualGetPropertyMap for multi image rolling cache");
259 // request AnimatedImageVisual with a property map
260 VisualFactory factory = VisualFactory::Get();
261 Property::Array urls;
262 CopyUrlsIntoArray(urls);
264 Visual::Base animatedImageVisual = factory.CreateVisual(
266 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
270 .Add("loopCount", 10)
271 .Add("frameDelay", 200)
272 .Add("pixelArea", Vector4())
273 .Add("wrapModeU", WrapMode::REPEAT)
274 .Add("wrapModeV", WrapMode::DEFAULT)
275 .Add("alphaMaskUrl", TEST_MASK_IMAGE_FILE_NAME)
276 .Add("maskContentScale", 1.6f)
277 .Add("cropToMask", true)
278 .Add("cornerRadius", 50.5f));
280 Property::Map resultMap;
281 animatedImageVisual.CreatePropertyMap(resultMap);
282 // check the property values from the returned map from a visual
283 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
284 DALI_TEST_CHECK(value);
285 DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
287 value = resultMap.Find(ImageVisual::Property::URL, "url");
288 DALI_TEST_CHECK(value);
289 Property::Array* resultUrls = value->GetArray();
290 DALI_TEST_CHECK(resultUrls);
291 DALI_TEST_EQUALS(resultUrls->Count(), urls.Count(), TEST_LOCATION);
293 value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, "batchSize");
294 DALI_TEST_CHECK(value);
295 DALI_TEST_EQUALS(value->Get<int>(), 4, TEST_LOCATION);
297 value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, "cacheSize");
298 DALI_TEST_CHECK(value);
299 DALI_TEST_EQUALS(value->Get<int>(), 8, TEST_LOCATION);
301 value = resultMap.Find(Toolkit::DevelImageVisual::Property::LOOP_COUNT, "loopCount");
302 DALI_TEST_CHECK(value);
303 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
305 value = resultMap.Find(ImageVisual::Property::FRAME_DELAY, "frameDelay");
306 DALI_TEST_CHECK(value);
307 DALI_TEST_EQUALS(value->Get<int>(), 200, TEST_LOCATION);
309 value = resultMap.Find(Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber");
310 DALI_TEST_CHECK(value);
311 DALI_TEST_EQUALS(value->Get<int>(), 11, TEST_LOCATION);
313 value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS, "cornerRadius");
314 DALI_TEST_CHECK(value);
315 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(50.5f, 50.5f, 50.5f, 50.5f), TEST_LOCATION);
317 value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
318 DALI_TEST_CHECK(value);
319 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
321 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
322 DALI_TEST_CHECK(value);
323 DALI_TEST_EQUALS(value->Get<float>(), 0.0f, TEST_LOCATION);
325 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, "borderlineColor");
326 DALI_TEST_CHECK(value);
327 DALI_TEST_EQUALS(value->Get<Vector4>(), Color::BLACK, TEST_LOCATION);
329 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, "borderlineOffset");
330 DALI_TEST_CHECK(value);
331 DALI_TEST_EQUALS(value->Get<float>(), 0.0f, TEST_LOCATION);
333 // Check mask properties
334 value = resultMap.Find(ImageVisual::Property::ALPHA_MASK_URL, "alphaMaskUrl");
335 DALI_TEST_CHECK(value);
336 DALI_TEST_CHECK(value->Get<std::string>() == TEST_MASK_IMAGE_FILE_NAME);
338 value = resultMap.Find(ImageVisual::Property::MASK_CONTENT_SCALE, "maskContentScale");
339 DALI_TEST_CHECK(value);
340 DALI_TEST_EQUALS(value->Get<float>(), 1.6f, TEST_LOCATION);
342 value = resultMap.Find(ImageVisual::Property::CROP_TO_MASK, "cropToMask");
343 DALI_TEST_CHECK(value);
344 DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
349 int UtcDaliAnimatedImageVisualGetPropertyMap04(void)
351 ToolkitTestApplication application;
352 tet_infoline("UtcDaliAnimatedImageVisualGetPropertyMap");
354 // request AnimatedImageVisual with a property map
355 VisualFactory factory = VisualFactory::Get();
356 Visual::Base animatedImageVisual = factory.CreateVisual(
358 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
359 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
360 .Add(ImageVisual::Property::BATCH_SIZE, 1)
361 .Add(ImageVisual::Property::CACHE_SIZE, 1)
362 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, true)
363 .Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DETACHED)
364 .Add(ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::ATTACHED)
365 .Add(DevelVisual::Property::BORDERLINE_WIDTH, 0.4f));
367 Property::Map resultMap;
368 animatedImageVisual.CreatePropertyMap(resultMap);
370 // check the property values from the returned map from a visual
371 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
372 DALI_TEST_CHECK(value);
373 DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
375 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
376 DALI_TEST_CHECK(value);
377 DALI_TEST_CHECK(value->Get<std::string>() == TEST_GIF_FILE_NAME);
379 value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, Property::INTEGER);
380 DALI_TEST_CHECK(value);
381 DALI_TEST_CHECK(value->Get<int>() == 2);
383 value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, Property::INTEGER);
384 DALI_TEST_CHECK(value);
385 DALI_TEST_CHECK(value->Get<int>() == 2);
387 value = resultMap.Find(ImageVisual::Property::SYNCHRONOUS_LOADING, Property::BOOLEAN);
388 DALI_TEST_CHECK(value);
389 DALI_TEST_CHECK(value->Get<bool>() == true);
391 value = resultMap.Find(ImageVisual::Property::RELEASE_POLICY, Property::INTEGER);
392 DALI_TEST_CHECK(value);
393 DALI_TEST_CHECK(value->Get<int>() == ImageVisual::ReleasePolicy::DETACHED);
395 value = resultMap.Find(ImageVisual::Property::LOAD_POLICY, Property::INTEGER);
396 DALI_TEST_CHECK(value);
397 DALI_TEST_CHECK(value->Get<int>() == ImageVisual::LoadPolicy::ATTACHED);
399 value = resultMap.Find(Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber");
400 DALI_TEST_CHECK(value);
401 DALI_TEST_EQUALS(value->Get<int>(), 4, TEST_LOCATION);
403 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
404 DALI_TEST_CHECK(value);
405 DALI_TEST_EQUALS(value->Get<float>(), 0.4f, TEST_LOCATION);
407 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, "borderlineColor");
408 DALI_TEST_CHECK(value);
409 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(0.0f, 0.0f, 0.0f, 1.0f), TEST_LOCATION);
411 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, "borderlineOffset");
412 DALI_TEST_CHECK(value);
413 DALI_TEST_EQUALS(value->Get<float>(), 0.0f, TEST_LOCATION);
418 int UtcDaliAnimatedImageVisualImageLoadingFail01(void)
420 ToolkitTestApplication application;
421 TestGlAbstraction& gl = application.GetGlAbstraction();
424 Property::Map propertyMap;
425 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
426 propertyMap.Insert(ImageVisual::Property::URL, "dummy.gif");
427 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
428 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
429 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
430 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
431 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
432 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
434 VisualFactory factory = VisualFactory::Get();
435 Visual::Base visual = factory.CreateVisual(propertyMap);
437 DummyControl dummyControl = DummyControl::New(true);
438 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
439 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
441 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
442 application.GetScene().Add(dummyControl);
444 TraceCallStack& textureTrace = gl.GetTextureTrace();
445 textureTrace.Enable(true);
447 application.SendNotification();
448 application.Render(20);
450 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 1, TEST_LOCATION);
452 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 6);
454 application.SendNotification();
455 application.Render(20);
457 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 1, TEST_LOCATION);
459 dummyControl.Unparent();
465 int UtcDaliAnimatedImageVisualSynchronousLoading(void)
467 ToolkitTestApplication application;
468 TestGlAbstraction& gl = application.GetGlAbstraction();
471 Property::Map propertyMap;
472 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
473 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
474 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
475 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
476 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
477 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
478 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
479 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
481 VisualFactory factory = VisualFactory::Get();
482 Visual::Base visual = factory.CreateVisual(propertyMap);
484 DummyControl dummyControl = DummyControl::New(true);
485 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
486 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
488 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
489 application.GetScene().Add(dummyControl);
491 TraceCallStack& textureTrace = gl.GetTextureTrace();
492 textureTrace.Enable(true);
494 application.SendNotification();
495 application.Render(20);
497 // The first frame is loaded synchronously and load next batch.
498 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
500 application.SendNotification();
501 application.Render();
503 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
504 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
506 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 3);
508 application.SendNotification();
509 application.Render(20);
511 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
513 application.SendNotification();
514 application.Render();
516 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
518 dummyControl.Unparent();
520 tet_infoline("Test that removing the visual from stage deletes all textures");
521 application.SendNotification();
522 application.Render(16);
523 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
528 int UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask(void)
530 ToolkitTestApplication application;
531 TestGlAbstraction& gl = application.GetGlAbstraction();
534 Property::Map propertyMap;
535 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
536 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
537 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
538 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
539 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
540 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
541 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
542 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
543 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
545 VisualFactory factory = VisualFactory::Get();
546 Visual::Base visual = factory.CreateVisual(propertyMap);
548 Property::Map testMap;
549 visual.CreatePropertyMap(testMap);
550 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
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 TraceCallStack& textureTrace = gl.GetTextureTrace();
560 textureTrace.Enable(true);
562 application.SendNotification();
563 application.Render(20);
565 // The first frame is loaded synchronously and load next batch with masking
566 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
568 application.SendNotification();
569 application.Render();
571 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
572 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
574 dummyControl.Unparent();
576 tet_infoline("Test that removing the visual from stage deletes all textures");
577 application.SendNotification();
578 application.Render(16);
579 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
584 int UtcDaliAnimatedImageVisualJumpToAction(void)
586 ToolkitTestApplication application;
587 TestGlAbstraction& gl = application.GetGlAbstraction();
589 Property::Array urls;
590 CopyUrlsIntoArray(urls);
593 Property::Map propertyMap;
594 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
595 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
596 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
597 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 12);
598 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
600 VisualFactory factory = VisualFactory::Get();
601 Visual::Base visual = factory.CreateVisual(propertyMap);
603 DummyControl dummyControl = DummyControl::New(true);
604 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
605 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
607 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
608 application.GetScene().Add(dummyControl);
609 application.SendNotification();
610 application.Render(20);
612 tet_infoline("Ready the visual after the visual is on stage");
613 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
615 tet_infoline("Test that a timer has been started");
616 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
618 TraceCallStack& textureTrace = gl.GetTextureTrace();
619 textureTrace.Enable(true);
621 application.SendNotification();
622 application.Render(20);
624 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
626 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map());
628 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
630 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 20);
632 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
634 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 6);
636 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(6), true, TEST_LOCATION);
637 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
639 dummyControl.Unparent();
641 tet_infoline("Test that removing the visual from stage deletes all textures");
642 application.SendNotification();
643 application.Render(16);
644 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
649 int UtcDaliAnimatedImageVisualStopBehavior(void)
651 ToolkitTestApplication application;
652 TestGlAbstraction& gl = application.GetGlAbstraction();
654 Property::Array urls;
655 CopyUrlsIntoArray(urls);
658 Property::Map propertyMap;
659 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
660 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
661 propertyMap.Insert(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
662 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
663 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 8);
664 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
666 VisualFactory factory = VisualFactory::Get();
667 Visual::Base visual = factory.CreateVisual(propertyMap);
669 // Expect that a batch of 4 textures has been requested. These will be serially loaded
672 DummyControl dummyControl = DummyControl::New(true);
673 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
674 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
676 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
677 application.GetScene().Add(dummyControl);
678 application.SendNotification();
679 application.Render(20);
681 tet_infoline("Ready the visual after the visual is on stage");
682 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
684 tet_infoline("Test that a timer has been started");
685 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
687 TraceCallStack& textureTrace = gl.GetTextureTrace();
688 textureTrace.Enable(true);
690 application.SendNotification();
691 application.Render(20);
693 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
695 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map());
697 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
699 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 1);
701 // Expect the second batch has been requested
702 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
704 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
706 dummyControl.Unparent();
708 tet_infoline("Test that removing the visual from stage deletes all textures");
709 application.SendNotification();
710 application.Render(16);
711 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
716 int UtcDaliAnimatedImageVisualStopBehavior02(void)
718 ToolkitTestApplication application;
719 TestGlAbstraction& gl = application.GetGlAbstraction();
721 Property::Array urls;
722 CopyUrlsIntoArray(urls);
725 Property::Map propertyMap;
726 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
727 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
728 propertyMap.Insert(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
729 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
730 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
731 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
733 VisualFactory factory = VisualFactory::Get();
734 Visual::Base visual = factory.CreateVisual(propertyMap);
736 // Expect that a batch of 4 textures has been requested. These will be serially loaded
739 DummyControl dummyControl = DummyControl::New(true);
740 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
741 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
743 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
744 application.GetScene().Add(dummyControl);
746 tet_infoline("Ready the visual after the visual is on stage");
747 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
749 TraceCallStack& textureTrace = gl.GetTextureTrace();
750 textureTrace.Enable(true);
752 application.SendNotification();
753 application.Render(20);
755 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 2, TEST_LOCATION);
757 Test::EmitGlobalTimerSignal();
759 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
761 application.SendNotification();
762 application.Render(20);
764 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
766 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map());
768 tet_infoline("Ready the visual after the visual is on stage");
769 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
771 application.SendNotification();
772 application.Render(20);
774 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
776 dummyControl.Unparent();
778 tet_infoline("Test that removing the visual from stage deletes all textures");
779 application.SendNotification();
780 application.Render(16);
781 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
786 int UtcDaliAnimatedImageVisualAnimatedImage01(void)
788 ToolkitTestApplication application;
789 TestGlAbstraction& gl = application.GetGlAbstraction();
791 tet_infoline("Set cache size same as GIF frame, and try to load same image at another ImageView");
793 Property::Map propertyMap;
794 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
795 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
796 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
797 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 4);
798 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
800 VisualFactory factory = VisualFactory::Get();
801 Visual::Base visual = factory.CreateVisual(propertyMap);
803 // Expect that a batch of 4 textures has been requested. These will be serially loaded
806 DummyControl dummyControl = DummyControl::New(true);
807 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
808 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
810 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
811 application.GetScene().Add(dummyControl);
813 application.SendNotification();
814 application.Render();
816 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
818 // Batch 2 frames. Now frame 0, 1 cached.
819 application.SendNotification();
820 application.Render(20);
822 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 2, TEST_LOCATION);
824 tet_infoline("Test that a timer has been started");
826 TraceCallStack& textureTrace = gl.GetTextureTrace();
827 textureTrace.Enable(true);
829 Test::EmitGlobalTimerSignal();
831 application.SendNotification();
832 application.Render();
834 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
836 // 0 frame removed. and after, batch 2 frames. Now frame 1, 2, 3 cached.
837 application.SendNotification();
838 application.Render(20);
840 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
842 Visual::Base visual2 = factory.CreateVisual(propertyMap);
843 DummyControl dummyControl2 = DummyControl::New(true);
844 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl2.GetImplementation());
845 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
846 application.GetScene().Add(dummyControl2);
848 tet_infoline("Add new view with same url");
850 application.SendNotification();
851 application.Render();
853 // Note that we only re-load 0 frame.
854 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
856 tet_infoline("Test that we don't try to re-load new image cause it cached");
857 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
859 // Batch 2 frames. Now visual frame 1, 2, 3 cached and visual2 frame 0, 1 cached.
860 application.SendNotification();
861 application.Render(20);
863 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 5, TEST_LOCATION);
865 textureTrace.Reset();
867 tet_infoline("Load some many frames");
869 const int repeatCount = 10;
870 for(int repeat = 0; repeat < repeatCount; ++repeat)
872 Test::EmitGlobalTimerSignal();
873 application.SendNotification();
874 application.Render(2000);
877 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // A new texture should NOT be generated.
878 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 5, TEST_LOCATION);
880 textureTrace.Reset();
882 dummyControl.Unparent();
883 dummyControl2.Unparent();
885 tet_infoline("Test that removing the visual from stage deletes all textures");
886 application.SendNotification();
887 application.Render(20);
888 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
893 int UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask01(void)
895 ToolkitTestApplication application;
896 TestGlAbstraction& gl = application.GetGlAbstraction();
899 Property::Map propertyMap;
900 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
901 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
902 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
903 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 4);
904 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
905 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
907 VisualFactory factory = VisualFactory::Get();
908 Visual::Base visual = factory.CreateVisual(propertyMap);
910 DummyControl dummyControl = DummyControl::New(true);
911 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
912 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
914 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
915 application.GetScene().Add(dummyControl);
917 application.SendNotification();
918 application.Render();
920 // load two frame(batch size), load mask image, and request two masking
921 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(5), true, TEST_LOCATION);
923 application.SendNotification();
924 application.Render(20);
926 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 2, TEST_LOCATION);
928 dummyControl.Unparent();
930 tet_infoline("Test that removing the visual from stage deletes all textures");
931 application.SendNotification();
932 application.Render(20);
933 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
938 int UtcDaliAnimatedImageVisualMultiImage01(void)
940 ToolkitTestApplication application;
941 TestGlAbstraction& gl = application.GetGlAbstraction();
943 Property::Array urls;
944 CopyUrlsIntoArray(urls);
947 Property::Map propertyMap;
948 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
949 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
950 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
951 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 8);
952 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
954 VisualFactory factory = VisualFactory::Get();
955 Visual::Base visual = factory.CreateVisual(propertyMap);
957 // Expect that a batch of 4 textures has been requested. These will be serially loaded
960 DummyControl dummyControl = DummyControl::New(true);
961 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
962 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
964 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
965 application.GetScene().Add(dummyControl);
966 application.SendNotification();
967 application.Render(16);
969 tet_infoline("Ready the visual after the visual is on stage");
970 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
972 tet_infoline("Test that a timer has been started");
973 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
975 TraceCallStack& textureTrace = gl.GetTextureTrace();
976 textureTrace.Enable(true);
978 application.SendNotification();
979 application.Render(16);
981 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
982 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
984 tet_infoline("Test that after 1 tick, and file loads completed, that we have 7 textures");
985 Test::EmitGlobalTimerSignal();
987 // Expect the second batch has been requested
988 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
990 application.SendNotification();
991 application.Render(16);
992 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
994 tet_infoline("Test that after 2 ticks that we have 6 textures");
996 Test::EmitGlobalTimerSignal();
997 application.SendNotification();
998 application.Render(16);
999 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 6, TEST_LOCATION);
1001 tet_infoline("And that at least 2 textures were requested");
1002 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1003 application.SendNotification();
1004 application.Render(16);
1005 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 8, TEST_LOCATION);
1007 tet_infoline("Test that after 3rd tick that we have 7 textures and 1 request");
1008 Test::EmitGlobalTimerSignal();
1009 application.SendNotification();
1010 application.Render(16);
1011 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
1013 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1014 application.SendNotification();
1015 application.Render(16);
1016 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 8, TEST_LOCATION);
1018 dummyControl.Unparent();
1020 tet_infoline("Test that removing the visual from stage deletes all textures");
1021 application.SendNotification();
1022 application.Render(16);
1023 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1028 int UtcDaliAnimatedImageVisualMultiImage02(void)
1030 ToolkitTestApplication application;
1031 TestGlAbstraction& gl = application.GetGlAbstraction();
1033 tet_infoline("Test that the animated visual has different batch and cache size.");
1036 Property::Array urls;
1037 CopyUrlsIntoArray(urls);
1039 Property::Map propertyMap;
1040 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1041 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1042 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 0);
1043 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 0);
1044 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1046 VisualFactory factory = VisualFactory::Get();
1047 Visual::Base visual = factory.CreateVisual(propertyMap); // TexMgr::Request load tId:0
1049 // Check the batch size and cache size need to have minimum 2.
1050 Property::Map resultMap;
1051 visual.CreatePropertyMap(resultMap);
1052 Property::Value* value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, "batchSize");
1053 DALI_TEST_CHECK(value);
1054 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1055 value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, "cacheSize");
1056 DALI_TEST_CHECK(value);
1057 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1060 // Batch size is 2 and cache size is 3
1061 propertyMap.Clear();
1062 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1063 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1064 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
1065 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 3);
1066 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1068 visual = factory.CreateVisual(propertyMap); // TexMgr::Request load tId:0
1070 // Expect that each image is loaded each tick
1071 DummyControl dummyControl = DummyControl::New(true);
1072 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1073 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1076 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1077 application.GetScene().Add(dummyControl);
1078 application.SendNotification();
1079 application.Render(16);
1081 tet_infoline("Ready the visual after the visual is on window");
1082 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1083 application.SendNotification();
1084 application.Render(16); //glGenTextures 1 and 2
1085 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
1087 tet_infoline("Test that each tick, a new image is requested");
1088 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
1089 application.SendNotification();
1090 application.Render(16);
1091 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1092 application.SendNotification();
1093 application.Render(16); //glGenTextures 3
1094 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1096 tet_infoline("Test that each tick, a new image is requested");
1097 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:1
1098 application.SendNotification();
1099 application.Render(16);
1100 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1101 application.SendNotification();
1102 application.Render(16); //glGenTextures 4
1103 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1105 dummyImpl1.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1106 dummyControl.Unparent();
1108 // Batch size is 9 and cache size is 4
1109 propertyMap.Clear();
1110 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1111 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1112 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 3);
1113 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 7);
1114 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1116 visual = factory.CreateVisual(propertyMap); // TexMgr::Request load tId:0
1118 // Expect that each image is loaded each tick
1119 dummyControl = DummyControl::New(true);
1120 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1121 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1124 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1125 application.GetScene().Add(dummyControl);
1126 application.SendNotification();
1127 application.Render(16);
1129 tet_infoline("Ready the visual after the visual is on window");
1130 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1131 application.SendNotification();
1132 application.Render(16); //glGenTextures 1, 2, and 3
1133 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1135 tet_infoline("Test that each tick, a new image is requested");
1136 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
1137 application.SendNotification();
1138 application.Render(16);
1139 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1140 application.SendNotification();
1141 application.Render(16); //glGenTextures 4, 5, and 6
1142 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 5, TEST_LOCATION);
1144 tet_infoline("Test that each tick, a new image is requested");
1145 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:1
1146 application.SendNotification();
1147 application.Render(16);
1148 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1149 application.SendNotification();
1150 application.Render(16); //glGenTextures 7, 1, and 2
1151 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
1153 tet_infoline("Test that each tick, a new image is requested");
1154 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:2
1155 application.SendNotification();
1156 application.Render(16);
1157 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1158 application.SendNotification();
1159 application.Render(16); //glGenTextures 3
1160 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
1162 dummyControl.Unparent();
1164 tet_infoline("Test that removing the visual from window deletes all textures");
1165 application.SendNotification();
1166 application.Render(16);
1167 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1172 int UtcDaliAnimatedImageVisualMultiImage03(void)
1174 ToolkitTestApplication application;
1175 TestGlAbstraction& gl = application.GetGlAbstraction();
1178 Property::Array urls1, urls2;
1179 CopyUrlsIntoArray(urls1);
1180 CopyUrlsIntoArray(urls2);
1182 Property::Map animatedImageMap1;
1183 animatedImageMap1.Insert(Visual::Property::TYPE, Visual::IMAGE);
1184 animatedImageMap1.Insert(ImageVisual::Property::URL, Property::Value(urls1));
1185 animatedImageMap1.Insert(ImageVisual::Property::BATCH_SIZE, 3);
1186 animatedImageMap1.Insert(ImageVisual::Property::CACHE_SIZE, 3);
1187 animatedImageMap1.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1189 Property::Map animatedImageMap2;
1190 animatedImageMap2.Insert(Visual::Property::TYPE, Visual::IMAGE);
1191 animatedImageMap2.Insert(ImageVisual::Property::URL, Property::Value(urls2));
1192 animatedImageMap2.Insert(ImageVisual::Property::BATCH_SIZE, 2);
1193 animatedImageMap2.Insert(ImageVisual::Property::CACHE_SIZE, 2);
1194 animatedImageMap2.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1196 VisualFactory factory = VisualFactory::Get();
1197 Visual::Base animatedImageVisual1 = factory.CreateVisual(animatedImageMap1);
1199 tet_infoline("Create two image views with the same URLs, offset by 1 frame.");
1201 DummyControl dummyControl1 = DummyControl::New(true);
1202 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl1.GetImplementation());
1203 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual1);
1204 dummyControl1.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1205 application.GetScene().Add(dummyControl1);
1207 application.SendNotification();
1208 application.Render(16);
1210 tet_infoline("Ready the requested image after the first visual is on stage");
1211 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1212 application.SendNotification();
1213 application.Render(16);
1214 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1216 Visual::Base animatedImageVisual2 = factory.CreateVisual(animatedImageMap2);
1217 DummyControl dummyControl2 = DummyControl::New(true);
1218 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl2.GetImplementation());
1219 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual2);
1220 dummyControl2.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1221 application.GetScene().Add(dummyControl2);
1222 application.SendNotification();
1223 application.Render(16);
1225 tet_infoline("The texture cache should be holding the requested images; check that the renderer has a texture");
1226 TextureSet ts = dummyControl2.GetRendererAt(0).GetTextures();
1227 Texture t1 = ts.GetTexture(0);
1228 DALI_TEST_EQUALS(ts.GetTextureCount(), 1, TEST_LOCATION);
1230 tet_infoline("Test that on the first tick, 1 new image is requested");
1231 Test::EmitGlobalTimerSignal(); // Both visuals should tick
1233 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1234 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1236 ts = dummyControl2.GetRendererAt(0).GetTextures();
1237 Texture t2 = ts.GetTexture(0);
1238 DALI_TEST_CHECK(t1 != t2);
1240 dummyControl1.Unparent();
1241 dummyControl2.Unparent();
1243 tet_infoline("Test that removing the visual from stage deletes all textures");
1244 application.SendNotification();
1245 application.Render(16);
1246 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1251 int UtcDaliAnimatedImageVisualMultiImage04(void)
1253 ToolkitTestApplication application;
1254 TestGlAbstraction& gl = application.GetGlAbstraction();
1255 TraceCallStack& textureTrace = gl.GetTextureTrace();
1256 textureTrace.Enable(true);
1258 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");
1260 Property::Array urls;
1261 CopyUrlsIntoArray(urls);
1264 Property::Map propertyMap;
1265 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1266 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1267 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 6);
1268 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 11);
1269 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1271 VisualFactory factory = VisualFactory::Get();
1272 Visual::Base visual = factory.CreateVisual(propertyMap);
1274 tet_infoline("Expect that a batch of 7 textures has been requested.");
1276 DummyControl dummyControl = DummyControl::New(true);
1277 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1278 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1280 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1281 application.GetScene().Add(dummyControl);
1282 application.SendNotification();
1283 application.Render(16);
1285 tet_infoline("Wait for the first batch to complete");
1286 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(6), true, TEST_LOCATION);
1288 tet_infoline("Test that a timer has been started");
1289 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1291 application.SendNotification();
1292 application.Render(16);
1294 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 6, TEST_LOCATION);
1295 tet_infoline("Test that after 1 tick, and 5 file loads completed, that we have 11 textures");
1296 Test::EmitGlobalTimerSignal();
1297 application.SendNotification();
1298 application.Render(16);
1300 // Expect the second batch has been requested
1301 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(5), true, TEST_LOCATION);
1303 application.SendNotification();
1304 application.Render(16);
1305 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 11, TEST_LOCATION);
1307 tet_infoline("Test that after 2 ticks that we have 11 textures and no requests");
1309 Test::EmitGlobalTimerSignal();
1310 application.SendNotification();
1311 application.Render(16);
1312 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 5), false, TEST_LOCATION);
1313 application.SendNotification();
1314 application.Render(16);
1315 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 11, TEST_LOCATION);
1317 tet_infoline("Test that after 3rd tick that we have 11 textures and no requests");
1318 Test::EmitGlobalTimerSignal();
1319 application.SendNotification();
1320 application.Render(16);
1322 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 5), false, TEST_LOCATION);
1323 application.SendNotification();
1324 application.Render(16);
1325 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 11, TEST_LOCATION);
1327 dummyControl.Unparent();
1330 tet_infoline("Test that removing the visual from stage deletes all textures");
1331 application.SendNotification();
1332 application.Render(16);
1333 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1338 int UtcDaliAnimatedImageVisualMultiImage05(void)
1340 ToolkitTestApplication application;
1341 TestGlAbstraction& gl = application.GetGlAbstraction();
1343 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");
1345 Property::Array urls;
1346 CopyUrlsIntoArray(urls);
1349 Property::Map propertyMap;
1350 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1351 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1352 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
1353 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 11);
1354 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1356 VisualFactory factory = VisualFactory::Get();
1357 Visual::Base visual = factory.CreateVisual(propertyMap);
1359 tet_infoline("Expect that a batch of 4 textures has been requested.");
1361 DummyControl dummyControl = DummyControl::New(true);
1362 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1363 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1365 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1366 application.GetScene().Add(dummyControl);
1367 application.SendNotification();
1368 application.Render(16);
1370 tet_infoline("Wait for the first batch to complete");
1371 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1373 tet_infoline("Test that a timer has been started");
1374 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1376 application.SendNotification();
1377 application.Render(16);
1379 tet_infoline("Test that a timer has been started");
1380 Test::EmitGlobalTimerSignal();
1381 application.SendNotification();
1382 application.Render(16);
1384 dummyControl.Unparent();
1387 application.SendNotification();
1388 application.Render(16);
1389 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1391 tet_infoline("Test that pending batch of image loads are cancelled instead of uploaded");
1392 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1393 application.SendNotification();
1394 application.Render(16);
1395 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1400 void TestLoopCount(ToolkitTestApplication& application, DummyControl& dummyControl, uint16_t frameCount, uint16_t loopCount, const char* location)
1402 TestGlAbstraction& gl = application.GetGlAbstraction();
1403 TraceCallStack& textureTrace = gl.GetTextureTrace();
1405 textureTrace.Enable(true);
1406 application.GetScene().Add(dummyControl);
1408 application.SendNotification();
1409 application.Render(16);
1411 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_INNER_LOCATION(location));
1413 application.SendNotification();
1414 application.Render();
1416 tet_infoline("Test that a timer has been created");
1417 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_INNER_LOCATION(location));
1419 for(uint16_t i = 0; i < loopCount; i++)
1421 for(uint16_t j = 0; j < frameCount; j++)
1423 if(i == 0 && j == 0)
1425 continue; // Because first frame is already showed and we call 2nd frame at the first time of timer animation.
1427 tet_printf("Test that after %u ticks, and we have %u frame \n", j + 1u, j + 1u);
1428 Test::EmitGlobalTimerSignal();
1429 application.SendNotification();
1430 application.Render(16);
1432 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_INNER_LOCATION(location));
1434 application.SendNotification();
1435 application.Render();
1436 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_INNER_LOCATION(location));
1437 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_INNER_LOCATION(location));
1439 tet_printf("Test Loop %u \n\n", i + 1u);
1442 tet_printf("Test that after %u loops, and we have no frame. Timer should stop \n", loopCount);
1443 Test::EmitGlobalTimerSignal();
1444 application.SendNotification();
1445 application.Render(16);
1446 DALI_TEST_EQUALS(Test::AreTimersRunning(), false, TEST_INNER_LOCATION(location));
1448 dummyControl.Unparent();
1451 int UtcDaliAnimatedImageVisualLoopCount(void)
1453 ToolkitTestApplication application;
1455 tet_infoline("UtcDaliAnimatedImageVisualLoopCount");
1458 // request AnimatedImageVisual with a property map
1459 // Test with no (0) loop count
1460 VisualFactory factory = VisualFactory::Get();
1461 Visual::Base animatedImageVisual = factory.CreateVisual(
1463 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1464 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1465 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1466 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1467 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1468 .Add(DevelImageVisual::Property::LOOP_COUNT, 0));
1470 DummyControl dummyControl = DummyControl::New(true);
1471 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1472 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1473 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1475 TestLoopCount(application, dummyControl, 4, 0, TEST_LOCATION);
1477 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1478 animatedImageVisual.Reset();
1480 application.SendNotification();
1481 application.Render(16);
1483 // Test with no (1) loop count. Request AnimatedImageVisual with a property map
1484 animatedImageVisual = factory.CreateVisual(
1486 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1487 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1488 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1489 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1490 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1491 .Add(DevelImageVisual::Property::LOOP_COUNT, 1));
1493 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1495 TestLoopCount(application, dummyControl, 4, 1, TEST_LOCATION);
1497 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1498 animatedImageVisual.Reset();
1500 application.SendNotification();
1501 application.Render(16);
1503 // Test with no (100) loop count. Request AnimatedImageVisual with a property map
1504 animatedImageVisual = factory.CreateVisual(
1506 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1507 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1508 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1509 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1510 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1511 .Add(DevelImageVisual::Property::LOOP_COUNT, 100));
1513 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1515 TestLoopCount(application, dummyControl, 4, 100, TEST_LOCATION);
1520 int UtcDaliAnimatedImageVisualPlayback(void)
1522 ToolkitTestApplication application;
1523 TestGlAbstraction& gl = application.GetGlAbstraction();
1524 TraceCallStack& textureTrace = gl.GetTextureTrace();
1526 tet_infoline("UtcDaliAnimatedImageVisualPlayback");
1529 // request AnimatedImageVisual with a property map
1530 // Test with forever (-1) loop count
1531 VisualFactory factory = VisualFactory::Get();
1532 Visual::Base animatedImageVisual = factory.CreateVisual(
1534 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1535 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1536 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1537 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1538 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1539 .Add(DevelImageVisual::Property::LOOP_COUNT, -1));
1541 DummyControl dummyControl = DummyControl::New(true);
1542 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1543 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1544 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1546 textureTrace.Enable(true);
1547 application.GetScene().Add(dummyControl);
1548 application.SendNotification();
1549 application.Render(16);
1551 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1553 application.SendNotification();
1554 application.Render();
1556 tet_infoline("Test that a timer has been created");
1557 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1559 Test::EmitGlobalTimerSignal();
1560 application.SendNotification();
1561 application.Render(16);
1563 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1565 application.SendNotification();
1566 application.Render();
1567 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_LOCATION);
1569 Property::Map attributes;
1570 tet_infoline("Test Pause action. Timer should stop after Pause action");
1571 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PAUSE, attributes);
1572 Test::EmitGlobalTimerSignal();
1573 application.SendNotification();
1574 application.Render(16);
1575 DALI_TEST_EQUALS(Test::AreTimersRunning(), false, TEST_LOCATION);
1577 tet_infoline("Test Play action. Timer should Restart after Play action");
1578 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes);
1579 Test::EmitGlobalTimerSignal();
1580 application.SendNotification();
1581 application.Render(16);
1583 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1585 application.SendNotification();
1586 application.Render();
1587 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_LOCATION);
1589 tet_infoline("Test Stop action. Timer should stop after Stop action");
1590 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, attributes);
1591 Test::EmitGlobalTimerSignal();
1592 application.SendNotification();
1593 application.Render(16);
1594 DALI_TEST_EQUALS(Test::AreTimersRunning(), false, TEST_LOCATION);
1596 tet_infoline("Test Play action. Timer should Restart after Play action");
1597 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes);
1598 Test::EmitGlobalTimerSignal();
1599 application.SendNotification();
1600 application.Render(16);
1602 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1604 application.SendNotification();
1605 application.Render();
1606 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_LOCATION);
1608 dummyControl.Unparent();