2 * Copyright (c) 2023 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>
31 #include <dali/devel-api/adaptor-framework/window-devel.h>
33 #include "dummy-control.h"
36 using namespace Dali::Toolkit;
38 void dali_animated_image_visual_startup(void)
40 test_return_value = TET_UNDEF;
43 void dali_animated_image_visual_cleanup(void)
45 test_return_value = TET_PASS;
50 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/application-icon-%02d.png";
51 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
52 const char* TEST_MASK_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/mask.png";
53 const char* TEST_WEBP_FILE_NAME = TEST_RESOURCE_DIR "/dali-logo.webp";
56 void CopyUrlsIntoArray(Property::Array& urls, int startIndex = 0)
58 for(int i = 20 + startIndex; i <= 30; ++i)
61 if(asprintf(&url, TEST_IMAGE_FILE_NAME, i) > 0)
63 Property::Value value(url);
70 int UtcDaliAnimatedImageVisualGetPropertyMap01(void)
72 ToolkitTestApplication application;
73 tet_infoline("UtcDaliAnimatedImageVisualGetPropertyMap");
75 // request AnimatedImageVisual with a property map
76 VisualFactory factory = VisualFactory::Get();
77 Visual::Base animatedImageVisual = factory.CreateVisual(
79 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
80 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
81 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
82 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
83 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
84 .Add(ImageVisual::Property::FITTING_MODE, FittingMode::FIT_WIDTH)
85 .Add(ImageVisual::Property::SAMPLING_MODE, SamplingMode::NEAREST)
86 .Add(ImageVisual::Property::DESIRED_WIDTH, 154)
87 .Add(ImageVisual::Property::DESIRED_HEIGHT, 79)
88 .Add(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME)
89 .Add(ImageVisual::Property::MASK_CONTENT_SCALE, 1.6f)
90 .Add(ImageVisual::Property::CROP_TO_MASK, true)
91 .Add(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING)
92 .Add(DevelVisual::Property::CORNER_RADIUS, 22.2f)
93 .Add(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE)
94 .Add(DevelVisual::Property::BORDERLINE_WIDTH, 33.3f)
95 .Add(DevelVisual::Property::BORDERLINE_COLOR, Color::RED)
96 .Add(DevelVisual::Property::BORDERLINE_OFFSET, 0.3f));
98 Property::Map resultMap;
99 animatedImageVisual.CreatePropertyMap(resultMap);
100 // check the property values from the returned map from a visual
101 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
102 DALI_TEST_CHECK(value);
103 DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
105 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
106 DALI_TEST_CHECK(value);
107 DALI_TEST_CHECK(value->Get<std::string>() == TEST_GIF_FILE_NAME);
109 value = resultMap.Find(Toolkit::ImageVisual::Property::WRAP_MODE_U, Property::INTEGER);
110 DALI_TEST_CHECK(value);
111 DALI_TEST_CHECK(value->Get<int>() == WrapMode::REPEAT);
113 value = resultMap.Find(Toolkit::ImageVisual::Property::WRAP_MODE_V, Property::INTEGER);
114 DALI_TEST_CHECK(value);
115 DALI_TEST_CHECK(value->Get<int>() == WrapMode::DEFAULT);
117 value = resultMap.Find(Toolkit::ImageVisual::Property::FITTING_MODE, Property::INTEGER);
118 DALI_TEST_CHECK(value);
119 DALI_TEST_CHECK(value->Get<int>() == FittingMode::FIT_WIDTH);
121 value = resultMap.Find(Toolkit::ImageVisual::Property::SAMPLING_MODE, Property::INTEGER);
122 DALI_TEST_CHECK(value);
123 DALI_TEST_CHECK(value->Get<int>() == SamplingMode::NEAREST);
125 value = resultMap.Find(Toolkit::ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER);
126 DALI_TEST_CHECK(value);
127 DALI_TEST_CHECK(value->Get<int>() == 154);
129 value = resultMap.Find(Toolkit::ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER);
130 DALI_TEST_CHECK(value);
131 DALI_TEST_CHECK(value->Get<int>() == 79);
133 value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
134 DALI_TEST_CHECK(value);
135 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(22.2f, 22.2f, 22.2f, 22.2f), TEST_LOCATION);
137 value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, Property::INTEGER);
138 DALI_TEST_CHECK(value);
139 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
141 value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT);
142 DALI_TEST_CHECK(value);
143 DALI_TEST_EQUALS(value->Get<float>(), 33.3f, TEST_LOCATION);
145 value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
146 DALI_TEST_CHECK(value);
147 DALI_TEST_EQUALS(value->Get<Vector4>(), Color::RED, TEST_LOCATION);
149 value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
150 DALI_TEST_CHECK(value);
151 DALI_TEST_EQUALS(value->Get<float>(), 0.3f, TEST_LOCATION);
153 // Check mask properties
154 value = resultMap.Find(ImageVisual::Property::ALPHA_MASK_URL, Property::STRING);
155 DALI_TEST_CHECK(value);
156 DALI_TEST_CHECK(value->Get<std::string>() == TEST_MASK_IMAGE_FILE_NAME);
158 value = resultMap.Find(ImageVisual::Property::MASK_CONTENT_SCALE, Property::FLOAT);
159 DALI_TEST_CHECK(value);
160 DALI_TEST_EQUALS(value->Get<float>(), 1.6f, TEST_LOCATION);
162 value = resultMap.Find(ImageVisual::Property::CROP_TO_MASK, Property::BOOLEAN);
163 DALI_TEST_CHECK(value);
164 DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
166 value = resultMap.Find(DevelImageVisual::Property::MASKING_TYPE, Property::INTEGER);
167 DALI_TEST_CHECK(value);
168 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
170 // Natural size getted as desired size
172 animatedImageVisual.GetNaturalSize(naturalSize);
173 DALI_TEST_EQUALS(naturalSize, Vector2(154, 79), TEST_LOCATION);
175 // request AnimatedImageVisual with an URL
176 Visual::Base animatedImageVisual2 = factory.CreateVisual(TEST_GIF_FILE_NAME, ImageDimensions());
178 animatedImageVisual2.CreatePropertyMap(resultMap);
179 // check the property values from the returned map from a visual
180 value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
181 DALI_TEST_CHECK(value);
182 DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
184 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
185 DALI_TEST_CHECK(value);
186 DALI_TEST_CHECK(value->Get<std::string>() == TEST_GIF_FILE_NAME);
188 // Natural size getted as image size
189 animatedImageVisual2.GetNaturalSize(naturalSize);
190 DALI_TEST_EQUALS(naturalSize, Vector2(50, 50), TEST_LOCATION);
195 int UtcDaliAnimatedImageVisualGetPropertyMap02(void)
197 ToolkitTestApplication application;
198 tet_infoline("UtcDaliAnimatedImageVisualGetPropertyMap for multi image with fixed cache");
200 // request AnimatedImageVisual with a property map
201 VisualFactory factory = VisualFactory::Get();
202 Property::Array urls;
203 CopyUrlsIntoArray(urls);
205 Visual::Base animatedImageVisual = factory.CreateVisual(
207 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
210 .Add("cacheSize", 20)
211 .Add("loopCount", 10)
212 .Add("frameDelay", 200)
213 .Add("pixelArea", Vector4())
214 .Add("wrapModeU", WrapMode::REPEAT)
215 .Add("wrapModeV", WrapMode::DEFAULT)
216 .Add("fittingMode", FittingMode::FIT_WIDTH)
217 .Add("samplingMode", SamplingMode::NEAREST)
218 .Add("desiredWidth", 154)
219 .Add("desiredHeight", 79)
220 .Add("alphaMaskUrl", TEST_MASK_IMAGE_FILE_NAME)
221 .Add("maskContentScale", 1.6f)
222 .Add("cropToMask", true)
223 .Add(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING)
224 .Add("cornerRadius", Vector4(50.0f, 25.0f, 12.5f, 33.0f))
225 .Add("cornerRadiusPolicy", Visual::Transform::Policy::RELATIVE)
226 .Add("borderlineWidth", 20.0f)
227 .Add("borderlineColor", Vector4())
228 .Add("borderlineOffset", -1.0f));
230 Property::Map resultMap;
231 animatedImageVisual.CreatePropertyMap(resultMap);
232 // check the property values from the returned map from a visual
233 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
234 DALI_TEST_CHECK(value);
235 DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
237 value = resultMap.Find(ImageVisual::Property::URL, "url");
238 DALI_TEST_CHECK(value);
239 Property::Array* resultUrls = value->GetArray();
240 DALI_TEST_CHECK(resultUrls);
241 DALI_TEST_EQUALS(resultUrls->Count(), urls.Count(), TEST_LOCATION);
243 value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, "batchSize");
244 DALI_TEST_CHECK(value);
245 DALI_TEST_EQUALS(value->Get<int>(), 4, TEST_LOCATION);
247 value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, "cacheSize");
248 DALI_TEST_CHECK(value);
249 DALI_TEST_EQUALS(value->Get<int>(), 20, TEST_LOCATION);
251 value = resultMap.Find(Toolkit::DevelImageVisual::Property::LOOP_COUNT, "loopCount");
252 DALI_TEST_CHECK(value);
253 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
255 value = resultMap.Find(ImageVisual::Property::FRAME_DELAY, "frameDelay");
256 DALI_TEST_CHECK(value);
257 DALI_TEST_EQUALS(value->Get<int>(), 200, TEST_LOCATION);
259 value = resultMap.Find(Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber");
260 DALI_TEST_CHECK(value);
261 DALI_TEST_EQUALS(value->Get<int>(), 11, TEST_LOCATION);
263 value = resultMap.Find(Toolkit::ImageVisual::Property::WRAP_MODE_U, "wrapModeU");
264 DALI_TEST_CHECK(value);
265 DALI_TEST_CHECK(value->Get<int>() == WrapMode::REPEAT);
267 value = resultMap.Find(Toolkit::ImageVisual::Property::WRAP_MODE_V, "wrapModeV");
268 DALI_TEST_CHECK(value);
269 DALI_TEST_CHECK(value->Get<int>() == WrapMode::DEFAULT);
271 value = resultMap.Find(Toolkit::ImageVisual::Property::FITTING_MODE, "fittingMode");
272 DALI_TEST_CHECK(value);
273 DALI_TEST_CHECK(value->Get<int>() == FittingMode::FIT_WIDTH);
275 value = resultMap.Find(Toolkit::ImageVisual::Property::SAMPLING_MODE, "samplingMode");
276 DALI_TEST_CHECK(value);
277 DALI_TEST_CHECK(value->Get<int>() == SamplingMode::NEAREST);
279 value = resultMap.Find(Toolkit::ImageVisual::Property::DESIRED_WIDTH, "desiredWidth");
280 DALI_TEST_CHECK(value);
281 DALI_TEST_CHECK(value->Get<int>() == 154);
283 value = resultMap.Find(Toolkit::ImageVisual::Property::DESIRED_HEIGHT, "desiredHeight");
284 DALI_TEST_CHECK(value);
285 DALI_TEST_CHECK(value->Get<int>() == 79);
287 value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS, "cornerRadius");
288 DALI_TEST_CHECK(value);
289 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(50.0f, 25.0f, 12.5f, 33.0f), TEST_LOCATION);
291 value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
292 DALI_TEST_CHECK(value);
293 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::RELATIVE);
295 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
296 DALI_TEST_CHECK(value);
297 DALI_TEST_EQUALS(value->Get<float>(), 20.0f, TEST_LOCATION);
299 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, "borderlineColor");
300 DALI_TEST_CHECK(value);
301 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4::ZERO, TEST_LOCATION);
303 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, "borderlineOffset");
304 DALI_TEST_CHECK(value);
305 DALI_TEST_EQUALS(value->Get<float>(), -1.0f, TEST_LOCATION);
307 // Check mask properties
308 value = resultMap.Find(ImageVisual::Property::ALPHA_MASK_URL, "alphaMaskUrl");
309 DALI_TEST_CHECK(value);
310 DALI_TEST_CHECK(value->Get<std::string>() == TEST_MASK_IMAGE_FILE_NAME);
312 value = resultMap.Find(ImageVisual::Property::MASK_CONTENT_SCALE, "maskContentScale");
313 DALI_TEST_CHECK(value);
314 DALI_TEST_EQUALS(value->Get<float>(), 1.6f, TEST_LOCATION);
316 value = resultMap.Find(ImageVisual::Property::CROP_TO_MASK, "cropToMask");
317 DALI_TEST_CHECK(value);
318 DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
320 value = resultMap.Find(DevelImageVisual::Property::MASKING_TYPE, Property::INTEGER);
321 DALI_TEST_CHECK(value);
322 DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
327 int UtcDaliAnimatedImageVisualGetPropertyMap03(void)
329 ToolkitTestApplication application;
330 tet_infoline("UtcDaliAnimatedImageVisualGetPropertyMap for multi image rolling cache");
332 // request AnimatedImageVisual with a property map
333 VisualFactory factory = VisualFactory::Get();
334 Property::Array urls;
335 CopyUrlsIntoArray(urls);
337 Visual::Base animatedImageVisual = factory.CreateVisual(
339 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
343 .Add("loopCount", 10)
344 .Add("frameDelay", 200)
345 .Add("pixelArea", Vector4())
346 .Add("wrapModeU", WrapMode::REPEAT)
347 .Add("wrapModeV", WrapMode::DEFAULT)
348 .Add("alphaMaskUrl", TEST_MASK_IMAGE_FILE_NAME)
349 .Add("maskContentScale", 1.6f)
350 .Add("cropToMask", true)
351 .Add(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING)
352 .Add("cornerRadius", 50.5f));
354 Property::Map resultMap;
355 animatedImageVisual.CreatePropertyMap(resultMap);
356 // check the property values from the returned map from a visual
357 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
358 DALI_TEST_CHECK(value);
359 DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
361 value = resultMap.Find(ImageVisual::Property::URL, "url");
362 DALI_TEST_CHECK(value);
363 Property::Array* resultUrls = value->GetArray();
364 DALI_TEST_CHECK(resultUrls);
365 DALI_TEST_EQUALS(resultUrls->Count(), urls.Count(), TEST_LOCATION);
367 value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, "batchSize");
368 DALI_TEST_CHECK(value);
369 DALI_TEST_EQUALS(value->Get<int>(), 4, TEST_LOCATION);
371 value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, "cacheSize");
372 DALI_TEST_CHECK(value);
373 DALI_TEST_EQUALS(value->Get<int>(), 8, TEST_LOCATION);
375 value = resultMap.Find(Toolkit::DevelImageVisual::Property::LOOP_COUNT, "loopCount");
376 DALI_TEST_CHECK(value);
377 DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
379 value = resultMap.Find(ImageVisual::Property::FRAME_DELAY, "frameDelay");
380 DALI_TEST_CHECK(value);
381 DALI_TEST_EQUALS(value->Get<int>(), 200, TEST_LOCATION);
383 value = resultMap.Find(Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber");
384 DALI_TEST_CHECK(value);
385 DALI_TEST_EQUALS(value->Get<int>(), 11, TEST_LOCATION);
387 value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS, "cornerRadius");
388 DALI_TEST_CHECK(value);
389 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(50.5f, 50.5f, 50.5f, 50.5f), TEST_LOCATION);
391 value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
392 DALI_TEST_CHECK(value);
393 DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
395 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
396 DALI_TEST_CHECK(value);
397 DALI_TEST_EQUALS(value->Get<float>(), 0.0f, TEST_LOCATION);
399 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, "borderlineColor");
400 DALI_TEST_CHECK(value);
401 DALI_TEST_EQUALS(value->Get<Vector4>(), Color::BLACK, TEST_LOCATION);
403 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, "borderlineOffset");
404 DALI_TEST_CHECK(value);
405 DALI_TEST_EQUALS(value->Get<float>(), 0.0f, TEST_LOCATION);
407 // Check mask properties
408 value = resultMap.Find(ImageVisual::Property::ALPHA_MASK_URL, "alphaMaskUrl");
409 DALI_TEST_CHECK(value);
410 DALI_TEST_CHECK(value->Get<std::string>() == TEST_MASK_IMAGE_FILE_NAME);
412 value = resultMap.Find(ImageVisual::Property::MASK_CONTENT_SCALE, "maskContentScale");
413 DALI_TEST_CHECK(value);
414 DALI_TEST_EQUALS(value->Get<float>(), 1.6f, TEST_LOCATION);
416 value = resultMap.Find(ImageVisual::Property::CROP_TO_MASK, "cropToMask");
417 DALI_TEST_CHECK(value);
418 DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
420 value = resultMap.Find(DevelImageVisual::Property::MASKING_TYPE, Property::INTEGER);
421 DALI_TEST_CHECK(value);
422 DALI_TEST_CHECK(value->Get<bool>() == DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
424 // Natural size getted as masked image size
426 animatedImageVisual.GetNaturalSize(naturalSize);
427 DALI_TEST_EQUALS(naturalSize, Vector2(100, 100), TEST_LOCATION);
432 int UtcDaliAnimatedImageVisualGetPropertyMap04(void)
434 ToolkitTestApplication application;
435 tet_infoline("UtcDaliAnimatedImageVisualGetPropertyMap");
437 // request AnimatedImageVisual with a property map
438 VisualFactory factory = VisualFactory::Get();
439 Visual::Base animatedImageVisual = factory.CreateVisual(
441 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
442 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
443 .Add(ImageVisual::Property::BATCH_SIZE, 1)
444 .Add(ImageVisual::Property::CACHE_SIZE, 1)
445 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, true)
446 .Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DETACHED)
447 .Add(ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::ATTACHED)
448 .Add(DevelVisual::Property::BORDERLINE_WIDTH, 0.4f));
450 Property::Map resultMap;
451 animatedImageVisual.CreatePropertyMap(resultMap);
453 // check the property values from the returned map from a visual
454 Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
455 DALI_TEST_CHECK(value);
456 DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
458 value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
459 DALI_TEST_CHECK(value);
460 DALI_TEST_CHECK(value->Get<std::string>() == TEST_GIF_FILE_NAME);
462 value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, Property::INTEGER);
463 DALI_TEST_CHECK(value);
464 DALI_TEST_CHECK(value->Get<int>() == 2);
466 value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, Property::INTEGER);
467 DALI_TEST_CHECK(value);
468 DALI_TEST_CHECK(value->Get<int>() == 2);
470 value = resultMap.Find(ImageVisual::Property::SYNCHRONOUS_LOADING, Property::BOOLEAN);
471 DALI_TEST_CHECK(value);
472 DALI_TEST_CHECK(value->Get<bool>() == true);
474 value = resultMap.Find(ImageVisual::Property::RELEASE_POLICY, Property::INTEGER);
475 DALI_TEST_CHECK(value);
476 DALI_TEST_CHECK(value->Get<int>() == ImageVisual::ReleasePolicy::DETACHED);
478 value = resultMap.Find(ImageVisual::Property::LOAD_POLICY, Property::INTEGER);
479 DALI_TEST_CHECK(value);
480 DALI_TEST_CHECK(value->Get<int>() == ImageVisual::LoadPolicy::ATTACHED);
482 value = resultMap.Find(Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber");
483 DALI_TEST_CHECK(value);
484 DALI_TEST_EQUALS(value->Get<int>(), 4, TEST_LOCATION);
486 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
487 DALI_TEST_CHECK(value);
488 DALI_TEST_EQUALS(value->Get<float>(), 0.4f, TEST_LOCATION);
490 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, "borderlineColor");
491 DALI_TEST_CHECK(value);
492 DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(0.0f, 0.0f, 0.0f, 1.0f), TEST_LOCATION);
494 value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, "borderlineOffset");
495 DALI_TEST_CHECK(value);
496 DALI_TEST_EQUALS(value->Get<float>(), 0.0f, TEST_LOCATION);
501 int UtcDaliAnimatedImageVisualImageLoadingFail01(void)
503 ToolkitTestApplication application;
504 TestGlAbstraction& gl = application.GetGlAbstraction();
507 Property::Map propertyMap;
508 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
509 propertyMap.Insert(ImageVisual::Property::URL, "dummy.gif");
510 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
511 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
512 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
513 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
514 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
515 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
517 VisualFactory factory = VisualFactory::Get();
518 Visual::Base visual = factory.CreateVisual(propertyMap);
520 DummyControl dummyControl = DummyControl::New(true);
521 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
522 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
524 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
525 application.GetScene().Add(dummyControl);
527 TraceCallStack& textureTrace = gl.GetTextureTrace();
528 textureTrace.Enable(true);
530 application.SendNotification();
531 application.Render(20);
533 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 1, TEST_LOCATION);
535 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 6);
537 application.SendNotification();
538 application.Render(20);
540 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 1, TEST_LOCATION);
542 dummyControl.Unparent();
548 int UtcDaliAnimatedImageVisualSynchronousLoading(void)
550 ToolkitTestApplication application;
551 TestGlAbstraction& gl = application.GetGlAbstraction();
554 Property::Map propertyMap;
555 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
556 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
557 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
558 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
559 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
560 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
561 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
562 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
564 VisualFactory factory = VisualFactory::Get();
565 Visual::Base visual = factory.CreateVisual(propertyMap);
567 DummyControl dummyControl = DummyControl::New(true);
568 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
569 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
571 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
572 application.GetScene().Add(dummyControl);
574 TraceCallStack& textureTrace = gl.GetTextureTrace();
575 textureTrace.Enable(true);
577 application.SendNotification();
578 application.Render(20);
580 // The first frame is loaded synchronously and load next batch.
581 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
583 application.SendNotification();
584 application.Render();
586 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
587 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
589 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 3);
591 application.SendNotification();
592 application.Render(20);
594 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
596 application.SendNotification();
597 application.Render();
599 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
601 dummyControl.Unparent();
603 tet_infoline("Test that removing the visual from stage deletes all textures");
604 application.SendNotification();
605 application.Render(16);
606 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
611 int UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask01(void)
613 ToolkitTestApplication application;
614 tet_infoline("UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask01 for CPU Alpha Masking");
615 TestGlAbstraction& gl = application.GetGlAbstraction();
618 Property::Map propertyMap;
619 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
620 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
621 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
622 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
623 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
624 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
625 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
626 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
627 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
629 VisualFactory factory = VisualFactory::Get();
630 Visual::Base visual = factory.CreateVisual(propertyMap);
632 Property::Map testMap;
633 visual.CreatePropertyMap(testMap);
634 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
636 DummyControl dummyControl = DummyControl::New(true);
637 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
638 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
640 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
641 application.GetScene().Add(dummyControl);
643 TraceCallStack& textureTrace = gl.GetTextureTrace();
644 textureTrace.Enable(true);
646 application.SendNotification();
647 application.Render(20);
649 // The first frame is loaded synchronously and load next batch with masking
650 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
652 application.SendNotification();
653 application.Render();
655 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
656 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
658 dummyControl.Unparent();
660 tet_infoline("Test that removing the visual from stage deletes all textures");
661 application.SendNotification();
662 application.Render(16);
663 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
668 int UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask02(void)
670 ToolkitTestApplication application;
671 tet_infoline("UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask02 for GPU Alpha Masking");
672 TestGlAbstraction& gl = application.GetGlAbstraction();
675 Property::Map propertyMap;
676 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
677 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
678 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
679 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
680 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
681 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
682 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
683 propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
684 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
685 propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
687 VisualFactory factory = VisualFactory::Get();
688 Visual::Base visual = factory.CreateVisual(propertyMap);
690 Property::Map testMap;
691 visual.CreatePropertyMap(testMap);
692 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
694 DummyControl dummyControl = DummyControl::New(true);
695 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
696 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
698 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
699 application.GetScene().Add(dummyControl);
701 TraceCallStack& textureTrace = gl.GetTextureTrace();
702 textureTrace.Enable(true);
704 application.SendNotification();
705 application.Render(20);
707 // The first frame is loaded synchronously and load next batch with masking
708 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
710 application.SendNotification();
711 application.Render();
713 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
714 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
716 dummyControl.Unparent();
718 tet_infoline("Test that removing the visual from stage deletes all textures");
719 application.SendNotification();
720 application.Render(16);
721 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
726 int UtcDaliAnimatedImageVisualJumpToAction(void)
728 ToolkitTestApplication application;
729 TestGlAbstraction& gl = application.GetGlAbstraction();
731 Property::Array urls;
732 CopyUrlsIntoArray(urls);
735 Property::Map propertyMap;
736 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
737 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
738 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
739 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 12);
740 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
742 VisualFactory factory = VisualFactory::Get();
743 Visual::Base visual = factory.CreateVisual(propertyMap);
745 DummyControl dummyControl = DummyControl::New(true);
746 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
747 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
749 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
750 application.GetScene().Add(dummyControl);
751 application.SendNotification();
752 application.Render(20);
754 tet_infoline("Ready the visual after the visual is on stage");
755 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
757 tet_infoline("Test that a timer has been started");
758 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
760 TraceCallStack& textureTrace = gl.GetTextureTrace();
761 textureTrace.Enable(true);
763 application.SendNotification();
764 application.Render(20);
766 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
768 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map());
770 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
772 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 20);
774 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
776 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 6);
778 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(6), 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 UtcDaliAnimatedImageVisualStopBehavior(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::FIRST_FRAME);
804 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
805 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 8);
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);
820 application.SendNotification();
821 application.Render(20);
823 tet_infoline("Ready the visual after the visual is on stage");
824 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
826 tet_infoline("Test that a timer has been started");
827 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
829 TraceCallStack& textureTrace = gl.GetTextureTrace();
830 textureTrace.Enable(true);
832 application.SendNotification();
833 application.Render(20);
835 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
837 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map());
839 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
841 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 1);
843 // Expect the second batch has been requested
844 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
846 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
848 dummyControl.Unparent();
850 tet_infoline("Test that removing the visual from stage deletes all textures");
851 application.SendNotification();
852 application.Render(16);
853 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
858 int UtcDaliAnimatedImageVisualStopBehavior02(void)
860 ToolkitTestApplication application;
861 TestGlAbstraction& gl = application.GetGlAbstraction();
863 Property::Array urls;
864 CopyUrlsIntoArray(urls);
867 Property::Map propertyMap;
868 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
869 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
870 propertyMap.Insert(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
871 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
872 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
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 tet_infoline("Ready the visual after the visual is on stage");
889 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
891 TraceCallStack& textureTrace = gl.GetTextureTrace();
892 textureTrace.Enable(true);
894 application.SendNotification();
895 application.Render(20);
897 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 2, TEST_LOCATION);
899 Test::EmitGlobalTimerSignal();
901 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
903 application.SendNotification();
904 application.Render(20);
906 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
908 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map());
910 tet_infoline("Ready the visual after the visual is on stage");
911 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
913 application.SendNotification();
914 application.Render(20);
916 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
918 dummyControl.Unparent();
920 tet_infoline("Test that removing the visual from stage deletes all textures");
921 application.SendNotification();
922 application.Render(16);
923 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
928 int UtcDaliAnimatedImageVisualAnimatedImage01(void)
930 ToolkitTestApplication application;
931 TestGlAbstraction& gl = application.GetGlAbstraction();
933 tet_infoline("Set cache size same as GIF frame, and try to load same image at another ImageView");
935 Property::Map propertyMap;
936 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
937 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
938 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
939 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 4);
940 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
942 VisualFactory factory = VisualFactory::Get();
943 Visual::Base visual = factory.CreateVisual(propertyMap);
945 // Expect that a batch of 4 textures has been requested. These will be serially loaded
948 DummyControl dummyControl = DummyControl::New(true);
949 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
950 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
952 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
953 application.GetScene().Add(dummyControl);
955 application.SendNotification();
956 application.Render();
958 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
960 // Batch 2 frames. Now frame 0, 1 cached.
961 application.SendNotification();
962 application.Render(20);
964 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 2, TEST_LOCATION);
966 tet_infoline("Test that a timer has been started");
968 TraceCallStack& textureTrace = gl.GetTextureTrace();
969 textureTrace.Enable(true);
971 Test::EmitGlobalTimerSignal();
973 application.SendNotification();
974 application.Render();
976 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
978 // 0 frame removed. and after, batch 2 frames. Now frame 1, 2, 3 cached.
979 application.SendNotification();
980 application.Render(20);
982 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
984 Visual::Base visual2 = factory.CreateVisual(propertyMap);
985 DummyControl dummyControl2 = DummyControl::New(true);
986 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl2.GetImplementation());
987 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
988 application.GetScene().Add(dummyControl2);
990 tet_infoline("Add new view with same url");
992 application.SendNotification();
993 application.Render();
995 // Note that we only re-load 0 frame.
996 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
998 tet_infoline("Test that we don't try to re-load new image cause it cached");
999 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
1001 // Batch 2 frames. Now visual frame 1, 2, 3 cached and visual2 frame 0, 1 cached.
1002 application.SendNotification();
1003 application.Render(20);
1005 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 5, TEST_LOCATION);
1007 textureTrace.Reset();
1009 tet_infoline("Load some many frames");
1011 const int repeatCount = 10;
1012 for(int repeat = 0; repeat < repeatCount; ++repeat)
1014 Test::EmitGlobalTimerSignal();
1015 application.SendNotification();
1016 application.Render(2000);
1019 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // A new texture should NOT be generated.
1020 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 5, TEST_LOCATION);
1022 textureTrace.Reset();
1024 dummyControl.Unparent();
1025 dummyControl2.Unparent();
1027 tet_infoline("Test that removing the visual from stage deletes all textures");
1028 application.SendNotification();
1029 application.Render(20);
1030 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1035 int UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask01(void)
1037 ToolkitTestApplication application;
1038 tet_infoline("UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask01 for CPU Alpha Masking");
1039 TestGlAbstraction& gl = application.GetGlAbstraction();
1042 Property::Map propertyMap;
1043 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
1044 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
1045 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
1046 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 4);
1047 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
1048 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
1050 VisualFactory factory = VisualFactory::Get();
1051 Visual::Base visual = factory.CreateVisual(propertyMap);
1053 DummyControl dummyControl = DummyControl::New(true);
1054 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1055 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1057 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1058 application.GetScene().Add(dummyControl);
1060 application.SendNotification();
1061 application.Render();
1063 // load two frame(batch size), load mask image, and request two masking
1064 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(5), true, TEST_LOCATION);
1066 application.SendNotification();
1067 application.Render(20);
1069 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 2, TEST_LOCATION);
1071 dummyControl.Unparent();
1073 tet_infoline("Test that removing the visual from stage deletes all textures");
1074 application.SendNotification();
1075 application.Render(20);
1076 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1081 int UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask02(void)
1083 ToolkitTestApplication application;
1084 tet_infoline("UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask02 for GPU Alpha Masking");
1085 TestGlAbstraction& gl = application.GetGlAbstraction();
1088 Property::Map propertyMap;
1089 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
1090 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
1091 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
1092 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 4);
1093 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
1094 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
1095 propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
1097 VisualFactory factory = VisualFactory::Get();
1098 Visual::Base visual = factory.CreateVisual(propertyMap);
1100 DummyControl dummyControl = DummyControl::New(true);
1101 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1102 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1104 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1105 application.GetScene().Add(dummyControl);
1107 Property::Map attributes;
1108 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, attributes);
1110 application.SendNotification();
1111 application.Render();
1113 // load two frame(batch size), load mask image, and request two masking
1114 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1116 application.SendNotification();
1117 application.Render(20);
1119 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1121 dummyControl.Unparent();
1123 tet_infoline("Test that removing the visual from stage deletes all textures");
1124 application.SendNotification();
1125 application.Render(20);
1126 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1131 int UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask03(void)
1133 ToolkitTestApplication application;
1134 tet_infoline("UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask03 for GPU Alpha Masking with broken mask texture");
1135 TestGlAbstraction& gl = application.GetGlAbstraction();
1138 Property::Map propertyMap;
1139 propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
1140 propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
1141 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
1142 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 4);
1143 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
1144 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, "");
1145 propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
1147 VisualFactory factory = VisualFactory::Get();
1148 Visual::Base visual = factory.CreateVisual(propertyMap);
1150 DummyControl dummyControl = DummyControl::New(true);
1151 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1152 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1154 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1155 application.GetScene().Add(dummyControl);
1157 application.SendNotification();
1158 application.Render();
1160 // load two frame(batch size), load mask image, and request two masking
1161 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1163 application.SendNotification();
1164 application.Render(20);
1166 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 3, TEST_LOCATION);
1168 dummyControl.Unparent();
1170 tet_infoline("Test that removing the visual from stage deletes all textures");
1171 application.SendNotification();
1172 application.Render(20);
1173 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1178 int UtcDaliAnimatedImageVisualMultiImage01(void)
1180 ToolkitTestApplication application;
1181 TestGlAbstraction& gl = application.GetGlAbstraction();
1183 Property::Array urls;
1184 CopyUrlsIntoArray(urls);
1187 Property::Map propertyMap;
1188 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1189 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1190 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
1191 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 8);
1192 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1194 VisualFactory factory = VisualFactory::Get();
1195 Visual::Base visual = factory.CreateVisual(propertyMap);
1197 // Expect that a batch of 4 textures has been requested. These will be serially loaded
1200 DummyControl dummyControl = DummyControl::New(true);
1201 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1202 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1204 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1205 application.GetScene().Add(dummyControl);
1206 application.SendNotification();
1207 application.Render(16);
1209 tet_infoline("Ready the visual after the visual is on stage");
1210 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1212 tet_infoline("Test that a timer has been started");
1213 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1215 TraceCallStack& textureTrace = gl.GetTextureTrace();
1216 textureTrace.Enable(true);
1218 application.SendNotification();
1219 application.Render(16);
1221 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
1222 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1224 tet_infoline("Test that after 1 tick, and file loads completed, that we have 7 textures");
1225 Test::EmitGlobalTimerSignal();
1227 // Expect the second batch has been requested
1228 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1230 application.SendNotification();
1231 application.Render(16);
1232 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
1234 tet_infoline("Test that after 2 ticks that we have 6 textures");
1236 Test::EmitGlobalTimerSignal();
1237 application.SendNotification();
1238 application.Render(16);
1239 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 6, TEST_LOCATION);
1241 tet_infoline("And that at least 2 textures were requested");
1242 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1243 application.SendNotification();
1244 application.Render(16);
1245 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 8, TEST_LOCATION);
1247 tet_infoline("Test that after 3rd tick that we have 7 textures and 1 request");
1248 Test::EmitGlobalTimerSignal();
1249 application.SendNotification();
1250 application.Render(16);
1251 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
1253 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1254 application.SendNotification();
1255 application.Render(16);
1256 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 8, TEST_LOCATION);
1258 dummyControl.Unparent();
1260 tet_infoline("Test that removing the visual from stage deletes all textures");
1261 application.SendNotification();
1262 application.Render(16);
1263 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1268 int UtcDaliAnimatedImageVisualMultiImage02(void)
1270 ToolkitTestApplication application;
1271 TestGlAbstraction& gl = application.GetGlAbstraction();
1273 tet_infoline("Test that the animated visual has different batch and cache size.");
1276 Property::Array urls;
1277 CopyUrlsIntoArray(urls);
1279 Property::Map propertyMap;
1280 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1281 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1282 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 0);
1283 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 0);
1284 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1286 VisualFactory factory = VisualFactory::Get();
1287 Visual::Base visual = factory.CreateVisual(propertyMap); // TexMgr::Request load tId:0
1289 // Check the batch size and cache size need to have minimum 2.
1290 Property::Map resultMap;
1291 visual.CreatePropertyMap(resultMap);
1292 Property::Value* value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, "batchSize");
1293 DALI_TEST_CHECK(value);
1294 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1295 value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, "cacheSize");
1296 DALI_TEST_CHECK(value);
1297 DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION);
1300 // Batch size is 2 and cache size is 3
1301 propertyMap.Clear();
1302 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1303 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1304 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
1305 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 3);
1306 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1308 visual = factory.CreateVisual(propertyMap); // TexMgr::Request load tId:0
1310 // Expect that each image is loaded each tick
1311 DummyControl dummyControl = DummyControl::New(true);
1312 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1313 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1316 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1317 application.GetScene().Add(dummyControl);
1318 application.SendNotification();
1319 application.Render(16);
1321 tet_infoline("Ready the visual after the visual is on window");
1322 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1323 application.SendNotification();
1324 application.Render(16); //glGenTextures 1 and 2
1325 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
1327 tet_infoline("Test that each tick, a new image is requested");
1328 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
1329 application.SendNotification();
1330 application.Render(16);
1331 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1332 application.SendNotification();
1333 application.Render(16); //glGenTextures 3
1334 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1336 tet_infoline("Test that each tick, a new image is requested");
1337 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:1
1338 application.SendNotification();
1339 application.Render(16);
1340 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1341 application.SendNotification();
1342 application.Render(16); //glGenTextures 4
1343 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1345 dummyImpl1.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1346 dummyControl.Unparent();
1348 // Ensure to remove cached texture. (Since we support lazy cache removal)
1349 application.SendNotification();
1350 application.Render(16);
1351 application.SendNotification();
1352 application.Render(16);
1354 // Batch size is 9 and cache size is 4
1355 propertyMap.Clear();
1356 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1357 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1358 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 3);
1359 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 7);
1360 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1362 visual = factory.CreateVisual(propertyMap); // TexMgr::Request load tId:0
1364 // Expect that each image is loaded each tick
1365 dummyControl = DummyControl::New(true);
1366 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1367 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1370 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1371 application.GetScene().Add(dummyControl);
1372 application.SendNotification();
1373 application.Render(16);
1375 tet_infoline("Ready the visual after the visual is on window");
1376 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1377 application.SendNotification();
1378 application.Render(16); //glGenTextures 1, 2, and 3
1379 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1381 tet_infoline("Test that each tick, a new image is requested");
1382 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:0
1383 application.SendNotification();
1384 application.Render(16);
1385 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1386 application.SendNotification();
1387 application.Render(16); //glGenTextures 4, 5, and 6
1388 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 5, TEST_LOCATION);
1390 tet_infoline("Test that each tick, a new image is requested");
1391 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:1
1392 application.SendNotification();
1393 application.Render(16);
1394 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1395 application.SendNotification();
1396 application.Render(16); //glGenTextures 7, 1, and 2
1397 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
1399 tet_infoline("Test that each tick, a new image is requested");
1400 Test::EmitGlobalTimerSignal(); // TexMgr::Remove tId:2
1401 application.SendNotification();
1402 application.Render(16);
1403 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1404 application.SendNotification();
1405 application.Render(16); //glGenTextures 3
1406 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 7, TEST_LOCATION);
1408 dummyControl.Unparent();
1410 tet_infoline("Test that removing the visual from window deletes all textures");
1411 application.SendNotification();
1412 application.Render(16);
1413 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1418 int UtcDaliAnimatedImageVisualMultiImage03(void)
1420 ToolkitTestApplication application;
1421 TestGlAbstraction& gl = application.GetGlAbstraction();
1424 Property::Array urls1, urls2;
1425 CopyUrlsIntoArray(urls1);
1426 CopyUrlsIntoArray(urls2);
1428 Property::Map animatedImageMap1;
1429 animatedImageMap1.Insert(Visual::Property::TYPE, Visual::IMAGE);
1430 animatedImageMap1.Insert(ImageVisual::Property::URL, Property::Value(urls1));
1431 animatedImageMap1.Insert(ImageVisual::Property::BATCH_SIZE, 3);
1432 animatedImageMap1.Insert(ImageVisual::Property::CACHE_SIZE, 3);
1433 animatedImageMap1.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1435 Property::Map animatedImageMap2;
1436 animatedImageMap2.Insert(Visual::Property::TYPE, Visual::IMAGE);
1437 animatedImageMap2.Insert(ImageVisual::Property::URL, Property::Value(urls2));
1438 animatedImageMap2.Insert(ImageVisual::Property::BATCH_SIZE, 2);
1439 animatedImageMap2.Insert(ImageVisual::Property::CACHE_SIZE, 2);
1440 animatedImageMap2.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1442 VisualFactory factory = VisualFactory::Get();
1443 Visual::Base animatedImageVisual1 = factory.CreateVisual(animatedImageMap1);
1445 tet_infoline("Create two image views with the same URLs, offset by 1 frame.");
1447 DummyControl dummyControl1 = DummyControl::New(true);
1448 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummyControl1.GetImplementation());
1449 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual1);
1450 dummyControl1.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1451 application.GetScene().Add(dummyControl1);
1453 application.SendNotification();
1454 application.Render(16);
1456 tet_infoline("Ready the requested image after the first visual is on stage");
1457 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1458 application.SendNotification();
1459 application.Render(16);
1460 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1462 Visual::Base animatedImageVisual2 = factory.CreateVisual(animatedImageMap2);
1463 DummyControl dummyControl2 = DummyControl::New(true);
1464 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(dummyControl2.GetImplementation());
1465 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual2);
1466 dummyControl2.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1467 application.GetScene().Add(dummyControl2);
1468 application.SendNotification();
1469 application.Render(16);
1471 tet_infoline("The texture cache should be holding the requested images; check that the renderer has a texture");
1472 TextureSet ts = dummyControl2.GetRendererAt(0).GetTextures();
1473 Texture t1 = ts.GetTexture(0);
1474 DALI_TEST_EQUALS(ts.GetTextureCount(), 1, TEST_LOCATION);
1476 tet_infoline("Test that on the first tick, 1 new image is requested");
1477 Test::EmitGlobalTimerSignal(); // Both visuals should tick
1479 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1480 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 3, TEST_LOCATION);
1482 ts = dummyControl2.GetRendererAt(0).GetTextures();
1483 Texture t2 = ts.GetTexture(0);
1484 DALI_TEST_CHECK(t1 != t2);
1486 dummyControl1.Unparent();
1487 dummyControl2.Unparent();
1489 tet_infoline("Test that removing the visual from stage deletes all textures");
1490 application.SendNotification();
1491 application.Render(16);
1492 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1497 int UtcDaliAnimatedImageVisualMultiImage04(void)
1499 ToolkitTestApplication application;
1500 TestGlAbstraction& gl = application.GetGlAbstraction();
1501 TraceCallStack& textureTrace = gl.GetTextureTrace();
1502 textureTrace.Enable(true);
1504 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");
1506 Property::Array urls;
1507 CopyUrlsIntoArray(urls);
1510 Property::Map propertyMap;
1511 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1512 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1513 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 6);
1514 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 11);
1515 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1517 VisualFactory factory = VisualFactory::Get();
1518 Visual::Base visual = factory.CreateVisual(propertyMap);
1520 tet_infoline("Expect that a batch of 7 textures has been requested.");
1522 DummyControl dummyControl = DummyControl::New(true);
1523 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1524 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1526 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1527 application.GetScene().Add(dummyControl);
1528 application.SendNotification();
1529 application.Render(16);
1531 tet_infoline("Wait for the first batch to complete");
1532 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(6), true, TEST_LOCATION);
1534 tet_infoline("Test that a timer has been started");
1535 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1537 application.SendNotification();
1538 application.Render(16);
1540 DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 6, TEST_LOCATION);
1541 tet_infoline("Test that after 1 tick, and 5 file loads completed, that we have 11 textures");
1542 Test::EmitGlobalTimerSignal();
1543 application.SendNotification();
1544 application.Render(16);
1546 // Expect the second batch has been requested
1547 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(5), true, TEST_LOCATION);
1549 application.SendNotification();
1550 application.Render(16);
1551 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 11, TEST_LOCATION);
1553 tet_infoline("Test that after 2 ticks that we have 11 textures and no requests");
1555 Test::EmitGlobalTimerSignal();
1556 application.SendNotification();
1557 application.Render(16);
1558 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 5), false, TEST_LOCATION);
1559 application.SendNotification();
1560 application.Render(16);
1561 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 11, TEST_LOCATION);
1563 tet_infoline("Test that after 3rd tick that we have 11 textures and no requests");
1564 Test::EmitGlobalTimerSignal();
1565 application.SendNotification();
1566 application.Render(16);
1568 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 5), false, TEST_LOCATION);
1569 application.SendNotification();
1570 application.Render(16);
1571 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 11, TEST_LOCATION);
1573 dummyControl.Unparent();
1576 tet_infoline("Test that removing the visual from stage deletes all textures");
1577 application.SendNotification();
1578 application.Render(16);
1579 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1584 int UtcDaliAnimatedImageVisualMultiImage05(void)
1586 ToolkitTestApplication application;
1587 TestGlAbstraction& gl = application.GetGlAbstraction();
1589 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");
1591 Property::Array urls;
1592 CopyUrlsIntoArray(urls);
1595 Property::Map propertyMap;
1596 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1597 propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
1598 propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
1599 propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 11);
1600 propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 100);
1602 VisualFactory factory = VisualFactory::Get();
1603 Visual::Base visual = factory.CreateVisual(propertyMap);
1605 tet_infoline("Expect that a batch of 4 textures has been requested.");
1607 DummyControl dummyControl = DummyControl::New(true);
1608 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1609 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1611 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1612 application.GetScene().Add(dummyControl);
1613 application.SendNotification();
1614 application.Render(16);
1616 tet_infoline("Wait for the first batch to complete");
1617 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1619 tet_infoline("Test that a timer has been started");
1620 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1622 application.SendNotification();
1623 application.Render(16);
1625 tet_infoline("Test that a timer has been started");
1626 Test::EmitGlobalTimerSignal();
1627 application.SendNotification();
1628 application.Render(16);
1630 dummyControl.Unparent();
1633 application.SendNotification();
1634 application.Render(16);
1635 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1637 tet_infoline("Test that pending batch of image loads are cancelled instead of uploaded");
1638 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
1639 application.SendNotification();
1640 application.Render(16);
1641 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
1646 void TestLoopCount(ToolkitTestApplication& application, DummyControl& dummyControl, uint16_t frameCount, uint16_t loopCount, const char* location)
1648 TestGlAbstraction& gl = application.GetGlAbstraction();
1649 TraceCallStack& textureTrace = gl.GetTextureTrace();
1651 textureTrace.Enable(true);
1652 application.GetScene().Add(dummyControl);
1654 application.SendNotification();
1655 application.Render(16);
1657 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_INNER_LOCATION(location));
1659 application.SendNotification();
1660 application.Render();
1662 tet_infoline("Test that a timer has been created");
1663 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_INNER_LOCATION(location));
1665 for(uint16_t i = 0; i < loopCount; i++)
1667 for(uint16_t j = 0; j < frameCount; j++)
1669 if(i == 0 && j == 0)
1671 continue; // Because first frame is already showed and we call 2nd frame at the first time of timer animation.
1673 tet_printf("Test that after %u ticks, and we have %u frame \n", j + 1u, j + 1u);
1674 Test::EmitGlobalTimerSignal();
1675 application.SendNotification();
1676 application.Render(16);
1678 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_INNER_LOCATION(location));
1680 application.SendNotification();
1681 application.Render();
1682 DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_INNER_LOCATION(location));
1683 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_INNER_LOCATION(location));
1685 tet_printf("Test Loop %u \n\n", i + 1u);
1688 tet_printf("Test that after %u loops, and we have no frame. Timer should stop \n", loopCount);
1689 Test::EmitGlobalTimerSignal();
1690 application.SendNotification();
1691 application.Render(16);
1692 DALI_TEST_EQUALS(Test::AreTimersRunning(), false, TEST_INNER_LOCATION(location));
1694 dummyControl.Unparent();
1697 int UtcDaliAnimatedImageVisualLoopCount(void)
1699 ToolkitTestApplication application;
1701 tet_infoline("UtcDaliAnimatedImageVisualLoopCount");
1704 // request AnimatedImageVisual with a property map
1705 // Test with no (0) loop count
1706 VisualFactory factory = VisualFactory::Get();
1707 Visual::Base animatedImageVisual = factory.CreateVisual(
1709 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1710 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1711 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1712 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1713 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1714 .Add(DevelImageVisual::Property::LOOP_COUNT, 0));
1716 DummyControl dummyControl = DummyControl::New(true);
1717 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1718 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1719 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1721 TestLoopCount(application, dummyControl, 4, 0, TEST_LOCATION);
1723 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1724 animatedImageVisual.Reset();
1726 application.SendNotification();
1727 application.Render(16);
1729 // Test with no (1) loop count. Request AnimatedImageVisual with a property map
1730 animatedImageVisual = factory.CreateVisual(
1732 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1733 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1734 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1735 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1736 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1737 .Add(DevelImageVisual::Property::LOOP_COUNT, 1));
1739 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1741 TestLoopCount(application, dummyControl, 4, 1, TEST_LOCATION);
1743 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1744 animatedImageVisual.Reset();
1746 application.SendNotification();
1747 application.Render(16);
1749 // Test with no (100) loop count. Request AnimatedImageVisual with a property map
1750 animatedImageVisual = factory.CreateVisual(
1752 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1753 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1754 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1755 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1756 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1757 .Add(DevelImageVisual::Property::LOOP_COUNT, 100));
1759 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1761 TestLoopCount(application, dummyControl, 4, 100, TEST_LOCATION);
1766 int UtcDaliAnimatedImageVisualPlayback(void)
1768 ToolkitTestApplication application;
1769 TestGlAbstraction& gl = application.GetGlAbstraction();
1770 TraceCallStack& textureTrace = gl.GetTextureTrace();
1772 tet_infoline("UtcDaliAnimatedImageVisualPlayback");
1775 // request AnimatedImageVisual with a property map
1776 // Test with forever (-1) loop count
1777 VisualFactory factory = VisualFactory::Get();
1778 Visual::Base animatedImageVisual = factory.CreateVisual(
1780 .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
1781 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
1782 .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
1783 .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
1784 .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
1785 .Add(DevelImageVisual::Property::LOOP_COUNT, -1));
1787 DummyControl dummyControl = DummyControl::New(true);
1788 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1789 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, animatedImageVisual);
1790 dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
1792 textureTrace.Enable(true);
1793 application.GetScene().Add(dummyControl);
1794 application.SendNotification();
1795 application.Render(16);
1797 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1799 application.SendNotification();
1800 application.Render();
1802 tet_infoline("Test that a timer has been created");
1803 DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
1805 Test::EmitGlobalTimerSignal();
1806 application.SendNotification();
1807 application.Render(16);
1809 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1811 application.SendNotification();
1812 application.Render();
1813 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_LOCATION);
1815 Property::Map attributes;
1816 tet_infoline("Test Pause action. Timer should stop after Pause action");
1817 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PAUSE, attributes);
1818 Test::EmitGlobalTimerSignal();
1819 application.SendNotification();
1820 application.Render(16);
1821 DALI_TEST_EQUALS(Test::AreTimersRunning(), false, TEST_LOCATION);
1823 tet_infoline("Test Play action. Timer should Restart after Play action");
1824 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes);
1825 Test::EmitGlobalTimerSignal();
1826 application.SendNotification();
1827 application.Render(16);
1829 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1831 application.SendNotification();
1832 application.Render();
1833 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_LOCATION);
1835 tet_infoline("Test Stop action. Timer should stop after Stop action");
1836 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, attributes);
1837 Test::EmitGlobalTimerSignal();
1838 application.SendNotification();
1839 application.Render(16);
1840 DALI_TEST_EQUALS(Test::AreTimersRunning(), false, TEST_LOCATION);
1842 tet_infoline("Test Play action. Timer should Restart after Play action");
1843 DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes);
1844 Test::EmitGlobalTimerSignal();
1845 application.SendNotification();
1846 application.Render(16);
1848 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1850 application.SendNotification();
1851 application.Render();
1852 DALI_TEST_EQUALS(Test::AreTimersRunning(), true, TEST_LOCATION);
1854 dummyControl.Unparent();
1860 int UtcDaliAnimatedImageVisualWrapMode(void)
1862 ToolkitTestApplication application;
1863 tet_infoline("UtcDaliAnimatedImageVisualWrapMode");
1865 VisualFactory factory = VisualFactory::Get();
1866 DALI_TEST_CHECK(factory);
1868 // Test wrap mode in animated image visual.
1869 const int width = 950;
1870 const int height = 1080;
1871 const Vector4 pixelArea(0.0f, 0.0f, 950 / 40, 1.0f);
1873 Property::Map propertyMap;
1874 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1875 propertyMap.Insert(ImageVisual::Property::URL, TEST_WEBP_FILE_NAME);
1876 propertyMap.Insert(ImageVisual::Property::PIXEL_AREA, pixelArea);
1877 propertyMap.Insert(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT);
1879 Visual::Base visual = factory.CreateVisual(propertyMap);
1880 DALI_TEST_CHECK(visual);
1882 TestGlAbstraction& gl = application.GetGlAbstraction();
1883 TraceCallStack& textureTrace = gl.GetTextureTrace();
1884 textureTrace.Enable(true);
1885 textureTrace.EnableLogging(true);
1886 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
1887 texParameterTrace.Enable(true);
1888 texParameterTrace.EnableLogging(true);
1890 DummyControl actor = DummyControl::New();
1891 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1892 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
1893 actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
1894 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1896 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1897 application.GetScene().Add(actor);
1898 application.SendNotification();
1899 application.Render();
1901 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1903 application.SendNotification();
1904 application.Render();
1906 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1908 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1910 // WITHOUT atlasing, the wrapping is handled by setting gl texture parameters
1911 std::stringstream out;
1912 out << std::hex << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_REPEAT;
1913 DALI_TEST_CHECK(texParameterTrace.FindMethodAndParams("TexParameteri", out.str()));
1915 // test the uniforms which used to handle the wrap mode
1916 Renderer renderer = actor.GetRendererAt(0u);
1917 DALI_TEST_CHECK(renderer);
1919 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
1920 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION);
1923 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
1928 int UtcDaliAnimatedImageVisualDesiredSize(void)
1930 ToolkitTestApplication application;
1931 tet_infoline("UtcDaliAnimatedImageVisualDesiredSize");
1933 TestGlAbstraction& gl = application.GetGlAbstraction();
1934 TraceCallStack& textureTrace = gl.GetTextureTrace();
1936 // Set desiredWidth < 37 and desiredHeight < 50, which is smaller than original image's size.
1937 int desiredWidth = 15;
1938 int desiredHeight = 20;
1940 Visual::Base visual = VisualFactory::Get().CreateVisual(TEST_GIF_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
1941 DALI_TEST_CHECK(visual);
1943 DummyControl actor = DummyControl::New(true);
1944 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1945 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1947 application.GetScene().Add(actor);
1949 application.SendNotification();
1950 application.Render();
1952 // Trigger count is 2 - first frame and second frame.
1953 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1955 textureTrace.Enable(true);
1956 textureTrace.EnableLogging(true);
1958 application.SendNotification();
1959 application.Render();
1962 std::stringstream out;
1963 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
1964 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
1967 // Unparent to make next trigger
1970 application.SendNotification();
1971 application.Render();
1974 actor.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.0f));
1975 application.GetScene().Add(actor);
1977 application.SendNotification();
1978 application.Render();
1980 // Trigger count is 2 - first frame and second frame.
1981 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1983 textureTrace.Reset();
1985 application.SendNotification();
1986 application.Render();
1989 std::stringstream out;
1990 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
1991 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str())); // The size should not be changed
1998 int UtcDaliAnimatedImageVisualControlVisibilityChanged(void)
2000 ToolkitTestApplication application;
2001 tet_infoline("UtcDaliAnimatedImageVisualControlVisibilityChanged");
2003 Property::Map propertyMap;
2004 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_IMAGE)
2005 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
2006 .Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME)
2007 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2009 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2010 DALI_TEST_CHECK(visual);
2012 DummyControl actor = DummyControl::New(true);
2013 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2014 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2016 Vector2 controlSize(20.f, 30.f);
2017 actor.SetProperty(Actor::Property::SIZE, controlSize);
2019 application.GetScene().Add(actor);
2021 application.SendNotification();
2022 application.Render();
2024 // Trigger count is 2 - load & render a frame
2025 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2027 Property::Map attributes;
2028 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes);
2030 application.SendNotification();
2031 application.Render();
2033 // Check frame number
2034 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2035 Renderer renderer = actor.GetRendererAt(0u);
2036 DALI_TEST_CHECK(renderer);
2038 Test::EmitGlobalTimerSignal();
2039 application.SendNotification();
2040 application.Render(16);
2042 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2044 application.SendNotification();
2045 application.Render();
2047 Property::Map resultMap;
2048 visual.CreatePropertyMap(resultMap);
2050 // check the property values from the returned map from a visual
2051 Property::Value* value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
2052 DALI_TEST_CHECK(value);
2053 DALI_TEST_NOT_EQUALS(value->Get<int>(), 0, Math::MACHINE_EPSILON_100, TEST_LOCATION);
2055 actor.SetProperty(Actor::Property::VISIBLE, false);
2057 Test::EmitGlobalTimerSignal();
2058 application.SendNotification();
2059 application.Render(16);
2061 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2063 application.SendNotification();
2064 application.Render();
2066 visual.CreatePropertyMap(resultMap);
2068 // check the property values from the returned map from a visual
2069 value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
2070 DALI_TEST_CHECK(value);
2071 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION);
2076 int UtcDaliAnimatedImageVisualWindowVisibilityChanged(void)
2078 ToolkitTestApplication application;
2079 tet_infoline("UtcDaliAnimatedImageVisualWindowVisibilityChanged");
2081 Property::Map propertyMap;
2082 propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_IMAGE)
2083 .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
2084 .Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME)
2085 .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2087 Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
2088 DALI_TEST_CHECK(visual);
2090 DummyControl actor = DummyControl::New(true);
2091 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2092 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
2094 Vector2 controlSize(20.f, 30.f);
2095 actor.SetProperty(Actor::Property::SIZE, controlSize);
2097 application.GetScene().Add(actor);
2099 application.SendNotification();
2100 application.Render();
2102 // Trigger count is 2 - load & render a frame
2103 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2105 Property::Map attributes;
2106 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes);
2108 application.SendNotification();
2109 application.Render();
2111 // Check frame number
2112 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2113 Renderer renderer = actor.GetRendererAt(0u);
2114 DALI_TEST_CHECK(renderer);
2116 Test::EmitGlobalTimerSignal();
2117 application.SendNotification();
2118 application.Render(16);
2120 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2122 application.SendNotification();
2123 application.Render();
2125 Property::Map resultMap;
2126 visual.CreatePropertyMap(resultMap);
2128 // check the property values from the returned map from a visual
2129 Property::Value* value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
2130 DALI_TEST_CHECK(value);
2131 DALI_TEST_NOT_EQUALS(value->Get<int>(), 0, Math::MACHINE_EPSILON_100, TEST_LOCATION);
2133 Window window = DevelWindow::Get(actor);
2136 Test::EmitGlobalTimerSignal();
2137 application.SendNotification();
2138 application.Render(16);
2140 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2142 application.SendNotification();
2143 application.Render();
2145 visual.CreatePropertyMap(resultMap);
2147 // check the property values from the returned map from a visual
2148 value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
2149 DALI_TEST_CHECK(value);
2150 DALI_TEST_EQUALS(value->Get<int>(), 0, TEST_LOCATION);