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";
52 const char* TEST_WEBP_FILE_NAME = TEST_RESOURCE_DIR "/dali-logo.webp";
55 void CopyUrlsIntoArray(Property::Array& urls, int startIndex = 0)
57 for(int i = 20 + startIndex; i <= 30; ++i)
60 if(asprintf(&url, TEST_IMAGE_FILE_NAME, i) > 0)
62 Property::Value value(url);
69 int UtcDaliAnimatedImageVisualGetPropertyMap01(void)
71 ToolkitTestApplication application;
72 tet_infoline("UtcDaliAnimatedImageVisualGetPropertyMap");
74 // request AnimatedImageVisual with a property map
75 VisualFactory factory = VisualFactory::Get();
76 Visual::Base animatedImageVisual = factory.CreateVisual(
78 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
79 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
80 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
81 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
82 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
83 .Add(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME)
84 .Add(ImageVisual::Property::MASK_CONTENT_SCALE, 1.6f)
85 .Add(ImageVisual::Property::CROP_TO_MASK, true)
86 .Add(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING)
87 .Add(DevelVisual::Property::CORNER_RADIUS, 22.2f)
88 .Add(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE)
89 .Add(DevelVisual::Property::BORDERLINE_WIDTH, 33.3f)
90 .Add(DevelVisual::Property::BORDERLINE_COLOR, Color::RED)
91 .Add(DevelVisual::Property::BORDERLINE_OFFSET, 0.3f));
93 Property::Map resultMap;
94 animatedImageVisual.CreatePropertyMap(resultMap);
95 // check the property values from the returned map from a visual
96 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
97 DALI_TEST_CHECK(value);
98 DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
100 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
101 DALI_TEST_CHECK(value);
102 DALI_TEST_CHECK(value->Get<std::string>() == TEST_GIF_FILE_NAME);
104 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
105 DALI_TEST_CHECK(value);
106 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(22.2f, 22.2f, 22.2f, 22.2f), TEST_LOCATION);
108 value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, Property::INTEGER);
109 DALI_TEST_CHECK(value);
110 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
112 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT);
113 DALI_TEST_CHECK(value);
114 DALI_TEST_EQUALS(value->Get<float>(), 33.3f, TEST_LOCATION);
116 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
117 DALI_TEST_CHECK(value);
118 DALI_TEST_EQUALS(value->Get<Vector4>(), Color::RED, TEST_LOCATION);
120 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
121 DALI_TEST_CHECK(value);
122 DALI_TEST_EQUALS(value->Get<float>(), 0.3f, TEST_LOCATION);
124 // Check mask properties
125 value = resultMap.Find(ImageVisual::Property::ALPHA_MASK_URL, Property::STRING);
126 DALI_TEST_CHECK(value);
127 DALI_TEST_CHECK(value->Get<std::string>() == TEST_MASK_IMAGE_FILE_NAME);
129 value = resultMap.Find(ImageVisual::Property::MASK_CONTENT_SCALE, Property::FLOAT);
130 DALI_TEST_CHECK(value);
131 DALI_TEST_EQUALS(value->Get<float>(), 1.6f, TEST_LOCATION);
133 value = resultMap.Find(ImageVisual::Property::CROP_TO_MASK, Property::BOOLEAN);
134 DALI_TEST_CHECK(value);
135 DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
137 value = resultMap.Find(DevelImageVisual::Property::MASKING_TYPE, Property::INTEGER);
138 DALI_TEST_CHECK(value);
139 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
142 animatedImageVisual.GetNaturalSize(naturalSize);
143 DALI_TEST_EQUALS(naturalSize, Vector2(100, 100), TEST_LOCATION);
145 // request AnimatedImageVisual with an URL
146 Visual::Base animatedImageVisual2 = factory.CreateVisual(TEST_GIF_FILE_NAME, ImageDimensions());
148 animatedImageVisual2.CreatePropertyMap(resultMap);
149 // check the property values from the returned map from a visual
150 value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
151 DALI_TEST_CHECK(value);
152 DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
154 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
155 DALI_TEST_CHECK(value);
156 DALI_TEST_CHECK(value->Get<std::string>() == TEST_GIF_FILE_NAME);
161 int UtcDaliAnimatedImageVisualGetPropertyMap02(void)
163 ToolkitTestApplication application;
164 tet_infoline("UtcDaliAnimatedImageVisualGetPropertyMap for multi image with fixed cache");
166 // request AnimatedImageVisual with a property map
167 VisualFactory factory = VisualFactory::Get();
168 Property::Array urls;
169 CopyUrlsIntoArray(urls);
171 Visual::Base animatedImageVisual = factory.CreateVisual(
173 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
176 .Add("cacheSize", 20)
177 .Add("loopCount", 10)
178 .Add("frameDelay", 200)
179 .Add("pixelArea", Vector4())
180 .Add("wrapModeU", WrapMode::REPEAT)
181 .Add("wrapModeV", WrapMode::DEFAULT)
182 .Add("alphaMaskUrl", TEST_MASK_IMAGE_FILE_NAME)
183 .Add("maskContentScale", 1.6f)
184 .Add("cropToMask", true)
185 .Add(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING)
186 .Add("cornerRadius", Vector4(50.0f, 25.0f, 12.5f, 33.0f))
187 .Add("cornerRadiusPolicy", Visual::Transform::Policy::RELATIVE)
188 .Add("borderlineWidth", 20.0f)
189 .Add("borderlineColor", Vector4())
190 .Add("borderlineOffset", -1.0f));
192 Property::Map resultMap;
193 animatedImageVisual.CreatePropertyMap(resultMap);
194 // check the property values from the returned map from a visual
195 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
196 DALI_TEST_CHECK(value);
197 DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
199 value = resultMap.Find(ImageVisual::Property::URL, "url");
200 DALI_TEST_CHECK(value);
201 Property::Array* resultUrls = value->GetArray();
202 DALI_TEST_CHECK(resultUrls);
203 DALI_TEST_EQUALS(resultUrls->Count(), urls.Count(), TEST_LOCATION);
205 value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, "batchSize");
206 DALI_TEST_CHECK(value);
207 DALI_TEST_EQUALS(value->Get<int>(), 4, TEST_LOCATION);
209 value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, "cacheSize");
210 DALI_TEST_CHECK(value);
211 DALI_TEST_EQUALS(value->Get<int>(), 20, TEST_LOCATION);
213 value = resultMap.Find(Toolkit::DevelImageVisual::Property::LOOP_COUNT, "loopCount");
214 DALI_TEST_CHECK(value);
215 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
217 value = resultMap.Find(ImageVisual::Property::FRAME_DELAY, "frameDelay");
218 DALI_TEST_CHECK(value);
219 DALI_TEST_EQUALS(value->Get<int>(), 200, TEST_LOCATION);
221 value = resultMap.Find(Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber");
222 DALI_TEST_CHECK(value);
223 DALI_TEST_EQUALS(value->Get<int>(), 11, TEST_LOCATION);
225 value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS, "cornerRadius");
226 DALI_TEST_CHECK(value);
227 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(50.0f, 25.0f, 12.5f, 33.0f), TEST_LOCATION);
229 value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
230 DALI_TEST_CHECK(value);
231 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::RELATIVE);
233 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
234 DALI_TEST_CHECK(value);
235 DALI_TEST_EQUALS(value->Get<float>(), 20.0f, TEST_LOCATION);
237 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, "borderlineColor");
238 DALI_TEST_CHECK(value);
239 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4::ZERO, TEST_LOCATION);
241 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, "borderlineOffset");
242 DALI_TEST_CHECK(value);
243 DALI_TEST_EQUALS(value->Get<float>(), -1.0f, TEST_LOCATION);
245 // Check mask properties
246 value = resultMap.Find(ImageVisual::Property::ALPHA_MASK_URL, "alphaMaskUrl");
247 DALI_TEST_CHECK(value);
248 DALI_TEST_CHECK(value->Get<std::string>() == TEST_MASK_IMAGE_FILE_NAME);
250 value = resultMap.Find(ImageVisual::Property::MASK_CONTENT_SCALE, "maskContentScale");
251 DALI_TEST_CHECK(value);
252 DALI_TEST_EQUALS(value->Get<float>(), 1.6f, TEST_LOCATION);
254 value = resultMap.Find(ImageVisual::Property::CROP_TO_MASK, "cropToMask");
255 DALI_TEST_CHECK(value);
256 DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
258 value = resultMap.Find(DevelImageVisual::Property::MASKING_TYPE, Property::INTEGER);
259 DALI_TEST_CHECK(value);
260 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
265 int UtcDaliAnimatedImageVisualGetPropertyMap03(void)
267 ToolkitTestApplication application;
268 tet_infoline("UtcDaliAnimatedImageVisualGetPropertyMap for multi image rolling cache");
270 // request AnimatedImageVisual with a property map
271 VisualFactory factory = VisualFactory::Get();
272 Property::Array urls;
273 CopyUrlsIntoArray(urls);
275 Visual::Base animatedImageVisual = factory.CreateVisual(
277 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
281 .Add("loopCount", 10)
282 .Add("frameDelay", 200)
283 .Add("pixelArea", Vector4())
284 .Add("wrapModeU", WrapMode::REPEAT)
285 .Add("wrapModeV", WrapMode::DEFAULT)
286 .Add("alphaMaskUrl", TEST_MASK_IMAGE_FILE_NAME)
287 .Add("maskContentScale", 1.6f)
288 .Add("cropToMask", true)
289 .Add(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING)
290 .Add("cornerRadius", 50.5f));
292 Property::Map resultMap;
293 animatedImageVisual.CreatePropertyMap(resultMap);
294 // check the property values from the returned map from a visual
295 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
296 DALI_TEST_CHECK(value);
297 DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
299 value = resultMap.Find(ImageVisual::Property::URL, "url");
300 DALI_TEST_CHECK(value);
301 Property::Array* resultUrls = value->GetArray();
302 DALI_TEST_CHECK(resultUrls);
303 DALI_TEST_EQUALS(resultUrls->Count(), urls.Count(), TEST_LOCATION);
305 value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, "batchSize");
306 DALI_TEST_CHECK(value);
307 DALI_TEST_EQUALS(value->Get<int>(), 4, TEST_LOCATION);
309 value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, "cacheSize");
310 DALI_TEST_CHECK(value);
311 DALI_TEST_EQUALS(value->Get<int>(), 8, TEST_LOCATION);
313 value = resultMap.Find(Toolkit::DevelImageVisual::Property::LOOP_COUNT, "loopCount");
314 DALI_TEST_CHECK(value);
315 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
317 value = resultMap.Find(ImageVisual::Property::FRAME_DELAY, "frameDelay");
318 DALI_TEST_CHECK(value);
319 DALI_TEST_EQUALS(value->Get<int>(), 200, TEST_LOCATION);
321 value = resultMap.Find(Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber");
322 DALI_TEST_CHECK(value);
323 DALI_TEST_EQUALS(value->Get<int>(), 11, TEST_LOCATION);
325 value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS, "cornerRadius");
326 DALI_TEST_CHECK(value);
327 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(50.5f, 50.5f, 50.5f, 50.5f), TEST_LOCATION);
329 value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
330 DALI_TEST_CHECK(value);
331 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
333 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
334 DALI_TEST_CHECK(value);
335 DALI_TEST_EQUALS(value->Get<float>(), 0.0f, TEST_LOCATION);
337 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, "borderlineColor");
338 DALI_TEST_CHECK(value);
339 DALI_TEST_EQUALS(value->Get<Vector4>(), Color::BLACK, TEST_LOCATION);
341 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, "borderlineOffset");
342 DALI_TEST_CHECK(value);
343 DALI_TEST_EQUALS(value->Get<float>(), 0.0f, TEST_LOCATION);
345 // Check mask properties
346 value = resultMap.Find(ImageVisual::Property::ALPHA_MASK_URL, "alphaMaskUrl");
347 DALI_TEST_CHECK(value);
348 DALI_TEST_CHECK(value->Get<std::string>() == TEST_MASK_IMAGE_FILE_NAME);
350 value = resultMap.Find(ImageVisual::Property::MASK_CONTENT_SCALE, "maskContentScale");
351 DALI_TEST_CHECK(value);
352 DALI_TEST_EQUALS(value->Get<float>(), 1.6f, TEST_LOCATION);
354 value = resultMap.Find(ImageVisual::Property::CROP_TO_MASK, "cropToMask");
355 DALI_TEST_CHECK(value);
356 DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
358 value = resultMap.Find(DevelImageVisual::Property::MASKING_TYPE, Property::INTEGER);
359 DALI_TEST_CHECK(value);
360 DALI_TEST_CHECK(value->Get<bool>() == DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
365 int UtcDaliAnimatedImageVisualGetPropertyMap04(void)
367 ToolkitTestApplication application;
368 tet_infoline("UtcDaliAnimatedImageVisualGetPropertyMap");
370 // request AnimatedImageVisual with a property map
371 VisualFactory factory = VisualFactory::Get();
372 Visual::Base animatedImageVisual = factory.CreateVisual(
374 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
375 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
376 .Add(ImageVisual::Property::BATCH_SIZE, 1)
377 .Add(ImageVisual::Property::CACHE_SIZE, 1)
378 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, true)
379 .Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DETACHED)
380 .Add(ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::ATTACHED)
381 .Add(DevelVisual::Property::BORDERLINE_WIDTH, 0.4f));
383 Property::Map resultMap;
384 animatedImageVisual.CreatePropertyMap(resultMap);
386 // check the property values from the returned map from a visual
387 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
388 DALI_TEST_CHECK(value);
389 DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
391 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
392 DALI_TEST_CHECK(value);
393 DALI_TEST_CHECK(value->Get<std::string>() == TEST_GIF_FILE_NAME);
395 value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, Property::INTEGER);
396 DALI_TEST_CHECK(value);
397 DALI_TEST_CHECK(value->Get<int>() == 2);
399 value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, Property::INTEGER);
400 DALI_TEST_CHECK(value);
401 DALI_TEST_CHECK(value->Get<int>() == 2);
403 value = resultMap.Find(ImageVisual::Property::SYNCHRONOUS_LOADING, Property::BOOLEAN);
404 DALI_TEST_CHECK(value);
405 DALI_TEST_CHECK(value->Get<bool>() == true);
407 value = resultMap.Find(ImageVisual::Property::RELEASE_POLICY, Property::INTEGER);
408 DALI_TEST_CHECK(value);
409 DALI_TEST_CHECK(value->Get<int>() == ImageVisual::ReleasePolicy::DETACHED);
411 value = resultMap.Find(ImageVisual::Property::LOAD_POLICY, Property::INTEGER);
412 DALI_TEST_CHECK(value);
413 DALI_TEST_CHECK(value->Get<int>() == ImageVisual::LoadPolicy::ATTACHED);
415 value = resultMap.Find(Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber");
416 DALI_TEST_CHECK(value);
417 DALI_TEST_EQUALS(value->Get<int>(), 4, TEST_LOCATION);
419 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
420 DALI_TEST_CHECK(value);
421 DALI_TEST_EQUALS(value->Get<float>(), 0.4f, TEST_LOCATION);
423 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, "borderlineColor");
424 DALI_TEST_CHECK(value);
425 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(0.0f, 0.0f, 0.0f, 1.0f), TEST_LOCATION);
427 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, "borderlineOffset");
428 DALI_TEST_CHECK(value);
429 DALI_TEST_EQUALS(value->Get<float>(), 0.0f, TEST_LOCATION);
434 int UtcDaliAnimatedImageVisualImageLoadingFail01(void)
436 ToolkitTestApplication application;
437 TestGlAbstraction& gl = application.GetGlAbstraction();
440 Property::Map propertyMap;
441 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
442 propertyMap.Insert(ImageVisual::Property::URL, "dummy.gif");
443 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
444 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
445 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
446 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
447 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
448 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
450 VisualFactory factory = VisualFactory::Get();
451 Visual::Base visual = factory.CreateVisual(propertyMap);
453 DummyControl dummyControl = DummyControl::New(true);
454 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
455 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
457 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
458 application.GetScene().Add(dummyControl);
460 TraceCallStack& textureTrace = gl.GetTextureTrace();
461 textureTrace.Enable(true);
463 application.SendNotification();
464 application.Render(20);
466 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 1, TEST_LOCATION);
468 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 6);
470 application.SendNotification();
471 application.Render(20);
473 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 1, TEST_LOCATION);
475 dummyControl.Unparent();
481 int UtcDaliAnimatedImageVisualSynchronousLoading(void)
483 ToolkitTestApplication application;
484 TestGlAbstraction& gl = application.GetGlAbstraction();
487 Property::Map propertyMap;
488 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
489 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
490 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
491 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
492 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
493 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
494 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
495 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
497 VisualFactory factory = VisualFactory::Get();
498 Visual::Base visual = factory.CreateVisual(propertyMap);
500 DummyControl dummyControl = DummyControl::New(true);
501 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
502 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
504 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
505 application.GetScene().Add(dummyControl);
507 TraceCallStack& textureTrace = gl.GetTextureTrace();
508 textureTrace.Enable(true);
510 application.SendNotification();
511 application.Render(20);
513 // The first frame is loaded synchronously and load next batch.
514 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
516 application.SendNotification();
517 application.Render();
519 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
520 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
522 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 3);
524 application.SendNotification();
525 application.Render(20);
527 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
529 application.SendNotification();
530 application.Render();
532 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
534 dummyControl.Unparent();
536 tet_infoline("Test that removing the visual from stage deletes all textures");
537 application.SendNotification();
538 application.Render(16);
539 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
544 int UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask01(void)
546 ToolkitTestApplication application;
547 tet_infoline("UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask01 for CPU Alpha Masking");
548 TestGlAbstraction& gl = application.GetGlAbstraction();
551 Property::Map propertyMap;
552 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
553 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
554 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
555 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
556 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
557 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
558 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
559 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
560 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
562 VisualFactory factory = VisualFactory::Get();
563 Visual::Base visual = factory.CreateVisual(propertyMap);
565 Property::Map testMap;
566 visual.CreatePropertyMap(testMap);
567 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
569 DummyControl dummyControl = DummyControl::New(true);
570 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
571 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
573 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
574 application.GetScene().Add(dummyControl);
576 TraceCallStack& textureTrace = gl.GetTextureTrace();
577 textureTrace.Enable(true);
579 application.SendNotification();
580 application.Render(20);
582 // The first frame is loaded synchronously and load next batch with masking
583 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
585 application.SendNotification();
586 application.Render();
588 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
589 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
591 dummyControl.Unparent();
593 tet_infoline("Test that removing the visual from stage deletes all textures");
594 application.SendNotification();
595 application.Render(16);
596 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
601 int UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask02(void)
603 ToolkitTestApplication application;
604 tet_infoline("UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask02 for GPU Alpha Masking");
605 TestGlAbstraction& gl = application.GetGlAbstraction();
608 Property::Map propertyMap;
609 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
610 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
611 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
612 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
613 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
614 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
615 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
616 propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
617 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
618 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
620 VisualFactory factory = VisualFactory::Get();
621 Visual::Base visual = factory.CreateVisual(propertyMap);
623 Property::Map testMap;
624 visual.CreatePropertyMap(testMap);
625 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
627 DummyControl dummyControl = DummyControl::New(true);
628 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
629 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
631 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
632 application.GetScene().Add(dummyControl);
634 TraceCallStack& textureTrace = gl.GetTextureTrace();
635 textureTrace.Enable(true);
637 application.SendNotification();
638 application.Render(20);
640 // The first frame is loaded synchronously and load next batch with masking
641 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
643 application.SendNotification();
644 application.Render();
646 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
647 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
649 dummyControl.Unparent();
651 tet_infoline("Test that removing the visual from stage deletes all textures");
652 application.SendNotification();
653 application.Render(16);
654 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
659 int UtcDaliAnimatedImageVisualJumpToAction(void)
661 ToolkitTestApplication application;
662 TestGlAbstraction& gl = application.GetGlAbstraction();
664 Property::Array urls;
665 CopyUrlsIntoArray(urls);
668 Property::Map propertyMap;
669 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
670 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
671 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
672 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 12);
673 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
675 VisualFactory factory = VisualFactory::Get();
676 Visual::Base visual = factory.CreateVisual(propertyMap);
678 DummyControl dummyControl = DummyControl::New(true);
679 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
680 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
682 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
683 application.GetScene().Add(dummyControl);
684 application.SendNotification();
685 application.Render(20);
687 tet_infoline("Ready the visual after the visual is on stage");
688 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
690 tet_infoline("Test that a timer has been started");
691 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
693 TraceCallStack& textureTrace = gl.GetTextureTrace();
694 textureTrace.Enable(true);
696 application.SendNotification();
697 application.Render(20);
699 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
701 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map());
703 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
705 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 20);
707 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
709 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 6);
711 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(6), true, TEST_LOCATION);
712 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
714 dummyControl.Unparent();
716 tet_infoline("Test that removing the visual from stage deletes all textures");
717 application.SendNotification();
718 application.Render(16);
719 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
724 int UtcDaliAnimatedImageVisualStopBehavior(void)
726 ToolkitTestApplication application;
727 TestGlAbstraction& gl = application.GetGlAbstraction();
729 Property::Array urls;
730 CopyUrlsIntoArray(urls);
733 Property::Map propertyMap;
734 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
735 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
736 propertyMap.Insert(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
737 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
738 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 8);
739 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
741 VisualFactory factory = VisualFactory::Get();
742 Visual::Base visual = factory.CreateVisual(propertyMap);
744 // Expect that a batch of 4 textures has been requested. These will be serially loaded
747 DummyControl dummyControl = DummyControl::New(true);
748 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
749 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
751 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
752 application.GetScene().Add(dummyControl);
753 application.SendNotification();
754 application.Render(20);
756 tet_infoline("Ready the visual after the visual is on stage");
757 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
759 tet_infoline("Test that a timer has been started");
760 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
762 TraceCallStack& textureTrace = gl.GetTextureTrace();
763 textureTrace.Enable(true);
765 application.SendNotification();
766 application.Render(20);
768 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
770 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map());
772 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
774 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 1);
776 // Expect the second batch has been requested
777 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
779 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
781 dummyControl.Unparent();
783 tet_infoline("Test that removing the visual from stage deletes all textures");
784 application.SendNotification();
785 application.Render(16);
786 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
791 int UtcDaliAnimatedImageVisualStopBehavior02(void)
793 ToolkitTestApplication application;
794 TestGlAbstraction& gl = application.GetGlAbstraction();
796 Property::Array urls;
797 CopyUrlsIntoArray(urls);
800 Property::Map propertyMap;
801 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
802 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
803 propertyMap.Insert(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
804 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
805 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
806 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
808 VisualFactory factory = VisualFactory::Get();
809 Visual::Base visual = factory.CreateVisual(propertyMap);
811 // Expect that a batch of 4 textures has been requested. These will be serially loaded
814 DummyControl dummyControl = DummyControl::New(true);
815 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
816 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
818 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
819 application.GetScene().Add(dummyControl);
821 tet_infoline("Ready the visual after the visual is on stage");
822 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
824 TraceCallStack& textureTrace = gl.GetTextureTrace();
825 textureTrace.Enable(true);
827 application.SendNotification();
828 application.Render(20);
830 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 2, TEST_LOCATION);
832 Test::EmitGlobalTimerSignal();
834 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
836 application.SendNotification();
837 application.Render(20);
839 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
841 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map());
843 tet_infoline("Ready the visual after the visual is on stage");
844 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
846 application.SendNotification();
847 application.Render(20);
849 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
851 dummyControl.Unparent();
853 tet_infoline("Test that removing the visual from stage deletes all textures");
854 application.SendNotification();
855 application.Render(16);
856 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
861 int UtcDaliAnimatedImageVisualAnimatedImage01(void)
863 ToolkitTestApplication application;
864 TestGlAbstraction& gl = application.GetGlAbstraction();
866 tet_infoline("Set cache size same as GIF frame, and try to load same image at another ImageView");
868 Property::Map propertyMap;
869 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
870 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
871 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
872 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 4);
873 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
875 VisualFactory factory = VisualFactory::Get();
876 Visual::Base visual = factory.CreateVisual(propertyMap);
878 // Expect that a batch of 4 textures has been requested. These will be serially loaded
881 DummyControl dummyControl = DummyControl::New(true);
882 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
883 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
885 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
886 application.GetScene().Add(dummyControl);
888 application.SendNotification();
889 application.Render();
891 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
893 // Batch 2 frames. Now frame 0, 1 cached.
894 application.SendNotification();
895 application.Render(20);
897 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 2, TEST_LOCATION);
899 tet_infoline("Test that a timer has been started");
901 TraceCallStack& textureTrace = gl.GetTextureTrace();
902 textureTrace.Enable(true);
904 Test::EmitGlobalTimerSignal();
906 application.SendNotification();
907 application.Render();
909 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
911 // 0 frame removed. and after, batch 2 frames. Now frame 1, 2, 3 cached.
912 application.SendNotification();
913 application.Render(20);
915 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
917 Visual::Base visual2 = factory.CreateVisual(propertyMap);
918 DummyControl dummyControl2 = DummyControl::New(true);
919 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl2.GetImplementation());
920 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
921 application.GetScene().Add(dummyControl2);
923 tet_infoline("Add new view with same url");
925 application.SendNotification();
926 application.Render();
928 // Note that we only re-load 0 frame.
929 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
931 tet_infoline("Test that we don't try to re-load new image cause it cached");
932 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
934 // Batch 2 frames. Now visual frame 1, 2, 3 cached and visual2 frame 0, 1 cached.
935 application.SendNotification();
936 application.Render(20);
938 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 5, TEST_LOCATION);
940 textureTrace.Reset();
942 tet_infoline("Load some many frames");
944 const int repeatCount = 10;
945 for(int repeat = 0; repeat < repeatCount; ++repeat)
947 Test::EmitGlobalTimerSignal();
948 application.SendNotification();
949 application.Render(2000);
952 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // A new texture should NOT be generated.
953 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 5, TEST_LOCATION);
955 textureTrace.Reset();
957 dummyControl.Unparent();
958 dummyControl2.Unparent();
960 tet_infoline("Test that removing the visual from stage deletes all textures");
961 application.SendNotification();
962 application.Render(20);
963 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
968 int UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask01(void)
970 ToolkitTestApplication application;
971 tet_infoline("UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask01 for CPU Alpha Masking");
972 TestGlAbstraction& gl = application.GetGlAbstraction();
975 Property::Map propertyMap;
976 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
977 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
978 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
979 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 4);
980 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
981 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
983 VisualFactory factory = VisualFactory::Get();
984 Visual::Base visual = factory.CreateVisual(propertyMap);
986 DummyControl dummyControl = DummyControl::New(true);
987 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
988 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
990 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
991 application.GetScene().Add(dummyControl);
993 application.SendNotification();
994 application.Render();
996 // load two frame(batch size), load mask image, and request two masking
997 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(5), true, TEST_LOCATION);
999 application.SendNotification();
1000 application.Render(20);
1002 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 2, TEST_LOCATION);
1004 dummyControl.Unparent();
1006 tet_infoline("Test that removing the visual from stage deletes all textures");
1007 application.SendNotification();
1008 application.Render(20);
1009 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1014 int UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask02(void)
1016 ToolkitTestApplication application;
1017 tet_infoline("UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask02 for GPU Alpha Masking");
1018 TestGlAbstraction& gl = application.GetGlAbstraction();
1021 Property::Map propertyMap;
1022 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
1023 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
1024 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
1025 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 4);
1026 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
1027 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
1028 propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
1030 VisualFactory factory = VisualFactory::Get();
1031 Visual::Base visual = factory.CreateVisual(propertyMap);
1033 DummyControl dummyControl = DummyControl::New(true);
1034 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1035 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1037 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1038 application.GetScene().Add(dummyControl);
1040 application.SendNotification();
1041 application.Render();
1043 // load two frame(batch size), load mask image, and request two masking
1044 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1046 application.SendNotification();
1047 application.Render(20);
1049 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 3, TEST_LOCATION);
1051 dummyControl.Unparent();
1053 tet_infoline("Test that removing the visual from stage deletes all textures");
1054 application.SendNotification();
1055 application.Render(20);
1056 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1061 int UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask03(void)
1063 ToolkitTestApplication application;
1064 tet_infoline("UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask03 for GPU Alpha Masking with broken mask texture");
1065 TestGlAbstraction& gl = application.GetGlAbstraction();
1068 Property::Map propertyMap;
1069 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
1070 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
1071 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
1072 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 4);
1073 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
1074 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, "");
1075 propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
1077 VisualFactory factory = VisualFactory::Get();
1078 Visual::Base visual = factory.CreateVisual(propertyMap);
1080 DummyControl dummyControl = DummyControl::New(true);
1081 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1082 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1084 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1085 application.GetScene().Add(dummyControl);
1087 application.SendNotification();
1088 application.Render();
1090 // load two frame(batch size), load mask image, and request two masking
1091 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1093 application.SendNotification();
1094 application.Render(20);
1096 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 3, TEST_LOCATION);
1098 dummyControl.Unparent();
1100 tet_infoline("Test that removing the visual from stage deletes all textures");
1101 application.SendNotification();
1102 application.Render(20);
1103 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1108 int UtcDaliAnimatedImageVisualMultiImage01(void)
1110 ToolkitTestApplication application;
1111 TestGlAbstraction& gl = application.GetGlAbstraction();
1113 Property::Array urls;
1114 CopyUrlsIntoArray(urls);
1117 Property::Map propertyMap;
1118 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1119 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1120 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
1121 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 8);
1122 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1124 VisualFactory factory = VisualFactory::Get();
1125 Visual::Base visual = factory.CreateVisual(propertyMap);
1127 // Expect that a batch of 4 textures has been requested. These will be serially loaded
1130 DummyControl dummyControl = DummyControl::New(true);
1131 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1132 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1134 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1135 application.GetScene().Add(dummyControl);
1136 application.SendNotification();
1137 application.Render(16);
1139 tet_infoline("Ready the visual after the visual is on stage");
1140 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1142 tet_infoline("Test that a timer has been started");
1143 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1145 TraceCallStack& textureTrace = gl.GetTextureTrace();
1146 textureTrace.Enable(true);
1148 application.SendNotification();
1149 application.Render(16);
1151 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
1152 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1154 tet_infoline("Test that after 1 tick, and file loads completed, that we have 7 textures");
1155 Test::EmitGlobalTimerSignal();
1157 // Expect the second batch has been requested
1158 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1160 application.SendNotification();
1161 application.Render(16);
1162 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
1164 tet_infoline("Test that after 2 ticks that we have 6 textures");
1166 Test::EmitGlobalTimerSignal();
1167 application.SendNotification();
1168 application.Render(16);
1169 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 6, TEST_LOCATION);
1171 tet_infoline("And that at least 2 textures were requested");
1172 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1173 application.SendNotification();
1174 application.Render(16);
1175 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 8, TEST_LOCATION);
1177 tet_infoline("Test that after 3rd tick that we have 7 textures and 1 request");
1178 Test::EmitGlobalTimerSignal();
1179 application.SendNotification();
1180 application.Render(16);
1181 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
1183 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1184 application.SendNotification();
1185 application.Render(16);
1186 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 8, TEST_LOCATION);
1188 dummyControl.Unparent();
1190 tet_infoline("Test that removing the visual from stage deletes all textures");
1191 application.SendNotification();
1192 application.Render(16);
1193 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1198 int UtcDaliAnimatedImageVisualMultiImage02(void)
1200 ToolkitTestApplication application;
1201 TestGlAbstraction& gl = application.GetGlAbstraction();
1203 tet_infoline("Test that the animated visual has different batch and cache size.");
1206 Property::Array urls;
1207 CopyUrlsIntoArray(urls);
1209 Property::Map propertyMap;
1210 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1211 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1212 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 0);
1213 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 0);
1214 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1216 VisualFactory factory = VisualFactory::Get();
1217 Visual::Base visual = factory.CreateVisual(propertyMap); // TexMgr::Request load tId:0
1219 // Check the batch size and cache size need to have minimum 2.
1220 Property::Map resultMap;
1221 visual.CreatePropertyMap(resultMap);
1222 Property::Value* value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, "batchSize");
1223 DALI_TEST_CHECK(value);
1224 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1225 value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, "cacheSize");
1226 DALI_TEST_CHECK(value);
1227 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1230 // Batch size is 2 and cache size is 3
1231 propertyMap.Clear();
1232 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1233 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1234 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
1235 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 3);
1236 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1238 visual = factory.CreateVisual(propertyMap); // TexMgr::Request load tId:0
1240 // Expect that each image is loaded each tick
1241 DummyControl dummyControl = DummyControl::New(true);
1242 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1243 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1246 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1247 application.GetScene().Add(dummyControl);
1248 application.SendNotification();
1249 application.Render(16);
1251 tet_infoline("Ready the visual after the visual is on window");
1252 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1253 application.SendNotification();
1254 application.Render(16); //glGenTextures 1 and 2
1255 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
1257 tet_infoline("Test that each tick, a new image is requested");
1258 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
1259 application.SendNotification();
1260 application.Render(16);
1261 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1262 application.SendNotification();
1263 application.Render(16); //glGenTextures 3
1264 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1266 tet_infoline("Test that each tick, a new image is requested");
1267 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:1
1268 application.SendNotification();
1269 application.Render(16);
1270 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1271 application.SendNotification();
1272 application.Render(16); //glGenTextures 4
1273 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1275 dummyImpl1.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1276 dummyControl.Unparent();
1278 // Batch size is 9 and cache size is 4
1279 propertyMap.Clear();
1280 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1281 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1282 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 3);
1283 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 7);
1284 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1286 visual = factory.CreateVisual(propertyMap); // TexMgr::Request load tId:0
1288 // Expect that each image is loaded each tick
1289 dummyControl = DummyControl::New(true);
1290 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1291 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1294 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1295 application.GetScene().Add(dummyControl);
1296 application.SendNotification();
1297 application.Render(16);
1299 tet_infoline("Ready the visual after the visual is on window");
1300 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1301 application.SendNotification();
1302 application.Render(16); //glGenTextures 1, 2, and 3
1303 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1305 tet_infoline("Test that each tick, a new image is requested");
1306 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
1307 application.SendNotification();
1308 application.Render(16);
1309 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1310 application.SendNotification();
1311 application.Render(16); //glGenTextures 4, 5, and 6
1312 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 5, TEST_LOCATION);
1314 tet_infoline("Test that each tick, a new image is requested");
1315 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:1
1316 application.SendNotification();
1317 application.Render(16);
1318 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1319 application.SendNotification();
1320 application.Render(16); //glGenTextures 7, 1, and 2
1321 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
1323 tet_infoline("Test that each tick, a new image is requested");
1324 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:2
1325 application.SendNotification();
1326 application.Render(16);
1327 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1328 application.SendNotification();
1329 application.Render(16); //glGenTextures 3
1330 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
1332 dummyControl.Unparent();
1334 tet_infoline("Test that removing the visual from window deletes all textures");
1335 application.SendNotification();
1336 application.Render(16);
1337 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1342 int UtcDaliAnimatedImageVisualMultiImage03(void)
1344 ToolkitTestApplication application;
1345 TestGlAbstraction& gl = application.GetGlAbstraction();
1348 Property::Array urls1, urls2;
1349 CopyUrlsIntoArray(urls1);
1350 CopyUrlsIntoArray(urls2);
1352 Property::Map animatedImageMap1;
1353 animatedImageMap1.Insert(Visual::Property::TYPE, Visual::IMAGE);
1354 animatedImageMap1.Insert(ImageVisual::Property::URL, Property::Value(urls1));
1355 animatedImageMap1.Insert(ImageVisual::Property::BATCH_SIZE, 3);
1356 animatedImageMap1.Insert(ImageVisual::Property::CACHE_SIZE, 3);
1357 animatedImageMap1.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1359 Property::Map animatedImageMap2;
1360 animatedImageMap2.Insert(Visual::Property::TYPE, Visual::IMAGE);
1361 animatedImageMap2.Insert(ImageVisual::Property::URL, Property::Value(urls2));
1362 animatedImageMap2.Insert(ImageVisual::Property::BATCH_SIZE, 2);
1363 animatedImageMap2.Insert(ImageVisual::Property::CACHE_SIZE, 2);
1364 animatedImageMap2.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1366 VisualFactory factory = VisualFactory::Get();
1367 Visual::Base animatedImageVisual1 = factory.CreateVisual(animatedImageMap1);
1369 tet_infoline("Create two image views with the same URLs, offset by 1 frame.");
1371 DummyControl dummyControl1 = DummyControl::New(true);
1372 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl1.GetImplementation());
1373 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual1);
1374 dummyControl1.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1375 application.GetScene().Add(dummyControl1);
1377 application.SendNotification();
1378 application.Render(16);
1380 tet_infoline("Ready the requested image after the first visual is on stage");
1381 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1382 application.SendNotification();
1383 application.Render(16);
1384 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1386 Visual::Base animatedImageVisual2 = factory.CreateVisual(animatedImageMap2);
1387 DummyControl dummyControl2 = DummyControl::New(true);
1388 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl2.GetImplementation());
1389 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual2);
1390 dummyControl2.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1391 application.GetScene().Add(dummyControl2);
1392 application.SendNotification();
1393 application.Render(16);
1395 tet_infoline("The texture cache should be holding the requested images; check that the renderer has a texture");
1396 TextureSet ts = dummyControl2.GetRendererAt(0).GetTextures();
1397 Texture t1 = ts.GetTexture(0);
1398 DALI_TEST_EQUALS(ts.GetTextureCount(), 1, TEST_LOCATION);
1400 tet_infoline("Test that on the first tick, 1 new image is requested");
1401 Test::EmitGlobalTimerSignal(); // Both visuals should tick
1403 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1404 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1406 ts = dummyControl2.GetRendererAt(0).GetTextures();
1407 Texture t2 = ts.GetTexture(0);
1408 DALI_TEST_CHECK(t1 != t2);
1410 dummyControl1.Unparent();
1411 dummyControl2.Unparent();
1413 tet_infoline("Test that removing the visual from stage deletes all textures");
1414 application.SendNotification();
1415 application.Render(16);
1416 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1421 int UtcDaliAnimatedImageVisualMultiImage04(void)
1423 ToolkitTestApplication application;
1424 TestGlAbstraction& gl = application.GetGlAbstraction();
1425 TraceCallStack& textureTrace = gl.GetTextureTrace();
1426 textureTrace.Enable(true);
1428 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");
1430 Property::Array urls;
1431 CopyUrlsIntoArray(urls);
1434 Property::Map propertyMap;
1435 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1436 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1437 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 6);
1438 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 11);
1439 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1441 VisualFactory factory = VisualFactory::Get();
1442 Visual::Base visual = factory.CreateVisual(propertyMap);
1444 tet_infoline("Expect that a batch of 7 textures has been requested.");
1446 DummyControl dummyControl = DummyControl::New(true);
1447 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1448 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1450 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1451 application.GetScene().Add(dummyControl);
1452 application.SendNotification();
1453 application.Render(16);
1455 tet_infoline("Wait for the first batch to complete");
1456 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(6), true, TEST_LOCATION);
1458 tet_infoline("Test that a timer has been started");
1459 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1461 application.SendNotification();
1462 application.Render(16);
1464 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 6, TEST_LOCATION);
1465 tet_infoline("Test that after 1 tick, and 5 file loads completed, that we have 11 textures");
1466 Test::EmitGlobalTimerSignal();
1467 application.SendNotification();
1468 application.Render(16);
1470 // Expect the second batch has been requested
1471 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(5), true, TEST_LOCATION);
1473 application.SendNotification();
1474 application.Render(16);
1475 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 11, TEST_LOCATION);
1477 tet_infoline("Test that after 2 ticks that we have 11 textures and no requests");
1479 Test::EmitGlobalTimerSignal();
1480 application.SendNotification();
1481 application.Render(16);
1482 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 5), false, TEST_LOCATION);
1483 application.SendNotification();
1484 application.Render(16);
1485 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 11, TEST_LOCATION);
1487 tet_infoline("Test that after 3rd tick that we have 11 textures and no requests");
1488 Test::EmitGlobalTimerSignal();
1489 application.SendNotification();
1490 application.Render(16);
1492 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 5), false, TEST_LOCATION);
1493 application.SendNotification();
1494 application.Render(16);
1495 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 11, TEST_LOCATION);
1497 dummyControl.Unparent();
1500 tet_infoline("Test that removing the visual from stage deletes all textures");
1501 application.SendNotification();
1502 application.Render(16);
1503 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1508 int UtcDaliAnimatedImageVisualMultiImage05(void)
1510 ToolkitTestApplication application;
1511 TestGlAbstraction& gl = application.GetGlAbstraction();
1513 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");
1515 Property::Array urls;
1516 CopyUrlsIntoArray(urls);
1519 Property::Map propertyMap;
1520 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1521 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1522 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
1523 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 11);
1524 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1526 VisualFactory factory = VisualFactory::Get();
1527 Visual::Base visual = factory.CreateVisual(propertyMap);
1529 tet_infoline("Expect that a batch of 4 textures has been requested.");
1531 DummyControl dummyControl = DummyControl::New(true);
1532 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1533 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1535 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1536 application.GetScene().Add(dummyControl);
1537 application.SendNotification();
1538 application.Render(16);
1540 tet_infoline("Wait for the first batch to complete");
1541 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1543 tet_infoline("Test that a timer has been started");
1544 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1546 application.SendNotification();
1547 application.Render(16);
1549 tet_infoline("Test that a timer has been started");
1550 Test::EmitGlobalTimerSignal();
1551 application.SendNotification();
1552 application.Render(16);
1554 dummyControl.Unparent();
1557 application.SendNotification();
1558 application.Render(16);
1559 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1561 tet_infoline("Test that pending batch of image loads are cancelled instead of uploaded");
1562 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1563 application.SendNotification();
1564 application.Render(16);
1565 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1570 void TestLoopCount(ToolkitTestApplication& application, DummyControl& dummyControl, uint16_t frameCount, uint16_t loopCount, const char* location)
1572 TestGlAbstraction& gl = application.GetGlAbstraction();
1573 TraceCallStack& textureTrace = gl.GetTextureTrace();
1575 textureTrace.Enable(true);
1576 application.GetScene().Add(dummyControl);
1578 application.SendNotification();
1579 application.Render(16);
1581 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_INNER_LOCATION(location));
1583 application.SendNotification();
1584 application.Render();
1586 tet_infoline("Test that a timer has been created");
1587 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_INNER_LOCATION(location));
1589 for(uint16_t i = 0; i < loopCount; i++)
1591 for(uint16_t j = 0; j < frameCount; j++)
1593 if(i == 0 && j == 0)
1595 continue; // Because first frame is already showed and we call 2nd frame at the first time of timer animation.
1597 tet_printf("Test that after %u ticks, and we have %u frame \n", j + 1u, j + 1u);
1598 Test::EmitGlobalTimerSignal();
1599 application.SendNotification();
1600 application.Render(16);
1602 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_INNER_LOCATION(location));
1604 application.SendNotification();
1605 application.Render();
1606 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_INNER_LOCATION(location));
1607 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_INNER_LOCATION(location));
1609 tet_printf("Test Loop %u \n\n", i + 1u);
1612 tet_printf("Test that after %u loops, and we have no frame. Timer should stop \n", loopCount);
1613 Test::EmitGlobalTimerSignal();
1614 application.SendNotification();
1615 application.Render(16);
1616 DALI_TEST_EQUALS(Test::AreTimersRunning(), false, TEST_INNER_LOCATION(location));
1618 dummyControl.Unparent();
1621 int UtcDaliAnimatedImageVisualLoopCount(void)
1623 ToolkitTestApplication application;
1625 tet_infoline("UtcDaliAnimatedImageVisualLoopCount");
1628 // request AnimatedImageVisual with a property map
1629 // Test with no (0) loop count
1630 VisualFactory factory = VisualFactory::Get();
1631 Visual::Base animatedImageVisual = factory.CreateVisual(
1633 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1634 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1635 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1636 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1637 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1638 .Add(DevelImageVisual::Property::LOOP_COUNT, 0));
1640 DummyControl dummyControl = DummyControl::New(true);
1641 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1642 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1643 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1645 TestLoopCount(application, dummyControl, 4, 0, TEST_LOCATION);
1647 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1648 animatedImageVisual.Reset();
1650 application.SendNotification();
1651 application.Render(16);
1653 // Test with no (1) loop count. Request AnimatedImageVisual with a property map
1654 animatedImageVisual = factory.CreateVisual(
1656 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1657 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1658 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1659 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1660 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1661 .Add(DevelImageVisual::Property::LOOP_COUNT, 1));
1663 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1665 TestLoopCount(application, dummyControl, 4, 1, TEST_LOCATION);
1667 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1668 animatedImageVisual.Reset();
1670 application.SendNotification();
1671 application.Render(16);
1673 // Test with no (100) loop count. Request AnimatedImageVisual with a property map
1674 animatedImageVisual = factory.CreateVisual(
1676 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1677 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1678 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1679 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1680 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1681 .Add(DevelImageVisual::Property::LOOP_COUNT, 100));
1683 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1685 TestLoopCount(application, dummyControl, 4, 100, TEST_LOCATION);
1690 int UtcDaliAnimatedImageVisualPlayback(void)
1692 ToolkitTestApplication application;
1693 TestGlAbstraction& gl = application.GetGlAbstraction();
1694 TraceCallStack& textureTrace = gl.GetTextureTrace();
1696 tet_infoline("UtcDaliAnimatedImageVisualPlayback");
1699 // request AnimatedImageVisual with a property map
1700 // Test with forever (-1) loop count
1701 VisualFactory factory = VisualFactory::Get();
1702 Visual::Base animatedImageVisual = factory.CreateVisual(
1704 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1705 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1706 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1707 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1708 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1709 .Add(DevelImageVisual::Property::LOOP_COUNT, -1));
1711 DummyControl dummyControl = DummyControl::New(true);
1712 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1713 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1714 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1716 textureTrace.Enable(true);
1717 application.GetScene().Add(dummyControl);
1718 application.SendNotification();
1719 application.Render(16);
1721 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1723 application.SendNotification();
1724 application.Render();
1726 tet_infoline("Test that a timer has been created");
1727 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1729 Test::EmitGlobalTimerSignal();
1730 application.SendNotification();
1731 application.Render(16);
1733 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1735 application.SendNotification();
1736 application.Render();
1737 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_LOCATION);
1739 Property::Map attributes;
1740 tet_infoline("Test Pause action. Timer should stop after Pause action");
1741 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PAUSE, attributes);
1742 Test::EmitGlobalTimerSignal();
1743 application.SendNotification();
1744 application.Render(16);
1745 DALI_TEST_EQUALS(Test::AreTimersRunning(), false, TEST_LOCATION);
1747 tet_infoline("Test Play action. Timer should Restart after Play action");
1748 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes);
1749 Test::EmitGlobalTimerSignal();
1750 application.SendNotification();
1751 application.Render(16);
1753 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1755 application.SendNotification();
1756 application.Render();
1757 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_LOCATION);
1759 tet_infoline("Test Stop action. Timer should stop after Stop action");
1760 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, attributes);
1761 Test::EmitGlobalTimerSignal();
1762 application.SendNotification();
1763 application.Render(16);
1764 DALI_TEST_EQUALS(Test::AreTimersRunning(), false, TEST_LOCATION);
1766 tet_infoline("Test Play action. Timer should Restart after Play action");
1767 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes);
1768 Test::EmitGlobalTimerSignal();
1769 application.SendNotification();
1770 application.Render(16);
1772 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1774 application.SendNotification();
1775 application.Render();
1776 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_LOCATION);
1778 dummyControl.Unparent();
1784 int UtcDaliAnimatedImageVisualWrapMode(void)
1786 ToolkitTestApplication application;
1787 tet_infoline("UtcDaliAnimatedImageVisualWrapMode");
1789 VisualFactory factory = VisualFactory::Get();
1790 DALI_TEST_CHECK(factory);
1792 // Test wrap mode in animated image visual.
1793 const int width = 950;
1794 const int height = 1080;
1795 const Vector4 pixelArea(0.0f, 0.0f, 950/ 40, 1.0f);
1797 Property::Map propertyMap;
1798 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1799 propertyMap.Insert(ImageVisual::Property::URL, TEST_WEBP_FILE_NAME);
1800 propertyMap.Insert(ImageVisual::Property::PIXEL_AREA, pixelArea);
1801 propertyMap.Insert(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT);
1803 Visual::Base visual = factory.CreateVisual(propertyMap);
1804 DALI_TEST_CHECK(visual);
1806 TestGlAbstraction& gl = application.GetGlAbstraction();
1807 TraceCallStack& textureTrace = gl.GetTextureTrace();
1808 textureTrace.Enable(true);
1809 textureTrace.EnableLogging(true);
1810 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
1811 texParameterTrace.Enable(true);
1812 texParameterTrace.EnableLogging(true);
1814 DummyControl actor = DummyControl::New();
1815 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1816 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
1817 actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
1818 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1820 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1821 application.GetScene().Add(actor);
1822 application.SendNotification();
1823 application.Render();
1825 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1827 application.SendNotification();
1828 application.Render();
1830 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1832 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1834 // WITHOUT atlasing, the wrapping is handled by setting gl texture parameters
1835 std::stringstream out;
1836 out << std::hex << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_REPEAT;
1837 DALI_TEST_CHECK(texParameterTrace.FindMethodAndParams("TexParameteri", out.str()));
1839 // test the uniforms which used to handle the wrap mode
1840 Renderer renderer = actor.GetRendererAt(0u);
1841 DALI_TEST_CHECK(renderer);
1843 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
1844 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION);
1847 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);