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.
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
24 #include <dali-toolkit-test-suite-utils.h>
25 #include <toolkit-event-thread-callback.h>
26 #include <toolkit-vector-image-renderer.h>
27 #include "dummy-control.h"
29 #include <test-encoded-image-buffer.h>
30 #include <test-native-image.h>
32 #include <dali-toolkit/dali-toolkit.h>
33 #include <dali-toolkit/devel-api/controls/control-devel.h>
34 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
35 #include <dali-toolkit/devel-api/styling/style-manager-devel.h>
36 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
37 #include <dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h>
38 #include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
39 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
40 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
41 #include <dali-toolkit/public-api/image-loader/image-url.h>
42 #include <dali-toolkit/public-api/image-loader/image.h>
43 #include <dali/devel-api/scripting/scripting.h>
46 using namespace Toolkit;
48 void utc_dali_toolkit_image_view_startup(void)
50 test_return_value = TET_UNDEF;
53 void utc_dali_toolkit_image_view_cleanup(void)
55 test_return_value = TET_PASS;
60 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
61 const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
63 // resolution: 1024*1024
64 const char* TEST_IMAGE_1 = TEST_RESOURCE_DIR "/TB-gloss.png";
65 const char* TEST_IMAGE_2 = TEST_RESOURCE_DIR "/tb-norm.png";
67 const char* TEST_BROKEN_IMAGE_DEFAULT = TEST_RESOURCE_DIR "/broken.png";
68 const char* TEST_BROKEN_IMAGE_S = TEST_RESOURCE_DIR "/broken_s.9.png";
69 const char* TEST_BROKEN_IMAGE_M = TEST_RESOURCE_DIR "/broken_m.9.png";
70 const char* TEST_BROKEN_IMAGE_L = TEST_RESOURCE_DIR "/broken_l.9.png";
71 const char* TEST_BROKEN_IMAGE_01 = TEST_RESOURCE_DIR "/button-up.9.png";
72 const char* TEST_BROKEN_IMAGE_02 = TEST_RESOURCE_DIR "/heartsframe.9.png";
74 const char* TEST_INVALID_NPATCH_FILE_NAME_01 = "invalid1.9.png";
76 // resolution: 34*34, pixel format: RGBA8888
77 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
78 // resolution: 600*600, pixel format: RGB888
79 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
81 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
82 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
84 const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
85 const char* TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
86 const char* TEST_WEBP_FILE_NAME = TEST_RESOURCE_DIR "/dali-logo.webp";
88 void TestUrl(ImageView imageView, const std::string url)
90 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
92 std::string urlActual;
93 DALI_TEST_CHECK(value.Get(urlActual));
94 DALI_TEST_EQUALS(urlActual, url, TEST_LOCATION);
99 int UtcDaliImageViewNewP(void)
101 ToolkitTestApplication application;
103 ImageView imageView = ImageView::New();
105 DALI_TEST_CHECK(imageView);
110 int UtcDaliImageViewNewUrlP(void)
112 ToolkitTestApplication application;
114 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
115 DALI_TEST_CHECK(imageView);
117 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
122 int UtcDaliImageViewConstructorP(void)
124 ToolkitTestApplication application;
128 DALI_TEST_CHECK(!imageView);
133 int UtcDaliImageViewCopyConstructorP(void)
135 ToolkitTestApplication application;
137 // Initialize an object, ref count == 1
138 ImageView imageView = ImageView::New();
140 ImageView copy(imageView);
141 DALI_TEST_CHECK(copy);
146 int UtcDaliImageViewMoveConstructor(void)
148 ToolkitTestApplication application;
150 ImageView imageView = ImageView::New();
151 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
152 imageView.SetProperty(Actor::Property::SENSITIVE, false);
153 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
155 ImageView moved = std::move(imageView);
156 DALI_TEST_CHECK(moved);
157 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
158 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
159 DALI_TEST_CHECK(!imageView);
164 int UtcDaliImageViewAssignmentOperatorP(void)
166 ToolkitTestApplication application;
168 ImageView imageView = ImageView::New();
170 ImageView copy(imageView);
171 DALI_TEST_CHECK(copy);
172 DALI_TEST_EQUALS(imageView, copy, TEST_LOCATION);
177 int UtcDaliImageViewMoveAssignment(void)
179 ToolkitTestApplication application;
181 ImageView imageView = ImageView::New();
182 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
183 imageView.SetProperty(Actor::Property::SENSITIVE, false);
184 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
187 moved = std::move(imageView);
188 DALI_TEST_CHECK(moved);
189 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
190 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
191 DALI_TEST_CHECK(!imageView);
196 int UtcDaliImageViewDownCastP(void)
198 ToolkitTestApplication application;
200 ImageView imageView = ImageView::New();
202 BaseHandle object(imageView);
204 ImageView imageView2 = ImageView::DownCast(object);
205 DALI_TEST_CHECK(imageView2);
207 ImageView imageView3 = DownCast<ImageView>(object);
208 DALI_TEST_CHECK(imageView3);
213 int UtcDaliImageViewDownCastN(void)
215 ToolkitTestApplication application;
217 BaseHandle unInitializedObject;
219 ImageView imageView1 = ImageView::DownCast(unInitializedObject);
220 DALI_TEST_CHECK(!imageView1);
222 ImageView imageView2 = DownCast<ImageView>(unInitializedObject);
223 DALI_TEST_CHECK(!imageView2);
228 int UtcDaliImageViewTypeRegistry(void)
230 ToolkitTestApplication application;
232 TypeRegistry typeRegistry = TypeRegistry::Get();
233 DALI_TEST_CHECK(typeRegistry);
235 TypeInfo typeInfo = typeRegistry.GetTypeInfo("ImageView");
236 DALI_TEST_CHECK(typeInfo);
238 BaseHandle handle = typeInfo.CreateInstance();
239 DALI_TEST_CHECK(handle);
241 ImageView imageView = ImageView::DownCast(handle);
242 DALI_TEST_CHECK(imageView);
247 int UtcDaliImageViewSetGetProperty01(void)
249 ToolkitTestApplication application;
251 ImageView imageView = ImageView::New();
253 Property::Index idx = imageView.GetPropertyIndex("image");
254 DALI_TEST_EQUALS(idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION);
256 imageView.SetProperty(idx, TEST_IMAGE_FILE_NAME);
257 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
262 int UtcDaliImageViewPreMultipliedAlphaPng(void)
264 ToolkitTestApplication application;
266 // Set up trace debug
267 TestGlAbstraction& gl = application.GetGlAbstraction();
268 TraceCallStack& textureTrace = gl.GetTextureTrace();
269 textureTrace.Enable(true);
271 Property::Map imageMap;
272 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
273 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
275 ImageView imageView1 = ImageView::New();
276 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
278 application.GetScene().Add(imageView1);
280 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
282 DALI_TEST_CHECK(value.Get(enable));
283 DALI_TEST_CHECK(enable); // Default value is true
285 // loading started, this waits for the loader thread for max 30 seconds
286 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
288 application.SendNotification();
289 application.Render();
291 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
292 DALI_TEST_CHECK(value.Get(enable));
293 DALI_TEST_CHECK(enable); // Keep true
295 // conventional alpha blending
296 Renderer renderer1 = imageView1.GetRendererAt(0);
297 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
298 DALI_TEST_CHECK(value.Get(enable));
299 DALI_TEST_CHECK(enable);
301 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
302 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
303 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
304 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
305 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
306 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
307 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
308 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
310 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
311 textureTrace.Reset();
313 // Disable pre-multiplied alpha blending
314 imageView1.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
317 Property::Map attributes;
318 DevelControl::DoAction(imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
320 // loading started, this waits for the loader thread for max 30 seconds
321 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
323 application.SendNotification();
324 application.Render();
326 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
327 DALI_TEST_CHECK(value.Get(enable));
328 DALI_TEST_CHECK(!enable);
330 // conventional alpha blending
331 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
332 DALI_TEST_CHECK(value.Get(enable));
333 DALI_TEST_CHECK(!enable);
335 srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
336 destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
337 srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
338 destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
339 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
340 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
341 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
342 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
344 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
345 textureTrace.Reset();
347 // Make a new ImageView using the same image
348 ImageView imageView2 = ImageView::New();
349 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
351 application.GetScene().Add(imageView2);
353 application.SendNotification();
354 application.Render();
356 Renderer renderer2 = imageView2.GetRendererAt(0);
357 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
358 DALI_TEST_CHECK(value.Get(enable));
359 DALI_TEST_CHECK(enable);
361 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
362 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
363 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
364 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
365 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
366 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
367 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
368 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
370 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
375 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
377 ToolkitTestApplication application;
379 // Set up trace debug
380 TestGlAbstraction& gl = application.GetGlAbstraction();
381 TraceCallStack& textureTrace = gl.GetTextureTrace();
382 textureTrace.Enable(true);
384 Property::Map imageMap;
385 imageMap[ImageVisual::Property::URL] = gImage_600_RGB;
386 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
388 ImageView imageView1 = ImageView::New();
389 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
391 application.GetScene().Add(imageView1);
393 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
395 DALI_TEST_CHECK(value.Get(enable));
396 DALI_TEST_CHECK(enable); // Default value is true
398 // loading started, this waits for the loader thread for max 30 seconds
399 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
401 application.SendNotification();
402 application.Render();
404 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
405 DALI_TEST_CHECK(value.Get(enable));
406 DALI_TEST_CHECK(!enable); // Should be false after loading
408 // conventional alpha blending
409 Renderer renderer1 = imageView1.GetRendererAt(0);
410 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
411 DALI_TEST_CHECK(value.Get(enable));
412 DALI_TEST_CHECK(!enable);
414 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
415 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
416 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
417 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
418 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
419 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
420 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
421 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
423 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
424 textureTrace.Reset();
426 ImageView imageView2 = ImageView::New();
427 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
429 // Disable pre-multiplied alpha blending
430 imageView2.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
432 application.GetScene().Add(imageView2);
434 application.SendNotification();
435 application.Render();
437 value = imageView2.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
438 DALI_TEST_CHECK(value.Get(enable));
439 DALI_TEST_CHECK(!enable);
441 // conventional alpha blending
442 Renderer renderer2 = imageView2.GetRendererAt(0);
443 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
444 DALI_TEST_CHECK(value.Get(enable));
445 DALI_TEST_CHECK(!enable);
447 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
448 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
449 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
450 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
451 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
452 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
453 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
454 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
456 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
461 int UtcDaliImageViewPixelArea(void)
463 // Test pixel area property
464 ToolkitTestApplication application;
466 static std::vector<UniformData> customUniforms =
468 UniformData("pixelArea", Property::Type::VECTOR4),
471 TestGraphicsController& graphics = application.GetGraphicsController();
472 graphics.AddCustomUniforms(customUniforms);
474 // Gif image, use AnimatedImageVisual internally
475 // Atlasing is applied to pack multiple frames, use custom wrap mode
476 ImageView gifView = ImageView::New();
477 const Vector4 pixelAreaVisual(0.f, 0.f, 2.f, 2.f);
478 gifView.SetProperty(ImageView::Property::IMAGE,
479 Property::Map().Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME).Add(ImageVisual::Property::PIXEL_AREA, pixelAreaVisual));
482 Integration::Scene stage = application.GetScene();
486 application.SendNotification();
487 application.Render(16);
489 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
491 application.SendNotification();
492 application.Render();
493 DALI_TEST_CHECK(gifView.GetRendererCount() == 1u);
495 const Vector4 fullTextureRect(0.f, 0.f, 1.f, 1.f);
496 // test that the pixel area value defined in the visual property map is registered on renderer
497 Renderer renderer = gifView.GetRendererAt(0);
498 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
499 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION);
501 // test that the shader has the default pixel area value registered.
502 Shader shader = renderer.GetShader();
503 pixelAreaValue = shader.GetProperty(shader.GetPropertyIndex("pixelArea"));
504 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION);
506 // test that the uniform uses the pixelArea property on the renderer.
507 TestGlAbstraction& gl = application.GetGlAbstraction();
508 Vector4 pixelAreaUniform;
509 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
510 DALI_TEST_EQUALS(pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
512 // set the pixelArea property on the control
513 const Vector4 pixelAreaControl(-1.f, -1.f, 3.f, 3.f);
514 gifView.SetProperty(ImageView::Property::PIXEL_AREA, pixelAreaControl);
515 application.SendNotification();
516 application.Render(16);
518 // check the pixelArea property on the control
519 pixelAreaValue = gifView.GetProperty(gifView.GetPropertyIndex("pixelArea"));
520 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION);
521 // test that the uniform uses the pixelArea property on the control.
522 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
523 DALI_TEST_EQUALS(pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
528 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
530 ToolkitTestApplication application;
531 TestGlAbstraction& gl = application.GetGlAbstraction();
532 const std::vector<GLuint>& textures = gl.GetBoundTextures();
533 size_t numTextures = textures.size();
535 // Async loading, no atlasing for big size image
536 ImageView imageView = ImageView::New(gImage_600_RGB);
538 // By default, Aysnc loading is used
539 application.GetScene().Add(imageView);
540 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
541 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
543 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
545 application.SendNotification();
546 application.Render(16);
547 application.SendNotification();
549 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
550 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
555 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
557 ToolkitTestApplication application;
559 //Async loading, automatic atlasing for small size image
560 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
562 callStack.Enable(true);
564 Property::Map imageMap;
566 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
567 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
568 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
569 imageMap[ImageVisual::Property::ATLASING] = true;
571 ImageView imageView = ImageView::New();
572 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
573 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
575 // By default, Aysnc loading is used
576 // loading is not started if the actor is offScene
578 application.GetScene().Add(imageView);
579 application.SendNotification();
580 application.Render(16);
581 application.Render(16);
582 application.SendNotification();
584 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
585 application.SendNotification();
586 application.Render(16);
587 application.Render(16);
588 application.SendNotification();
590 // loading started, this waits for the loader thread for max 30 seconds
591 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
593 application.SendNotification();
594 application.Render(16);
596 callStack.Enable(false);
598 TraceCallStack::NamedParams params;
599 params["width"] << 34;
600 params["height"] << 34;
601 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
606 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
608 ToolkitTestApplication application;
610 //Async loading, automatic atlasing for small size image
611 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
613 callStack.Enable(true);
615 Property::Map asyncLoadingMap;
616 asyncLoadingMap["url"] = gImage_34_RGBA;
617 asyncLoadingMap["desiredHeight"] = 34;
618 asyncLoadingMap["desiredWidth"] = 34;
619 asyncLoadingMap["synchronousLoading"] = false;
620 asyncLoadingMap["atlasing"] = true;
622 ImageView imageView = ImageView::New();
623 imageView.SetProperty(ImageView::Property::IMAGE, asyncLoadingMap);
625 application.GetScene().Add(imageView);
626 application.SendNotification();
627 application.Render(16);
628 application.Render(16);
629 application.SendNotification();
631 // loading started, this waits for the loader thread for max 30 seconds
632 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
634 application.SendNotification();
635 application.Render(16);
637 callStack.Enable(false);
639 TraceCallStack::NamedParams params;
640 params["width"] << 34;
641 params["height"] << 34;
642 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
647 int UtcDaliImageViewSyncLoading(void)
649 ToolkitTestApplication application;
651 tet_infoline("ImageView Testing sync loading and size using index key property map");
653 Property::Map syncLoadingMap;
654 syncLoadingMap[ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
655 syncLoadingMap[ImageVisual::Property::ATLASING] = true;
657 // Sync loading, no atlasing for big size image
659 ImageView imageView = ImageView::New();
661 // Sync loading is used
662 syncLoadingMap[ImageVisual::Property::URL] = gImage_600_RGB;
663 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
666 // Sync loading, automatic atlasing for small size image
668 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
670 callStack.Enable(true);
672 ImageView imageView = ImageView::New();
674 // Sync loading is used
675 syncLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
676 syncLoadingMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
677 syncLoadingMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
678 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
680 application.GetScene().Add(imageView);
681 application.SendNotification();
682 application.Render(16);
684 TraceCallStack::NamedParams params;
685 params["width"] << 34;
686 params["height"] << 34;
687 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
694 int UtcDaliImageViewSyncLoading02(void)
696 ToolkitTestApplication application;
698 tet_infoline("ImageView Testing sync loading and size using string key property map");
700 // Sync loading, automatic atlasing for small size image
702 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
704 callStack.Enable(true);
706 ImageView imageView = ImageView::New();
708 // Sync loading is used
709 Property::Map syncLoadingMap;
710 syncLoadingMap["url"] = gImage_34_RGBA;
711 syncLoadingMap["desiredHeight"] = 34;
712 syncLoadingMap["desiredWidth"] = 34;
713 syncLoadingMap["synchronousLoading"] = true;
714 syncLoadingMap["atlasing"] = true;
715 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
717 application.GetScene().Add(imageView);
718 application.SendNotification();
719 application.Render(16);
721 TraceCallStack::NamedParams params;
722 params["width"] << 34;
723 params["height"] << 34;
724 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
731 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
733 ToolkitTestApplication application;
734 TestGlAbstraction& gl = application.GetGlAbstraction();
735 const std::vector<GLuint>& textures = gl.GetBoundTextures();
736 size_t numTextures = textures.size();
738 // Get encoded raw-buffer image and generate url
739 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
740 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
742 // Async loading, no atlasing for big size image
743 ImageView imageView = ImageView::New(url.GetUrl());
745 // By default, Aysnc loading is used
746 application.GetScene().Add(imageView);
747 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
748 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
750 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
752 application.SendNotification();
753 application.Render(16);
754 application.SendNotification();
756 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
757 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
762 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
764 ToolkitTestApplication application;
766 // Get encoded raw-buffer image and generate url
767 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
768 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
769 ImageUrl url2 = Toolkit::Image::GenerateUrl(buffer);
771 // Generate url is not equal to url2
772 // NOTE : This behavior may changed when ImageUrl compare operator changed.
773 DALI_TEST_CHECK(url != url2);
774 // Generate url's string is equal to url2's string
775 DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
777 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
778 url2 = Toolkit::Image::GenerateUrl(buffer2);
780 // Check whethere two url are not equal
781 DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
783 // Async loading, automatic atlasing for small size image
784 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
786 callStack.Enable(true);
788 Property::Map imageMap;
790 imageMap[ImageVisual::Property::URL] = url.GetUrl();
791 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 600;
792 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 600;
793 imageMap[ImageVisual::Property::ATLASING] = true;
795 // No atlasing with big image
796 ImageView imageView_bigdesired = ImageView::New();
797 imageView_bigdesired.SetProperty(ImageView::Property::IMAGE, imageMap);
798 imageView_bigdesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
800 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 0;
801 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 0;
803 // No atlasing with zero desired size
804 ImageView imageView_nodesired = ImageView::New();
805 imageView_nodesired.SetProperty(ImageView::Property::IMAGE, imageMap);
806 imageView_nodesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
808 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
809 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
811 ImageView imageView = ImageView::New();
812 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
813 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
815 // By default, Aysnc loading is used
816 // loading is not started if the actor is offScene
817 application.GetScene().Add(imageView);
818 application.GetScene().Add(imageView_bigdesired);
819 application.GetScene().Add(imageView_nodesired);
820 application.SendNotification();
821 application.Render(16);
823 // loading started, this waits for the loader thread for max 30 seconds
824 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
826 application.Render(16);
827 application.SendNotification();
829 // Change url to url2
830 imageMap[ImageVisual::Property::URL] = url2.GetUrl();
831 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
833 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
834 application.SendNotification();
835 application.Render(16);
836 application.Render(16);
837 application.SendNotification();
839 // loading started, this waits for the loader thread for max 30 seconds
840 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
842 application.SendNotification();
843 application.Render(16);
845 callStack.Enable(false);
847 TraceCallStack::NamedParams params;
848 params["width"] << 34;
849 params["height"] << 34;
850 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
855 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
857 ToolkitTestApplication application;
859 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
861 // Get encoded raw-buffer image and generate url
862 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
863 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
865 // Sync loading, automatic atlasing for small size image
867 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
869 callStack.Enable(true);
871 ImageView imageView = ImageView::New();
873 // Sync loading is used
874 Property::Map syncLoadingMap;
875 syncLoadingMap["url"] = url.GetUrl();
876 syncLoadingMap["alphaMaskUrl"] = gImage_34_RGBA;
877 syncLoadingMap["desiredHeight"] = 34;
878 syncLoadingMap["desiredWidth"] = 34;
879 syncLoadingMap["synchronousLoading"] = true;
880 syncLoadingMap["atlasing"] = true;
881 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
883 application.GetScene().Add(imageView);
884 application.SendNotification();
885 application.Render(16);
887 TraceCallStack::NamedParams params;
888 params["width"] << 34;
889 params["height"] << 34;
890 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
898 int UtcDaliImageViewAddedTexture(void)
900 ToolkitTestApplication application;
902 tet_infoline("ImageView Testing image view with texture provided manager url");
904 ImageView imageView = ImageView::New();
906 // empty texture is ok, though pointless from app point of view
908 std::string url = TextureManager::AddTexture(empty);
909 DALI_TEST_CHECK(url.size() > 0u);
911 Property::Map propertyMap;
912 propertyMap[ImageVisual::Property::URL] = url;
913 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
915 application.GetScene().Add(imageView);
916 application.SendNotification();
917 application.Render();
922 int UtcDaliImageViewSizeWithBackground(void)
924 ToolkitTestApplication application;
928 ImageView imageView = ImageView::New();
930 imageView.SetProperty(Control::Property::BACKGROUND,
932 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
933 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
934 {ImageVisual::Property::DESIRED_WIDTH, width},
935 {ImageVisual::Property::DESIRED_HEIGHT, height},
938 application.GetScene().Add(imageView);
939 application.SendNotification();
940 application.Render();
942 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
943 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
948 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
950 ToolkitTestApplication application;
952 int widthBackground = 100;
953 int heightBackground = 200;
957 ImageView imageView = ImageView::New();
959 imageView.SetProperty(Control::Property::BACKGROUND,
961 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
962 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
963 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
964 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground},
967 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio, 600x600 pixels
969 application.GetScene().Add(imageView);
970 application.SendNotification();
971 application.Render();
973 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
974 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
979 int UtcDaliImageViewHeightForWidthBackground(void)
981 ToolkitTestApplication application;
983 int widthBackground = 100;
984 int heightBackground = 200;
986 ImageView imageView = ImageView::New();
988 imageView.SetProperty(Control::Property::BACKGROUND,
989 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
990 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
991 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
992 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}});
994 application.GetScene().Add(imageView);
995 application.SendNotification();
996 application.Render();
998 Control control = Control::DownCast(imageView);
999 DALI_TEST_CHECK(control);
1000 DALI_TEST_EQUALS(imageView.GetHeightForWidth(123.f), control.GetHeightForWidth(123.f), TEST_LOCATION);
1001 DALI_TEST_EQUALS(imageView.GetWidthForHeight(321.f), control.GetWidthForHeight(321.f), TEST_LOCATION);
1006 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
1008 ToolkitTestApplication application;
1010 int widthBackground = 100;
1011 int heightBackground = 200;
1015 ImageView imageView = ImageView::New();
1017 imageView.SetProperty(Control::Property::BACKGROUND,
1018 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1019 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1020 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1021 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}}); // 1 to 2 ratio
1023 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio
1025 application.GetScene().Add(imageView);
1026 application.SendNotification();
1027 application.Render();
1029 DALI_TEST_EQUALS(imageView.GetHeightForWidth(width), (float)height, TEST_LOCATION);
1030 DALI_TEST_EQUALS(imageView.GetWidthForHeight(height), (float)width, TEST_LOCATION);
1035 int UtcDaliImageViewSetImageUrl(void)
1037 ToolkitTestApplication application;
1039 ImageView imageView = ImageView::New();
1040 imageView.SetImage(TEST_IMAGE_FILE_NAME);
1041 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
1043 imageView.SetImage(TEST_IMAGE_FILE_NAME2);
1044 TestUrl(imageView, TEST_IMAGE_FILE_NAME2);
1049 bool gResourceReadySignalFired = false;
1050 Vector3 gNaturalSize;
1052 void ResourceReadySignal(Control control)
1054 gResourceReadySignalFired = true;
1057 void OnResourceReadySignalSVG(Control control)
1059 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1060 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(control);
1061 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1062 Property::Map resultMap;
1063 imageVisual.CreatePropertyMap(resultMap);
1065 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1066 DALI_TEST_CHECK(transformValue);
1067 Property::Map* retMap = transformValue->GetMap();
1068 DALI_TEST_CHECK(retMap);
1070 // Fitting mode should not be applied at this point
1071 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::SIZE)->Get<Vector2>(), Vector2::ZERO, TEST_LOCATION);
1074 int UtcDaliImageViewCheckResourceReady(void)
1076 ToolkitTestApplication application;
1078 gResourceReadySignalFired = false;
1080 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1081 ImageView imageView = ImageView::New(TEST_GIF_FILE_NAME);
1083 imageView.SetProperty(Control::Property::BACKGROUND,
1084 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1085 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1086 {ImageVisual::Property::DESIRED_WIDTH, 100},
1087 {ImageVisual::Property::DESIRED_HEIGHT, 200}});
1089 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1091 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1093 application.GetScene().Add(imageView);
1095 // loading started, this waits for the loader thread
1096 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1098 application.SendNotification();
1099 application.Render(16);
1101 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1103 application.SendNotification();
1104 application.Render();
1106 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1108 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1113 int UtcDaliImageViewSetImageTypeChangesP(void)
1115 ToolkitTestApplication application;
1117 ImageView imageView = ImageView::New();
1118 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1120 application.GetScene().Add(imageView);
1124 Toolkit::Visual::Base visual;
1126 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1127 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1129 application.SendNotification();
1130 application.Render(16);
1132 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1134 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1135 DALI_TEST_CHECK(!visual); // Visual should be invalid
1138 imageView.SetImage("TEST_URL");
1140 application.SendNotification();
1141 application.Render(16);
1143 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1144 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1146 DALI_TEST_CHECK(value.Get(url)); // Value should NOT be empty
1147 DALI_TEST_CHECK(!value.Get(map)); // Value should be empty
1148 DALI_TEST_CHECK(visual); // Visual should be valid
1151 imageView.SetImage("");
1153 application.SendNotification();
1154 application.Render(16);
1156 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1157 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1159 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1161 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1162 DALI_TEST_CHECK(!visual); // Visual should be invalid
1164 // Set a URL in property map
1165 Property::Map propertyMap;
1166 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1167 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1169 application.SendNotification();
1170 application.Render(16);
1172 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1173 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1175 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1176 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1177 DALI_TEST_CHECK(visual); // Visual should be valid
1179 // Set a URL in property map again
1180 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1181 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1183 application.SendNotification();
1184 application.Render(16);
1186 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1187 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1189 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1190 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1191 DALI_TEST_CHECK(visual); // Visual should be valid
1193 // Set an empty URL in property map
1194 propertyMap[ImageVisual::Property::URL] = std::string();
1195 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1197 application.SendNotification();
1198 application.Render(16);
1200 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1201 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1203 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1204 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1205 DALI_TEST_CHECK(!visual); // Visual should be invalid
1207 // Set a URL in property map again
1208 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1209 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1211 application.SendNotification();
1212 application.Render(16);
1214 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1215 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1217 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1218 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1219 DALI_TEST_CHECK(visual); // Visual should be valid
1221 // Set an empty property map
1222 propertyMap.Clear();
1223 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1225 application.SendNotification();
1226 application.Render(16);
1228 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1229 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1231 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1232 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1233 DALI_TEST_CHECK(map.Empty()); // But PropertyMap should be empty
1234 DALI_TEST_CHECK(!visual); // Visual should be invalid
1239 int UtcDaliImageViewResourceUrlP(void)
1241 ToolkitTestApplication application;
1243 ImageView imageView = ImageView::New();
1244 DALI_TEST_CHECK(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>().empty());
1246 imageView.SetProperty(ImageView::Property::IMAGE, "TestString");
1247 DALI_TEST_EQUALS(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>(), "TestString", TEST_LOCATION);
1252 int UtcDaliImageViewReplaceImage(void)
1254 ToolkitTestApplication application;
1256 gResourceReadySignalFired = false;
1258 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1259 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1261 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1263 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1265 application.GetScene().Add(imageView);
1267 application.SendNotification();
1268 application.Render(16);
1270 // loading started, this waits for the loader thread for max 30 seconds
1271 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1273 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1275 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1277 gResourceReadySignalFired = false;
1279 imageView.SetImage(TEST_IMAGE_2);
1281 application.SendNotification();
1282 application.Render(16);
1284 // loading started, this waits for the loader thread for max 30 seconds
1285 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1287 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1289 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1291 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1296 int UtcDaliImageViewReloadAlphaMaskImage(void)
1298 ToolkitTestApplication application;
1300 gResourceReadySignalFired = false;
1302 ImageView dummy = ImageView::New();
1303 ImageView imageView = ImageView::New();
1304 Property::Map propertyMap;
1306 // To keep alpha mask cached, scene on some dummy image.
1307 // Note : If we don't cache alpha mask image, the reference count of mask image become zero.
1308 // In this case, we might need to wait mask image loading, which is not neccesary & can be changed behavior.
1309 propertyMap[ImageVisual::Property::URL] = gImage_600_RGB;
1310 propertyMap[ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
1311 dummy.SetProperty(ImageView::Property::IMAGE, propertyMap);
1313 application.GetScene().Add(dummy);
1315 application.SendNotification();
1316 application.Render(16);
1318 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1320 application.SendNotification();
1321 application.Render(16);
1323 propertyMap.Clear();
1324 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1325 propertyMap[ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
1326 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1328 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1330 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1332 application.GetScene().Add(imageView);
1334 application.SendNotification();
1335 application.Render(16);
1337 // Load image and use cached mask. Now we try to apply masking.
1338 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1340 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
1342 // Cancel apply masking.
1343 imageView.Unparent();
1345 application.SendNotification();
1346 application.Render(16);
1348 // Reload same image again.
1349 application.GetScene().Add(imageView);
1351 application.SendNotification();
1352 application.Render(16);
1354 // Finish apply masking.
1355 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1357 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1358 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1359 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1364 void OnRelayoutOverride(Size size)
1366 gNaturalSize = size; // Size Relayout is using
1369 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1371 ToolkitTestApplication application;
1373 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1374 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1375 imageView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1377 DummyControl dummyControl = DummyControl::New(true);
1378 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1379 dummyControl.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
1381 dummyControl.Add(imageView);
1382 dummyImpl.SetRelayoutCallback(&OnRelayoutOverride);
1383 application.GetScene().Add(dummyControl);
1385 application.SendNotification();
1386 application.Render();
1388 // loading started, this waits for the loader thread for max 30 seconds
1389 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1391 DALI_TEST_EQUALS(gNaturalSize.width, 1024.0f, TEST_LOCATION);
1392 DALI_TEST_EQUALS(gNaturalSize.height, 1024.0f, TEST_LOCATION);
1394 gNaturalSize = Vector3::ZERO;
1396 imageView.SetImage(gImage_600_RGB);
1398 // Waiting for resourceReady so SendNotifcation not called here.
1400 // loading started, this waits for the loader thread for max 30 seconds
1401 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1403 // Trigger a potential relayout
1404 application.SendNotification();
1405 application.Render();
1407 DALI_TEST_EQUALS(gNaturalSize.width, 600.0f, TEST_LOCATION);
1408 DALI_TEST_EQUALS(gNaturalSize.height, 600.0f, TEST_LOCATION);
1413 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1415 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1417 ToolkitTestApplication application;
1419 gResourceReadySignalFired = false;
1421 Property::Map imageMap;
1423 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1424 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1426 tet_infoline("Creating ImageView without URL so image does not start loading");
1427 ImageView imageView = ImageView::New();
1428 tet_infoline("Connect to image loaded signal before setting image");
1429 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1430 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1431 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1433 // loading started, this waits for the loader thread
1434 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1436 application.SendNotification();
1437 application.Render(16);
1439 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1444 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1446 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1448 ToolkitTestApplication application;
1450 gResourceReadySignalFired = false;
1452 Property::Map imageMap;
1454 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1455 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1457 ImageView imageView = ImageView::New();
1458 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1459 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1461 // loading started, this waits for the loader thread
1462 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1464 application.SendNotification();
1465 application.Render(16);
1467 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1468 gResourceReadySignalFired = false;
1470 ImageView imageViewWithExistingImage = ImageView::New();
1471 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1472 imageViewWithExistingImage.SetProperty(ImageView::Property::IMAGE, imageMap);
1474 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1479 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1481 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1483 ToolkitTestApplication application;
1485 gResourceReadySignalFired = false;
1487 Property::Map imageImmediateLoadingMap;
1488 imageImmediateLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1489 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1491 tet_infoline("Immediate load an image");
1492 ImageView imageView = ImageView::New();
1493 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1494 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
1496 // loading started, this waits for the loader thread
1497 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1499 application.SendNotification();
1500 application.Render(16);
1502 tet_infoline("Check image loaded");
1503 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1504 gResourceReadySignalFired = false;
1506 tet_infoline("Create another ImageView with the same URL");
1507 ImageView imageViewWithExistingImage = ImageView::New(gImage_34_RGBA);
1508 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1509 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1511 application.GetScene().Add(imageViewWithExistingImage);
1513 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1518 int UtcDaliImageViewPaddingProperty(void)
1520 ToolkitTestApplication application;
1522 ImageView imageView = ImageView::New();
1523 Property::Map imagePropertyMap;
1524 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1525 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
1526 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1527 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1528 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1529 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1530 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1531 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1532 application.GetScene().Add(imageView);
1534 application.SendNotification();
1535 application.Render();
1537 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1539 ImageView childImage = ImageView::New();
1540 childImage.SetBackgroundColor(Color::BLACK);
1541 childImage.SetProperty(Actor::Property::SIZE, Vector2(10.f, 10.f));
1542 imageView.Add(childImage);
1544 application.SendNotification();
1545 application.Render();
1547 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1548 DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
1550 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1551 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1552 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1553 Property::Map resultMap;
1554 imageVisual.CreatePropertyMap(resultMap);
1556 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1557 DALI_TEST_CHECK(transformValue);
1558 Property::Map* retMap = transformValue->GetMap();
1559 DALI_TEST_CHECK(retMap);
1561 // Image Visual should be positioned depending on ImageView's padding
1562 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1567 int UtcDaliImageViewPaddingProperty02(void)
1569 ToolkitTestApplication application;
1571 ImageView imageView = ImageView::New();
1572 Property::Map imagePropertyMap;
1573 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1574 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1575 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1576 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1577 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1578 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1579 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1580 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1581 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1582 application.GetScene().Add(imageView);
1584 application.SendNotification();
1585 application.Render();
1587 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1589 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1590 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1591 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1592 Property::Map resultMap;
1593 imageVisual.CreatePropertyMap(resultMap);
1595 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1596 DALI_TEST_CHECK(transformValue);
1597 Property::Map* retMap = transformValue->GetMap();
1598 DALI_TEST_CHECK(retMap);
1600 // Image Visual should be positioned depending on ImageView's padding
1601 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1606 int UtcDaliImageViewPaddingProperty03(void)
1608 tet_infoline("Test Setting Image Padding then removing it.");
1610 ToolkitTestApplication application;
1612 ImageView imageView = ImageView::New();
1613 Property::Map imagePropertyMap;
1614 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1615 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1616 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1617 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1618 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1619 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1620 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1621 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1622 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1623 application.GetScene().Add(imageView);
1625 application.SendNotification();
1626 application.Render();
1628 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1630 tet_infoline("Remove Padding and test Visual is position correctly");
1632 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1634 application.SendNotification();
1635 application.Render();
1637 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1638 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1639 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1640 Property::Map resultMap;
1641 imageVisual.CreatePropertyMap(resultMap);
1643 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1644 DALI_TEST_CHECK(transformValue);
1645 Property::Map* retMap = transformValue->GetMap();
1646 DALI_TEST_CHECK(retMap);
1648 // Image Visual should be positioned depending on ImageView's padding
1649 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1654 int UtcDaliImageViewPaddingProperty04(void)
1656 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1658 ToolkitTestApplication application;
1660 ImageView imageView = ImageView::New();
1661 Property::Map imagePropertyMap;
1662 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1663 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1664 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1665 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1666 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FILL;
1667 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1668 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1669 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1670 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1671 application.GetScene().Add(imageView);
1673 application.SendNotification();
1674 application.Render();
1676 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1678 tet_infoline("Remove Padding and test Visual is position correctly");
1680 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1682 application.SendNotification();
1683 application.Render();
1685 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1686 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1687 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1688 Property::Map resultMap;
1689 imageVisual.CreatePropertyMap(resultMap);
1691 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1692 DALI_TEST_CHECK(transformValue);
1693 Property::Map* retMap = transformValue->GetMap();
1694 DALI_TEST_CHECK(retMap);
1696 // Image Visual should be positioned depending on ImageView's padding
1697 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1702 int UtcDaliImageViewTransformTest01(void)
1704 tet_infoline("Test Setting a offset transform on the ImageView");
1706 ToolkitTestApplication application;
1708 ImageView imageView = ImageView::New();
1709 Property::Map imagePropertyMap;
1710 imagePropertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE)
1711 .Add(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/Kid1.svg")
1712 .Add(ImageVisual::Property::DESIRED_WIDTH, 120)
1713 .Add(ImageVisual::Property::DESIRED_HEIGHT, 120)
1714 .Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL)
1715 .Add(Visual::Property::TRANSFORM,
1716 Property::Map().Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1717 Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE))
1718 .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(8, 8)));
1720 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1721 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1722 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1723 application.GetScene().Add(imageView);
1725 application.SendNotification();
1726 application.Render();
1728 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1729 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1730 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1731 Property::Map resultMap;
1732 imageVisual.CreatePropertyMap(resultMap);
1734 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1735 DALI_TEST_CHECK(transformValue);
1736 Property::Map* retMap = transformValue->GetMap();
1737 DALI_TEST_CHECK(retMap);
1739 // Image Visual should be positioned depending on ImageView's padding
1740 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(8, 8), TEST_LOCATION);
1741 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET_POLICY)->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1746 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1748 ToolkitTestApplication application;
1750 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1751 ImageView imageView = ImageView::New();
1752 Property::Map imageMap;
1753 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1754 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_34_RGBA;
1755 imageMap[Toolkit::ImageVisual::Property::ATLASING] = true;
1756 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1757 application.GetScene().Add(imageView);
1759 // Trigger a potential relayout
1760 application.SendNotification();
1761 application.Render();
1763 Vector3 naturalSize = imageView.GetNaturalSize();
1765 DALI_TEST_EQUALS(naturalSize.width, 34.0f, TEST_LOCATION);
1766 DALI_TEST_EQUALS(naturalSize.height, 34.0f, TEST_LOCATION);
1771 int UtcDaliImageViewFillMode(void)
1773 ToolkitTestApplication application;
1775 tet_infoline("Create an ImageVisual without padding and set the fill-mode to fill");
1777 ImageView imageView = ImageView::New();
1778 Property::Map imageMap;
1779 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1780 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB);
1781 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL);
1783 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1785 application.GetScene().Add(imageView);
1787 // Trigger a potential relayout
1788 application.SendNotification();
1789 application.Render();
1791 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1792 Property::Map returnedMap;
1793 visual.CreatePropertyMap(returnedMap);
1795 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1796 DALI_TEST_CHECK(value);
1797 Property::Map* map = value->GetMap();
1798 DALI_TEST_CHECK(map);
1800 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1801 DALI_TEST_CHECK(value);
1802 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION);
1804 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1805 DALI_TEST_CHECK(value);
1806 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1811 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1813 ToolkitTestApplication application;
1815 tet_infoline("Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )");
1816 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1818 ImageView imageView = ImageView::New();
1819 Property::Map imageMap;
1820 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1821 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1822 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
1824 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1825 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1827 application.GetScene().Add(imageView);
1829 // Trigger a potential relayout
1830 application.SendNotification();
1831 application.Render();
1833 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1834 Property::Map returnedMap;
1835 visual.CreatePropertyMap(returnedMap);
1837 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1838 DALI_TEST_CHECK(value);
1839 Property::Map* map = value->GetMap();
1840 DALI_TEST_CHECK(map);
1843 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1844 DALI_TEST_CHECK(value);
1845 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION);
1847 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1848 DALI_TEST_CHECK(value);
1849 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1851 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1852 DALI_TEST_CHECK(value);
1853 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
1858 int UtcDaliImageViewFittingModesFill(void)
1860 ToolkitTestApplication application;
1862 tet_infoline("Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )");
1863 tet_infoline(" There should be no need to change the transform, only size is changed to fit view");
1865 ImageView imageView = ImageView::New();
1866 Property::Map imageMap;
1867 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1868 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1869 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL);
1871 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1872 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1874 application.GetScene().Add(imageView);
1876 // Trigger a potential relayout
1877 application.SendNotification();
1878 application.Render();
1880 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1881 Property::Map returnedMap;
1882 visual.CreatePropertyMap(returnedMap);
1884 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1885 DALI_TEST_CHECK(value);
1886 Property::Map* map = value->GetMap();
1887 DALI_TEST_CHECK(map);
1889 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1890 DALI_TEST_CHECK(value);
1891 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Change the internal size according to the image view size
1893 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1894 DALI_TEST_CHECK(value);
1895 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1897 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1898 DALI_TEST_CHECK(value);
1899 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1904 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1906 ToolkitTestApplication application;
1908 tet_infoline("Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )");
1909 tet_infoline(" offset or size is the same as view, but adjust internally using pixelArea ");
1911 ImageView imageView = ImageView::New();
1912 Property::Map imageMap;
1913 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1914 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1915 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO);
1917 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1918 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 500));
1920 application.GetScene().Add(imageView);
1922 // Trigger a potential relayout
1923 application.SendNotification();
1924 application.Render();
1926 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1927 Property::Map returnedMap;
1928 visual.CreatePropertyMap(returnedMap);
1930 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1931 DALI_TEST_CHECK(value);
1932 Property::Map* map = value->GetMap();
1933 DALI_TEST_CHECK(map);
1936 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1937 DALI_TEST_CHECK(value);
1938 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 500), TEST_LOCATION); // Change the internal size according to the image view size
1940 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1941 DALI_TEST_CHECK(value);
1942 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1944 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1945 DALI_TEST_CHECK(value);
1946 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1951 int UtcDaliImageViewFittingModesCenter01(void)
1953 ToolkitTestApplication application;
1955 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [700,700] )");
1956 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1958 ImageView imageView = ImageView::New();
1959 Property::Map imageMap;
1960 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1961 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1962 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1964 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1965 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1967 application.GetScene().Add(imageView);
1969 // Trigger a potential relayout
1970 application.SendNotification();
1971 application.Render();
1973 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1974 Property::Map returnedMap;
1975 visual.CreatePropertyMap(returnedMap);
1977 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1978 DALI_TEST_CHECK(value);
1979 Property::Map* map = value->GetMap();
1980 DALI_TEST_CHECK(map);
1982 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1983 DALI_TEST_CHECK(value);
1984 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1986 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1987 DALI_TEST_CHECK(value);
1988 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1990 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1991 DALI_TEST_CHECK(value);
1992 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1997 int UtcDaliImageViewFittingModesCenter02(void)
1999 ToolkitTestApplication application;
2001 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [500,500] )");
2002 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
2004 ImageView imageView = ImageView::New();
2005 Property::Map imageMap;
2006 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2007 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2008 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
2010 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2011 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
2013 application.GetScene().Add(imageView);
2015 // Trigger a potential relayout
2016 application.SendNotification();
2017 application.Render();
2019 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2020 Property::Map returnedMap;
2021 visual.CreatePropertyMap(returnedMap);
2023 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2024 DALI_TEST_CHECK(value);
2025 Property::Map* map = value->GetMap();
2026 DALI_TEST_CHECK(map);
2028 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2029 DALI_TEST_CHECK(value);
2030 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2032 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2033 DALI_TEST_CHECK(value);
2034 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2036 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2037 DALI_TEST_CHECK(value);
2038 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
2043 int UtcDaliImageViewFittingModesFitHeight01(void)
2045 ToolkitTestApplication application;
2047 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )");
2049 ImageView imageView = ImageView::New();
2050 Property::Map imageMap;
2051 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2052 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2053 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2055 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2056 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2058 application.GetScene().Add(imageView);
2060 // Trigger a potential relayout
2061 application.SendNotification();
2062 application.Render();
2064 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2065 Property::Map returnedMap;
2066 visual.CreatePropertyMap(returnedMap);
2068 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2069 DALI_TEST_CHECK(value);
2070 Property::Map* map = value->GetMap();
2071 DALI_TEST_CHECK(map);
2073 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2074 DALI_TEST_CHECK(value);
2075 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 700), TEST_LOCATION); // Change the internal size according to the image view size
2077 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2078 DALI_TEST_CHECK(value);
2079 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2081 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2082 DALI_TEST_CHECK(value);
2083 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2088 int UtcDaliImageViewFittingModesFitHeight02(void)
2090 ToolkitTestApplication application;
2092 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )");
2094 ImageView imageView = ImageView::New();
2095 Property::Map imageMap;
2096 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2097 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2098 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2100 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2101 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2103 application.GetScene().Add(imageView);
2105 // Trigger a potential relayout
2106 application.SendNotification();
2107 application.Render();
2109 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2110 Property::Map returnedMap;
2111 visual.CreatePropertyMap(returnedMap);
2113 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2114 DALI_TEST_CHECK(value);
2115 Property::Map* map = value->GetMap();
2116 DALI_TEST_CHECK(map);
2118 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2119 DALI_TEST_CHECK(value);
2120 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2122 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2123 DALI_TEST_CHECK(value);
2124 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2126 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2127 DALI_TEST_CHECK(value);
2128 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2133 int UtcDaliImageViewFittingModesFitWidth01(void)
2135 ToolkitTestApplication application;
2137 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )");
2139 ImageView imageView = ImageView::New();
2140 Property::Map imageMap;
2141 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2142 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2143 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2145 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2146 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2148 application.GetScene().Add(imageView);
2150 // Trigger a potential relayout
2151 application.SendNotification();
2152 application.Render();
2154 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2155 Property::Map returnedMap;
2156 visual.CreatePropertyMap(returnedMap);
2158 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2159 DALI_TEST_CHECK(value);
2160 Property::Map* map = value->GetMap();
2161 DALI_TEST_CHECK(map);
2163 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2164 DALI_TEST_CHECK(value);
2165 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2167 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2168 DALI_TEST_CHECK(value);
2169 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2171 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2172 DALI_TEST_CHECK(value);
2173 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
2178 int UtcDaliImageViewFittingModesFitWidth02(void)
2180 ToolkitTestApplication application;
2182 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )");
2184 ImageView imageView = ImageView::New();
2185 Property::Map imageMap;
2186 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2187 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2188 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2190 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2191 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2193 application.GetScene().Add(imageView);
2195 // Trigger a potential relayout
2196 application.SendNotification();
2197 application.Render();
2199 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2200 Property::Map returnedMap;
2201 visual.CreatePropertyMap(returnedMap);
2203 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2204 DALI_TEST_CHECK(value);
2205 Property::Map* map = value->GetMap();
2206 DALI_TEST_CHECK(map);
2208 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2209 DALI_TEST_CHECK(value);
2210 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 600), TEST_LOCATION); // Change the internal size according to the image view size
2212 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2213 DALI_TEST_CHECK(value);
2214 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2216 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2217 DALI_TEST_CHECK(value);
2218 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2223 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2225 ToolkitTestApplication application;
2227 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2229 ImageView imageView = ImageView::New();
2231 // 1. Render using FittingMode::SHRINK_TO_FIT
2232 Property::Map imageMap;
2233 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2234 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2235 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2237 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2238 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2240 application.GetScene().Add(imageView);
2242 // Trigger a potential relayout
2243 application.SendNotification();
2244 application.Render();
2246 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2247 Property::Map returnedMap;
2248 visual.CreatePropertyMap(returnedMap);
2250 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2251 DALI_TEST_CHECK(value);
2252 Property::Map* map = value->GetMap();
2253 DALI_TEST_CHECK(map);
2255 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2256 DALI_TEST_CHECK(value);
2257 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2259 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2260 DALI_TEST_CHECK(value);
2261 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2263 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2264 DALI_TEST_CHECK(value);
2265 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2267 // 2. Render again using DevelVisaul::CENTER
2268 Property::Map imageMap2;
2269 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2270 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2271 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2273 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2274 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2276 application.GetScene().Add(imageView);
2278 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2280 // Trigger a potential relayout
2281 application.SendNotification();
2282 application.Render();
2284 returnedMap.Clear();
2285 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2287 visual.CreatePropertyMap(returnedMap);
2289 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2290 DALI_TEST_CHECK(value);
2291 map = value->GetMap();
2292 DALI_TEST_CHECK(map);
2294 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2295 DALI_TEST_CHECK(value);
2296 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2298 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2299 DALI_TEST_CHECK(value);
2300 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2302 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2303 DALI_TEST_CHECK(value);
2304 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2306 // 3. Render again using before fittingMode
2307 Property::Map imageMap3;
2308 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2309 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2310 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2312 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2313 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2315 application.GetScene().Add(imageView);
2317 // Trigger a potential relayout
2318 application.SendNotification();
2319 application.Render();
2321 returnedMap.Clear();
2322 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2323 visual.CreatePropertyMap(returnedMap);
2325 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2326 DALI_TEST_CHECK(value);
2327 map = value->GetMap();
2328 DALI_TEST_CHECK(map);
2330 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2331 DALI_TEST_CHECK(value);
2332 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2334 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2335 DALI_TEST_CHECK(value);
2336 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2338 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2339 DALI_TEST_CHECK(value);
2340 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2345 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2347 ToolkitTestApplication application;
2349 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2351 ImageView imageView = ImageView::New();
2353 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2354 Property::Map imageMap;
2355 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2356 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2357 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2359 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2360 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2362 application.GetScene().Add(imageView);
2364 // Trigger a potential relayout
2365 application.SendNotification();
2366 application.Render();
2368 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2369 Property::Map returnedMap;
2370 visual.CreatePropertyMap(returnedMap);
2372 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2373 DALI_TEST_CHECK(value);
2374 Property::Map* map = value->GetMap();
2375 DALI_TEST_CHECK(map);
2377 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2378 DALI_TEST_CHECK(value);
2379 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2381 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2382 DALI_TEST_CHECK(value);
2383 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2385 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2386 DALI_TEST_CHECK(value);
2387 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2389 // 2. Render again using DevelVisaul::CENTER
2390 Property::Map imageMap2;
2391 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2392 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2393 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2395 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2396 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2398 application.GetScene().Add(imageView);
2400 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2402 // Trigger a potential relayout
2403 application.SendNotification();
2404 application.Render();
2406 returnedMap.Clear();
2407 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2409 visual.CreatePropertyMap(returnedMap);
2411 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2412 DALI_TEST_CHECK(value);
2413 map = value->GetMap();
2414 DALI_TEST_CHECK(map);
2416 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2417 DALI_TEST_CHECK(value);
2418 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2420 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2421 DALI_TEST_CHECK(value);
2422 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2424 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2425 DALI_TEST_CHECK(value);
2426 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2428 // 3. Render again using before fittingMode
2429 Property::Map imageMap3;
2430 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2431 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2432 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2434 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2435 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2437 application.GetScene().Add(imageView);
2439 // Trigger a potential relayout
2440 application.SendNotification();
2441 application.Render();
2443 returnedMap.Clear();
2444 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2445 visual.CreatePropertyMap(returnedMap);
2447 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2448 DALI_TEST_CHECK(value);
2449 map = value->GetMap();
2450 DALI_TEST_CHECK(map);
2452 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2453 DALI_TEST_CHECK(value);
2454 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2456 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2457 DALI_TEST_CHECK(value);
2458 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2460 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2461 DALI_TEST_CHECK(value);
2462 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2467 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2469 ToolkitTestApplication application;
2471 tet_infoline("Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )");
2473 ImageView imageView = ImageView::New();
2474 Property::Map imageMap;
2475 imageMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE);
2476 imageMap.Add(Toolkit::ImageVisual::Property::URL, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME); // 249x169 image
2478 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2479 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
2481 application.GetScene().Add(imageView);
2483 // Trigger a potential relayout
2484 application.SendNotification();
2485 application.Render();
2487 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2488 Property::Map returnedMap;
2489 visual.CreatePropertyMap(returnedMap);
2491 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2492 DALI_TEST_CHECK(value);
2493 Property::Map* map = value->GetMap();
2494 DALI_TEST_CHECK(map);
2496 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2497 DALI_TEST_CHECK(value);
2498 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Relative size so will take up 100%
2500 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2501 DALI_TEST_CHECK(value);
2502 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2504 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2505 DALI_TEST_CHECK(value);
2506 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2511 int UtcDaliImageViewCustomShader(void)
2513 ToolkitTestApplication application;
2515 // Set a custom shader with an image url
2517 Property::Map properties;
2518 Property::Map shader;
2519 const std::string vertexShader = "Foobar";
2520 const std::string fragmentShader = "Foobar";
2521 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2522 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2524 properties[Visual::Property::TYPE] = Visual::IMAGE;
2525 properties[Visual::Property::SHADER] = shader;
2526 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2528 ImageView imageView = ImageView::New();
2529 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2531 application.GetScene().Add(imageView);
2533 application.SendNotification();
2534 application.Render();
2536 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2538 Renderer renderer = imageView.GetRendererAt(0);
2539 Shader shader2 = renderer.GetShader();
2540 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2541 Property::Map* map = value.GetMap();
2542 DALI_TEST_CHECK(map);
2544 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2545 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2547 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2548 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2551 // Set a custom shader after setting an image url
2553 Property::Map properties;
2554 Property::Map shader;
2555 const std::string vertexShader = "Foobar";
2556 const std::string fragmentShader = "Foobar";
2557 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2558 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2560 properties[Visual::Property::SHADER] = shader;
2562 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
2563 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2565 application.GetScene().Add(imageView);
2567 application.SendNotification();
2568 application.Render();
2570 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2572 Renderer renderer = imageView.GetRendererAt(0);
2573 Shader shader2 = renderer.GetShader();
2574 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2575 Property::Map* map = value.GetMap();
2576 DALI_TEST_CHECK(map);
2578 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2579 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2581 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2582 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2585 // Set a custom shader before setting an image url
2587 Property::Map properties;
2588 Property::Map shader;
2589 const std::string vertexShader = "Foobar";
2590 const std::string fragmentShader = "Foobar";
2591 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2592 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2594 properties[Visual::Property::SHADER] = shader;
2596 ImageView imageView = ImageView::New();
2597 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2598 imageView.SetProperty(ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME);
2600 application.GetScene().Add(imageView);
2602 application.SendNotification();
2603 application.Render();
2604 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2606 Renderer renderer = imageView.GetRendererAt(0);
2607 Shader shader2 = renderer.GetShader();
2608 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2609 Property::Map* map = value.GetMap();
2610 DALI_TEST_CHECK(map);
2612 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2613 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2615 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2616 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2619 // Set a custom shader after setting a property map
2621 Property::Map properties;
2622 Property::Map shader;
2623 const std::string vertexShader = "Foobar";
2624 const std::string fragmentShader = "Foobar";
2625 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2626 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2628 properties[Visual::Property::SHADER] = shader;
2630 Property::Map properties1;
2631 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2632 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2634 ImageView imageView = ImageView::New();
2635 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2636 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2638 application.GetScene().Add(imageView);
2640 application.SendNotification();
2641 application.Render();
2642 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2644 Renderer renderer = imageView.GetRendererAt(0);
2645 Shader shader2 = renderer.GetShader();
2646 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2647 Property::Map* map = value.GetMap();
2648 DALI_TEST_CHECK(map);
2650 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2651 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2653 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2654 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2657 // Set a custom shader before setting a property map
2659 Property::Map properties;
2660 Property::Map shader;
2661 const std::string vertexShader = "Foobar";
2662 const std::string fragmentShader = "Foobar";
2663 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2664 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2666 properties[Visual::Property::SHADER] = shader;
2668 Property::Map properties1;
2669 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2670 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2672 ImageView imageView = ImageView::New();
2673 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2674 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2676 application.GetScene().Add(imageView);
2678 application.SendNotification();
2679 application.Render();
2680 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2682 Renderer renderer = imageView.GetRendererAt(0);
2683 Shader shader2 = renderer.GetShader();
2684 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2685 Property::Map* map = value.GetMap();
2686 DALI_TEST_CHECK(map);
2688 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2689 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2691 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2692 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2700 static int gFailCounter = 0;
2701 const int MAX_RETRIES(3);
2703 void ReloadImage(ImageView imageView)
2705 Property::Map imageImmediateLoadingMap;
2706 imageImmediateLoadingMap[ImageVisual::Property::URL] = "Non-existant-image.jpg";
2707 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
2709 tet_infoline("Immediate load an image");
2710 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
2713 void ResourceFailedReload(Control control)
2719 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2721 tet_infoline("Test reloading failed image from within signal handler.");
2723 ToolkitTestApplication application;
2727 ImageView imageView = ImageView::New();
2728 imageView.ResourceReadySignal().Connect(&ResourceFailedReload);
2729 DALI_TEST_EQUALS(gFailCounter, 0, TEST_LOCATION);
2730 ReloadImage(imageView);
2732 // loading started, this waits for the loader thread to complete
2733 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2734 DALI_TEST_EQUALS(gFailCounter, 1, TEST_LOCATION);
2736 ReloadImage(imageView);
2737 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2738 DALI_TEST_EQUALS(gFailCounter, 2, TEST_LOCATION);
2740 ReloadImage(imageView);
2741 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2742 DALI_TEST_EQUALS(gFailCounter, 3, TEST_LOCATION);
2747 int UtcDaliImageViewLoadRemoteSVG(void)
2749 tet_infoline("Test load from a remote server.");
2751 ToolkitTestApplication application;
2754 Toolkit::ImageView imageView;
2755 imageView = Toolkit::ImageView::New();
2756 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2757 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2758 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2759 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2760 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2762 application.GetScene().Add(imageView);
2764 DALI_TEST_CHECK(imageView);
2766 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2768 application.SendNotification();
2770 // Wait for loading & rasterization
2771 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2773 application.SendNotification();
2774 application.Render();
2776 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2781 Toolkit::ImageView imageView;
2782 imageView = Toolkit::ImageView::New();
2783 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2784 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2785 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2786 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2788 application.GetScene().Add(imageView);
2790 DALI_TEST_CHECK(imageView);
2792 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2794 application.SendNotification();
2796 // Wait for loading & rasterization
2797 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2799 application.SendNotification();
2800 application.Render();
2802 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2808 int UtcDaliImageViewSyncSVGLoading(void)
2810 ToolkitTestApplication application;
2812 tet_infoline("ImageView Testing SVG image sync loading");
2815 ImageView imageView = ImageView::New();
2817 // Sync loading is used
2818 Property::Map syncLoadingMap;
2819 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2820 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2821 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2822 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2824 application.GetScene().Add(imageView);
2825 DALI_TEST_CHECK(imageView);
2827 application.SendNotification();
2828 Vector3 naturalSize = imageView.GetNaturalSize();
2830 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2831 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2836 int UtcDaliImageViewSyncSVGLoading02(void)
2838 ToolkitTestApplication application;
2840 tet_infoline("ImageView Testing SVG image sync loading");
2843 ImageView imageView = ImageView::New();
2845 // Sync loading is used
2846 Property::Map syncLoadingMap;
2847 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2848 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2849 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2850 syncLoadingMap.Insert(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
2851 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2852 imageView.ResourceReadySignal().Connect(&OnResourceReadySignalSVG);
2854 application.GetScene().Add(imageView);
2855 DALI_TEST_CHECK(imageView);
2857 application.SendNotification();
2858 application.Render();
2860 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
2861 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
2862 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
2863 Property::Map resultMap;
2864 imageVisual.CreatePropertyMap(resultMap);
2866 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
2867 DALI_TEST_CHECK(transformValue);
2868 Property::Map* retMap = transformValue->GetMap();
2869 DALI_TEST_CHECK(retMap);
2871 // Image Visual should be positioned depending on ImageView's padding
2872 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::SIZE)->Get<Vector2>(), Vector2(100, 100), TEST_LOCATION);
2874 Vector3 naturalSize = imageView.GetNaturalSize();
2875 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2876 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2881 int UtcDaliImageViewAsyncSVGLoading(void)
2883 ToolkitTestApplication application;
2885 tet_infoline("ImageView Testing SVG image async loading");
2888 ImageView imageView = ImageView::New();
2890 // Async loading is used - default value of SYNCHRONOUS_LOADING is false.
2891 Property::Map propertyMap;
2892 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2893 propertyMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2894 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
2896 application.GetScene().Add(imageView);
2897 DALI_TEST_CHECK(imageView);
2899 application.SendNotification();
2902 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2904 application.SendNotification();
2905 application.Render(16);
2907 Vector3 naturalSize = imageView.GetNaturalSize();
2908 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2909 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2914 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2916 ToolkitTestApplication application;
2918 tet_infoline("ImageView Testing SVG image async loading");
2922 ImageView imageView = ImageView::New();
2924 // Sync loading is used
2925 Property::Map syncLoadingMap;
2926 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2927 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2929 // Check to set invalid value
2930 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2931 // Check if error log is outputted when setting other value like string.
2932 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2933 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5));
2934 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2936 application.GetScene().Add(imageView);
2937 DALI_TEST_CHECK(imageView);
2939 application.SendNotification();
2942 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2944 application.SendNotification();
2945 application.Render(16);
2947 Vector3 naturalSize = imageView.GetNaturalSize();
2948 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2949 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2951 Property::Value value = imageView.GetProperty(ImageView::Property::IMAGE);
2952 Property::Map* map = value.GetMap();
2953 DALI_TEST_CHECK(map);
2955 Property::Value* sync = map->Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING);
2956 DALI_TEST_CHECK(sync);
2957 DALI_TEST_EQUALS(false, sync->Get<bool>(), TEST_LOCATION);
2962 int UtcDaliImageViewSvgLoadingFailureLocalFile(void)
2964 // Local svg file - invalid file path
2966 ToolkitTestApplication application;
2968 TestGlAbstraction& gl = application.GetGlAbstraction();
2969 TraceCallStack& textureTrace = gl.GetTextureTrace();
2970 textureTrace.Enable(true);
2972 gResourceReadySignalFired = false;
2974 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2975 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2976 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2978 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2980 application.GetScene().Add(imageView);
2982 application.SendNotification();
2984 // loading started, this waits for the loader thread - load
2985 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2987 application.SendNotification();
2988 application.Render(16);
2990 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2991 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2992 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2994 // Should be shown a broken image
2995 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2996 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2999 // Local svg file - invalid file path without size set
3001 ToolkitTestApplication application;
3003 TestGlAbstraction& gl = application.GetGlAbstraction();
3004 TraceCallStack& textureTrace = gl.GetTextureTrace();
3005 textureTrace.Enable(true);
3007 gResourceReadySignalFired = false;
3008 textureTrace.Reset();
3010 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
3011 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3013 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3015 application.GetScene().Add(imageView);
3017 application.SendNotification();
3019 // loading started, this waits for the loader thread - load & rasterize
3020 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3022 application.SendNotification();
3023 application.Render(16);
3025 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3026 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3027 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3029 // Should be shown a broken image
3030 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3031 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3034 // Local svg file - invalid file
3036 ToolkitTestApplication application;
3038 TestGlAbstraction& gl = application.GetGlAbstraction();
3039 TraceCallStack& textureTrace = gl.GetTextureTrace();
3040 textureTrace.Enable(true);
3042 gResourceReadySignalFired = false;
3043 textureTrace.Reset();
3045 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.svg");
3046 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3047 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3049 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3051 application.GetScene().Add(imageView);
3053 application.SendNotification();
3055 // loading started, this waits for the loader thread - load & rasterize
3056 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3058 application.SendNotification();
3059 application.Render(16);
3061 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3062 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3063 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3065 // Should be shown a broken image
3066 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3067 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3073 int UtcDaliImageViewSvgLoadingFailureRemoteFile01(void)
3077 ToolkitTestApplication application;
3079 TestGlAbstraction& gl = application.GetGlAbstraction();
3080 TraceCallStack& textureTrace = gl.GetTextureTrace();
3081 textureTrace.Enable(true);
3083 gResourceReadySignalFired = false;
3085 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
3086 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3087 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3089 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3091 application.GetScene().Add(imageView);
3093 application.SendNotification();
3095 // loading started, this waits for the loader thread - load & rasterize
3096 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3098 application.SendNotification();
3099 application.Render(16);
3101 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3102 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3103 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3105 // Should be shown a broken image
3106 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3107 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3113 int UtcDaliImageViewSvgLoadingFailureRemoteFile02(void)
3115 // Remote svg file without size set
3117 ToolkitTestApplication application;
3119 TestGlAbstraction& gl = application.GetGlAbstraction();
3120 TraceCallStack& textureTrace = gl.GetTextureTrace();
3121 textureTrace.Enable(true);
3123 gResourceReadySignalFired = false;
3125 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
3126 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3128 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3130 application.GetScene().Add(imageView);
3132 application.SendNotification();
3134 // loading started, this waits for the loader thread - load & rasterize
3135 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3137 application.SendNotification();
3138 application.Render(16);
3140 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3141 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3142 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3144 // Should be shown a broken image
3145 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3146 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3152 int UtcDaliImageViewSvgRasterizationFailure(void)
3154 ToolkitTestApplication application;
3156 gResourceReadySignalFired = false;
3158 TestGlAbstraction& gl = application.GetGlAbstraction();
3159 TraceCallStack& textureTrace = gl.GetTextureTrace();
3160 textureTrace.Enable(true);
3162 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid1.svg");
3163 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3164 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3166 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3168 application.GetScene().Add(imageView);
3170 application.SendNotification();
3172 // Wait for loading & rasterization
3173 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3175 application.SendNotification();
3176 application.Render(16);
3178 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3179 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3180 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3182 // Should be shown a broken image
3183 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3184 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3189 int UtcDaliImageViewSvgChageSize(void)
3191 ToolkitTestApplication application;
3193 TestGlAbstraction& gl = application.GetGlAbstraction();
3194 TraceCallStack& textureTrace = gl.GetTextureTrace();
3195 textureTrace.Enable(true);
3197 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME);
3198 application.GetScene().Add(imageView);
3200 application.SendNotification();
3202 // Wait for loading & rasterization
3203 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3205 application.SendNotification();
3206 application.Render(16);
3208 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3210 // Change actor size, then rasterization should be done again
3211 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3213 application.SendNotification();
3215 // Wait for rasterization
3216 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3218 application.SendNotification();
3219 application.Render(16);
3221 // We should not load the file again.
3222 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3227 int UtcDaliImageViewSvgAtlasing(void)
3229 ToolkitTestApplication application;
3231 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
3233 callStack.Enable(true);
3235 Property::Map propertyMap;
3236 propertyMap["url"] = TEST_SVG_FILE_NAME;
3237 propertyMap["atlasing"] = true;
3239 ImageView imageView = ImageView::New();
3240 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
3241 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3242 application.GetScene().Add(imageView);
3244 application.SendNotification();
3246 // Wait for loading & rasterization
3247 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3249 application.SendNotification();
3250 application.Render(16);
3253 TraceCallStack::NamedParams params1;
3254 params1["width"] << 100;
3255 params1["height"] << 100;
3256 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params1), true, TEST_LOCATION);
3258 imageView.SetProperty(Actor::Property::SIZE, Vector2(600.f, 600.f));
3260 application.SendNotification();
3262 // Wait for rasterization
3263 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3267 application.SendNotification();
3268 application.Render(16);
3271 TraceCallStack::NamedParams params2;
3272 params2["width"] << 600;
3273 params2["height"] << 600;
3274 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexImage2D", params2), true, TEST_LOCATION);
3279 int UtcDaliImageViewTVGLoading(void)
3281 ToolkitTestApplication application;
3283 tet_infoline("ImageView Testing TVG image loading");
3286 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/test.tvg");
3287 application.GetScene().Add(imageView);
3288 DALI_TEST_CHECK(imageView);
3290 application.SendNotification();
3292 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3294 application.SendNotification();
3295 application.Render(16);
3297 Vector3 naturalSize = imageView.GetNaturalSize();
3299 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3300 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3305 int UtcDaliImageViewSvgDesiredSize01(void)
3307 ToolkitTestApplication application;
3309 TestGlAbstraction& gl = application.GetGlAbstraction();
3310 TraceCallStack& textureTrace = gl.GetTextureTrace();
3311 textureTrace.Enable(true);
3313 int desiredWidth = 100, desiredHeight = 150;
3314 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
3316 application.GetScene().Add(imageView);
3318 application.SendNotification();
3320 // Wait for loading & rasterization
3321 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3323 application.SendNotification();
3324 application.Render(16);
3327 std::stringstream out;
3328 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
3329 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
3335 int UtcDaliImageViewSvgDesiredSize02(void)
3337 ToolkitTestApplication application;
3339 TestGlAbstraction& gl = application.GetGlAbstraction();
3340 TraceCallStack& textureTrace = gl.GetTextureTrace();
3341 textureTrace.Enable(true);
3343 int desiredWidth = 150, desiredHeight = 100;
3344 ImageView imageView = ImageView::New();
3345 imageView[ImageView::Property::IMAGE] = Property::Map().Add("url", TEST_SVG_FILE_NAME).Add("desiredWidth", desiredWidth).Add("desiredHeight", desiredHeight);
3346 application.GetScene().Add(imageView);
3348 application.SendNotification();
3350 // Wait for loading & rasterization
3351 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3353 application.SendNotification();
3354 application.Render(16);
3357 std::stringstream out;
3358 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
3359 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
3365 int UtcDaliImageViewImageLoadFailure01(void)
3367 ToolkitTestApplication application;
3369 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3370 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3371 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3372 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3374 std::string brokenUrl;
3375 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3376 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3378 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3379 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3381 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3382 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3384 ImageView imageView = ImageView::New("invalidUrl.png");
3385 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3387 application.GetScene().Add(imageView);
3388 application.SendNotification();
3389 application.Render(16);
3391 // loading started, this waits for the loader thread
3392 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3397 int UtcDaliImageViewImageLoadFailure02(void)
3399 ToolkitTestApplication application;
3401 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3402 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
3403 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3404 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3406 std::string brokenUrl;
3407 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3408 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
3410 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3411 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3413 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3414 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3416 ImageView imageView = ImageView::New("invalidUrl.png");
3417 imageView.SetProperty(Actor::Property::SIZE, Vector2(30.f, 30.f));
3418 application.GetScene().Add(imageView);
3419 application.SendNotification();
3420 application.Render(16);
3422 // loading started, this waits for the loader thread
3423 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3428 int UtcDaliImageViewImageLoadFailure03(void)
3430 ToolkitTestApplication application;
3432 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3433 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
3434 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
3436 std::string brokenUrl;
3437 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3438 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3440 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3441 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3443 ImageView imageView = ImageView::New("invalidUrl.png");
3444 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3445 application.GetScene().Add(imageView);
3446 application.SendNotification();
3447 application.Render(16);
3449 // loading started, this waits for the loader thread
3450 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3455 int UtcDaliImageViewImageLoadFailure04(void)
3457 ToolkitTestApplication application;
3459 ImageView imageView = ImageView::New("invalidUrl.png");
3460 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3461 application.GetScene().Add(imageView);
3462 application.SendNotification();
3463 application.Render(16);
3465 // loading started, this waits for the loader thread
3466 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3468 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3469 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3470 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3471 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3473 ImageView imageView2 = ImageView::New("invalidUrl.png");
3474 imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3475 application.GetScene().Add(imageView2);
3477 std::string brokenUrl;
3478 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3479 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3481 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3482 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3484 application.SendNotification();
3485 application.Render(16);
3487 // loading started, this waits for the loader thread
3488 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3490 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3492 ImageView imageView3 = ImageView::New("invalidUrl.png");
3493 imageView3.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3494 application.GetScene().Add(imageView3);
3496 application.SendNotification();
3497 application.Render(16);
3499 // loading started, this waits for the loader thread
3500 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3507 static int gResourceReadySignalCounter = 0;
3509 void OnResourceReadySignal01(Control control)
3511 gResourceReadySignalCounter++;
3513 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3515 if(gResourceReadySignalCounter == 1)
3518 // It makes the first new visual be deleted immediately
3519 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3520 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3523 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3525 // Make the resource ready immediately
3526 control[ImageView::Property::IMAGE] = gImage_600_RGB;
3530 void OnResourceReadySignal02(Control control)
3532 if(++gResourceReadySignalCounter == 1)
3534 // It makes the first new visual be deleted immediately
3535 // The first image will not be loaded.
3536 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB).Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3537 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3541 ImageView gImageView1;
3542 ImageView gImageView2;
3543 ImageView gImageView3;
3544 ImageView gImageView4;
3546 void OnResourceReadySignal03(Control control)
3548 if(gResourceReadySignalCounter == 0)
3551 // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3552 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3554 // 2. Load a new image
3555 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3557 // 3. Use the new image again
3558 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3559 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3561 else if(gResourceReadySignalCounter == 1)
3563 // This is called from TextureManager::ProcessQueuedTextures().
3564 gImageView1.Unparent();
3565 gImageView1.Reset();
3567 gResourceReadySignalCounter++;
3570 void OnSimpleResourceReadySignal(Control control)
3572 // simply increate counter
3573 gResourceReadySignalCounter++;
3576 int gResourceReadySignal04ComesOrder = 0;
3578 void OnResourceReadySignal04(Control control)
3580 gResourceReadySignalCounter++;
3581 tet_printf("rc %d\n", gResourceReadySignalCounter);
3582 if(gResourceReadySignalCounter == 1)
3584 auto scene = gImageView1.GetParent();
3586 // Request load something
3587 // We hope this request result is return later than gImageView2.
3588 gImageView3 = ImageView::New(TEST_IMAGE_1);
3589 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3590 scene.Add(gImageView3);
3591 gImageView4 = ImageView::New(TEST_IMAGE_2);
3592 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3593 scene.Add(gImageView4);
3595 if(control == gImageView1)
3597 gResourceReadySignal04ComesOrder = 1;
3601 gResourceReadySignal04ComesOrder = 2;
3604 if(gResourceReadySignalCounter == 2)
3606 if(gResourceReadySignal04ComesOrder == 1 && control == gImageView2)
3608 // Scene off first one.
3609 gImageView1.Unparent();
3611 // Scene off second one.
3612 gImageView2.Unparent();
3614 else if(gResourceReadySignal04ComesOrder == 2 && control == gImageView1)
3616 // Scene off first one.
3617 gImageView2.Unparent();
3619 // Scene off second one.
3620 gImageView1.Unparent();
3624 // We can't check that this utc fail case. just pass always when we come here.
3625 gResourceReadySignal04ComesOrder = -1;
3628 // If we don't seperate index of FreeList area
3629 // and if we don't queue remove during obversing,
3630 // cache index become something invalid data.
3631 // In this case, some strange observer can be called.
3632 // For example, gImageView4.LoadComplete will be called.
3636 void OnResourceReadySignal05(Control control)
3638 gResourceReadySignalCounter++;
3640 // Request load with same image
3641 // NOTE : The url must not be same as gImageView1
3642 const int viewCount = 4;
3643 for(int i = 0; i < viewCount; ++i)
3645 gImageView1.Add(ImageView::New("invalid2.jpg"));
3649 int gResourceReadySignal06ComesOrder = 0;
3651 void OnResourceReadySignal06(Control control)
3653 gResourceReadySignalCounter++;
3654 if(gResourceReadySignalCounter == 1)
3656 auto scene = gImageView1.GetParent();
3658 // Request load something
3659 // We hope this request result is return later than gImageView2.
3662 map1[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
3663 map1[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
3665 gImageView3 = ImageView::New();
3666 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3667 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3670 map2[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
3671 map2[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_S;
3672 gImageView4 = ImageView::New();
3673 gImageView4.SetProperty(Toolkit::ImageView::Property::IMAGE, map2);
3674 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3676 if(control == gImageView1)
3678 gResourceReadySignal06ComesOrder = 1;
3682 gResourceReadySignal06ComesOrder = 2;
3685 if(gResourceReadySignalCounter == 2)
3687 if(gResourceReadySignal06ComesOrder == 1 && control == gImageView2)
3689 // Scene off first one.
3690 gImageView1.Unparent();
3692 // Scene off second one.
3693 gImageView2.Unparent();
3695 else if(gResourceReadySignal06ComesOrder == 2 && control == gImageView1)
3697 // Scene off first one.
3698 gImageView2.Unparent();
3700 // Scene off second one.
3701 gImageView1.Unparent();
3705 // We can't check that this utc fail case. just pass always when we come here.
3706 gResourceReadySignal06ComesOrder = -1;
3709 // If we don't seperate index of FreeList area
3710 // and if we don't queue remove during obversing,
3711 // cache index become something invalid data.
3712 // In this case, some strange observer can be called.
3713 // For example, gImageView4.LoadComplete will be called.
3717 void OnResourceReadySignal07(Control control)
3719 gResourceReadySignalCounter++;
3720 // Load masked image
3721 tet_printf("rc %d %d\n", gResourceReadySignalCounter, static_cast<bool>(gImageView2));
3725 auto scene = gImageView1.GetParent();
3728 map1[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
3729 map1[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
3731 gImageView2 = ImageView::New();
3732 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3733 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal07);
3735 scene.Add(gImageView2);
3739 void OnResourceReadySignal08(Control control)
3741 gResourceReadySignalCounter++;
3745 gImageView1.Unparent();
3746 gImageView1.Reset();
3750 gImageView2.Unparent();
3751 gImageView2.Reset();
3755 std::size_t gResourceReadySignal09Emitted = false;
3757 void OnResourceReadySignal09(Control control)
3759 gResourceReadySignalCounter++;
3761 if(gImageView1 && !gResourceReadySignal09Emitted)
3763 gResourceReadySignal09Emitted = true;
3764 gImageView1.ResourceReadySignal().Disconnect(&OnResourceReadySignal09);
3766 // Try to load cached invalid nine patch image. It will request load now.
3767 gImageView1.SetImage(TEST_INVALID_NPATCH_FILE_NAME_01);
3768 gImageView2.SetImage(TEST_INVALID_NPATCH_FILE_NAME_01);
3770 // Destroy all visuals immediatly.
3771 gImageView1.Unparent();
3772 gImageView1.Reset();
3773 gImageView2.Unparent();
3774 gImageView2.Reset();
3777 constexpr int gResourceReadySignal10MaxCounter = 5;
3779 void OnResourceReadySignal10(Control control)
3781 gResourceReadySignalCounter++;
3783 tet_printf("OnResourceReadySignal10 comes!\n");
3784 if(gResourceReadySignalCounter < gResourceReadySignal10MaxCounter)
3786 tet_printf("OnResourceReadySignal10 Set image\n");
3787 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, gImage_34_RGBA);
3788 tet_printf("OnResourceReadySignal10 Set image done\n");
3794 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3796 tet_infoline("Test setting image from within signal handler.");
3798 ToolkitTestApplication application;
3800 gResourceReadySignalCounter = 0;
3802 ImageView imageView = ImageView::New(gImage_34_RGBA);
3803 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal01);
3805 application.GetScene().Add(imageView);
3807 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3809 application.SendNotification();
3810 application.Render();
3812 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3814 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3816 // Create a new ImageView to cache the image
3817 ImageView imageView1 = ImageView::New(gImage_600_RGB);
3818 application.GetScene().Add(imageView1);
3820 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3822 application.SendNotification();
3823 application.Render();
3826 gResourceReadySignalCounter = 0;
3828 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3830 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3832 application.SendNotification();
3833 application.Render();
3835 // Run idle callback
3836 application.RunIdles();
3838 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3840 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3845 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
3847 tet_infoline("Test setting image from within signal handler.");
3849 ToolkitTestApplication application;
3851 gResourceReadySignalCounter = 0;
3853 ImageView imageView = ImageView::New(gImage_34_RGBA);
3854 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal02);
3856 application.GetScene().Add(imageView);
3858 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3860 application.SendNotification();
3861 application.Render();
3863 // Wait for loading an image
3864 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3866 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3868 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3873 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3875 tet_infoline("Test setting image from within signal handler.");
3877 ToolkitTestApplication application;
3879 gResourceReadySignalCounter = 0;
3881 gImageView1 = ImageView::New(gImage_34_RGBA);
3882 application.GetScene().Add(gImageView1);
3885 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3887 gImageView2 = ImageView::New(gImage_600_RGB);
3888 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3889 application.GetScene().Add(gImageView2);
3891 gImageView3 = ImageView::New();
3892 application.GetScene().Add(gImageView3);
3894 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3896 application.SendNotification();
3897 application.Render();
3902 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask01(void)
3904 tet_infoline("Test signal handler when image / mask image is broken.");
3906 ToolkitTestApplication application;
3908 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, const std::string& url, const std::string& mask, const char* location) {
3909 gResourceReadySignalCounter = 0;
3912 map[Toolkit::ImageVisual::Property::URL] = url;
3915 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3917 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3919 ImageView imageView = ImageView::New();
3920 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3921 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3922 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3924 application.GetScene().Add(imageView);
3925 application.SendNotification();
3926 application.Render();
3931 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3933 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3934 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3936 imageView.Unparent();
3939 for(int synchronous = 0; synchronous <= 1; synchronous++)
3941 tet_printf("Test normal case (sync:%d)\n", synchronous);
3942 TestResourceReadyUrl(1, synchronous, gImage_600_RGB, "", TEST_LOCATION);
3943 TestResourceReadyUrl(3, synchronous, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 3 event trigger required : 2 image load + 1 apply mask
3945 tet_printf("Test broken image case (sync:%d)\n", synchronous);
3946 TestResourceReadyUrl(1, synchronous, "invalid.jpg", "", TEST_LOCATION);
3947 TestResourceReadyUrl(2, synchronous, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3949 tet_printf("Test broken mask image case (sync:%d)\n", synchronous);
3950 TestResourceReadyUrl(2, synchronous, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3952 tet_printf("Test broken both image, mask image case (sync:%d)\n", synchronous);
3953 TestResourceReadyUrl(2, synchronous, "invalid.jpg", "invalid.png", TEST_LOCATION);
3959 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask02(void)
3961 tet_infoline("Test signal handler when image try to use cached-and-broken mask image.");
3963 ToolkitTestApplication application;
3965 gResourceReadySignalCounter = 0;
3967 auto TestBrokenMaskResourceReadyUrl = [&application](const std::string& url, const char* location) {
3969 map[Toolkit::ImageVisual::Property::URL] = url;
3970 // Use invalid mask url
3971 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
3973 ImageView imageView = ImageView::New();
3974 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3975 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3976 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3978 application.GetScene().Add(imageView);
3980 // Don't unparent imageView, for keep the cache.
3983 // Use more than 4 images (The number of LocalImageLoadThread)
3984 const std::vector<std::string> testUrlList = {gImage_34_RGBA, gImage_600_RGB, "invalid.jpg" /* invalid url */, TEST_IMAGE_1, TEST_IMAGE_2, TEST_BROKEN_IMAGE_DEFAULT};
3986 int expectResourceReadySignalCounter = 0;
3988 for(auto& url : testUrlList)
3990 TestBrokenMaskResourceReadyUrl(url, TEST_LOCATION);
3991 expectResourceReadySignalCounter++;
3994 // Remain 1 signal due to we use #URL + 1 mask image.
3995 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(expectResourceReadySignalCounter + 1), true, TEST_LOCATION);
3996 application.SendNotification();
3997 application.Render();
3998 DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
4003 int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
4005 tet_infoline("Test signal handler various case.");
4007 auto TestResourceReadyUrl = [](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
4008 ToolkitTestApplication application;
4010 gResourceReadySignalCounter = 0;
4013 map[Toolkit::ImageVisual::Property::URL] = url;
4016 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
4018 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
4020 ImageView imageView = ImageView::New();
4021 imageView[Toolkit::ImageView::Property::IMAGE] = map;
4022 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
4023 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4025 application.GetScene().Add(imageView);
4026 application.SendNotification();
4027 application.Render();
4030 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
4032 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
4033 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
4034 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, location);
4036 imageView.Unparent();
4039 auto TestAuxiliaryResourceReadyUrl = [](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
4040 ToolkitTestApplication application;
4042 gResourceReadySignalCounter = 0;
4045 map[Toolkit::ImageVisual::Property::URL] = url;
4046 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE] = auxiliaryUrl;
4047 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA] = 0.5f;
4048 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
4050 ImageView imageView = ImageView::New();
4051 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4052 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4053 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4054 application.GetScene().Add(imageView);
4056 application.SendNotification();
4057 application.Render();
4062 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, location);
4065 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
4066 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
4067 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
4069 imageView.Unparent();
4072 // Case 1 : asynchronous loading
4073 tet_printf("Test invalid single simple image Asynchronous\n");
4076 TestResourceReadyUrl(1, 0, 1, gImage_600_RGB, "", TEST_LOCATION);
4077 TestResourceReadyUrl(2, 0, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // load & rasterize
4078 TestResourceReadyUrl(1, 0, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
4080 TestResourceReadyUrl(2, 0, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // 2 image loading - batch size
4081 TestResourceReadyUrl(2, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // load & rasterize
4083 TestResourceReadyUrl(3, 0, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 2 image loading + 1 applymask
4085 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
4088 TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
4089 TestResourceReadyUrl(1, 0, 0, "invalid.svg", "", TEST_LOCATION);
4090 TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
4091 TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION); // 1 image loading
4092 TestResourceReadyUrl(1, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
4094 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", "invalid.png", TEST_LOCATION); // 2 image loading
4095 TestResourceReadyUrl(2, 0, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); // 2 image loading
4096 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION); // 2 image loading
4098 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
4099 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
4100 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
4102 // Case 2 : Synchronous loading
4103 tet_printf("Test invalid single simple image Synchronous\n");
4106 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "", TEST_LOCATION);
4107 TestResourceReadyUrl(0, 1, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
4108 TestResourceReadyUrl(0, 1, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
4110 TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // first frame image loading sync + second frame image loading async
4112 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION);
4114 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
4117 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
4118 TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION);
4119 TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
4120 TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
4122 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "invalid.png", TEST_LOCATION);
4123 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION);
4124 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
4126 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
4127 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
4128 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
4133 int UtcDaliImageViewSetImageOnResourceReadySignal04(void)
4135 tet_infoline("Test texturemanager's remove queue works well within signal handler.");
4137 ToolkitTestApplication application;
4139 gResourceReadySignalCounter = 0;
4140 gResourceReadySignal04ComesOrder = 0;
4142 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
4143 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal04);
4144 application.GetScene().Add(gImageView1);
4146 gImageView2 = ImageView::New("invalid.png"); // request invalid image, to make loading failed fast.
4147 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal04);
4148 application.GetScene().Add(gImageView2);
4150 application.SendNotification();
4151 application.Render();
4153 tet_infoline("Try to load 2 invalid image");
4155 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4156 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4158 tet_infoline("load done");
4160 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
4161 if(gResourceReadySignal04ComesOrder == -1)
4163 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
4167 // gImageView3 and gImageView4 load must not be successed yet.
4168 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
4169 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
4171 application.SendNotification();
4172 application.Render();
4174 tet_infoline("Try to load 2 valid image");
4176 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4177 DALI_TEST_EQUALS(gResourceReadySignalCounter, 4, TEST_LOCATION);
4179 tet_infoline("load done");
4181 // gImageView3 and gImageView4 load must be successed now.
4182 DALI_TEST_EQUALS(gImageView3.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
4183 DALI_TEST_EQUALS(gImageView4.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
4188 int UtcDaliImageViewSetImageOnResourceReadySignal05(void)
4190 tet_infoline("Test multiple views with same image during ResourceReady load the image only 1 times");
4192 ToolkitTestApplication application;
4194 gResourceReadySignalCounter = 0;
4196 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
4197 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal05);
4198 application.GetScene().Add(gImageView1);
4200 application.SendNotification();
4201 application.Render();
4203 tet_infoline("Try to load 1 invalid.jpg image");
4204 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4205 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4207 tet_infoline("Try to load 1 invalid2.jpg image");
4208 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4210 tet_infoline("Now we don't have any image to be loaded. Check event thread trigger failed.");
4211 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
4213 gImageView1.Unparent();
4214 gImageView1.Reset();
4218 int UtcDaliImageViewSetImageOnResourceReadySignal06(void)
4220 tet_infoline("Test texturemanager's remove image & mask queue works well within signal handler.");
4222 ToolkitTestApplication application;
4224 gResourceReadySignalCounter = 0;
4225 gResourceReadySignal06ComesOrder = 0;
4228 map[Toolkit::ImageVisual::Property::URL] = "invalid.jpg";
4229 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
4231 gImageView1 = ImageView::New(); // request invalid image, to make loading failed fast.
4232 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4233 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal06);
4234 application.GetScene().Add(gImageView1);
4236 gImageView2 = ImageView::New(); // request invalid image, to make loading failed fast.
4237 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4238 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal06);
4239 application.GetScene().Add(gImageView2);
4241 application.SendNotification();
4242 application.Render();
4244 tet_infoline("Try to load 2 invalid image");
4246 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4247 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4249 tet_infoline("load done");
4251 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
4252 if(gResourceReadySignal06ComesOrder == -1)
4254 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
4258 // gImageView3 and gImageView4 load must not be successed yet.
4259 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
4260 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
4262 application.GetScene().Add(gImageView3);
4263 application.GetScene().Add(gImageView4);
4264 application.SendNotification();
4265 application.Render();
4267 tet_infoline("Try to load 2 valid image");
4269 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4270 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4272 tet_infoline("load done");
4277 int UtcDaliImageViewSetImageOnResourceReadySignal07(void)
4279 tet_infoline("Test texturemanager's remove image & mask queue works well within signal handler 02.");
4281 ToolkitTestApplication application;
4283 gResourceReadySignalCounter = 0;
4286 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4288 // Clear image view for clear test
4292 gImageView1.Reset();
4296 gImageView2.Reset();
4299 gImageView1 = ImageView::New();
4300 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4301 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal07);
4302 application.GetScene().Add(gImageView1);
4304 application.SendNotification();
4305 application.Render();
4309 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4310 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4312 tet_infoline("load image1 done");
4314 // Load gImageView2 and mask
4316 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4317 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4319 // gImageView2 mask apply done
4321 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4322 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4324 tet_infoline("load image2 done");
4328 int UtcDaliImageViewSetImageOnResourceReadySignal08(void)
4330 tet_infoline("Test remove npatch images during resource ready");
4332 ToolkitTestApplication application;
4334 gResourceReadySignalCounter = 0;
4337 map[Toolkit::ImageVisual::Property::URL] = TEST_BROKEN_IMAGE_M;
4339 // Clear image view for clear test
4343 gImageView1.Reset();
4347 gImageView2.Reset();
4350 // Case 1 : Remove all images during resource ready.
4353 gImageView1 = ImageView::New();
4354 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4355 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal08);
4356 application.GetScene().Add(gImageView1);
4358 application.SendNotification();
4359 application.Render();
4362 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4363 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4365 application.SendNotification();
4366 application.Render();
4368 DALI_TEST_CHECK(true);
4372 // Exception should not happened
4373 DALI_TEST_CHECK(false);
4377 application.SendNotification();
4378 application.Render();
4380 gResourceReadySignalCounter = 0;
4382 // Case 2 : Remove all images when we use cached resource.
4385 gImageView1 = ImageView::New();
4386 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4387 gImageView1.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4388 application.GetScene().Add(gImageView1);
4390 application.SendNotification();
4391 application.Render();
4394 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4395 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4397 application.SendNotification();
4398 application.Render();
4400 gImageView2 = ImageView::New();
4401 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4402 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal08);
4403 application.GetScene().Add(gImageView2);
4404 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4406 application.SendNotification();
4407 application.Render();
4409 DALI_TEST_CHECK(true);
4413 // Exception should not happened
4414 DALI_TEST_CHECK(false);
4416 gResourceReadySignalCounter = 0;
4418 // Clear image view for clear test
4422 gImageView1.Reset();
4426 gImageView2.Reset();
4432 int UtcDaliImageViewSetImageOnResourceReadySignal09(void)
4434 tet_infoline("Test load invalid npatch images during invalid resource ready");
4436 ToolkitTestApplication application;
4438 gResourceReadySignalCounter = 0;
4441 map[Toolkit::ImageVisual::Property::URL] = TEST_INVALID_NPATCH_FILE_NAME_01;
4443 // Clear image view for clear test
4447 gImageView1.Reset();
4451 gImageView2.Reset();
4455 gImageView3.Reset();
4458 // Dummy view with npatch image
4459 ImageView dummyView = ImageView::New(TEST_BROKEN_IMAGE_M);
4460 application.GetScene().Add(dummyView);
4462 application.SendNotification();
4463 application.Render();
4464 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4465 application.SendNotification();
4466 application.Render();
4468 // Case 1 : Reload images during resource ready.
4471 gResourceReadySignal09Emitted = false;
4473 gImageView1 = ImageView::New();
4474 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4475 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal09);
4476 application.GetScene().Add(gImageView1);
4478 gImageView2 = ImageView::New();
4479 application.GetScene().Add(gImageView2);
4481 // Load TEST_INVALID_NPATCH_FILE_NAME_01
4482 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4484 // Load TEST_INVALID_NPATCH_FILE_NAME_01 one more times.
4485 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4487 application.SendNotification();
4488 application.Render();
4490 DALI_TEST_CHECK(true);
4494 // Exception should not happened
4495 DALI_TEST_CHECK(false);
4499 application.SendNotification();
4500 application.Render();
4502 gResourceReadySignalCounter = 0;
4504 // Case 2 : Remove all images when we use cached resource.
4507 gResourceReadySignal09Emitted = false;
4509 gImageView3 = ImageView::New();
4510 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4511 gImageView3.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4512 application.GetScene().Add(gImageView3);
4514 gImageView2 = ImageView::New();
4515 application.GetScene().Add(gImageView2);
4518 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4520 gImageView1 = ImageView::New();
4521 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4522 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal09);
4523 application.GetScene().Add(gImageView1);
4526 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4528 // Load TEST_INVALID_NPATCH_FILE_NAME_01 one more times.
4529 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4531 application.SendNotification();
4532 application.Render();
4534 DALI_TEST_CHECK(true);
4538 // Exception should not happened
4539 DALI_TEST_CHECK(false);
4541 gResourceReadySignalCounter = 0;
4543 // Clear image view for clear test
4547 gImageView1.Reset();
4551 gImageView2.Reset();
4555 gImageView3.Reset();
4561 int UtcDaliImageViewSetImageOnResourceReadySignal10(void)
4563 tet_infoline("Test ResourceReady signal comes more than 2 times.");
4565 ToolkitTestApplication application;
4567 gResourceReadySignalCounter = 0;
4569 // Clear image view for clear test
4573 gImageView1.Reset();
4576 // Dummy view to cache image.
4577 ImageView dummyView = ImageView::New(gImage_34_RGBA);
4578 application.GetScene().Add(dummyView);
4580 application.SendNotification();
4581 application.Render();
4582 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4583 application.SendNotification();
4584 application.Render();
4588 gImageView1 = ImageView::New();
4589 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, gImage_34_RGBA);
4590 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal10);
4591 application.GetScene().Add(gImageView1); // It will call resourceReady signal 1 time.
4593 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4595 DALI_TEST_GREATER(gResourceReadySignal10MaxCounter, gResourceReadySignalCounter, TEST_LOCATION); // Check whether resource ready call too much.
4597 for(int i = 0; i < gResourceReadySignal10MaxCounter; ++i)
4599 tet_printf("RunIdles\n");
4600 // Executes the idle callbacks.
4601 application.RunIdles();
4602 application.SendNotification();
4603 application.Render();
4604 tet_printf("RunIdles done\n");
4606 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4608 DALI_TEST_EQUALS(gResourceReadySignalCounter, gResourceReadySignal10MaxCounter, TEST_LOCATION);
4610 DALI_TEST_CHECK(true);
4614 // Exception should not happened
4615 DALI_TEST_CHECK(false);
4619 application.SendNotification();
4620 application.Render();
4622 gResourceReadySignalCounter = 0;
4624 gResourceReadySignalCounter = 0;
4626 // Clear image view for clear test
4630 gImageView1.Reset();
4636 int UtcDaliImageViewUseSameUrlWithAnimatedImageVisual(void)
4638 tet_infoline("Test multiple views with same image in animated image visual");
4639 ToolkitTestApplication application;
4641 gImageView1 = ImageView::New(TEST_WEBP_FILE_NAME);
4642 application.GetScene().Add(gImageView1);
4644 tet_infoline("Remove imageView and Create new imageView with same url");
4645 application.GetScene().Remove(gImageView1);
4646 gImageView2 = ImageView::New(TEST_WEBP_FILE_NAME);
4647 application.GetScene().Add(gImageView2);
4649 application.SendNotification();
4650 application.Render();
4652 tet_infoline("Check the ImageView load image successfully");
4653 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4657 int UtcDaliImageViewNpatchImageCacheTest01(void)
4659 tet_infoline("Test npatch image cached");
4661 ToolkitTestApplication application;
4662 ImageView imageView[2];
4664 auto& gl = application.GetGlAbstraction();
4665 gl.EnableTextureCallTrace(true);
4666 auto& textureCallStack = gl.GetTextureTrace();
4667 textureCallStack.Enable(true);
4668 textureCallStack.EnableLogging(true);
4670 auto TestNPatch = [&](int index, const std::string& nPatchImageUrl, const char* location) {
4671 if(imageView[index])
4673 imageView[index].Unparent();
4676 // Ensure remove npatch cache if required.
4677 application.SendNotification();
4678 application.Render();
4680 imageView[index] = ImageView::New(nPatchImageUrl);
4681 imageView[index].SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4682 application.GetScene().Add(imageView[index]);
4685 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4686 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4688 application.SendNotification();
4689 application.Render();
4691 tet_printf("trace : \n%s\n", textureCallStack.GetTraceString().c_str());
4693 // Check we gen only 1 textures
4694 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 1, TEST_LOCATION);
4695 textureCallStack.Reset();
4697 // Let we use cached textures
4698 for(int i = 0; i < 10; i++)
4700 TestNPatch(1, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4701 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4704 application.SendNotification();
4705 application.Render();
4706 // Check we use cached npatch data so we don't generate new texture textures
4707 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 0, TEST_LOCATION);
4710 imageView[0].Unparent();
4711 imageView[0].Reset();
4712 imageView[1].Unparent();
4713 imageView[1].Reset();
4715 application.SendNotification();
4716 application.Render();
4718 textureCallStack.Reset();
4719 // Let we use deference textures
4720 TestNPatch(1, TEST_BROKEN_IMAGE_S, TEST_LOCATION);
4721 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4723 application.SendNotification();
4724 application.Render();
4725 // Try to load multiple times.
4726 for(int i = 0; i < 3; i++)
4728 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4729 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4730 TestNPatch(1, TEST_BROKEN_IMAGE_S, TEST_LOCATION);
4731 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4733 application.SendNotification();
4734 application.Render();
4736 imageView[0].Unparent();
4737 imageView[0].Reset();
4738 imageView[1].Unparent();
4739 imageView[1].Reset();
4741 application.SendNotification();
4742 application.Render();
4744 // Check memory leak
4745 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), textureCallStack.CountMethod("DeleteTextures"), TEST_LOCATION);
4750 int UtcDaliImageViewNpatchImageCacheTest02(void)
4752 tet_infoline("Test npatch image cached with border");
4754 ToolkitTestApplication application;
4755 ImageView imageView[2];
4757 auto& gl = application.GetGlAbstraction();
4758 gl.EnableTextureCallTrace(true);
4759 auto& textureCallStack = gl.GetTextureTrace();
4760 textureCallStack.Enable(true);
4761 textureCallStack.EnableLogging(true);
4763 auto TestBorderImage = [&](int index, const std::string& normalImageUrl, const Rect<int> border, const char* location) {
4765 map[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::N_PATCH;
4766 map[Toolkit::ImageVisual::Property::URL] = normalImageUrl;
4767 map[Toolkit::ImageVisual::Property::BORDER] = border;
4769 imageView[index] = ImageView::New();
4770 imageView[index].SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4771 imageView[index].SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4772 application.GetScene().Add(imageView[index]);
4775 TestBorderImage(0, gImage_34_RGBA, Rect<int>(0, 0, 0, 0), TEST_LOCATION);
4776 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4778 application.SendNotification();
4779 application.Render();
4781 tet_printf("trace : \n%s\n", textureCallStack.GetTraceString().c_str());
4783 // Check we gen only 1 textures
4784 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 1, TEST_LOCATION);
4785 textureCallStack.Reset();
4787 // Let we use cached textures
4788 for(int i = 0; i < 10; i++)
4790 TestBorderImage(0, gImage_34_RGBA, Rect<int>(i, i + 1, i + 2, i + 3), TEST_LOCATION);
4791 TestBorderImage(1, gImage_34_RGBA, Rect<int>(i + 1, i, i + 3, i + 2), TEST_LOCATION);
4794 application.SendNotification();
4795 application.Render();
4797 // Check we use cached npatch data so we don't generate new texture textures
4798 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 0, TEST_LOCATION);
4803 int UtcDaliImageViewPlaceholderImage01(void)
4805 tet_infoline("Test imageView use placeholder image");
4807 ToolkitTestApplication application;
4809 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4811 ImageView imageView = ImageView::New();
4812 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4813 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4814 application.GetScene().Add(imageView);
4816 Property::Value value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4818 DALI_TEST_CHECK(value.Get(url));
4819 DALI_TEST_CHECK(url.empty());
4820 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4822 application.SendNotification();
4823 application.Render();
4825 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4826 DALI_TEST_CHECK(value.Get(url));
4827 DALI_TEST_CHECK(url == gImage_34_RGBA);
4829 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4830 application.SendNotification();
4831 application.Render();
4833 // Replace Image test
4834 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4835 map[ImageView::Property::PLACEHOLDER_IMAGE] = gImage_34_RGBA;
4836 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4837 application.SendNotification();
4838 application.Render();
4840 map[Toolkit::ImageVisual::Property::URL] = "";
4841 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4842 application.SendNotification();
4843 application.Render();
4845 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
4846 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4847 application.SendNotification();
4848 application.Render();
4850 // Replace Image test2
4851 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4852 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4853 application.SendNotification();
4854 application.Render();
4856 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
4857 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4858 application.SendNotification();
4859 application.Render();
4861 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4862 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4863 application.SendNotification();
4864 application.Render(900);
4866 map[Toolkit::ImageVisual::Property::URL] = "";
4867 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4868 application.SendNotification();
4869 application.Render();
4871 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4872 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4873 application.SendNotification();
4874 application.Render();
4879 int UtcDaliImageViewPlaceholderImage02(void)
4881 tet_infoline("Test imageView use placeholder image without resource ready");
4883 ToolkitTestApplication application;
4886 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4888 ImageView imageView = ImageView::New();
4889 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4890 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4891 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
4892 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
4893 application.GetScene().Add(imageView);
4895 Property::Value value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4897 DALI_TEST_CHECK(value.Get(url));
4898 DALI_TEST_CHECK(url.empty());
4900 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4901 application.SendNotification();
4902 application.Render();
4904 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4906 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4907 DALI_TEST_CHECK(value.Get(url));
4908 DALI_TEST_CHECK(url == gImage_34_RGBA);
4910 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
4911 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
4913 gResourceReadySignalFired = false;
4914 map[Toolkit::ImageVisual::Property::URL] = "";
4915 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4916 application.SendNotification();
4917 application.Render();
4919 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
4920 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
4925 int UtcDaliImageViewTransitionEffect01(void)
4927 tet_infoline("Test imageView use transition effect");
4929 ToolkitTestApplication application;
4931 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4932 map[Toolkit::Visual::Property::OPACITY] = 0.9f;
4934 ImageView imageView = ImageView::New();
4935 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4936 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4937 application.GetScene().Add(imageView);
4939 Property::Value value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
4941 DALI_TEST_CHECK(value.Get(transition));
4942 DALI_TEST_CHECK(transition == false);
4943 imageView.SetProperty(Toolkit::ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
4945 application.SendNotification();
4946 application.Render();
4948 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
4949 DALI_TEST_CHECK(value.Get(transition));
4950 DALI_TEST_CHECK(transition == true);
4952 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4953 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4954 application.SendNotification();
4955 application.Render();
4957 // Test transition effect with placeholder
4958 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4959 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4960 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4961 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4962 application.SendNotification();
4963 application.Render();
4965 map[Toolkit::ImageVisual::Property::URL] = "";
4966 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4967 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4968 application.SendNotification();
4969 application.Render();
4971 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4972 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4973 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4974 application.SendNotification();
4975 application.Render();
4977 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4978 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4979 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4980 application.SendNotification();
4982 map[Toolkit::ImageVisual::Property::URL] = "";
4983 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4984 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4985 application.SendNotification();
4986 application.Render();
4988 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4989 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4990 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, "");
4991 application.SendNotification();
4992 application.Render();
4994 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4995 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4996 application.SendNotification();
4997 application.Render();
4999 map[Toolkit::ImageVisual::Property::URL] = "";
5000 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5001 application.SendNotification();
5002 application.Render();
5004 // Test transition effect without placeholder
5005 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5006 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5007 application.SendNotification();
5008 application.Render();
5010 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5011 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5012 application.SendNotification();
5013 application.Render();
5015 map[Toolkit::ImageVisual::Property::URL] = "";
5016 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5017 application.SendNotification();
5018 application.Render();
5020 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5021 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5022 application.SendNotification();
5023 application.Render();
5025 imageView.SetImage(TEST_IMAGE_1);
5026 application.SendNotification();
5027 application.Render();
5029 imageView.SetImage(gImage_600_RGB);
5030 application.SendNotification();
5031 application.Render(9000);
5033 imageView.SetImage("");
5034 application.SendNotification();
5035 application.Render();
5037 imageView.SetImage(TEST_IMAGE_1);
5038 application.SendNotification();
5039 application.Render();
5042 imageView.Unparent();
5048 int UtcDaliImageViewTransitionEffect02(void)
5050 tet_infoline("Test imageView use transition effect with replace image");
5052 ToolkitTestApplication application;
5056 ImageView imageView = ImageView::New();
5057 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5058 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5059 application.GetScene().Add(imageView);
5061 Property::Value value;
5062 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5064 DALI_TEST_CHECK(value.Get(transition));
5065 DALI_TEST_CHECK(transition == false);
5066 imageView.SetProperty(Toolkit::ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
5068 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5070 DALI_TEST_CHECK(value.Get(url));
5071 DALI_TEST_CHECK(url.empty());
5072 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5073 application.SendNotification();
5074 application.Render();
5076 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, "");
5077 application.SendNotification();
5078 application.Render();
5080 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5081 application.SendNotification();
5082 application.Render();
5084 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5085 DALI_TEST_CHECK(value.Get(transition));
5086 DALI_TEST_CHECK(transition == true);
5088 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5089 DALI_TEST_CHECK(value.Get(url));
5090 DALI_TEST_CHECK(url == gImage_34_RGBA);
5092 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5093 application.SendNotification();
5094 application.Render();
5097 imageView.Unparent();
5103 int UtcDaliImageViewTransitionEffect03(void)
5105 tet_infoline("Test imageView use transition effect with placeholder");
5107 ToolkitTestApplication application;
5110 ImageView imageView = ImageView::New();
5111 imageView.SetImage("");
5112 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5113 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5114 imageView.SetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
5115 application.GetScene().Add(imageView);
5117 //DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5119 application.SendNotification();
5120 application.Render(16);
5122 tet_infoline("(1)");
5123 imageView.SetImage(gImage_600_RGB);
5124 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5125 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
5126 application.SendNotification();
5127 application.Render(16);
5129 Property::Value value;
5130 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5132 DALI_TEST_CHECK(value.Get(transition));
5133 DALI_TEST_CHECK(transition == true);
5135 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5137 DALI_TEST_CHECK(value.Get(url));
5138 DALI_TEST_CHECK(url == gImage_34_RGBA);
5140 imageView.SetImage("");
5141 application.SendNotification();
5142 application.Render(16);
5144 imageView.SetImage(TEST_IMAGE_1);
5145 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5146 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5147 application.SendNotification();
5148 application.Render(16);
5151 imageView.Unparent();