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);
529 int UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask(void)
531 ToolkitTestApplication application;
532 TestGlAbstraction& gl = application.GetGlAbstraction();
535 Property::Map propertyMap;
536 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
537 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
538 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
539 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
540 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
541 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
542 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
543 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
544 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
546 VisualFactory factory = VisualFactory::Get();
547 Visual::Base visual = factory.CreateVisual(propertyMap);
549 Property::Map testMap;
550 visual.CreatePropertyMap(testMap);
551 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
553 DummyControl dummyControl = DummyControl::New(true);
554 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
555 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
557 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
558 application.GetScene().Add(dummyControl);
560 TraceCallStack& textureTrace = gl.GetTextureTrace();
561 textureTrace.Enable(true);
563 application.SendNotification();
564 application.Render(20);
566 // The first frame is loaded synchronously and load next batch with masking
567 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
569 application.SendNotification();
570 application.Render();
572 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
573 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
575 dummyControl.Unparent();
577 tet_infoline("Test that removing the visual from stage deletes all textures");
578 application.SendNotification();
579 application.Render(16);
580 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
585 int UtcDaliAnimatedImageVisualJumpToAction(void)
587 ToolkitTestApplication application;
588 TestGlAbstraction& gl = application.GetGlAbstraction();
590 Property::Array urls;
591 CopyUrlsIntoArray(urls);
594 Property::Map propertyMap;
595 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
596 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
597 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
598 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 12);
599 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
601 VisualFactory factory = VisualFactory::Get();
602 Visual::Base visual = factory.CreateVisual(propertyMap);
604 DummyControl dummyControl = DummyControl::New(true);
605 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
606 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
608 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
609 application.GetScene().Add(dummyControl);
610 application.SendNotification();
611 application.Render(20);
613 tet_infoline("Ready the visual after the visual is on stage");
614 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
616 tet_infoline("Test that a timer has been started");
617 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
619 TraceCallStack& textureTrace = gl.GetTextureTrace();
620 textureTrace.Enable(true);
622 application.SendNotification();
623 application.Render(20);
625 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
627 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map());
629 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
631 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 20);
633 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
635 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 6);
637 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(6), true, TEST_LOCATION);
638 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
640 dummyControl.Unparent();
642 tet_infoline("Test that removing the visual from stage deletes all textures");
643 application.SendNotification();
644 application.Render(16);
645 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
650 int UtcDaliAnimatedImageVisualStopBehavior(void)
652 ToolkitTestApplication application;
653 TestGlAbstraction& gl = application.GetGlAbstraction();
655 Property::Array urls;
656 CopyUrlsIntoArray(urls);
659 Property::Map propertyMap;
660 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
661 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
662 propertyMap.Insert(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
663 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
664 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 8);
665 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
667 VisualFactory factory = VisualFactory::Get();
668 Visual::Base visual = factory.CreateVisual(propertyMap);
670 // Expect that a batch of 4 textures has been requested. These will be serially loaded
673 DummyControl dummyControl = DummyControl::New(true);
674 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
675 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
677 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
678 application.GetScene().Add(dummyControl);
679 application.SendNotification();
680 application.Render(20);
682 tet_infoline("Ready the visual after the visual is on stage");
683 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
685 tet_infoline("Test that a timer has been started");
686 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
688 TraceCallStack& textureTrace = gl.GetTextureTrace();
689 textureTrace.Enable(true);
691 application.SendNotification();
692 application.Render(20);
694 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
696 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map());
698 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
700 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 1);
702 // Expect the second batch has been requested
703 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
705 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
707 dummyControl.Unparent();
709 tet_infoline("Test that removing the visual from stage deletes all textures");
710 application.SendNotification();
711 application.Render(16);
712 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
717 int UtcDaliAnimatedImageVisualStopBehavior02(void)
719 ToolkitTestApplication application;
720 TestGlAbstraction& gl = application.GetGlAbstraction();
722 Property::Array urls;
723 CopyUrlsIntoArray(urls);
726 Property::Map propertyMap;
727 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
728 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
729 propertyMap.Insert(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
730 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
731 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
732 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
734 VisualFactory factory = VisualFactory::Get();
735 Visual::Base visual = factory.CreateVisual(propertyMap);
737 // Expect that a batch of 4 textures has been requested. These will be serially loaded
740 DummyControl dummyControl = DummyControl::New(true);
741 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
742 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
744 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
745 application.GetScene().Add(dummyControl);
747 tet_infoline("Ready the visual after the visual is on stage");
748 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
750 TraceCallStack& textureTrace = gl.GetTextureTrace();
751 textureTrace.Enable(true);
753 application.SendNotification();
754 application.Render(20);
756 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 2, TEST_LOCATION);
758 Test::EmitGlobalTimerSignal();
760 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
762 application.SendNotification();
763 application.Render(20);
765 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
767 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map());
769 tet_infoline("Ready the visual after the visual is on stage");
770 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
772 application.SendNotification();
773 application.Render(20);
775 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
777 dummyControl.Unparent();
779 tet_infoline("Test that removing the visual from stage deletes all textures");
780 application.SendNotification();
781 application.Render(16);
782 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
787 int UtcDaliAnimatedImageVisualAnimatedImage01(void)
789 ToolkitTestApplication application;
790 TestGlAbstraction& gl = application.GetGlAbstraction();
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 application.SendNotification();
819 application.Render(20);
821 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 2, TEST_LOCATION);
823 tet_infoline("Test that a timer has been started");
825 TraceCallStack& textureTrace = gl.GetTextureTrace();
826 textureTrace.Enable(true);
828 Test::EmitGlobalTimerSignal();
830 application.SendNotification();
831 application.Render();
833 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
835 application.SendNotification();
836 application.Render(20);
838 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
840 dummyControl.Unparent();
842 tet_infoline("Test that removing the visual from stage deletes all textures");
843 application.SendNotification();
844 application.Render(20);
845 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
850 int UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask01(void)
852 ToolkitTestApplication application;
853 TestGlAbstraction& gl = application.GetGlAbstraction();
856 Property::Map propertyMap;
857 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
858 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
859 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
860 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 4);
861 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
862 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
865 VisualFactory factory = VisualFactory::Get();
866 Visual::Base visual = factory.CreateVisual(propertyMap);
868 DummyControl dummyControl = DummyControl::New(true);
869 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
870 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
872 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
873 application.GetScene().Add(dummyControl);
875 application.SendNotification();
876 application.Render();
878 // load two frame(batch size), load mask image, and request two masking
879 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(5), true, TEST_LOCATION);
881 application.SendNotification();
882 application.Render(20);
884 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 2, TEST_LOCATION);
886 dummyControl.Unparent();
888 tet_infoline("Test that removing the visual from stage deletes all textures");
889 application.SendNotification();
890 application.Render(20);
891 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
896 int UtcDaliAnimatedImageVisualMultiImage01(void)
898 ToolkitTestApplication application;
899 TestGlAbstraction& gl = application.GetGlAbstraction();
901 Property::Array urls;
902 CopyUrlsIntoArray(urls);
905 Property::Map propertyMap;
906 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
907 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
908 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
909 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 8);
910 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
912 VisualFactory factory = VisualFactory::Get();
913 Visual::Base visual = factory.CreateVisual(propertyMap);
915 // Expect that a batch of 4 textures has been requested. These will be serially loaded
918 DummyControl dummyControl = DummyControl::New(true);
919 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
920 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
922 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
923 application.GetScene().Add(dummyControl);
924 application.SendNotification();
925 application.Render(16);
927 tet_infoline("Ready the visual after the visual is on stage");
928 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
930 tet_infoline("Test that a timer has been started");
931 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
933 TraceCallStack& textureTrace = gl.GetTextureTrace();
934 textureTrace.Enable(true);
936 application.SendNotification();
937 application.Render(16);
939 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
940 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
942 tet_infoline("Test that after 1 tick, and file loads completed, that we have 7 textures");
943 Test::EmitGlobalTimerSignal();
945 // Expect the second batch has been requested
946 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
948 application.SendNotification();
949 application.Render(16);
950 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
952 tet_infoline("Test that after 2 ticks that we have 6 textures");
954 Test::EmitGlobalTimerSignal();
955 application.SendNotification();
956 application.Render(16);
957 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 6, TEST_LOCATION);
959 tet_infoline("And that at least 2 textures were requested");
960 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
961 application.SendNotification();
962 application.Render(16);
963 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 8, TEST_LOCATION);
965 tet_infoline("Test that after 3rd tick that we have 7 textures and 1 request");
966 Test::EmitGlobalTimerSignal();
967 application.SendNotification();
968 application.Render(16);
969 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
971 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
972 application.SendNotification();
973 application.Render(16);
974 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 8, TEST_LOCATION);
976 dummyControl.Unparent();
978 tet_infoline("Test that removing the visual from stage deletes all textures");
979 application.SendNotification();
980 application.Render(16);
981 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
986 int UtcDaliAnimatedImageVisualMultiImage02(void)
988 ToolkitTestApplication application;
989 TestGlAbstraction& gl = application.GetGlAbstraction();
991 tet_infoline("Test that the animated visual has different batch and cache size.");
994 Property::Array urls;
995 CopyUrlsIntoArray(urls);
997 Property::Map propertyMap;
998 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
999 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1000 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 0);
1001 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 0);
1002 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1004 VisualFactory factory = VisualFactory::Get();
1005 Visual::Base visual = factory.CreateVisual(propertyMap); // TexMgr::Request load tId:0
1007 // Check the batch size and cache size need to have minimum 2.
1008 Property::Map resultMap;
1009 visual.CreatePropertyMap(resultMap);
1010 Property::Value* value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, "batchSize");
1011 DALI_TEST_CHECK(value);
1012 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1013 value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, "cacheSize");
1014 DALI_TEST_CHECK(value);
1015 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1018 // Batch size is 2 and cache size is 3
1019 propertyMap.Clear();
1020 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1021 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1022 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
1023 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 3);
1024 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1026 visual = factory.CreateVisual(propertyMap); // TexMgr::Request load tId:0
1028 // Expect that each image is loaded each tick
1029 DummyControl dummyControl = DummyControl::New(true);
1030 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1031 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1034 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1035 application.GetScene().Add(dummyControl);
1036 application.SendNotification();
1037 application.Render(16);
1039 tet_infoline("Ready the visual after the visual is on window");
1040 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1041 application.SendNotification();
1042 application.Render(16); //glGenTextures 1 and 2
1043 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
1045 tet_infoline("Test that each tick, a new image is requested");
1046 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
1047 application.SendNotification();
1048 application.Render(16);
1049 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1050 application.SendNotification();
1051 application.Render(16); //glGenTextures 3
1052 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1054 tet_infoline("Test that each tick, a new image is requested");
1055 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:1
1056 application.SendNotification();
1057 application.Render(16);
1058 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1059 application.SendNotification();
1060 application.Render(16); //glGenTextures 4
1061 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1063 dummyImpl1.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1064 dummyControl.Unparent();
1066 // Batch size is 9 and cache size is 4
1067 propertyMap.Clear();
1068 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1069 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1070 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 3);
1071 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 7);
1072 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1074 visual = factory.CreateVisual(propertyMap); // TexMgr::Request load tId:0
1076 // Expect that each image is loaded each tick
1077 dummyControl = DummyControl::New(true);
1078 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1079 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1082 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1083 application.GetScene().Add(dummyControl);
1084 application.SendNotification();
1085 application.Render(16);
1087 tet_infoline("Ready the visual after the visual is on window");
1088 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1089 application.SendNotification();
1090 application.Render(16); //glGenTextures 1, 2, and 3
1091 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1093 tet_infoline("Test that each tick, a new image is requested");
1094 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
1095 application.SendNotification();
1096 application.Render(16);
1097 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1098 application.SendNotification();
1099 application.Render(16); //glGenTextures 4, 5, and 6
1100 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 5, TEST_LOCATION);
1102 tet_infoline("Test that each tick, a new image is requested");
1103 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:1
1104 application.SendNotification();
1105 application.Render(16);
1106 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1107 application.SendNotification();
1108 application.Render(16); //glGenTextures 7, 1, and 2
1109 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
1111 tet_infoline("Test that each tick, a new image is requested");
1112 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:2
1113 application.SendNotification();
1114 application.Render(16);
1115 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1116 application.SendNotification();
1117 application.Render(16); //glGenTextures 3
1118 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
1120 dummyControl.Unparent();
1122 tet_infoline("Test that removing the visual from window deletes all textures");
1123 application.SendNotification();
1124 application.Render(16);
1125 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1130 int UtcDaliAnimatedImageVisualMultiImage03(void)
1132 ToolkitTestApplication application;
1133 TestGlAbstraction& gl = application.GetGlAbstraction();
1136 Property::Array urls1, urls2;
1137 CopyUrlsIntoArray(urls1);
1138 CopyUrlsIntoArray(urls2);
1140 Property::Map animatedImageMap1;
1141 animatedImageMap1.Insert(Visual::Property::TYPE, Visual::IMAGE);
1142 animatedImageMap1.Insert(ImageVisual::Property::URL, Property::Value(urls1));
1143 animatedImageMap1.Insert(ImageVisual::Property::BATCH_SIZE, 3);
1144 animatedImageMap1.Insert(ImageVisual::Property::CACHE_SIZE, 3);
1145 animatedImageMap1.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1147 Property::Map animatedImageMap2;
1148 animatedImageMap2.Insert(Visual::Property::TYPE, Visual::IMAGE);
1149 animatedImageMap2.Insert(ImageVisual::Property::URL, Property::Value(urls2));
1150 animatedImageMap2.Insert(ImageVisual::Property::BATCH_SIZE, 2);
1151 animatedImageMap2.Insert(ImageVisual::Property::CACHE_SIZE, 2);
1152 animatedImageMap2.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1154 VisualFactory factory = VisualFactory::Get();
1155 Visual::Base animatedImageVisual1 = factory.CreateVisual(animatedImageMap1);
1157 tet_infoline("Create two image views with the same URLs, offset by 1 frame.");
1159 DummyControl dummyControl1 = DummyControl::New(true);
1160 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl1.GetImplementation());
1161 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual1);
1162 dummyControl1.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1163 application.GetScene().Add(dummyControl1);
1165 application.SendNotification();
1166 application.Render(16);
1168 tet_infoline("Ready the requested image after the first visual is on stage");
1169 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1170 application.SendNotification();
1171 application.Render(16);
1172 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1174 Visual::Base animatedImageVisual2 = factory.CreateVisual(animatedImageMap2);
1175 DummyControl dummyControl2 = DummyControl::New(true);
1176 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl2.GetImplementation());
1177 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual2);
1178 dummyControl2.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1179 application.GetScene().Add(dummyControl2);
1180 application.SendNotification();
1181 application.Render(16);
1183 tet_infoline("The texture cache should be holding the requested images; check that the renderer has a texture");
1184 TextureSet ts = dummyControl2.GetRendererAt(0).GetTextures();
1185 Texture t1 = ts.GetTexture(0);
1186 DALI_TEST_EQUALS(ts.GetTextureCount(), 1, TEST_LOCATION);
1188 tet_infoline("Test that on the first tick, 1 new image is requested");
1189 Test::EmitGlobalTimerSignal(); // Both visuals should tick
1191 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1192 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1194 ts = dummyControl2.GetRendererAt(0).GetTextures();
1195 Texture t2 = ts.GetTexture(0);
1196 DALI_TEST_CHECK(t1 != t2);
1198 dummyControl1.Unparent();
1199 dummyControl2.Unparent();
1201 tet_infoline("Test that removing the visual from stage deletes all textures");
1202 application.SendNotification();
1203 application.Render(16);
1204 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1209 int UtcDaliAnimatedImageVisualMultiImage04(void)
1211 ToolkitTestApplication application;
1212 TestGlAbstraction& gl = application.GetGlAbstraction();
1213 TraceCallStack& textureTrace = gl.GetTextureTrace();
1214 textureTrace.Enable(true);
1216 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");
1218 Property::Array urls;
1219 CopyUrlsIntoArray(urls);
1222 Property::Map propertyMap;
1223 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1224 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1225 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 6);
1226 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 11);
1227 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1229 VisualFactory factory = VisualFactory::Get();
1230 Visual::Base visual = factory.CreateVisual(propertyMap);
1232 tet_infoline("Expect that a batch of 7 textures has been requested.");
1234 DummyControl dummyControl = DummyControl::New(true);
1235 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1236 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1238 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1239 application.GetScene().Add(dummyControl);
1240 application.SendNotification();
1241 application.Render(16);
1243 tet_infoline("Wait for the first batch to complete");
1244 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(6), true, TEST_LOCATION);
1246 tet_infoline("Test that a timer has been started");
1247 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1249 application.SendNotification();
1250 application.Render(16);
1252 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 6, TEST_LOCATION);
1253 tet_infoline("Test that after 1 tick, and 5 file loads completed, that we have 11 textures");
1254 Test::EmitGlobalTimerSignal();
1255 application.SendNotification();
1256 application.Render(16);
1258 // Expect the second batch has been requested
1259 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(5), true, TEST_LOCATION);
1261 application.SendNotification();
1262 application.Render(16);
1263 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 11, TEST_LOCATION);
1265 tet_infoline("Test that after 2 ticks that we have 11 textures and no requests");
1267 Test::EmitGlobalTimerSignal();
1268 application.SendNotification();
1269 application.Render(16);
1270 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 5), false, TEST_LOCATION);
1271 application.SendNotification();
1272 application.Render(16);
1273 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 11, TEST_LOCATION);
1275 tet_infoline("Test that after 3rd tick that we have 11 textures and no requests");
1276 Test::EmitGlobalTimerSignal();
1277 application.SendNotification();
1278 application.Render(16);
1280 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 5), false, TEST_LOCATION);
1281 application.SendNotification();
1282 application.Render(16);
1283 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 11, TEST_LOCATION);
1285 dummyControl.Unparent();
1288 tet_infoline("Test that removing the visual from stage deletes all textures");
1289 application.SendNotification();
1290 application.Render(16);
1291 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1296 int UtcDaliAnimatedImageVisualMultiImage05(void)
1298 ToolkitTestApplication application;
1299 TestGlAbstraction& gl = application.GetGlAbstraction();
1301 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");
1303 Property::Array urls;
1304 CopyUrlsIntoArray(urls);
1307 Property::Map propertyMap;
1308 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1309 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1310 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
1311 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 11);
1312 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1314 VisualFactory factory = VisualFactory::Get();
1315 Visual::Base visual = factory.CreateVisual(propertyMap);
1317 tet_infoline("Expect that a batch of 4 textures has been requested.");
1319 DummyControl dummyControl = DummyControl::New(true);
1320 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1321 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1323 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1324 application.GetScene().Add(dummyControl);
1325 application.SendNotification();
1326 application.Render(16);
1328 tet_infoline("Wait for the first batch to complete");
1329 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1331 tet_infoline("Test that a timer has been started");
1332 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1334 application.SendNotification();
1335 application.Render(16);
1337 tet_infoline("Test that a timer has been started");
1338 Test::EmitGlobalTimerSignal();
1339 application.SendNotification();
1340 application.Render(16);
1342 dummyControl.Unparent();
1345 application.SendNotification();
1346 application.Render(16);
1347 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1349 tet_infoline("Test that pending batch of image loads are cancelled instead of uploaded");
1350 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1351 application.SendNotification();
1352 application.Render(16);
1353 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1358 void TestLoopCount(ToolkitTestApplication& application, DummyControl& dummyControl, uint16_t frameCount, uint16_t loopCount, const char* location)
1360 TestGlAbstraction& gl = application.GetGlAbstraction();
1361 TraceCallStack& textureTrace = gl.GetTextureTrace();
1363 textureTrace.Enable(true);
1364 application.GetScene().Add(dummyControl);
1366 application.SendNotification();
1367 application.Render(16);
1369 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_INNER_LOCATION(location));
1371 application.SendNotification();
1372 application.Render();
1374 tet_infoline("Test that a timer has been created");
1375 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_INNER_LOCATION(location));
1377 for(uint16_t i = 0; i < loopCount; i++)
1379 for(uint16_t j = 0; j < frameCount; j++)
1381 if(i == 0 && j == 0)
1383 continue; // Because first frame is already showed and we call 2nd frame at the first time of timer animation.
1385 tet_printf("Test that after %u ticks, and we have %u frame \n", j + 1u, j + 1u);
1386 Test::EmitGlobalTimerSignal();
1387 application.SendNotification();
1388 application.Render(16);
1390 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_INNER_LOCATION(location));
1392 application.SendNotification();
1393 application.Render();
1394 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_INNER_LOCATION(location));
1395 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_INNER_LOCATION(location));
1397 tet_printf("Test Loop %u \n\n", i + 1u);
1400 tet_printf("Test that after %u loops, and we have no frame. Timer should stop \n", loopCount);
1401 Test::EmitGlobalTimerSignal();
1402 application.SendNotification();
1403 application.Render(16);
1404 DALI_TEST_EQUALS(Test::AreTimersRunning(), false, TEST_INNER_LOCATION(location));
1406 dummyControl.Unparent();
1409 int UtcDaliAnimatedImageVisualLoopCount(void)
1411 ToolkitTestApplication application;
1413 tet_infoline("UtcDaliAnimatedImageVisualLoopCount");
1416 // request AnimatedImageVisual with a property map
1417 // Test with no (0) loop count
1418 VisualFactory factory = VisualFactory::Get();
1419 Visual::Base animatedImageVisual = factory.CreateVisual(
1421 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1422 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1423 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1424 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1425 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1426 .Add(DevelImageVisual::Property::LOOP_COUNT, 0));
1428 DummyControl dummyControl = DummyControl::New(true);
1429 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1430 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1431 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1433 TestLoopCount(application, dummyControl, 4, 0, TEST_LOCATION);
1435 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1436 animatedImageVisual.Reset();
1438 application.SendNotification();
1439 application.Render(16);
1441 // Test with no (1) loop count. Request AnimatedImageVisual with a property map
1442 animatedImageVisual = factory.CreateVisual(
1444 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1445 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1446 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1447 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1448 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1449 .Add(DevelImageVisual::Property::LOOP_COUNT, 1));
1451 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1453 TestLoopCount(application, dummyControl, 4, 1, TEST_LOCATION);
1455 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1456 animatedImageVisual.Reset();
1458 application.SendNotification();
1459 application.Render(16);
1461 // Test with no (100) loop count. Request AnimatedImageVisual with a property map
1462 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, 100));
1471 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1473 TestLoopCount(application, dummyControl, 4, 100, TEST_LOCATION);
1478 int UtcDaliAnimatedImageVisualPlayback(void)
1480 ToolkitTestApplication application;
1481 TestGlAbstraction& gl = application.GetGlAbstraction();
1482 TraceCallStack& textureTrace = gl.GetTextureTrace();
1484 tet_infoline("UtcDaliAnimatedImageVisualPlayback");
1487 // request AnimatedImageVisual with a property map
1488 // Test with forever (-1) loop count
1489 VisualFactory factory = VisualFactory::Get();
1490 Visual::Base animatedImageVisual = factory.CreateVisual(
1492 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1493 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1494 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1495 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1496 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1497 .Add(DevelImageVisual::Property::LOOP_COUNT, -1));
1499 DummyControl dummyControl = DummyControl::New(true);
1500 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1501 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1502 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1504 textureTrace.Enable(true);
1505 application.GetScene().Add(dummyControl);
1506 application.SendNotification();
1507 application.Render(16);
1509 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1511 application.SendNotification();
1512 application.Render();
1514 tet_infoline("Test that a timer has been created");
1515 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1517 Test::EmitGlobalTimerSignal();
1518 application.SendNotification();
1519 application.Render(16);
1521 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1523 application.SendNotification();
1524 application.Render();
1525 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_LOCATION);
1527 Property::Map attributes;
1528 tet_infoline("Test Pause action. Timer should stop after Pause action");
1529 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PAUSE, attributes);
1530 Test::EmitGlobalTimerSignal();
1531 application.SendNotification();
1532 application.Render(16);
1533 DALI_TEST_EQUALS(Test::AreTimersRunning(), false, TEST_LOCATION);
1535 tet_infoline("Test Play action. Timer should Restart after Play action");
1536 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes);
1537 Test::EmitGlobalTimerSignal();
1538 application.SendNotification();
1539 application.Render(16);
1541 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1543 application.SendNotification();
1544 application.Render();
1545 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_LOCATION);
1547 tet_infoline("Test Stop action. Timer should stop after Stop action");
1548 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, attributes);
1549 Test::EmitGlobalTimerSignal();
1550 application.SendNotification();
1551 application.Render(16);
1552 DALI_TEST_EQUALS(Test::AreTimersRunning(), false, TEST_LOCATION);
1554 tet_infoline("Test Play action. Timer should Restart after Play action");
1555 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes);
1556 Test::EmitGlobalTimerSignal();
1557 application.SendNotification();
1558 application.Render(16);
1560 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1562 application.SendNotification();
1563 application.Render();
1564 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_LOCATION);
1566 dummyControl.Unparent();