2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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 // resolution: 34*34, pixel format: RGBA8888
75 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
76 // resolution: 600*600, pixel format: RGB888
77 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
79 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
80 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
82 const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
83 const char* TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
85 const char* TEST_WEBP_FILE_NAME = TEST_RESOURCE_DIR "/dali-logo.webp";
87 void TestUrl(ImageView imageView, const std::string url)
89 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
91 std::string urlActual;
92 DALI_TEST_CHECK(value.Get(urlActual));
93 DALI_TEST_EQUALS(urlActual, url, TEST_LOCATION);
98 int UtcDaliImageViewNewP(void)
100 ToolkitTestApplication application;
102 ImageView imageView = ImageView::New();
104 DALI_TEST_CHECK(imageView);
109 int UtcDaliImageViewNewUrlP(void)
111 ToolkitTestApplication application;
113 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
114 DALI_TEST_CHECK(imageView);
116 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
121 int UtcDaliImageViewConstructorP(void)
123 ToolkitTestApplication application;
127 DALI_TEST_CHECK(!imageView);
132 int UtcDaliImageViewCopyConstructorP(void)
134 ToolkitTestApplication application;
136 // Initialize an object, ref count == 1
137 ImageView imageView = ImageView::New();
139 ImageView copy(imageView);
140 DALI_TEST_CHECK(copy);
145 int UtcDaliImageViewMoveConstructor(void)
147 ToolkitTestApplication application;
149 ImageView imageView = ImageView::New();
150 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
151 imageView.SetProperty(Actor::Property::SENSITIVE, false);
152 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
154 ImageView moved = std::move(imageView);
155 DALI_TEST_CHECK(moved);
156 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
157 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
158 DALI_TEST_CHECK(!imageView);
163 int UtcDaliImageViewAssignmentOperatorP(void)
165 ToolkitTestApplication application;
167 ImageView imageView = ImageView::New();
169 ImageView copy(imageView);
170 DALI_TEST_CHECK(copy);
171 DALI_TEST_EQUALS(imageView, copy, TEST_LOCATION);
176 int UtcDaliImageViewMoveAssignment(void)
178 ToolkitTestApplication application;
180 ImageView imageView = ImageView::New();
181 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
182 imageView.SetProperty(Actor::Property::SENSITIVE, false);
183 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
186 moved = std::move(imageView);
187 DALI_TEST_CHECK(moved);
188 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
189 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
190 DALI_TEST_CHECK(!imageView);
195 int UtcDaliImageViewDownCastP(void)
197 ToolkitTestApplication application;
199 ImageView imageView = ImageView::New();
201 BaseHandle object(imageView);
203 ImageView imageView2 = ImageView::DownCast(object);
204 DALI_TEST_CHECK(imageView2);
206 ImageView imageView3 = DownCast<ImageView>(object);
207 DALI_TEST_CHECK(imageView3);
212 int UtcDaliImageViewDownCastN(void)
214 ToolkitTestApplication application;
216 BaseHandle unInitializedObject;
218 ImageView imageView1 = ImageView::DownCast(unInitializedObject);
219 DALI_TEST_CHECK(!imageView1);
221 ImageView imageView2 = DownCast<ImageView>(unInitializedObject);
222 DALI_TEST_CHECK(!imageView2);
227 int UtcDaliImageViewTypeRegistry(void)
229 ToolkitTestApplication application;
231 TypeRegistry typeRegistry = TypeRegistry::Get();
232 DALI_TEST_CHECK(typeRegistry);
234 TypeInfo typeInfo = typeRegistry.GetTypeInfo("ImageView");
235 DALI_TEST_CHECK(typeInfo);
237 BaseHandle handle = typeInfo.CreateInstance();
238 DALI_TEST_CHECK(handle);
240 ImageView imageView = ImageView::DownCast(handle);
241 DALI_TEST_CHECK(imageView);
246 int UtcDaliImageViewSetGetProperty01(void)
248 ToolkitTestApplication application;
250 ImageView imageView = ImageView::New();
252 Property::Index idx = imageView.GetPropertyIndex("image");
253 DALI_TEST_EQUALS(idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION);
255 imageView.SetProperty(idx, TEST_IMAGE_FILE_NAME);
256 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
261 int UtcDaliImageViewPreMultipliedAlphaPng(void)
263 ToolkitTestApplication application;
265 // Set up trace debug
266 TestGlAbstraction& gl = application.GetGlAbstraction();
267 TraceCallStack& textureTrace = gl.GetTextureTrace();
268 textureTrace.Enable(true);
270 Property::Map imageMap;
271 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
272 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
274 ImageView imageView1 = ImageView::New();
275 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
277 application.GetScene().Add(imageView1);
279 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
281 DALI_TEST_CHECK(value.Get(enable));
282 DALI_TEST_CHECK(enable); // Default value is true
284 // loading started, this waits for the loader thread for max 30 seconds
285 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
287 application.SendNotification();
288 application.Render();
290 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
291 DALI_TEST_CHECK(value.Get(enable));
292 DALI_TEST_CHECK(enable); // Keep true
294 // conventional alpha blending
295 Renderer renderer1 = imageView1.GetRendererAt(0);
296 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
297 DALI_TEST_CHECK(value.Get(enable));
298 DALI_TEST_CHECK(enable);
300 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
301 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
302 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
303 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
304 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
305 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
306 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
307 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
309 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
310 textureTrace.Reset();
312 // Disable pre-multiplied alpha blending
313 imageView1.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
316 Property::Map attributes;
317 DevelControl::DoAction(imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
319 // loading started, this waits for the loader thread for max 30 seconds
320 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
322 application.SendNotification();
323 application.Render();
325 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
326 DALI_TEST_CHECK(value.Get(enable));
327 DALI_TEST_CHECK(!enable);
329 // conventional alpha blending
330 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
331 DALI_TEST_CHECK(value.Get(enable));
332 DALI_TEST_CHECK(!enable);
334 srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
335 destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
336 srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
337 destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
338 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
339 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
340 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
341 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
343 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
344 textureTrace.Reset();
346 // Make a new ImageView using the same image
347 ImageView imageView2 = ImageView::New();
348 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
350 application.GetScene().Add(imageView2);
352 application.SendNotification();
353 application.Render();
355 Renderer renderer2 = imageView2.GetRendererAt(0);
356 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
357 DALI_TEST_CHECK(value.Get(enable));
358 DALI_TEST_CHECK(enable);
360 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
361 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
362 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
363 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
364 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
365 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
366 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
367 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
369 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
374 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
376 ToolkitTestApplication application;
378 // Set up trace debug
379 TestGlAbstraction& gl = application.GetGlAbstraction();
380 TraceCallStack& textureTrace = gl.GetTextureTrace();
381 textureTrace.Enable(true);
383 Property::Map imageMap;
384 imageMap[ImageVisual::Property::URL] = gImage_600_RGB;
385 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
387 ImageView imageView1 = ImageView::New();
388 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
390 application.GetScene().Add(imageView1);
392 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
394 DALI_TEST_CHECK(value.Get(enable));
395 DALI_TEST_CHECK(enable); // Default value is true
397 // loading started, this waits for the loader thread for max 30 seconds
398 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
400 application.SendNotification();
401 application.Render();
403 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
404 DALI_TEST_CHECK(value.Get(enable));
405 DALI_TEST_CHECK(!enable); // Should be false after loading
407 // conventional alpha blending
408 Renderer renderer1 = imageView1.GetRendererAt(0);
409 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
410 DALI_TEST_CHECK(value.Get(enable));
411 DALI_TEST_CHECK(!enable);
413 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
414 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
415 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
416 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
417 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
418 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
419 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
420 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
422 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
423 textureTrace.Reset();
425 ImageView imageView2 = ImageView::New();
426 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
428 // Disable pre-multiplied alpha blending
429 imageView2.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
431 application.GetScene().Add(imageView2);
433 application.SendNotification();
434 application.Render();
436 value = imageView2.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
437 DALI_TEST_CHECK(value.Get(enable));
438 DALI_TEST_CHECK(!enable);
440 // conventional alpha blending
441 Renderer renderer2 = imageView2.GetRendererAt(0);
442 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
443 DALI_TEST_CHECK(value.Get(enable));
444 DALI_TEST_CHECK(!enable);
446 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
447 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
448 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
449 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
450 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
451 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
452 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
453 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
455 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
460 int UtcDaliImageViewPixelArea(void)
462 // Test pixel area property
463 ToolkitTestApplication application;
465 static std::vector<UniformData> customUniforms =
467 UniformData("pixelArea", Property::Type::VECTOR4),
470 TestGraphicsController& graphics = application.GetGraphicsController();
471 graphics.AddCustomUniforms(customUniforms);
473 // Gif image, use AnimatedImageVisual internally
474 // Atlasing is applied to pack multiple frames, use custom wrap mode
475 ImageView gifView = ImageView::New();
476 const Vector4 pixelAreaVisual(0.f, 0.f, 2.f, 2.f);
477 gifView.SetProperty(ImageView::Property::IMAGE,
478 Property::Map().Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME).Add(ImageVisual::Property::PIXEL_AREA, pixelAreaVisual));
481 Integration::Scene stage = application.GetScene();
485 application.SendNotification();
486 application.Render(16);
488 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
490 application.SendNotification();
491 application.Render();
492 DALI_TEST_CHECK(gifView.GetRendererCount() == 1u);
494 const Vector4 fullTextureRect(0.f, 0.f, 1.f, 1.f);
495 // test that the pixel area value defined in the visual property map is registered on renderer
496 Renderer renderer = gifView.GetRendererAt(0);
497 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
498 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION);
500 // test that the shader has the default pixel area value registered.
501 Shader shader = renderer.GetShader();
502 pixelAreaValue = shader.GetProperty(shader.GetPropertyIndex("pixelArea"));
503 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION);
505 // test that the uniform uses the pixelArea property on the renderer.
506 TestGlAbstraction& gl = application.GetGlAbstraction();
507 Vector4 pixelAreaUniform;
508 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
509 DALI_TEST_EQUALS(pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
511 // set the pixelArea property on the control
512 const Vector4 pixelAreaControl(-1.f, -1.f, 3.f, 3.f);
513 gifView.SetProperty(ImageView::Property::PIXEL_AREA, pixelAreaControl);
514 application.SendNotification();
515 application.Render(16);
517 // check the pixelArea property on the control
518 pixelAreaValue = gifView.GetProperty(gifView.GetPropertyIndex("pixelArea"));
519 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION);
520 // test that the uniform uses the pixelArea property on the control.
521 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
522 DALI_TEST_EQUALS(pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
527 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
529 ToolkitTestApplication application;
530 TestGlAbstraction& gl = application.GetGlAbstraction();
531 const std::vector<GLuint>& textures = gl.GetBoundTextures();
532 size_t numTextures = textures.size();
534 // Async loading, no atlasing for big size image
535 ImageView imageView = ImageView::New(gImage_600_RGB);
537 // By default, Aysnc loading is used
538 application.GetScene().Add(imageView);
539 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
540 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
542 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
544 application.SendNotification();
545 application.Render(16);
546 application.SendNotification();
548 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
549 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
554 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
556 ToolkitTestApplication application;
558 //Async loading, automatic atlasing for small size image
559 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
561 callStack.Enable(true);
563 Property::Map imageMap;
565 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
566 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
567 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
568 imageMap[ImageVisual::Property::ATLASING] = true;
570 ImageView imageView = ImageView::New();
571 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
572 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
574 // By default, Aysnc loading is used
575 // loading is not started if the actor is offScene
577 application.GetScene().Add(imageView);
578 application.SendNotification();
579 application.Render(16);
580 application.Render(16);
581 application.SendNotification();
583 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
584 application.SendNotification();
585 application.Render(16);
586 application.Render(16);
587 application.SendNotification();
589 // loading started, this waits for the loader thread for max 30 seconds
590 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
592 application.SendNotification();
593 application.Render(16);
595 callStack.Enable(false);
597 TraceCallStack::NamedParams params;
598 params["width"] << 34;
599 params["height"] << 34;
600 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
605 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
607 ToolkitTestApplication application;
609 //Async loading, automatic atlasing for small size image
610 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
612 callStack.Enable(true);
614 Property::Map asyncLoadingMap;
615 asyncLoadingMap["url"] = gImage_34_RGBA;
616 asyncLoadingMap["desiredHeight"] = 34;
617 asyncLoadingMap["desiredWidth"] = 34;
618 asyncLoadingMap["synchronousLoading"] = false;
619 asyncLoadingMap["atlasing"] = true;
621 ImageView imageView = ImageView::New();
622 imageView.SetProperty(ImageView::Property::IMAGE, asyncLoadingMap);
624 application.GetScene().Add(imageView);
625 application.SendNotification();
626 application.Render(16);
627 application.Render(16);
628 application.SendNotification();
630 // loading started, this waits for the loader thread for max 30 seconds
631 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
633 application.SendNotification();
634 application.Render(16);
636 callStack.Enable(false);
638 TraceCallStack::NamedParams params;
639 params["width"] << 34;
640 params["height"] << 34;
641 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
646 int UtcDaliImageViewSyncLoading(void)
648 ToolkitTestApplication application;
650 tet_infoline("ImageView Testing sync loading and size using index key property map");
652 Property::Map syncLoadingMap;
653 syncLoadingMap[ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
654 syncLoadingMap[ImageVisual::Property::ATLASING] = true;
656 // Sync loading, no atlasing for big size image
658 ImageView imageView = ImageView::New();
660 // Sync loading is used
661 syncLoadingMap[ImageVisual::Property::URL] = gImage_600_RGB;
662 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
665 // Sync loading, automatic atlasing for small size image
667 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
669 callStack.Enable(true);
671 ImageView imageView = ImageView::New();
673 // Sync loading is used
674 syncLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
675 syncLoadingMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
676 syncLoadingMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
677 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
679 application.GetScene().Add(imageView);
680 application.SendNotification();
681 application.Render(16);
683 TraceCallStack::NamedParams params;
684 params["width"] << 34;
685 params["height"] << 34;
686 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
693 int UtcDaliImageViewSyncLoading02(void)
695 ToolkitTestApplication application;
697 tet_infoline("ImageView Testing sync loading and size using string key property map");
699 // Sync loading, automatic atlasing for small size image
701 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
703 callStack.Enable(true);
705 ImageView imageView = ImageView::New();
707 // Sync loading is used
708 Property::Map syncLoadingMap;
709 syncLoadingMap["url"] = gImage_34_RGBA;
710 syncLoadingMap["desiredHeight"] = 34;
711 syncLoadingMap["desiredWidth"] = 34;
712 syncLoadingMap["synchronousLoading"] = true;
713 syncLoadingMap["atlasing"] = true;
714 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
716 application.GetScene().Add(imageView);
717 application.SendNotification();
718 application.Render(16);
720 TraceCallStack::NamedParams params;
721 params["width"] << 34;
722 params["height"] << 34;
723 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
730 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
732 ToolkitTestApplication application;
733 TestGlAbstraction& gl = application.GetGlAbstraction();
734 const std::vector<GLuint>& textures = gl.GetBoundTextures();
735 size_t numTextures = textures.size();
737 // Get encoded raw-buffer image and generate url
738 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
739 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
741 // Async loading, no atlasing for big size image
742 ImageView imageView = ImageView::New(url.GetUrl());
744 // By default, Aysnc loading is used
745 application.GetScene().Add(imageView);
746 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
747 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
749 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
751 application.SendNotification();
752 application.Render(16);
753 application.SendNotification();
755 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
756 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
761 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
763 ToolkitTestApplication application;
765 // Get encoded raw-buffer image and generate url
766 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
767 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
768 ImageUrl url2 = Toolkit::Image::GenerateUrl(buffer);
770 // Generate url is not equal to url2
771 // NOTE : This behavior may changed when ImageUrl compare operator changed.
772 DALI_TEST_CHECK(url != url2);
773 // Generate url's string is equal to url2's string
774 DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
776 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
777 url2 = Toolkit::Image::GenerateUrl(buffer2);
779 // Check whethere two url are not equal
780 DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
782 // Async loading, automatic atlasing for small size image
783 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
785 callStack.Enable(true);
787 Property::Map imageMap;
789 imageMap[ImageVisual::Property::URL] = url.GetUrl();
790 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 600;
791 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 600;
792 imageMap[ImageVisual::Property::ATLASING] = true;
794 // No atlasing with big image
795 ImageView imageView_bigdesired = ImageView::New();
796 imageView_bigdesired.SetProperty(ImageView::Property::IMAGE, imageMap);
797 imageView_bigdesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
799 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 0;
800 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 0;
802 // No atlasing with zero desired size
803 ImageView imageView_nodesired = ImageView::New();
804 imageView_nodesired.SetProperty(ImageView::Property::IMAGE, imageMap);
805 imageView_nodesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
807 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
808 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
810 ImageView imageView = ImageView::New();
811 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
812 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
814 // By default, Aysnc loading is used
815 // loading is not started if the actor is offScene
816 application.GetScene().Add(imageView);
817 application.GetScene().Add(imageView_bigdesired);
818 application.GetScene().Add(imageView_nodesired);
819 application.SendNotification();
820 application.Render(16);
822 // loading started, this waits for the loader thread for max 30 seconds
823 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
825 application.Render(16);
826 application.SendNotification();
828 // Change url to url2
829 imageMap[ImageVisual::Property::URL] = url2.GetUrl();
830 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
832 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
833 application.SendNotification();
834 application.Render(16);
835 application.Render(16);
836 application.SendNotification();
838 // loading started, this waits for the loader thread for max 30 seconds
839 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
841 application.SendNotification();
842 application.Render(16);
844 callStack.Enable(false);
846 TraceCallStack::NamedParams params;
847 params["width"] << 34;
848 params["height"] << 34;
849 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
854 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
856 ToolkitTestApplication application;
858 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
860 // Get encoded raw-buffer image and generate url
861 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
862 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
864 // Sync loading, automatic atlasing for small size image
866 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
868 callStack.Enable(true);
870 ImageView imageView = ImageView::New();
872 // Sync loading is used
873 Property::Map syncLoadingMap;
874 syncLoadingMap["url"] = url.GetUrl();
875 syncLoadingMap["alphaMaskUrl"] = gImage_34_RGBA;
876 syncLoadingMap["desiredHeight"] = 34;
877 syncLoadingMap["desiredWidth"] = 34;
878 syncLoadingMap["synchronousLoading"] = true;
879 syncLoadingMap["atlasing"] = true;
880 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
882 application.GetScene().Add(imageView);
883 application.SendNotification();
884 application.Render(16);
886 TraceCallStack::NamedParams params;
887 params["width"] << 34;
888 params["height"] << 34;
889 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
897 int UtcDaliImageViewAddedTexture(void)
899 ToolkitTestApplication application;
901 tet_infoline("ImageView Testing image view with texture provided manager url");
903 ImageView imageView = ImageView::New();
905 // empty texture is ok, though pointless from app point of view
907 std::string url = TextureManager::AddTexture(empty);
908 DALI_TEST_CHECK(url.size() > 0u);
910 Property::Map propertyMap;
911 propertyMap[ImageVisual::Property::URL] = url;
912 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
914 application.GetScene().Add(imageView);
915 application.SendNotification();
916 application.Render();
921 int UtcDaliImageViewSizeWithBackground(void)
923 ToolkitTestApplication application;
927 ImageView imageView = ImageView::New();
929 imageView.SetProperty(Control::Property::BACKGROUND,
931 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
932 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
933 {ImageVisual::Property::DESIRED_WIDTH, width},
934 {ImageVisual::Property::DESIRED_HEIGHT, height},
937 application.GetScene().Add(imageView);
938 application.SendNotification();
939 application.Render();
941 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
942 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
947 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
949 ToolkitTestApplication application;
951 int widthBackground = 100;
952 int heightBackground = 200;
956 ImageView imageView = ImageView::New();
958 imageView.SetProperty(Control::Property::BACKGROUND,
960 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
961 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
962 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
963 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground},
966 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio, 600x600 pixels
968 application.GetScene().Add(imageView);
969 application.SendNotification();
970 application.Render();
972 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
973 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
978 int UtcDaliImageViewHeightForWidthBackground(void)
980 ToolkitTestApplication application;
982 int widthBackground = 100;
983 int heightBackground = 200;
985 ImageView imageView = ImageView::New();
987 imageView.SetProperty(Control::Property::BACKGROUND,
988 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
989 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
990 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
991 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}});
993 application.GetScene().Add(imageView);
994 application.SendNotification();
995 application.Render();
997 Control control = Control::DownCast(imageView);
998 DALI_TEST_CHECK(control);
999 DALI_TEST_EQUALS(imageView.GetHeightForWidth(123.f), control.GetHeightForWidth(123.f), TEST_LOCATION);
1000 DALI_TEST_EQUALS(imageView.GetWidthForHeight(321.f), control.GetWidthForHeight(321.f), TEST_LOCATION);
1005 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
1007 ToolkitTestApplication application;
1009 int widthBackground = 100;
1010 int heightBackground = 200;
1014 ImageView imageView = ImageView::New();
1016 imageView.SetProperty(Control::Property::BACKGROUND,
1017 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1018 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1019 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1020 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}}); // 1 to 2 ratio
1022 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio
1024 application.GetScene().Add(imageView);
1025 application.SendNotification();
1026 application.Render();
1028 DALI_TEST_EQUALS(imageView.GetHeightForWidth(width), (float)height, TEST_LOCATION);
1029 DALI_TEST_EQUALS(imageView.GetWidthForHeight(height), (float)width, TEST_LOCATION);
1034 int UtcDaliImageViewSetImageUrl(void)
1036 ToolkitTestApplication application;
1038 ImageView imageView = ImageView::New();
1039 imageView.SetImage(TEST_IMAGE_FILE_NAME);
1040 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
1042 imageView.SetImage(TEST_IMAGE_FILE_NAME2);
1043 TestUrl(imageView, TEST_IMAGE_FILE_NAME2);
1048 bool gResourceReadySignalFired = false;
1049 Vector3 gNaturalSize;
1051 void ResourceReadySignal(Control control)
1053 gResourceReadySignalFired = true;
1056 int UtcDaliImageViewCheckResourceReady(void)
1058 ToolkitTestApplication application;
1060 gResourceReadySignalFired = false;
1062 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1063 ImageView imageView = ImageView::New(TEST_GIF_FILE_NAME);
1065 imageView.SetProperty(Control::Property::BACKGROUND,
1066 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1067 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1068 {ImageVisual::Property::DESIRED_WIDTH, 100},
1069 {ImageVisual::Property::DESIRED_HEIGHT, 200}});
1071 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1073 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1075 application.GetScene().Add(imageView);
1077 // loading started, this waits for the loader thread
1078 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1080 application.SendNotification();
1081 application.Render(16);
1083 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1085 application.SendNotification();
1086 application.Render();
1088 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1090 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1095 int UtcDaliImageViewSetImageTypeChangesP(void)
1097 ToolkitTestApplication application;
1099 ImageView imageView = ImageView::New();
1100 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1102 application.GetScene().Add(imageView);
1106 Toolkit::Visual::Base visual;
1108 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1109 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1111 application.SendNotification();
1112 application.Render(16);
1114 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1116 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1117 DALI_TEST_CHECK(!visual); // Visual should be invalid
1120 imageView.SetImage("TEST_URL");
1122 application.SendNotification();
1123 application.Render(16);
1125 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1126 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1128 DALI_TEST_CHECK(value.Get(url)); // Value should NOT be empty
1129 DALI_TEST_CHECK(!value.Get(map)); // Value should be empty
1130 DALI_TEST_CHECK(visual); // Visual should be valid
1133 imageView.SetImage("");
1135 application.SendNotification();
1136 application.Render(16);
1138 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1139 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1141 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1143 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1144 DALI_TEST_CHECK(!visual); // Visual should be invalid
1146 // Set a URL in property map
1147 Property::Map propertyMap;
1148 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1149 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1151 application.SendNotification();
1152 application.Render(16);
1154 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1155 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1157 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1158 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1159 DALI_TEST_CHECK(visual); // Visual should be valid
1161 // Set a URL in property map again
1162 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1163 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1165 application.SendNotification();
1166 application.Render(16);
1168 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1169 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1171 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1172 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1173 DALI_TEST_CHECK(visual); // Visual should be valid
1175 // Set an empty URL in property map
1176 propertyMap[ImageVisual::Property::URL] = std::string();
1177 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1179 application.SendNotification();
1180 application.Render(16);
1182 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1183 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1185 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1186 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1187 DALI_TEST_CHECK(!visual); // Visual should be invalid
1189 // Set a URL in property map again
1190 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1191 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1193 application.SendNotification();
1194 application.Render(16);
1196 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1197 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1199 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1200 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1201 DALI_TEST_CHECK(visual); // Visual should be valid
1203 // Set an empty property map
1204 propertyMap.Clear();
1205 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1207 application.SendNotification();
1208 application.Render(16);
1210 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1211 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1213 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1214 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1215 DALI_TEST_CHECK(map.Empty()); // But PropertyMap should be empty
1216 DALI_TEST_CHECK(!visual); // Visual should be invalid
1221 int UtcDaliImageViewResourceUrlP(void)
1223 ToolkitTestApplication application;
1225 ImageView imageView = ImageView::New();
1226 DALI_TEST_CHECK(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>().empty());
1228 imageView.SetProperty(ImageView::Property::IMAGE, "TestString");
1229 DALI_TEST_EQUALS(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>(), "TestString", TEST_LOCATION);
1234 int UtcDaliImageViewReplaceImage(void)
1236 ToolkitTestApplication application;
1238 gResourceReadySignalFired = false;
1240 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1241 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1243 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1245 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1247 application.GetScene().Add(imageView);
1249 application.SendNotification();
1250 application.Render(16);
1252 // loading started, this waits for the loader thread for max 30 seconds
1253 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1255 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1257 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1259 gResourceReadySignalFired = false;
1261 imageView.SetImage(TEST_IMAGE_2);
1263 application.SendNotification();
1264 application.Render(16);
1266 // loading started, this waits for the loader thread for max 30 seconds
1267 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1269 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1271 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1273 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1278 void OnRelayoutOverride(Size size)
1280 gNaturalSize = size; // Size Relayout is using
1283 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1285 ToolkitTestApplication application;
1287 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1288 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1289 imageView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1291 DummyControl dummyControl = DummyControl::New(true);
1292 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1293 dummyControl.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
1295 dummyControl.Add(imageView);
1296 dummyImpl.SetRelayoutCallback(&OnRelayoutOverride);
1297 application.GetScene().Add(dummyControl);
1299 application.SendNotification();
1300 application.Render();
1302 // loading started, this waits for the loader thread for max 30 seconds
1303 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1305 DALI_TEST_EQUALS(gNaturalSize.width, 1024.0f, TEST_LOCATION);
1306 DALI_TEST_EQUALS(gNaturalSize.height, 1024.0f, TEST_LOCATION);
1308 gNaturalSize = Vector3::ZERO;
1310 imageView.SetImage(gImage_600_RGB);
1312 // Waiting for resourceReady so SendNotifcation not called here.
1314 // loading started, this waits for the loader thread for max 30 seconds
1315 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1317 // Trigger a potential relayout
1318 application.SendNotification();
1319 application.Render();
1321 DALI_TEST_EQUALS(gNaturalSize.width, 600.0f, TEST_LOCATION);
1322 DALI_TEST_EQUALS(gNaturalSize.height, 600.0f, TEST_LOCATION);
1327 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1329 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1331 ToolkitTestApplication application;
1333 gResourceReadySignalFired = false;
1335 Property::Map imageMap;
1337 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1338 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1340 tet_infoline("Creating ImageView without URL so image does not start loading");
1341 ImageView imageView = ImageView::New();
1342 tet_infoline("Connect to image loaded signal before setting image");
1343 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1344 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1345 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1347 // loading started, this waits for the loader thread
1348 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1350 application.SendNotification();
1351 application.Render(16);
1353 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1358 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1360 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1362 ToolkitTestApplication application;
1364 gResourceReadySignalFired = false;
1366 Property::Map imageMap;
1368 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1369 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1371 ImageView imageView = ImageView::New();
1372 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1373 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1375 // loading started, this waits for the loader thread
1376 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1378 application.SendNotification();
1379 application.Render(16);
1381 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1382 gResourceReadySignalFired = false;
1384 ImageView imageViewWithExistingImage = ImageView::New();
1385 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1386 imageViewWithExistingImage.SetProperty(ImageView::Property::IMAGE, imageMap);
1388 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1393 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1395 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1397 ToolkitTestApplication application;
1399 gResourceReadySignalFired = false;
1401 Property::Map imageImmediateLoadingMap;
1402 imageImmediateLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1403 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1405 tet_infoline("Immediate load an image");
1406 ImageView imageView = ImageView::New();
1407 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1408 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
1410 // loading started, this waits for the loader thread
1411 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1413 application.SendNotification();
1414 application.Render(16);
1416 tet_infoline("Check image loaded");
1417 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1418 gResourceReadySignalFired = false;
1420 tet_infoline("Create another ImageView with the same URL");
1421 ImageView imageViewWithExistingImage = ImageView::New(gImage_34_RGBA);
1422 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1423 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1425 application.GetScene().Add(imageViewWithExistingImage);
1427 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1432 int UtcDaliImageViewPaddingProperty(void)
1434 ToolkitTestApplication application;
1436 ImageView imageView = ImageView::New();
1437 Property::Map imagePropertyMap;
1438 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1439 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
1440 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1441 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1442 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1443 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1444 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1445 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1446 application.GetScene().Add(imageView);
1448 application.SendNotification();
1449 application.Render();
1451 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1453 ImageView childImage = ImageView::New();
1454 childImage.SetBackgroundColor(Color::BLACK);
1455 childImage.SetProperty(Actor::Property::SIZE, Vector2(10.f, 10.f));
1456 imageView.Add(childImage);
1458 application.SendNotification();
1459 application.Render();
1461 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1462 DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
1464 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1465 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1466 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1467 Property::Map resultMap;
1468 imageVisual.CreatePropertyMap(resultMap);
1470 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1471 DALI_TEST_CHECK(transformValue);
1472 Property::Map* retMap = transformValue->GetMap();
1473 DALI_TEST_CHECK(retMap);
1475 // Image Visual should be positioned depending on ImageView's padding
1476 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1481 int UtcDaliImageViewPaddingProperty02(void)
1483 ToolkitTestApplication application;
1485 ImageView imageView = ImageView::New();
1486 Property::Map imagePropertyMap;
1487 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1488 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1489 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1490 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1491 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1492 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1493 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1494 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1495 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1496 application.GetScene().Add(imageView);
1498 application.SendNotification();
1499 application.Render();
1501 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1503 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1504 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1505 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1506 Property::Map resultMap;
1507 imageVisual.CreatePropertyMap(resultMap);
1509 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1510 DALI_TEST_CHECK(transformValue);
1511 Property::Map* retMap = transformValue->GetMap();
1512 DALI_TEST_CHECK(retMap);
1514 // Image Visual should be positioned depending on ImageView's padding
1515 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1520 int UtcDaliImageViewPaddingProperty03(void)
1522 tet_infoline("Test Setting Image Padding then removing it.");
1524 ToolkitTestApplication application;
1526 ImageView imageView = ImageView::New();
1527 Property::Map imagePropertyMap;
1528 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1529 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1530 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1531 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1532 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1533 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1534 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1535 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1536 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1537 application.GetScene().Add(imageView);
1539 application.SendNotification();
1540 application.Render();
1542 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1544 tet_infoline("Remove Padding and test Visual is position correctly");
1546 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1548 application.SendNotification();
1549 application.Render();
1551 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1552 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1553 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1554 Property::Map resultMap;
1555 imageVisual.CreatePropertyMap(resultMap);
1557 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1558 DALI_TEST_CHECK(transformValue);
1559 Property::Map* retMap = transformValue->GetMap();
1560 DALI_TEST_CHECK(retMap);
1562 // Image Visual should be positioned depending on ImageView's padding
1563 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1568 int UtcDaliImageViewPaddingProperty04(void)
1570 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1572 ToolkitTestApplication application;
1574 ImageView imageView = ImageView::New();
1575 Property::Map imagePropertyMap;
1576 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1577 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1578 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1579 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1580 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FILL;
1581 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1582 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1583 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1584 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1585 application.GetScene().Add(imageView);
1587 application.SendNotification();
1588 application.Render();
1590 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1592 tet_infoline("Remove Padding and test Visual is position correctly");
1594 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1596 application.SendNotification();
1597 application.Render();
1599 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1600 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1601 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1602 Property::Map resultMap;
1603 imageVisual.CreatePropertyMap(resultMap);
1605 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1606 DALI_TEST_CHECK(transformValue);
1607 Property::Map* retMap = transformValue->GetMap();
1608 DALI_TEST_CHECK(retMap);
1610 // Image Visual should be positioned depending on ImageView's padding
1611 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1616 int UtcDaliImageViewTransformTest01(void)
1618 tet_infoline("Test Setting a offset transform on the ImageView");
1620 ToolkitTestApplication application;
1622 ImageView imageView = ImageView::New();
1623 Property::Map imagePropertyMap;
1624 imagePropertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE)
1625 .Add(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/Kid1.svg")
1626 .Add(ImageVisual::Property::DESIRED_WIDTH, 120)
1627 .Add(ImageVisual::Property::DESIRED_HEIGHT, 120)
1628 .Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL)
1629 .Add(Visual::Property::TRANSFORM,
1630 Property::Map().Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1631 Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE))
1632 .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(8, 8)));
1634 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1635 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1636 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1637 application.GetScene().Add(imageView);
1639 application.SendNotification();
1640 application.Render();
1642 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1643 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1644 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1645 Property::Map resultMap;
1646 imageVisual.CreatePropertyMap(resultMap);
1648 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1649 DALI_TEST_CHECK(transformValue);
1650 Property::Map* retMap = transformValue->GetMap();
1651 DALI_TEST_CHECK(retMap);
1653 // Image Visual should be positioned depending on ImageView's padding
1654 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(8, 8), TEST_LOCATION);
1655 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);
1660 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1662 ToolkitTestApplication application;
1664 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1665 ImageView imageView = ImageView::New();
1666 Property::Map imageMap;
1667 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1668 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_34_RGBA;
1669 imageMap[Toolkit::ImageVisual::Property::ATLASING] = true;
1670 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1671 application.GetScene().Add(imageView);
1673 // Trigger a potential relayout
1674 application.SendNotification();
1675 application.Render();
1677 Vector3 naturalSize = imageView.GetNaturalSize();
1679 DALI_TEST_EQUALS(naturalSize.width, 34.0f, TEST_LOCATION);
1680 DALI_TEST_EQUALS(naturalSize.height, 34.0f, TEST_LOCATION);
1685 int UtcDaliImageViewFillMode(void)
1687 ToolkitTestApplication application;
1689 tet_infoline("Create an ImageVisual without padding and set the fill-mode to fill");
1691 ImageView imageView = ImageView::New();
1692 Property::Map imageMap;
1693 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1694 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB);
1695 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL);
1697 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1699 application.GetScene().Add(imageView);
1701 // Trigger a potential relayout
1702 application.SendNotification();
1703 application.Render();
1705 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1706 Property::Map returnedMap;
1707 visual.CreatePropertyMap(returnedMap);
1709 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1710 DALI_TEST_CHECK(value);
1711 Property::Map* map = value->GetMap();
1712 DALI_TEST_CHECK(map);
1714 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1715 DALI_TEST_CHECK(value);
1716 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION);
1718 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1719 DALI_TEST_CHECK(value);
1720 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1725 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1727 ToolkitTestApplication application;
1729 tet_infoline("Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )");
1730 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1732 ImageView imageView = ImageView::New();
1733 Property::Map imageMap;
1734 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1735 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1736 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
1738 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1739 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1741 application.GetScene().Add(imageView);
1743 // Trigger a potential relayout
1744 application.SendNotification();
1745 application.Render();
1747 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1748 Property::Map returnedMap;
1749 visual.CreatePropertyMap(returnedMap);
1751 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1752 DALI_TEST_CHECK(value);
1753 Property::Map* map = value->GetMap();
1754 DALI_TEST_CHECK(map);
1757 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1758 DALI_TEST_CHECK(value);
1759 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION);
1761 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1762 DALI_TEST_CHECK(value);
1763 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1765 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1766 DALI_TEST_CHECK(value);
1767 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
1772 int UtcDaliImageViewFittingModesFill(void)
1774 ToolkitTestApplication application;
1776 tet_infoline("Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )");
1777 tet_infoline(" There should be no need to change the transform, only size is changed to fit view");
1779 ImageView imageView = ImageView::New();
1780 Property::Map imageMap;
1781 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1782 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1783 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL);
1785 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1786 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1788 application.GetScene().Add(imageView);
1790 // Trigger a potential relayout
1791 application.SendNotification();
1792 application.Render();
1794 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1795 Property::Map returnedMap;
1796 visual.CreatePropertyMap(returnedMap);
1798 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1799 DALI_TEST_CHECK(value);
1800 Property::Map* map = value->GetMap();
1801 DALI_TEST_CHECK(map);
1803 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1804 DALI_TEST_CHECK(value);
1805 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Change the internal size according to the image view size
1807 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1808 DALI_TEST_CHECK(value);
1809 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1811 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1812 DALI_TEST_CHECK(value);
1813 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1818 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1820 ToolkitTestApplication application;
1822 tet_infoline("Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )");
1823 tet_infoline(" offset or size is the same as view, but adjust internally using pixelArea ");
1825 ImageView imageView = ImageView::New();
1826 Property::Map imageMap;
1827 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1828 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1829 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO);
1831 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1832 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 500));
1834 application.GetScene().Add(imageView);
1836 // Trigger a potential relayout
1837 application.SendNotification();
1838 application.Render();
1840 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1841 Property::Map returnedMap;
1842 visual.CreatePropertyMap(returnedMap);
1844 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1845 DALI_TEST_CHECK(value);
1846 Property::Map* map = value->GetMap();
1847 DALI_TEST_CHECK(map);
1850 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1851 DALI_TEST_CHECK(value);
1852 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 500), TEST_LOCATION); // Change the internal size according to the image view size
1854 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1855 DALI_TEST_CHECK(value);
1856 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1858 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1859 DALI_TEST_CHECK(value);
1860 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1865 int UtcDaliImageViewFittingModesCenter01(void)
1867 ToolkitTestApplication application;
1869 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [700,700] )");
1870 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1872 ImageView imageView = ImageView::New();
1873 Property::Map imageMap;
1874 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1875 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1876 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1878 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1879 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1881 application.GetScene().Add(imageView);
1883 // Trigger a potential relayout
1884 application.SendNotification();
1885 application.Render();
1887 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1888 Property::Map returnedMap;
1889 visual.CreatePropertyMap(returnedMap);
1891 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1892 DALI_TEST_CHECK(value);
1893 Property::Map* map = value->GetMap();
1894 DALI_TEST_CHECK(map);
1896 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1897 DALI_TEST_CHECK(value);
1898 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1900 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1901 DALI_TEST_CHECK(value);
1902 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1904 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1905 DALI_TEST_CHECK(value);
1906 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1911 int UtcDaliImageViewFittingModesCenter02(void)
1913 ToolkitTestApplication application;
1915 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [500,500] )");
1916 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1918 ImageView imageView = ImageView::New();
1919 Property::Map imageMap;
1920 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1921 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1922 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1924 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1925 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1927 application.GetScene().Add(imageView);
1929 // Trigger a potential relayout
1930 application.SendNotification();
1931 application.Render();
1933 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1934 Property::Map returnedMap;
1935 visual.CreatePropertyMap(returnedMap);
1937 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1938 DALI_TEST_CHECK(value);
1939 Property::Map* map = value->GetMap();
1940 DALI_TEST_CHECK(map);
1942 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1943 DALI_TEST_CHECK(value);
1944 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1946 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1947 DALI_TEST_CHECK(value);
1948 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1950 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1951 DALI_TEST_CHECK(value);
1952 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1957 int UtcDaliImageViewFittingModesFitHeight01(void)
1959 ToolkitTestApplication application;
1961 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )");
1963 ImageView imageView = ImageView::New();
1964 Property::Map imageMap;
1965 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1966 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1967 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1969 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1970 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1972 application.GetScene().Add(imageView);
1974 // Trigger a potential relayout
1975 application.SendNotification();
1976 application.Render();
1978 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1979 Property::Map returnedMap;
1980 visual.CreatePropertyMap(returnedMap);
1982 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1983 DALI_TEST_CHECK(value);
1984 Property::Map* map = value->GetMap();
1985 DALI_TEST_CHECK(map);
1987 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1988 DALI_TEST_CHECK(value);
1989 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 700), TEST_LOCATION); // Change the internal size according to the image view size
1991 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1992 DALI_TEST_CHECK(value);
1993 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1995 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1996 DALI_TEST_CHECK(value);
1997 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2002 int UtcDaliImageViewFittingModesFitHeight02(void)
2004 ToolkitTestApplication application;
2006 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )");
2008 ImageView imageView = ImageView::New();
2009 Property::Map imageMap;
2010 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2011 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2012 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2014 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2015 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2017 application.GetScene().Add(imageView);
2019 // Trigger a potential relayout
2020 application.SendNotification();
2021 application.Render();
2023 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2024 Property::Map returnedMap;
2025 visual.CreatePropertyMap(returnedMap);
2027 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2028 DALI_TEST_CHECK(value);
2029 Property::Map* map = value->GetMap();
2030 DALI_TEST_CHECK(map);
2032 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2033 DALI_TEST_CHECK(value);
2034 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2036 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2037 DALI_TEST_CHECK(value);
2038 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2040 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2041 DALI_TEST_CHECK(value);
2042 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2047 int UtcDaliImageViewFittingModesFitWidth01(void)
2049 ToolkitTestApplication application;
2051 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )");
2053 ImageView imageView = ImageView::New();
2054 Property::Map imageMap;
2055 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2056 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2057 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2059 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2060 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2062 application.GetScene().Add(imageView);
2064 // Trigger a potential relayout
2065 application.SendNotification();
2066 application.Render();
2068 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2069 Property::Map returnedMap;
2070 visual.CreatePropertyMap(returnedMap);
2072 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2073 DALI_TEST_CHECK(value);
2074 Property::Map* map = value->GetMap();
2075 DALI_TEST_CHECK(map);
2077 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2078 DALI_TEST_CHECK(value);
2079 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2081 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2082 DALI_TEST_CHECK(value);
2083 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2085 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2086 DALI_TEST_CHECK(value);
2087 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
2092 int UtcDaliImageViewFittingModesFitWidth02(void)
2094 ToolkitTestApplication application;
2096 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )");
2098 ImageView imageView = ImageView::New();
2099 Property::Map imageMap;
2100 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2101 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2102 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2104 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2105 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2107 application.GetScene().Add(imageView);
2109 // Trigger a potential relayout
2110 application.SendNotification();
2111 application.Render();
2113 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2114 Property::Map returnedMap;
2115 visual.CreatePropertyMap(returnedMap);
2117 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2118 DALI_TEST_CHECK(value);
2119 Property::Map* map = value->GetMap();
2120 DALI_TEST_CHECK(map);
2122 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2123 DALI_TEST_CHECK(value);
2124 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 600), TEST_LOCATION); // Change the internal size according to the image view size
2126 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2127 DALI_TEST_CHECK(value);
2128 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2130 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2131 DALI_TEST_CHECK(value);
2132 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2137 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2139 ToolkitTestApplication application;
2141 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2143 ImageView imageView = ImageView::New();
2145 // 1. Render using FittingMode::SHRINK_TO_FIT
2146 Property::Map imageMap;
2147 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2148 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2149 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2151 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2152 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2154 application.GetScene().Add(imageView);
2156 // Trigger a potential relayout
2157 application.SendNotification();
2158 application.Render();
2160 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2161 Property::Map returnedMap;
2162 visual.CreatePropertyMap(returnedMap);
2164 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2165 DALI_TEST_CHECK(value);
2166 Property::Map* map = value->GetMap();
2167 DALI_TEST_CHECK(map);
2169 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2170 DALI_TEST_CHECK(value);
2171 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2173 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2174 DALI_TEST_CHECK(value);
2175 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2177 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2178 DALI_TEST_CHECK(value);
2179 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2181 // 2. Render again using DevelVisaul::CENTER
2182 Property::Map imageMap2;
2183 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2184 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2185 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2187 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2188 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2190 application.GetScene().Add(imageView);
2192 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2194 // Trigger a potential relayout
2195 application.SendNotification();
2196 application.Render();
2198 returnedMap.Clear();
2199 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2201 visual.CreatePropertyMap(returnedMap);
2203 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2204 DALI_TEST_CHECK(value);
2205 map = value->GetMap();
2206 DALI_TEST_CHECK(map);
2208 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2209 DALI_TEST_CHECK(value);
2210 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2212 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2213 DALI_TEST_CHECK(value);
2214 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2216 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2217 DALI_TEST_CHECK(value);
2218 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2220 // 3. Render again using before fittingMode
2221 Property::Map imageMap3;
2222 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2223 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2224 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2226 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2227 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2229 application.GetScene().Add(imageView);
2231 // Trigger a potential relayout
2232 application.SendNotification();
2233 application.Render();
2235 returnedMap.Clear();
2236 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2237 visual.CreatePropertyMap(returnedMap);
2239 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2240 DALI_TEST_CHECK(value);
2241 map = value->GetMap();
2242 DALI_TEST_CHECK(map);
2244 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2245 DALI_TEST_CHECK(value);
2246 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2248 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2249 DALI_TEST_CHECK(value);
2250 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2252 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2253 DALI_TEST_CHECK(value);
2254 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2259 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2261 ToolkitTestApplication application;
2263 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2265 ImageView imageView = ImageView::New();
2267 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2268 Property::Map imageMap;
2269 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2270 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2271 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2273 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2274 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2276 application.GetScene().Add(imageView);
2278 // Trigger a potential relayout
2279 application.SendNotification();
2280 application.Render();
2282 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2283 Property::Map returnedMap;
2284 visual.CreatePropertyMap(returnedMap);
2286 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2287 DALI_TEST_CHECK(value);
2288 Property::Map* map = value->GetMap();
2289 DALI_TEST_CHECK(map);
2291 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2292 DALI_TEST_CHECK(value);
2293 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2295 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2296 DALI_TEST_CHECK(value);
2297 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2299 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2300 DALI_TEST_CHECK(value);
2301 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2303 // 2. Render again using DevelVisaul::CENTER
2304 Property::Map imageMap2;
2305 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2306 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2307 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2309 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2310 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2312 application.GetScene().Add(imageView);
2314 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2316 // Trigger a potential relayout
2317 application.SendNotification();
2318 application.Render();
2320 returnedMap.Clear();
2321 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2323 visual.CreatePropertyMap(returnedMap);
2325 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2326 DALI_TEST_CHECK(value);
2327 map = value->GetMap();
2328 DALI_TEST_CHECK(map);
2330 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2331 DALI_TEST_CHECK(value);
2332 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2334 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2335 DALI_TEST_CHECK(value);
2336 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2338 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2339 DALI_TEST_CHECK(value);
2340 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2342 // 3. Render again using before fittingMode
2343 Property::Map imageMap3;
2344 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2345 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2346 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2348 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2349 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2351 application.GetScene().Add(imageView);
2353 // Trigger a potential relayout
2354 application.SendNotification();
2355 application.Render();
2357 returnedMap.Clear();
2358 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2359 visual.CreatePropertyMap(returnedMap);
2361 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2362 DALI_TEST_CHECK(value);
2363 map = value->GetMap();
2364 DALI_TEST_CHECK(map);
2366 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2367 DALI_TEST_CHECK(value);
2368 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2370 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2371 DALI_TEST_CHECK(value);
2372 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2374 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2375 DALI_TEST_CHECK(value);
2376 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2381 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2383 ToolkitTestApplication application;
2385 tet_infoline("Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )");
2387 ImageView imageView = ImageView::New();
2388 Property::Map imageMap;
2389 imageMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE);
2390 imageMap.Add(Toolkit::ImageVisual::Property::URL, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME); // 249x169 image
2392 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2393 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
2395 application.GetScene().Add(imageView);
2397 // Trigger a potential relayout
2398 application.SendNotification();
2399 application.Render();
2401 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2402 Property::Map returnedMap;
2403 visual.CreatePropertyMap(returnedMap);
2405 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2406 DALI_TEST_CHECK(value);
2407 Property::Map* map = value->GetMap();
2408 DALI_TEST_CHECK(map);
2410 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2411 DALI_TEST_CHECK(value);
2412 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Relative size so will take up 100%
2414 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2415 DALI_TEST_CHECK(value);
2416 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2418 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2419 DALI_TEST_CHECK(value);
2420 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2425 int UtcDaliImageViewCustomShader(void)
2427 ToolkitTestApplication application;
2429 // Set a custom shader with an image url
2431 Property::Map properties;
2432 Property::Map shader;
2433 const std::string vertexShader = "Foobar";
2434 const std::string fragmentShader = "Foobar";
2435 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2436 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2438 properties[Visual::Property::TYPE] = Visual::IMAGE;
2439 properties[Visual::Property::SHADER] = shader;
2440 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2442 ImageView imageView = ImageView::New();
2443 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2445 application.GetScene().Add(imageView);
2447 application.SendNotification();
2448 application.Render();
2450 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2452 Renderer renderer = imageView.GetRendererAt(0);
2453 Shader shader2 = renderer.GetShader();
2454 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2455 Property::Map* map = value.GetMap();
2456 DALI_TEST_CHECK(map);
2458 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2459 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2461 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2462 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2465 // Set a custom shader after setting an image url
2467 Property::Map properties;
2468 Property::Map shader;
2469 const std::string vertexShader = "Foobar";
2470 const std::string fragmentShader = "Foobar";
2471 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2472 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2474 properties[Visual::Property::SHADER] = shader;
2476 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
2477 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2479 application.GetScene().Add(imageView);
2481 application.SendNotification();
2482 application.Render();
2484 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2486 Renderer renderer = imageView.GetRendererAt(0);
2487 Shader shader2 = renderer.GetShader();
2488 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2489 Property::Map* map = value.GetMap();
2490 DALI_TEST_CHECK(map);
2492 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2493 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2495 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2496 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2499 // Set a custom shader before setting 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::SHADER] = shader;
2510 ImageView imageView = ImageView::New();
2511 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2512 imageView.SetProperty(ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME);
2514 application.GetScene().Add(imageView);
2516 application.SendNotification();
2517 application.Render();
2518 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2520 Renderer renderer = imageView.GetRendererAt(0);
2521 Shader shader2 = renderer.GetShader();
2522 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2523 Property::Map* map = value.GetMap();
2524 DALI_TEST_CHECK(map);
2526 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2527 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2529 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2530 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2533 // Set a custom shader after setting a property map
2535 Property::Map properties;
2536 Property::Map shader;
2537 const std::string vertexShader = "Foobar";
2538 const std::string fragmentShader = "Foobar";
2539 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2540 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2542 properties[Visual::Property::SHADER] = shader;
2544 Property::Map properties1;
2545 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2546 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2548 ImageView imageView = ImageView::New();
2549 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2550 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2552 application.GetScene().Add(imageView);
2554 application.SendNotification();
2555 application.Render();
2556 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2558 Renderer renderer = imageView.GetRendererAt(0);
2559 Shader shader2 = renderer.GetShader();
2560 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2561 Property::Map* map = value.GetMap();
2562 DALI_TEST_CHECK(map);
2564 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2565 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2567 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2568 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2571 // Set a custom shader before setting a property map
2573 Property::Map properties;
2574 Property::Map shader;
2575 const std::string vertexShader = "Foobar";
2576 const std::string fragmentShader = "Foobar";
2577 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2578 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2580 properties[Visual::Property::SHADER] = shader;
2582 Property::Map properties1;
2583 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2584 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2586 ImageView imageView = ImageView::New();
2587 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2588 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2590 application.GetScene().Add(imageView);
2592 application.SendNotification();
2593 application.Render();
2594 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2596 Renderer renderer = imageView.GetRendererAt(0);
2597 Shader shader2 = renderer.GetShader();
2598 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2599 Property::Map* map = value.GetMap();
2600 DALI_TEST_CHECK(map);
2602 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2603 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2605 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2606 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2614 static int gFailCounter = 0;
2615 const int MAX_RETRIES(3);
2617 void ReloadImage(ImageView imageView)
2619 Property::Map imageImmediateLoadingMap;
2620 imageImmediateLoadingMap[ImageVisual::Property::URL] = "Non-existant-image.jpg";
2621 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
2623 tet_infoline("Immediate load an image");
2624 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
2627 void ResourceFailedReload(Control control)
2630 if(gFailCounter < MAX_RETRIES)
2632 ReloadImage(ImageView::DownCast(control));
2637 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2639 tet_infoline("Test reloading failed image from within signal handler.");
2641 ToolkitTestApplication application;
2645 ImageView imageView = ImageView::New();
2646 imageView.ResourceReadySignal().Connect(&ResourceFailedReload);
2647 DALI_TEST_EQUALS(gFailCounter, 0, TEST_LOCATION);
2648 ReloadImage(imageView);
2650 // loading started, this waits for the loader thread to complete
2651 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2652 application.SendNotification();
2654 DALI_TEST_EQUALS(gFailCounter, 1, TEST_LOCATION);
2656 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2657 application.SendNotification();
2659 DALI_TEST_EQUALS(gFailCounter, 2, TEST_LOCATION);
2661 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2662 application.SendNotification();
2663 DALI_TEST_EQUALS(gFailCounter, 3, TEST_LOCATION);
2668 int UtcDaliImageViewLoadRemoteSVG(void)
2670 tet_infoline("Test load from a remote server.");
2672 ToolkitTestApplication application;
2675 Toolkit::ImageView imageView;
2676 imageView = Toolkit::ImageView::New();
2677 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2678 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2679 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2680 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2681 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2683 application.GetScene().Add(imageView);
2685 DALI_TEST_CHECK(imageView);
2687 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2689 application.SendNotification();
2691 // Wait for loading & rasterization
2692 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2694 application.SendNotification();
2695 application.Render();
2697 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2702 Toolkit::ImageView imageView;
2703 imageView = Toolkit::ImageView::New();
2704 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2705 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2706 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2707 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2709 application.GetScene().Add(imageView);
2711 DALI_TEST_CHECK(imageView);
2713 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2715 application.SendNotification();
2717 // Wait for loading & rasterization
2718 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2720 application.SendNotification();
2721 application.Render();
2723 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2729 int UtcDaliImageViewSyncSVGLoading(void)
2731 ToolkitTestApplication application;
2733 tet_infoline("ImageView Testing SVG image sync loading");
2736 ImageView imageView = ImageView::New();
2738 // Sync loading is used
2739 Property::Map syncLoadingMap;
2740 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2741 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2742 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2743 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2745 application.GetScene().Add(imageView);
2746 DALI_TEST_CHECK(imageView);
2748 application.SendNotification();
2749 Vector3 naturalSize = imageView.GetNaturalSize();
2751 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2752 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2757 int UtcDaliImageViewAsyncSVGLoading(void)
2759 ToolkitTestApplication application;
2761 tet_infoline("ImageView Testing SVG image async loading");
2764 ImageView imageView = ImageView::New();
2766 // Async loading is used - default value of SYNCHRONOUS_LOADING is false.
2767 Property::Map propertyMap;
2768 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2769 propertyMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2770 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
2772 application.GetScene().Add(imageView);
2773 DALI_TEST_CHECK(imageView);
2775 application.SendNotification();
2778 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2780 application.SendNotification();
2781 application.Render(16);
2783 Vector3 naturalSize = imageView.GetNaturalSize();
2784 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2785 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2790 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2792 ToolkitTestApplication application;
2794 tet_infoline("ImageView Testing SVG image async loading");
2798 ImageView imageView = ImageView::New();
2800 // Sync loading is used
2801 Property::Map syncLoadingMap;
2802 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2803 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2805 // Check to set invalid value
2806 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2807 // Check if error log is outputted when setting other value like string.
2808 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2809 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5));
2810 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2812 application.GetScene().Add(imageView);
2813 DALI_TEST_CHECK(imageView);
2815 application.SendNotification();
2818 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2820 application.SendNotification();
2821 application.Render(16);
2823 Vector3 naturalSize = imageView.GetNaturalSize();
2824 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2825 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2827 Property::Value value = imageView.GetProperty(ImageView::Property::IMAGE);
2828 Property::Map* map = value.GetMap();
2829 DALI_TEST_CHECK(map);
2831 Property::Value* sync = map->Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING);
2832 DALI_TEST_CHECK(sync);
2833 DALI_TEST_EQUALS(false, sync->Get<bool>(), TEST_LOCATION);
2838 int UtcDaliImageViewSvgLoadingFailureLocalFile(void)
2840 // Local svg file - invalid file path
2842 ToolkitTestApplication application;
2844 TestGlAbstraction& gl = application.GetGlAbstraction();
2845 TraceCallStack& textureTrace = gl.GetTextureTrace();
2846 textureTrace.Enable(true);
2848 gResourceReadySignalFired = false;
2850 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2851 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2852 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2854 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2856 application.GetScene().Add(imageView);
2858 application.SendNotification();
2860 // loading started, this waits for the loader thread - load
2861 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2863 application.SendNotification();
2864 application.Render(16);
2866 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2867 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2868 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2870 // Should be shown a broken image
2871 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2872 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2875 // Local svg file - invalid file path without size set
2877 ToolkitTestApplication application;
2879 TestGlAbstraction& gl = application.GetGlAbstraction();
2880 TraceCallStack& textureTrace = gl.GetTextureTrace();
2881 textureTrace.Enable(true);
2883 gResourceReadySignalFired = false;
2884 textureTrace.Reset();
2886 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2887 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2889 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2891 application.GetScene().Add(imageView);
2893 application.SendNotification();
2895 // loading started, this waits for the loader thread - load & rasterize
2896 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2898 application.SendNotification();
2899 application.Render(16);
2901 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2902 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2903 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2905 // Should be shown a broken image
2906 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2907 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2910 // Local svg file - invalid file
2912 ToolkitTestApplication application;
2914 TestGlAbstraction& gl = application.GetGlAbstraction();
2915 TraceCallStack& textureTrace = gl.GetTextureTrace();
2916 textureTrace.Enable(true);
2918 gResourceReadySignalFired = false;
2919 textureTrace.Reset();
2921 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.svg");
2922 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2923 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2925 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2927 application.GetScene().Add(imageView);
2929 application.SendNotification();
2931 // loading started, this waits for the loader thread - load & rasterize
2932 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2934 application.SendNotification();
2935 application.Render(16);
2937 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2938 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2939 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2941 // Should be shown a broken image
2942 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2943 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2949 int UtcDaliImageViewSvgLoadingFailureRemoteFile01(void)
2953 ToolkitTestApplication application;
2955 TestGlAbstraction& gl = application.GetGlAbstraction();
2956 TraceCallStack& textureTrace = gl.GetTextureTrace();
2957 textureTrace.Enable(true);
2959 gResourceReadySignalFired = false;
2961 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
2962 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2963 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2965 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2967 application.GetScene().Add(imageView);
2969 application.SendNotification();
2971 // loading started, this waits for the loader thread - load & rasterize
2972 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2974 application.SendNotification();
2975 application.Render(16);
2977 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2978 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2979 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2981 // Should be shown a broken image
2982 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2983 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2989 int UtcDaliImageViewSvgLoadingFailureRemoteFile02(void)
2991 // Remote svg file without size set
2993 ToolkitTestApplication application;
2995 TestGlAbstraction& gl = application.GetGlAbstraction();
2996 TraceCallStack& textureTrace = gl.GetTextureTrace();
2997 textureTrace.Enable(true);
2999 gResourceReadySignalFired = false;
3001 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
3002 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3004 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3006 application.GetScene().Add(imageView);
3008 application.SendNotification();
3010 // loading started, this waits for the loader thread - load & rasterize
3011 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3013 application.SendNotification();
3014 application.Render(16);
3016 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3017 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3018 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3020 // Should be shown a broken image
3021 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3022 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3028 int UtcDaliImageViewSvgRasterizationFailure(void)
3030 ToolkitTestApplication application;
3032 gResourceReadySignalFired = false;
3034 TestGlAbstraction& gl = application.GetGlAbstraction();
3035 TraceCallStack& textureTrace = gl.GetTextureTrace();
3036 textureTrace.Enable(true);
3038 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid1.svg");
3039 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3040 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3042 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3044 application.GetScene().Add(imageView);
3046 application.SendNotification();
3048 // Wait for loading & rasterization
3049 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3051 application.SendNotification();
3052 application.Render(16);
3054 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3055 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3056 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3058 // Should be shown a broken image
3059 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3060 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3065 int UtcDaliImageViewSvgChageSize(void)
3067 ToolkitTestApplication application;
3069 TestGlAbstraction& gl = application.GetGlAbstraction();
3070 TraceCallStack& textureTrace = gl.GetTextureTrace();
3071 textureTrace.Enable(true);
3073 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME);
3074 application.GetScene().Add(imageView);
3076 application.SendNotification();
3078 // Wait for loading & rasterization
3079 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3081 application.SendNotification();
3082 application.Render(16);
3084 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3086 // Change actor size, then rasterization should be done again
3087 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3089 application.SendNotification();
3091 // Wait for rasterization
3092 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3094 application.SendNotification();
3095 application.Render(16);
3097 // We should not load the file again.
3098 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3103 int UtcDaliImageViewSvgAtlasing(void)
3105 ToolkitTestApplication application;
3107 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
3109 callStack.Enable(true);
3111 Property::Map propertyMap;
3112 propertyMap["url"] = TEST_SVG_FILE_NAME;
3113 propertyMap["atlasing"] = true;
3115 ImageView imageView = ImageView::New();
3116 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
3117 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3118 application.GetScene().Add(imageView);
3120 application.SendNotification();
3122 // Wait for loading & rasterization
3123 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3125 application.SendNotification();
3126 application.Render(16);
3129 TraceCallStack::NamedParams params1;
3130 params1["width"] << 100;
3131 params1["height"] << 100;
3132 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params1), true, TEST_LOCATION);
3134 imageView.SetProperty(Actor::Property::SIZE, Vector2(600.f, 600.f));
3136 application.SendNotification();
3138 // Wait for rasterization
3139 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3143 application.SendNotification();
3144 application.Render(16);
3147 TraceCallStack::NamedParams params2;
3148 params2["width"] << 600;
3149 params2["height"] << 600;
3150 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexImage2D", params2), true, TEST_LOCATION);
3155 int UtcDaliImageViewTVGLoading(void)
3157 ToolkitTestApplication application;
3159 tet_infoline("ImageView Testing TVG image loading");
3162 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/test.tvg");
3163 application.GetScene().Add(imageView);
3164 DALI_TEST_CHECK(imageView);
3166 application.SendNotification();
3168 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3170 application.SendNotification();
3171 application.Render(16);
3173 Vector3 naturalSize = imageView.GetNaturalSize();
3175 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3176 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3181 int UtcDaliImageViewImageLoadFailure01(void)
3183 ToolkitTestApplication application;
3185 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3186 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3187 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3188 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3190 std::string brokenUrl;
3191 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3192 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3194 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3195 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3197 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3198 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3200 ImageView imageView = ImageView::New("invalidUrl.png");
3201 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3203 application.GetScene().Add(imageView);
3204 application.SendNotification();
3205 application.Render(16);
3207 // loading started, this waits for the loader thread
3208 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3213 int UtcDaliImageViewImageLoadFailure02(void)
3215 ToolkitTestApplication application;
3217 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3218 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
3219 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3220 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3222 std::string brokenUrl;
3223 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3224 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
3226 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3227 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3229 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3230 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3232 ImageView imageView = ImageView::New("invalidUrl.png");
3233 imageView.SetProperty(Actor::Property::SIZE, Vector2(30.f, 30.f));
3234 application.GetScene().Add(imageView);
3235 application.SendNotification();
3236 application.Render(16);
3238 // loading started, this waits for the loader thread
3239 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3244 int UtcDaliImageViewImageLoadFailure03(void)
3246 ToolkitTestApplication application;
3248 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3249 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
3250 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
3252 std::string brokenUrl;
3253 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3254 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3256 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3257 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3259 ImageView imageView = ImageView::New("invalidUrl.png");
3260 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3261 application.GetScene().Add(imageView);
3262 application.SendNotification();
3263 application.Render(16);
3265 // loading started, this waits for the loader thread
3266 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3271 int UtcDaliImageViewImageLoadFailure04(void)
3273 ToolkitTestApplication application;
3275 ImageView imageView = ImageView::New("invalidUrl.png");
3276 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3277 application.GetScene().Add(imageView);
3278 application.SendNotification();
3279 application.Render(16);
3281 // loading started, this waits for the loader thread
3282 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3284 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3285 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3286 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3287 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3289 ImageView imageView2 = ImageView::New("invalidUrl.png");
3290 imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3291 application.GetScene().Add(imageView2);
3293 std::string brokenUrl;
3294 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3295 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3297 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3298 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3300 application.SendNotification();
3301 application.Render(16);
3303 // loading started, this waits for the loader thread
3304 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3306 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3308 ImageView imageView3 = ImageView::New("invalidUrl.png");
3309 imageView3.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3310 application.GetScene().Add(imageView3);
3312 application.SendNotification();
3313 application.Render(16);
3315 // loading started, this waits for the loader thread
3316 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3323 static int gResourceReadySignalCounter = 0;
3325 void OnResourceReadySignal01(Control control)
3327 gResourceReadySignalCounter++;
3329 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3331 if(gResourceReadySignalCounter == 1)
3334 // It makes the first new visual be deleted immediately
3335 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3336 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3339 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3341 // Make the resource ready immediately
3342 control[ImageView::Property::IMAGE] = gImage_600_RGB;
3346 void OnResourceReadySignal02(Control control)
3348 if(++gResourceReadySignalCounter == 1)
3350 // It makes the first new visual be deleted immediately
3351 // The first image will not be loaded.
3352 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB).Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3353 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3357 ImageView gImageView1;
3358 ImageView gImageView2;
3359 ImageView gImageView3;
3360 ImageView gImageView4;
3362 void OnResourceReadySignal03(Control control)
3364 if(gResourceReadySignalCounter == 0)
3367 // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3368 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3370 // 2. Load a new image
3371 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3373 // 3. Use the new image again
3374 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3375 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3377 else if(gResourceReadySignalCounter == 1)
3379 // This is called from TextureManager::ProcessQueuedTextures().
3380 gImageView1.Unparent();
3381 gImageView1.Reset();
3383 gResourceReadySignalCounter++;
3386 void OnSimpleResourceReadySignal(Control control)
3388 // simply increate counter
3389 gResourceReadySignalCounter++;
3392 int gResourceReadySignal04ComesOrder = 0;
3394 void OnResourceReadySignal04(Control control)
3396 gResourceReadySignalCounter++;
3397 tet_printf("rc %d\n", gResourceReadySignalCounter);
3398 if(gResourceReadySignalCounter == 1)
3400 auto scene = gImageView1.GetParent();
3402 // Request load something
3403 // We hope this request result is return later than gImageView2.
3404 gImageView3 = ImageView::New(TEST_IMAGE_1);
3405 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3406 scene.Add(gImageView3);
3407 gImageView4 = ImageView::New(TEST_IMAGE_2);
3408 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3409 scene.Add(gImageView4);
3411 if(control == gImageView1)
3413 gResourceReadySignal04ComesOrder = 1;
3417 gResourceReadySignal04ComesOrder = 2;
3420 if(gResourceReadySignalCounter == 2)
3422 if(gResourceReadySignal04ComesOrder == 1 && control == gImageView2)
3424 // Scene off first one.
3425 gImageView1.Unparent();
3427 // Scene off second one.
3428 gImageView2.Unparent();
3430 else if(gResourceReadySignal04ComesOrder == 2 && control == gImageView1)
3432 // Scene off first one.
3433 gImageView2.Unparent();
3435 // Scene off second one.
3436 gImageView1.Unparent();
3440 // We can't check that this utc fail case. just pass always when we come here.
3441 gResourceReadySignal04ComesOrder = -1;
3444 // If we don't seperate index of FreeList area
3445 // and if we don't queue remove during obversing,
3446 // cache index become something invalid data.
3447 // In this case, some strange observer can be called.
3448 // For example, gImageView4.LoadComplete will be called.
3452 void OnResourceReadySignal05(Control control)
3454 gResourceReadySignalCounter++;
3456 // Request load with same image
3457 // NOTE : The url must not be same as gImageView1
3458 const int viewCount = 4;
3459 for(int i = 0; i < viewCount; ++i)
3461 gImageView1.Add(ImageView::New("invalid2.jpg"));
3467 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3469 tet_infoline("Test setting image from within signal handler.");
3471 ToolkitTestApplication application;
3473 gResourceReadySignalCounter = 0;
3475 ImageView imageView = ImageView::New(gImage_34_RGBA);
3476 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal01);
3478 application.GetScene().Add(imageView);
3480 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3482 application.SendNotification();
3483 application.Render();
3485 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3487 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3489 // Create a new ImageView to cache the image
3490 ImageView imageView1 = ImageView::New(gImage_600_RGB);
3491 application.GetScene().Add(imageView1);
3493 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3495 application.SendNotification();
3496 application.Render();
3499 gResourceReadySignalCounter = 0;
3501 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3503 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3505 application.SendNotification();
3506 application.Render();
3508 // Run idle callback
3509 application.RunIdles();
3511 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3513 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3518 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
3520 tet_infoline("Test setting image from within signal handler.");
3522 ToolkitTestApplication application;
3524 gResourceReadySignalCounter = 0;
3526 ImageView imageView = ImageView::New(gImage_34_RGBA);
3527 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal02);
3529 application.GetScene().Add(imageView);
3531 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3533 application.SendNotification();
3534 application.Render();
3536 // Wait for loading an image
3537 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3539 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3541 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3546 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3548 tet_infoline("Test setting image from within signal handler.");
3550 ToolkitTestApplication application;
3552 gResourceReadySignalCounter = 0;
3554 gImageView1 = ImageView::New(gImage_34_RGBA);
3555 application.GetScene().Add(gImageView1);
3558 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3560 gImageView2 = ImageView::New(gImage_600_RGB);
3561 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3562 application.GetScene().Add(gImageView2);
3564 gImageView3 = ImageView::New();
3565 application.GetScene().Add(gImageView3);
3567 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3569 application.SendNotification();
3570 application.Render();
3575 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask01(void)
3577 tet_infoline("Test signal handler when image / mask image is broken.");
3579 ToolkitTestApplication application;
3581 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, const std::string& url, const std::string& mask, const char* location) {
3582 gResourceReadySignalCounter = 0;
3585 map[Toolkit::ImageVisual::Property::URL] = url;
3588 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3590 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3592 ImageView imageView = ImageView::New();
3593 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3594 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3595 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3597 application.GetScene().Add(imageView);
3598 application.SendNotification();
3599 application.Render();
3604 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3606 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3607 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3609 imageView.Unparent();
3612 for(int synchronous = 0; synchronous <= 1; synchronous++)
3614 tet_printf("Test normal case (sync:%d)\n", synchronous);
3615 TestResourceReadyUrl(1, synchronous, gImage_600_RGB, "", TEST_LOCATION);
3616 TestResourceReadyUrl(3, synchronous, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 3 event trigger required : 2 image load + 1 apply mask
3618 tet_printf("Test broken image case (sync:%d)\n", synchronous);
3619 TestResourceReadyUrl(1, synchronous, "invalid.jpg", "", TEST_LOCATION);
3620 TestResourceReadyUrl(2, synchronous, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3622 tet_printf("Test broken mask image case (sync:%d)\n", synchronous);
3623 TestResourceReadyUrl(2, synchronous, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3625 tet_printf("Test broken both image, mask image case (sync:%d)\n", synchronous);
3626 TestResourceReadyUrl(2, synchronous, "invalid.jpg", "invalid.png", TEST_LOCATION);
3632 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask02(void)
3634 tet_infoline("Test signal handler when image try to use cached-and-broken mask image.");
3636 ToolkitTestApplication application;
3638 gResourceReadySignalCounter = 0;
3640 auto TestBrokenMaskResourceReadyUrl = [&application](const std::string& url, const char* location) {
3642 map[Toolkit::ImageVisual::Property::URL] = url;
3643 // Use invalid mask url
3644 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
3646 ImageView imageView = ImageView::New();
3647 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3648 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3649 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3651 application.GetScene().Add(imageView);
3652 application.SendNotification();
3653 application.Render();
3655 // Don't unparent imageView, for keep the cache.
3658 // Use more than 4 images (The number of LocalImageLoadThread)
3659 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};
3661 int expectResourceReadySignalCounter = 0;
3663 for(auto& url : testUrlList)
3665 TestBrokenMaskResourceReadyUrl(url, TEST_LOCATION);
3666 expectResourceReadySignalCounter++;
3669 // Remain 1 signal due to we use #URL + 1 mask image.
3670 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(expectResourceReadySignalCounter + 1), true, TEST_LOCATION);
3672 DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
3677 int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
3679 tet_infoline("Test signal handler various case.");
3681 auto TestResourceReadyUrl = [](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
3682 ToolkitTestApplication application;
3684 gResourceReadySignalCounter = 0;
3687 map[Toolkit::ImageVisual::Property::URL] = url;
3690 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3692 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3694 ImageView imageView = ImageView::New();
3695 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3696 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3697 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3699 application.GetScene().Add(imageView);
3700 application.SendNotification();
3701 application.Render();
3704 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3706 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3707 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3708 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, location);
3710 imageView.Unparent();
3713 auto TestAuxiliaryResourceReadyUrl = [](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
3714 ToolkitTestApplication application;
3716 gResourceReadySignalCounter = 0;
3719 map[Toolkit::ImageVisual::Property::URL] = url;
3720 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE] = auxiliaryUrl;
3721 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA] = 0.5f;
3722 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3724 ImageView imageView = ImageView::New();
3725 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
3726 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
3727 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3728 application.GetScene().Add(imageView);
3730 application.SendNotification();
3731 application.Render();
3736 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, location);
3739 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3740 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3741 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3743 imageView.Unparent();
3746 // Case 1 : asynchronous loading
3747 tet_printf("Test invalid single simple image Asynchronous\n");
3750 TestResourceReadyUrl(1, 0, 1, gImage_600_RGB, "", TEST_LOCATION);
3751 TestResourceReadyUrl(2, 0, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // load & rasterize
3752 TestResourceReadyUrl(1, 0, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
3754 TestResourceReadyUrl(2, 0, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // 2 image loading - batch size
3755 TestResourceReadyUrl(2, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // load & rasterize
3757 TestResourceReadyUrl(3, 0, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 2 image loading + 1 applymask
3759 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
3762 TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
3763 TestResourceReadyUrl(1, 0, 0, "invalid.svg", "", TEST_LOCATION);
3764 TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
3765 TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION); // 1 image loading
3766 TestResourceReadyUrl(1, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
3768 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", "invalid.png", TEST_LOCATION); // 2 image loading
3769 TestResourceReadyUrl(2, 0, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); // 2 image loading
3770 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION); // 2 image loading
3772 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
3773 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
3774 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
3776 // Case 2 : Synchronous loading
3777 tet_printf("Test invalid single simple image Synchronous\n");
3780 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "", TEST_LOCATION);
3781 TestResourceReadyUrl(0, 1, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
3782 TestResourceReadyUrl(0, 1, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
3784 TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // first frame image loading sync + second frame image loading async
3786 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION);
3788 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
3791 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
3792 TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION);
3793 TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
3794 TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
3796 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "invalid.png", TEST_LOCATION);
3797 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3798 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3800 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
3801 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
3802 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
3807 int UtcDaliImageViewSetImageOnResourceReadySignal04(void)
3809 tet_infoline("Test texturemanager's remove queue works well within signal handler.");
3811 ToolkitTestApplication application;
3813 gResourceReadySignalCounter = 0;
3814 gResourceReadySignal04ComesOrder = 0;
3816 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
3817 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3818 application.GetScene().Add(gImageView1);
3820 gImageView2 = ImageView::New("invalid.png"); // request invalid image, to make loading failed fast.
3821 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3822 application.GetScene().Add(gImageView2);
3824 application.SendNotification();
3825 application.Render();
3827 tet_infoline("Try to load 2 invalid image");
3829 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3830 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3832 tet_infoline("load done");
3834 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
3835 if(gResourceReadySignal04ComesOrder == -1)
3837 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
3841 // gImageView3 and gImageView4 load must not be successed yet.
3842 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
3843 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
3845 application.SendNotification();
3846 application.Render();
3848 tet_infoline("Try to load 2 valid image");
3850 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3851 DALI_TEST_EQUALS(gResourceReadySignalCounter, 4, TEST_LOCATION);
3853 tet_infoline("load done");
3855 // gImageView3 and gImageView4 load must be successed now.
3856 DALI_TEST_EQUALS(gImageView3.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
3857 DALI_TEST_EQUALS(gImageView4.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
3862 int UtcDaliImageViewSetImageOnResourceReadySignal05(void)
3864 tet_infoline("Test multiple views with same image during ResourceReady load the image only 1 times");
3866 ToolkitTestApplication application;
3868 gResourceReadySignalCounter = 0;
3870 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
3871 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal05);
3872 application.GetScene().Add(gImageView1);
3874 application.SendNotification();
3875 application.Render();
3877 tet_infoline("Try to load 1 invalid.jpg image");
3878 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3879 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
3881 tet_infoline("Try to load 1 invalid2.jpg image");
3882 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3884 tet_infoline("Now we don't have any image to be loaded. Check event thread trigger failed.");
3885 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
3887 gImageView1.Unparent();
3888 gImageView1.Reset();
3893 int UtcDaliImageViewUseSameUrlWithAnimatedImageVisual(void)
3895 tet_infoline("Test multiple views with same image in animated image visual");
3896 ToolkitTestApplication application;
3898 gImageView1 = ImageView::New(TEST_WEBP_FILE_NAME);
3899 application.GetScene().Add(gImageView1);
3901 tet_infoline("Remove imageView and Create new imageView with same url");
3902 application.GetScene().Remove(gImageView1);
3903 gImageView2 = ImageView::New(TEST_WEBP_FILE_NAME);
3904 application.GetScene().Add(gImageView2);
3906 application.SendNotification();
3907 application.Render();
3909 tet_infoline("Check the ImageView load image successfully");
3910 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);