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);
580 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
582 // loading started, this waits for the loader thread for max 30 seconds
583 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
585 application.SendNotification();
586 application.Render(16);
588 callStack.Enable(false);
590 TraceCallStack::NamedParams params;
591 params["width"] << 34;
592 params["height"] << 34;
593 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
598 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
600 ToolkitTestApplication application;
602 //Async loading, automatic atlasing for small size image
603 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
605 callStack.Enable(true);
607 Property::Map asyncLoadingMap;
608 asyncLoadingMap["url"] = gImage_34_RGBA;
609 asyncLoadingMap["desiredHeight"] = 34;
610 asyncLoadingMap["desiredWidth"] = 34;
611 asyncLoadingMap["synchronousLoading"] = false;
612 asyncLoadingMap["atlasing"] = true;
614 ImageView imageView = ImageView::New();
615 imageView.SetProperty(ImageView::Property::IMAGE, asyncLoadingMap);
617 application.GetScene().Add(imageView);
619 // loading started, this waits for the loader thread for max 30 seconds
620 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
622 application.SendNotification();
623 application.Render(16);
625 callStack.Enable(false);
627 TraceCallStack::NamedParams params;
628 params["width"] << 34;
629 params["height"] << 34;
630 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
635 int UtcDaliImageViewSyncLoading(void)
637 ToolkitTestApplication application;
639 tet_infoline("ImageView Testing sync loading and size using index key property map");
641 Property::Map syncLoadingMap;
642 syncLoadingMap[ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
643 syncLoadingMap[ImageVisual::Property::ATLASING] = true;
645 // Sync loading, no atlasing for big size image
647 ImageView imageView = ImageView::New();
649 // Sync loading is used
650 syncLoadingMap[ImageVisual::Property::URL] = gImage_600_RGB;
651 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
654 // Sync loading, automatic atlasing for small size image
656 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
658 callStack.Enable(true);
660 ImageView imageView = ImageView::New();
662 // Sync loading is used
663 syncLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
664 syncLoadingMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
665 syncLoadingMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
666 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
668 application.GetScene().Add(imageView);
669 application.SendNotification();
670 application.Render(16);
672 TraceCallStack::NamedParams params;
673 params["width"] << 34;
674 params["height"] << 34;
675 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
682 int UtcDaliImageViewSyncLoading02(void)
684 ToolkitTestApplication application;
686 tet_infoline("ImageView Testing sync loading and size using string key property map");
688 // Sync loading, automatic atlasing for small size image
690 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
692 callStack.Enable(true);
694 ImageView imageView = ImageView::New();
696 // Sync loading is used
697 Property::Map syncLoadingMap;
698 syncLoadingMap["url"] = gImage_34_RGBA;
699 syncLoadingMap["desiredHeight"] = 34;
700 syncLoadingMap["desiredWidth"] = 34;
701 syncLoadingMap["synchronousLoading"] = true;
702 syncLoadingMap["atlasing"] = true;
703 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
705 application.GetScene().Add(imageView);
706 application.SendNotification();
707 application.Render(16);
709 TraceCallStack::NamedParams params;
710 params["width"] << 34;
711 params["height"] << 34;
712 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
719 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
721 ToolkitTestApplication application;
722 TestGlAbstraction& gl = application.GetGlAbstraction();
723 const std::vector<GLuint>& textures = gl.GetBoundTextures();
724 size_t numTextures = textures.size();
726 // Get encoded raw-buffer image and generate url
727 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
728 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
730 // Async loading, no atlasing for big size image
731 ImageView imageView = ImageView::New(url.GetUrl());
733 // By default, Aysnc loading is used
734 application.GetScene().Add(imageView);
735 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
736 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
738 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
740 application.SendNotification();
741 application.Render(16);
742 application.SendNotification();
744 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
745 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
750 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
752 ToolkitTestApplication application;
754 // Get encoded raw-buffer image and generate url
755 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
756 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
757 ImageUrl url2 = Toolkit::Image::GenerateUrl(buffer);
759 // Generate url is not equal to url2
760 // NOTE : This behavior may changed when ImageUrl compare operator changed.
761 DALI_TEST_CHECK(url != url2);
762 // Generate url's string is equal to url2's string
763 DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
765 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
766 url2 = Toolkit::Image::GenerateUrl(buffer2);
768 // Check whethere two url are not equal
769 DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
771 // Async loading, automatic atlasing for small size image
772 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
774 callStack.Enable(true);
776 Property::Map imageMap;
778 imageMap[ImageVisual::Property::URL] = url.GetUrl();
779 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 600;
780 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 600;
781 imageMap[ImageVisual::Property::ATLASING] = true;
783 // No atlasing with big image
784 ImageView imageView_bigdesired = ImageView::New();
785 imageView_bigdesired.SetProperty(ImageView::Property::IMAGE, imageMap);
786 imageView_bigdesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
788 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 0;
789 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 0;
791 // No atlasing with zero desired size
792 ImageView imageView_nodesired = ImageView::New();
793 imageView_nodesired.SetProperty(ImageView::Property::IMAGE, imageMap);
794 imageView_nodesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
796 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
797 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
799 ImageView imageView = ImageView::New();
800 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
801 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
803 // By default, Aysnc loading is used
804 // loading is not started if the actor is offScene
805 application.GetScene().Add(imageView);
806 application.GetScene().Add(imageView_bigdesired);
807 application.GetScene().Add(imageView_nodesired);
808 application.SendNotification();
809 application.Render(16);
811 // loading started, this waits for the loader thread for max 30 seconds
812 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
814 application.Render(16);
815 application.SendNotification();
817 // Change url to url2
818 imageMap[ImageVisual::Property::URL] = url2.GetUrl();
819 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
821 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
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.SendNotification();
827 application.Render(16);
829 callStack.Enable(false);
831 TraceCallStack::NamedParams params;
832 params["width"] << 34;
833 params["height"] << 34;
834 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
839 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
841 ToolkitTestApplication application;
843 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
845 // Get encoded raw-buffer image and generate url
846 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
847 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
849 // Sync loading, automatic atlasing for small size image
851 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
853 callStack.Enable(true);
855 ImageView imageView = ImageView::New();
857 // Sync loading is used
858 Property::Map syncLoadingMap;
859 syncLoadingMap["url"] = url.GetUrl();
860 syncLoadingMap["alphaMaskUrl"] = gImage_34_RGBA;
861 syncLoadingMap["desiredHeight"] = 34;
862 syncLoadingMap["desiredWidth"] = 34;
863 syncLoadingMap["synchronousLoading"] = true;
864 syncLoadingMap["atlasing"] = true;
865 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
867 application.GetScene().Add(imageView);
868 application.SendNotification();
869 application.Render(16);
871 TraceCallStack::NamedParams params;
872 params["width"] << 34;
873 params["height"] << 34;
874 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
882 int UtcDaliImageViewAddedTexture(void)
884 ToolkitTestApplication application;
886 tet_infoline("ImageView Testing image view with texture provided manager url");
888 ImageView imageView = ImageView::New();
890 // empty texture is ok, though pointless from app point of view
892 std::string url = TextureManager::AddTexture(empty);
893 DALI_TEST_CHECK(url.size() > 0u);
895 Property::Map propertyMap;
896 propertyMap[ImageVisual::Property::URL] = url;
897 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
899 application.GetScene().Add(imageView);
900 application.SendNotification();
901 application.Render();
906 int UtcDaliImageViewSizeWithBackground(void)
908 ToolkitTestApplication application;
912 ImageView imageView = ImageView::New();
914 imageView.SetProperty(Control::Property::BACKGROUND,
916 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
917 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
918 {ImageVisual::Property::DESIRED_WIDTH, width},
919 {ImageVisual::Property::DESIRED_HEIGHT, height},
922 application.GetScene().Add(imageView);
923 application.SendNotification();
924 application.Render();
926 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
927 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
932 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
934 ToolkitTestApplication application;
936 int widthBackground = 100;
937 int heightBackground = 200;
941 ImageView imageView = ImageView::New();
943 imageView.SetProperty(Control::Property::BACKGROUND,
945 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
946 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
947 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
948 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground},
951 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio, 600x600 pixels
953 application.GetScene().Add(imageView);
954 application.SendNotification();
955 application.Render();
957 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
958 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
963 int UtcDaliImageViewHeightForWidthBackground(void)
965 ToolkitTestApplication application;
967 int widthBackground = 100;
968 int heightBackground = 200;
970 ImageView imageView = ImageView::New();
972 imageView.SetProperty(Control::Property::BACKGROUND,
973 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
974 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
975 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
976 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}});
978 application.GetScene().Add(imageView);
979 application.SendNotification();
980 application.Render();
982 Control control = Control::DownCast(imageView);
983 DALI_TEST_CHECK(control);
984 DALI_TEST_EQUALS(imageView.GetHeightForWidth(123.f), control.GetHeightForWidth(123.f), TEST_LOCATION);
985 DALI_TEST_EQUALS(imageView.GetWidthForHeight(321.f), control.GetWidthForHeight(321.f), TEST_LOCATION);
990 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
992 ToolkitTestApplication application;
994 int widthBackground = 100;
995 int heightBackground = 200;
999 ImageView imageView = ImageView::New();
1001 imageView.SetProperty(Control::Property::BACKGROUND,
1002 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1003 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1004 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1005 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}}); // 1 to 2 ratio
1007 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio
1009 application.GetScene().Add(imageView);
1010 application.SendNotification();
1011 application.Render();
1013 DALI_TEST_EQUALS(imageView.GetHeightForWidth(width), (float)height, TEST_LOCATION);
1014 DALI_TEST_EQUALS(imageView.GetWidthForHeight(height), (float)width, TEST_LOCATION);
1019 int UtcDaliImageViewSetImageUrl(void)
1021 ToolkitTestApplication application;
1023 ImageView imageView = ImageView::New();
1024 imageView.SetImage(TEST_IMAGE_FILE_NAME);
1025 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
1027 imageView.SetImage(TEST_IMAGE_FILE_NAME2);
1028 TestUrl(imageView, TEST_IMAGE_FILE_NAME2);
1033 bool gResourceReadySignalFired = false;
1034 Vector3 gNaturalSize;
1036 void ResourceReadySignal(Control control)
1038 gResourceReadySignalFired = true;
1041 void OnResourceReadySignalSVG(Control control)
1043 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1044 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(control);
1045 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1046 Property::Map resultMap;
1047 imageVisual.CreatePropertyMap(resultMap);
1049 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1050 DALI_TEST_CHECK(transformValue);
1051 Property::Map* retMap = transformValue->GetMap();
1052 DALI_TEST_CHECK(retMap);
1054 // Fitting mode should not be applied at this point
1055 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::SIZE)->Get<Vector2>(), Vector2::ZERO, TEST_LOCATION);
1058 int UtcDaliImageViewCheckResourceReady(void)
1060 ToolkitTestApplication application;
1062 gResourceReadySignalFired = false;
1064 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1065 ImageView imageView = ImageView::New(TEST_GIF_FILE_NAME);
1067 imageView.SetProperty(Control::Property::BACKGROUND,
1068 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1069 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1070 {ImageVisual::Property::DESIRED_WIDTH, 100},
1071 {ImageVisual::Property::DESIRED_HEIGHT, 200}});
1073 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1075 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1077 application.GetScene().Add(imageView);
1079 // loading started, this waits for the loader thread
1080 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1082 application.SendNotification();
1083 application.Render(16);
1085 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1087 application.SendNotification();
1088 application.Render();
1090 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1092 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1097 int UtcDaliImageViewSetImageTypeChangesP(void)
1099 ToolkitTestApplication application;
1101 ImageView imageView = ImageView::New();
1102 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1104 application.GetScene().Add(imageView);
1108 Toolkit::Visual::Base visual;
1110 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1111 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1113 application.SendNotification();
1114 application.Render(16);
1116 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1118 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1119 DALI_TEST_CHECK(!visual); // Visual should be invalid
1122 imageView.SetImage("TEST_URL");
1124 application.SendNotification();
1125 application.Render(16);
1127 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1128 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1130 DALI_TEST_CHECK(value.Get(url)); // Value should NOT be empty
1131 DALI_TEST_CHECK(!value.Get(map)); // Value should be empty
1132 DALI_TEST_CHECK(visual); // Visual should be valid
1135 imageView.SetImage("");
1137 application.SendNotification();
1138 application.Render(16);
1140 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1141 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1143 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1145 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1146 DALI_TEST_CHECK(!visual); // Visual should be invalid
1148 // Set a URL in property map
1149 Property::Map propertyMap;
1150 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1151 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
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
1160 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1161 DALI_TEST_CHECK(visual); // Visual should be valid
1163 // Set a URL in property map again
1164 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1165 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1167 application.SendNotification();
1168 application.Render(16);
1170 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1171 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1173 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1174 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1175 DALI_TEST_CHECK(visual); // Visual should be valid
1177 // Set an empty URL in property map
1178 propertyMap[ImageVisual::Property::URL] = std::string();
1179 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1181 application.SendNotification();
1182 application.Render(16);
1184 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1185 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1187 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1188 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1189 DALI_TEST_CHECK(!visual); // Visual should be invalid
1191 // Set a URL in property map again
1192 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1193 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1195 application.SendNotification();
1196 application.Render(16);
1198 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1199 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1201 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1202 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1203 DALI_TEST_CHECK(visual); // Visual should be valid
1205 // Set an empty property map
1206 propertyMap.Clear();
1207 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1209 application.SendNotification();
1210 application.Render(16);
1212 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1213 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1215 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1216 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1217 DALI_TEST_CHECK(map.Empty()); // But PropertyMap should be empty
1218 DALI_TEST_CHECK(!visual); // Visual should be invalid
1223 int UtcDaliImageViewResourceUrlP(void)
1225 ToolkitTestApplication application;
1227 ImageView imageView = ImageView::New();
1228 DALI_TEST_CHECK(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>().empty());
1230 imageView.SetProperty(ImageView::Property::IMAGE, "TestString");
1231 DALI_TEST_EQUALS(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>(), "TestString", TEST_LOCATION);
1236 int UtcDaliImageViewReplaceImage(void)
1238 ToolkitTestApplication application;
1240 gResourceReadySignalFired = false;
1242 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1243 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1245 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1247 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1249 application.GetScene().Add(imageView);
1251 application.SendNotification();
1252 application.Render(16);
1254 // loading started, this waits for the loader thread for max 30 seconds
1255 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1257 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1259 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1261 gResourceReadySignalFired = false;
1263 imageView.SetImage(TEST_IMAGE_2);
1265 application.SendNotification();
1266 application.Render(16);
1268 // loading started, this waits for the loader thread for max 30 seconds
1269 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1271 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1273 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1275 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1280 int UtcDaliImageViewReloadAlphaMaskImage(void)
1282 ToolkitTestApplication application;
1284 gResourceReadySignalFired = false;
1286 ImageView dummy = ImageView::New();
1287 ImageView imageView = ImageView::New();
1288 Property::Map propertyMap;
1290 // To keep alpha mask cached, scene on some dummy image.
1291 // Note : If we don't cache alpha mask image, the reference count of mask image become zero.
1292 // In this case, we might need to wait mask image loading, which is not neccesary & can be changed behavior.
1293 propertyMap[ImageVisual::Property::URL] = gImage_600_RGB;
1294 propertyMap[ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
1295 dummy.SetProperty(ImageView::Property::IMAGE, propertyMap);
1297 application.GetScene().Add(dummy);
1299 application.SendNotification();
1300 application.Render(16);
1302 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1304 application.SendNotification();
1305 application.Render(16);
1307 propertyMap.Clear();
1308 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1309 propertyMap[ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
1310 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1312 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1314 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1316 application.GetScene().Add(imageView);
1318 application.SendNotification();
1319 application.Render(16);
1321 // Load image and use cached mask. Now we try to apply masking.
1322 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1324 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
1326 // Cancel apply masking.
1327 imageView.Unparent();
1329 application.SendNotification();
1330 application.Render(16);
1332 // Reload same image again.
1333 application.GetScene().Add(imageView);
1335 application.SendNotification();
1336 application.Render(16);
1338 // Finish apply masking.
1339 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1341 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1342 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1343 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1348 void OnRelayoutOverride(Size size)
1350 gNaturalSize = size; // Size Relayout is using
1353 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1355 ToolkitTestApplication application;
1357 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1358 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1359 imageView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1361 DummyControl dummyControl = DummyControl::New(true);
1362 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1363 dummyControl.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
1365 dummyControl.Add(imageView);
1366 dummyImpl.SetRelayoutCallback(&OnRelayoutOverride);
1367 application.GetScene().Add(dummyControl);
1369 application.SendNotification();
1370 application.Render();
1372 // loading started, this waits for the loader thread for max 30 seconds
1373 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1375 DALI_TEST_EQUALS(gNaturalSize.width, 1024.0f, TEST_LOCATION);
1376 DALI_TEST_EQUALS(gNaturalSize.height, 1024.0f, TEST_LOCATION);
1378 gNaturalSize = Vector3::ZERO;
1380 imageView.SetImage(gImage_600_RGB);
1382 // Waiting for resourceReady so SendNotifcation not called here.
1384 // loading started, this waits for the loader thread for max 30 seconds
1385 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1387 // Trigger a potential relayout
1388 application.SendNotification();
1389 application.Render();
1391 DALI_TEST_EQUALS(gNaturalSize.width, 600.0f, TEST_LOCATION);
1392 DALI_TEST_EQUALS(gNaturalSize.height, 600.0f, TEST_LOCATION);
1397 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1399 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1401 ToolkitTestApplication application;
1403 gResourceReadySignalFired = false;
1405 Property::Map imageMap;
1407 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1408 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1410 tet_infoline("Creating ImageView without URL so image does not start loading");
1411 ImageView imageView = ImageView::New();
1412 tet_infoline("Connect to image loaded signal before setting image");
1413 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1414 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1415 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1417 // loading started, this waits for the loader thread
1418 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1420 application.SendNotification();
1421 application.Render(16);
1423 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1428 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1430 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1432 ToolkitTestApplication application;
1434 gResourceReadySignalFired = false;
1436 Property::Map imageMap;
1438 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1439 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1441 ImageView imageView = ImageView::New();
1442 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1443 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1445 // loading started, this waits for the loader thread
1446 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1448 application.SendNotification();
1449 application.Render(16);
1451 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1452 gResourceReadySignalFired = false;
1454 ImageView imageViewWithExistingImage = ImageView::New();
1455 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1456 imageViewWithExistingImage.SetProperty(ImageView::Property::IMAGE, imageMap);
1458 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1463 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1465 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1467 ToolkitTestApplication application;
1469 gResourceReadySignalFired = false;
1471 Property::Map imageImmediateLoadingMap;
1472 imageImmediateLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1473 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1475 tet_infoline("Immediate load an image");
1476 ImageView imageView = ImageView::New();
1477 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1478 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
1480 // loading started, this waits for the loader thread
1481 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1483 application.SendNotification();
1484 application.Render(16);
1486 tet_infoline("Check image loaded");
1487 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1488 gResourceReadySignalFired = false;
1490 tet_infoline("Create another ImageView with the same URL");
1491 ImageView imageViewWithExistingImage = ImageView::New(gImage_34_RGBA);
1492 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1493 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1495 application.GetScene().Add(imageViewWithExistingImage);
1497 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1502 int UtcDaliImageViewPaddingProperty(void)
1504 ToolkitTestApplication application;
1506 ImageView imageView = ImageView::New();
1507 Property::Map imagePropertyMap;
1508 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1509 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
1510 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1511 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1512 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1513 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1514 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1515 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1516 application.GetScene().Add(imageView);
1518 application.SendNotification();
1519 application.Render();
1521 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1523 ImageView childImage = ImageView::New();
1524 childImage.SetBackgroundColor(Color::BLACK);
1525 childImage.SetProperty(Actor::Property::SIZE, Vector2(10.f, 10.f));
1526 imageView.Add(childImage);
1528 application.SendNotification();
1529 application.Render();
1531 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1532 DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
1534 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1535 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1536 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1537 Property::Map resultMap;
1538 imageVisual.CreatePropertyMap(resultMap);
1540 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1541 DALI_TEST_CHECK(transformValue);
1542 Property::Map* retMap = transformValue->GetMap();
1543 DALI_TEST_CHECK(retMap);
1545 // Image Visual should be positioned depending on ImageView's padding
1546 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1551 int UtcDaliImageViewPaddingProperty02(void)
1553 ToolkitTestApplication application;
1555 ImageView imageView = ImageView::New();
1556 Property::Map imagePropertyMap;
1557 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1558 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1559 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1560 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1561 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1562 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1563 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1564 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1565 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1566 application.GetScene().Add(imageView);
1568 application.SendNotification();
1569 application.Render();
1571 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1573 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1574 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1575 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1576 Property::Map resultMap;
1577 imageVisual.CreatePropertyMap(resultMap);
1579 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1580 DALI_TEST_CHECK(transformValue);
1581 Property::Map* retMap = transformValue->GetMap();
1582 DALI_TEST_CHECK(retMap);
1584 // Image Visual should be positioned depending on ImageView's padding
1585 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1590 int UtcDaliImageViewPaddingProperty03(void)
1592 tet_infoline("Test Setting Image Padding then removing it.");
1594 ToolkitTestApplication application;
1596 ImageView imageView = ImageView::New();
1597 Property::Map imagePropertyMap;
1598 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1599 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1600 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1601 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1602 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1603 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1604 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1605 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1606 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1607 application.GetScene().Add(imageView);
1609 application.SendNotification();
1610 application.Render();
1612 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1614 tet_infoline("Remove Padding and test Visual is position correctly");
1616 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1618 application.SendNotification();
1619 application.Render();
1621 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1622 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1623 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1624 Property::Map resultMap;
1625 imageVisual.CreatePropertyMap(resultMap);
1627 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1628 DALI_TEST_CHECK(transformValue);
1629 Property::Map* retMap = transformValue->GetMap();
1630 DALI_TEST_CHECK(retMap);
1632 // Image Visual should be positioned depending on ImageView's padding
1633 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1638 int UtcDaliImageViewPaddingProperty04(void)
1640 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1642 ToolkitTestApplication application;
1644 ImageView imageView = ImageView::New();
1645 Property::Map imagePropertyMap;
1646 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1647 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1648 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1649 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1650 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FILL;
1651 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1652 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1653 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1654 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1655 application.GetScene().Add(imageView);
1657 application.SendNotification();
1658 application.Render();
1660 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1662 tet_infoline("Remove Padding and test Visual is position correctly");
1664 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1666 application.SendNotification();
1667 application.Render();
1669 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1670 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1671 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1672 Property::Map resultMap;
1673 imageVisual.CreatePropertyMap(resultMap);
1675 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1676 DALI_TEST_CHECK(transformValue);
1677 Property::Map* retMap = transformValue->GetMap();
1678 DALI_TEST_CHECK(retMap);
1680 // Image Visual should be positioned depending on ImageView's padding
1681 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1686 int UtcDaliImageViewTransformTest01(void)
1688 tet_infoline("Test Setting a offset transform on the ImageView");
1690 ToolkitTestApplication application;
1692 ImageView imageView = ImageView::New();
1693 Property::Map imagePropertyMap;
1694 imagePropertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE)
1695 .Add(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/Kid1.svg")
1696 .Add(ImageVisual::Property::DESIRED_WIDTH, 120)
1697 .Add(ImageVisual::Property::DESIRED_HEIGHT, 120)
1698 .Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL)
1699 .Add(Visual::Property::TRANSFORM,
1700 Property::Map().Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1701 Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE))
1702 .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(8, 8)));
1704 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1705 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1706 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1707 application.GetScene().Add(imageView);
1709 application.SendNotification();
1710 application.Render();
1712 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1713 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1714 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1715 Property::Map resultMap;
1716 imageVisual.CreatePropertyMap(resultMap);
1718 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1719 DALI_TEST_CHECK(transformValue);
1720 Property::Map* retMap = transformValue->GetMap();
1721 DALI_TEST_CHECK(retMap);
1723 // Image Visual should be positioned depending on ImageView's padding
1724 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(8, 8), TEST_LOCATION);
1725 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);
1730 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1732 ToolkitTestApplication application;
1734 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1735 ImageView imageView = ImageView::New();
1736 Property::Map imageMap;
1737 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1738 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_34_RGBA;
1739 imageMap[Toolkit::ImageVisual::Property::ATLASING] = true;
1740 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1741 application.GetScene().Add(imageView);
1743 // Trigger a potential relayout
1744 application.SendNotification();
1745 application.Render();
1747 Vector3 naturalSize = imageView.GetNaturalSize();
1749 DALI_TEST_EQUALS(naturalSize.width, 34.0f, TEST_LOCATION);
1750 DALI_TEST_EQUALS(naturalSize.height, 34.0f, TEST_LOCATION);
1755 int UtcDaliImageViewFillMode(void)
1757 ToolkitTestApplication application;
1759 tet_infoline("Create an ImageVisual without padding and set the fill-mode to fill");
1761 ImageView imageView = ImageView::New();
1762 Property::Map imageMap;
1763 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1764 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB);
1765 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL);
1767 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1769 application.GetScene().Add(imageView);
1771 // Trigger a potential relayout
1772 application.SendNotification();
1773 application.Render();
1775 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1776 Property::Map returnedMap;
1777 visual.CreatePropertyMap(returnedMap);
1779 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1780 DALI_TEST_CHECK(value);
1781 Property::Map* map = value->GetMap();
1782 DALI_TEST_CHECK(map);
1784 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1785 DALI_TEST_CHECK(value);
1786 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION);
1788 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1789 DALI_TEST_CHECK(value);
1790 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1795 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1797 ToolkitTestApplication application;
1799 tet_infoline("Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )");
1800 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1802 ImageView imageView = ImageView::New();
1803 Property::Map imageMap;
1804 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1805 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1806 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
1808 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1809 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1811 application.GetScene().Add(imageView);
1813 // Trigger a potential relayout
1814 application.SendNotification();
1815 application.Render();
1817 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1818 Property::Map returnedMap;
1819 visual.CreatePropertyMap(returnedMap);
1821 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1822 DALI_TEST_CHECK(value);
1823 Property::Map* map = value->GetMap();
1824 DALI_TEST_CHECK(map);
1827 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1828 DALI_TEST_CHECK(value);
1829 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION);
1831 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1832 DALI_TEST_CHECK(value);
1833 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1835 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1836 DALI_TEST_CHECK(value);
1837 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
1842 int UtcDaliImageViewFittingModesFill(void)
1844 ToolkitTestApplication application;
1846 tet_infoline("Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )");
1847 tet_infoline(" There should be no need to change the transform, only size is changed to fit view");
1849 ImageView imageView = ImageView::New();
1850 Property::Map imageMap;
1851 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1852 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1853 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL);
1855 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1856 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1858 application.GetScene().Add(imageView);
1860 // Trigger a potential relayout
1861 application.SendNotification();
1862 application.Render();
1864 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1865 Property::Map returnedMap;
1866 visual.CreatePropertyMap(returnedMap);
1868 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1869 DALI_TEST_CHECK(value);
1870 Property::Map* map = value->GetMap();
1871 DALI_TEST_CHECK(map);
1873 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1874 DALI_TEST_CHECK(value);
1875 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Change the internal size according to the image view size
1877 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1878 DALI_TEST_CHECK(value);
1879 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1881 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1882 DALI_TEST_CHECK(value);
1883 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1888 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1890 ToolkitTestApplication application;
1892 tet_infoline("Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )");
1893 tet_infoline(" offset or size is the same as view, but adjust internally using pixelArea ");
1895 ImageView imageView = ImageView::New();
1896 Property::Map imageMap;
1897 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1898 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1899 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO);
1901 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1902 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 500));
1904 application.GetScene().Add(imageView);
1906 // Trigger a potential relayout
1907 application.SendNotification();
1908 application.Render();
1910 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1911 Property::Map returnedMap;
1912 visual.CreatePropertyMap(returnedMap);
1914 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1915 DALI_TEST_CHECK(value);
1916 Property::Map* map = value->GetMap();
1917 DALI_TEST_CHECK(map);
1920 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1921 DALI_TEST_CHECK(value);
1922 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 500), TEST_LOCATION); // Change the internal size according to the image view size
1924 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1925 DALI_TEST_CHECK(value);
1926 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1928 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1929 DALI_TEST_CHECK(value);
1930 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1935 int UtcDaliImageViewFittingModesCenter01(void)
1937 ToolkitTestApplication application;
1939 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [700,700] )");
1940 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1942 ImageView imageView = ImageView::New();
1943 Property::Map imageMap;
1944 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1945 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1946 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1948 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1949 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1951 application.GetScene().Add(imageView);
1953 // Trigger a potential relayout
1954 application.SendNotification();
1955 application.Render();
1957 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1958 Property::Map returnedMap;
1959 visual.CreatePropertyMap(returnedMap);
1961 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1962 DALI_TEST_CHECK(value);
1963 Property::Map* map = value->GetMap();
1964 DALI_TEST_CHECK(map);
1966 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1967 DALI_TEST_CHECK(value);
1968 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1970 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1971 DALI_TEST_CHECK(value);
1972 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1974 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1975 DALI_TEST_CHECK(value);
1976 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1981 int UtcDaliImageViewFittingModesCenter02(void)
1983 ToolkitTestApplication application;
1985 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [500,500] )");
1986 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1988 ImageView imageView = ImageView::New();
1989 Property::Map imageMap;
1990 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1991 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1992 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1994 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1995 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1997 application.GetScene().Add(imageView);
1999 // Trigger a potential relayout
2000 application.SendNotification();
2001 application.Render();
2003 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2004 Property::Map returnedMap;
2005 visual.CreatePropertyMap(returnedMap);
2007 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2008 DALI_TEST_CHECK(value);
2009 Property::Map* map = value->GetMap();
2010 DALI_TEST_CHECK(map);
2012 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2013 DALI_TEST_CHECK(value);
2014 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2016 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2017 DALI_TEST_CHECK(value);
2018 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2020 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2021 DALI_TEST_CHECK(value);
2022 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
2027 int UtcDaliImageViewFittingModesFitHeight01(void)
2029 ToolkitTestApplication application;
2031 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )");
2033 ImageView imageView = ImageView::New();
2034 Property::Map imageMap;
2035 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2036 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2037 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2039 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2040 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2042 application.GetScene().Add(imageView);
2044 // Trigger a potential relayout
2045 application.SendNotification();
2046 application.Render();
2048 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2049 Property::Map returnedMap;
2050 visual.CreatePropertyMap(returnedMap);
2052 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2053 DALI_TEST_CHECK(value);
2054 Property::Map* map = value->GetMap();
2055 DALI_TEST_CHECK(map);
2057 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2058 DALI_TEST_CHECK(value);
2059 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 700), TEST_LOCATION); // Change the internal size according to the image view size
2061 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2062 DALI_TEST_CHECK(value);
2063 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2065 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2066 DALI_TEST_CHECK(value);
2067 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2072 int UtcDaliImageViewFittingModesFitHeight02(void)
2074 ToolkitTestApplication application;
2076 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )");
2078 ImageView imageView = ImageView::New();
2079 Property::Map imageMap;
2080 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2081 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2082 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2084 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2085 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2087 application.GetScene().Add(imageView);
2089 // Trigger a potential relayout
2090 application.SendNotification();
2091 application.Render();
2093 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2094 Property::Map returnedMap;
2095 visual.CreatePropertyMap(returnedMap);
2097 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2098 DALI_TEST_CHECK(value);
2099 Property::Map* map = value->GetMap();
2100 DALI_TEST_CHECK(map);
2102 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2103 DALI_TEST_CHECK(value);
2104 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2106 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2107 DALI_TEST_CHECK(value);
2108 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2110 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2111 DALI_TEST_CHECK(value);
2112 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2117 int UtcDaliImageViewFittingModesFitWidth01(void)
2119 ToolkitTestApplication application;
2121 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )");
2123 ImageView imageView = ImageView::New();
2124 Property::Map imageMap;
2125 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2126 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2127 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2129 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2130 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2132 application.GetScene().Add(imageView);
2134 // Trigger a potential relayout
2135 application.SendNotification();
2136 application.Render();
2138 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2139 Property::Map returnedMap;
2140 visual.CreatePropertyMap(returnedMap);
2142 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2143 DALI_TEST_CHECK(value);
2144 Property::Map* map = value->GetMap();
2145 DALI_TEST_CHECK(map);
2147 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2148 DALI_TEST_CHECK(value);
2149 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2151 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2152 DALI_TEST_CHECK(value);
2153 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2155 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2156 DALI_TEST_CHECK(value);
2157 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
2162 int UtcDaliImageViewFittingModesFitWidth02(void)
2164 ToolkitTestApplication application;
2166 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )");
2168 ImageView imageView = ImageView::New();
2169 Property::Map imageMap;
2170 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2171 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2172 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2174 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2175 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2177 application.GetScene().Add(imageView);
2179 // Trigger a potential relayout
2180 application.SendNotification();
2181 application.Render();
2183 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2184 Property::Map returnedMap;
2185 visual.CreatePropertyMap(returnedMap);
2187 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2188 DALI_TEST_CHECK(value);
2189 Property::Map* map = value->GetMap();
2190 DALI_TEST_CHECK(map);
2192 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2193 DALI_TEST_CHECK(value);
2194 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 600), TEST_LOCATION); // Change the internal size according to the image view size
2196 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2197 DALI_TEST_CHECK(value);
2198 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2200 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2201 DALI_TEST_CHECK(value);
2202 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2207 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2209 ToolkitTestApplication application;
2211 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2213 ImageView imageView = ImageView::New();
2215 // 1. Render using FittingMode::SHRINK_TO_FIT
2216 Property::Map imageMap;
2217 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2218 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2219 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2221 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2222 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2224 application.GetScene().Add(imageView);
2226 // Trigger a potential relayout
2227 application.SendNotification();
2228 application.Render();
2230 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2231 Property::Map returnedMap;
2232 visual.CreatePropertyMap(returnedMap);
2234 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2235 DALI_TEST_CHECK(value);
2236 Property::Map* map = value->GetMap();
2237 DALI_TEST_CHECK(map);
2239 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2240 DALI_TEST_CHECK(value);
2241 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2243 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2244 DALI_TEST_CHECK(value);
2245 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2247 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2248 DALI_TEST_CHECK(value);
2249 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2251 // 2. Render again using DevelVisaul::CENTER
2252 Property::Map imageMap2;
2253 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2254 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2255 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2257 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2258 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2260 application.GetScene().Add(imageView);
2262 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2264 // Trigger a potential relayout
2265 application.SendNotification();
2266 application.Render();
2268 returnedMap.Clear();
2269 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2271 visual.CreatePropertyMap(returnedMap);
2273 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2274 DALI_TEST_CHECK(value);
2275 map = value->GetMap();
2276 DALI_TEST_CHECK(map);
2278 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2279 DALI_TEST_CHECK(value);
2280 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2282 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2283 DALI_TEST_CHECK(value);
2284 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2286 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2287 DALI_TEST_CHECK(value);
2288 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2290 // 3. Render again using before fittingMode
2291 Property::Map imageMap3;
2292 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2293 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2294 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2296 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2297 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2299 application.GetScene().Add(imageView);
2301 // Trigger a potential relayout
2302 application.SendNotification();
2303 application.Render();
2305 returnedMap.Clear();
2306 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2307 visual.CreatePropertyMap(returnedMap);
2309 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2310 DALI_TEST_CHECK(value);
2311 map = value->GetMap();
2312 DALI_TEST_CHECK(map);
2314 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2315 DALI_TEST_CHECK(value);
2316 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2318 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2319 DALI_TEST_CHECK(value);
2320 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2322 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2323 DALI_TEST_CHECK(value);
2324 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2329 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2331 ToolkitTestApplication application;
2333 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2335 ImageView imageView = ImageView::New();
2337 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2338 Property::Map imageMap;
2339 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2340 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2341 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2343 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2344 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2346 application.GetScene().Add(imageView);
2348 // Trigger a potential relayout
2349 application.SendNotification();
2350 application.Render();
2352 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2353 Property::Map returnedMap;
2354 visual.CreatePropertyMap(returnedMap);
2356 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2357 DALI_TEST_CHECK(value);
2358 Property::Map* map = value->GetMap();
2359 DALI_TEST_CHECK(map);
2361 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2362 DALI_TEST_CHECK(value);
2363 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2365 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2366 DALI_TEST_CHECK(value);
2367 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2369 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2370 DALI_TEST_CHECK(value);
2371 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2373 // 2. Render again using DevelVisaul::CENTER
2374 Property::Map imageMap2;
2375 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2376 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2377 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2379 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2380 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2382 application.GetScene().Add(imageView);
2384 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2386 // Trigger a potential relayout
2387 application.SendNotification();
2388 application.Render();
2390 returnedMap.Clear();
2391 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2393 visual.CreatePropertyMap(returnedMap);
2395 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2396 DALI_TEST_CHECK(value);
2397 map = value->GetMap();
2398 DALI_TEST_CHECK(map);
2400 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2401 DALI_TEST_CHECK(value);
2402 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2404 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2405 DALI_TEST_CHECK(value);
2406 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2408 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2409 DALI_TEST_CHECK(value);
2410 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2412 // 3. Render again using before fittingMode
2413 Property::Map imageMap3;
2414 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2415 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2416 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2418 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2419 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2421 application.GetScene().Add(imageView);
2423 // Trigger a potential relayout
2424 application.SendNotification();
2425 application.Render();
2427 returnedMap.Clear();
2428 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2429 visual.CreatePropertyMap(returnedMap);
2431 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2432 DALI_TEST_CHECK(value);
2433 map = value->GetMap();
2434 DALI_TEST_CHECK(map);
2436 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2437 DALI_TEST_CHECK(value);
2438 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2440 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2441 DALI_TEST_CHECK(value);
2442 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2444 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2445 DALI_TEST_CHECK(value);
2446 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2451 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2453 ToolkitTestApplication application;
2455 tet_infoline("Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )");
2457 ImageView imageView = ImageView::New();
2458 Property::Map imageMap;
2459 imageMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE);
2460 imageMap.Add(Toolkit::ImageVisual::Property::URL, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME); // 249x169 image
2462 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2463 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
2465 application.GetScene().Add(imageView);
2467 // Trigger a potential relayout
2468 application.SendNotification();
2469 application.Render();
2471 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2472 Property::Map returnedMap;
2473 visual.CreatePropertyMap(returnedMap);
2475 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2476 DALI_TEST_CHECK(value);
2477 Property::Map* map = value->GetMap();
2478 DALI_TEST_CHECK(map);
2480 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2481 DALI_TEST_CHECK(value);
2482 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Relative size so will take up 100%
2484 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2485 DALI_TEST_CHECK(value);
2486 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2488 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2489 DALI_TEST_CHECK(value);
2490 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2495 int UtcDaliImageViewCustomShader(void)
2497 ToolkitTestApplication application;
2499 // Set a custom shader with an image url
2501 Property::Map properties;
2502 Property::Map shader;
2503 const std::string vertexShader = "Foobar";
2504 const std::string fragmentShader = "Foobar";
2505 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2506 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2508 properties[Visual::Property::TYPE] = Visual::IMAGE;
2509 properties[Visual::Property::SHADER] = shader;
2510 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2512 ImageView imageView = ImageView::New();
2513 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2515 application.GetScene().Add(imageView);
2517 application.SendNotification();
2518 application.Render();
2520 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2522 Renderer renderer = imageView.GetRendererAt(0);
2523 Shader shader2 = renderer.GetShader();
2524 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2525 Property::Map* map = value.GetMap();
2526 DALI_TEST_CHECK(map);
2528 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2529 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2531 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2532 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2535 // Set a custom shader after setting an image url
2537 Property::Map properties;
2538 Property::Map shader;
2539 const std::string vertexShader = "Foobar";
2540 const std::string fragmentShader = "Foobar";
2541 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2542 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2544 properties[Visual::Property::SHADER] = shader;
2546 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
2547 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2549 application.GetScene().Add(imageView);
2551 application.SendNotification();
2552 application.Render();
2554 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2556 Renderer renderer = imageView.GetRendererAt(0);
2557 Shader shader2 = renderer.GetShader();
2558 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2559 Property::Map* map = value.GetMap();
2560 DALI_TEST_CHECK(map);
2562 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2563 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2565 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2566 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2569 // Set a custom shader before setting an image url
2571 Property::Map properties;
2572 Property::Map shader;
2573 const std::string vertexShader = "Foobar";
2574 const std::string fragmentShader = "Foobar";
2575 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2576 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2578 properties[Visual::Property::SHADER] = shader;
2580 ImageView imageView = ImageView::New();
2581 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2582 imageView.SetProperty(ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME);
2584 application.GetScene().Add(imageView);
2586 application.SendNotification();
2587 application.Render();
2588 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2590 Renderer renderer = imageView.GetRendererAt(0);
2591 Shader shader2 = renderer.GetShader();
2592 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2593 Property::Map* map = value.GetMap();
2594 DALI_TEST_CHECK(map);
2596 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2597 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2599 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2600 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2603 // Set a custom shader after setting a property map
2605 Property::Map properties;
2606 Property::Map shader;
2607 const std::string vertexShader = "Foobar";
2608 const std::string fragmentShader = "Foobar";
2609 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2610 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2612 properties[Visual::Property::SHADER] = shader;
2614 Property::Map properties1;
2615 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2616 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2618 ImageView imageView = ImageView::New();
2619 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2620 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2622 application.GetScene().Add(imageView);
2624 application.SendNotification();
2625 application.Render();
2626 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2628 Renderer renderer = imageView.GetRendererAt(0);
2629 Shader shader2 = renderer.GetShader();
2630 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2631 Property::Map* map = value.GetMap();
2632 DALI_TEST_CHECK(map);
2634 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2635 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2637 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2638 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2641 // Set a custom shader before setting a property map
2643 Property::Map properties;
2644 Property::Map shader;
2645 const std::string vertexShader = "Foobar";
2646 const std::string fragmentShader = "Foobar";
2647 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2648 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2650 properties[Visual::Property::SHADER] = shader;
2652 Property::Map properties1;
2653 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2654 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2656 ImageView imageView = ImageView::New();
2657 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2658 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2660 application.GetScene().Add(imageView);
2662 application.SendNotification();
2663 application.Render();
2664 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2666 Renderer renderer = imageView.GetRendererAt(0);
2667 Shader shader2 = renderer.GetShader();
2668 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2669 Property::Map* map = value.GetMap();
2670 DALI_TEST_CHECK(map);
2672 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2673 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2675 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2676 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2684 static int gFailCounter = 0;
2685 const int MAX_RETRIES(3);
2687 void ReloadImage(ImageView imageView)
2689 Property::Map imageImmediateLoadingMap;
2690 imageImmediateLoadingMap[ImageVisual::Property::URL] = "Non-existant-image.jpg";
2691 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
2693 tet_infoline("Immediate load an image");
2694 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
2697 void ResourceFailedReload(Control control)
2703 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2705 tet_infoline("Test reloading failed image from within signal handler.");
2707 ToolkitTestApplication application;
2711 ImageView imageView = ImageView::New();
2712 imageView.ResourceReadySignal().Connect(&ResourceFailedReload);
2713 DALI_TEST_EQUALS(gFailCounter, 0, TEST_LOCATION);
2714 ReloadImage(imageView);
2716 // loading started, this waits for the loader thread to complete
2717 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2718 DALI_TEST_EQUALS(gFailCounter, 1, TEST_LOCATION);
2720 ReloadImage(imageView);
2721 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2722 DALI_TEST_EQUALS(gFailCounter, 2, TEST_LOCATION);
2724 ReloadImage(imageView);
2725 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2726 DALI_TEST_EQUALS(gFailCounter, 3, TEST_LOCATION);
2731 int UtcDaliImageViewLoadRemoteSVG(void)
2733 tet_infoline("Test load from a remote server.");
2735 ToolkitTestApplication application;
2738 Toolkit::ImageView imageView;
2739 imageView = Toolkit::ImageView::New();
2740 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2741 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2742 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2743 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2744 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2746 application.GetScene().Add(imageView);
2748 DALI_TEST_CHECK(imageView);
2750 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2752 application.SendNotification();
2754 // Wait for loading & rasterization
2755 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2757 application.SendNotification();
2758 application.Render();
2760 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2765 Toolkit::ImageView imageView;
2766 imageView = Toolkit::ImageView::New();
2767 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2768 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2769 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2770 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2772 application.GetScene().Add(imageView);
2774 DALI_TEST_CHECK(imageView);
2776 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2778 application.SendNotification();
2780 // Wait for loading & rasterization
2781 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2783 application.SendNotification();
2784 application.Render();
2786 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2792 int UtcDaliImageViewSyncSVGLoading(void)
2794 ToolkitTestApplication application;
2796 tet_infoline("ImageView Testing SVG image sync loading");
2799 ImageView imageView = ImageView::New();
2801 // Sync loading is used
2802 Property::Map syncLoadingMap;
2803 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2804 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2805 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2806 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2808 application.GetScene().Add(imageView);
2809 DALI_TEST_CHECK(imageView);
2811 application.SendNotification();
2812 Vector3 naturalSize = imageView.GetNaturalSize();
2814 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2815 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2820 int UtcDaliImageViewSyncSVGLoading02(void)
2822 ToolkitTestApplication application;
2824 tet_infoline("ImageView Testing SVG image sync loading");
2827 ImageView imageView = ImageView::New();
2829 // Sync loading is used
2830 Property::Map syncLoadingMap;
2831 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2832 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2833 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2834 syncLoadingMap.Insert(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
2835 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2836 imageView.ResourceReadySignal().Connect(&OnResourceReadySignalSVG);
2838 application.GetScene().Add(imageView);
2839 DALI_TEST_CHECK(imageView);
2841 application.SendNotification();
2842 application.Render();
2844 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
2845 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
2846 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
2847 Property::Map resultMap;
2848 imageVisual.CreatePropertyMap(resultMap);
2850 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
2851 DALI_TEST_CHECK(transformValue);
2852 Property::Map* retMap = transformValue->GetMap();
2853 DALI_TEST_CHECK(retMap);
2855 // Image Visual should be positioned depending on ImageView's padding
2856 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::SIZE)->Get<Vector2>(), Vector2(100, 100), TEST_LOCATION);
2858 Vector3 naturalSize = imageView.GetNaturalSize();
2859 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2860 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2865 int UtcDaliImageViewAsyncSVGLoading(void)
2867 ToolkitTestApplication application;
2869 tet_infoline("ImageView Testing SVG image async loading");
2872 ImageView imageView = ImageView::New();
2874 // Async loading is used - default value of SYNCHRONOUS_LOADING is false.
2875 Property::Map propertyMap;
2876 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2877 propertyMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2878 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
2880 application.GetScene().Add(imageView);
2881 DALI_TEST_CHECK(imageView);
2883 application.SendNotification();
2886 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2888 application.SendNotification();
2889 application.Render(16);
2891 Vector3 naturalSize = imageView.GetNaturalSize();
2892 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2893 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2898 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2900 ToolkitTestApplication application;
2902 tet_infoline("ImageView Testing SVG image async loading");
2906 ImageView imageView = ImageView::New();
2908 // Sync loading is used
2909 Property::Map syncLoadingMap;
2910 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2911 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2913 // Check to set invalid value
2914 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2915 // Check if error log is outputted when setting other value like string.
2916 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2917 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5));
2918 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2920 application.GetScene().Add(imageView);
2921 DALI_TEST_CHECK(imageView);
2923 application.SendNotification();
2926 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2928 application.SendNotification();
2929 application.Render(16);
2931 Vector3 naturalSize = imageView.GetNaturalSize();
2932 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2933 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2935 Property::Value value = imageView.GetProperty(ImageView::Property::IMAGE);
2936 Property::Map* map = value.GetMap();
2937 DALI_TEST_CHECK(map);
2939 Property::Value* sync = map->Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING);
2940 DALI_TEST_CHECK(sync);
2941 DALI_TEST_EQUALS(false, sync->Get<bool>(), TEST_LOCATION);
2946 int UtcDaliImageViewSvgLoadingFailureLocalFile(void)
2948 // Local svg file - invalid file path
2950 ToolkitTestApplication application;
2952 TestGlAbstraction& gl = application.GetGlAbstraction();
2953 TraceCallStack& textureTrace = gl.GetTextureTrace();
2954 textureTrace.Enable(true);
2956 gResourceReadySignalFired = false;
2958 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2959 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2960 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2962 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2964 application.GetScene().Add(imageView);
2966 application.SendNotification();
2968 // loading started, this waits for the loader thread - load
2969 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2971 application.SendNotification();
2972 application.Render(16);
2974 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2975 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2976 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2978 // Should be shown a broken image
2979 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2980 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2983 // Local svg file - invalid file path without size set
2985 ToolkitTestApplication application;
2987 TestGlAbstraction& gl = application.GetGlAbstraction();
2988 TraceCallStack& textureTrace = gl.GetTextureTrace();
2989 textureTrace.Enable(true);
2991 gResourceReadySignalFired = false;
2992 textureTrace.Reset();
2994 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2995 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2997 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2999 application.GetScene().Add(imageView);
3001 application.SendNotification();
3003 // loading started, this waits for the loader thread - load & rasterize
3004 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3006 application.SendNotification();
3007 application.Render(16);
3009 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3010 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3011 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3013 // Should be shown a broken image
3014 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3015 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3018 // Local svg file - invalid file
3020 ToolkitTestApplication application;
3022 TestGlAbstraction& gl = application.GetGlAbstraction();
3023 TraceCallStack& textureTrace = gl.GetTextureTrace();
3024 textureTrace.Enable(true);
3026 gResourceReadySignalFired = false;
3027 textureTrace.Reset();
3029 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.svg");
3030 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3031 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3033 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3035 application.GetScene().Add(imageView);
3037 application.SendNotification();
3039 // loading started, this waits for the loader thread - load & rasterize
3040 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3042 application.SendNotification();
3043 application.Render(16);
3045 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3046 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3047 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3049 // Should be shown a broken image
3050 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3051 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3057 int UtcDaliImageViewSvgLoadingFailureRemoteFile01(void)
3061 ToolkitTestApplication application;
3063 TestGlAbstraction& gl = application.GetGlAbstraction();
3064 TraceCallStack& textureTrace = gl.GetTextureTrace();
3065 textureTrace.Enable(true);
3067 gResourceReadySignalFired = false;
3069 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
3070 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3071 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3073 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3075 application.GetScene().Add(imageView);
3077 application.SendNotification();
3079 // loading started, this waits for the loader thread - load & rasterize
3080 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3082 application.SendNotification();
3083 application.Render(16);
3085 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3086 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3087 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3089 // Should be shown a broken image
3090 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3091 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3097 int UtcDaliImageViewSvgLoadingFailureRemoteFile02(void)
3099 // Remote svg file without size set
3101 ToolkitTestApplication application;
3103 TestGlAbstraction& gl = application.GetGlAbstraction();
3104 TraceCallStack& textureTrace = gl.GetTextureTrace();
3105 textureTrace.Enable(true);
3107 gResourceReadySignalFired = false;
3109 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
3110 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3112 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3114 application.GetScene().Add(imageView);
3116 application.SendNotification();
3118 // loading started, this waits for the loader thread - load & rasterize
3119 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3121 application.SendNotification();
3122 application.Render(16);
3124 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3125 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3126 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3128 // Should be shown a broken image
3129 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3130 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3136 int UtcDaliImageViewSvgRasterizationFailure(void)
3138 ToolkitTestApplication application;
3140 gResourceReadySignalFired = false;
3142 TestGlAbstraction& gl = application.GetGlAbstraction();
3143 TraceCallStack& textureTrace = gl.GetTextureTrace();
3144 textureTrace.Enable(true);
3146 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid1.svg");
3147 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3148 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3150 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3152 application.GetScene().Add(imageView);
3154 application.SendNotification();
3156 // Wait for loading & rasterization
3157 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3159 application.SendNotification();
3160 application.Render(16);
3162 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3163 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3164 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3166 // Should be shown a broken image
3167 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3168 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3173 int UtcDaliImageViewSvgChageSize(void)
3175 ToolkitTestApplication application;
3177 TestGlAbstraction& gl = application.GetGlAbstraction();
3178 TraceCallStack& textureTrace = gl.GetTextureTrace();
3179 textureTrace.Enable(true);
3181 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME);
3182 application.GetScene().Add(imageView);
3184 application.SendNotification();
3186 // Wait for loading & rasterization
3187 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3189 application.SendNotification();
3190 application.Render(16);
3192 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3194 // Change actor size, then rasterization should be done again
3195 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3197 application.SendNotification();
3199 // Wait for rasterization
3200 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3202 application.SendNotification();
3203 application.Render(16);
3205 // We should not load the file again.
3206 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3211 int UtcDaliImageViewSvgAtlasing(void)
3213 ToolkitTestApplication application;
3215 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
3217 callStack.Enable(true);
3219 Property::Map propertyMap;
3220 propertyMap["url"] = TEST_SVG_FILE_NAME;
3221 propertyMap["atlasing"] = true;
3223 ImageView imageView = ImageView::New();
3224 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
3225 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3226 application.GetScene().Add(imageView);
3228 application.SendNotification();
3230 // Wait for loading & rasterization
3231 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3233 application.SendNotification();
3234 application.Render(16);
3237 TraceCallStack::NamedParams params1;
3238 params1["width"] << 100;
3239 params1["height"] << 100;
3240 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params1), true, TEST_LOCATION);
3242 imageView.SetProperty(Actor::Property::SIZE, Vector2(600.f, 600.f));
3244 application.SendNotification();
3246 // Wait for rasterization
3247 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3251 application.SendNotification();
3252 application.Render(16);
3255 TraceCallStack::NamedParams params2;
3256 params2["width"] << 600;
3257 params2["height"] << 600;
3258 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexImage2D", params2), true, TEST_LOCATION);
3263 int UtcDaliImageViewTVGLoading(void)
3265 ToolkitTestApplication application;
3267 tet_infoline("ImageView Testing TVG image loading");
3270 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/test.tvg");
3271 application.GetScene().Add(imageView);
3272 DALI_TEST_CHECK(imageView);
3274 application.SendNotification();
3276 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3278 application.SendNotification();
3279 application.Render(16);
3281 Vector3 naturalSize = imageView.GetNaturalSize();
3283 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3284 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3289 int UtcDaliImageViewSvgDesiredSize01(void)
3291 ToolkitTestApplication application;
3293 TestGlAbstraction& gl = application.GetGlAbstraction();
3294 TraceCallStack& textureTrace = gl.GetTextureTrace();
3295 textureTrace.Enable(true);
3297 int desiredWidth = 100, desiredHeight = 150;
3298 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
3300 application.GetScene().Add(imageView);
3302 application.SendNotification();
3304 // Wait for loading & rasterization
3305 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3307 application.SendNotification();
3308 application.Render(16);
3311 std::stringstream out;
3312 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
3313 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
3319 int UtcDaliImageViewSvgDesiredSize02(void)
3321 ToolkitTestApplication application;
3323 TestGlAbstraction& gl = application.GetGlAbstraction();
3324 TraceCallStack& textureTrace = gl.GetTextureTrace();
3325 textureTrace.Enable(true);
3327 int desiredWidth = 150, desiredHeight = 100;
3328 ImageView imageView = ImageView::New();
3329 imageView[ImageView::Property::IMAGE] = Property::Map().Add("url", TEST_SVG_FILE_NAME).Add("desiredWidth", desiredWidth).Add("desiredHeight", desiredHeight);
3330 application.GetScene().Add(imageView);
3332 application.SendNotification();
3334 // Wait for loading & rasterization
3335 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3337 application.SendNotification();
3338 application.Render(16);
3341 std::stringstream out;
3342 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
3343 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
3349 int UtcDaliImageViewImageLoadFailure01(void)
3351 ToolkitTestApplication application;
3353 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3354 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3355 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3356 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3358 std::string brokenUrl;
3359 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3360 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3362 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3363 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3365 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3366 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3368 ImageView imageView = ImageView::New("invalidUrl.png");
3369 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3371 application.GetScene().Add(imageView);
3372 application.SendNotification();
3373 application.Render(16);
3375 // loading started, this waits for the loader thread
3376 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3381 int UtcDaliImageViewImageLoadFailure02(void)
3383 ToolkitTestApplication application;
3385 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3386 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
3387 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3388 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3390 std::string brokenUrl;
3391 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3392 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
3394 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3395 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3397 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3398 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3400 ImageView imageView = ImageView::New("invalidUrl.png");
3401 imageView.SetProperty(Actor::Property::SIZE, Vector2(30.f, 30.f));
3402 application.GetScene().Add(imageView);
3403 application.SendNotification();
3404 application.Render(16);
3406 // loading started, this waits for the loader thread
3407 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3412 int UtcDaliImageViewImageLoadFailure03(void)
3414 ToolkitTestApplication application;
3416 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3417 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
3418 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
3420 std::string brokenUrl;
3421 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3422 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3424 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3425 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3427 ImageView imageView = ImageView::New("invalidUrl.png");
3428 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3429 application.GetScene().Add(imageView);
3430 application.SendNotification();
3431 application.Render(16);
3433 // loading started, this waits for the loader thread
3434 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3439 int UtcDaliImageViewImageLoadFailure04(void)
3441 ToolkitTestApplication application;
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);
3452 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3453 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3454 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3455 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3457 ImageView imageView2 = ImageView::New("invalidUrl.png");
3458 imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3459 application.GetScene().Add(imageView2);
3461 std::string brokenUrl;
3462 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3463 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3465 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3466 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3468 application.SendNotification();
3469 application.Render(16);
3471 // loading started, this waits for the loader thread
3472 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3474 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3476 ImageView imageView3 = ImageView::New("invalidUrl.png");
3477 imageView3.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3478 application.GetScene().Add(imageView3);
3480 application.SendNotification();
3481 application.Render(16);
3483 // loading started, this waits for the loader thread
3484 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3491 static int gResourceReadySignalCounter = 0;
3493 void OnResourceReadySignal01(Control control)
3495 gResourceReadySignalCounter++;
3497 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3499 if(gResourceReadySignalCounter == 1)
3502 // It makes the first new visual be deleted immediately
3503 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3504 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3507 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3509 // Make the resource ready immediately
3510 control[ImageView::Property::IMAGE] = gImage_600_RGB;
3514 void OnResourceReadySignal02(Control control)
3516 if(++gResourceReadySignalCounter == 1)
3518 // It makes the first new visual be deleted immediately
3519 // The first image will not be loaded.
3520 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB).Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3521 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3525 ImageView gImageView1;
3526 ImageView gImageView2;
3527 ImageView gImageView3;
3528 ImageView gImageView4;
3530 void OnResourceReadySignal03(Control control)
3532 if(gResourceReadySignalCounter == 0)
3535 // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3536 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3538 // 2. Load a new image
3539 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3541 // 3. Use the new image again
3542 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3543 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3545 else if(gResourceReadySignalCounter == 1)
3547 // This is called from TextureManager::ProcessQueuedTextures().
3548 gImageView1.Unparent();
3549 gImageView1.Reset();
3551 gResourceReadySignalCounter++;
3554 void OnSimpleResourceReadySignal(Control control)
3556 // simply increate counter
3557 gResourceReadySignalCounter++;
3560 int gResourceReadySignal04ComesOrder = 0;
3562 void OnResourceReadySignal04(Control control)
3564 gResourceReadySignalCounter++;
3565 tet_printf("rc %d\n", gResourceReadySignalCounter);
3566 if(gResourceReadySignalCounter == 1)
3568 auto scene = gImageView1.GetParent();
3570 // Request load something
3571 // We hope this request result is return later than gImageView2.
3572 gImageView3 = ImageView::New(TEST_IMAGE_1);
3573 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3574 scene.Add(gImageView3);
3575 gImageView4 = ImageView::New(TEST_IMAGE_2);
3576 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3577 scene.Add(gImageView4);
3579 if(control == gImageView1)
3581 gResourceReadySignal04ComesOrder = 1;
3585 gResourceReadySignal04ComesOrder = 2;
3588 if(gResourceReadySignalCounter == 2)
3590 if(gResourceReadySignal04ComesOrder == 1 && control == gImageView2)
3592 // Scene off first one.
3593 gImageView1.Unparent();
3595 // Scene off second one.
3596 gImageView2.Unparent();
3598 else if(gResourceReadySignal04ComesOrder == 2 && control == gImageView1)
3600 // Scene off first one.
3601 gImageView2.Unparent();
3603 // Scene off second one.
3604 gImageView1.Unparent();
3608 // We can't check that this utc fail case. just pass always when we come here.
3609 gResourceReadySignal04ComesOrder = -1;
3612 // If we don't seperate index of FreeList area
3613 // and if we don't queue remove during obversing,
3614 // cache index become something invalid data.
3615 // In this case, some strange observer can be called.
3616 // For example, gImageView4.LoadComplete will be called.
3620 void OnResourceReadySignal05(Control control)
3622 gResourceReadySignalCounter++;
3624 // Request load with same image
3625 // NOTE : The url must not be same as gImageView1
3626 const int viewCount = 4;
3627 for(int i = 0; i < viewCount; ++i)
3629 gImageView1.Add(ImageView::New("invalid2.jpg"));
3633 int gResourceReadySignal06ComesOrder = 0;
3635 void OnResourceReadySignal06(Control control)
3637 gResourceReadySignalCounter++;
3638 if(gResourceReadySignalCounter == 1)
3640 auto scene = gImageView1.GetParent();
3642 // Request load something
3643 // We hope this request result is return later than gImageView2.
3646 map1[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
3647 map1[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
3649 gImageView3 = ImageView::New();
3650 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3651 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3654 map2[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
3655 map2[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_S;
3656 gImageView4 = ImageView::New();
3657 gImageView4.SetProperty(Toolkit::ImageView::Property::IMAGE, map2);
3658 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3660 if(control == gImageView1)
3662 gResourceReadySignal06ComesOrder = 1;
3666 gResourceReadySignal06ComesOrder = 2;
3669 if(gResourceReadySignalCounter == 2)
3671 if(gResourceReadySignal06ComesOrder == 1 && control == gImageView2)
3673 // Scene off first one.
3674 gImageView1.Unparent();
3676 // Scene off second one.
3677 gImageView2.Unparent();
3679 else if(gResourceReadySignal06ComesOrder == 2 && control == gImageView1)
3681 // Scene off first one.
3682 gImageView2.Unparent();
3684 // Scene off second one.
3685 gImageView1.Unparent();
3689 // We can't check that this utc fail case. just pass always when we come here.
3690 gResourceReadySignal06ComesOrder = -1;
3693 // If we don't seperate index of FreeList area
3694 // and if we don't queue remove during obversing,
3695 // cache index become something invalid data.
3696 // In this case, some strange observer can be called.
3697 // For example, gImageView4.LoadComplete will be called.
3701 void OnResourceReadySignal07(Control control)
3703 gResourceReadySignalCounter++;
3704 // Load masked image
3705 tet_printf("rc %d %d\n", gResourceReadySignalCounter, static_cast<bool>(gImageView2));
3709 auto scene = gImageView1.GetParent();
3712 map1[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
3713 map1[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
3715 gImageView2 = ImageView::New();
3716 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3717 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal07);
3719 scene.Add(gImageView2);
3723 void OnResourceReadySignal08(Control control)
3725 gResourceReadySignalCounter++;
3729 gImageView1.Unparent();
3730 gImageView1.Reset();
3734 gImageView2.Unparent();
3735 gImageView2.Reset();
3739 std::size_t gResourceReadySignal09Emitted = false;
3741 void OnResourceReadySignal09(Control control)
3743 gResourceReadySignalCounter++;
3745 if(gImageView1 && !gResourceReadySignal09Emitted)
3747 gResourceReadySignal09Emitted = true;
3748 gImageView1.ResourceReadySignal().Disconnect(&OnResourceReadySignal09);
3750 // Try to load cached invalid nine patch image. It will request load now.
3751 gImageView1.SetImage(TEST_INVALID_NPATCH_FILE_NAME_01);
3752 gImageView2.SetImage(TEST_INVALID_NPATCH_FILE_NAME_01);
3754 // Destroy all visuals immediatly.
3755 gImageView1.Unparent();
3756 gImageView1.Reset();
3757 gImageView2.Unparent();
3758 gImageView2.Reset();
3761 constexpr int gResourceReadySignal10MaxCounter = 5;
3763 void OnResourceReadySignal10(Control control)
3765 gResourceReadySignalCounter++;
3767 tet_printf("OnResourceReadySignal10 comes!\n");
3768 if(gResourceReadySignalCounter < gResourceReadySignal10MaxCounter)
3770 tet_printf("OnResourceReadySignal10 Set image\n");
3771 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, gImage_34_RGBA);
3772 tet_printf("OnResourceReadySignal10 Set image done\n");
3778 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3780 tet_infoline("Test setting image from within signal handler.");
3782 ToolkitTestApplication application;
3784 gResourceReadySignalCounter = 0;
3786 ImageView imageView = ImageView::New(gImage_34_RGBA);
3787 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal01);
3789 application.GetScene().Add(imageView);
3791 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3793 application.SendNotification();
3794 application.Render();
3796 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3798 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3800 // Create a new ImageView to cache the image
3801 ImageView imageView1 = ImageView::New(gImage_600_RGB);
3802 application.GetScene().Add(imageView1);
3804 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3806 application.SendNotification();
3807 application.Render();
3810 gResourceReadySignalCounter = 0;
3812 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3814 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3816 application.SendNotification();
3817 application.Render();
3819 // Run idle callback
3820 application.RunIdles();
3822 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3824 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3829 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
3831 tet_infoline("Test setting image from within signal handler.");
3833 ToolkitTestApplication application;
3835 gResourceReadySignalCounter = 0;
3837 ImageView imageView = ImageView::New(gImage_34_RGBA);
3838 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal02);
3840 application.GetScene().Add(imageView);
3842 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3844 application.SendNotification();
3845 application.Render();
3847 // Wait for loading an image
3848 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3850 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3852 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3857 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3859 tet_infoline("Test setting image from within signal handler.");
3861 ToolkitTestApplication application;
3863 gResourceReadySignalCounter = 0;
3865 gImageView1 = ImageView::New(gImage_34_RGBA);
3866 application.GetScene().Add(gImageView1);
3869 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3871 gImageView2 = ImageView::New(gImage_600_RGB);
3872 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3873 application.GetScene().Add(gImageView2);
3875 gImageView3 = ImageView::New();
3876 application.GetScene().Add(gImageView3);
3878 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3880 application.SendNotification();
3881 application.Render();
3886 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask01(void)
3888 tet_infoline("Test signal handler when image / mask image is broken.");
3890 ToolkitTestApplication application;
3892 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, const std::string& url, const std::string& mask, const char* location) {
3893 gResourceReadySignalCounter = 0;
3896 map[Toolkit::ImageVisual::Property::URL] = url;
3899 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3901 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3903 ImageView imageView = ImageView::New();
3904 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3905 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3906 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3908 application.GetScene().Add(imageView);
3909 application.SendNotification();
3910 application.Render();
3915 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3917 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3918 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3920 imageView.Unparent();
3923 for(int synchronous = 0; synchronous <= 1; synchronous++)
3925 tet_printf("Test normal case (sync:%d)\n", synchronous);
3926 TestResourceReadyUrl(1, synchronous, gImage_600_RGB, "", TEST_LOCATION);
3927 TestResourceReadyUrl(3, synchronous, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 3 event trigger required : 2 image load + 1 apply mask
3929 tet_printf("Test broken image case (sync:%d)\n", synchronous);
3930 TestResourceReadyUrl(1, synchronous, "invalid.jpg", "", TEST_LOCATION);
3931 TestResourceReadyUrl(2, synchronous, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3933 tet_printf("Test broken mask image case (sync:%d)\n", synchronous);
3934 TestResourceReadyUrl(2, synchronous, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3936 tet_printf("Test broken both image, mask image case (sync:%d)\n", synchronous);
3937 TestResourceReadyUrl(2, synchronous, "invalid.jpg", "invalid.png", TEST_LOCATION);
3943 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask02(void)
3945 tet_infoline("Test signal handler when image try to use cached-and-broken mask image.");
3947 ToolkitTestApplication application;
3949 gResourceReadySignalCounter = 0;
3951 auto TestBrokenMaskResourceReadyUrl = [&application](const std::string& url, const char* location) {
3953 map[Toolkit::ImageVisual::Property::URL] = url;
3954 // Use invalid mask url
3955 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
3957 ImageView imageView = ImageView::New();
3958 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3959 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3960 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3962 application.GetScene().Add(imageView);
3964 // Don't unparent imageView, for keep the cache.
3967 // Use more than 4 images (The number of LocalImageLoadThread)
3968 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};
3970 int expectResourceReadySignalCounter = 0;
3972 for(auto& url : testUrlList)
3974 TestBrokenMaskResourceReadyUrl(url, TEST_LOCATION);
3975 expectResourceReadySignalCounter++;
3978 // Remain 1 signal due to we use #URL + 1 mask image.
3979 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(expectResourceReadySignalCounter + 1), true, TEST_LOCATION);
3980 application.SendNotification();
3981 application.Render();
3982 DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
3987 int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
3989 tet_infoline("Test signal handler various case.");
3991 auto TestResourceReadyUrl = [](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
3992 ToolkitTestApplication application;
3994 gResourceReadySignalCounter = 0;
3997 map[Toolkit::ImageVisual::Property::URL] = url;
4000 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
4002 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
4004 ImageView imageView = ImageView::New();
4005 imageView[Toolkit::ImageView::Property::IMAGE] = map;
4006 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
4007 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4009 application.GetScene().Add(imageView);
4010 application.SendNotification();
4011 application.Render();
4014 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
4016 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
4017 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
4018 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, location);
4020 imageView.Unparent();
4023 auto TestAuxiliaryResourceReadyUrl = [](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
4024 ToolkitTestApplication application;
4026 gResourceReadySignalCounter = 0;
4029 map[Toolkit::ImageVisual::Property::URL] = url;
4030 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE] = auxiliaryUrl;
4031 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA] = 0.5f;
4032 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
4034 ImageView imageView = ImageView::New();
4035 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4036 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4037 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4038 application.GetScene().Add(imageView);
4040 application.SendNotification();
4041 application.Render();
4046 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, location);
4049 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
4050 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
4051 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
4053 imageView.Unparent();
4056 // Case 1 : asynchronous loading
4057 tet_printf("Test invalid single simple image Asynchronous\n");
4060 TestResourceReadyUrl(1, 0, 1, gImage_600_RGB, "", TEST_LOCATION);
4061 TestResourceReadyUrl(2, 0, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // load & rasterize
4062 TestResourceReadyUrl(1, 0, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
4064 TestResourceReadyUrl(2, 0, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // 2 image loading - batch size
4065 TestResourceReadyUrl(2, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // load & rasterize
4067 TestResourceReadyUrl(3, 0, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 2 image loading + 1 applymask
4069 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
4072 TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
4073 TestResourceReadyUrl(1, 0, 0, "invalid.svg", "", TEST_LOCATION);
4074 TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
4075 TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION); // 1 image loading
4076 TestResourceReadyUrl(1, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
4078 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", "invalid.png", TEST_LOCATION); // 2 image loading
4079 TestResourceReadyUrl(2, 0, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); // 2 image loading
4080 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION); // 2 image loading
4082 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
4083 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
4084 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
4086 // Case 2 : Synchronous loading
4087 tet_printf("Test invalid single simple image Synchronous\n");
4090 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "", TEST_LOCATION);
4091 TestResourceReadyUrl(0, 1, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
4092 TestResourceReadyUrl(0, 1, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
4094 TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // first frame image loading sync + second frame image loading async
4096 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION);
4098 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
4101 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
4102 TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION);
4103 TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
4104 TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
4106 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "invalid.png", TEST_LOCATION);
4107 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION);
4108 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
4110 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
4111 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
4112 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
4117 int UtcDaliImageViewSetImageOnResourceReadySignal04(void)
4119 tet_infoline("Test texturemanager's remove queue works well within signal handler.");
4121 ToolkitTestApplication application;
4123 gResourceReadySignalCounter = 0;
4124 gResourceReadySignal04ComesOrder = 0;
4126 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
4127 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal04);
4128 application.GetScene().Add(gImageView1);
4130 gImageView2 = ImageView::New("invalid.png"); // request invalid image, to make loading failed fast.
4131 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal04);
4132 application.GetScene().Add(gImageView2);
4134 application.SendNotification();
4135 application.Render();
4137 tet_infoline("Try to load 2 invalid image");
4139 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4140 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4142 tet_infoline("load done");
4144 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
4145 if(gResourceReadySignal04ComesOrder == -1)
4147 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
4151 // gImageView3 and gImageView4 load must not be successed yet.
4152 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
4153 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
4155 application.SendNotification();
4156 application.Render();
4158 tet_infoline("Try to load 2 valid image");
4160 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4161 DALI_TEST_EQUALS(gResourceReadySignalCounter, 4, TEST_LOCATION);
4163 tet_infoline("load done");
4165 // gImageView3 and gImageView4 load must be successed now.
4166 DALI_TEST_EQUALS(gImageView3.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
4167 DALI_TEST_EQUALS(gImageView4.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
4172 int UtcDaliImageViewSetImageOnResourceReadySignal05(void)
4174 tet_infoline("Test multiple views with same image during ResourceReady load the image only 1 times");
4176 ToolkitTestApplication application;
4178 gResourceReadySignalCounter = 0;
4180 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
4181 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal05);
4182 application.GetScene().Add(gImageView1);
4184 application.SendNotification();
4185 application.Render();
4187 tet_infoline("Try to load 1 invalid.jpg image");
4188 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4189 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4191 tet_infoline("Try to load 1 invalid2.jpg image");
4192 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4194 tet_infoline("Now we don't have any image to be loaded. Check event thread trigger failed.");
4195 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
4197 gImageView1.Unparent();
4198 gImageView1.Reset();
4202 int UtcDaliImageViewSetImageOnResourceReadySignal06(void)
4204 tet_infoline("Test texturemanager's remove image & mask queue works well within signal handler.");
4206 ToolkitTestApplication application;
4208 gResourceReadySignalCounter = 0;
4209 gResourceReadySignal06ComesOrder = 0;
4212 map[Toolkit::ImageVisual::Property::URL] = "invalid.jpg";
4213 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
4215 gImageView1 = ImageView::New(); // request invalid image, to make loading failed fast.
4216 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4217 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal06);
4218 application.GetScene().Add(gImageView1);
4220 gImageView2 = ImageView::New(); // request invalid image, to make loading failed fast.
4221 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4222 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal06);
4223 application.GetScene().Add(gImageView2);
4225 application.SendNotification();
4226 application.Render();
4228 tet_infoline("Try to load 2 invalid image");
4230 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4231 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4233 tet_infoline("load done");
4235 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
4236 if(gResourceReadySignal06ComesOrder == -1)
4238 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
4242 // gImageView3 and gImageView4 load must not be successed yet.
4243 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
4244 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
4246 application.GetScene().Add(gImageView3);
4247 application.GetScene().Add(gImageView4);
4248 application.SendNotification();
4249 application.Render();
4251 tet_infoline("Try to load 2 valid image");
4253 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4254 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4256 tet_infoline("load done");
4261 int UtcDaliImageViewSetImageOnResourceReadySignal07(void)
4263 tet_infoline("Test texturemanager's remove image & mask queue works well within signal handler 02.");
4265 ToolkitTestApplication application;
4267 gResourceReadySignalCounter = 0;
4270 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4272 // Clear image view for clear test
4276 gImageView1.Reset();
4280 gImageView2.Reset();
4283 gImageView1 = ImageView::New();
4284 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4285 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal07);
4286 application.GetScene().Add(gImageView1);
4288 application.SendNotification();
4289 application.Render();
4293 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4294 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4296 tet_infoline("load image1 done");
4298 // Load gImageView2 and mask
4300 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4301 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4303 // gImageView2 mask apply done
4305 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4306 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4308 tet_infoline("load image2 done");
4312 int UtcDaliImageViewSetImageOnResourceReadySignal08(void)
4314 tet_infoline("Test remove npatch images during resource ready");
4316 ToolkitTestApplication application;
4318 gResourceReadySignalCounter = 0;
4321 map[Toolkit::ImageVisual::Property::URL] = TEST_BROKEN_IMAGE_M;
4323 // Clear image view for clear test
4327 gImageView1.Reset();
4331 gImageView2.Reset();
4334 // Case 1 : Remove all images during resource ready.
4337 gImageView1 = ImageView::New();
4338 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4339 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal08);
4340 application.GetScene().Add(gImageView1);
4342 application.SendNotification();
4343 application.Render();
4346 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4347 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4349 application.SendNotification();
4350 application.Render();
4352 DALI_TEST_CHECK(true);
4356 // Exception should not happened
4357 DALI_TEST_CHECK(false);
4361 application.SendNotification();
4362 application.Render();
4364 gResourceReadySignalCounter = 0;
4366 // Case 2 : Remove all images when we use cached resource.
4369 gImageView1 = ImageView::New();
4370 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4371 gImageView1.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4372 application.GetScene().Add(gImageView1);
4374 application.SendNotification();
4375 application.Render();
4378 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4379 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4381 application.SendNotification();
4382 application.Render();
4384 gImageView2 = ImageView::New();
4385 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4386 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal08);
4387 application.GetScene().Add(gImageView2);
4388 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4390 application.SendNotification();
4391 application.Render();
4393 DALI_TEST_CHECK(true);
4397 // Exception should not happened
4398 DALI_TEST_CHECK(false);
4400 gResourceReadySignalCounter = 0;
4402 // Clear image view for clear test
4406 gImageView1.Reset();
4410 gImageView2.Reset();
4416 int UtcDaliImageViewSetImageOnResourceReadySignal09(void)
4418 tet_infoline("Test load invalid npatch images during invalid resource ready");
4420 ToolkitTestApplication application;
4422 gResourceReadySignalCounter = 0;
4425 map[Toolkit::ImageVisual::Property::URL] = TEST_INVALID_NPATCH_FILE_NAME_01;
4427 // Clear image view for clear test
4431 gImageView1.Reset();
4435 gImageView2.Reset();
4439 gImageView3.Reset();
4442 // Dummy view with npatch image
4443 ImageView dummyView = ImageView::New(TEST_BROKEN_IMAGE_M);
4444 application.GetScene().Add(dummyView);
4446 application.SendNotification();
4447 application.Render();
4448 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4449 application.SendNotification();
4450 application.Render();
4452 // Case 1 : Reload images during resource ready.
4455 gResourceReadySignal09Emitted = false;
4457 gImageView1 = ImageView::New();
4458 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4459 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal09);
4460 application.GetScene().Add(gImageView1);
4462 gImageView2 = ImageView::New();
4463 application.GetScene().Add(gImageView2);
4465 // Load TEST_INVALID_NPATCH_FILE_NAME_01
4466 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4468 // Load TEST_INVALID_NPATCH_FILE_NAME_01 one more times.
4469 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4471 application.SendNotification();
4472 application.Render();
4474 DALI_TEST_CHECK(true);
4478 // Exception should not happened
4479 DALI_TEST_CHECK(false);
4483 application.SendNotification();
4484 application.Render();
4486 gResourceReadySignalCounter = 0;
4488 // Case 2 : Remove all images when we use cached resource.
4491 gResourceReadySignal09Emitted = false;
4493 gImageView3 = ImageView::New();
4494 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4495 gImageView3.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4496 application.GetScene().Add(gImageView3);
4498 gImageView2 = ImageView::New();
4499 application.GetScene().Add(gImageView2);
4502 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4504 gImageView1 = ImageView::New();
4505 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4506 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal09);
4507 application.GetScene().Add(gImageView1);
4510 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4512 // Load TEST_INVALID_NPATCH_FILE_NAME_01 one more times.
4513 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4515 application.SendNotification();
4516 application.Render();
4518 DALI_TEST_CHECK(true);
4522 // Exception should not happened
4523 DALI_TEST_CHECK(false);
4525 gResourceReadySignalCounter = 0;
4527 // Clear image view for clear test
4531 gImageView1.Reset();
4535 gImageView2.Reset();
4539 gImageView3.Reset();
4545 int UtcDaliImageViewSetImageOnResourceReadySignal10(void)
4547 tet_infoline("Test ResourceReady signal comes more than 2 times.");
4549 ToolkitTestApplication application;
4551 gResourceReadySignalCounter = 0;
4553 // Clear image view for clear test
4557 gImageView1.Reset();
4560 // Dummy view to cache image.
4561 ImageView dummyView = ImageView::New(gImage_34_RGBA);
4562 application.GetScene().Add(dummyView);
4564 application.SendNotification();
4565 application.Render();
4566 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4567 application.SendNotification();
4568 application.Render();
4572 gImageView1 = ImageView::New();
4573 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, gImage_34_RGBA);
4574 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal10);
4575 application.GetScene().Add(gImageView1); // It will call resourceReady signal 1 time.
4577 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4579 DALI_TEST_GREATER(gResourceReadySignal10MaxCounter, gResourceReadySignalCounter, TEST_LOCATION); // Check whether resource ready call too much.
4581 for(int i = 0; i < gResourceReadySignal10MaxCounter; ++i)
4583 tet_printf("RunIdles\n");
4584 // Executes the idle callbacks.
4585 application.RunIdles();
4586 application.SendNotification();
4587 application.Render();
4588 tet_printf("RunIdles done\n");
4590 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4592 DALI_TEST_EQUALS(gResourceReadySignalCounter, gResourceReadySignal10MaxCounter, TEST_LOCATION);
4594 DALI_TEST_CHECK(true);
4598 // Exception should not happened
4599 DALI_TEST_CHECK(false);
4603 application.SendNotification();
4604 application.Render();
4606 gResourceReadySignalCounter = 0;
4608 gResourceReadySignalCounter = 0;
4610 // Clear image view for clear test
4614 gImageView1.Reset();
4620 int UtcDaliImageViewUseSameUrlWithAnimatedImageVisual(void)
4622 tet_infoline("Test multiple views with same image in animated image visual");
4623 ToolkitTestApplication application;
4625 gImageView1 = ImageView::New(TEST_WEBP_FILE_NAME);
4626 application.GetScene().Add(gImageView1);
4628 tet_infoline("Remove imageView and Create new imageView with same url");
4629 application.GetScene().Remove(gImageView1);
4630 gImageView2 = ImageView::New(TEST_WEBP_FILE_NAME);
4631 application.GetScene().Add(gImageView2);
4633 application.SendNotification();
4634 application.Render();
4636 tet_infoline("Check the ImageView load image successfully");
4637 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4641 int UtcDaliImageViewNpatchImageCacheTest01(void)
4643 tet_infoline("Test npatch image cached");
4645 ToolkitTestApplication application;
4646 ImageView imageView[2];
4648 auto& gl = application.GetGlAbstraction();
4649 gl.EnableTextureCallTrace(true);
4650 auto& textureCallStack = gl.GetTextureTrace();
4651 textureCallStack.Enable(true);
4652 textureCallStack.EnableLogging(true);
4654 auto TestNPatch = [&](int index, const std::string& nPatchImageUrl, const char* location) {
4655 if(imageView[index])
4657 imageView[index].Unparent();
4660 // Ensure remove npatch cache if required.
4661 application.SendNotification();
4662 application.Render();
4664 imageView[index] = ImageView::New(nPatchImageUrl);
4665 imageView[index].SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4666 application.GetScene().Add(imageView[index]);
4669 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4670 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4672 application.SendNotification();
4673 application.Render();
4675 tet_printf("trace : \n%s\n", textureCallStack.GetTraceString().c_str());
4677 // Check we gen only 1 textures
4678 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 1, TEST_LOCATION);
4679 textureCallStack.Reset();
4681 // Let we use cached textures
4682 for(int i = 0; i < 10; i++)
4684 TestNPatch(1, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4685 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4688 application.SendNotification();
4689 application.Render();
4690 // Check we use cached npatch data so we don't generate new texture textures
4691 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 0, TEST_LOCATION);
4694 imageView[0].Unparent();
4695 imageView[0].Reset();
4696 imageView[1].Unparent();
4697 imageView[1].Reset();
4699 application.SendNotification();
4700 application.Render();
4702 textureCallStack.Reset();
4703 // Let we use deference textures
4704 TestNPatch(1, TEST_BROKEN_IMAGE_S, TEST_LOCATION);
4705 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4707 application.SendNotification();
4708 application.Render();
4709 // Try to load multiple times.
4710 for(int i = 0; i < 3; i++)
4712 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4713 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4714 TestNPatch(1, TEST_BROKEN_IMAGE_S, TEST_LOCATION);
4715 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4717 application.SendNotification();
4718 application.Render();
4720 imageView[0].Unparent();
4721 imageView[0].Reset();
4722 imageView[1].Unparent();
4723 imageView[1].Reset();
4725 application.SendNotification();
4726 application.Render();
4728 // Check memory leak
4729 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), textureCallStack.CountMethod("DeleteTextures"), TEST_LOCATION);
4734 int UtcDaliImageViewNpatchImageCacheTest02(void)
4736 tet_infoline("Test npatch image cached with border");
4738 ToolkitTestApplication application;
4739 ImageView imageView[2];
4741 auto& gl = application.GetGlAbstraction();
4742 gl.EnableTextureCallTrace(true);
4743 auto& textureCallStack = gl.GetTextureTrace();
4744 textureCallStack.Enable(true);
4745 textureCallStack.EnableLogging(true);
4747 auto TestBorderImage = [&](int index, const std::string& normalImageUrl, const Rect<int> border, const char* location) {
4749 map[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::N_PATCH;
4750 map[Toolkit::ImageVisual::Property::URL] = normalImageUrl;
4751 map[Toolkit::ImageVisual::Property::BORDER] = border;
4753 imageView[index] = ImageView::New();
4754 imageView[index].SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4755 imageView[index].SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4756 application.GetScene().Add(imageView[index]);
4759 TestBorderImage(0, gImage_34_RGBA, Rect<int>(0, 0, 0, 0), TEST_LOCATION);
4760 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4762 application.SendNotification();
4763 application.Render();
4765 tet_printf("trace : \n%s\n", textureCallStack.GetTraceString().c_str());
4767 // Check we gen only 1 textures
4768 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 1, TEST_LOCATION);
4769 textureCallStack.Reset();
4771 // Let we use cached textures
4772 for(int i = 0; i < 10; i++)
4774 TestBorderImage(0, gImage_34_RGBA, Rect<int>(i, i + 1, i + 2, i + 3), TEST_LOCATION);
4775 TestBorderImage(1, gImage_34_RGBA, Rect<int>(i + 1, i, i + 3, i + 2), TEST_LOCATION);
4778 application.SendNotification();
4779 application.Render();
4781 // Check we use cached npatch data so we don't generate new texture textures
4782 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 0, TEST_LOCATION);
4787 int UtcDaliImageViewPlaceholderImage01(void)
4789 tet_infoline("Test imageView use placeholder image");
4791 ToolkitTestApplication application;
4793 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4795 ImageView imageView = ImageView::New();
4796 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4797 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4798 application.GetScene().Add(imageView);
4800 Property::Value value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4802 DALI_TEST_CHECK(value.Get(url));
4803 DALI_TEST_CHECK(url.empty());
4804 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4806 application.SendNotification();
4807 application.Render();
4809 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4810 DALI_TEST_CHECK(value.Get(url));
4811 DALI_TEST_CHECK(url == gImage_34_RGBA);
4813 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4814 application.SendNotification();
4815 application.Render();
4817 // Replace Image test
4818 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4819 map[ImageView::Property::PLACEHOLDER_IMAGE] = gImage_34_RGBA;
4820 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4821 application.SendNotification();
4822 application.Render();
4824 map[Toolkit::ImageVisual::Property::URL] = "";
4825 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4826 application.SendNotification();
4827 application.Render();
4829 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
4830 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4831 application.SendNotification();
4832 application.Render();
4834 // Replace Image test2
4835 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4836 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4837 application.SendNotification();
4838 application.Render();
4840 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
4841 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4842 application.SendNotification();
4843 application.Render();
4845 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4846 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4847 application.SendNotification();
4848 application.Render(900);
4850 map[Toolkit::ImageVisual::Property::URL] = "";
4851 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4852 application.SendNotification();
4853 application.Render();
4855 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4856 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4857 application.SendNotification();
4858 application.Render();
4863 int UtcDaliImageViewPlaceholderImage02(void)
4865 tet_infoline("Test imageView use placeholder image without resource ready");
4867 ToolkitTestApplication application;
4870 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4872 ImageView imageView = ImageView::New();
4873 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4874 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4875 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
4876 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
4877 application.GetScene().Add(imageView);
4879 Property::Value value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4881 DALI_TEST_CHECK(value.Get(url));
4882 DALI_TEST_CHECK(url.empty());
4884 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4885 application.SendNotification();
4886 application.Render();
4888 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4890 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4891 DALI_TEST_CHECK(value.Get(url));
4892 DALI_TEST_CHECK(url == gImage_34_RGBA);
4894 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
4895 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
4897 gResourceReadySignalFired = false;
4898 map[Toolkit::ImageVisual::Property::URL] = "";
4899 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4900 application.SendNotification();
4901 application.Render();
4903 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
4904 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
4909 int UtcDaliImageViewTransitionEffect01(void)
4911 tet_infoline("Test imageView use transition effect");
4913 ToolkitTestApplication application;
4915 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4916 map[Toolkit::Visual::Property::OPACITY] = 0.9f;
4918 ImageView imageView = ImageView::New();
4919 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4920 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4921 application.GetScene().Add(imageView);
4923 Property::Value value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
4925 DALI_TEST_CHECK(value.Get(transition));
4926 DALI_TEST_CHECK(transition == false);
4927 imageView.SetProperty(Toolkit::ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
4929 application.SendNotification();
4930 application.Render();
4932 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
4933 DALI_TEST_CHECK(value.Get(transition));
4934 DALI_TEST_CHECK(transition == true);
4936 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4937 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4938 application.SendNotification();
4939 application.Render();
4941 // Test transition effect with placeholder
4942 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4943 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4944 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4945 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4946 application.SendNotification();
4947 application.Render();
4949 map[Toolkit::ImageVisual::Property::URL] = "";
4950 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4951 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4952 application.SendNotification();
4953 application.Render();
4955 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4956 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4957 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4958 application.SendNotification();
4959 application.Render();
4961 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4962 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4963 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4964 application.SendNotification();
4966 map[Toolkit::ImageVisual::Property::URL] = "";
4967 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4968 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4969 application.SendNotification();
4970 application.Render();
4972 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4973 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4974 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, "");
4975 application.SendNotification();
4976 application.Render();
4978 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4979 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4980 application.SendNotification();
4981 application.Render();
4983 map[Toolkit::ImageVisual::Property::URL] = "";
4984 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4985 application.SendNotification();
4986 application.Render();
4988 // Test transition effect without placeholder
4989 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4990 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
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 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5005 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5006 application.SendNotification();
5007 application.Render();
5009 imageView.SetImage(TEST_IMAGE_1);
5010 application.SendNotification();
5011 application.Render();
5013 imageView.SetImage(gImage_600_RGB);
5014 application.SendNotification();
5015 application.Render(9000);
5017 imageView.SetImage("");
5018 application.SendNotification();
5019 application.Render();
5021 imageView.SetImage(TEST_IMAGE_1);
5022 application.SendNotification();
5023 application.Render();
5026 imageView.Unparent();
5032 int UtcDaliImageViewTransitionEffect02(void)
5034 tet_infoline("Test imageView use transition effect with replace image");
5036 ToolkitTestApplication application;
5040 ImageView imageView = ImageView::New();
5041 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5042 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5043 application.GetScene().Add(imageView);
5045 Property::Value value;
5046 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5048 DALI_TEST_CHECK(value.Get(transition));
5049 DALI_TEST_CHECK(transition == false);
5050 imageView.SetProperty(Toolkit::ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
5052 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5054 DALI_TEST_CHECK(value.Get(url));
5055 DALI_TEST_CHECK(url.empty());
5056 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5057 application.SendNotification();
5058 application.Render();
5060 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, "");
5061 application.SendNotification();
5062 application.Render();
5064 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5065 application.SendNotification();
5066 application.Render();
5068 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5069 DALI_TEST_CHECK(value.Get(transition));
5070 DALI_TEST_CHECK(transition == true);
5072 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5073 DALI_TEST_CHECK(value.Get(url));
5074 DALI_TEST_CHECK(url == gImage_34_RGBA);
5076 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5077 application.SendNotification();
5078 application.Render();
5081 imageView.Unparent();
5087 int UtcDaliImageViewTransitionEffect03(void)
5089 tet_infoline("Test imageView use transition effect with placeholder");
5091 ToolkitTestApplication application;
5094 ImageView imageView = ImageView::New();
5095 imageView.SetImage("");
5096 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5097 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5098 imageView.SetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
5099 application.GetScene().Add(imageView);
5101 //DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5103 application.SendNotification();
5104 application.Render(16);
5106 tet_infoline("(1)");
5107 imageView.SetImage(gImage_600_RGB);
5108 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5109 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
5110 application.SendNotification();
5111 application.Render(16);
5113 Property::Value value;
5114 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5116 DALI_TEST_CHECK(value.Get(transition));
5117 DALI_TEST_CHECK(transition == true);
5119 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5121 DALI_TEST_CHECK(value.Get(url));
5122 DALI_TEST_CHECK(url == gImage_34_RGBA);
5124 imageView.SetImage("");
5125 application.SendNotification();
5126 application.Render(16);
5128 imageView.SetImage(TEST_IMAGE_1);
5129 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5130 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5131 application.SendNotification();
5132 application.Render(16);
5135 imageView.Unparent();