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 // To do: we need to fix caching bug in animated-visual
857 //tet_infoline("Test that we don't try to re-load new image cause it cached");
858 //DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
860 // Batch 2 frames. Now visual frame 1, 2, 3 cached and visual2 frame 0, 1 cached.
861 application.SendNotification();
862 application.Render(20);
864 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 5, TEST_LOCATION);
866 textureTrace.Reset();
868 tet_infoline("Load some many frames");
870 const int repeatCount = 10;
871 for(int repeat = 0; repeat < repeatCount; ++repeat)
873 Test::EmitGlobalTimerSignal();
874 application.SendNotification();
875 application.Render(2000);
878 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // A new texture should NOT be generated.
879 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 5, TEST_LOCATION);
881 textureTrace.Reset();
883 dummyControl.Unparent();
884 dummyControl2.Unparent();
886 tet_infoline("Test that removing the visual from stage deletes all textures");
887 application.SendNotification();
888 application.Render(20);
889 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
894 int UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask01(void)
896 ToolkitTestApplication application;
897 TestGlAbstraction& gl = application.GetGlAbstraction();
900 Property::Map propertyMap;
901 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
902 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
903 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
904 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 4);
905 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
906 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
908 VisualFactory factory = VisualFactory::Get();
909 Visual::Base visual = factory.CreateVisual(propertyMap);
911 DummyControl dummyControl = DummyControl::New(true);
912 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
913 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
915 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
916 application.GetScene().Add(dummyControl);
918 application.SendNotification();
919 application.Render();
921 // load two frame(batch size), load mask image, and request two masking
922 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(5), true, TEST_LOCATION);
924 application.SendNotification();
925 application.Render(20);
927 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 2, TEST_LOCATION);
929 dummyControl.Unparent();
931 tet_infoline("Test that removing the visual from stage deletes all textures");
932 application.SendNotification();
933 application.Render(20);
934 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
939 int UtcDaliAnimatedImageVisualMultiImage01(void)
941 ToolkitTestApplication application;
942 TestGlAbstraction& gl = application.GetGlAbstraction();
944 Property::Array urls;
945 CopyUrlsIntoArray(urls);
948 Property::Map propertyMap;
949 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
950 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
951 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
952 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 8);
953 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
955 VisualFactory factory = VisualFactory::Get();
956 Visual::Base visual = factory.CreateVisual(propertyMap);
958 // Expect that a batch of 4 textures has been requested. These will be serially loaded
961 DummyControl dummyControl = DummyControl::New(true);
962 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
963 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
965 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
966 application.GetScene().Add(dummyControl);
967 application.SendNotification();
968 application.Render(16);
970 tet_infoline("Ready the visual after the visual is on stage");
971 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
973 tet_infoline("Test that a timer has been started");
974 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
976 TraceCallStack& textureTrace = gl.GetTextureTrace();
977 textureTrace.Enable(true);
979 application.SendNotification();
980 application.Render(16);
982 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
983 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
985 tet_infoline("Test that after 1 tick, and file loads completed, that we have 7 textures");
986 Test::EmitGlobalTimerSignal();
988 // Expect the second batch has been requested
989 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
991 application.SendNotification();
992 application.Render(16);
993 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
995 tet_infoline("Test that after 2 ticks that we have 6 textures");
997 Test::EmitGlobalTimerSignal();
998 application.SendNotification();
999 application.Render(16);
1000 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 6, TEST_LOCATION);
1002 tet_infoline("And that at least 2 textures were requested");
1003 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1004 application.SendNotification();
1005 application.Render(16);
1006 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 8, TEST_LOCATION);
1008 tet_infoline("Test that after 3rd tick that we have 7 textures and 1 request");
1009 Test::EmitGlobalTimerSignal();
1010 application.SendNotification();
1011 application.Render(16);
1012 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
1014 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1015 application.SendNotification();
1016 application.Render(16);
1017 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 8, TEST_LOCATION);
1019 dummyControl.Unparent();
1021 tet_infoline("Test that removing the visual from stage deletes all textures");
1022 application.SendNotification();
1023 application.Render(16);
1024 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1029 int UtcDaliAnimatedImageVisualMultiImage02(void)
1031 ToolkitTestApplication application;
1032 TestGlAbstraction& gl = application.GetGlAbstraction();
1034 tet_infoline("Test that the animated visual has different batch and cache size.");
1037 Property::Array urls;
1038 CopyUrlsIntoArray(urls);
1040 Property::Map propertyMap;
1041 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1042 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1043 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 0);
1044 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 0);
1045 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1047 VisualFactory factory = VisualFactory::Get();
1048 Visual::Base visual = factory.CreateVisual(propertyMap); // TexMgr::Request load tId:0
1050 // Check the batch size and cache size need to have minimum 2.
1051 Property::Map resultMap;
1052 visual.CreatePropertyMap(resultMap);
1053 Property::Value* value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, "batchSize");
1054 DALI_TEST_CHECK(value);
1055 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1056 value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, "cacheSize");
1057 DALI_TEST_CHECK(value);
1058 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1061 // Batch size is 2 and cache size is 3
1062 propertyMap.Clear();
1063 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1064 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1065 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
1066 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 3);
1067 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1069 visual = factory.CreateVisual(propertyMap); // TexMgr::Request load tId:0
1071 // Expect that each image is loaded each tick
1072 DummyControl dummyControl = DummyControl::New(true);
1073 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1074 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1077 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1078 application.GetScene().Add(dummyControl);
1079 application.SendNotification();
1080 application.Render(16);
1082 tet_infoline("Ready the visual after the visual is on window");
1083 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1084 application.SendNotification();
1085 application.Render(16); //glGenTextures 1 and 2
1086 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
1088 tet_infoline("Test that each tick, a new image is requested");
1089 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
1090 application.SendNotification();
1091 application.Render(16);
1092 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1093 application.SendNotification();
1094 application.Render(16); //glGenTextures 3
1095 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1097 tet_infoline("Test that each tick, a new image is requested");
1098 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:1
1099 application.SendNotification();
1100 application.Render(16);
1101 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1102 application.SendNotification();
1103 application.Render(16); //glGenTextures 4
1104 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1106 dummyImpl1.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1107 dummyControl.Unparent();
1109 // Batch size is 9 and cache size is 4
1110 propertyMap.Clear();
1111 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1112 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1113 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 3);
1114 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 7);
1115 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1117 visual = factory.CreateVisual(propertyMap); // TexMgr::Request load tId:0
1119 // Expect that each image is loaded each tick
1120 dummyControl = DummyControl::New(true);
1121 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1122 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1125 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1126 application.GetScene().Add(dummyControl);
1127 application.SendNotification();
1128 application.Render(16);
1130 tet_infoline("Ready the visual after the visual is on window");
1131 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1132 application.SendNotification();
1133 application.Render(16); //glGenTextures 1, 2, and 3
1134 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1136 tet_infoline("Test that each tick, a new image is requested");
1137 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
1138 application.SendNotification();
1139 application.Render(16);
1140 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1141 application.SendNotification();
1142 application.Render(16); //glGenTextures 4, 5, and 6
1143 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 5, TEST_LOCATION);
1145 tet_infoline("Test that each tick, a new image is requested");
1146 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:1
1147 application.SendNotification();
1148 application.Render(16);
1149 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1150 application.SendNotification();
1151 application.Render(16); //glGenTextures 7, 1, and 2
1152 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
1154 tet_infoline("Test that each tick, a new image is requested");
1155 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:2
1156 application.SendNotification();
1157 application.Render(16);
1158 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1159 application.SendNotification();
1160 application.Render(16); //glGenTextures 3
1161 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
1163 dummyControl.Unparent();
1165 tet_infoline("Test that removing the visual from window deletes all textures");
1166 application.SendNotification();
1167 application.Render(16);
1168 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1173 int UtcDaliAnimatedImageVisualMultiImage03(void)
1175 ToolkitTestApplication application;
1176 TestGlAbstraction& gl = application.GetGlAbstraction();
1179 Property::Array urls1, urls2;
1180 CopyUrlsIntoArray(urls1);
1181 CopyUrlsIntoArray(urls2);
1183 Property::Map animatedImageMap1;
1184 animatedImageMap1.Insert(Visual::Property::TYPE, Visual::IMAGE);
1185 animatedImageMap1.Insert(ImageVisual::Property::URL, Property::Value(urls1));
1186 animatedImageMap1.Insert(ImageVisual::Property::BATCH_SIZE, 3);
1187 animatedImageMap1.Insert(ImageVisual::Property::CACHE_SIZE, 3);
1188 animatedImageMap1.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1190 Property::Map animatedImageMap2;
1191 animatedImageMap2.Insert(Visual::Property::TYPE, Visual::IMAGE);
1192 animatedImageMap2.Insert(ImageVisual::Property::URL, Property::Value(urls2));
1193 animatedImageMap2.Insert(ImageVisual::Property::BATCH_SIZE, 2);
1194 animatedImageMap2.Insert(ImageVisual::Property::CACHE_SIZE, 2);
1195 animatedImageMap2.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1197 VisualFactory factory = VisualFactory::Get();
1198 Visual::Base animatedImageVisual1 = factory.CreateVisual(animatedImageMap1);
1200 tet_infoline("Create two image views with the same URLs, offset by 1 frame.");
1202 DummyControl dummyControl1 = DummyControl::New(true);
1203 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl1.GetImplementation());
1204 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual1);
1205 dummyControl1.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1206 application.GetScene().Add(dummyControl1);
1208 application.SendNotification();
1209 application.Render(16);
1211 tet_infoline("Ready the requested image after the first visual is on stage");
1212 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1213 application.SendNotification();
1214 application.Render(16);
1215 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1217 Visual::Base animatedImageVisual2 = factory.CreateVisual(animatedImageMap2);
1218 DummyControl dummyControl2 = DummyControl::New(true);
1219 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl2.GetImplementation());
1220 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual2);
1221 dummyControl2.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1222 application.GetScene().Add(dummyControl2);
1223 application.SendNotification();
1224 application.Render(16);
1226 tet_infoline("The texture cache should be holding the requested images; check that the renderer has a texture");
1227 TextureSet ts = dummyControl2.GetRendererAt(0).GetTextures();
1228 Texture t1 = ts.GetTexture(0);
1229 DALI_TEST_EQUALS(ts.GetTextureCount(), 1, TEST_LOCATION);
1231 tet_infoline("Test that on the first tick, 1 new image is requested");
1232 Test::EmitGlobalTimerSignal(); // Both visuals should tick
1234 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1235 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1237 ts = dummyControl2.GetRendererAt(0).GetTextures();
1238 Texture t2 = ts.GetTexture(0);
1239 DALI_TEST_CHECK(t1 != t2);
1241 dummyControl1.Unparent();
1242 dummyControl2.Unparent();
1244 tet_infoline("Test that removing the visual from stage deletes all textures");
1245 application.SendNotification();
1246 application.Render(16);
1247 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1252 int UtcDaliAnimatedImageVisualMultiImage04(void)
1254 ToolkitTestApplication application;
1255 TestGlAbstraction& gl = application.GetGlAbstraction();
1256 TraceCallStack& textureTrace = gl.GetTextureTrace();
1257 textureTrace.Enable(true);
1259 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");
1261 Property::Array urls;
1262 CopyUrlsIntoArray(urls);
1265 Property::Map propertyMap;
1266 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1267 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1268 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 6);
1269 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 11);
1270 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1272 VisualFactory factory = VisualFactory::Get();
1273 Visual::Base visual = factory.CreateVisual(propertyMap);
1275 tet_infoline("Expect that a batch of 7 textures has been requested.");
1277 DummyControl dummyControl = DummyControl::New(true);
1278 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1279 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1281 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1282 application.GetScene().Add(dummyControl);
1283 application.SendNotification();
1284 application.Render(16);
1286 tet_infoline("Wait for the first batch to complete");
1287 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(6), true, TEST_LOCATION);
1289 tet_infoline("Test that a timer has been started");
1290 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1292 application.SendNotification();
1293 application.Render(16);
1295 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 6, TEST_LOCATION);
1296 tet_infoline("Test that after 1 tick, and 5 file loads completed, that we have 11 textures");
1297 Test::EmitGlobalTimerSignal();
1298 application.SendNotification();
1299 application.Render(16);
1301 // Expect the second batch has been requested
1302 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(5), true, TEST_LOCATION);
1304 application.SendNotification();
1305 application.Render(16);
1306 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 11, TEST_LOCATION);
1308 tet_infoline("Test that after 2 ticks that we have 11 textures and no requests");
1310 Test::EmitGlobalTimerSignal();
1311 application.SendNotification();
1312 application.Render(16);
1313 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 5), false, TEST_LOCATION);
1314 application.SendNotification();
1315 application.Render(16);
1316 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 11, TEST_LOCATION);
1318 tet_infoline("Test that after 3rd tick that we have 11 textures and no requests");
1319 Test::EmitGlobalTimerSignal();
1320 application.SendNotification();
1321 application.Render(16);
1323 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 5), false, TEST_LOCATION);
1324 application.SendNotification();
1325 application.Render(16);
1326 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 11, TEST_LOCATION);
1328 dummyControl.Unparent();
1331 tet_infoline("Test that removing the visual from stage deletes all textures");
1332 application.SendNotification();
1333 application.Render(16);
1334 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1339 int UtcDaliAnimatedImageVisualMultiImage05(void)
1341 ToolkitTestApplication application;
1342 TestGlAbstraction& gl = application.GetGlAbstraction();
1344 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");
1346 Property::Array urls;
1347 CopyUrlsIntoArray(urls);
1350 Property::Map propertyMap;
1351 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1352 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1353 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
1354 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 11);
1355 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1357 VisualFactory factory = VisualFactory::Get();
1358 Visual::Base visual = factory.CreateVisual(propertyMap);
1360 tet_infoline("Expect that a batch of 4 textures has been requested.");
1362 DummyControl dummyControl = DummyControl::New(true);
1363 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1364 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1366 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1367 application.GetScene().Add(dummyControl);
1368 application.SendNotification();
1369 application.Render(16);
1371 tet_infoline("Wait for the first batch to complete");
1372 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1374 tet_infoline("Test that a timer has been started");
1375 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1377 application.SendNotification();
1378 application.Render(16);
1380 tet_infoline("Test that a timer has been started");
1381 Test::EmitGlobalTimerSignal();
1382 application.SendNotification();
1383 application.Render(16);
1385 dummyControl.Unparent();
1388 application.SendNotification();
1389 application.Render(16);
1390 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1392 tet_infoline("Test that pending batch of image loads are cancelled instead of uploaded");
1393 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1394 application.SendNotification();
1395 application.Render(16);
1396 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1401 void TestLoopCount(ToolkitTestApplication& application, DummyControl& dummyControl, uint16_t frameCount, uint16_t loopCount, const char* location)
1403 TestGlAbstraction& gl = application.GetGlAbstraction();
1404 TraceCallStack& textureTrace = gl.GetTextureTrace();
1406 textureTrace.Enable(true);
1407 application.GetScene().Add(dummyControl);
1409 application.SendNotification();
1410 application.Render(16);
1412 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_INNER_LOCATION(location));
1414 application.SendNotification();
1415 application.Render();
1417 tet_infoline("Test that a timer has been created");
1418 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_INNER_LOCATION(location));
1420 for(uint16_t i = 0; i < loopCount; i++)
1422 for(uint16_t j = 0; j < frameCount; j++)
1424 if(i == 0 && j == 0)
1426 continue; // Because first frame is already showed and we call 2nd frame at the first time of timer animation.
1428 tet_printf("Test that after %u ticks, and we have %u frame \n", j + 1u, j + 1u);
1429 Test::EmitGlobalTimerSignal();
1430 application.SendNotification();
1431 application.Render(16);
1433 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_INNER_LOCATION(location));
1435 application.SendNotification();
1436 application.Render();
1437 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_INNER_LOCATION(location));
1438 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_INNER_LOCATION(location));
1440 tet_printf("Test Loop %u \n\n", i + 1u);
1443 tet_printf("Test that after %u loops, and we have no frame. Timer should stop \n", loopCount);
1444 Test::EmitGlobalTimerSignal();
1445 application.SendNotification();
1446 application.Render(16);
1447 DALI_TEST_EQUALS(Test::AreTimersRunning(), false, TEST_INNER_LOCATION(location));
1449 dummyControl.Unparent();
1452 int UtcDaliAnimatedImageVisualLoopCount(void)
1454 ToolkitTestApplication application;
1456 tet_infoline("UtcDaliAnimatedImageVisualLoopCount");
1459 // request AnimatedImageVisual with a property map
1460 // Test with no (0) loop count
1461 VisualFactory factory = VisualFactory::Get();
1462 Visual::Base animatedImageVisual = factory.CreateVisual(
1464 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1465 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1466 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1467 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1468 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1469 .Add(DevelImageVisual::Property::LOOP_COUNT, 0));
1471 DummyControl dummyControl = DummyControl::New(true);
1472 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1473 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1474 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1476 TestLoopCount(application, dummyControl, 4, 0, TEST_LOCATION);
1478 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1479 animatedImageVisual.Reset();
1481 application.SendNotification();
1482 application.Render(16);
1484 // Test with no (1) loop count. Request AnimatedImageVisual with a property map
1485 animatedImageVisual = factory.CreateVisual(
1487 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1488 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1489 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1490 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1491 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1492 .Add(DevelImageVisual::Property::LOOP_COUNT, 1));
1494 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1496 TestLoopCount(application, dummyControl, 4, 1, TEST_LOCATION);
1498 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1499 animatedImageVisual.Reset();
1501 application.SendNotification();
1502 application.Render(16);
1504 // Test with no (100) loop count. Request AnimatedImageVisual with a property map
1505 animatedImageVisual = factory.CreateVisual(
1507 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1508 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1509 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1510 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1511 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1512 .Add(DevelImageVisual::Property::LOOP_COUNT, 100));
1514 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1516 TestLoopCount(application, dummyControl, 4, 100, TEST_LOCATION);
1521 int UtcDaliAnimatedImageVisualPlayback(void)
1523 ToolkitTestApplication application;
1524 TestGlAbstraction& gl = application.GetGlAbstraction();
1525 TraceCallStack& textureTrace = gl.GetTextureTrace();
1527 tet_infoline("UtcDaliAnimatedImageVisualPlayback");
1530 // request AnimatedImageVisual with a property map
1531 // Test with forever (-1) loop count
1532 VisualFactory factory = VisualFactory::Get();
1533 Visual::Base animatedImageVisual = factory.CreateVisual(
1535 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1536 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1537 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1538 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1539 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1540 .Add(DevelImageVisual::Property::LOOP_COUNT, -1));
1542 DummyControl dummyControl = DummyControl::New(true);
1543 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1544 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1545 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1547 textureTrace.Enable(true);
1548 application.GetScene().Add(dummyControl);
1549 application.SendNotification();
1550 application.Render(16);
1552 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1554 application.SendNotification();
1555 application.Render();
1557 tet_infoline("Test that a timer has been created");
1558 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1560 Test::EmitGlobalTimerSignal();
1561 application.SendNotification();
1562 application.Render(16);
1564 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1566 application.SendNotification();
1567 application.Render();
1568 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_LOCATION);
1570 Property::Map attributes;
1571 tet_infoline("Test Pause action. Timer should stop after Pause action");
1572 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PAUSE, attributes);
1573 Test::EmitGlobalTimerSignal();
1574 application.SendNotification();
1575 application.Render(16);
1576 DALI_TEST_EQUALS(Test::AreTimersRunning(), false, TEST_LOCATION);
1578 tet_infoline("Test Play action. Timer should Restart after Play action");
1579 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes);
1580 Test::EmitGlobalTimerSignal();
1581 application.SendNotification();
1582 application.Render(16);
1584 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1586 application.SendNotification();
1587 application.Render();
1588 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_LOCATION);
1590 tet_infoline("Test Stop action. Timer should stop after Stop action");
1591 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, attributes);
1592 Test::EmitGlobalTimerSignal();
1593 application.SendNotification();
1594 application.Render(16);
1595 DALI_TEST_EQUALS(Test::AreTimersRunning(), false, TEST_LOCATION);
1597 tet_infoline("Test Play action. Timer should Restart after Play action");
1598 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes);
1599 Test::EmitGlobalTimerSignal();
1600 application.SendNotification();
1601 application.Render(16);
1603 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1605 application.SendNotification();
1606 application.Render();
1607 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_LOCATION);
1609 dummyControl.Unparent();