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";
84 const char* TEST_WEBP_FILE_NAME = TEST_RESOURCE_DIR "/dali-logo.webp";
86 void TestUrl(ImageView imageView, const std::string url)
88 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
90 std::string urlActual;
91 DALI_TEST_CHECK(value.Get(urlActual));
92 DALI_TEST_EQUALS(urlActual, url, TEST_LOCATION);
97 int UtcDaliImageViewNewP(void)
99 ToolkitTestApplication application;
101 ImageView imageView = ImageView::New();
103 DALI_TEST_CHECK(imageView);
108 int UtcDaliImageViewNewUrlP(void)
110 ToolkitTestApplication application;
112 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
113 DALI_TEST_CHECK(imageView);
115 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
120 int UtcDaliImageViewConstructorP(void)
122 ToolkitTestApplication application;
126 DALI_TEST_CHECK(!imageView);
131 int UtcDaliImageViewCopyConstructorP(void)
133 ToolkitTestApplication application;
135 // Initialize an object, ref count == 1
136 ImageView imageView = ImageView::New();
138 ImageView copy(imageView);
139 DALI_TEST_CHECK(copy);
144 int UtcDaliImageViewMoveConstructor(void)
146 ToolkitTestApplication application;
148 ImageView imageView = ImageView::New();
149 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
150 imageView.SetProperty(Actor::Property::SENSITIVE, false);
151 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
153 ImageView moved = std::move(imageView);
154 DALI_TEST_CHECK(moved);
155 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
156 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
157 DALI_TEST_CHECK(!imageView);
162 int UtcDaliImageViewAssignmentOperatorP(void)
164 ToolkitTestApplication application;
166 ImageView imageView = ImageView::New();
168 ImageView copy(imageView);
169 DALI_TEST_CHECK(copy);
170 DALI_TEST_EQUALS(imageView, copy, TEST_LOCATION);
175 int UtcDaliImageViewMoveAssignment(void)
177 ToolkitTestApplication application;
179 ImageView imageView = ImageView::New();
180 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
181 imageView.SetProperty(Actor::Property::SENSITIVE, false);
182 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
185 moved = std::move(imageView);
186 DALI_TEST_CHECK(moved);
187 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
188 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
189 DALI_TEST_CHECK(!imageView);
194 int UtcDaliImageViewDownCastP(void)
196 ToolkitTestApplication application;
198 ImageView imageView = ImageView::New();
200 BaseHandle object(imageView);
202 ImageView imageView2 = ImageView::DownCast(object);
203 DALI_TEST_CHECK(imageView2);
205 ImageView imageView3 = DownCast<ImageView>(object);
206 DALI_TEST_CHECK(imageView3);
211 int UtcDaliImageViewDownCastN(void)
213 ToolkitTestApplication application;
215 BaseHandle unInitializedObject;
217 ImageView imageView1 = ImageView::DownCast(unInitializedObject);
218 DALI_TEST_CHECK(!imageView1);
220 ImageView imageView2 = DownCast<ImageView>(unInitializedObject);
221 DALI_TEST_CHECK(!imageView2);
226 int UtcDaliImageViewTypeRegistry(void)
228 ToolkitTestApplication application;
230 TypeRegistry typeRegistry = TypeRegistry::Get();
231 DALI_TEST_CHECK(typeRegistry);
233 TypeInfo typeInfo = typeRegistry.GetTypeInfo("ImageView");
234 DALI_TEST_CHECK(typeInfo);
236 BaseHandle handle = typeInfo.CreateInstance();
237 DALI_TEST_CHECK(handle);
239 ImageView imageView = ImageView::DownCast(handle);
240 DALI_TEST_CHECK(imageView);
245 int UtcDaliImageViewSetGetProperty01(void)
247 ToolkitTestApplication application;
249 ImageView imageView = ImageView::New();
251 Property::Index idx = imageView.GetPropertyIndex("image");
252 DALI_TEST_EQUALS(idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION);
254 imageView.SetProperty(idx, TEST_IMAGE_FILE_NAME);
255 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
260 int UtcDaliImageViewPreMultipliedAlphaPng(void)
262 ToolkitTestApplication application;
264 // Set up trace debug
265 TestGlAbstraction& gl = application.GetGlAbstraction();
266 TraceCallStack& textureTrace = gl.GetTextureTrace();
267 textureTrace.Enable(true);
269 Property::Map imageMap;
270 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
271 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
273 ImageView imageView1 = ImageView::New();
274 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
276 application.GetScene().Add(imageView1);
278 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
280 DALI_TEST_CHECK(value.Get(enable));
281 DALI_TEST_CHECK(enable); // Default value is true
283 // loading started, this waits for the loader thread for max 30 seconds
284 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
286 application.SendNotification();
287 application.Render();
289 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
290 DALI_TEST_CHECK(value.Get(enable));
291 DALI_TEST_CHECK(enable); // Keep true
293 // conventional alpha blending
294 Renderer renderer1 = imageView1.GetRendererAt(0);
295 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
296 DALI_TEST_CHECK(value.Get(enable));
297 DALI_TEST_CHECK(enable);
299 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
300 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
301 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
302 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
303 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
304 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
305 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
306 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
308 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
309 textureTrace.Reset();
311 // Disable pre-multiplied alpha blending
312 imageView1.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
315 Property::Map attributes;
316 DevelControl::DoAction(imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
318 // loading started, this waits for the loader thread for max 30 seconds
319 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
321 application.SendNotification();
322 application.Render();
324 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
325 DALI_TEST_CHECK(value.Get(enable));
326 DALI_TEST_CHECK(!enable);
328 // conventional alpha blending
329 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
330 DALI_TEST_CHECK(value.Get(enable));
331 DALI_TEST_CHECK(!enable);
333 srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
334 destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
335 srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
336 destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
337 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
338 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
339 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
340 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
342 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
343 textureTrace.Reset();
345 // Make a new ImageView using the same image
346 ImageView imageView2 = ImageView::New();
347 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
349 application.GetScene().Add(imageView2);
351 application.SendNotification();
352 application.Render();
354 Renderer renderer2 = imageView2.GetRendererAt(0);
355 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
356 DALI_TEST_CHECK(value.Get(enable));
357 DALI_TEST_CHECK(enable);
359 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
360 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
361 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
362 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
363 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
364 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
365 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
366 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
368 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
373 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
375 ToolkitTestApplication application;
377 // Set up trace debug
378 TestGlAbstraction& gl = application.GetGlAbstraction();
379 TraceCallStack& textureTrace = gl.GetTextureTrace();
380 textureTrace.Enable(true);
382 Property::Map imageMap;
383 imageMap[ImageVisual::Property::URL] = gImage_600_RGB;
384 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
386 ImageView imageView1 = ImageView::New();
387 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
389 application.GetScene().Add(imageView1);
391 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
393 DALI_TEST_CHECK(value.Get(enable));
394 DALI_TEST_CHECK(enable); // Default value is true
396 // loading started, this waits for the loader thread for max 30 seconds
397 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
399 application.SendNotification();
400 application.Render();
402 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
403 DALI_TEST_CHECK(value.Get(enable));
404 DALI_TEST_CHECK(!enable); // Should be false after loading
406 // conventional alpha blending
407 Renderer renderer1 = imageView1.GetRendererAt(0);
408 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
409 DALI_TEST_CHECK(value.Get(enable));
410 DALI_TEST_CHECK(!enable);
412 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
413 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
414 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
415 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
416 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
417 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
418 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
419 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
421 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
422 textureTrace.Reset();
424 ImageView imageView2 = ImageView::New();
425 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
427 // Disable pre-multiplied alpha blending
428 imageView2.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
430 application.GetScene().Add(imageView2);
432 application.SendNotification();
433 application.Render();
435 value = imageView2.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
436 DALI_TEST_CHECK(value.Get(enable));
437 DALI_TEST_CHECK(!enable);
439 // conventional alpha blending
440 Renderer renderer2 = imageView2.GetRendererAt(0);
441 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
442 DALI_TEST_CHECK(value.Get(enable));
443 DALI_TEST_CHECK(!enable);
445 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
446 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
447 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
448 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
449 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
450 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
451 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
452 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
454 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
459 int UtcDaliImageViewPixelArea(void)
461 // Test pixel area property
462 ToolkitTestApplication application;
464 static std::vector<UniformData> customUniforms =
466 UniformData("pixelArea", Property::Type::VECTOR4),
469 TestGraphicsController& graphics = application.GetGraphicsController();
470 graphics.AddCustomUniforms(customUniforms);
472 // Gif image, use AnimatedImageVisual internally
473 // Atlasing is applied to pack multiple frames, use custom wrap mode
474 ImageView gifView = ImageView::New();
475 const Vector4 pixelAreaVisual(0.f, 0.f, 2.f, 2.f);
476 gifView.SetProperty(ImageView::Property::IMAGE,
477 Property::Map().Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME).Add(ImageVisual::Property::PIXEL_AREA, pixelAreaVisual));
480 Integration::Scene stage = application.GetScene();
484 application.SendNotification();
485 application.Render(16);
487 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
489 application.SendNotification();
490 application.Render();
491 DALI_TEST_CHECK(gifView.GetRendererCount() == 1u);
493 const Vector4 fullTextureRect(0.f, 0.f, 1.f, 1.f);
494 // test that the pixel area value defined in the visual property map is registered on renderer
495 Renderer renderer = gifView.GetRendererAt(0);
496 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
497 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION);
499 // test that the shader has the default pixel area value registered.
500 Shader shader = renderer.GetShader();
501 pixelAreaValue = shader.GetProperty(shader.GetPropertyIndex("pixelArea"));
502 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION);
504 // test that the uniform uses the pixelArea property on the renderer.
505 TestGlAbstraction& gl = application.GetGlAbstraction();
506 Vector4 pixelAreaUniform;
507 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
508 DALI_TEST_EQUALS(pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
510 // set the pixelArea property on the control
511 const Vector4 pixelAreaControl(-1.f, -1.f, 3.f, 3.f);
512 gifView.SetProperty(ImageView::Property::PIXEL_AREA, pixelAreaControl);
513 application.SendNotification();
514 application.Render(16);
516 // check the pixelArea property on the control
517 pixelAreaValue = gifView.GetProperty(gifView.GetPropertyIndex("pixelArea"));
518 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION);
519 // test that the uniform uses the pixelArea property on the control.
520 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
521 DALI_TEST_EQUALS(pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
526 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
528 ToolkitTestApplication application;
529 TestGlAbstraction& gl = application.GetGlAbstraction();
530 const std::vector<GLuint>& textures = gl.GetBoundTextures();
531 size_t numTextures = textures.size();
533 // Async loading, no atlasing for big size image
534 ImageView imageView = ImageView::New(gImage_600_RGB);
536 // By default, Aysnc loading is used
537 application.GetScene().Add(imageView);
538 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
539 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
541 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
543 application.SendNotification();
544 application.Render(16);
545 application.SendNotification();
547 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
548 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
553 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
555 ToolkitTestApplication application;
557 //Async loading, automatic atlasing for small size image
558 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
560 callStack.Enable(true);
562 Property::Map imageMap;
564 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
565 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
566 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
567 imageMap[ImageVisual::Property::ATLASING] = true;
569 ImageView imageView = ImageView::New();
570 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
571 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
573 // By default, Aysnc loading is used
574 // loading is not started if the actor is offScene
576 application.GetScene().Add(imageView);
577 application.SendNotification();
578 application.Render(16);
579 application.Render(16);
580 application.SendNotification();
582 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
583 application.SendNotification();
584 application.Render(16);
585 application.Render(16);
586 application.SendNotification();
588 // loading started, this waits for the loader thread for max 30 seconds
589 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
591 application.SendNotification();
592 application.Render(16);
594 callStack.Enable(false);
596 TraceCallStack::NamedParams params;
597 params["width"] << 34;
598 params["height"] << 34;
599 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
604 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
606 ToolkitTestApplication application;
608 //Async loading, automatic atlasing for small size image
609 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
611 callStack.Enable(true);
613 Property::Map asyncLoadingMap;
614 asyncLoadingMap["url"] = gImage_34_RGBA;
615 asyncLoadingMap["desiredHeight"] = 34;
616 asyncLoadingMap["desiredWidth"] = 34;
617 asyncLoadingMap["synchronousLoading"] = false;
618 asyncLoadingMap["atlasing"] = true;
620 ImageView imageView = ImageView::New();
621 imageView.SetProperty(ImageView::Property::IMAGE, asyncLoadingMap);
623 application.GetScene().Add(imageView);
624 application.SendNotification();
625 application.Render(16);
626 application.Render(16);
627 application.SendNotification();
629 // loading started, this waits for the loader thread for max 30 seconds
630 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
632 application.SendNotification();
633 application.Render(16);
635 callStack.Enable(false);
637 TraceCallStack::NamedParams params;
638 params["width"] << 34;
639 params["height"] << 34;
640 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
645 int UtcDaliImageViewSyncLoading(void)
647 ToolkitTestApplication application;
649 tet_infoline("ImageView Testing sync loading and size using index key property map");
651 Property::Map syncLoadingMap;
652 syncLoadingMap[ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
653 syncLoadingMap[ImageVisual::Property::ATLASING] = true;
655 // Sync loading, no atlasing for big size image
657 ImageView imageView = ImageView::New();
659 // Sync loading is used
660 syncLoadingMap[ImageVisual::Property::URL] = gImage_600_RGB;
661 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
664 // Sync loading, automatic atlasing for small size image
666 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
668 callStack.Enable(true);
670 ImageView imageView = ImageView::New();
672 // Sync loading is used
673 syncLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
674 syncLoadingMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
675 syncLoadingMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
676 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
678 application.GetScene().Add(imageView);
679 application.SendNotification();
680 application.Render(16);
682 TraceCallStack::NamedParams params;
683 params["width"] << 34;
684 params["height"] << 34;
685 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
692 int UtcDaliImageViewSyncLoading02(void)
694 ToolkitTestApplication application;
696 tet_infoline("ImageView Testing sync loading and size using string key property map");
698 // Sync loading, automatic atlasing for small size image
700 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
702 callStack.Enable(true);
704 ImageView imageView = ImageView::New();
706 // Sync loading is used
707 Property::Map syncLoadingMap;
708 syncLoadingMap["url"] = gImage_34_RGBA;
709 syncLoadingMap["desiredHeight"] = 34;
710 syncLoadingMap["desiredWidth"] = 34;
711 syncLoadingMap["synchronousLoading"] = true;
712 syncLoadingMap["atlasing"] = true;
713 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
715 application.GetScene().Add(imageView);
716 application.SendNotification();
717 application.Render(16);
719 TraceCallStack::NamedParams params;
720 params["width"] << 34;
721 params["height"] << 34;
722 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
729 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
731 ToolkitTestApplication application;
732 TestGlAbstraction& gl = application.GetGlAbstraction();
733 const std::vector<GLuint>& textures = gl.GetBoundTextures();
734 size_t numTextures = textures.size();
736 // Get encoded raw-buffer image and generate url
737 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
738 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
740 // Async loading, no atlasing for big size image
741 ImageView imageView = ImageView::New(url.GetUrl());
743 // By default, Aysnc loading is used
744 application.GetScene().Add(imageView);
745 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
746 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
748 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
750 application.SendNotification();
751 application.Render(16);
752 application.SendNotification();
754 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
755 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
760 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
762 ToolkitTestApplication application;
764 // Get encoded raw-buffer image and generate url
765 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
766 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
767 ImageUrl url2 = Toolkit::Image::GenerateUrl(buffer);
769 // Generate url is not equal to url2
770 // NOTE : This behavior may changed when ImageUrl compare operator changed.
771 DALI_TEST_CHECK(url != url2);
772 // Generate url's string is equal to url2's string
773 DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
775 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
776 url2 = Toolkit::Image::GenerateUrl(buffer2);
778 // Check whethere two url are not equal
779 DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
781 // Async loading, automatic atlasing for small size image
782 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
784 callStack.Enable(true);
786 Property::Map imageMap;
788 imageMap[ImageVisual::Property::URL] = url.GetUrl();
789 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 600;
790 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 600;
791 imageMap[ImageVisual::Property::ATLASING] = true;
793 // No atlasing with big image
794 ImageView imageView_bigdesired = ImageView::New();
795 imageView_bigdesired.SetProperty(ImageView::Property::IMAGE, imageMap);
796 imageView_bigdesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
798 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 0;
799 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 0;
801 // No atlasing with zero desired size
802 ImageView imageView_nodesired = ImageView::New();
803 imageView_nodesired.SetProperty(ImageView::Property::IMAGE, imageMap);
804 imageView_nodesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
806 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
807 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
809 ImageView imageView = ImageView::New();
810 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
811 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
813 // By default, Aysnc loading is used
814 // loading is not started if the actor is offScene
815 application.GetScene().Add(imageView);
816 application.GetScene().Add(imageView_bigdesired);
817 application.GetScene().Add(imageView_nodesired);
818 application.SendNotification();
819 application.Render(16);
821 // loading started, this waits for the loader thread for max 30 seconds
822 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
824 application.Render(16);
825 application.SendNotification();
827 // Change url to url2
828 imageMap[ImageVisual::Property::URL] = url2.GetUrl();
829 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
831 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
832 application.SendNotification();
833 application.Render(16);
834 application.Render(16);
835 application.SendNotification();
837 // loading started, this waits for the loader thread for max 30 seconds
838 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
840 application.SendNotification();
841 application.Render(16);
843 callStack.Enable(false);
845 TraceCallStack::NamedParams params;
846 params["width"] << 34;
847 params["height"] << 34;
848 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
853 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
855 ToolkitTestApplication application;
857 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
859 // Get encoded raw-buffer image and generate url
860 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
861 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
863 // Sync loading, automatic atlasing for small size image
865 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
867 callStack.Enable(true);
869 ImageView imageView = ImageView::New();
871 // Sync loading is used
872 Property::Map syncLoadingMap;
873 syncLoadingMap["url"] = url.GetUrl();
874 syncLoadingMap["alphaMaskUrl"] = gImage_34_RGBA;
875 syncLoadingMap["desiredHeight"] = 34;
876 syncLoadingMap["desiredWidth"] = 34;
877 syncLoadingMap["synchronousLoading"] = true;
878 syncLoadingMap["atlasing"] = true;
879 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
881 application.GetScene().Add(imageView);
882 application.SendNotification();
883 application.Render(16);
885 TraceCallStack::NamedParams params;
886 params["width"] << 34;
887 params["height"] << 34;
888 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
896 int UtcDaliImageViewAddedTexture(void)
898 ToolkitTestApplication application;
900 tet_infoline("ImageView Testing image view with texture provided manager url");
902 ImageView imageView = ImageView::New();
904 // empty texture is ok, though pointless from app point of view
906 std::string url = TextureManager::AddTexture(empty);
907 DALI_TEST_CHECK(url.size() > 0u);
909 Property::Map propertyMap;
910 propertyMap[ImageVisual::Property::URL] = url;
911 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
913 application.GetScene().Add(imageView);
914 application.SendNotification();
915 application.Render();
920 int UtcDaliImageViewSizeWithBackground(void)
922 ToolkitTestApplication application;
926 ImageView imageView = ImageView::New();
928 imageView.SetProperty(Control::Property::BACKGROUND,
930 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
931 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
932 {ImageVisual::Property::DESIRED_WIDTH, width},
933 {ImageVisual::Property::DESIRED_HEIGHT, height},
936 application.GetScene().Add(imageView);
937 application.SendNotification();
938 application.Render();
940 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
941 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
946 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
948 ToolkitTestApplication application;
950 int widthBackground = 100;
951 int heightBackground = 200;
955 ImageView imageView = ImageView::New();
957 imageView.SetProperty(Control::Property::BACKGROUND,
959 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
960 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
961 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
962 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground},
965 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio, 600x600 pixels
967 application.GetScene().Add(imageView);
968 application.SendNotification();
969 application.Render();
971 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
972 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
977 int UtcDaliImageViewHeightForWidthBackground(void)
979 ToolkitTestApplication application;
981 int widthBackground = 100;
982 int heightBackground = 200;
984 ImageView imageView = ImageView::New();
986 imageView.SetProperty(Control::Property::BACKGROUND,
987 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
988 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
989 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
990 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}});
992 application.GetScene().Add(imageView);
993 application.SendNotification();
994 application.Render();
996 Control control = Control::DownCast(imageView);
997 DALI_TEST_CHECK(control);
998 DALI_TEST_EQUALS(imageView.GetHeightForWidth(123.f), control.GetHeightForWidth(123.f), TEST_LOCATION);
999 DALI_TEST_EQUALS(imageView.GetWidthForHeight(321.f), control.GetWidthForHeight(321.f), TEST_LOCATION);
1004 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
1006 ToolkitTestApplication application;
1008 int widthBackground = 100;
1009 int heightBackground = 200;
1013 ImageView imageView = ImageView::New();
1015 imageView.SetProperty(Control::Property::BACKGROUND,
1016 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1017 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1018 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1019 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}}); // 1 to 2 ratio
1021 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio
1023 application.GetScene().Add(imageView);
1024 application.SendNotification();
1025 application.Render();
1027 DALI_TEST_EQUALS(imageView.GetHeightForWidth(width), (float)height, TEST_LOCATION);
1028 DALI_TEST_EQUALS(imageView.GetWidthForHeight(height), (float)width, TEST_LOCATION);
1033 int UtcDaliImageViewSetImageUrl(void)
1035 ToolkitTestApplication application;
1037 ImageView imageView = ImageView::New();
1038 imageView.SetImage(TEST_IMAGE_FILE_NAME);
1039 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
1041 imageView.SetImage(TEST_IMAGE_FILE_NAME2);
1042 TestUrl(imageView, TEST_IMAGE_FILE_NAME2);
1047 bool gResourceReadySignalFired = false;
1048 Vector3 gNaturalSize;
1050 void ResourceReadySignal(Control control)
1052 gResourceReadySignalFired = true;
1055 int UtcDaliImageViewCheckResourceReady(void)
1057 ToolkitTestApplication application;
1059 gResourceReadySignalFired = false;
1061 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1062 ImageView imageView = ImageView::New(TEST_GIF_FILE_NAME);
1064 imageView.SetProperty(Control::Property::BACKGROUND,
1065 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1066 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1067 {ImageVisual::Property::DESIRED_WIDTH, 100},
1068 {ImageVisual::Property::DESIRED_HEIGHT, 200}});
1070 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1072 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1074 application.GetScene().Add(imageView);
1076 // loading started, this waits for the loader thread
1077 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1079 application.SendNotification();
1080 application.Render(16);
1082 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1084 application.SendNotification();
1085 application.Render();
1087 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1089 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1094 int UtcDaliImageViewSetImageTypeChangesP(void)
1096 ToolkitTestApplication application;
1098 ImageView imageView = ImageView::New();
1099 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1101 application.GetScene().Add(imageView);
1105 Toolkit::Visual::Base visual;
1107 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1108 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1110 application.SendNotification();
1111 application.Render(16);
1113 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1115 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1116 DALI_TEST_CHECK(!visual); // Visual should be invalid
1119 imageView.SetImage("TEST_URL");
1121 application.SendNotification();
1122 application.Render(16);
1124 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1125 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1127 DALI_TEST_CHECK(value.Get(url)); // Value should NOT be empty
1128 DALI_TEST_CHECK(!value.Get(map)); // Value should be empty
1129 DALI_TEST_CHECK(visual); // Visual should be valid
1132 imageView.SetImage("");
1134 application.SendNotification();
1135 application.Render(16);
1137 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1138 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1140 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1142 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1143 DALI_TEST_CHECK(!visual); // Visual should be invalid
1145 // Set a URL in property map
1146 Property::Map propertyMap;
1147 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1148 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1150 application.SendNotification();
1151 application.Render(16);
1153 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1154 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1156 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1157 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1158 DALI_TEST_CHECK(visual); // Visual should be valid
1160 // Set a URL in property map again
1161 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1162 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1164 application.SendNotification();
1165 application.Render(16);
1167 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1168 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1170 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1171 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1172 DALI_TEST_CHECK(visual); // Visual should be valid
1174 // Set an empty URL in property map
1175 propertyMap[ImageVisual::Property::URL] = std::string();
1176 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1178 application.SendNotification();
1179 application.Render(16);
1181 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1182 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1184 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1185 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1186 DALI_TEST_CHECK(!visual); // Visual should be invalid
1188 // Set a URL in property map again
1189 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1190 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1192 application.SendNotification();
1193 application.Render(16);
1195 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1196 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1198 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1199 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1200 DALI_TEST_CHECK(visual); // Visual should be valid
1202 // Set an empty property map
1203 propertyMap.Clear();
1204 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1206 application.SendNotification();
1207 application.Render(16);
1209 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1210 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1212 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1213 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1214 DALI_TEST_CHECK(map.Empty()); // But PropertyMap should be empty
1215 DALI_TEST_CHECK(!visual); // Visual should be invalid
1220 int UtcDaliImageViewResourceUrlP(void)
1222 ToolkitTestApplication application;
1224 ImageView imageView = ImageView::New();
1225 DALI_TEST_CHECK(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>().empty());
1227 imageView.SetProperty(ImageView::Property::IMAGE, "TestString");
1228 DALI_TEST_EQUALS(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>(), "TestString", TEST_LOCATION);
1233 int UtcDaliImageViewReplaceImage(void)
1235 ToolkitTestApplication application;
1237 gResourceReadySignalFired = false;
1239 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1240 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1242 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1244 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1246 application.GetScene().Add(imageView);
1248 application.SendNotification();
1249 application.Render(16);
1251 // loading started, this waits for the loader thread for max 30 seconds
1252 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1254 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1256 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1258 gResourceReadySignalFired = false;
1260 imageView.SetImage(TEST_IMAGE_2);
1262 application.SendNotification();
1263 application.Render(16);
1265 // loading started, this waits for the loader thread for max 30 seconds
1266 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1268 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1270 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1272 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1277 void OnRelayoutOverride(Size size)
1279 gNaturalSize = size; // Size Relayout is using
1282 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1284 ToolkitTestApplication application;
1286 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1287 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1288 imageView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1290 DummyControl dummyControl = DummyControl::New(true);
1291 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1292 dummyControl.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
1294 dummyControl.Add(imageView);
1295 dummyImpl.SetRelayoutCallback(&OnRelayoutOverride);
1296 application.GetScene().Add(dummyControl);
1298 application.SendNotification();
1299 application.Render();
1301 // loading started, this waits for the loader thread for max 30 seconds
1302 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1304 DALI_TEST_EQUALS(gNaturalSize.width, 1024.0f, TEST_LOCATION);
1305 DALI_TEST_EQUALS(gNaturalSize.height, 1024.0f, TEST_LOCATION);
1307 gNaturalSize = Vector3::ZERO;
1309 imageView.SetImage(gImage_600_RGB);
1311 // Waiting for resourceReady so SendNotifcation not called here.
1313 // loading started, this waits for the loader thread for max 30 seconds
1314 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1316 // Trigger a potential relayout
1317 application.SendNotification();
1318 application.Render();
1320 DALI_TEST_EQUALS(gNaturalSize.width, 600.0f, TEST_LOCATION);
1321 DALI_TEST_EQUALS(gNaturalSize.height, 600.0f, TEST_LOCATION);
1326 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1328 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1330 ToolkitTestApplication application;
1332 gResourceReadySignalFired = false;
1334 Property::Map imageMap;
1336 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1337 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1339 tet_infoline("Creating ImageView without URL so image does not start loading");
1340 ImageView imageView = ImageView::New();
1341 tet_infoline("Connect to image loaded signal before setting image");
1342 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1343 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1344 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1346 // loading started, this waits for the loader thread
1347 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1349 application.SendNotification();
1350 application.Render(16);
1352 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1357 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1359 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1361 ToolkitTestApplication application;
1363 gResourceReadySignalFired = false;
1365 Property::Map imageMap;
1367 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1368 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1370 ImageView imageView = ImageView::New();
1371 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1372 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1374 // loading started, this waits for the loader thread
1375 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1377 application.SendNotification();
1378 application.Render(16);
1380 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1381 gResourceReadySignalFired = false;
1383 ImageView imageViewWithExistingImage = ImageView::New();
1384 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1385 imageViewWithExistingImage.SetProperty(ImageView::Property::IMAGE, imageMap);
1387 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1392 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1394 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1396 ToolkitTestApplication application;
1398 gResourceReadySignalFired = false;
1400 Property::Map imageImmediateLoadingMap;
1401 imageImmediateLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1402 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1404 tet_infoline("Immediate load an image");
1405 ImageView imageView = ImageView::New();
1406 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1407 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
1409 // loading started, this waits for the loader thread
1410 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1412 application.SendNotification();
1413 application.Render(16);
1415 tet_infoline("Check image loaded");
1416 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1417 gResourceReadySignalFired = false;
1419 tet_infoline("Create another ImageView with the same URL");
1420 ImageView imageViewWithExistingImage = ImageView::New(gImage_34_RGBA);
1421 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1422 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1424 application.GetScene().Add(imageViewWithExistingImage);
1426 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1431 int UtcDaliImageViewPaddingProperty(void)
1433 ToolkitTestApplication application;
1435 ImageView imageView = ImageView::New();
1436 Property::Map imagePropertyMap;
1437 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1438 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
1439 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1440 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1441 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1442 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1443 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1444 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1445 application.GetScene().Add(imageView);
1447 application.SendNotification();
1448 application.Render();
1450 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1452 ImageView childImage = ImageView::New();
1453 childImage.SetBackgroundColor(Color::BLACK);
1454 childImage.SetProperty(Actor::Property::SIZE, Vector2(10.f, 10.f));
1455 imageView.Add(childImage);
1457 application.SendNotification();
1458 application.Render();
1460 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1461 DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
1463 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1464 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1465 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1466 Property::Map resultMap;
1467 imageVisual.CreatePropertyMap(resultMap);
1469 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1470 DALI_TEST_CHECK(transformValue);
1471 Property::Map* retMap = transformValue->GetMap();
1472 DALI_TEST_CHECK(retMap);
1474 // Image Visual should be positioned depending on ImageView's padding
1475 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1480 int UtcDaliImageViewPaddingProperty02(void)
1482 ToolkitTestApplication application;
1484 ImageView imageView = ImageView::New();
1485 Property::Map imagePropertyMap;
1486 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1487 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1488 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1489 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1490 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1491 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1492 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1493 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1494 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1495 application.GetScene().Add(imageView);
1497 application.SendNotification();
1498 application.Render();
1500 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1502 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1503 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1504 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1505 Property::Map resultMap;
1506 imageVisual.CreatePropertyMap(resultMap);
1508 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1509 DALI_TEST_CHECK(transformValue);
1510 Property::Map* retMap = transformValue->GetMap();
1511 DALI_TEST_CHECK(retMap);
1513 // Image Visual should be positioned depending on ImageView's padding
1514 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1519 int UtcDaliImageViewPaddingProperty03(void)
1521 tet_infoline("Test Setting Image Padding then removing it.");
1523 ToolkitTestApplication application;
1525 ImageView imageView = ImageView::New();
1526 Property::Map imagePropertyMap;
1527 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1528 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1529 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1530 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1531 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1532 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1533 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1534 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1535 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1536 application.GetScene().Add(imageView);
1538 application.SendNotification();
1539 application.Render();
1541 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1543 tet_infoline("Remove Padding and test Visual is position correctly");
1545 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1547 application.SendNotification();
1548 application.Render();
1550 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1551 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1552 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1553 Property::Map resultMap;
1554 imageVisual.CreatePropertyMap(resultMap);
1556 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1557 DALI_TEST_CHECK(transformValue);
1558 Property::Map* retMap = transformValue->GetMap();
1559 DALI_TEST_CHECK(retMap);
1561 // Image Visual should be positioned depending on ImageView's padding
1562 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1567 int UtcDaliImageViewPaddingProperty04(void)
1569 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1571 ToolkitTestApplication application;
1573 ImageView imageView = ImageView::New();
1574 Property::Map imagePropertyMap;
1575 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1576 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1577 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1578 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1579 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FILL;
1580 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1581 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1582 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1583 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1584 application.GetScene().Add(imageView);
1586 application.SendNotification();
1587 application.Render();
1589 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1591 tet_infoline("Remove Padding and test Visual is position correctly");
1593 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1595 application.SendNotification();
1596 application.Render();
1598 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1599 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1600 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1601 Property::Map resultMap;
1602 imageVisual.CreatePropertyMap(resultMap);
1604 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1605 DALI_TEST_CHECK(transformValue);
1606 Property::Map* retMap = transformValue->GetMap();
1607 DALI_TEST_CHECK(retMap);
1609 // Image Visual should be positioned depending on ImageView's padding
1610 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1615 int UtcDaliImageViewTransformTest01(void)
1617 tet_infoline("Test Setting a offset transform on the ImageView");
1619 ToolkitTestApplication application;
1621 ImageView imageView = ImageView::New();
1622 Property::Map imagePropertyMap;
1623 imagePropertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE)
1624 .Add(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/Kid1.svg")
1625 .Add(ImageVisual::Property::DESIRED_WIDTH, 120)
1626 .Add(ImageVisual::Property::DESIRED_HEIGHT, 120)
1627 .Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL)
1628 .Add(Visual::Property::TRANSFORM,
1629 Property::Map().Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1630 Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE))
1631 .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(8, 8)));
1633 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1634 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1635 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1636 application.GetScene().Add(imageView);
1638 application.SendNotification();
1639 application.Render();
1641 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1642 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1643 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1644 Property::Map resultMap;
1645 imageVisual.CreatePropertyMap(resultMap);
1647 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1648 DALI_TEST_CHECK(transformValue);
1649 Property::Map* retMap = transformValue->GetMap();
1650 DALI_TEST_CHECK(retMap);
1652 // Image Visual should be positioned depending on ImageView's padding
1653 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(8, 8), TEST_LOCATION);
1654 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);
1659 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1661 ToolkitTestApplication application;
1663 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1664 ImageView imageView = ImageView::New();
1665 Property::Map imageMap;
1666 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1667 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_34_RGBA;
1668 imageMap[Toolkit::ImageVisual::Property::ATLASING] = true;
1669 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1670 application.GetScene().Add(imageView);
1672 // Trigger a potential relayout
1673 application.SendNotification();
1674 application.Render();
1676 Vector3 naturalSize = imageView.GetNaturalSize();
1678 DALI_TEST_EQUALS(naturalSize.width, 34.0f, TEST_LOCATION);
1679 DALI_TEST_EQUALS(naturalSize.height, 34.0f, TEST_LOCATION);
1684 int UtcDaliImageViewFillMode(void)
1686 ToolkitTestApplication application;
1688 tet_infoline("Create an ImageVisual without padding and set the fill-mode to fill");
1690 ImageView imageView = ImageView::New();
1691 Property::Map imageMap;
1692 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1693 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB);
1694 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL);
1696 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1698 application.GetScene().Add(imageView);
1700 // Trigger a potential relayout
1701 application.SendNotification();
1702 application.Render();
1704 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1705 Property::Map returnedMap;
1706 visual.CreatePropertyMap(returnedMap);
1708 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1709 DALI_TEST_CHECK(value);
1710 Property::Map* map = value->GetMap();
1711 DALI_TEST_CHECK(map);
1713 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1714 DALI_TEST_CHECK(value);
1715 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION);
1717 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1718 DALI_TEST_CHECK(value);
1719 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1724 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1726 ToolkitTestApplication application;
1728 tet_infoline("Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )");
1729 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1731 ImageView imageView = ImageView::New();
1732 Property::Map imageMap;
1733 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1734 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1735 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
1737 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1738 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1740 application.GetScene().Add(imageView);
1742 // Trigger a potential relayout
1743 application.SendNotification();
1744 application.Render();
1746 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1747 Property::Map returnedMap;
1748 visual.CreatePropertyMap(returnedMap);
1750 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1751 DALI_TEST_CHECK(value);
1752 Property::Map* map = value->GetMap();
1753 DALI_TEST_CHECK(map);
1756 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1757 DALI_TEST_CHECK(value);
1758 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION);
1760 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1761 DALI_TEST_CHECK(value);
1762 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1764 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1765 DALI_TEST_CHECK(value);
1766 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
1771 int UtcDaliImageViewFittingModesFill(void)
1773 ToolkitTestApplication application;
1775 tet_infoline("Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )");
1776 tet_infoline(" There should be no need to change the transform, only size is changed to fit view");
1778 ImageView imageView = ImageView::New();
1779 Property::Map imageMap;
1780 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1781 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1782 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL);
1784 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1785 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1787 application.GetScene().Add(imageView);
1789 // Trigger a potential relayout
1790 application.SendNotification();
1791 application.Render();
1793 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1794 Property::Map returnedMap;
1795 visual.CreatePropertyMap(returnedMap);
1797 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1798 DALI_TEST_CHECK(value);
1799 Property::Map* map = value->GetMap();
1800 DALI_TEST_CHECK(map);
1802 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1803 DALI_TEST_CHECK(value);
1804 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Change the internal size according to the image view size
1806 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1807 DALI_TEST_CHECK(value);
1808 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1810 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1811 DALI_TEST_CHECK(value);
1812 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1817 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1819 ToolkitTestApplication application;
1821 tet_infoline("Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )");
1822 tet_infoline(" offset or size is the same as view, but adjust internally using pixelArea ");
1824 ImageView imageView = ImageView::New();
1825 Property::Map imageMap;
1826 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1827 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1828 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO);
1830 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1831 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 500));
1833 application.GetScene().Add(imageView);
1835 // Trigger a potential relayout
1836 application.SendNotification();
1837 application.Render();
1839 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1840 Property::Map returnedMap;
1841 visual.CreatePropertyMap(returnedMap);
1843 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1844 DALI_TEST_CHECK(value);
1845 Property::Map* map = value->GetMap();
1846 DALI_TEST_CHECK(map);
1849 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1850 DALI_TEST_CHECK(value);
1851 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 500), TEST_LOCATION); // Change the internal size according to the image view size
1853 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1854 DALI_TEST_CHECK(value);
1855 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1857 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1858 DALI_TEST_CHECK(value);
1859 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1864 int UtcDaliImageViewFittingModesCenter01(void)
1866 ToolkitTestApplication application;
1868 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [700,700] )");
1869 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1871 ImageView imageView = ImageView::New();
1872 Property::Map imageMap;
1873 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1874 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1875 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1877 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1878 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1880 application.GetScene().Add(imageView);
1882 // Trigger a potential relayout
1883 application.SendNotification();
1884 application.Render();
1886 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1887 Property::Map returnedMap;
1888 visual.CreatePropertyMap(returnedMap);
1890 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1891 DALI_TEST_CHECK(value);
1892 Property::Map* map = value->GetMap();
1893 DALI_TEST_CHECK(map);
1895 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1896 DALI_TEST_CHECK(value);
1897 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1899 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1900 DALI_TEST_CHECK(value);
1901 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1903 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1904 DALI_TEST_CHECK(value);
1905 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1910 int UtcDaliImageViewFittingModesCenter02(void)
1912 ToolkitTestApplication application;
1914 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [500,500] )");
1915 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1917 ImageView imageView = ImageView::New();
1918 Property::Map imageMap;
1919 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1920 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1921 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1923 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1924 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1926 application.GetScene().Add(imageView);
1928 // Trigger a potential relayout
1929 application.SendNotification();
1930 application.Render();
1932 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1933 Property::Map returnedMap;
1934 visual.CreatePropertyMap(returnedMap);
1936 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1937 DALI_TEST_CHECK(value);
1938 Property::Map* map = value->GetMap();
1939 DALI_TEST_CHECK(map);
1941 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1942 DALI_TEST_CHECK(value);
1943 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1945 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1946 DALI_TEST_CHECK(value);
1947 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1949 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1950 DALI_TEST_CHECK(value);
1951 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1956 int UtcDaliImageViewFittingModesFitHeight01(void)
1958 ToolkitTestApplication application;
1960 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )");
1962 ImageView imageView = ImageView::New();
1963 Property::Map imageMap;
1964 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1965 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1966 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1968 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1969 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1971 application.GetScene().Add(imageView);
1973 // Trigger a potential relayout
1974 application.SendNotification();
1975 application.Render();
1977 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1978 Property::Map returnedMap;
1979 visual.CreatePropertyMap(returnedMap);
1981 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1982 DALI_TEST_CHECK(value);
1983 Property::Map* map = value->GetMap();
1984 DALI_TEST_CHECK(map);
1986 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1987 DALI_TEST_CHECK(value);
1988 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 700), TEST_LOCATION); // Change the internal size according to the image view size
1990 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1991 DALI_TEST_CHECK(value);
1992 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1994 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1995 DALI_TEST_CHECK(value);
1996 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2001 int UtcDaliImageViewFittingModesFitHeight02(void)
2003 ToolkitTestApplication application;
2005 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )");
2007 ImageView imageView = ImageView::New();
2008 Property::Map imageMap;
2009 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2010 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2011 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2013 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2014 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2016 application.GetScene().Add(imageView);
2018 // Trigger a potential relayout
2019 application.SendNotification();
2020 application.Render();
2022 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2023 Property::Map returnedMap;
2024 visual.CreatePropertyMap(returnedMap);
2026 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2027 DALI_TEST_CHECK(value);
2028 Property::Map* map = value->GetMap();
2029 DALI_TEST_CHECK(map);
2031 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2032 DALI_TEST_CHECK(value);
2033 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2035 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2036 DALI_TEST_CHECK(value);
2037 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2039 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2040 DALI_TEST_CHECK(value);
2041 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2046 int UtcDaliImageViewFittingModesFitWidth01(void)
2048 ToolkitTestApplication application;
2050 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )");
2052 ImageView imageView = ImageView::New();
2053 Property::Map imageMap;
2054 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2055 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2056 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2058 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2059 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2061 application.GetScene().Add(imageView);
2063 // Trigger a potential relayout
2064 application.SendNotification();
2065 application.Render();
2067 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2068 Property::Map returnedMap;
2069 visual.CreatePropertyMap(returnedMap);
2071 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2072 DALI_TEST_CHECK(value);
2073 Property::Map* map = value->GetMap();
2074 DALI_TEST_CHECK(map);
2076 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2077 DALI_TEST_CHECK(value);
2078 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2080 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2081 DALI_TEST_CHECK(value);
2082 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2084 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2085 DALI_TEST_CHECK(value);
2086 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
2091 int UtcDaliImageViewFittingModesFitWidth02(void)
2093 ToolkitTestApplication application;
2095 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )");
2097 ImageView imageView = ImageView::New();
2098 Property::Map imageMap;
2099 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2100 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2101 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2103 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2104 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2106 application.GetScene().Add(imageView);
2108 // Trigger a potential relayout
2109 application.SendNotification();
2110 application.Render();
2112 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2113 Property::Map returnedMap;
2114 visual.CreatePropertyMap(returnedMap);
2116 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2117 DALI_TEST_CHECK(value);
2118 Property::Map* map = value->GetMap();
2119 DALI_TEST_CHECK(map);
2121 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2122 DALI_TEST_CHECK(value);
2123 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 600), TEST_LOCATION); // Change the internal size according to the image view size
2125 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2126 DALI_TEST_CHECK(value);
2127 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2129 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2130 DALI_TEST_CHECK(value);
2131 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2136 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2138 ToolkitTestApplication application;
2140 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2142 ImageView imageView = ImageView::New();
2144 // 1. Render using FittingMode::SHRINK_TO_FIT
2145 Property::Map imageMap;
2146 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2147 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2148 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2150 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2151 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2153 application.GetScene().Add(imageView);
2155 // Trigger a potential relayout
2156 application.SendNotification();
2157 application.Render();
2159 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2160 Property::Map returnedMap;
2161 visual.CreatePropertyMap(returnedMap);
2163 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2164 DALI_TEST_CHECK(value);
2165 Property::Map* map = value->GetMap();
2166 DALI_TEST_CHECK(map);
2168 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2169 DALI_TEST_CHECK(value);
2170 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2172 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2173 DALI_TEST_CHECK(value);
2174 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2176 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2177 DALI_TEST_CHECK(value);
2178 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2180 // 2. Render again using DevelVisaul::CENTER
2181 Property::Map imageMap2;
2182 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2183 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2184 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2186 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2187 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2189 application.GetScene().Add(imageView);
2191 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2193 // Trigger a potential relayout
2194 application.SendNotification();
2195 application.Render();
2197 returnedMap.Clear();
2198 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2200 visual.CreatePropertyMap(returnedMap);
2202 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2203 DALI_TEST_CHECK(value);
2204 map = value->GetMap();
2205 DALI_TEST_CHECK(map);
2207 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2208 DALI_TEST_CHECK(value);
2209 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2211 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2212 DALI_TEST_CHECK(value);
2213 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2215 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2216 DALI_TEST_CHECK(value);
2217 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2219 // 3. Render again using before fittingMode
2220 Property::Map imageMap3;
2221 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2222 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2223 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2225 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2226 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2228 application.GetScene().Add(imageView);
2230 // Trigger a potential relayout
2231 application.SendNotification();
2232 application.Render();
2234 returnedMap.Clear();
2235 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2236 visual.CreatePropertyMap(returnedMap);
2238 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2239 DALI_TEST_CHECK(value);
2240 map = value->GetMap();
2241 DALI_TEST_CHECK(map);
2243 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2244 DALI_TEST_CHECK(value);
2245 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2247 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2248 DALI_TEST_CHECK(value);
2249 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2251 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2252 DALI_TEST_CHECK(value);
2253 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2258 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2260 ToolkitTestApplication application;
2262 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2264 ImageView imageView = ImageView::New();
2266 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2267 Property::Map imageMap;
2268 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2269 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2270 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2272 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2273 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2275 application.GetScene().Add(imageView);
2277 // Trigger a potential relayout
2278 application.SendNotification();
2279 application.Render();
2281 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2282 Property::Map returnedMap;
2283 visual.CreatePropertyMap(returnedMap);
2285 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2286 DALI_TEST_CHECK(value);
2287 Property::Map* map = value->GetMap();
2288 DALI_TEST_CHECK(map);
2290 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2291 DALI_TEST_CHECK(value);
2292 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2294 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2295 DALI_TEST_CHECK(value);
2296 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2298 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2299 DALI_TEST_CHECK(value);
2300 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2302 // 2. Render again using DevelVisaul::CENTER
2303 Property::Map imageMap2;
2304 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2305 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2306 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2308 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2309 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2311 application.GetScene().Add(imageView);
2313 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2315 // Trigger a potential relayout
2316 application.SendNotification();
2317 application.Render();
2319 returnedMap.Clear();
2320 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2322 visual.CreatePropertyMap(returnedMap);
2324 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2325 DALI_TEST_CHECK(value);
2326 map = value->GetMap();
2327 DALI_TEST_CHECK(map);
2329 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2330 DALI_TEST_CHECK(value);
2331 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2333 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2334 DALI_TEST_CHECK(value);
2335 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2337 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2338 DALI_TEST_CHECK(value);
2339 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2341 // 3. Render again using before fittingMode
2342 Property::Map imageMap3;
2343 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2344 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2345 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2347 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2348 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2350 application.GetScene().Add(imageView);
2352 // Trigger a potential relayout
2353 application.SendNotification();
2354 application.Render();
2356 returnedMap.Clear();
2357 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2358 visual.CreatePropertyMap(returnedMap);
2360 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2361 DALI_TEST_CHECK(value);
2362 map = value->GetMap();
2363 DALI_TEST_CHECK(map);
2365 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2366 DALI_TEST_CHECK(value);
2367 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2369 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2370 DALI_TEST_CHECK(value);
2371 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2373 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2374 DALI_TEST_CHECK(value);
2375 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2380 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2382 ToolkitTestApplication application;
2384 tet_infoline("Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )");
2386 ImageView imageView = ImageView::New();
2387 Property::Map imageMap;
2388 imageMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE);
2389 imageMap.Add(Toolkit::ImageVisual::Property::URL, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME); // 249x169 image
2391 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2392 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
2394 application.GetScene().Add(imageView);
2396 // Trigger a potential relayout
2397 application.SendNotification();
2398 application.Render();
2400 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2401 Property::Map returnedMap;
2402 visual.CreatePropertyMap(returnedMap);
2404 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2405 DALI_TEST_CHECK(value);
2406 Property::Map* map = value->GetMap();
2407 DALI_TEST_CHECK(map);
2409 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2410 DALI_TEST_CHECK(value);
2411 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Relative size so will take up 100%
2413 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2414 DALI_TEST_CHECK(value);
2415 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2417 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2418 DALI_TEST_CHECK(value);
2419 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2424 int UtcDaliImageViewCustomShader(void)
2426 ToolkitTestApplication application;
2428 // Set a custom shader with an image url
2430 Property::Map properties;
2431 Property::Map shader;
2432 const std::string vertexShader = "Foobar";
2433 const std::string fragmentShader = "Foobar";
2434 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2435 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2437 properties[Visual::Property::TYPE] = Visual::IMAGE;
2438 properties[Visual::Property::SHADER] = shader;
2439 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2441 ImageView imageView = ImageView::New();
2442 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2444 application.GetScene().Add(imageView);
2446 application.SendNotification();
2447 application.Render();
2449 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2451 Renderer renderer = imageView.GetRendererAt(0);
2452 Shader shader2 = renderer.GetShader();
2453 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2454 Property::Map* map = value.GetMap();
2455 DALI_TEST_CHECK(map);
2457 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2458 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2460 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2461 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2464 // Set a custom shader after setting an image url
2466 Property::Map properties;
2467 Property::Map shader;
2468 const std::string vertexShader = "Foobar";
2469 const std::string fragmentShader = "Foobar";
2470 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2471 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2473 properties[Visual::Property::SHADER] = shader;
2475 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
2476 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2478 application.GetScene().Add(imageView);
2480 application.SendNotification();
2481 application.Render();
2483 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2485 Renderer renderer = imageView.GetRendererAt(0);
2486 Shader shader2 = renderer.GetShader();
2487 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2488 Property::Map* map = value.GetMap();
2489 DALI_TEST_CHECK(map);
2491 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2492 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2494 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2495 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2498 // Set a custom shader before setting an image url
2500 Property::Map properties;
2501 Property::Map shader;
2502 const std::string vertexShader = "Foobar";
2503 const std::string fragmentShader = "Foobar";
2504 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2505 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2507 properties[Visual::Property::SHADER] = shader;
2509 ImageView imageView = ImageView::New();
2510 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2511 imageView.SetProperty(ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME);
2513 application.GetScene().Add(imageView);
2515 application.SendNotification();
2516 application.Render();
2517 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2519 Renderer renderer = imageView.GetRendererAt(0);
2520 Shader shader2 = renderer.GetShader();
2521 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2522 Property::Map* map = value.GetMap();
2523 DALI_TEST_CHECK(map);
2525 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2526 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2528 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2529 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2532 // Set a custom shader after setting a property map
2534 Property::Map properties;
2535 Property::Map shader;
2536 const std::string vertexShader = "Foobar";
2537 const std::string fragmentShader = "Foobar";
2538 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2539 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2541 properties[Visual::Property::SHADER] = shader;
2543 Property::Map properties1;
2544 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2545 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2547 ImageView imageView = ImageView::New();
2548 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2549 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2551 application.GetScene().Add(imageView);
2553 application.SendNotification();
2554 application.Render();
2555 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2557 Renderer renderer = imageView.GetRendererAt(0);
2558 Shader shader2 = renderer.GetShader();
2559 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2560 Property::Map* map = value.GetMap();
2561 DALI_TEST_CHECK(map);
2563 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2564 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2566 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2567 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2570 // Set a custom shader before setting a property map
2572 Property::Map properties;
2573 Property::Map shader;
2574 const std::string vertexShader = "Foobar";
2575 const std::string fragmentShader = "Foobar";
2576 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2577 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2579 properties[Visual::Property::SHADER] = shader;
2581 Property::Map properties1;
2582 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2583 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2585 ImageView imageView = ImageView::New();
2586 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2587 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2589 application.GetScene().Add(imageView);
2591 application.SendNotification();
2592 application.Render();
2593 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2595 Renderer renderer = imageView.GetRendererAt(0);
2596 Shader shader2 = renderer.GetShader();
2597 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2598 Property::Map* map = value.GetMap();
2599 DALI_TEST_CHECK(map);
2601 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2602 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2604 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2605 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2613 static int gFailCounter = 0;
2614 const int MAX_RETRIES(3);
2616 void ReloadImage(ImageView imageView)
2618 Property::Map imageImmediateLoadingMap;
2619 imageImmediateLoadingMap[ImageVisual::Property::URL] = "Non-existant-image.jpg";
2620 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
2622 tet_infoline("Immediate load an image");
2623 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
2626 void ResourceFailedReload(Control control)
2629 if(gFailCounter < MAX_RETRIES)
2631 ReloadImage(ImageView::DownCast(control));
2636 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2638 tet_infoline("Test reloading failed image from within signal handler.");
2640 ToolkitTestApplication application;
2644 ImageView imageView = ImageView::New();
2645 imageView.ResourceReadySignal().Connect(&ResourceFailedReload);
2646 DALI_TEST_EQUALS(gFailCounter, 0, TEST_LOCATION);
2647 ReloadImage(imageView);
2649 // loading started, this waits for the loader thread to complete
2650 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2651 application.SendNotification();
2653 DALI_TEST_EQUALS(gFailCounter, 1, TEST_LOCATION);
2655 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2656 application.SendNotification();
2658 DALI_TEST_EQUALS(gFailCounter, 2, TEST_LOCATION);
2660 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2661 application.SendNotification();
2662 DALI_TEST_EQUALS(gFailCounter, 3, TEST_LOCATION);
2667 int UtcDaliImageViewLoadRemoteSVG(void)
2669 tet_infoline("Test load from a remote server.");
2671 ToolkitTestApplication application;
2674 Toolkit::ImageView imageView;
2675 imageView = Toolkit::ImageView::New();
2676 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2677 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2678 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2679 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2680 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2682 application.GetScene().Add(imageView);
2684 DALI_TEST_CHECK(imageView);
2686 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2688 application.SendNotification();
2690 // Wait for loading & rasterization
2691 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2693 application.SendNotification();
2694 application.Render();
2696 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2701 Toolkit::ImageView imageView;
2702 imageView = Toolkit::ImageView::New();
2703 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2704 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2705 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2706 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2708 application.GetScene().Add(imageView);
2710 DALI_TEST_CHECK(imageView);
2712 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2714 application.SendNotification();
2716 // Wait for loading & rasterization
2717 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2719 application.SendNotification();
2720 application.Render();
2722 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2728 int UtcDaliImageViewSyncSVGLoading(void)
2730 ToolkitTestApplication application;
2732 tet_infoline("ImageView Testing SVG image sync loading");
2735 ImageView imageView = ImageView::New();
2737 // Sync loading is used
2738 Property::Map syncLoadingMap;
2739 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2740 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2741 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2742 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2744 application.GetScene().Add(imageView);
2745 DALI_TEST_CHECK(imageView);
2747 application.SendNotification();
2748 Vector3 naturalSize = imageView.GetNaturalSize();
2750 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2751 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2756 int UtcDaliImageViewAsyncSVGLoading(void)
2758 ToolkitTestApplication application;
2760 tet_infoline("ImageView Testing SVG image async loading");
2763 ImageView imageView = ImageView::New();
2765 // Async loading is used - default value of SYNCHRONOUS_LOADING is false.
2766 Property::Map propertyMap;
2767 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2768 propertyMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2769 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
2771 application.GetScene().Add(imageView);
2772 DALI_TEST_CHECK(imageView);
2774 application.SendNotification();
2777 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2779 application.SendNotification();
2780 application.Render(16);
2782 Vector3 naturalSize = imageView.GetNaturalSize();
2783 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2784 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2789 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2791 ToolkitTestApplication application;
2793 tet_infoline("ImageView Testing SVG image async loading");
2797 ImageView imageView = ImageView::New();
2799 // Sync loading is used
2800 Property::Map syncLoadingMap;
2801 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2802 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2804 // Check to set invalid value
2805 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2806 // Check if error log is outputted when setting other value like string.
2807 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2808 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5));
2809 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2811 application.GetScene().Add(imageView);
2812 DALI_TEST_CHECK(imageView);
2814 application.SendNotification();
2817 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2819 application.SendNotification();
2820 application.Render(16);
2822 Vector3 naturalSize = imageView.GetNaturalSize();
2823 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2824 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2826 Property::Value value = imageView.GetProperty(ImageView::Property::IMAGE);
2827 Property::Map* map = value.GetMap();
2828 DALI_TEST_CHECK(map);
2830 Property::Value* sync = map->Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING);
2831 DALI_TEST_CHECK(sync);
2832 DALI_TEST_EQUALS(false, sync->Get<bool>(), TEST_LOCATION);
2837 int UtcDaliImageViewSvgLoadingFailureLocalFile(void)
2839 // Local svg file - invalid file path
2841 ToolkitTestApplication application;
2843 TestGlAbstraction& gl = application.GetGlAbstraction();
2844 TraceCallStack& textureTrace = gl.GetTextureTrace();
2845 textureTrace.Enable(true);
2847 gResourceReadySignalFired = false;
2849 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2850 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2851 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2853 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2855 application.GetScene().Add(imageView);
2857 application.SendNotification();
2859 // loading started, this waits for the loader thread - load
2860 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2862 application.SendNotification();
2863 application.Render(16);
2865 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2866 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2867 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2869 // Should be shown a broken image
2870 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2871 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2874 // Local svg file - invalid file path without size set
2876 ToolkitTestApplication application;
2878 TestGlAbstraction& gl = application.GetGlAbstraction();
2879 TraceCallStack& textureTrace = gl.GetTextureTrace();
2880 textureTrace.Enable(true);
2882 gResourceReadySignalFired = false;
2883 textureTrace.Reset();
2885 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2886 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2888 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2890 application.GetScene().Add(imageView);
2892 application.SendNotification();
2894 // loading started, this waits for the loader thread - load & rasterize
2895 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2897 application.SendNotification();
2898 application.Render(16);
2900 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2901 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2902 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2904 // Should be shown a broken image
2905 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2906 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2909 // Local svg file - invalid file
2911 ToolkitTestApplication application;
2913 TestGlAbstraction& gl = application.GetGlAbstraction();
2914 TraceCallStack& textureTrace = gl.GetTextureTrace();
2915 textureTrace.Enable(true);
2917 gResourceReadySignalFired = false;
2918 textureTrace.Reset();
2920 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.svg");
2921 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2922 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2924 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2926 application.GetScene().Add(imageView);
2928 application.SendNotification();
2930 // loading started, this waits for the loader thread - load & rasterize
2931 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2933 application.SendNotification();
2934 application.Render(16);
2936 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2937 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2938 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2940 // Should be shown a broken image
2941 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2942 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2948 int UtcDaliImageViewSvgLoadingFailureRemoteFile01(void)
2952 ToolkitTestApplication application;
2954 TestGlAbstraction& gl = application.GetGlAbstraction();
2955 TraceCallStack& textureTrace = gl.GetTextureTrace();
2956 textureTrace.Enable(true);
2958 gResourceReadySignalFired = false;
2960 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
2961 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2962 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2964 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2966 application.GetScene().Add(imageView);
2968 application.SendNotification();
2970 // loading started, this waits for the loader thread - load & rasterize
2971 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2973 application.SendNotification();
2974 application.Render(16);
2976 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2977 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2978 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2980 // Should be shown a broken image
2981 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2982 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2988 int UtcDaliImageViewSvgLoadingFailureRemoteFile02(void)
2990 // Remote svg file without size set
2992 ToolkitTestApplication application;
2994 TestGlAbstraction& gl = application.GetGlAbstraction();
2995 TraceCallStack& textureTrace = gl.GetTextureTrace();
2996 textureTrace.Enable(true);
2998 gResourceReadySignalFired = false;
3000 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
3001 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3003 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3005 application.GetScene().Add(imageView);
3007 application.SendNotification();
3009 // loading started, this waits for the loader thread - load & rasterize
3010 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3012 application.SendNotification();
3013 application.Render(16);
3015 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3016 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3017 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3019 // Should be shown a broken image
3020 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3021 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3027 int UtcDaliImageViewSvgRasterizationFailure(void)
3029 ToolkitTestApplication application;
3031 gResourceReadySignalFired = false;
3033 TestGlAbstraction& gl = application.GetGlAbstraction();
3034 TraceCallStack& textureTrace = gl.GetTextureTrace();
3035 textureTrace.Enable(true);
3037 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid1.svg");
3038 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3039 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3041 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3043 application.GetScene().Add(imageView);
3045 application.SendNotification();
3047 // Wait for loading & rasterization
3048 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3050 application.SendNotification();
3051 application.Render(16);
3053 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3054 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3055 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3057 // Should be shown a broken image
3058 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3059 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3064 int UtcDaliImageViewSvgChageSize(void)
3066 ToolkitTestApplication application;
3068 TestGlAbstraction& gl = application.GetGlAbstraction();
3069 TraceCallStack& textureTrace = gl.GetTextureTrace();
3070 textureTrace.Enable(true);
3072 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME);
3073 application.GetScene().Add(imageView);
3075 application.SendNotification();
3077 // Wait for loading & rasterization
3078 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3080 application.SendNotification();
3081 application.Render(16);
3083 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3085 // Change actor size, then rasterization should be done again
3086 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3088 application.SendNotification();
3090 // Wait for rasterization
3091 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3093 application.SendNotification();
3094 application.Render(16);
3096 // We should not load the file again.
3097 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3102 int UtcDaliImageViewSvgAtlasing(void)
3104 ToolkitTestApplication application;
3106 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
3108 callStack.Enable(true);
3110 Property::Map propertyMap;
3111 propertyMap["url"] = TEST_SVG_FILE_NAME;
3112 propertyMap["atlasing"] = true;
3114 ImageView imageView = ImageView::New();
3115 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
3116 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3117 application.GetScene().Add(imageView);
3119 application.SendNotification();
3121 // Wait for loading & rasterization
3122 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3124 application.SendNotification();
3125 application.Render(16);
3128 TraceCallStack::NamedParams params1;
3129 params1["width"] << 100;
3130 params1["height"] << 100;
3131 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params1), true, TEST_LOCATION);
3133 imageView.SetProperty(Actor::Property::SIZE, Vector2(600.f, 600.f));
3135 application.SendNotification();
3137 // Wait for rasterization
3138 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3142 application.SendNotification();
3143 application.Render(16);
3146 TraceCallStack::NamedParams params2;
3147 params2["width"] << 600;
3148 params2["height"] << 600;
3149 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexImage2D", params2), true, TEST_LOCATION);
3154 int UtcDaliImageViewTVGLoading(void)
3156 ToolkitTestApplication application;
3158 tet_infoline("ImageView Testing TVG image loading");
3161 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/test.tvg");
3162 application.GetScene().Add(imageView);
3163 DALI_TEST_CHECK(imageView);
3165 application.SendNotification();
3167 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3169 application.SendNotification();
3170 application.Render(16);
3172 Vector3 naturalSize = imageView.GetNaturalSize();
3174 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3175 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3180 int UtcDaliImageViewImageLoadFailure01(void)
3182 ToolkitTestApplication application;
3184 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3185 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3186 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3187 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3189 std::string brokenUrl;
3190 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3191 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3193 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3194 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3196 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3197 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3199 ImageView imageView = ImageView::New("invalidUrl.png");
3200 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3202 application.GetScene().Add(imageView);
3203 application.SendNotification();
3204 application.Render(16);
3206 // loading started, this waits for the loader thread
3207 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3212 int UtcDaliImageViewImageLoadFailure02(void)
3214 ToolkitTestApplication application;
3216 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3217 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
3218 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3219 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3221 std::string brokenUrl;
3222 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3223 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
3225 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3226 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3228 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3229 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3231 ImageView imageView = ImageView::New("invalidUrl.png");
3232 imageView.SetProperty(Actor::Property::SIZE, Vector2(30.f, 30.f));
3233 application.GetScene().Add(imageView);
3234 application.SendNotification();
3235 application.Render(16);
3237 // loading started, this waits for the loader thread
3238 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3243 int UtcDaliImageViewImageLoadFailure03(void)
3245 ToolkitTestApplication application;
3247 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3248 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
3249 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
3251 std::string brokenUrl;
3252 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3253 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3255 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3256 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3258 ImageView imageView = ImageView::New("invalidUrl.png");
3259 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3260 application.GetScene().Add(imageView);
3261 application.SendNotification();
3262 application.Render(16);
3264 // loading started, this waits for the loader thread
3265 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3270 int UtcDaliImageViewImageLoadFailure04(void)
3272 ToolkitTestApplication application;
3274 ImageView imageView = ImageView::New("invalidUrl.png");
3275 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3276 application.GetScene().Add(imageView);
3277 application.SendNotification();
3278 application.Render(16);
3280 // loading started, this waits for the loader thread
3281 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3283 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3284 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3285 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3286 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3288 ImageView imageView2 = ImageView::New("invalidUrl.png");
3289 imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3290 application.GetScene().Add(imageView2);
3292 std::string brokenUrl;
3293 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3294 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3296 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3297 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3299 application.SendNotification();
3300 application.Render(16);
3302 // loading started, this waits for the loader thread
3303 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3305 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3307 ImageView imageView3 = ImageView::New("invalidUrl.png");
3308 imageView3.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3309 application.GetScene().Add(imageView3);
3311 application.SendNotification();
3312 application.Render(16);
3314 // loading started, this waits for the loader thread
3315 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3322 static int gResourceReadySignalCounter = 0;
3324 void OnResourceReadySignal01(Control control)
3326 gResourceReadySignalCounter++;
3328 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3330 if(gResourceReadySignalCounter == 1)
3333 // It makes the first new visual be deleted immediately
3334 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3335 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3338 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3340 // Make the resource ready immediately
3341 control[ImageView::Property::IMAGE] = gImage_600_RGB;
3345 void OnResourceReadySignal02(Control control)
3347 if(++gResourceReadySignalCounter == 1)
3349 // It makes the first new visual be deleted immediately
3350 // The first image will not be loaded.
3351 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB).Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3352 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3356 ImageView gImageView1;
3357 ImageView gImageView2;
3358 ImageView gImageView3;
3359 ImageView gImageView4;
3361 void OnResourceReadySignal03(Control control)
3363 if(gResourceReadySignalCounter == 0)
3366 // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3367 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3369 // 2. Load a new image
3370 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3372 // 3. Use the new image again
3373 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3374 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3376 else if(gResourceReadySignalCounter == 1)
3378 // This is called from TextureManager::ProcessQueuedTextures().
3379 gImageView1.Unparent();
3380 gImageView1.Reset();
3382 gResourceReadySignalCounter++;
3385 void OnSimpleResourceReadySignal(Control control)
3387 // simply increate counter
3388 gResourceReadySignalCounter++;
3391 int gResourceReadySignal04ComesOrder = 0;
3393 void OnResourceReadySignal04(Control control)
3395 gResourceReadySignalCounter++;
3396 tet_printf("rc %d\n", gResourceReadySignalCounter);
3397 if(gResourceReadySignalCounter == 1)
3399 auto scene = gImageView1.GetParent();
3401 // Request load something
3402 // We hope this request result is return later than gImageView2.
3403 gImageView3 = ImageView::New(TEST_IMAGE_1);
3404 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3405 scene.Add(gImageView3);
3406 gImageView4 = ImageView::New(TEST_IMAGE_2);
3407 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3408 scene.Add(gImageView4);
3410 if(control == gImageView1)
3412 gResourceReadySignal04ComesOrder = 1;
3416 gResourceReadySignal04ComesOrder = 2;
3419 if(gResourceReadySignalCounter == 2)
3421 if(gResourceReadySignal04ComesOrder == 1 && control == gImageView2)
3423 // Scene off first one.
3424 gImageView1.Unparent();
3426 // Scene off second one.
3427 gImageView2.Unparent();
3429 else if(gResourceReadySignal04ComesOrder == 2 && control == gImageView1)
3431 // Scene off first one.
3432 gImageView2.Unparent();
3434 // Scene off second one.
3435 gImageView1.Unparent();
3439 // We can't check that this utc fail case. just pass always when we come here.
3440 gResourceReadySignal04ComesOrder = -1;
3443 // If we don't seperate index of FreeList area
3444 // and if we don't queue remove during obversing,
3445 // cache index become something invalid data.
3446 // In this case, some strange observer can be called.
3447 // For example, gImageView4.LoadComplete will be called.
3451 void OnResourceReadySignal05(Control control)
3453 gResourceReadySignalCounter++;
3455 // Request load with same image
3456 // NOTE : The url must not be same as gImageView1
3457 const int viewCount = 4;
3458 for(int i = 0; i < viewCount; ++i)
3460 gImageView1.Add(ImageView::New("invalid2.jpg"));
3464 int gResourceReadySignal06ComesOrder = 0;
3466 void OnResourceReadySignal06(Control control)
3468 gResourceReadySignalCounter++;
3469 if(gResourceReadySignalCounter == 1)
3471 auto scene = gImageView1.GetParent();
3473 // Request load something
3474 // We hope this request result is return later than gImageView2.
3477 map1[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
3478 map1[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
3480 gImageView3 = ImageView::New();
3481 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3482 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3485 map2[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
3486 map2[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_S;
3487 gImageView4 = ImageView::New();
3488 gImageView4.SetProperty(Toolkit::ImageView::Property::IMAGE, map2);
3489 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3491 if(control == gImageView1)
3493 gResourceReadySignal06ComesOrder = 1;
3497 gResourceReadySignal06ComesOrder = 2;
3500 if(gResourceReadySignalCounter == 2)
3502 if(gResourceReadySignal06ComesOrder == 1 && control == gImageView2)
3504 // Scene off first one.
3505 gImageView1.Unparent();
3507 // Scene off second one.
3508 gImageView2.Unparent();
3510 else if(gResourceReadySignal06ComesOrder == 2 && control == gImageView1)
3512 // Scene off first one.
3513 gImageView2.Unparent();
3515 // Scene off second one.
3516 gImageView1.Unparent();
3520 // We can't check that this utc fail case. just pass always when we come here.
3521 gResourceReadySignal06ComesOrder = -1;
3524 // If we don't seperate index of FreeList area
3525 // and if we don't queue remove during obversing,
3526 // cache index become something invalid data.
3527 // In this case, some strange observer can be called.
3528 // For example, gImageView4.LoadComplete will be called.
3534 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3536 tet_infoline("Test setting image from within signal handler.");
3538 ToolkitTestApplication application;
3540 gResourceReadySignalCounter = 0;
3542 ImageView imageView = ImageView::New(gImage_34_RGBA);
3543 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal01);
3545 application.GetScene().Add(imageView);
3547 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3549 application.SendNotification();
3550 application.Render();
3552 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3554 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3556 // Create a new ImageView to cache the image
3557 ImageView imageView1 = ImageView::New(gImage_600_RGB);
3558 application.GetScene().Add(imageView1);
3560 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3562 application.SendNotification();
3563 application.Render();
3566 gResourceReadySignalCounter = 0;
3568 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3570 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3572 application.SendNotification();
3573 application.Render();
3575 // Run idle callback
3576 application.RunIdles();
3578 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3580 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3585 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
3587 tet_infoline("Test setting image from within signal handler.");
3589 ToolkitTestApplication application;
3591 gResourceReadySignalCounter = 0;
3593 ImageView imageView = ImageView::New(gImage_34_RGBA);
3594 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal02);
3596 application.GetScene().Add(imageView);
3598 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3600 application.SendNotification();
3601 application.Render();
3603 // Wait for loading an image
3604 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3606 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3608 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3613 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3615 tet_infoline("Test setting image from within signal handler.");
3617 ToolkitTestApplication application;
3619 gResourceReadySignalCounter = 0;
3621 gImageView1 = ImageView::New(gImage_34_RGBA);
3622 application.GetScene().Add(gImageView1);
3625 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3627 gImageView2 = ImageView::New(gImage_600_RGB);
3628 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3629 application.GetScene().Add(gImageView2);
3631 gImageView3 = ImageView::New();
3632 application.GetScene().Add(gImageView3);
3634 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3636 application.SendNotification();
3637 application.Render();
3642 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask01(void)
3644 tet_infoline("Test signal handler when image / mask image is broken.");
3646 ToolkitTestApplication application;
3648 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, const std::string& url, const std::string& mask, const char* location) {
3649 gResourceReadySignalCounter = 0;
3652 map[Toolkit::ImageVisual::Property::URL] = url;
3655 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3657 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3659 ImageView imageView = ImageView::New();
3660 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3661 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3662 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3664 application.GetScene().Add(imageView);
3665 application.SendNotification();
3666 application.Render();
3671 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3673 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3674 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3676 imageView.Unparent();
3679 for(int synchronous = 0; synchronous <= 1; synchronous++)
3681 tet_printf("Test normal case (sync:%d)\n", synchronous);
3682 TestResourceReadyUrl(1, synchronous, gImage_600_RGB, "", TEST_LOCATION);
3683 TestResourceReadyUrl(3, synchronous, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 3 event trigger required : 2 image load + 1 apply mask
3685 tet_printf("Test broken image case (sync:%d)\n", synchronous);
3686 TestResourceReadyUrl(1, synchronous, "invalid.jpg", "", TEST_LOCATION);
3687 TestResourceReadyUrl(2, synchronous, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3689 tet_printf("Test broken mask image case (sync:%d)\n", synchronous);
3690 TestResourceReadyUrl(2, synchronous, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3692 tet_printf("Test broken both image, mask image case (sync:%d)\n", synchronous);
3693 TestResourceReadyUrl(2, synchronous, "invalid.jpg", "invalid.png", TEST_LOCATION);
3699 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask02(void)
3701 tet_infoline("Test signal handler when image try to use cached-and-broken mask image.");
3703 ToolkitTestApplication application;
3705 gResourceReadySignalCounter = 0;
3707 auto TestBrokenMaskResourceReadyUrl = [&application](const std::string& url, const char* location) {
3709 map[Toolkit::ImageVisual::Property::URL] = url;
3710 // Use invalid mask url
3711 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
3713 ImageView imageView = ImageView::New();
3714 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3715 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3716 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3718 application.GetScene().Add(imageView);
3719 application.SendNotification();
3720 application.Render();
3722 // Don't unparent imageView, for keep the cache.
3725 // Use more than 4 images (The number of LocalImageLoadThread)
3726 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};
3728 int expectResourceReadySignalCounter = 0;
3730 for(auto& url : testUrlList)
3732 TestBrokenMaskResourceReadyUrl(url, TEST_LOCATION);
3733 expectResourceReadySignalCounter++;
3736 // Remain 1 signal due to we use #URL + 1 mask image.
3737 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(expectResourceReadySignalCounter + 1), true, TEST_LOCATION);
3739 DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
3744 int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
3746 tet_infoline("Test signal handler various case.");
3748 auto TestResourceReadyUrl = [](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
3749 ToolkitTestApplication application;
3751 gResourceReadySignalCounter = 0;
3754 map[Toolkit::ImageVisual::Property::URL] = url;
3757 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3759 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3761 ImageView imageView = ImageView::New();
3762 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3763 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3764 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3766 application.GetScene().Add(imageView);
3767 application.SendNotification();
3768 application.Render();
3771 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3773 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3774 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3775 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, location);
3777 imageView.Unparent();
3780 auto TestAuxiliaryResourceReadyUrl = [](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
3781 ToolkitTestApplication application;
3783 gResourceReadySignalCounter = 0;
3786 map[Toolkit::ImageVisual::Property::URL] = url;
3787 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE] = auxiliaryUrl;
3788 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA] = 0.5f;
3789 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3791 ImageView imageView = ImageView::New();
3792 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
3793 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
3794 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3795 application.GetScene().Add(imageView);
3797 application.SendNotification();
3798 application.Render();
3803 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, location);
3806 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3807 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3808 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3810 imageView.Unparent();
3813 // Case 1 : asynchronous loading
3814 tet_printf("Test invalid single simple image Asynchronous\n");
3817 TestResourceReadyUrl(1, 0, 1, gImage_600_RGB, "", TEST_LOCATION);
3818 TestResourceReadyUrl(2, 0, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // load & rasterize
3819 TestResourceReadyUrl(1, 0, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
3821 TestResourceReadyUrl(2, 0, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // 2 image loading - batch size
3822 TestResourceReadyUrl(2, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // load & rasterize
3824 TestResourceReadyUrl(3, 0, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 2 image loading + 1 applymask
3826 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
3829 TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
3830 TestResourceReadyUrl(1, 0, 0, "invalid.svg", "", TEST_LOCATION);
3831 TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
3832 TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION); // 1 image loading
3833 TestResourceReadyUrl(1, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
3835 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", "invalid.png", TEST_LOCATION); // 2 image loading
3836 TestResourceReadyUrl(2, 0, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); // 2 image loading
3837 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION); // 2 image loading
3839 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
3840 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
3841 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
3843 // Case 2 : Synchronous loading
3844 tet_printf("Test invalid single simple image Synchronous\n");
3847 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "", TEST_LOCATION);
3848 TestResourceReadyUrl(0, 1, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
3849 TestResourceReadyUrl(0, 1, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
3851 TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // first frame image loading sync + second frame image loading async
3853 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION);
3855 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
3858 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
3859 TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION);
3860 TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
3861 TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
3863 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "invalid.png", TEST_LOCATION);
3864 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3865 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3867 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
3868 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
3869 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
3874 int UtcDaliImageViewSetImageOnResourceReadySignal04(void)
3876 tet_infoline("Test texturemanager's remove queue works well within signal handler.");
3878 ToolkitTestApplication application;
3880 gResourceReadySignalCounter = 0;
3881 gResourceReadySignal04ComesOrder = 0;
3883 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
3884 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3885 application.GetScene().Add(gImageView1);
3887 gImageView2 = ImageView::New("invalid.png"); // request invalid image, to make loading failed fast.
3888 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3889 application.GetScene().Add(gImageView2);
3891 application.SendNotification();
3892 application.Render();
3894 tet_infoline("Try to load 2 invalid image");
3896 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3897 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3899 tet_infoline("load done");
3901 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
3902 if(gResourceReadySignal04ComesOrder == -1)
3904 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
3908 // gImageView3 and gImageView4 load must not be successed yet.
3909 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
3910 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
3912 application.SendNotification();
3913 application.Render();
3915 tet_infoline("Try to load 2 valid image");
3917 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3918 DALI_TEST_EQUALS(gResourceReadySignalCounter, 4, TEST_LOCATION);
3920 tet_infoline("load done");
3922 // gImageView3 and gImageView4 load must be successed now.
3923 DALI_TEST_EQUALS(gImageView3.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
3924 DALI_TEST_EQUALS(gImageView4.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
3929 int UtcDaliImageViewSetImageOnResourceReadySignal05(void)
3931 tet_infoline("Test multiple views with same image during ResourceReady load the image only 1 times");
3933 ToolkitTestApplication application;
3935 gResourceReadySignalCounter = 0;
3937 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
3938 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal05);
3939 application.GetScene().Add(gImageView1);
3941 application.SendNotification();
3942 application.Render();
3944 tet_infoline("Try to load 1 invalid.jpg image");
3945 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3946 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
3948 tet_infoline("Try to load 1 invalid2.jpg image");
3949 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3951 tet_infoline("Now we don't have any image to be loaded. Check event thread trigger failed.");
3952 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
3954 gImageView1.Unparent();
3955 gImageView1.Reset();
3959 int UtcDaliImageViewSetImageOnResourceReadySignal06(void)
3961 tet_infoline("Test texturemanager's remove image & mask queue works well within signal handler.");
3963 ToolkitTestApplication application;
3965 gResourceReadySignalCounter = 0;
3966 gResourceReadySignal06ComesOrder = 0;
3969 map[Toolkit::ImageVisual::Property::URL] = "invalid.jpg";
3970 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
3972 gImageView1 = ImageView::New(); // request invalid image, to make loading failed fast.
3973 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
3974 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3975 application.GetScene().Add(gImageView1);
3977 gImageView2 = ImageView::New(); // request invalid image, to make loading failed fast.
3978 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
3979 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3980 application.GetScene().Add(gImageView2);
3982 application.SendNotification();
3983 application.Render();
3985 tet_infoline("Try to load 2 invalid image");
3987 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3988 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3990 tet_infoline("load done");
3992 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
3993 if(gResourceReadySignal06ComesOrder == -1)
3995 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
3999 // gImageView3 and gImageView4 load must not be successed yet.
4000 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
4001 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
4003 application.GetScene().Add(gImageView3);
4004 application.GetScene().Add(gImageView4);
4005 application.SendNotification();
4006 application.Render();
4008 tet_infoline("Try to load 2 valid image");
4010 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4011 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4013 tet_infoline("load done");
4018 int UtcDaliImageViewUseSameUrlWithAnimatedImageVisual(void)
4020 tet_infoline("Test multiple views with same image in animated image visual");
4021 ToolkitTestApplication application;
4023 gImageView1 = ImageView::New(TEST_WEBP_FILE_NAME);
4024 application.GetScene().Add(gImageView1);
4026 tet_infoline("Remove imageView and Create new imageView with same url");
4027 application.GetScene().Remove(gImageView1);
4028 gImageView2 = ImageView::New(TEST_WEBP_FILE_NAME);
4029 application.GetScene().Add(gImageView2);
4031 application.SendNotification();
4032 application.Render();
4034 tet_infoline("Check the ImageView load image successfully");
4035 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);