2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
24 #include <dali-toolkit-test-suite-utils.h>
25 #include <toolkit-event-thread-callback.h>
26 #include <toolkit-vector-image-renderer.h>
27 #include "dummy-control.h"
29 #include <test-encoded-image-buffer.h>
30 #include <test-native-image.h>
32 #include <dali-toolkit/dali-toolkit.h>
33 #include <dali-toolkit/devel-api/controls/control-devel.h>
34 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
35 #include <dali-toolkit/devel-api/styling/style-manager-devel.h>
36 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
37 #include <dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h>
38 #include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
39 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
40 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
41 #include <dali-toolkit/public-api/image-loader/image-url.h>
42 #include <dali-toolkit/public-api/image-loader/image.h>
43 #include <dali/devel-api/scripting/scripting.h>
46 using namespace Toolkit;
48 void utc_dali_toolkit_image_view_startup(void)
50 test_return_value = TET_UNDEF;
53 void utc_dali_toolkit_image_view_cleanup(void)
55 test_return_value = TET_PASS;
60 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
61 const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
63 // resolution: 1024*1024
64 const char* TEST_IMAGE_1 = TEST_RESOURCE_DIR "/TB-gloss.png";
65 const char* TEST_IMAGE_2 = TEST_RESOURCE_DIR "/tb-norm.png";
67 const char* TEST_BROKEN_IMAGE_DEFAULT = TEST_RESOURCE_DIR "/broken.png";
68 const char* TEST_BROKEN_IMAGE_S = TEST_RESOURCE_DIR "/broken_s.9.png";
69 const char* TEST_BROKEN_IMAGE_M = TEST_RESOURCE_DIR "/broken_m.9.png";
70 const char* TEST_BROKEN_IMAGE_L = TEST_RESOURCE_DIR "/broken_l.9.png";
71 const char* TEST_BROKEN_IMAGE_01 = TEST_RESOURCE_DIR "/button-up.9.png";
72 const char* TEST_BROKEN_IMAGE_02 = TEST_RESOURCE_DIR "/heartsframe.9.png";
74 // resolution: 34*34, pixel format: RGBA8888
75 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
76 // resolution: 600*600, pixel format: RGB888
77 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
79 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
80 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
82 const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
83 const char* TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
85 void TestUrl(ImageView imageView, const std::string url)
87 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
89 std::string urlActual;
90 DALI_TEST_CHECK(value.Get(urlActual));
91 DALI_TEST_EQUALS(urlActual, url, TEST_LOCATION);
96 int UtcDaliImageViewNewP(void)
98 ToolkitTestApplication application;
100 ImageView imageView = ImageView::New();
102 DALI_TEST_CHECK(imageView);
107 int UtcDaliImageViewNewUrlP(void)
109 ToolkitTestApplication application;
111 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
112 DALI_TEST_CHECK(imageView);
114 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
119 int UtcDaliImageViewConstructorP(void)
121 ToolkitTestApplication application;
125 DALI_TEST_CHECK(!imageView);
130 int UtcDaliImageViewCopyConstructorP(void)
132 ToolkitTestApplication application;
134 // Initialize an object, ref count == 1
135 ImageView imageView = ImageView::New();
137 ImageView copy(imageView);
138 DALI_TEST_CHECK(copy);
143 int UtcDaliImageViewMoveConstructor(void)
145 ToolkitTestApplication application;
147 ImageView imageView = ImageView::New();
148 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
149 imageView.SetProperty(Actor::Property::SENSITIVE, false);
150 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
152 ImageView moved = std::move(imageView);
153 DALI_TEST_CHECK(moved);
154 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
155 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
156 DALI_TEST_CHECK(!imageView);
161 int UtcDaliImageViewAssignmentOperatorP(void)
163 ToolkitTestApplication application;
165 ImageView imageView = ImageView::New();
167 ImageView copy(imageView);
168 DALI_TEST_CHECK(copy);
169 DALI_TEST_EQUALS(imageView, copy, TEST_LOCATION);
174 int UtcDaliImageViewMoveAssignment(void)
176 ToolkitTestApplication application;
178 ImageView imageView = ImageView::New();
179 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
180 imageView.SetProperty(Actor::Property::SENSITIVE, false);
181 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
184 moved = std::move(imageView);
185 DALI_TEST_CHECK(moved);
186 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
187 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
188 DALI_TEST_CHECK(!imageView);
193 int UtcDaliImageViewDownCastP(void)
195 ToolkitTestApplication application;
197 ImageView imageView = ImageView::New();
199 BaseHandle object(imageView);
201 ImageView imageView2 = ImageView::DownCast(object);
202 DALI_TEST_CHECK(imageView2);
204 ImageView imageView3 = DownCast<ImageView>(object);
205 DALI_TEST_CHECK(imageView3);
210 int UtcDaliImageViewDownCastN(void)
212 ToolkitTestApplication application;
214 BaseHandle unInitializedObject;
216 ImageView imageView1 = ImageView::DownCast(unInitializedObject);
217 DALI_TEST_CHECK(!imageView1);
219 ImageView imageView2 = DownCast<ImageView>(unInitializedObject);
220 DALI_TEST_CHECK(!imageView2);
225 int UtcDaliImageViewTypeRegistry(void)
227 ToolkitTestApplication application;
229 TypeRegistry typeRegistry = TypeRegistry::Get();
230 DALI_TEST_CHECK(typeRegistry);
232 TypeInfo typeInfo = typeRegistry.GetTypeInfo("ImageView");
233 DALI_TEST_CHECK(typeInfo);
235 BaseHandle handle = typeInfo.CreateInstance();
236 DALI_TEST_CHECK(handle);
238 ImageView imageView = ImageView::DownCast(handle);
239 DALI_TEST_CHECK(imageView);
244 int UtcDaliImageViewSetGetProperty01(void)
246 ToolkitTestApplication application;
248 ImageView imageView = ImageView::New();
250 Property::Index idx = imageView.GetPropertyIndex("image");
251 DALI_TEST_EQUALS(idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION);
253 imageView.SetProperty(idx, TEST_IMAGE_FILE_NAME);
254 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
259 int UtcDaliImageViewPreMultipliedAlphaPng(void)
261 ToolkitTestApplication application;
263 // Set up trace debug
264 TestGlAbstraction& gl = application.GetGlAbstraction();
265 TraceCallStack& textureTrace = gl.GetTextureTrace();
266 textureTrace.Enable(true);
268 Property::Map imageMap;
269 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
270 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
272 ImageView imageView1 = ImageView::New();
273 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
275 application.GetScene().Add(imageView1);
277 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
279 DALI_TEST_CHECK(value.Get(enable));
280 DALI_TEST_CHECK(enable); // Default value is true
282 // loading started, this waits for the loader thread for max 30 seconds
283 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
285 application.SendNotification();
286 application.Render();
288 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
289 DALI_TEST_CHECK(value.Get(enable));
290 DALI_TEST_CHECK(enable); // Keep true
292 // conventional alpha blending
293 Renderer renderer1 = imageView1.GetRendererAt(0);
294 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
295 DALI_TEST_CHECK(value.Get(enable));
296 DALI_TEST_CHECK(enable);
298 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
299 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
300 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
301 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
302 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
303 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
304 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
305 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
307 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
308 textureTrace.Reset();
310 // Disable pre-multiplied alpha blending
311 imageView1.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
314 Property::Map attributes;
315 DevelControl::DoAction(imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
317 // loading started, this waits for the loader thread for max 30 seconds
318 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
320 application.SendNotification();
321 application.Render();
323 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
324 DALI_TEST_CHECK(value.Get(enable));
325 DALI_TEST_CHECK(!enable);
327 // conventional alpha blending
328 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
329 DALI_TEST_CHECK(value.Get(enable));
330 DALI_TEST_CHECK(!enable);
332 srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
333 destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
334 srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
335 destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
336 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
337 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
338 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
339 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
341 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
342 textureTrace.Reset();
344 // Make a new ImageView using the same image
345 ImageView imageView2 = ImageView::New();
346 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
348 application.GetScene().Add(imageView2);
350 application.SendNotification();
351 application.Render();
353 Renderer renderer2 = imageView2.GetRendererAt(0);
354 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
355 DALI_TEST_CHECK(value.Get(enable));
356 DALI_TEST_CHECK(enable);
358 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
359 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
360 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
361 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
362 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
363 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
364 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
365 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
367 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
372 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
374 ToolkitTestApplication application;
376 // Set up trace debug
377 TestGlAbstraction& gl = application.GetGlAbstraction();
378 TraceCallStack& textureTrace = gl.GetTextureTrace();
379 textureTrace.Enable(true);
381 Property::Map imageMap;
382 imageMap[ImageVisual::Property::URL] = gImage_600_RGB;
383 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
385 ImageView imageView1 = ImageView::New();
386 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
388 application.GetScene().Add(imageView1);
390 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
392 DALI_TEST_CHECK(value.Get(enable));
393 DALI_TEST_CHECK(enable); // Default value is true
395 // loading started, this waits for the loader thread for max 30 seconds
396 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
398 application.SendNotification();
399 application.Render();
401 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
402 DALI_TEST_CHECK(value.Get(enable));
403 DALI_TEST_CHECK(!enable); // Should be false after loading
405 // conventional alpha blending
406 Renderer renderer1 = imageView1.GetRendererAt(0);
407 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
408 DALI_TEST_CHECK(value.Get(enable));
409 DALI_TEST_CHECK(!enable);
411 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
412 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
413 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
414 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
415 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
416 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
417 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
418 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
420 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
421 textureTrace.Reset();
423 ImageView imageView2 = ImageView::New();
424 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
426 // Disable pre-multiplied alpha blending
427 imageView2.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
429 application.GetScene().Add(imageView2);
431 application.SendNotification();
432 application.Render();
434 value = imageView2.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
435 DALI_TEST_CHECK(value.Get(enable));
436 DALI_TEST_CHECK(!enable);
438 // conventional alpha blending
439 Renderer renderer2 = imageView2.GetRendererAt(0);
440 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
441 DALI_TEST_CHECK(value.Get(enable));
442 DALI_TEST_CHECK(!enable);
444 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
445 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
446 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
447 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
448 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
449 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
450 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
451 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
453 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
458 int UtcDaliImageViewPixelArea(void)
460 // Test pixel area property
461 ToolkitTestApplication application;
463 static std::vector<UniformData> customUniforms =
465 UniformData("pixelArea", Property::Type::VECTOR4),
468 TestGraphicsController& graphics = application.GetGraphicsController();
469 graphics.AddCustomUniforms(customUniforms);
471 // Gif image, use AnimatedImageVisual internally
472 // Atlasing is applied to pack multiple frames, use custom wrap mode
473 ImageView gifView = ImageView::New();
474 const Vector4 pixelAreaVisual(0.f, 0.f, 2.f, 2.f);
475 gifView.SetProperty(ImageView::Property::IMAGE,
476 Property::Map().Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME).Add(ImageVisual::Property::PIXEL_AREA, pixelAreaVisual));
479 Integration::Scene stage = application.GetScene();
483 application.SendNotification();
484 application.Render(16);
486 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
488 application.SendNotification();
489 application.Render();
490 DALI_TEST_CHECK(gifView.GetRendererCount() == 1u);
492 const Vector4 fullTextureRect(0.f, 0.f, 1.f, 1.f);
493 // test that the pixel area value defined in the visual property map is registered on renderer
494 Renderer renderer = gifView.GetRendererAt(0);
495 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
496 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION);
498 // test that the shader has the default pixel area value registered.
499 Shader shader = renderer.GetShader();
500 pixelAreaValue = shader.GetProperty(shader.GetPropertyIndex("pixelArea"));
501 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION);
503 // test that the uniform uses the pixelArea property on the renderer.
504 TestGlAbstraction& gl = application.GetGlAbstraction();
505 Vector4 pixelAreaUniform;
506 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
507 DALI_TEST_EQUALS(pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
509 // set the pixelArea property on the control
510 const Vector4 pixelAreaControl(-1.f, -1.f, 3.f, 3.f);
511 gifView.SetProperty(ImageView::Property::PIXEL_AREA, pixelAreaControl);
512 application.SendNotification();
513 application.Render(16);
515 // check the pixelArea property on the control
516 pixelAreaValue = gifView.GetProperty(gifView.GetPropertyIndex("pixelArea"));
517 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION);
518 // test that the uniform uses the pixelArea property on the control.
519 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
520 DALI_TEST_EQUALS(pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
525 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
527 ToolkitTestApplication application;
528 TestGlAbstraction& gl = application.GetGlAbstraction();
529 const std::vector<GLuint>& textures = gl.GetBoundTextures();
530 size_t numTextures = textures.size();
532 // Async loading, no atlasing for big size image
533 ImageView imageView = ImageView::New(gImage_600_RGB);
535 // By default, Aysnc loading is used
536 application.GetScene().Add(imageView);
537 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
538 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
540 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
542 application.SendNotification();
543 application.Render(16);
544 application.SendNotification();
546 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
547 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
552 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
554 ToolkitTestApplication application;
556 //Async loading, automatic atlasing for small size image
557 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
559 callStack.Enable(true);
561 Property::Map imageMap;
563 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
564 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
565 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
566 imageMap[ImageVisual::Property::ATLASING] = true;
568 ImageView imageView = ImageView::New();
569 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
570 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
572 // By default, Aysnc loading is used
573 // loading is not started if the actor is offScene
575 application.GetScene().Add(imageView);
576 application.SendNotification();
577 application.Render(16);
578 application.Render(16);
579 application.SendNotification();
581 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
582 application.SendNotification();
583 application.Render(16);
584 application.Render(16);
585 application.SendNotification();
587 // loading started, this waits for the loader thread for max 30 seconds
588 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
590 application.SendNotification();
591 application.Render(16);
593 callStack.Enable(false);
595 TraceCallStack::NamedParams params;
596 params["width"] << 34;
597 params["height"] << 34;
598 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
603 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
605 ToolkitTestApplication application;
607 //Async loading, automatic atlasing for small size image
608 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
610 callStack.Enable(true);
612 Property::Map asyncLoadingMap;
613 asyncLoadingMap["url"] = gImage_34_RGBA;
614 asyncLoadingMap["desiredHeight"] = 34;
615 asyncLoadingMap["desiredWidth"] = 34;
616 asyncLoadingMap["synchronousLoading"] = false;
617 asyncLoadingMap["atlasing"] = true;
619 ImageView imageView = ImageView::New();
620 imageView.SetProperty(ImageView::Property::IMAGE, asyncLoadingMap);
622 application.GetScene().Add(imageView);
623 application.SendNotification();
624 application.Render(16);
625 application.Render(16);
626 application.SendNotification();
628 // loading started, this waits for the loader thread for max 30 seconds
629 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
631 application.SendNotification();
632 application.Render(16);
634 callStack.Enable(false);
636 TraceCallStack::NamedParams params;
637 params["width"] << 34;
638 params["height"] << 34;
639 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
644 int UtcDaliImageViewSyncLoading(void)
646 ToolkitTestApplication application;
648 tet_infoline("ImageView Testing sync loading and size using index key property map");
650 Property::Map syncLoadingMap;
651 syncLoadingMap[ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
652 syncLoadingMap[ImageVisual::Property::ATLASING] = true;
654 // Sync loading, no atlasing for big size image
656 ImageView imageView = ImageView::New();
658 // Sync loading is used
659 syncLoadingMap[ImageVisual::Property::URL] = gImage_600_RGB;
660 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
663 // Sync loading, automatic atlasing for small size image
665 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
667 callStack.Enable(true);
669 ImageView imageView = ImageView::New();
671 // Sync loading is used
672 syncLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
673 syncLoadingMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
674 syncLoadingMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
675 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
677 application.GetScene().Add(imageView);
678 application.SendNotification();
679 application.Render(16);
681 TraceCallStack::NamedParams params;
682 params["width"] << 34;
683 params["height"] << 34;
684 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
691 int UtcDaliImageViewSyncLoading02(void)
693 ToolkitTestApplication application;
695 tet_infoline("ImageView Testing sync loading and size using string key property map");
697 // Sync loading, automatic atlasing for small size image
699 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
701 callStack.Enable(true);
703 ImageView imageView = ImageView::New();
705 // Sync loading is used
706 Property::Map syncLoadingMap;
707 syncLoadingMap["url"] = gImage_34_RGBA;
708 syncLoadingMap["desiredHeight"] = 34;
709 syncLoadingMap["desiredWidth"] = 34;
710 syncLoadingMap["synchronousLoading"] = true;
711 syncLoadingMap["atlasing"] = true;
712 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
714 application.GetScene().Add(imageView);
715 application.SendNotification();
716 application.Render(16);
718 TraceCallStack::NamedParams params;
719 params["width"] << 34;
720 params["height"] << 34;
721 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
728 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
730 ToolkitTestApplication application;
731 TestGlAbstraction& gl = application.GetGlAbstraction();
732 const std::vector<GLuint>& textures = gl.GetBoundTextures();
733 size_t numTextures = textures.size();
735 // Get encoded raw-buffer image and generate url
736 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
737 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
739 // Async loading, no atlasing for big size image
740 ImageView imageView = ImageView::New(url.GetUrl());
742 // By default, Aysnc loading is used
743 application.GetScene().Add(imageView);
744 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
745 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
747 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
749 application.SendNotification();
750 application.Render(16);
751 application.SendNotification();
753 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
754 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
759 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
761 ToolkitTestApplication application;
763 // Get encoded raw-buffer image and generate url
764 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
765 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
766 ImageUrl url2 = Toolkit::Image::GenerateUrl(buffer);
768 // Generate url is not equal to url2
769 // NOTE : This behavior may changed when ImageUrl compare operator changed.
770 DALI_TEST_CHECK(url != url2);
771 // Generate url's string is equal to url2's string
772 DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
774 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
775 url2 = Toolkit::Image::GenerateUrl(buffer2);
777 // Check whethere two url are not equal
778 DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
780 // Async loading, automatic atlasing for small size image
781 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
783 callStack.Enable(true);
785 Property::Map imageMap;
787 imageMap[ImageVisual::Property::URL] = url.GetUrl();
788 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
789 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
790 imageMap[ImageVisual::Property::ATLASING] = true;
792 ImageView imageView = ImageView::New();
793 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
794 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
796 // By default, Aysnc loading is used
797 // loading is not started if the actor is offScene
799 application.GetScene().Add(imageView);
800 application.SendNotification();
801 application.Render(16);
802 application.Render(16);
803 application.SendNotification();
805 // Change url to url2
806 imageMap[ImageVisual::Property::URL] = url2.GetUrl();
807 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
809 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
810 application.SendNotification();
811 application.Render(16);
812 application.Render(16);
813 application.SendNotification();
815 // loading started, this waits for the loader thread for max 30 seconds
816 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
818 application.SendNotification();
819 application.Render(16);
821 callStack.Enable(false);
823 TraceCallStack::NamedParams params;
824 params["width"] << 34;
825 params["height"] << 34;
826 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
831 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
833 ToolkitTestApplication application;
835 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
837 // Get encoded raw-buffer image and generate url
838 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
839 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
841 // Sync loading, automatic atlasing for small size image
843 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
845 callStack.Enable(true);
847 ImageView imageView = ImageView::New();
849 // Sync loading is used
850 Property::Map syncLoadingMap;
851 syncLoadingMap["url"] = url.GetUrl();
852 syncLoadingMap["desiredHeight"] = 34;
853 syncLoadingMap["desiredWidth"] = 34;
854 syncLoadingMap["synchronousLoading"] = true;
855 syncLoadingMap["atlasing"] = true;
856 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
858 application.GetScene().Add(imageView);
859 application.SendNotification();
860 application.Render(16);
862 TraceCallStack::NamedParams params;
863 params["width"] << 34;
864 params["height"] << 34;
865 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
873 int UtcDaliImageViewAddedTexture(void)
875 ToolkitTestApplication application;
877 tet_infoline("ImageView Testing image view with texture provided manager url");
879 ImageView imageView = ImageView::New();
881 // empty texture is ok, though pointless from app point of view
883 std::string url = TextureManager::AddTexture(empty);
884 DALI_TEST_CHECK(url.size() > 0u);
886 Property::Map propertyMap;
887 propertyMap[ImageVisual::Property::URL] = url;
888 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
890 application.GetScene().Add(imageView);
891 application.SendNotification();
892 application.Render();
897 int UtcDaliImageViewSizeWithBackground(void)
899 ToolkitTestApplication application;
903 ImageView imageView = ImageView::New();
905 imageView.SetProperty(Control::Property::BACKGROUND,
907 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
908 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
909 {ImageVisual::Property::DESIRED_WIDTH, width},
910 {ImageVisual::Property::DESIRED_HEIGHT, height},
913 application.GetScene().Add(imageView);
914 application.SendNotification();
915 application.Render();
917 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
918 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
923 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
925 ToolkitTestApplication application;
927 int widthBackground = 100;
928 int heightBackground = 200;
932 ImageView imageView = ImageView::New();
934 imageView.SetProperty(Control::Property::BACKGROUND,
936 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
937 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
938 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
939 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground},
942 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio, 600x600 pixels
944 application.GetScene().Add(imageView);
945 application.SendNotification();
946 application.Render();
948 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
949 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
954 int UtcDaliImageViewHeightForWidthBackground(void)
956 ToolkitTestApplication application;
958 int widthBackground = 100;
959 int heightBackground = 200;
961 ImageView imageView = ImageView::New();
963 imageView.SetProperty(Control::Property::BACKGROUND,
964 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
965 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
966 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
967 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}});
969 application.GetScene().Add(imageView);
970 application.SendNotification();
971 application.Render();
973 Control control = Control::DownCast(imageView);
974 DALI_TEST_CHECK(control);
975 DALI_TEST_EQUALS(imageView.GetHeightForWidth(123.f), control.GetHeightForWidth(123.f), TEST_LOCATION);
976 DALI_TEST_EQUALS(imageView.GetWidthForHeight(321.f), control.GetWidthForHeight(321.f), TEST_LOCATION);
981 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
983 ToolkitTestApplication application;
985 int widthBackground = 100;
986 int heightBackground = 200;
990 ImageView imageView = ImageView::New();
992 imageView.SetProperty(Control::Property::BACKGROUND,
993 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
994 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
995 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
996 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}}); // 1 to 2 ratio
998 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio
1000 application.GetScene().Add(imageView);
1001 application.SendNotification();
1002 application.Render();
1004 DALI_TEST_EQUALS(imageView.GetHeightForWidth(width), (float)height, TEST_LOCATION);
1005 DALI_TEST_EQUALS(imageView.GetWidthForHeight(height), (float)width, TEST_LOCATION);
1010 int UtcDaliImageViewSetImageUrl(void)
1012 ToolkitTestApplication application;
1014 ImageView imageView = ImageView::New();
1015 imageView.SetImage(TEST_IMAGE_FILE_NAME);
1016 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
1018 imageView.SetImage(TEST_IMAGE_FILE_NAME2);
1019 TestUrl(imageView, TEST_IMAGE_FILE_NAME2);
1024 bool gResourceReadySignalFired = false;
1025 Vector3 gNaturalSize;
1027 void ResourceReadySignal(Control control)
1029 gResourceReadySignalFired = true;
1032 int UtcDaliImageViewCheckResourceReady(void)
1034 ToolkitTestApplication application;
1036 gResourceReadySignalFired = false;
1038 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1039 ImageView imageView = ImageView::New(TEST_GIF_FILE_NAME);
1041 imageView.SetProperty(Control::Property::BACKGROUND,
1042 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1043 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1044 {ImageVisual::Property::DESIRED_WIDTH, 100},
1045 {ImageVisual::Property::DESIRED_HEIGHT, 200}});
1047 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1049 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1051 application.GetScene().Add(imageView);
1053 // loading started, this waits for the loader thread
1054 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1056 application.SendNotification();
1057 application.Render(16);
1059 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1061 application.SendNotification();
1062 application.Render();
1064 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1066 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1071 int UtcDaliImageViewSetImageTypeChangesP(void)
1073 ToolkitTestApplication application;
1075 ImageView imageView = ImageView::New();
1076 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1078 application.GetScene().Add(imageView);
1082 Toolkit::Visual::Base visual;
1084 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1085 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1087 application.SendNotification();
1088 application.Render(16);
1090 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1092 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1093 DALI_TEST_CHECK(!visual); // Visual should be invalid
1096 imageView.SetImage("TEST_URL");
1098 application.SendNotification();
1099 application.Render(16);
1101 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1102 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1104 DALI_TEST_CHECK(value.Get(url)); // Value should NOT be empty
1105 DALI_TEST_CHECK(!value.Get(map)); // Value should be empty
1106 DALI_TEST_CHECK(visual); // Visual should be valid
1109 imageView.SetImage("");
1111 application.SendNotification();
1112 application.Render(16);
1114 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1115 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1117 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1119 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1120 DALI_TEST_CHECK(!visual); // Visual should be invalid
1122 // Set a URL in property map
1123 Property::Map propertyMap;
1124 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1125 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1127 application.SendNotification();
1128 application.Render(16);
1130 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1131 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1133 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1134 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1135 DALI_TEST_CHECK(visual); // Visual should be valid
1137 // Set a URL in property map again
1138 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1139 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1141 application.SendNotification();
1142 application.Render(16);
1144 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1145 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1147 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1148 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1149 DALI_TEST_CHECK(visual); // Visual should be valid
1151 // Set an empty URL in property map
1152 propertyMap[ImageVisual::Property::URL] = std::string();
1153 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1155 application.SendNotification();
1156 application.Render(16);
1158 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1159 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1161 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1162 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1163 DALI_TEST_CHECK(!visual); // Visual should be invalid
1165 // Set a URL in property map again
1166 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1167 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1169 application.SendNotification();
1170 application.Render(16);
1172 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1173 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1175 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1176 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1177 DALI_TEST_CHECK(visual); // Visual should be valid
1179 // Set an empty property map
1180 propertyMap.Clear();
1181 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1183 application.SendNotification();
1184 application.Render(16);
1186 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1187 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1189 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1190 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1191 DALI_TEST_CHECK(map.Empty()); // But PropertyMap should be empty
1192 DALI_TEST_CHECK(!visual); // Visual should be invalid
1197 int UtcDaliImageViewResourceUrlP(void)
1199 ToolkitTestApplication application;
1201 ImageView imageView = ImageView::New();
1202 DALI_TEST_CHECK(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>().empty());
1204 imageView.SetProperty(ImageView::Property::IMAGE, "TestString");
1205 DALI_TEST_EQUALS(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>(), "TestString", TEST_LOCATION);
1210 int UtcDaliImageViewReplaceImage(void)
1212 ToolkitTestApplication application;
1214 gResourceReadySignalFired = false;
1216 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1217 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1219 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1221 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1223 application.GetScene().Add(imageView);
1225 application.SendNotification();
1226 application.Render(16);
1228 // loading started, this waits for the loader thread for max 30 seconds
1229 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1231 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1233 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1235 gResourceReadySignalFired = false;
1237 imageView.SetImage(TEST_IMAGE_2);
1239 application.SendNotification();
1240 application.Render(16);
1242 // loading started, this waits for the loader thread for max 30 seconds
1243 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1245 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1247 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1249 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1254 void OnRelayoutOverride(Size size)
1256 gNaturalSize = size; // Size Relayout is using
1259 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1261 ToolkitTestApplication application;
1263 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1264 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1265 imageView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1267 DummyControl dummyControl = DummyControl::New(true);
1268 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1269 dummyControl.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
1271 dummyControl.Add(imageView);
1272 dummyImpl.SetRelayoutCallback(&OnRelayoutOverride);
1273 application.GetScene().Add(dummyControl);
1275 application.SendNotification();
1276 application.Render();
1278 // loading started, this waits for the loader thread for max 30 seconds
1279 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1281 DALI_TEST_EQUALS(gNaturalSize.width, 1024.0f, TEST_LOCATION);
1282 DALI_TEST_EQUALS(gNaturalSize.height, 1024.0f, TEST_LOCATION);
1284 gNaturalSize = Vector3::ZERO;
1286 imageView.SetImage(gImage_600_RGB);
1288 // Waiting for resourceReady so SendNotifcation not called here.
1290 // loading started, this waits for the loader thread for max 30 seconds
1291 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1293 // Trigger a potential relayout
1294 application.SendNotification();
1295 application.Render();
1297 DALI_TEST_EQUALS(gNaturalSize.width, 600.0f, TEST_LOCATION);
1298 DALI_TEST_EQUALS(gNaturalSize.height, 600.0f, TEST_LOCATION);
1303 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1305 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1307 ToolkitTestApplication application;
1309 gResourceReadySignalFired = false;
1311 Property::Map imageMap;
1313 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1314 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1316 tet_infoline("Creating ImageView without URL so image does not start loading");
1317 ImageView imageView = ImageView::New();
1318 tet_infoline("Connect to image loaded signal before setting image");
1319 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1320 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1321 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1323 // loading started, this waits for the loader thread
1324 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1326 application.SendNotification();
1327 application.Render(16);
1329 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1334 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1336 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1338 ToolkitTestApplication application;
1340 gResourceReadySignalFired = false;
1342 Property::Map imageMap;
1344 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1345 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1347 ImageView imageView = ImageView::New();
1348 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1349 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1351 // loading started, this waits for the loader thread
1352 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1354 application.SendNotification();
1355 application.Render(16);
1357 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1358 gResourceReadySignalFired = false;
1360 ImageView imageViewWithExistingImage = ImageView::New();
1361 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1362 imageViewWithExistingImage.SetProperty(ImageView::Property::IMAGE, imageMap);
1364 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1369 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1371 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1373 ToolkitTestApplication application;
1375 gResourceReadySignalFired = false;
1377 Property::Map imageImmediateLoadingMap;
1378 imageImmediateLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1379 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1381 tet_infoline("Immediate load an image");
1382 ImageView imageView = ImageView::New();
1383 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1384 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
1386 // loading started, this waits for the loader thread
1387 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1389 application.SendNotification();
1390 application.Render(16);
1392 tet_infoline("Check image loaded");
1393 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1394 gResourceReadySignalFired = false;
1396 tet_infoline("Create another ImageView with the same URL");
1397 ImageView imageViewWithExistingImage = ImageView::New(gImage_34_RGBA);
1398 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1399 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1401 application.GetScene().Add(imageViewWithExistingImage);
1403 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1408 int UtcDaliImageViewPaddingProperty(void)
1410 ToolkitTestApplication application;
1412 ImageView imageView = ImageView::New();
1413 Property::Map imagePropertyMap;
1414 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1415 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
1416 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1417 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1418 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1419 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1420 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1421 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1422 application.GetScene().Add(imageView);
1424 application.SendNotification();
1425 application.Render();
1427 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1429 ImageView childImage = ImageView::New();
1430 childImage.SetBackgroundColor(Color::BLACK);
1431 childImage.SetProperty(Actor::Property::SIZE, Vector2(10.f, 10.f));
1432 imageView.Add(childImage);
1434 application.SendNotification();
1435 application.Render();
1437 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1438 DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
1440 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1441 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1442 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1443 Property::Map resultMap;
1444 imageVisual.CreatePropertyMap(resultMap);
1446 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1447 DALI_TEST_CHECK(transformValue);
1448 Property::Map* retMap = transformValue->GetMap();
1449 DALI_TEST_CHECK(retMap);
1451 // Image Visual should be positioned depending on ImageView's padding
1452 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1457 int UtcDaliImageViewPaddingProperty02(void)
1459 ToolkitTestApplication application;
1461 ImageView imageView = ImageView::New();
1462 Property::Map imagePropertyMap;
1463 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1464 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1465 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1466 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1467 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1468 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1469 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1470 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1471 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1472 application.GetScene().Add(imageView);
1474 application.SendNotification();
1475 application.Render();
1477 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1479 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1480 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1481 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1482 Property::Map resultMap;
1483 imageVisual.CreatePropertyMap(resultMap);
1485 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1486 DALI_TEST_CHECK(transformValue);
1487 Property::Map* retMap = transformValue->GetMap();
1488 DALI_TEST_CHECK(retMap);
1490 // Image Visual should be positioned depending on ImageView's padding
1491 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1496 int UtcDaliImageViewPaddingProperty03(void)
1498 tet_infoline("Test Setting Image Padding then removing it.");
1500 ToolkitTestApplication application;
1502 ImageView imageView = ImageView::New();
1503 Property::Map imagePropertyMap;
1504 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1505 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1506 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1507 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1508 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1509 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1510 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1511 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1512 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1513 application.GetScene().Add(imageView);
1515 application.SendNotification();
1516 application.Render();
1518 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1520 tet_infoline("Remove Padding and test Visual is position correctly");
1522 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1524 application.SendNotification();
1525 application.Render();
1527 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1528 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1529 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1530 Property::Map resultMap;
1531 imageVisual.CreatePropertyMap(resultMap);
1533 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1534 DALI_TEST_CHECK(transformValue);
1535 Property::Map* retMap = transformValue->GetMap();
1536 DALI_TEST_CHECK(retMap);
1538 // Image Visual should be positioned depending on ImageView's padding
1539 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1544 int UtcDaliImageViewPaddingProperty04(void)
1546 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1548 ToolkitTestApplication application;
1550 ImageView imageView = ImageView::New();
1551 Property::Map imagePropertyMap;
1552 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1553 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1554 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1555 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1556 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FILL;
1557 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1558 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1559 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1560 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1561 application.GetScene().Add(imageView);
1563 application.SendNotification();
1564 application.Render();
1566 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1568 tet_infoline("Remove Padding and test Visual is position correctly");
1570 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1572 application.SendNotification();
1573 application.Render();
1575 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1576 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1577 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1578 Property::Map resultMap;
1579 imageVisual.CreatePropertyMap(resultMap);
1581 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1582 DALI_TEST_CHECK(transformValue);
1583 Property::Map* retMap = transformValue->GetMap();
1584 DALI_TEST_CHECK(retMap);
1586 // Image Visual should be positioned depending on ImageView's padding
1587 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1592 int UtcDaliImageViewTransformTest01(void)
1594 tet_infoline("Test Setting a offset transform on the ImageView");
1596 ToolkitTestApplication application;
1598 ImageView imageView = ImageView::New();
1599 Property::Map imagePropertyMap;
1600 imagePropertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE)
1601 .Add(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/Kid1.svg")
1602 .Add(ImageVisual::Property::DESIRED_WIDTH, 120)
1603 .Add(ImageVisual::Property::DESIRED_HEIGHT, 120)
1604 .Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL)
1605 .Add(Visual::Property::TRANSFORM,
1606 Property::Map().Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1607 Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE))
1608 .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(8, 8)));
1610 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1611 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1612 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1613 application.GetScene().Add(imageView);
1615 application.SendNotification();
1616 application.Render();
1618 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1619 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1620 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1621 Property::Map resultMap;
1622 imageVisual.CreatePropertyMap(resultMap);
1624 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1625 DALI_TEST_CHECK(transformValue);
1626 Property::Map* retMap = transformValue->GetMap();
1627 DALI_TEST_CHECK(retMap);
1629 // Image Visual should be positioned depending on ImageView's padding
1630 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(8, 8), TEST_LOCATION);
1631 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);
1636 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1638 ToolkitTestApplication application;
1640 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1641 ImageView imageView = ImageView::New();
1642 Property::Map imageMap;
1643 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1644 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_34_RGBA;
1645 imageMap[Toolkit::ImageVisual::Property::ATLASING] = true;
1646 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1647 application.GetScene().Add(imageView);
1649 // Trigger a potential relayout
1650 application.SendNotification();
1651 application.Render();
1653 Vector3 naturalSize = imageView.GetNaturalSize();
1655 DALI_TEST_EQUALS(naturalSize.width, 34.0f, TEST_LOCATION);
1656 DALI_TEST_EQUALS(naturalSize.height, 34.0f, TEST_LOCATION);
1661 int UtcDaliImageViewFillMode(void)
1663 ToolkitTestApplication application;
1665 tet_infoline("Create an ImageVisual without padding and set the fill-mode to fill");
1667 ImageView imageView = ImageView::New();
1668 Property::Map imageMap;
1669 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1670 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB);
1671 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL);
1673 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1675 application.GetScene().Add(imageView);
1677 // Trigger a potential relayout
1678 application.SendNotification();
1679 application.Render();
1681 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1682 Property::Map returnedMap;
1683 visual.CreatePropertyMap(returnedMap);
1685 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1686 DALI_TEST_CHECK(value);
1687 Property::Map* map = value->GetMap();
1688 DALI_TEST_CHECK(map);
1690 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1691 DALI_TEST_CHECK(value);
1692 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION);
1694 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1695 DALI_TEST_CHECK(value);
1696 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1701 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1703 ToolkitTestApplication application;
1705 tet_infoline("Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )");
1706 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1708 ImageView imageView = ImageView::New();
1709 Property::Map imageMap;
1710 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1711 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1712 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
1714 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1715 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1717 application.GetScene().Add(imageView);
1719 // Trigger a potential relayout
1720 application.SendNotification();
1721 application.Render();
1723 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1724 Property::Map returnedMap;
1725 visual.CreatePropertyMap(returnedMap);
1727 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1728 DALI_TEST_CHECK(value);
1729 Property::Map* map = value->GetMap();
1730 DALI_TEST_CHECK(map);
1733 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1734 DALI_TEST_CHECK(value);
1735 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION);
1737 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1738 DALI_TEST_CHECK(value);
1739 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1741 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1742 DALI_TEST_CHECK(value);
1743 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
1748 int UtcDaliImageViewFittingModesFill(void)
1750 ToolkitTestApplication application;
1752 tet_infoline("Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )");
1753 tet_infoline(" There should be no need to change the transform, only size is changed to fit view");
1755 ImageView imageView = ImageView::New();
1756 Property::Map imageMap;
1757 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1758 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1759 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL);
1761 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1762 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1764 application.GetScene().Add(imageView);
1766 // Trigger a potential relayout
1767 application.SendNotification();
1768 application.Render();
1770 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1771 Property::Map returnedMap;
1772 visual.CreatePropertyMap(returnedMap);
1774 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1775 DALI_TEST_CHECK(value);
1776 Property::Map* map = value->GetMap();
1777 DALI_TEST_CHECK(map);
1779 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1780 DALI_TEST_CHECK(value);
1781 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Change the internal size according to the image view size
1783 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1784 DALI_TEST_CHECK(value);
1785 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1787 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1788 DALI_TEST_CHECK(value);
1789 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1794 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1796 ToolkitTestApplication application;
1798 tet_infoline("Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )");
1799 tet_infoline(" offset or size is the same as view, but adjust internally using pixelArea ");
1801 ImageView imageView = ImageView::New();
1802 Property::Map imageMap;
1803 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1804 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1805 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO);
1807 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1808 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 500));
1810 application.GetScene().Add(imageView);
1812 // Trigger a potential relayout
1813 application.SendNotification();
1814 application.Render();
1816 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1817 Property::Map returnedMap;
1818 visual.CreatePropertyMap(returnedMap);
1820 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1821 DALI_TEST_CHECK(value);
1822 Property::Map* map = value->GetMap();
1823 DALI_TEST_CHECK(map);
1826 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1827 DALI_TEST_CHECK(value);
1828 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 500), TEST_LOCATION); // Change the internal size according to the image view size
1830 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1831 DALI_TEST_CHECK(value);
1832 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1834 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1835 DALI_TEST_CHECK(value);
1836 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1841 int UtcDaliImageViewFittingModesCenter01(void)
1843 ToolkitTestApplication application;
1845 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [700,700] )");
1846 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1848 ImageView imageView = ImageView::New();
1849 Property::Map imageMap;
1850 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1851 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1852 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1854 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1855 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1857 application.GetScene().Add(imageView);
1859 // Trigger a potential relayout
1860 application.SendNotification();
1861 application.Render();
1863 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1864 Property::Map returnedMap;
1865 visual.CreatePropertyMap(returnedMap);
1867 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1868 DALI_TEST_CHECK(value);
1869 Property::Map* map = value->GetMap();
1870 DALI_TEST_CHECK(map);
1872 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1873 DALI_TEST_CHECK(value);
1874 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1876 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1877 DALI_TEST_CHECK(value);
1878 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1880 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1881 DALI_TEST_CHECK(value);
1882 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1887 int UtcDaliImageViewFittingModesCenter02(void)
1889 ToolkitTestApplication application;
1891 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [500,500] )");
1892 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1894 ImageView imageView = ImageView::New();
1895 Property::Map imageMap;
1896 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1897 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1898 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1900 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1901 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1903 application.GetScene().Add(imageView);
1905 // Trigger a potential relayout
1906 application.SendNotification();
1907 application.Render();
1909 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1910 Property::Map returnedMap;
1911 visual.CreatePropertyMap(returnedMap);
1913 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1914 DALI_TEST_CHECK(value);
1915 Property::Map* map = value->GetMap();
1916 DALI_TEST_CHECK(map);
1918 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1919 DALI_TEST_CHECK(value);
1920 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1922 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1923 DALI_TEST_CHECK(value);
1924 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1926 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1927 DALI_TEST_CHECK(value);
1928 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1933 int UtcDaliImageViewFittingModesFitHeight01(void)
1935 ToolkitTestApplication application;
1937 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )");
1939 ImageView imageView = ImageView::New();
1940 Property::Map imageMap;
1941 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1942 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1943 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1945 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1946 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1948 application.GetScene().Add(imageView);
1950 // Trigger a potential relayout
1951 application.SendNotification();
1952 application.Render();
1954 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1955 Property::Map returnedMap;
1956 visual.CreatePropertyMap(returnedMap);
1958 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1959 DALI_TEST_CHECK(value);
1960 Property::Map* map = value->GetMap();
1961 DALI_TEST_CHECK(map);
1963 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1964 DALI_TEST_CHECK(value);
1965 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 700), TEST_LOCATION); // Change the internal size according to the image view size
1967 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1968 DALI_TEST_CHECK(value);
1969 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1971 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1972 DALI_TEST_CHECK(value);
1973 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1978 int UtcDaliImageViewFittingModesFitHeight02(void)
1980 ToolkitTestApplication application;
1982 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )");
1984 ImageView imageView = ImageView::New();
1985 Property::Map imageMap;
1986 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1987 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
1988 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1990 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1991 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
1993 application.GetScene().Add(imageView);
1995 // Trigger a potential relayout
1996 application.SendNotification();
1997 application.Render();
1999 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2000 Property::Map returnedMap;
2001 visual.CreatePropertyMap(returnedMap);
2003 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2004 DALI_TEST_CHECK(value);
2005 Property::Map* map = value->GetMap();
2006 DALI_TEST_CHECK(map);
2008 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2009 DALI_TEST_CHECK(value);
2010 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2012 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2013 DALI_TEST_CHECK(value);
2014 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2016 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2017 DALI_TEST_CHECK(value);
2018 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2023 int UtcDaliImageViewFittingModesFitWidth01(void)
2025 ToolkitTestApplication application;
2027 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )");
2029 ImageView imageView = ImageView::New();
2030 Property::Map imageMap;
2031 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2032 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2033 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2035 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2036 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2038 application.GetScene().Add(imageView);
2040 // Trigger a potential relayout
2041 application.SendNotification();
2042 application.Render();
2044 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2045 Property::Map returnedMap;
2046 visual.CreatePropertyMap(returnedMap);
2048 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2049 DALI_TEST_CHECK(value);
2050 Property::Map* map = value->GetMap();
2051 DALI_TEST_CHECK(map);
2053 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2054 DALI_TEST_CHECK(value);
2055 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2057 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2058 DALI_TEST_CHECK(value);
2059 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2061 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2062 DALI_TEST_CHECK(value);
2063 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
2068 int UtcDaliImageViewFittingModesFitWidth02(void)
2070 ToolkitTestApplication application;
2072 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )");
2074 ImageView imageView = ImageView::New();
2075 Property::Map imageMap;
2076 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2077 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2078 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2080 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2081 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2083 application.GetScene().Add(imageView);
2085 // Trigger a potential relayout
2086 application.SendNotification();
2087 application.Render();
2089 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2090 Property::Map returnedMap;
2091 visual.CreatePropertyMap(returnedMap);
2093 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2094 DALI_TEST_CHECK(value);
2095 Property::Map* map = value->GetMap();
2096 DALI_TEST_CHECK(map);
2098 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2099 DALI_TEST_CHECK(value);
2100 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 600), TEST_LOCATION); // Change the internal size according to the image view size
2102 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2103 DALI_TEST_CHECK(value);
2104 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2106 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2107 DALI_TEST_CHECK(value);
2108 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2113 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2115 ToolkitTestApplication application;
2117 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2119 ImageView imageView = ImageView::New();
2121 // 1. Render using FittingMode::SHRINK_TO_FIT
2122 Property::Map imageMap;
2123 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2124 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2125 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2127 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2128 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2130 application.GetScene().Add(imageView);
2132 // Trigger a potential relayout
2133 application.SendNotification();
2134 application.Render();
2136 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2137 Property::Map returnedMap;
2138 visual.CreatePropertyMap(returnedMap);
2140 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2141 DALI_TEST_CHECK(value);
2142 Property::Map* map = value->GetMap();
2143 DALI_TEST_CHECK(map);
2145 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2146 DALI_TEST_CHECK(value);
2147 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2149 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2150 DALI_TEST_CHECK(value);
2151 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2153 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2154 DALI_TEST_CHECK(value);
2155 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2157 // 2. Render again using DevelVisaul::CENTER
2158 Property::Map imageMap2;
2159 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2160 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2161 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2163 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2164 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2166 application.GetScene().Add(imageView);
2168 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2170 // Trigger a potential relayout
2171 application.SendNotification();
2172 application.Render();
2174 returnedMap.Clear();
2175 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2177 visual.CreatePropertyMap(returnedMap);
2179 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2180 DALI_TEST_CHECK(value);
2181 map = value->GetMap();
2182 DALI_TEST_CHECK(map);
2184 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2185 DALI_TEST_CHECK(value);
2186 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2188 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2189 DALI_TEST_CHECK(value);
2190 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2192 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2193 DALI_TEST_CHECK(value);
2194 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2196 // 3. Render again using before fittingMode
2197 Property::Map imageMap3;
2198 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2199 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2200 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2202 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2203 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2205 application.GetScene().Add(imageView);
2207 // Trigger a potential relayout
2208 application.SendNotification();
2209 application.Render();
2211 returnedMap.Clear();
2212 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2213 visual.CreatePropertyMap(returnedMap);
2215 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2216 DALI_TEST_CHECK(value);
2217 map = value->GetMap();
2218 DALI_TEST_CHECK(map);
2220 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2221 DALI_TEST_CHECK(value);
2222 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2224 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2225 DALI_TEST_CHECK(value);
2226 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2228 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2229 DALI_TEST_CHECK(value);
2230 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2235 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2237 ToolkitTestApplication application;
2239 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2241 ImageView imageView = ImageView::New();
2243 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2244 Property::Map imageMap;
2245 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2246 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2247 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2249 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2250 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2252 application.GetScene().Add(imageView);
2254 // Trigger a potential relayout
2255 application.SendNotification();
2256 application.Render();
2258 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2259 Property::Map returnedMap;
2260 visual.CreatePropertyMap(returnedMap);
2262 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2263 DALI_TEST_CHECK(value);
2264 Property::Map* map = value->GetMap();
2265 DALI_TEST_CHECK(map);
2267 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2268 DALI_TEST_CHECK(value);
2269 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2271 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2272 DALI_TEST_CHECK(value);
2273 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2275 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2276 DALI_TEST_CHECK(value);
2277 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2279 // 2. Render again using DevelVisaul::CENTER
2280 Property::Map imageMap2;
2281 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2282 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2283 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2285 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2286 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2288 application.GetScene().Add(imageView);
2290 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2292 // Trigger a potential relayout
2293 application.SendNotification();
2294 application.Render();
2296 returnedMap.Clear();
2297 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2299 visual.CreatePropertyMap(returnedMap);
2301 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2302 DALI_TEST_CHECK(value);
2303 map = value->GetMap();
2304 DALI_TEST_CHECK(map);
2306 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2307 DALI_TEST_CHECK(value);
2308 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2310 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2311 DALI_TEST_CHECK(value);
2312 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2314 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2315 DALI_TEST_CHECK(value);
2316 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2318 // 3. Render again using before fittingMode
2319 Property::Map imageMap3;
2320 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2321 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2322 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2324 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2325 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2327 application.GetScene().Add(imageView);
2329 // Trigger a potential relayout
2330 application.SendNotification();
2331 application.Render();
2333 returnedMap.Clear();
2334 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2335 visual.CreatePropertyMap(returnedMap);
2337 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2338 DALI_TEST_CHECK(value);
2339 map = value->GetMap();
2340 DALI_TEST_CHECK(map);
2342 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2343 DALI_TEST_CHECK(value);
2344 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2346 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2347 DALI_TEST_CHECK(value);
2348 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2350 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2351 DALI_TEST_CHECK(value);
2352 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2357 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2359 ToolkitTestApplication application;
2361 tet_infoline("Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )");
2363 ImageView imageView = ImageView::New();
2364 Property::Map imageMap;
2365 imageMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE);
2366 imageMap.Add(Toolkit::ImageVisual::Property::URL, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME); // 249x169 image
2368 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2369 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
2371 application.GetScene().Add(imageView);
2373 // Trigger a potential relayout
2374 application.SendNotification();
2375 application.Render();
2377 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2378 Property::Map returnedMap;
2379 visual.CreatePropertyMap(returnedMap);
2381 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2382 DALI_TEST_CHECK(value);
2383 Property::Map* map = value->GetMap();
2384 DALI_TEST_CHECK(map);
2386 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2387 DALI_TEST_CHECK(value);
2388 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Relative size so will take up 100%
2390 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2391 DALI_TEST_CHECK(value);
2392 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2394 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2395 DALI_TEST_CHECK(value);
2396 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2401 int UtcDaliImageViewCustomShader(void)
2403 ToolkitTestApplication application;
2405 // Set a custom shader with an image url
2407 Property::Map properties;
2408 Property::Map shader;
2409 const std::string vertexShader = "Foobar";
2410 const std::string fragmentShader = "Foobar";
2411 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2412 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2414 properties[Visual::Property::TYPE] = Visual::IMAGE;
2415 properties[Visual::Property::SHADER] = shader;
2416 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2418 ImageView imageView = ImageView::New();
2419 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2421 application.GetScene().Add(imageView);
2423 application.SendNotification();
2424 application.Render();
2426 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2428 Renderer renderer = imageView.GetRendererAt(0);
2429 Shader shader2 = renderer.GetShader();
2430 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2431 Property::Map* map = value.GetMap();
2432 DALI_TEST_CHECK(map);
2434 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2435 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2437 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2438 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2441 // Set a custom shader after setting an image url
2443 Property::Map properties;
2444 Property::Map shader;
2445 const std::string vertexShader = "Foobar";
2446 const std::string fragmentShader = "Foobar";
2447 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2448 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2450 properties[Visual::Property::SHADER] = shader;
2452 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
2453 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2455 application.GetScene().Add(imageView);
2457 application.SendNotification();
2458 application.Render();
2460 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2462 Renderer renderer = imageView.GetRendererAt(0);
2463 Shader shader2 = renderer.GetShader();
2464 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2465 Property::Map* map = value.GetMap();
2466 DALI_TEST_CHECK(map);
2468 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2469 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2471 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2472 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2475 // Set a custom shader before setting an image url
2477 Property::Map properties;
2478 Property::Map shader;
2479 const std::string vertexShader = "Foobar";
2480 const std::string fragmentShader = "Foobar";
2481 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2482 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2484 properties[Visual::Property::SHADER] = shader;
2486 ImageView imageView = ImageView::New();
2487 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2488 imageView.SetProperty(ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME);
2490 application.GetScene().Add(imageView);
2492 application.SendNotification();
2493 application.Render();
2494 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2496 Renderer renderer = imageView.GetRendererAt(0);
2497 Shader shader2 = renderer.GetShader();
2498 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2499 Property::Map* map = value.GetMap();
2500 DALI_TEST_CHECK(map);
2502 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2503 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2505 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2506 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2509 // Set a custom shader after setting a property map
2511 Property::Map properties;
2512 Property::Map shader;
2513 const std::string vertexShader = "Foobar";
2514 const std::string fragmentShader = "Foobar";
2515 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2516 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2518 properties[Visual::Property::SHADER] = shader;
2520 Property::Map properties1;
2521 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2522 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2524 ImageView imageView = ImageView::New();
2525 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2526 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2528 application.GetScene().Add(imageView);
2530 application.SendNotification();
2531 application.Render();
2532 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2534 Renderer renderer = imageView.GetRendererAt(0);
2535 Shader shader2 = renderer.GetShader();
2536 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2537 Property::Map* map = value.GetMap();
2538 DALI_TEST_CHECK(map);
2540 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2541 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2543 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2544 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2547 // Set a custom shader before setting a property map
2549 Property::Map properties;
2550 Property::Map shader;
2551 const std::string vertexShader = "Foobar";
2552 const std::string fragmentShader = "Foobar";
2553 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2554 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2556 properties[Visual::Property::SHADER] = shader;
2558 Property::Map properties1;
2559 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2560 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2562 ImageView imageView = ImageView::New();
2563 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2564 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2566 application.GetScene().Add(imageView);
2568 application.SendNotification();
2569 application.Render();
2570 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2572 Renderer renderer = imageView.GetRendererAt(0);
2573 Shader shader2 = renderer.GetShader();
2574 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2575 Property::Map* map = value.GetMap();
2576 DALI_TEST_CHECK(map);
2578 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2579 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2581 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2582 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2590 static int gFailCounter = 0;
2591 const int MAX_RETRIES(3);
2593 void ReloadImage(ImageView imageView)
2595 Property::Map imageImmediateLoadingMap;
2596 imageImmediateLoadingMap[ImageVisual::Property::URL] = "Non-existant-image.jpg";
2597 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
2599 tet_infoline("Immediate load an image");
2600 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
2603 void ResourceFailedReload(Control control)
2606 if(gFailCounter < MAX_RETRIES)
2608 ReloadImage(ImageView::DownCast(control));
2613 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2615 tet_infoline("Test reloading failed image from within signal handler.");
2617 ToolkitTestApplication application;
2621 ImageView imageView = ImageView::New();
2622 imageView.ResourceReadySignal().Connect(&ResourceFailedReload);
2623 DALI_TEST_EQUALS(gFailCounter, 0, TEST_LOCATION);
2624 ReloadImage(imageView);
2626 // loading started, this waits for the loader thread to complete
2627 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2628 application.SendNotification();
2630 DALI_TEST_EQUALS(gFailCounter, 1, TEST_LOCATION);
2632 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2633 application.SendNotification();
2635 DALI_TEST_EQUALS(gFailCounter, 2, TEST_LOCATION);
2637 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2638 application.SendNotification();
2639 DALI_TEST_EQUALS(gFailCounter, 3, TEST_LOCATION);
2644 int UtcDaliImageViewLoadRemoteSVG(void)
2646 tet_infoline("Test load from a remote server.");
2648 ToolkitTestApplication application;
2651 Toolkit::ImageView imageView;
2652 imageView = Toolkit::ImageView::New();
2653 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2654 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2655 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2656 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2657 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2659 application.GetScene().Add(imageView);
2661 DALI_TEST_CHECK(imageView);
2663 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2665 application.SendNotification();
2667 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2669 application.SendNotification();
2670 application.Render();
2672 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2677 Toolkit::ImageView imageView;
2678 imageView = Toolkit::ImageView::New();
2679 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2680 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2681 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2682 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2684 application.GetScene().Add(imageView);
2686 DALI_TEST_CHECK(imageView);
2688 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2690 application.SendNotification();
2692 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2694 application.SendNotification();
2695 application.Render();
2697 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2703 int UtcDaliImageViewSyncSVGLoading(void)
2705 ToolkitTestApplication application;
2707 tet_infoline("ImageView Testing SVG image sync loading");
2710 ImageView imageView = ImageView::New();
2712 // Sync loading is used
2713 Property::Map syncLoadingMap;
2714 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2715 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2716 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2717 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2719 application.GetScene().Add(imageView);
2720 DALI_TEST_CHECK(imageView);
2722 application.SendNotification();
2723 Vector3 naturalSize = imageView.GetNaturalSize();
2725 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2726 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2731 int UtcDaliImageViewAsyncSVGLoading(void)
2733 ToolkitTestApplication application;
2735 tet_infoline("ImageView Testing SVG image async loading");
2738 ImageView imageView = ImageView::New();
2740 // Async loading is used - default value of SYNCHRONOUS_LOADING is false.
2741 Property::Map propertyMap;
2742 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2743 propertyMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2744 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
2746 application.GetScene().Add(imageView);
2747 DALI_TEST_CHECK(imageView);
2749 application.SendNotification();
2751 // Wait for rasterization
2752 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2754 application.SendNotification();
2755 application.Render(16);
2757 Vector3 naturalSize = imageView.GetNaturalSize();
2758 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2759 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2764 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2766 ToolkitTestApplication application;
2768 tet_infoline("ImageView Testing SVG image async loading");
2772 ImageView imageView = ImageView::New();
2774 // Sync loading is used
2775 Property::Map syncLoadingMap;
2776 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2777 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2779 // Check to set invalid value
2780 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2781 // Check if error log is outputted when setting other value like string.
2782 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2783 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5));
2784 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2786 application.GetScene().Add(imageView);
2787 DALI_TEST_CHECK(imageView);
2789 application.SendNotification();
2791 // Wait for rasterization
2792 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2794 application.SendNotification();
2795 application.Render(16);
2797 Vector3 naturalSize = imageView.GetNaturalSize();
2798 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2799 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2801 Property::Value value = imageView.GetProperty(ImageView::Property::IMAGE);
2802 Property::Map* map = value.GetMap();
2803 DALI_TEST_CHECK(map);
2805 Property::Value* sync = map->Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING);
2806 DALI_TEST_CHECK(sync);
2807 DALI_TEST_EQUALS(false, sync->Get<bool>(), TEST_LOCATION);
2812 int UtcDaliImageViewSvgLoadingFailure(void)
2814 ToolkitTestApplication application;
2816 TestGlAbstraction& gl = application.GetGlAbstraction();
2817 TraceCallStack& textureTrace = gl.GetTextureTrace();
2818 textureTrace.Enable(true);
2820 // Local svg file - invalid file path
2822 gResourceReadySignalFired = false;
2824 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2825 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2826 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2828 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2830 application.GetScene().Add(imageView);
2832 application.SendNotification();
2834 // loading started, this waits for the loader thread
2835 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2837 application.SendNotification();
2838 application.Render(16);
2840 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2841 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2842 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2844 // Should be shown a broken image
2845 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2846 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2849 // Local svg file - invalid file path without size set
2851 gResourceReadySignalFired = false;
2852 textureTrace.Reset();
2854 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2855 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2857 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2859 application.GetScene().Add(imageView);
2861 application.SendNotification();
2863 // loading started, this waits for the loader thread
2864 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2866 application.SendNotification();
2867 application.Render(16);
2869 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2870 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2871 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2873 // Should be shown a broken image
2874 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2875 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2878 // Local svg file - invalid file
2880 gResourceReadySignalFired = false;
2881 textureTrace.Reset();
2883 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.svg");
2884 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2885 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2887 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2889 application.GetScene().Add(imageView);
2891 application.SendNotification();
2893 // loading started, this waits for the loader thread
2894 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2896 application.SendNotification();
2897 application.Render(16);
2899 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2900 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2901 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2903 // Should be shown a broken image
2904 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2905 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2910 gResourceReadySignalFired = false;
2911 textureTrace.Reset();
2913 ImageView imageView = ImageView::New("https://bar.org/foobar.svg");
2914 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2915 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2917 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2919 application.GetScene().Add(imageView);
2921 application.SendNotification();
2923 // loading started, this waits for the loader thread
2924 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2926 application.SendNotification();
2927 application.Render(16);
2929 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2930 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2931 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2933 // Should be shown a broken image
2934 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2935 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2938 // Remote svg file without size set
2940 gResourceReadySignalFired = false;
2941 textureTrace.Reset();
2943 ImageView imageView = ImageView::New("https://bar.org/foobar.svg");
2944 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2946 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2948 application.GetScene().Add(imageView);
2950 application.SendNotification();
2952 // loading started, this waits for the loader thread
2953 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2955 application.SendNotification();
2956 application.Render(16);
2958 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2959 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2960 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2962 // Should be shown a broken image
2963 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2964 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2970 int UtcDaliImageViewSvgRasterizationFailure(void)
2972 ToolkitTestApplication application;
2974 gResourceReadySignalFired = false;
2976 TestGlAbstraction& gl = application.GetGlAbstraction();
2977 TraceCallStack& textureTrace = gl.GetTextureTrace();
2978 textureTrace.Enable(true);
2980 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid1.svg");
2981 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2982 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2984 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2986 application.GetScene().Add(imageView);
2988 application.SendNotification();
2990 // loading started, this waits for the loader thread
2991 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2993 application.SendNotification();
2994 application.Render(16);
2996 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2997 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2998 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3000 // Should be shown a broken image
3001 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3002 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3007 int UtcDaliImageViewSvgChageSize(void)
3009 ToolkitTestApplication application;
3011 TestGlAbstraction& gl = application.GetGlAbstraction();
3012 TraceCallStack& textureTrace = gl.GetTextureTrace();
3013 textureTrace.Enable(true);
3015 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME);
3016 application.GetScene().Add(imageView);
3018 application.SendNotification();
3020 // loading started, this waits for the loader thread
3021 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3023 application.SendNotification();
3024 application.Render(16);
3026 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3028 // Change actor size, then rasterization should be done again
3029 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3031 application.SendNotification();
3033 // loading started, this waits for the loader thread
3034 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3036 application.SendNotification();
3037 application.Render(16);
3039 // We should not load the file again.
3040 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3045 int UtcDaliImageViewTVGLoading(void)
3047 ToolkitTestApplication application;
3049 tet_infoline("ImageView Testing TVG image loading");
3052 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/test.tvg");
3053 application.GetScene().Add(imageView);
3054 DALI_TEST_CHECK(imageView);
3056 application.SendNotification();
3058 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3060 application.SendNotification();
3061 application.Render(16);
3063 Vector3 naturalSize = imageView.GetNaturalSize();
3065 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3066 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3071 int UtcDaliImageViewImageLoadFailure01(void)
3073 ToolkitTestApplication application;
3075 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3076 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3077 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3078 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3080 std::string brokenUrl;
3081 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3082 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3084 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3085 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3087 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3088 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3090 ImageView imageView = ImageView::New("invalidUrl.png");
3091 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3093 application.GetScene().Add(imageView);
3094 application.SendNotification();
3095 application.Render(16);
3097 // loading started, this waits for the loader thread
3098 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3103 int UtcDaliImageViewImageLoadFailure02(void)
3105 ToolkitTestApplication application;
3107 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3108 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
3109 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3110 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3112 std::string brokenUrl;
3113 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3114 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
3116 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3117 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3119 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3120 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3122 ImageView imageView = ImageView::New("invalidUrl.png");
3123 imageView.SetProperty(Actor::Property::SIZE, Vector2(30.f, 30.f));
3124 application.GetScene().Add(imageView);
3125 application.SendNotification();
3126 application.Render(16);
3128 // loading started, this waits for the loader thread
3129 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3134 int UtcDaliImageViewImageLoadFailure03(void)
3136 ToolkitTestApplication application;
3138 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3139 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
3140 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
3142 std::string brokenUrl;
3143 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3144 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3146 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3147 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3149 ImageView imageView = ImageView::New("invalidUrl.png");
3150 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3151 application.GetScene().Add(imageView);
3152 application.SendNotification();
3153 application.Render(16);
3155 // loading started, this waits for the loader thread
3156 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3161 int UtcDaliImageViewImageLoadFailure04(void)
3163 ToolkitTestApplication application;
3165 ImageView imageView = ImageView::New("invalidUrl.png");
3166 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3167 application.GetScene().Add(imageView);
3168 application.SendNotification();
3169 application.Render(16);
3171 // loading started, this waits for the loader thread
3172 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3174 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3175 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3176 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3177 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3179 ImageView imageView2 = ImageView::New("invalidUrl.png");
3180 imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3181 application.GetScene().Add(imageView2);
3183 std::string brokenUrl;
3184 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3185 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3187 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3188 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3190 application.SendNotification();
3191 application.Render(16);
3193 // loading started, this waits for the loader thread
3194 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3196 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3198 ImageView imageView3 = ImageView::New("invalidUrl.png");
3199 imageView3.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3200 application.GetScene().Add(imageView3);
3202 application.SendNotification();
3203 application.Render(16);
3205 // loading started, this waits for the loader thread
3206 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3213 static int gResourceReadySignalCounter = 0;
3215 void OnResourceReadySignal01(Control control)
3217 gResourceReadySignalCounter++;
3219 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3221 if(gResourceReadySignalCounter == 1)
3224 // It makes the first new visual be deleted immediately
3225 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3226 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3229 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3231 // Make the resource ready immediately
3232 control[ImageView::Property::IMAGE] = gImage_600_RGB;
3236 void OnResourceReadySignal02(Control control)
3238 if(++gResourceReadySignalCounter == 1)
3240 // It makes the first new visual be deleted immediately
3241 // The first image will not be loaded.
3242 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB).Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3243 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3247 ImageView gImageView1;
3248 ImageView gImageView2;
3249 ImageView gImageView3;
3250 ImageView gImageView4;
3252 void OnResourceReadySignal03(Control control)
3254 if(gResourceReadySignalCounter == 0)
3257 // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3258 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3260 // 2. Load a new image
3261 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3263 // 3. Use the new image again
3264 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3265 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3267 else if(gResourceReadySignalCounter == 1)
3269 // This is called from TextureManager::ProcessQueuedTextures().
3270 gImageView1.Unparent();
3271 gImageView1.Reset();
3273 gResourceReadySignalCounter++;
3276 void OnSimpleResourceReadySignal(Control control)
3278 // simply increate counter
3279 gResourceReadySignalCounter++;
3282 int gResourceReadySignal04ComesOrder = 0;
3284 void OnResourceReadySignal04(Control control)
3286 gResourceReadySignalCounter++;
3287 tet_printf("rc %d\n", gResourceReadySignalCounter);
3288 if(gResourceReadySignalCounter == 1)
3290 auto scene = gImageView1.GetParent();
3292 // Request load something
3293 // We hope this request result is return later than gImageView2.
3294 gImageView3 = ImageView::New(TEST_IMAGE_1);
3295 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3296 scene.Add(gImageView3);
3297 gImageView4 = ImageView::New(TEST_IMAGE_2);
3298 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3299 scene.Add(gImageView4);
3301 if(control == gImageView1)
3303 gResourceReadySignal04ComesOrder = 1;
3307 gResourceReadySignal04ComesOrder = 2;
3310 if(gResourceReadySignalCounter == 2)
3312 if(gResourceReadySignal04ComesOrder == 1 && control == gImageView2)
3314 // Scene off first one.
3315 gImageView1.Unparent();
3317 // Scene off second one.
3318 gImageView2.Unparent();
3320 else if(gResourceReadySignal04ComesOrder == 2 && control == gImageView1)
3322 // Scene off first one.
3323 gImageView2.Unparent();
3325 // Scene off second one.
3326 gImageView1.Unparent();
3330 // We can't check that this utc fail case. just pass always when we come here.
3331 gResourceReadySignal04ComesOrder = -1;
3334 // If we don't seperate index of FreeList area
3335 // and if we don't queue remove during obversing,
3336 // cache index become something invalid data.
3337 // In this case, some strange observer can be called.
3338 // For example, gImageView4.LoadComplete will be called.
3344 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3346 tet_infoline("Test setting image from within signal handler.");
3348 ToolkitTestApplication application;
3350 gResourceReadySignalCounter = 0;
3352 ImageView imageView = ImageView::New(gImage_34_RGBA);
3353 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal01);
3355 application.GetScene().Add(imageView);
3357 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3359 application.SendNotification();
3360 application.Render();
3362 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3364 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3366 // Create a new ImageView to cache the image
3367 ImageView imageView1 = ImageView::New(gImage_600_RGB);
3368 application.GetScene().Add(imageView1);
3370 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3372 application.SendNotification();
3373 application.Render();
3376 gResourceReadySignalCounter = 0;
3378 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3380 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3382 application.SendNotification();
3383 application.Render();
3385 // Run idle callback
3386 application.RunIdles();
3388 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3390 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3395 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
3397 tet_infoline("Test setting image from within signal handler.");
3399 ToolkitTestApplication application;
3401 gResourceReadySignalCounter = 0;
3403 ImageView imageView = ImageView::New(gImage_34_RGBA);
3404 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal02);
3406 application.GetScene().Add(imageView);
3408 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3410 application.SendNotification();
3411 application.Render();
3413 // Wait for loading an image
3414 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3416 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3418 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3423 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3425 tet_infoline("Test setting image from within signal handler.");
3427 ToolkitTestApplication application;
3429 gResourceReadySignalCounter = 0;
3431 gImageView1 = ImageView::New(gImage_34_RGBA);
3432 application.GetScene().Add(gImageView1);
3435 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3437 gImageView2 = ImageView::New(gImage_600_RGB);
3438 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3439 application.GetScene().Add(gImageView2);
3441 gImageView3 = ImageView::New();
3442 application.GetScene().Add(gImageView3);
3444 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3446 application.SendNotification();
3447 application.Render();
3452 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask01(void)
3454 tet_infoline("Test signal handler when image / mask image is broken.");
3456 ToolkitTestApplication application;
3458 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, const std::string& url, const std::string& mask, const char* location) {
3459 gResourceReadySignalCounter = 0;
3462 map[Toolkit::ImageVisual::Property::URL] = url;
3465 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3467 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3469 ImageView imageView = ImageView::New();
3470 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3471 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3472 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3474 application.GetScene().Add(imageView);
3475 application.SendNotification();
3476 application.Render();
3481 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3483 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3484 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3486 imageView.Unparent();
3489 for(int synchronous = 0; synchronous <= 1; synchronous++)
3491 tet_printf("Test normal case (sync:%d)\n", synchronous);
3492 TestResourceReadyUrl(1, synchronous, gImage_600_RGB, "", TEST_LOCATION);
3493 TestResourceReadyUrl(3, synchronous, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 3 event trigger required : 2 image load + 1 apply mask
3495 tet_printf("Test broken image case (sync:%d)\n", synchronous);
3496 TestResourceReadyUrl(1, synchronous, "invalid.jpg", "", TEST_LOCATION);
3497 TestResourceReadyUrl(2, synchronous, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3499 tet_printf("Test broken mask image case (sync:%d)\n", synchronous);
3500 TestResourceReadyUrl(2, synchronous, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3502 tet_printf("Test broken both image, mask image case (sync:%d)\n", synchronous);
3503 TestResourceReadyUrl(2, synchronous, "invalid.jpg", "invalid.png", TEST_LOCATION);
3509 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask02(void)
3511 tet_infoline("Test signal handler when image try to use cached-and-broken mask image.");
3513 ToolkitTestApplication application;
3515 gResourceReadySignalCounter = 0;
3517 auto TestBrokenMaskResourceReadyUrl = [&application](const std::string& url, const char* location) {
3519 map[Toolkit::ImageVisual::Property::URL] = url;
3520 // Use invalid mask url
3521 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
3523 ImageView imageView = ImageView::New();
3524 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3525 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3526 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3528 application.GetScene().Add(imageView);
3529 application.SendNotification();
3530 application.Render();
3532 // Don't unparent imageView, for keep the cache.
3535 // Use more than 4 images (The number of LocalImageLoadThread)
3536 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};
3538 int expectResourceReadySignalCounter = 0;
3540 for(auto& url : testUrlList)
3542 TestBrokenMaskResourceReadyUrl(url, TEST_LOCATION);
3543 expectResourceReadySignalCounter++;
3546 // Remain 1 signal due to we use #URL + 1 mask image.
3547 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(expectResourceReadySignalCounter + 1), true, TEST_LOCATION);
3549 DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
3554 int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
3556 tet_infoline("Test signal handler various case.");
3558 ToolkitTestApplication application;
3560 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
3561 gResourceReadySignalCounter = 0;
3564 map[Toolkit::ImageVisual::Property::URL] = url;
3567 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3569 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3571 ImageView imageView = ImageView::New();
3572 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3573 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3574 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3576 application.GetScene().Add(imageView);
3577 application.SendNotification();
3578 application.Render();
3581 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3583 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3584 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3585 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3587 imageView.Unparent();
3590 auto TestAuxiliaryResourceReadyUrl = [&application](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
3591 gResourceReadySignalCounter = 0;
3594 map[Toolkit::ImageVisual::Property::URL] = url;
3595 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE] = auxiliaryUrl;
3596 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA] = 0.5f;
3597 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3599 ImageView imageView = ImageView::New();
3600 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
3601 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
3602 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3603 application.GetScene().Add(imageView);
3605 application.SendNotification();
3606 application.Render();
3611 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, location);
3614 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3615 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3616 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3618 imageView.Unparent();
3621 // Case 1 : asynchronous loading
3622 tet_printf("Test invalid single simple image Asynchronous\n");
3625 TestResourceReadyUrl(1, 0, 1, gImage_600_RGB, "", TEST_LOCATION);
3626 TestResourceReadyUrl(1, 0, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // 1 rasterize
3627 TestResourceReadyUrl(1, 0, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
3629 TestResourceReadyUrl(2, 0, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // 2 image loading - batch size
3630 TestResourceReadyUrl(1, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // 1 rasterize
3632 TestResourceReadyUrl(3, 0, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 2 image loading + 1 applymask
3634 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
3637 TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
3638 TestResourceReadyUrl(1, 0, 0, "invalid.svg", "", TEST_LOCATION);
3639 TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
3640 TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION); // 1 image loading
3641 TestResourceReadyUrl(0, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
3643 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", "invalid.png", TEST_LOCATION); // 2 image loading
3644 TestResourceReadyUrl(2, 0, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); // 2 image loading
3645 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION); // 2 image loading
3647 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
3648 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
3649 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
3651 // Case 2 : Synchronous loading
3652 tet_printf("Test invalid single simple image Synchronous\n");
3655 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "", TEST_LOCATION);
3656 TestResourceReadyUrl(0, 1, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
3657 TestResourceReadyUrl(0, 1, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
3659 TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // first frame image loading sync + second frame image loading async
3660 TestResourceReadyUrl(0, 1, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
3662 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION);
3664 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
3667 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
3668 TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION);
3669 TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
3670 TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
3671 TestResourceReadyUrl(0, 1, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
3673 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "invalid.png", TEST_LOCATION);
3674 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3675 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3677 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
3678 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
3679 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
3684 int UtcDaliImageViewSetImageOnResourceReadySignal04(void)
3686 tet_infoline("Test texturemanager's remove queue works well within signal handler.");
3688 ToolkitTestApplication application;
3690 gResourceReadySignalCounter = 0;
3691 gResourceReadySignal04ComesOrder = 0;
3693 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
3694 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3695 application.GetScene().Add(gImageView1);
3697 gImageView2 = ImageView::New("invalid.png"); // request invalid image, to make loading failed fast.
3698 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3699 application.GetScene().Add(gImageView2);
3701 application.SendNotification();
3702 application.Render();
3704 tet_infoline("Try to load 2 invalid image");
3706 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3707 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3709 tet_infoline("load done");
3711 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
3712 if(gResourceReadySignal04ComesOrder == -1)
3714 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
3718 // gImageView3 and gImageView4 load must not be successed yet.
3719 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
3720 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
3722 application.SendNotification();
3723 application.Render();
3725 tet_infoline("Try to load 2 valid image");
3727 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3728 DALI_TEST_EQUALS(gResourceReadySignalCounter, 4, TEST_LOCATION);
3730 tet_infoline("load done");
3732 // gImageView3 and gImageView4 load must be successed now.
3733 DALI_TEST_EQUALS(gImageView3.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
3734 DALI_TEST_EQUALS(gImageView4.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);