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 "dummy-control.h"
28 #include <test-encoded-image-buffer.h>
29 #include <test-native-image.h>
31 #include <dali-toolkit/dali-toolkit.h>
32 #include <dali-toolkit/devel-api/controls/control-devel.h>
33 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
34 #include <dali-toolkit/devel-api/styling/style-manager-devel.h>
35 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
36 #include <dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h>
37 #include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
38 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
39 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
40 #include <dali-toolkit/public-api/image-loader/image-url.h>
41 #include <dali-toolkit/public-api/image-loader/image.h>
42 #include <dali/devel-api/scripting/scripting.h>
45 using namespace Toolkit;
47 void utc_dali_toolkit_image_view_startup(void)
49 test_return_value = TET_UNDEF;
52 void utc_dali_toolkit_image_view_cleanup(void)
54 test_return_value = TET_PASS;
59 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
60 const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
62 const char* TEST_IMAGE_1 = TEST_RESOURCE_DIR "/TB-gloss.png";
63 const char* TEST_IMAGE_2 = TEST_RESOURCE_DIR "/tb-norm.png";
65 const char* TEST_BROKEN_IMAGE_DEFAULT = TEST_RESOURCE_DIR "/broken.png";
66 const char* TEST_BROKEN_IMAGE_S = TEST_RESOURCE_DIR "/broken_s.9.png";
67 const char* TEST_BROKEN_IMAGE_M = TEST_RESOURCE_DIR "/broken_m.9.png";
68 const char* TEST_BROKEN_IMAGE_L = TEST_RESOURCE_DIR "/broken_l.9.png";
69 const char* TEST_BROKEN_IMAGE_01 = TEST_RESOURCE_DIR "/button-up.9.png";
70 const char* TEST_BROKEN_IMAGE_02 = TEST_RESOURCE_DIR "/heartsframe.9.png";
72 // resolution: 34*34, pixel format: RGBA8888
73 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
74 // resolution: 600*600, pixel format: RGB888
75 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
77 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
78 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
80 const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
81 const char* TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
83 void TestUrl(ImageView imageView, const std::string url)
85 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
87 std::string urlActual;
88 DALI_TEST_CHECK(value.Get(urlActual));
89 DALI_TEST_EQUALS(urlActual, url, TEST_LOCATION);
94 int UtcDaliImageViewNewP(void)
96 ToolkitTestApplication application;
98 ImageView imageView = ImageView::New();
100 DALI_TEST_CHECK(imageView);
105 int UtcDaliImageViewNewUrlP(void)
107 ToolkitTestApplication application;
109 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
110 DALI_TEST_CHECK(imageView);
112 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
117 int UtcDaliImageViewConstructorP(void)
119 ToolkitTestApplication application;
123 DALI_TEST_CHECK(!imageView);
128 int UtcDaliImageViewCopyConstructorP(void)
130 ToolkitTestApplication application;
132 // Initialize an object, ref count == 1
133 ImageView imageView = ImageView::New();
135 ImageView copy(imageView);
136 DALI_TEST_CHECK(copy);
141 int UtcDaliImageViewMoveConstructor(void)
143 ToolkitTestApplication application;
145 ImageView imageView = ImageView::New();
146 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
147 imageView.SetProperty(Actor::Property::SENSITIVE, false);
148 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
150 ImageView moved = std::move(imageView);
151 DALI_TEST_CHECK(moved);
152 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
153 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
154 DALI_TEST_CHECK(!imageView);
159 int UtcDaliImageViewAssignmentOperatorP(void)
161 ToolkitTestApplication application;
163 ImageView imageView = ImageView::New();
165 ImageView copy(imageView);
166 DALI_TEST_CHECK(copy);
167 DALI_TEST_EQUALS(imageView, copy, TEST_LOCATION);
172 int UtcDaliImageViewMoveAssignment(void)
174 ToolkitTestApplication application;
176 ImageView imageView = ImageView::New();
177 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
178 imageView.SetProperty(Actor::Property::SENSITIVE, false);
179 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
182 moved = std::move(imageView);
183 DALI_TEST_CHECK(moved);
184 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
185 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
186 DALI_TEST_CHECK(!imageView);
191 int UtcDaliImageViewDownCastP(void)
193 ToolkitTestApplication application;
195 ImageView imageView = ImageView::New();
197 BaseHandle object(imageView);
199 ImageView imageView2 = ImageView::DownCast(object);
200 DALI_TEST_CHECK(imageView2);
202 ImageView imageView3 = DownCast<ImageView>(object);
203 DALI_TEST_CHECK(imageView3);
208 int UtcDaliImageViewDownCastN(void)
210 ToolkitTestApplication application;
212 BaseHandle unInitializedObject;
214 ImageView imageView1 = ImageView::DownCast(unInitializedObject);
215 DALI_TEST_CHECK(!imageView1);
217 ImageView imageView2 = DownCast<ImageView>(unInitializedObject);
218 DALI_TEST_CHECK(!imageView2);
223 int UtcDaliImageViewTypeRegistry(void)
225 ToolkitTestApplication application;
227 TypeRegistry typeRegistry = TypeRegistry::Get();
228 DALI_TEST_CHECK(typeRegistry);
230 TypeInfo typeInfo = typeRegistry.GetTypeInfo("ImageView");
231 DALI_TEST_CHECK(typeInfo);
233 BaseHandle handle = typeInfo.CreateInstance();
234 DALI_TEST_CHECK(handle);
236 ImageView imageView = ImageView::DownCast(handle);
237 DALI_TEST_CHECK(imageView);
242 int UtcDaliImageViewSetGetProperty01(void)
244 ToolkitTestApplication application;
246 ImageView imageView = ImageView::New();
248 Property::Index idx = imageView.GetPropertyIndex("image");
249 DALI_TEST_EQUALS(idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION);
251 imageView.SetProperty(idx, TEST_IMAGE_FILE_NAME);
252 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
257 int UtcDaliImageViewPreMultipliedAlphaPng(void)
259 ToolkitTestApplication application;
261 // Set up trace debug
262 TestGlAbstraction& gl = application.GetGlAbstraction();
263 TraceCallStack& textureTrace = gl.GetTextureTrace();
264 textureTrace.Enable(true);
266 Property::Map imageMap;
267 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
268 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
270 ImageView imageView1 = ImageView::New();
271 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
273 application.GetScene().Add(imageView1);
275 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
277 DALI_TEST_CHECK(value.Get(enable));
278 DALI_TEST_CHECK(enable); // Default value is true
280 // loading started, this waits for the loader thread for max 30 seconds
281 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
283 application.SendNotification();
284 application.Render();
286 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
287 DALI_TEST_CHECK(value.Get(enable));
288 DALI_TEST_CHECK(enable); // Keep true
290 // conventional alpha blending
291 Renderer renderer1 = imageView1.GetRendererAt(0);
292 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
293 DALI_TEST_CHECK(value.Get(enable));
294 DALI_TEST_CHECK(enable);
296 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
297 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
298 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
299 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
300 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
301 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
302 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
303 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
305 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
306 textureTrace.Reset();
308 // Disable pre-multiplied alpha blending
309 imageView1.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
312 Property::Map attributes;
313 DevelControl::DoAction(imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
315 // loading started, this waits for the loader thread for max 30 seconds
316 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
318 application.SendNotification();
319 application.Render();
321 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
322 DALI_TEST_CHECK(value.Get(enable));
323 DALI_TEST_CHECK(!enable);
325 // conventional alpha blending
326 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
327 DALI_TEST_CHECK(value.Get(enable));
328 DALI_TEST_CHECK(!enable);
330 srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
331 destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
332 srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
333 destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
334 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
335 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
336 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
337 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
339 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
340 textureTrace.Reset();
342 // Make a new ImageView using the same image
343 ImageView imageView2 = ImageView::New();
344 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
346 application.GetScene().Add(imageView2);
348 application.SendNotification();
349 application.Render();
351 Renderer renderer2 = imageView2.GetRendererAt(0);
352 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
353 DALI_TEST_CHECK(value.Get(enable));
354 DALI_TEST_CHECK(enable);
356 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
357 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
358 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
359 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
360 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
361 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
362 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
363 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
365 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
370 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
372 ToolkitTestApplication application;
374 // Set up trace debug
375 TestGlAbstraction& gl = application.GetGlAbstraction();
376 TraceCallStack& textureTrace = gl.GetTextureTrace();
377 textureTrace.Enable(true);
379 Property::Map imageMap;
380 imageMap[ImageVisual::Property::URL] = gImage_600_RGB;
381 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
383 ImageView imageView1 = ImageView::New();
384 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
386 application.GetScene().Add(imageView1);
388 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
390 DALI_TEST_CHECK(value.Get(enable));
391 DALI_TEST_CHECK(enable); // Default value is true
393 // loading started, this waits for the loader thread for max 30 seconds
394 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
396 application.SendNotification();
397 application.Render();
399 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
400 DALI_TEST_CHECK(value.Get(enable));
401 DALI_TEST_CHECK(!enable); // Should be false after loading
403 // conventional alpha blending
404 Renderer renderer1 = imageView1.GetRendererAt(0);
405 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
406 DALI_TEST_CHECK(value.Get(enable));
407 DALI_TEST_CHECK(!enable);
409 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
410 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
411 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
412 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
413 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
414 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
415 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
416 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
418 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
419 textureTrace.Reset();
421 ImageView imageView2 = ImageView::New();
422 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
424 // Disable pre-multiplied alpha blending
425 imageView2.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
427 application.GetScene().Add(imageView2);
429 application.SendNotification();
430 application.Render();
432 value = imageView2.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
433 DALI_TEST_CHECK(value.Get(enable));
434 DALI_TEST_CHECK(!enable);
436 // conventional alpha blending
437 Renderer renderer2 = imageView2.GetRendererAt(0);
438 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
439 DALI_TEST_CHECK(value.Get(enable));
440 DALI_TEST_CHECK(!enable);
442 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
443 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
444 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
445 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
446 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
447 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
448 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
449 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
451 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
456 int UtcDaliImageViewPixelArea(void)
458 // Test pixel area property
459 ToolkitTestApplication application;
461 static std::vector<UniformData> customUniforms =
463 UniformData("pixelArea", Property::Type::VECTOR4),
466 TestGraphicsController& graphics = application.GetGraphicsController();
467 graphics.AddCustomUniforms(customUniforms);
469 // Gif image, use AnimatedImageVisual internally
470 // Atlasing is applied to pack multiple frames, use custom wrap mode
471 ImageView gifView = ImageView::New();
472 const Vector4 pixelAreaVisual(0.f, 0.f, 2.f, 2.f);
473 gifView.SetProperty(ImageView::Property::IMAGE,
474 Property::Map().Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME).Add(ImageVisual::Property::PIXEL_AREA, pixelAreaVisual));
477 Integration::Scene stage = application.GetScene();
481 application.SendNotification();
482 application.Render(16);
484 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
486 application.SendNotification();
487 application.Render();
488 DALI_TEST_CHECK(gifView.GetRendererCount() == 1u);
490 const Vector4 fullTextureRect(0.f, 0.f, 1.f, 1.f);
491 // test that the pixel area value defined in the visual property map is registered on renderer
492 Renderer renderer = gifView.GetRendererAt(0);
493 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
494 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION);
496 // test that the shader has the default pixel area value registered.
497 Shader shader = renderer.GetShader();
498 pixelAreaValue = shader.GetProperty(shader.GetPropertyIndex("pixelArea"));
499 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION);
501 // test that the uniform uses the pixelArea property on the renderer.
502 TestGlAbstraction& gl = application.GetGlAbstraction();
503 Vector4 pixelAreaUniform;
504 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
505 DALI_TEST_EQUALS(pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
507 // set the pixelArea property on the control
508 const Vector4 pixelAreaControl(-1.f, -1.f, 3.f, 3.f);
509 gifView.SetProperty(ImageView::Property::PIXEL_AREA, pixelAreaControl);
510 application.SendNotification();
511 application.Render(16);
513 // check the pixelArea property on the control
514 pixelAreaValue = gifView.GetProperty(gifView.GetPropertyIndex("pixelArea"));
515 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION);
516 // test that the uniform uses the pixelArea property on the control.
517 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
518 DALI_TEST_EQUALS(pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
523 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
525 ToolkitTestApplication application;
526 TestGlAbstraction& gl = application.GetGlAbstraction();
527 const std::vector<GLuint>& textures = gl.GetBoundTextures();
528 size_t numTextures = textures.size();
530 // Async loading, no atlasing for big size image
531 ImageView imageView = ImageView::New(gImage_600_RGB);
533 // By default, Aysnc loading is used
534 application.GetScene().Add(imageView);
535 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
536 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
538 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
540 application.SendNotification();
541 application.Render(16);
542 application.SendNotification();
544 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
545 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
550 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
552 ToolkitTestApplication application;
554 //Async loading, automatic atlasing for small size image
555 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
557 callStack.Enable(true);
559 Property::Map imageMap;
561 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
562 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
563 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
564 imageMap[ImageVisual::Property::ATLASING] = true;
566 ImageView imageView = ImageView::New();
567 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
568 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
570 // By default, Aysnc loading is used
571 // loading is not started if the actor is offScene
573 application.GetScene().Add(imageView);
574 application.SendNotification();
575 application.Render(16);
576 application.Render(16);
577 application.SendNotification();
579 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
580 application.SendNotification();
581 application.Render(16);
582 application.Render(16);
583 application.SendNotification();
585 // loading started, this waits for the loader thread for max 30 seconds
586 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
588 application.SendNotification();
589 application.Render(16);
591 callStack.Enable(false);
593 TraceCallStack::NamedParams params;
594 params["width"] << 34;
595 params["height"] << 34;
596 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
601 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
603 ToolkitTestApplication application;
605 //Async loading, automatic atlasing for small size image
606 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
608 callStack.Enable(true);
610 Property::Map asyncLoadingMap;
611 asyncLoadingMap["url"] = gImage_34_RGBA;
612 asyncLoadingMap["desiredHeight"] = 34;
613 asyncLoadingMap["desiredWidth"] = 34;
614 asyncLoadingMap["synchronousLoading"] = false;
615 asyncLoadingMap["atlasing"] = true;
617 ImageView imageView = ImageView::New();
618 imageView.SetProperty(ImageView::Property::IMAGE, asyncLoadingMap);
620 application.GetScene().Add(imageView);
621 application.SendNotification();
622 application.Render(16);
623 application.Render(16);
624 application.SendNotification();
626 // loading started, this waits for the loader thread for max 30 seconds
627 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
629 application.SendNotification();
630 application.Render(16);
632 callStack.Enable(false);
634 TraceCallStack::NamedParams params;
635 params["width"] << 34;
636 params["height"] << 34;
637 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
642 int UtcDaliImageViewSyncLoading(void)
644 ToolkitTestApplication application;
646 tet_infoline("ImageView Testing sync loading and size using index key property map");
648 Property::Map syncLoadingMap;
649 syncLoadingMap[ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
650 syncLoadingMap[ImageVisual::Property::ATLASING] = true;
652 // Sync loading, no atlasing for big size image
654 ImageView imageView = ImageView::New();
656 // Sync loading is used
657 syncLoadingMap[ImageVisual::Property::URL] = gImage_600_RGB;
658 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
661 // Sync loading, automatic atlasing for small size image
663 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
665 callStack.Enable(true);
667 ImageView imageView = ImageView::New();
669 // Sync loading is used
670 syncLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
671 syncLoadingMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
672 syncLoadingMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
673 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
675 application.GetScene().Add(imageView);
676 application.SendNotification();
677 application.Render(16);
679 TraceCallStack::NamedParams params;
680 params["width"] << 34;
681 params["height"] << 34;
682 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
689 int UtcDaliImageViewSyncLoading02(void)
691 ToolkitTestApplication application;
693 tet_infoline("ImageView Testing sync loading and size using string key property map");
695 // Sync loading, automatic atlasing for small size image
697 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
699 callStack.Enable(true);
701 ImageView imageView = ImageView::New();
703 // Sync loading is used
704 Property::Map syncLoadingMap;
705 syncLoadingMap["url"] = gImage_34_RGBA;
706 syncLoadingMap["desiredHeight"] = 34;
707 syncLoadingMap["desiredWidth"] = 34;
708 syncLoadingMap["synchronousLoading"] = true;
709 syncLoadingMap["atlasing"] = true;
710 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
712 application.GetScene().Add(imageView);
713 application.SendNotification();
714 application.Render(16);
716 TraceCallStack::NamedParams params;
717 params["width"] << 34;
718 params["height"] << 34;
719 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
726 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
728 ToolkitTestApplication application;
729 TestGlAbstraction& gl = application.GetGlAbstraction();
730 const std::vector<GLuint>& textures = gl.GetBoundTextures();
731 size_t numTextures = textures.size();
733 // Get encoded raw-buffer image and generate url
734 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
735 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
737 // Async loading, no atlasing for big size image
738 ImageView imageView = ImageView::New(url.GetUrl());
740 // By default, Aysnc loading is used
741 application.GetScene().Add(imageView);
742 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
743 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
745 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
747 application.SendNotification();
748 application.Render(16);
749 application.SendNotification();
751 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
752 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
757 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
759 ToolkitTestApplication application;
761 // Get encoded raw-buffer image and generate url
762 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
763 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
764 ImageUrl url2 = Toolkit::Image::GenerateUrl(buffer);
766 // Generate url is not equal to url2
767 // NOTE : This behavior may changed when ImageUrl compare operator changed.
768 DALI_TEST_CHECK(url != url2);
769 // Generate url's string is equal to url2's string
770 DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
772 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
773 url2 = Toolkit::Image::GenerateUrl(buffer2);
775 // Check whethere two url are not equal
776 DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
778 // Async loading, automatic atlasing for small size image
779 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
781 callStack.Enable(true);
783 Property::Map imageMap;
785 imageMap[ImageVisual::Property::URL] = url.GetUrl();
786 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
787 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
788 imageMap[ImageVisual::Property::ATLASING] = true;
790 ImageView imageView = ImageView::New();
791 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
792 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
794 // By default, Aysnc loading is used
795 // loading is not started if the actor is offScene
797 application.GetScene().Add(imageView);
798 application.SendNotification();
799 application.Render(16);
800 application.Render(16);
801 application.SendNotification();
803 // Change url to url2
804 imageMap[ImageVisual::Property::URL] = url2.GetUrl();
805 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
807 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
808 application.SendNotification();
809 application.Render(16);
810 application.Render(16);
811 application.SendNotification();
813 // loading started, this waits for the loader thread for max 30 seconds
814 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
816 application.SendNotification();
817 application.Render(16);
819 callStack.Enable(false);
821 TraceCallStack::NamedParams params;
822 params["width"] << 34;
823 params["height"] << 34;
824 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
829 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
831 ToolkitTestApplication application;
833 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
835 // Get encoded raw-buffer image and generate url
836 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
837 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
839 // Sync loading, automatic atlasing for small size image
841 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
843 callStack.Enable(true);
845 ImageView imageView = ImageView::New();
847 // Sync loading is used
848 Property::Map syncLoadingMap;
849 syncLoadingMap["url"] = url.GetUrl();
850 syncLoadingMap["desiredHeight"] = 34;
851 syncLoadingMap["desiredWidth"] = 34;
852 syncLoadingMap["synchronousLoading"] = true;
853 syncLoadingMap["atlasing"] = true;
854 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
856 application.GetScene().Add(imageView);
857 application.SendNotification();
858 application.Render(16);
860 TraceCallStack::NamedParams params;
861 params["width"] << 34;
862 params["height"] << 34;
863 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
871 int UtcDaliImageViewAddedTexture(void)
873 ToolkitTestApplication application;
875 tet_infoline("ImageView Testing image view with texture provided manager url");
877 ImageView imageView = ImageView::New();
879 // empty texture is ok, though pointless from app point of view
881 std::string url = TextureManager::AddTexture(empty);
882 DALI_TEST_CHECK(url.size() > 0u);
884 Property::Map propertyMap;
885 propertyMap[ImageVisual::Property::URL] = url;
886 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
888 application.GetScene().Add(imageView);
889 application.SendNotification();
890 application.Render();
895 int UtcDaliImageViewSizeWithBackground(void)
897 ToolkitTestApplication application;
901 ImageView imageView = ImageView::New();
903 imageView.SetProperty(Control::Property::BACKGROUND,
905 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
906 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
907 {ImageVisual::Property::DESIRED_WIDTH, width},
908 {ImageVisual::Property::DESIRED_HEIGHT, height},
911 application.GetScene().Add(imageView);
912 application.SendNotification();
913 application.Render();
915 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
916 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
921 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
923 ToolkitTestApplication application;
925 int widthBackground = 100;
926 int heightBackground = 200;
930 ImageView imageView = ImageView::New();
932 imageView.SetProperty(Control::Property::BACKGROUND,
934 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
935 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
936 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
937 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground},
940 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio, 600x600 pixels
942 application.GetScene().Add(imageView);
943 application.SendNotification();
944 application.Render();
946 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
947 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
952 int UtcDaliImageViewHeightForWidthBackground(void)
954 ToolkitTestApplication application;
956 int widthBackground = 100;
957 int heightBackground = 200;
959 ImageView imageView = ImageView::New();
961 imageView.SetProperty(Control::Property::BACKGROUND,
962 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
963 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
964 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
965 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}});
967 application.GetScene().Add(imageView);
968 application.SendNotification();
969 application.Render();
971 Control control = Control::DownCast(imageView);
972 DALI_TEST_CHECK(control);
973 DALI_TEST_EQUALS(imageView.GetHeightForWidth(123.f), control.GetHeightForWidth(123.f), TEST_LOCATION);
974 DALI_TEST_EQUALS(imageView.GetWidthForHeight(321.f), control.GetWidthForHeight(321.f), TEST_LOCATION);
979 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
981 ToolkitTestApplication application;
983 int widthBackground = 100;
984 int heightBackground = 200;
988 ImageView imageView = ImageView::New();
990 imageView.SetProperty(Control::Property::BACKGROUND,
991 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
992 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
993 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
994 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}}); // 1 to 2 ratio
996 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio
998 application.GetScene().Add(imageView);
999 application.SendNotification();
1000 application.Render();
1002 DALI_TEST_EQUALS(imageView.GetHeightForWidth(width), (float)height, TEST_LOCATION);
1003 DALI_TEST_EQUALS(imageView.GetWidthForHeight(height), (float)width, TEST_LOCATION);
1008 int UtcDaliImageViewSetImageUrl(void)
1010 ToolkitTestApplication application;
1012 ImageView imageView = ImageView::New();
1013 imageView.SetImage(TEST_IMAGE_FILE_NAME);
1014 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
1016 imageView.SetImage(TEST_IMAGE_FILE_NAME2);
1017 TestUrl(imageView, TEST_IMAGE_FILE_NAME2);
1022 bool gResourceReadySignalFired = false;
1023 Vector3 gNaturalSize;
1025 void ResourceReadySignal(Control control)
1027 gResourceReadySignalFired = true;
1030 int UtcDaliImageViewCheckResourceReady(void)
1032 ToolkitTestApplication application;
1034 gResourceReadySignalFired = false;
1036 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1037 ImageView imageView = ImageView::New(TEST_GIF_FILE_NAME);
1039 imageView.SetProperty(Control::Property::BACKGROUND,
1040 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1041 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1042 {ImageVisual::Property::DESIRED_WIDTH, 100},
1043 {ImageVisual::Property::DESIRED_HEIGHT, 200}});
1045 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1047 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1049 application.GetScene().Add(imageView);
1051 // loading started, this waits for the loader thread
1052 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1054 application.SendNotification();
1055 application.Render(16);
1057 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1059 application.SendNotification();
1060 application.Render();
1062 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1064 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1069 int UtcDaliImageViewSetImageTypeChangesP(void)
1071 ToolkitTestApplication application;
1073 ImageView imageView = ImageView::New();
1074 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1076 application.GetScene().Add(imageView);
1080 Toolkit::Visual::Base visual;
1082 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1083 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1085 application.SendNotification();
1086 application.Render(16);
1088 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1090 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1091 DALI_TEST_CHECK(!visual); // Visual should be invalid
1094 imageView.SetImage("TEST_URL");
1096 application.SendNotification();
1097 application.Render(16);
1099 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1100 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1102 DALI_TEST_CHECK(value.Get(url)); // Value should NOT be empty
1103 DALI_TEST_CHECK(!value.Get(map)); // Value should be empty
1104 DALI_TEST_CHECK(visual); // Visual should be valid
1107 imageView.SetImage("");
1109 application.SendNotification();
1110 application.Render(16);
1112 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1113 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1115 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1117 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1118 DALI_TEST_CHECK(!visual); // Visual should be invalid
1120 // Set a URL in property map
1121 Property::Map propertyMap;
1122 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1123 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1125 application.SendNotification();
1126 application.Render(16);
1128 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1129 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1131 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1132 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1133 DALI_TEST_CHECK(visual); // Visual should be valid
1135 // Set a URL in property map again
1136 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1137 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1139 application.SendNotification();
1140 application.Render(16);
1142 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1143 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1145 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1146 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1147 DALI_TEST_CHECK(visual); // Visual should be valid
1149 // Set an empty URL in property map
1150 propertyMap[ImageVisual::Property::URL] = std::string();
1151 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1153 application.SendNotification();
1154 application.Render(16);
1156 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1157 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1159 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1160 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1161 DALI_TEST_CHECK(!visual); // Visual should be invalid
1163 // Set a URL in property map again
1164 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1165 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1167 application.SendNotification();
1168 application.Render(16);
1170 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1171 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1173 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1174 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1175 DALI_TEST_CHECK(visual); // Visual should be valid
1177 // Set an empty property map
1178 propertyMap.Clear();
1179 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1181 application.SendNotification();
1182 application.Render(16);
1184 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1185 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1187 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1188 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1189 DALI_TEST_CHECK(map.Empty()); // But PropertyMap should be empty
1190 DALI_TEST_CHECK(!visual); // Visual should be invalid
1195 int UtcDaliImageViewResourceUrlP(void)
1197 ToolkitTestApplication application;
1199 ImageView imageView = ImageView::New();
1200 DALI_TEST_CHECK(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>().empty());
1202 imageView.SetProperty(ImageView::Property::IMAGE, "TestString");
1203 DALI_TEST_EQUALS(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>(), "TestString", TEST_LOCATION);
1208 int UtcDaliImageViewReplaceImage(void)
1210 ToolkitTestApplication application;
1212 gResourceReadySignalFired = false;
1214 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1215 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1217 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1219 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1221 application.GetScene().Add(imageView);
1223 application.SendNotification();
1224 application.Render(16);
1226 // loading started, this waits for the loader thread for max 30 seconds
1227 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1229 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1231 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1233 gResourceReadySignalFired = false;
1235 imageView.SetImage(TEST_IMAGE_2);
1237 application.SendNotification();
1238 application.Render(16);
1240 // loading started, this waits for the loader thread for max 30 seconds
1241 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1243 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1245 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1247 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1252 void OnRelayoutOverride(Size size)
1254 gNaturalSize = size; // Size Relayout is using
1257 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1259 ToolkitTestApplication application;
1261 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1262 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1263 imageView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1265 DummyControl dummyControl = DummyControl::New(true);
1266 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1267 dummyControl.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
1269 dummyControl.Add(imageView);
1270 dummyImpl.SetRelayoutCallback(&OnRelayoutOverride);
1271 application.GetScene().Add(dummyControl);
1273 application.SendNotification();
1274 application.Render();
1276 // loading started, this waits for the loader thread for max 30 seconds
1277 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1279 DALI_TEST_EQUALS(gNaturalSize.width, 1024.0f, TEST_LOCATION);
1280 DALI_TEST_EQUALS(gNaturalSize.height, 1024.0f, TEST_LOCATION);
1282 gNaturalSize = Vector3::ZERO;
1284 imageView.SetImage(gImage_600_RGB);
1286 // Waiting for resourceReady so SendNotifcation not called here.
1288 // loading started, this waits for the loader thread for max 30 seconds
1289 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1291 // Trigger a potential relayout
1292 application.SendNotification();
1293 application.Render();
1295 DALI_TEST_EQUALS(gNaturalSize.width, 600.0f, TEST_LOCATION);
1296 DALI_TEST_EQUALS(gNaturalSize.height, 600.0f, TEST_LOCATION);
1301 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1303 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1305 ToolkitTestApplication application;
1307 gResourceReadySignalFired = false;
1309 Property::Map imageMap;
1311 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1312 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1314 tet_infoline("Creating ImageView without URL so image does not start loading");
1315 ImageView imageView = ImageView::New();
1316 tet_infoline("Connect to image loaded signal before setting image");
1317 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1318 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1319 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1321 // loading started, this waits for the loader thread
1322 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1324 application.SendNotification();
1325 application.Render(16);
1327 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1332 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1334 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1336 ToolkitTestApplication application;
1338 gResourceReadySignalFired = false;
1340 Property::Map imageMap;
1342 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1343 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1345 ImageView imageView = ImageView::New();
1346 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1347 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1349 // loading started, this waits for the loader thread
1350 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1352 application.SendNotification();
1353 application.Render(16);
1355 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1356 gResourceReadySignalFired = false;
1358 ImageView imageViewWithExistingImage = ImageView::New();
1359 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1360 imageViewWithExistingImage.SetProperty(ImageView::Property::IMAGE, imageMap);
1362 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1367 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1369 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1371 ToolkitTestApplication application;
1373 gResourceReadySignalFired = false;
1375 Property::Map imageImmediateLoadingMap;
1376 imageImmediateLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1377 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1379 tet_infoline("Immediate load an image");
1380 ImageView imageView = ImageView::New();
1381 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1382 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
1384 // loading started, this waits for the loader thread
1385 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1387 application.SendNotification();
1388 application.Render(16);
1390 tet_infoline("Check image loaded");
1391 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1392 gResourceReadySignalFired = false;
1394 tet_infoline("Create another ImageView with the same URL");
1395 ImageView imageViewWithExistingImage = ImageView::New(gImage_34_RGBA);
1396 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1397 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1399 application.GetScene().Add(imageViewWithExistingImage);
1401 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1406 int UtcDaliImageViewPaddingProperty(void)
1408 ToolkitTestApplication application;
1410 ImageView imageView = ImageView::New();
1411 Property::Map imagePropertyMap;
1412 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1413 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
1414 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1415 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1416 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1417 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1418 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1419 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1420 application.GetScene().Add(imageView);
1422 application.SendNotification();
1423 application.Render();
1425 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1427 ImageView childImage = ImageView::New();
1428 childImage.SetBackgroundColor(Color::BLACK);
1429 childImage.SetProperty(Actor::Property::SIZE, Vector2(10.f, 10.f));
1430 imageView.Add(childImage);
1432 application.SendNotification();
1433 application.Render();
1435 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1436 DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
1438 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1439 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1440 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1441 Property::Map resultMap;
1442 imageVisual.CreatePropertyMap(resultMap);
1444 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1445 DALI_TEST_CHECK(transformValue);
1446 Property::Map* retMap = transformValue->GetMap();
1447 DALI_TEST_CHECK(retMap);
1449 // Image Visual should be positioned depending on ImageView's padding
1450 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1455 int UtcDaliImageViewPaddingProperty02(void)
1457 ToolkitTestApplication application;
1459 ImageView imageView = ImageView::New();
1460 Property::Map imagePropertyMap;
1461 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1462 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1463 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1464 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1465 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1466 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1467 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1468 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1469 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1470 application.GetScene().Add(imageView);
1472 application.SendNotification();
1473 application.Render();
1475 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1477 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1478 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1479 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1480 Property::Map resultMap;
1481 imageVisual.CreatePropertyMap(resultMap);
1483 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1484 DALI_TEST_CHECK(transformValue);
1485 Property::Map* retMap = transformValue->GetMap();
1486 DALI_TEST_CHECK(retMap);
1488 // Image Visual should be positioned depending on ImageView's padding
1489 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1494 int UtcDaliImageViewPaddingProperty03(void)
1496 tet_infoline("Test Setting Image Padding then removing it.");
1498 ToolkitTestApplication application;
1500 ImageView imageView = ImageView::New();
1501 Property::Map imagePropertyMap;
1502 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1503 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1504 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1505 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1506 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1507 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1508 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1509 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1510 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1511 application.GetScene().Add(imageView);
1513 application.SendNotification();
1514 application.Render();
1516 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1518 tet_infoline("Remove Padding and test Visual is position correctly");
1520 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1522 application.SendNotification();
1523 application.Render();
1525 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1526 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1527 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1528 Property::Map resultMap;
1529 imageVisual.CreatePropertyMap(resultMap);
1531 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1532 DALI_TEST_CHECK(transformValue);
1533 Property::Map* retMap = transformValue->GetMap();
1534 DALI_TEST_CHECK(retMap);
1536 // Image Visual should be positioned depending on ImageView's padding
1537 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1542 int UtcDaliImageViewPaddingProperty04(void)
1544 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1546 ToolkitTestApplication application;
1548 ImageView imageView = ImageView::New();
1549 Property::Map imagePropertyMap;
1550 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1551 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1552 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1553 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1554 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FILL;
1555 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1556 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1557 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1558 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1559 application.GetScene().Add(imageView);
1561 application.SendNotification();
1562 application.Render();
1564 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1566 tet_infoline("Remove Padding and test Visual is position correctly");
1568 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1570 application.SendNotification();
1571 application.Render();
1573 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1574 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1575 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1576 Property::Map resultMap;
1577 imageVisual.CreatePropertyMap(resultMap);
1579 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1580 DALI_TEST_CHECK(transformValue);
1581 Property::Map* retMap = transformValue->GetMap();
1582 DALI_TEST_CHECK(retMap);
1584 // Image Visual should be positioned depending on ImageView's padding
1585 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1590 int UtcDaliImageViewTransformTest01(void)
1592 tet_infoline("Test Setting a offset transform on the ImageView");
1594 ToolkitTestApplication application;
1596 ImageView imageView = ImageView::New();
1597 Property::Map imagePropertyMap;
1598 imagePropertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE)
1599 .Add(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/Kid1.svg")
1600 .Add(ImageVisual::Property::DESIRED_WIDTH, 120)
1601 .Add(ImageVisual::Property::DESIRED_HEIGHT, 120)
1602 .Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL)
1603 .Add(Visual::Property::TRANSFORM,
1604 Property::Map().Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1605 Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE))
1606 .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(8, 8)));
1608 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1609 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1610 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1611 application.GetScene().Add(imageView);
1613 application.SendNotification();
1614 application.Render();
1616 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1617 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1618 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1619 Property::Map resultMap;
1620 imageVisual.CreatePropertyMap(resultMap);
1622 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1623 DALI_TEST_CHECK(transformValue);
1624 Property::Map* retMap = transformValue->GetMap();
1625 DALI_TEST_CHECK(retMap);
1627 // Image Visual should be positioned depending on ImageView's padding
1628 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(8, 8), TEST_LOCATION);
1629 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);
1634 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1636 ToolkitTestApplication application;
1638 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1639 ImageView imageView = ImageView::New();
1640 Property::Map imageMap;
1641 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1642 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_34_RGBA;
1643 imageMap[Toolkit::ImageVisual::Property::ATLASING] = true;
1644 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1645 application.GetScene().Add(imageView);
1647 // Trigger a potential relayout
1648 application.SendNotification();
1649 application.Render();
1651 Vector3 naturalSize = imageView.GetNaturalSize();
1653 DALI_TEST_EQUALS(naturalSize.width, 34.0f, TEST_LOCATION);
1654 DALI_TEST_EQUALS(naturalSize.height, 34.0f, TEST_LOCATION);
1659 int UtcDaliImageViewFillMode(void)
1661 ToolkitTestApplication application;
1663 tet_infoline("Create an ImageVisual without padding and set the fill-mode to fill");
1665 ImageView imageView = ImageView::New();
1666 Property::Map imageMap;
1667 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1668 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB);
1669 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL);
1671 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1673 application.GetScene().Add(imageView);
1675 // Trigger a potential relayout
1676 application.SendNotification();
1677 application.Render();
1679 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1680 Property::Map returnedMap;
1681 visual.CreatePropertyMap(returnedMap);
1683 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1684 DALI_TEST_CHECK(value);
1685 Property::Map* map = value->GetMap();
1686 DALI_TEST_CHECK(map);
1688 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1689 DALI_TEST_CHECK(value);
1690 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION);
1692 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1693 DALI_TEST_CHECK(value);
1694 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1699 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1701 ToolkitTestApplication application;
1703 tet_infoline("Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )");
1704 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1706 ImageView imageView = ImageView::New();
1707 Property::Map imageMap;
1708 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1709 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1710 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
1712 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1713 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1715 application.GetScene().Add(imageView);
1717 // Trigger a potential relayout
1718 application.SendNotification();
1719 application.Render();
1721 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1722 Property::Map returnedMap;
1723 visual.CreatePropertyMap(returnedMap);
1725 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1726 DALI_TEST_CHECK(value);
1727 Property::Map* map = value->GetMap();
1728 DALI_TEST_CHECK(map);
1731 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1732 DALI_TEST_CHECK(value);
1733 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION);
1735 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1736 DALI_TEST_CHECK(value);
1737 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1739 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1740 DALI_TEST_CHECK(value);
1741 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
1746 int UtcDaliImageViewFittingModesFill(void)
1748 ToolkitTestApplication application;
1750 tet_infoline("Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )");
1751 tet_infoline(" There should be no need to change the transform, only size is changed to fit view");
1753 ImageView imageView = ImageView::New();
1754 Property::Map imageMap;
1755 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1756 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1757 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL);
1759 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1760 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1762 application.GetScene().Add(imageView);
1764 // Trigger a potential relayout
1765 application.SendNotification();
1766 application.Render();
1768 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1769 Property::Map returnedMap;
1770 visual.CreatePropertyMap(returnedMap);
1772 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1773 DALI_TEST_CHECK(value);
1774 Property::Map* map = value->GetMap();
1775 DALI_TEST_CHECK(map);
1777 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1778 DALI_TEST_CHECK(value);
1779 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Change the internal size according to the image view size
1781 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1782 DALI_TEST_CHECK(value);
1783 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1785 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1786 DALI_TEST_CHECK(value);
1787 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1792 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1794 ToolkitTestApplication application;
1796 tet_infoline("Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )");
1797 tet_infoline(" offset or size is the same as view, but adjust internally using pixelArea ");
1799 ImageView imageView = ImageView::New();
1800 Property::Map imageMap;
1801 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1802 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1803 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO);
1805 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1806 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 500));
1808 application.GetScene().Add(imageView);
1810 // Trigger a potential relayout
1811 application.SendNotification();
1812 application.Render();
1814 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1815 Property::Map returnedMap;
1816 visual.CreatePropertyMap(returnedMap);
1818 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1819 DALI_TEST_CHECK(value);
1820 Property::Map* map = value->GetMap();
1821 DALI_TEST_CHECK(map);
1824 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1825 DALI_TEST_CHECK(value);
1826 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 500), TEST_LOCATION); // Change the internal size according to the image view size
1828 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1829 DALI_TEST_CHECK(value);
1830 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1832 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1833 DALI_TEST_CHECK(value);
1834 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1839 int UtcDaliImageViewFittingModesCenter01(void)
1841 ToolkitTestApplication application;
1843 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [700,700] )");
1844 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1846 ImageView imageView = ImageView::New();
1847 Property::Map imageMap;
1848 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1849 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1850 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1852 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1853 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1855 application.GetScene().Add(imageView);
1857 // Trigger a potential relayout
1858 application.SendNotification();
1859 application.Render();
1861 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1862 Property::Map returnedMap;
1863 visual.CreatePropertyMap(returnedMap);
1865 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1866 DALI_TEST_CHECK(value);
1867 Property::Map* map = value->GetMap();
1868 DALI_TEST_CHECK(map);
1870 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1871 DALI_TEST_CHECK(value);
1872 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1874 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1875 DALI_TEST_CHECK(value);
1876 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1878 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1879 DALI_TEST_CHECK(value);
1880 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1885 int UtcDaliImageViewFittingModesCenter02(void)
1887 ToolkitTestApplication application;
1889 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [500,500] )");
1890 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1892 ImageView imageView = ImageView::New();
1893 Property::Map imageMap;
1894 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1895 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1896 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1898 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1899 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1901 application.GetScene().Add(imageView);
1903 // Trigger a potential relayout
1904 application.SendNotification();
1905 application.Render();
1907 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1908 Property::Map returnedMap;
1909 visual.CreatePropertyMap(returnedMap);
1911 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1912 DALI_TEST_CHECK(value);
1913 Property::Map* map = value->GetMap();
1914 DALI_TEST_CHECK(map);
1916 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1917 DALI_TEST_CHECK(value);
1918 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1920 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1921 DALI_TEST_CHECK(value);
1922 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1924 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1925 DALI_TEST_CHECK(value);
1926 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1931 int UtcDaliImageViewFittingModesFitHeight01(void)
1933 ToolkitTestApplication application;
1935 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )");
1937 ImageView imageView = ImageView::New();
1938 Property::Map imageMap;
1939 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1940 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1941 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1943 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1944 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1946 application.GetScene().Add(imageView);
1948 // Trigger a potential relayout
1949 application.SendNotification();
1950 application.Render();
1952 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1953 Property::Map returnedMap;
1954 visual.CreatePropertyMap(returnedMap);
1956 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1957 DALI_TEST_CHECK(value);
1958 Property::Map* map = value->GetMap();
1959 DALI_TEST_CHECK(map);
1961 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1962 DALI_TEST_CHECK(value);
1963 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 700), TEST_LOCATION); // Change the internal size according to the image view size
1965 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1966 DALI_TEST_CHECK(value);
1967 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1969 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1970 DALI_TEST_CHECK(value);
1971 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1976 int UtcDaliImageViewFittingModesFitHeight02(void)
1978 ToolkitTestApplication application;
1980 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )");
1982 ImageView imageView = ImageView::New();
1983 Property::Map imageMap;
1984 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1985 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
1986 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1988 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1989 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
1991 application.GetScene().Add(imageView);
1993 // Trigger a potential relayout
1994 application.SendNotification();
1995 application.Render();
1997 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1998 Property::Map returnedMap;
1999 visual.CreatePropertyMap(returnedMap);
2001 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2002 DALI_TEST_CHECK(value);
2003 Property::Map* map = value->GetMap();
2004 DALI_TEST_CHECK(map);
2006 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2007 DALI_TEST_CHECK(value);
2008 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2010 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2011 DALI_TEST_CHECK(value);
2012 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2014 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2015 DALI_TEST_CHECK(value);
2016 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2021 int UtcDaliImageViewFittingModesFitWidth01(void)
2023 ToolkitTestApplication application;
2025 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )");
2027 ImageView imageView = ImageView::New();
2028 Property::Map imageMap;
2029 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2030 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2031 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2033 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2034 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2036 application.GetScene().Add(imageView);
2038 // Trigger a potential relayout
2039 application.SendNotification();
2040 application.Render();
2042 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2043 Property::Map returnedMap;
2044 visual.CreatePropertyMap(returnedMap);
2046 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2047 DALI_TEST_CHECK(value);
2048 Property::Map* map = value->GetMap();
2049 DALI_TEST_CHECK(map);
2051 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2052 DALI_TEST_CHECK(value);
2053 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2055 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2056 DALI_TEST_CHECK(value);
2057 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2059 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2060 DALI_TEST_CHECK(value);
2061 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
2066 int UtcDaliImageViewFittingModesFitWidth02(void)
2068 ToolkitTestApplication application;
2070 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )");
2072 ImageView imageView = ImageView::New();
2073 Property::Map imageMap;
2074 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2075 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2076 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2078 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2079 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2081 application.GetScene().Add(imageView);
2083 // Trigger a potential relayout
2084 application.SendNotification();
2085 application.Render();
2087 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2088 Property::Map returnedMap;
2089 visual.CreatePropertyMap(returnedMap);
2091 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2092 DALI_TEST_CHECK(value);
2093 Property::Map* map = value->GetMap();
2094 DALI_TEST_CHECK(map);
2096 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2097 DALI_TEST_CHECK(value);
2098 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 600), TEST_LOCATION); // Change the internal size according to the image view size
2100 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2101 DALI_TEST_CHECK(value);
2102 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2104 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2105 DALI_TEST_CHECK(value);
2106 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2111 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2113 ToolkitTestApplication application;
2115 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2117 ImageView imageView = ImageView::New();
2119 // 1. Render using FittingMode::SHRINK_TO_FIT
2120 Property::Map imageMap;
2121 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2122 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2123 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2125 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2126 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2128 application.GetScene().Add(imageView);
2130 // Trigger a potential relayout
2131 application.SendNotification();
2132 application.Render();
2134 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2135 Property::Map returnedMap;
2136 visual.CreatePropertyMap(returnedMap);
2138 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2139 DALI_TEST_CHECK(value);
2140 Property::Map* map = value->GetMap();
2141 DALI_TEST_CHECK(map);
2143 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2144 DALI_TEST_CHECK(value);
2145 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2147 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2148 DALI_TEST_CHECK(value);
2149 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2151 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2152 DALI_TEST_CHECK(value);
2153 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2155 // 2. Render again using DevelVisaul::CENTER
2156 Property::Map imageMap2;
2157 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2158 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2159 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2161 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2162 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2164 application.GetScene().Add(imageView);
2166 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2168 // Trigger a potential relayout
2169 application.SendNotification();
2170 application.Render();
2172 returnedMap.Clear();
2173 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2175 visual.CreatePropertyMap(returnedMap);
2177 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2178 DALI_TEST_CHECK(value);
2179 map = value->GetMap();
2180 DALI_TEST_CHECK(map);
2182 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2183 DALI_TEST_CHECK(value);
2184 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2186 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2187 DALI_TEST_CHECK(value);
2188 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2190 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2191 DALI_TEST_CHECK(value);
2192 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2194 // 3. Render again using before fittingMode
2195 Property::Map imageMap3;
2196 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2197 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2198 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2200 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2201 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2203 application.GetScene().Add(imageView);
2205 // Trigger a potential relayout
2206 application.SendNotification();
2207 application.Render();
2209 returnedMap.Clear();
2210 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2211 visual.CreatePropertyMap(returnedMap);
2213 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2214 DALI_TEST_CHECK(value);
2215 map = value->GetMap();
2216 DALI_TEST_CHECK(map);
2218 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2219 DALI_TEST_CHECK(value);
2220 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2222 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2223 DALI_TEST_CHECK(value);
2224 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2226 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2227 DALI_TEST_CHECK(value);
2228 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2233 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2235 ToolkitTestApplication application;
2237 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2239 ImageView imageView = ImageView::New();
2241 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2242 Property::Map imageMap;
2243 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2244 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2245 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2247 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2248 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2250 application.GetScene().Add(imageView);
2252 // Trigger a potential relayout
2253 application.SendNotification();
2254 application.Render();
2256 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2257 Property::Map returnedMap;
2258 visual.CreatePropertyMap(returnedMap);
2260 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2261 DALI_TEST_CHECK(value);
2262 Property::Map* map = value->GetMap();
2263 DALI_TEST_CHECK(map);
2265 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2266 DALI_TEST_CHECK(value);
2267 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2269 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2270 DALI_TEST_CHECK(value);
2271 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2273 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2274 DALI_TEST_CHECK(value);
2275 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2277 // 2. Render again using DevelVisaul::CENTER
2278 Property::Map imageMap2;
2279 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2280 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2281 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2283 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2284 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2286 application.GetScene().Add(imageView);
2288 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2290 // Trigger a potential relayout
2291 application.SendNotification();
2292 application.Render();
2294 returnedMap.Clear();
2295 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2297 visual.CreatePropertyMap(returnedMap);
2299 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2300 DALI_TEST_CHECK(value);
2301 map = value->GetMap();
2302 DALI_TEST_CHECK(map);
2304 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2305 DALI_TEST_CHECK(value);
2306 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2308 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2309 DALI_TEST_CHECK(value);
2310 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2312 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2313 DALI_TEST_CHECK(value);
2314 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2316 // 3. Render again using before fittingMode
2317 Property::Map imageMap3;
2318 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2319 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2320 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2322 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2323 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2325 application.GetScene().Add(imageView);
2327 // Trigger a potential relayout
2328 application.SendNotification();
2329 application.Render();
2331 returnedMap.Clear();
2332 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2333 visual.CreatePropertyMap(returnedMap);
2335 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2336 DALI_TEST_CHECK(value);
2337 map = value->GetMap();
2338 DALI_TEST_CHECK(map);
2340 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2341 DALI_TEST_CHECK(value);
2342 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2344 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2345 DALI_TEST_CHECK(value);
2346 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2348 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2349 DALI_TEST_CHECK(value);
2350 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2355 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2357 ToolkitTestApplication application;
2359 tet_infoline("Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )");
2361 ImageView imageView = ImageView::New();
2362 Property::Map imageMap;
2363 imageMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE);
2364 imageMap.Add(Toolkit::ImageVisual::Property::URL, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME); // 249x169 image
2366 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2367 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
2369 application.GetScene().Add(imageView);
2371 // Trigger a potential relayout
2372 application.SendNotification();
2373 application.Render();
2375 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2376 Property::Map returnedMap;
2377 visual.CreatePropertyMap(returnedMap);
2379 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2380 DALI_TEST_CHECK(value);
2381 Property::Map* map = value->GetMap();
2382 DALI_TEST_CHECK(map);
2384 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2385 DALI_TEST_CHECK(value);
2386 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Relative size so will take up 100%
2388 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2389 DALI_TEST_CHECK(value);
2390 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2392 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2393 DALI_TEST_CHECK(value);
2394 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2399 int UtcDaliImageViewCustomShader(void)
2401 ToolkitTestApplication application;
2403 // Set a custom shader with an image url
2405 Property::Map properties;
2406 Property::Map shader;
2407 const std::string vertexShader = "Foobar";
2408 const std::string fragmentShader = "Foobar";
2409 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2410 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2412 properties[Visual::Property::TYPE] = Visual::IMAGE;
2413 properties[Visual::Property::SHADER] = shader;
2414 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2416 ImageView imageView = ImageView::New();
2417 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2419 application.GetScene().Add(imageView);
2421 application.SendNotification();
2422 application.Render();
2424 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2426 Renderer renderer = imageView.GetRendererAt(0);
2427 Shader shader2 = renderer.GetShader();
2428 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2429 Property::Map* map = value.GetMap();
2430 DALI_TEST_CHECK(map);
2432 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2433 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2435 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2436 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2439 // Set a custom shader after setting an image url
2441 Property::Map properties;
2442 Property::Map shader;
2443 const std::string vertexShader = "Foobar";
2444 const std::string fragmentShader = "Foobar";
2445 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2446 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2448 properties[Visual::Property::SHADER] = shader;
2450 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
2451 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2453 application.GetScene().Add(imageView);
2455 application.SendNotification();
2456 application.Render();
2458 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2460 Renderer renderer = imageView.GetRendererAt(0);
2461 Shader shader2 = renderer.GetShader();
2462 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2463 Property::Map* map = value.GetMap();
2464 DALI_TEST_CHECK(map);
2466 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2467 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2469 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2470 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2473 // Set a custom shader before setting an image url
2475 Property::Map properties;
2476 Property::Map shader;
2477 const std::string vertexShader = "Foobar";
2478 const std::string fragmentShader = "Foobar";
2479 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2480 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2482 properties[Visual::Property::SHADER] = shader;
2484 ImageView imageView = ImageView::New();
2485 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2486 imageView.SetProperty(ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME);
2488 application.GetScene().Add(imageView);
2490 application.SendNotification();
2491 application.Render();
2492 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2494 Renderer renderer = imageView.GetRendererAt(0);
2495 Shader shader2 = renderer.GetShader();
2496 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2497 Property::Map* map = value.GetMap();
2498 DALI_TEST_CHECK(map);
2500 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2501 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2503 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2504 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2507 // Set a custom shader after setting a property map
2509 Property::Map properties;
2510 Property::Map shader;
2511 const std::string vertexShader = "Foobar";
2512 const std::string fragmentShader = "Foobar";
2513 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2514 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2516 properties[Visual::Property::SHADER] = shader;
2518 Property::Map properties1;
2519 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2520 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2522 ImageView imageView = ImageView::New();
2523 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2524 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2526 application.GetScene().Add(imageView);
2528 application.SendNotification();
2529 application.Render();
2530 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2532 Renderer renderer = imageView.GetRendererAt(0);
2533 Shader shader2 = renderer.GetShader();
2534 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2535 Property::Map* map = value.GetMap();
2536 DALI_TEST_CHECK(map);
2538 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2539 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2541 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2542 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2545 // Set a custom shader before setting a property map
2547 Property::Map properties;
2548 Property::Map shader;
2549 const std::string vertexShader = "Foobar";
2550 const std::string fragmentShader = "Foobar";
2551 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2552 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2554 properties[Visual::Property::SHADER] = shader;
2556 Property::Map properties1;
2557 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2558 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2560 ImageView imageView = ImageView::New();
2561 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2562 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2564 application.GetScene().Add(imageView);
2566 application.SendNotification();
2567 application.Render();
2568 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2570 Renderer renderer = imageView.GetRendererAt(0);
2571 Shader shader2 = renderer.GetShader();
2572 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2573 Property::Map* map = value.GetMap();
2574 DALI_TEST_CHECK(map);
2576 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2577 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2579 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2580 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2588 static int gFailCounter = 0;
2589 const int MAX_RETRIES(3);
2591 void ReloadImage(ImageView imageView)
2593 Property::Map imageImmediateLoadingMap;
2594 imageImmediateLoadingMap[ImageVisual::Property::URL] = "Non-existant-image.jpg";
2595 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
2597 tet_infoline("Immediate load an image");
2598 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
2601 void ResourceFailedReload(Control control)
2604 if(gFailCounter < MAX_RETRIES)
2606 ReloadImage(ImageView::DownCast(control));
2611 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2613 tet_infoline("Test reloading failed image from within signal handler.");
2615 ToolkitTestApplication application;
2619 ImageView imageView = ImageView::New();
2620 imageView.ResourceReadySignal().Connect(&ResourceFailedReload);
2621 DALI_TEST_EQUALS(gFailCounter, 0, TEST_LOCATION);
2622 ReloadImage(imageView);
2624 // loading started, this waits for the loader thread to complete
2625 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2626 application.SendNotification();
2628 DALI_TEST_EQUALS(gFailCounter, 1, TEST_LOCATION);
2630 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2631 application.SendNotification();
2633 DALI_TEST_EQUALS(gFailCounter, 2, TEST_LOCATION);
2635 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2636 application.SendNotification();
2637 DALI_TEST_EQUALS(gFailCounter, 3, TEST_LOCATION);
2642 int UtcDaliImageViewLoadRemoteSVG(void)
2644 tet_infoline("Test load from a remote server.");
2646 ToolkitTestApplication application;
2647 Toolkit::ImageView imageView;
2648 imageView = Toolkit::ImageView::New();
2649 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2650 // Victor. Temporary (or permanent?) update as the url above seems not to work from time to time ...
2651 // imageView.SetImage("https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/SVG_logo.svg/64px-SVG_logo.svg.png");
2652 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2653 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2654 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2655 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2657 application.GetScene().Add(imageView);
2659 DALI_TEST_CHECK(imageView);
2661 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2663 application.SendNotification();
2665 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2667 application.SendNotification();
2668 application.Render();
2670 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2675 int UtcDaliImageViewSyncSVGLoading(void)
2677 ToolkitTestApplication application;
2679 tet_infoline("ImageView Testing SVG image sync loading");
2681 // Sync loading, automatic atlasing for small size image
2683 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2685 callStack.Enable(true);
2687 ImageView imageView = ImageView::New();
2689 // Sync loading is used
2690 Property::Map syncLoadingMap;
2691 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2692 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2693 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2694 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2696 application.GetScene().Add(imageView);
2697 DALI_TEST_CHECK(imageView);
2699 application.SendNotification();
2700 application.Render(16);
2701 Vector3 naturalSize = imageView.GetNaturalSize();
2703 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2704 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2709 int UtcDaliImageViewAsyncSVGLoading(void)
2711 ToolkitTestApplication application;
2713 tet_infoline("ImageView Testing SVG image async loading");
2715 // Sync loading, automatic atlasing for small size image
2717 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2719 callStack.Enable(true);
2721 ImageView imageView = ImageView::New();
2723 // Sync loading is used
2724 Property::Map syncLoadingMap;
2725 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2726 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2727 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2728 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2730 application.GetScene().Add(imageView);
2731 DALI_TEST_CHECK(imageView);
2733 application.SendNotification();
2734 application.Render(16);
2735 Vector3 naturalSize = imageView.GetNaturalSize();
2737 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2738 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2743 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2745 ToolkitTestApplication application;
2747 tet_infoline("ImageView Testing SVG image async loading");
2749 // Sync loading, automatic atlasing for small size image
2751 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2753 callStack.Enable(true);
2755 ImageView imageView = ImageView::New();
2757 // Sync loading is used
2758 Property::Map syncLoadingMap;
2759 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2760 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2762 // Check to set invalid value
2763 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2764 // Check if error log is outputted when setting other value like string.
2765 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2766 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5));
2767 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2769 application.GetScene().Add(imageView);
2770 DALI_TEST_CHECK(imageView);
2772 application.SendNotification();
2773 application.Render(16);
2774 Vector3 naturalSize = imageView.GetNaturalSize();
2775 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2776 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2778 Property::Value value = imageView.GetProperty(ImageView::Property::IMAGE);
2779 Property::Map* map = value.GetMap();
2780 DALI_TEST_CHECK(map);
2782 Property::Value* sync = map->Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING);
2783 DALI_TEST_CHECK(sync);
2784 DALI_TEST_EQUALS(false, sync->Get<bool>(), TEST_LOCATION);
2789 int UtcDaliImageViewSvgLoadingFailure(void)
2791 ToolkitTestApplication application;
2793 // Local svg file - invalid file path
2795 gResourceReadySignalFired = false;
2797 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2798 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2799 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2801 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2803 application.GetScene().Add(imageView);
2805 application.SendNotification();
2806 application.Render(16);
2808 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2809 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2810 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2813 // Local svg file - invalid file
2815 gResourceReadySignalFired = false;
2817 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.svg");
2818 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2819 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2821 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2823 application.GetScene().Add(imageView);
2825 application.SendNotification();
2826 application.Render(16);
2828 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2829 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2830 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2835 gResourceReadySignalFired = false;
2837 ImageView imageView = ImageView::New("https://bar.org/foobar.svg");
2838 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2839 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2841 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2843 application.GetScene().Add(imageView);
2845 application.SendNotification();
2847 // loading started, this waits for the loader thread
2848 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2850 application.SendNotification();
2851 application.Render(16);
2853 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2854 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2855 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2861 int UtcDaliImageViewSvgRasterizationFailure(void)
2863 ToolkitTestApplication application;
2865 gResourceReadySignalFired = false;
2867 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/svg1.svg");
2868 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2869 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2871 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2873 application.GetScene().Add(imageView);
2875 application.SendNotification();
2877 // loading started, this waits for the loader thread
2878 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2880 application.SendNotification();
2881 application.Render(16);
2883 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2884 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2885 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::READY, TEST_LOCATION);
2888 gResourceReadySignalFired = false;
2891 imageView.SetProperty(Actor::Property::SIZE, Vector2(0.f, 0.f));
2893 application.SendNotification();
2895 // rasterization started, this waits for the rasterize thread
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 // Fail to rasterize because the size is 0.
2904 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2909 int UtcDaliImageViewTVGLoading(void)
2911 ToolkitTestApplication application;
2913 tet_infoline("ImageView Testing TVG image loading");
2916 ImageView imageView = ImageView::New();
2918 imageView.SetImage(TEST_RESOURCE_DIR "/test.tvg");
2920 application.GetScene().Add(imageView);
2921 DALI_TEST_CHECK(imageView);
2922 Vector3 naturalSize = imageView.GetNaturalSize();
2924 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2925 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2929 int UtcDaliImageViewImageLoadFailure01(void)
2931 ToolkitTestApplication application;
2933 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
2934 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
2935 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
2936 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
2938 std::string brokenUrl;
2939 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
2940 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
2942 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
2943 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
2945 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
2946 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
2948 ImageView imageView = ImageView::New("invalidUrl.png");
2949 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2951 application.GetScene().Add(imageView);
2952 application.SendNotification();
2953 application.Render(16);
2955 // loading started, this waits for the loader thread
2956 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2961 int UtcDaliImageViewImageLoadFailure02(void)
2963 ToolkitTestApplication application;
2965 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
2966 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
2967 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
2968 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
2970 std::string brokenUrl;
2971 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
2972 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
2974 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
2975 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
2977 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
2978 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
2980 ImageView imageView = ImageView::New("invalidUrl.png");
2981 imageView.SetProperty(Actor::Property::SIZE, Vector2(30.f, 30.f));
2982 application.GetScene().Add(imageView);
2983 application.SendNotification();
2984 application.Render(16);
2986 // loading started, this waits for the loader thread
2987 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2992 int UtcDaliImageViewImageLoadFailure03(void)
2994 ToolkitTestApplication application;
2996 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
2997 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
2998 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
3000 std::string brokenUrl;
3001 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3002 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3004 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3005 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3007 ImageView imageView = ImageView::New("invalidUrl.png");
3008 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3009 application.GetScene().Add(imageView);
3010 application.SendNotification();
3011 application.Render(16);
3013 // loading started, this waits for the loader thread
3014 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3019 int UtcDaliImageViewImageLoadFailure04(void)
3021 ToolkitTestApplication application;
3023 ImageView imageView = ImageView::New("invalidUrl.png");
3024 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3025 application.GetScene().Add(imageView);
3026 application.SendNotification();
3027 application.Render(16);
3029 // loading started, this waits for the loader thread
3030 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3032 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3033 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3034 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3035 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3037 ImageView imageView2 = ImageView::New("invalidUrl.png");
3038 imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3039 application.GetScene().Add(imageView2);
3041 std::string brokenUrl;
3042 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3043 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3045 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3046 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3048 application.SendNotification();
3049 application.Render(16);
3051 // loading started, this waits for the loader thread
3052 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3054 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3056 ImageView imageView3 = ImageView::New("invalidUrl.png");
3057 imageView3.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3058 application.GetScene().Add(imageView3);
3060 application.SendNotification();
3061 application.Render(16);
3063 // loading started, this waits for the loader thread
3064 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3071 static int gResourceReadySignalCounter = 0;
3073 void OnResourceReadySignal01(Control control)
3075 gResourceReadySignalCounter++;
3077 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3079 if(gResourceReadySignalCounter == 1)
3082 // It makes the first new visual be deleted immediately
3083 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3084 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3087 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3089 // Make the resource ready immediately
3090 control[ImageView::Property::IMAGE] = TEST_RESOURCE_DIR "/svg1.svg";
3094 void OnResourceReadySignal02(Control control)
3096 if(++gResourceReadySignalCounter == 1)
3098 // It makes the first new visual be deleted immediately
3099 // The first image will not be loaded.
3100 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB).Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3101 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3105 ImageView gImageView1;
3106 ImageView gImageView2;
3107 ImageView gImageView3;
3109 void OnResourceReadySignal03(Control control)
3111 if(gResourceReadySignalCounter == 0)
3114 // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3115 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3117 // 2. Load a new image
3118 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3120 // 3. Use the new image again
3121 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3122 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3124 else if(gResourceReadySignalCounter == 1)
3126 // This is called from TextureManager::ProcessQueuedTextures().
3127 gImageView1.Unparent();
3128 gImageView1.Reset();
3130 gResourceReadySignalCounter++;
3133 void OnSimpleResourceReadySignal(Control control)
3135 // simply increate counter
3136 gResourceReadySignalCounter++;
3141 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3143 tet_infoline("Test setting image from within signal handler.");
3145 ToolkitTestApplication application;
3147 gResourceReadySignalCounter = 0;
3149 ImageView imageView = ImageView::New(gImage_34_RGBA);
3150 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal01);
3152 application.GetScene().Add(imageView);
3154 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3156 application.SendNotification();
3157 application.Render();
3159 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3161 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3164 gResourceReadySignalCounter = 0;
3166 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3168 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3170 application.SendNotification();
3171 application.Render();
3173 // Run idle callback
3174 application.RunIdles();
3176 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3178 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3183 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
3185 tet_infoline("Test setting image from within signal handler.");
3187 ToolkitTestApplication application;
3189 gResourceReadySignalCounter = 0;
3191 ImageView imageView = ImageView::New(gImage_34_RGBA);
3192 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal02);
3194 application.GetScene().Add(imageView);
3196 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3198 application.SendNotification();
3199 application.Render();
3201 // Wait for loading an image
3202 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3204 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3206 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3211 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3213 tet_infoline("Test setting image from within signal handler.");
3215 ToolkitTestApplication application;
3217 gResourceReadySignalCounter = 0;
3219 gImageView1 = ImageView::New(gImage_34_RGBA);
3220 application.GetScene().Add(gImageView1);
3223 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3225 gImageView2 = ImageView::New(gImage_600_RGB);
3226 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3227 application.GetScene().Add(gImageView2);
3229 gImageView3 = ImageView::New();
3230 application.GetScene().Add(gImageView3);
3232 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3234 application.SendNotification();
3235 application.Render();
3240 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask01(void)
3242 tet_infoline("Test signal handler when image / mask image is broken.");
3244 ToolkitTestApplication application;
3246 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, const std::string& url, const std::string& mask, const char* location) {
3247 gResourceReadySignalCounter = 0;
3250 map[Toolkit::ImageVisual::Property::URL] = url;
3253 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3255 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3257 ImageView imageView = ImageView::New();
3258 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3259 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3260 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3262 application.GetScene().Add(imageView);
3263 application.SendNotification();
3264 application.Render();
3269 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3271 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3272 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3274 imageView.Unparent();
3277 for(int synchronous = 0; synchronous <= 1; synchronous++)
3279 tet_printf("Test normal case (sync:%d)\n", synchronous);
3280 TestResourceReadyUrl(1, synchronous, gImage_600_RGB, "", TEST_LOCATION);
3281 TestResourceReadyUrl(3, synchronous, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 3 event trigger required : 2 image load + 1 apply mask
3283 tet_printf("Test broken image case (sync:%d)\n", synchronous);
3284 TestResourceReadyUrl(1, synchronous, "invalid.jpg", "", TEST_LOCATION);
3285 TestResourceReadyUrl(2, synchronous, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3287 tet_printf("Test broken mask image case (sync:%d)\n", synchronous);
3288 TestResourceReadyUrl(2, synchronous, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3290 tet_printf("Test broken both image, mask image case (sync:%d)\n", synchronous);
3291 TestResourceReadyUrl(2, synchronous, "invalid.jpg", "invalid.png", TEST_LOCATION);
3297 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask02(void)
3299 tet_infoline("Test signal handler when image try to use cached-and-broken mask image.");
3301 ToolkitTestApplication application;
3303 gResourceReadySignalCounter = 0;
3305 auto TestBrokenMaskResourceReadyUrl = [&application](const std::string& url, const char* location) {
3307 map[Toolkit::ImageVisual::Property::URL] = url;
3308 // Use invalid mask url
3309 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
3311 ImageView imageView = ImageView::New();
3312 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3313 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3314 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3316 application.GetScene().Add(imageView);
3317 application.SendNotification();
3318 application.Render();
3320 // Don't unparent imageView, for keep the cache.
3323 // Use more than 4 images (The number of LocalImageLoadThread)
3324 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};
3326 int expectResourceReadySignalCounter = 0;
3328 for(auto& url : testUrlList)
3330 TestBrokenMaskResourceReadyUrl(url, TEST_LOCATION);
3331 expectResourceReadySignalCounter++;
3334 // Remain 1 signal due to we use #URL + 1 mask image.
3335 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(expectResourceReadySignalCounter + 1), true, TEST_LOCATION);
3337 DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
3342 int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
3344 tet_infoline("Test signal handler various case.");
3346 ToolkitTestApplication application;
3348 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
3349 gResourceReadySignalCounter = 0;
3352 map[Toolkit::ImageVisual::Property::URL] = url;
3355 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3357 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3359 ImageView imageView = ImageView::New();
3360 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3361 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3362 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3364 application.GetScene().Add(imageView);
3365 application.SendNotification();
3366 application.Render();
3369 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3371 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3372 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3373 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3375 imageView.Unparent();
3378 auto TestAuxiliaryResourceReadyUrl = [&application](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
3379 gResourceReadySignalCounter = 0;
3382 map[Toolkit::ImageVisual::Property::URL] = url;
3383 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE] = auxiliaryUrl;
3384 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA] = 0.5f;
3385 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3387 ImageView imageView = ImageView::New();
3388 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
3389 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
3390 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3391 application.GetScene().Add(imageView);
3393 application.SendNotification();
3394 application.Render();
3399 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, location);
3402 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3403 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3404 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3406 imageView.Unparent();
3409 // Case 1 : asynchronous loading
3410 tet_printf("Test invalid single simple image Asynchronous\n");
3413 TestResourceReadyUrl(1, 0, 1, gImage_600_RGB, "", TEST_LOCATION);
3414 TestResourceReadyUrl(1, 0, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // 1 rasterize
3415 TestResourceReadyUrl(1, 0, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
3417 TestResourceReadyUrl(2, 0, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // 2 image loading - batch size
3418 TestResourceReadyUrl(1, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // 1 rasterize
3420 TestResourceReadyUrl(3, 0, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 2 image loading + 1 applymask
3422 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
3425 TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
3426 TestResourceReadyUrl(0, 0, 0, "invalid.svg", "", TEST_LOCATION); // 0 rasterize
3427 TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
3428 TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION); // 1 image loading
3429 TestResourceReadyUrl(0, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
3431 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", "invalid.png", TEST_LOCATION); // 2 image loading
3432 TestResourceReadyUrl(2, 0, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); // 2 image loading
3433 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION); // 2 image loading
3435 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
3436 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
3437 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
3439 // Case 2 : Synchronous loading
3440 tet_printf("Test invalid single simple image Synchronous\n");
3443 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "", TEST_LOCATION);
3444 TestResourceReadyUrl(0, 1, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
3445 TestResourceReadyUrl(0, 1, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
3447 TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // first frame image loading sync + second frame image loading async
3448 TestResourceReadyUrl(0, 1, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
3450 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION);
3452 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
3455 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
3456 TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION); // 0 rasterize
3457 TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
3458 TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
3459 TestResourceReadyUrl(0, 1, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
3461 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "invalid.png", TEST_LOCATION);
3462 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3463 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3465 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
3466 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
3467 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);