2 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
24 #include <dali-toolkit-test-suite-utils.h>
25 #include <toolkit-event-thread-callback.h>
26 #include <toolkit-vector-image-renderer.h>
27 #include "dummy-control.h"
29 #include <test-encoded-image-buffer.h>
30 #include <test-native-image.h>
32 #include <dali-toolkit/dali-toolkit.h>
33 #include <dali-toolkit/devel-api/controls/control-devel.h>
34 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
35 #include <dali-toolkit/devel-api/styling/style-manager-devel.h>
36 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
37 #include <dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h>
38 #include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
39 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
40 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
41 #include <dali-toolkit/public-api/image-loader/image-url.h>
42 #include <dali-toolkit/public-api/image-loader/image.h>
43 #include <dali/devel-api/scripting/scripting.h>
46 using namespace Toolkit;
48 void utc_dali_toolkit_image_view_startup(void)
50 test_return_value = TET_UNDEF;
53 void utc_dali_toolkit_image_view_cleanup(void)
55 test_return_value = TET_PASS;
60 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
61 const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
63 // resolution: 1024*1024
64 const char* TEST_IMAGE_1 = TEST_RESOURCE_DIR "/TB-gloss.png";
65 const char* TEST_IMAGE_2 = TEST_RESOURCE_DIR "/tb-norm.png";
67 const char* TEST_BROKEN_IMAGE_DEFAULT = TEST_RESOURCE_DIR "/broken.png";
68 const char* TEST_BROKEN_IMAGE_S = TEST_RESOURCE_DIR "/broken_s.9.png";
69 const char* TEST_BROKEN_IMAGE_M = TEST_RESOURCE_DIR "/broken_m.9.png";
70 const char* TEST_BROKEN_IMAGE_L = TEST_RESOURCE_DIR "/broken_l.9.png";
71 const char* TEST_BROKEN_IMAGE_01 = TEST_RESOURCE_DIR "/button-up.9.png";
72 const char* TEST_BROKEN_IMAGE_02 = TEST_RESOURCE_DIR "/heartsframe.9.png";
74 const char* TEST_INVALID_NPATCH_FILE_NAME_01 = "invalid1.9.png";
76 // resolution: 34*34, pixel format: RGBA8888
77 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
78 // resolution: 600*600, pixel format: RGB888
79 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
81 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
82 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
84 const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
85 const char* TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
86 const char* TEST_WEBP_FILE_NAME = TEST_RESOURCE_DIR "/dali-logo.webp";
88 const char* TEST_OVERWRITABLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/overwritable-image.jpg";
90 void TestUrl(ImageView imageView, const std::string url)
92 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
94 std::string urlActual;
95 DALI_TEST_CHECK(value.Get(urlActual));
96 DALI_TEST_EQUALS(urlActual, url, TEST_LOCATION);
99 void OverwriteImage(const char* sourceFilename)
101 FILE* fpOut = fopen(TEST_OVERWRITABLE_IMAGE_FILE_NAME, "wb");
102 DALI_TEST_CHECK(fpOut);
105 FILE* fpIn = fopen(sourceFilename, "rb");
108 fseek(fpIn, 0, SEEK_END);
109 size_t size = ftell(fpIn);
111 tet_printf("Open %s success! file size : %zu byte\n", sourceFilename, size);
112 Dali::Vector<uint8_t> data;
114 fseek(fpIn, 0, SEEK_SET);
115 size_t realSize = fread(data.Begin(), sizeof(uint8_t), size, fpIn);
117 data.Resize(realSize);
120 fwrite(data.Begin(), sizeof(uint8_t), size, fpOut);
124 tet_printf("Open %s failed! write invalid\n", sourceFilename);
125 fprintf(fpOut, "invalid\n");
133 int UtcDaliImageViewNewP(void)
135 ToolkitTestApplication application;
137 ImageView imageView = ImageView::New();
139 DALI_TEST_CHECK(imageView);
144 int UtcDaliImageViewNewUrlP(void)
146 ToolkitTestApplication application;
148 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
149 DALI_TEST_CHECK(imageView);
151 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
156 int UtcDaliImageViewConstructorP(void)
158 ToolkitTestApplication application;
162 DALI_TEST_CHECK(!imageView);
167 int UtcDaliImageViewCopyConstructorP(void)
169 ToolkitTestApplication application;
171 // Initialize an object, ref count == 1
172 ImageView imageView = ImageView::New();
174 ImageView copy(imageView);
175 DALI_TEST_CHECK(copy);
180 int UtcDaliImageViewMoveConstructor(void)
182 ToolkitTestApplication application;
184 ImageView imageView = ImageView::New();
185 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
186 imageView.SetProperty(Actor::Property::SENSITIVE, false);
187 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
189 ImageView moved = std::move(imageView);
190 DALI_TEST_CHECK(moved);
191 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
192 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
193 DALI_TEST_CHECK(!imageView);
198 int UtcDaliImageViewAssignmentOperatorP(void)
200 ToolkitTestApplication application;
202 ImageView imageView = ImageView::New();
204 ImageView copy(imageView);
205 DALI_TEST_CHECK(copy);
206 DALI_TEST_EQUALS(imageView, copy, TEST_LOCATION);
211 int UtcDaliImageViewMoveAssignment(void)
213 ToolkitTestApplication application;
215 ImageView imageView = ImageView::New();
216 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
217 imageView.SetProperty(Actor::Property::SENSITIVE, false);
218 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
221 moved = std::move(imageView);
222 DALI_TEST_CHECK(moved);
223 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
224 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
225 DALI_TEST_CHECK(!imageView);
230 int UtcDaliImageViewDownCastP(void)
232 ToolkitTestApplication application;
234 ImageView imageView = ImageView::New();
236 BaseHandle object(imageView);
238 ImageView imageView2 = ImageView::DownCast(object);
239 DALI_TEST_CHECK(imageView2);
241 ImageView imageView3 = DownCast<ImageView>(object);
242 DALI_TEST_CHECK(imageView3);
247 int UtcDaliImageViewDownCastN(void)
249 ToolkitTestApplication application;
251 BaseHandle unInitializedObject;
253 ImageView imageView1 = ImageView::DownCast(unInitializedObject);
254 DALI_TEST_CHECK(!imageView1);
256 ImageView imageView2 = DownCast<ImageView>(unInitializedObject);
257 DALI_TEST_CHECK(!imageView2);
262 int UtcDaliImageViewTypeRegistry(void)
264 ToolkitTestApplication application;
266 TypeRegistry typeRegistry = TypeRegistry::Get();
267 DALI_TEST_CHECK(typeRegistry);
269 TypeInfo typeInfo = typeRegistry.GetTypeInfo("ImageView");
270 DALI_TEST_CHECK(typeInfo);
272 BaseHandle handle = typeInfo.CreateInstance();
273 DALI_TEST_CHECK(handle);
275 ImageView imageView = ImageView::DownCast(handle);
276 DALI_TEST_CHECK(imageView);
281 int UtcDaliImageViewSetGetProperty01(void)
283 ToolkitTestApplication application;
285 ImageView imageView = ImageView::New();
287 Property::Index idx = imageView.GetPropertyIndex("image");
288 DALI_TEST_EQUALS(idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION);
290 imageView.SetProperty(idx, TEST_IMAGE_FILE_NAME);
291 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
296 int UtcDaliImageViewPreMultipliedAlphaPng(void)
298 ToolkitTestApplication application;
300 // Set up trace debug
301 TestGlAbstraction& gl = application.GetGlAbstraction();
302 TraceCallStack& textureTrace = gl.GetTextureTrace();
303 textureTrace.Enable(true);
305 Property::Map imageMap;
306 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
307 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
309 ImageView imageView1 = ImageView::New();
310 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
312 application.GetScene().Add(imageView1);
314 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
316 DALI_TEST_CHECK(value.Get(enable));
317 DALI_TEST_CHECK(enable); // Default value is true
319 // loading started, this waits for the loader thread for max 30 seconds
320 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
322 application.SendNotification();
323 application.Render();
325 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
326 DALI_TEST_CHECK(value.Get(enable));
327 DALI_TEST_CHECK(enable); // Keep true
329 // conventional alpha blending
330 Renderer renderer1 = imageView1.GetRendererAt(0);
331 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
332 DALI_TEST_CHECK(value.Get(enable));
333 DALI_TEST_CHECK(enable);
335 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
336 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
337 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
338 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
339 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
340 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
341 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
342 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
344 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
345 textureTrace.Reset();
347 // Disable pre-multiplied alpha blending
348 imageView1.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
351 Property::Map attributes;
352 DevelControl::DoAction(imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
354 // loading started, this waits for the loader thread for max 30 seconds
355 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
357 application.SendNotification();
358 application.Render();
360 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
361 DALI_TEST_CHECK(value.Get(enable));
362 DALI_TEST_CHECK(!enable);
364 // conventional alpha blending
365 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
366 DALI_TEST_CHECK(value.Get(enable));
367 DALI_TEST_CHECK(!enable);
369 srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
370 destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
371 srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
372 destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
373 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
374 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
375 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
376 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
378 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
379 textureTrace.Reset();
381 // Make a new ImageView using the same image
382 ImageView imageView2 = ImageView::New();
383 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
385 application.GetScene().Add(imageView2);
387 application.SendNotification();
388 application.Render();
390 Renderer renderer2 = imageView2.GetRendererAt(0);
391 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
392 DALI_TEST_CHECK(value.Get(enable));
393 DALI_TEST_CHECK(enable);
395 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
396 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
397 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
398 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
399 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
400 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
401 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
402 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
404 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
409 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
411 ToolkitTestApplication application;
413 // Set up trace debug
414 TestGlAbstraction& gl = application.GetGlAbstraction();
415 TraceCallStack& textureTrace = gl.GetTextureTrace();
416 textureTrace.Enable(true);
418 Property::Map imageMap;
419 imageMap[ImageVisual::Property::URL] = gImage_600_RGB;
420 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
422 ImageView imageView1 = ImageView::New();
423 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
425 application.GetScene().Add(imageView1);
427 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
429 DALI_TEST_CHECK(value.Get(enable));
430 DALI_TEST_CHECK(enable); // Default value is true
432 // loading started, this waits for the loader thread for max 30 seconds
433 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
435 application.SendNotification();
436 application.Render();
438 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
439 DALI_TEST_CHECK(value.Get(enable));
440 DALI_TEST_CHECK(!enable); // Should be false after loading
442 // conventional alpha blending
443 Renderer renderer1 = imageView1.GetRendererAt(0);
444 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
445 DALI_TEST_CHECK(value.Get(enable));
446 DALI_TEST_CHECK(!enable);
448 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
449 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
450 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
451 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
452 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
453 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
454 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
455 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
457 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
458 textureTrace.Reset();
460 ImageView imageView2 = ImageView::New();
461 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
463 // Disable pre-multiplied alpha blending
464 imageView2.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
466 application.GetScene().Add(imageView2);
468 application.SendNotification();
469 application.Render();
471 value = imageView2.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
472 DALI_TEST_CHECK(value.Get(enable));
473 DALI_TEST_CHECK(!enable);
475 // conventional alpha blending
476 Renderer renderer2 = imageView2.GetRendererAt(0);
477 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
478 DALI_TEST_CHECK(value.Get(enable));
479 DALI_TEST_CHECK(!enable);
481 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
482 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
483 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
484 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
485 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
486 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
487 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
488 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
490 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
495 int UtcDaliImageViewPixelArea(void)
497 // Test pixel area property
498 ToolkitTestApplication application;
500 static std::vector<UniformData> customUniforms =
502 UniformData("pixelArea", Property::Type::VECTOR4),
505 TestGraphicsController& graphics = application.GetGraphicsController();
506 graphics.AddCustomUniforms(customUniforms);
508 // Gif image, use AnimatedImageVisual internally
509 // Atlasing is applied to pack multiple frames, use custom wrap mode
510 ImageView gifView = ImageView::New();
511 const Vector4 pixelAreaVisual(0.f, 0.f, 2.f, 2.f);
512 gifView.SetProperty(ImageView::Property::IMAGE,
513 Property::Map().Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME).Add(ImageVisual::Property::PIXEL_AREA, pixelAreaVisual));
516 Integration::Scene stage = application.GetScene();
520 application.SendNotification();
521 application.Render(16);
523 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
525 application.SendNotification();
526 application.Render();
527 DALI_TEST_CHECK(gifView.GetRendererCount() == 1u);
529 const Vector4 fullTextureRect(0.f, 0.f, 1.f, 1.f);
530 // test that the pixel area value defined in the visual property map is registered on renderer
531 Renderer renderer = gifView.GetRendererAt(0);
532 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
533 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION);
535 // test that the shader has the default pixel area value registered.
536 Shader shader = renderer.GetShader();
537 pixelAreaValue = shader.GetProperty(shader.GetPropertyIndex("pixelArea"));
538 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION);
540 // test that the uniform uses the pixelArea property on the renderer.
541 TestGlAbstraction& gl = application.GetGlAbstraction();
542 Vector4 pixelAreaUniform;
543 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
544 DALI_TEST_EQUALS(pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
546 // set the pixelArea property on the control
547 const Vector4 pixelAreaControl(-1.f, -1.f, 3.f, 3.f);
548 gifView.SetProperty(ImageView::Property::PIXEL_AREA, pixelAreaControl);
549 application.SendNotification();
550 application.Render(16);
552 // check the pixelArea property on the control
553 pixelAreaValue = gifView.GetProperty(gifView.GetPropertyIndex("pixelArea"));
554 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION);
555 // test that the uniform uses the pixelArea property on the control.
556 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
557 DALI_TEST_EQUALS(pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
562 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
564 ToolkitTestApplication application;
565 TestGlAbstraction& gl = application.GetGlAbstraction();
566 const std::vector<GLuint>& textures = gl.GetBoundTextures();
567 size_t numTextures = textures.size();
569 // Async loading, no atlasing for big size image
570 ImageView imageView = ImageView::New(gImage_600_RGB);
572 // By default, Aysnc loading is used
573 application.GetScene().Add(imageView);
574 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
575 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
577 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
579 application.SendNotification();
580 application.Render(16);
581 application.SendNotification();
583 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
584 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
589 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
591 ToolkitTestApplication application;
593 //Async loading, automatic atlasing for small size image
594 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
596 callStack.Enable(true);
598 Property::Map imageMap;
600 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
601 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
602 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
603 imageMap[ImageVisual::Property::ATLASING] = true;
605 ImageView imageView = ImageView::New();
606 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
607 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
609 // By default, Aysnc loading is used
610 // loading is not started if the actor is offScene
612 application.GetScene().Add(imageView);
614 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
616 // loading started, this waits for the loader thread for max 30 seconds
617 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
619 application.SendNotification();
620 application.Render(16);
622 callStack.Enable(false);
624 TraceCallStack::NamedParams params;
625 params["width"] << 34;
626 params["height"] << 34;
627 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
632 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
634 ToolkitTestApplication application;
636 //Async loading, automatic atlasing for small size image
637 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
639 callStack.Enable(true);
641 Property::Map asyncLoadingMap;
642 asyncLoadingMap["url"] = gImage_34_RGBA;
643 asyncLoadingMap["desiredHeight"] = 34;
644 asyncLoadingMap["desiredWidth"] = 34;
645 asyncLoadingMap["synchronousLoading"] = false;
646 asyncLoadingMap["atlasing"] = true;
648 ImageView imageView = ImageView::New();
649 imageView.SetProperty(ImageView::Property::IMAGE, asyncLoadingMap);
651 application.GetScene().Add(imageView);
653 // loading started, this waits for the loader thread for max 30 seconds
654 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
656 application.SendNotification();
657 application.Render(16);
659 callStack.Enable(false);
661 TraceCallStack::NamedParams params;
662 params["width"] << 34;
663 params["height"] << 34;
664 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
669 int UtcDaliImageViewSyncLoading(void)
671 ToolkitTestApplication application;
673 tet_infoline("ImageView Testing sync loading and size using index key property map");
675 Property::Map syncLoadingMap;
676 syncLoadingMap[ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
677 syncLoadingMap[ImageVisual::Property::ATLASING] = true;
679 // Sync loading, no atlasing for big size image
681 ImageView imageView = ImageView::New();
683 // Sync loading is used
684 syncLoadingMap[ImageVisual::Property::URL] = gImage_600_RGB;
685 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
688 // Sync loading, automatic atlasing for small size image
690 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
692 callStack.Enable(true);
694 ImageView imageView = ImageView::New();
696 // Sync loading is used
697 syncLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
698 syncLoadingMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
699 syncLoadingMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
700 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
702 application.GetScene().Add(imageView);
703 application.SendNotification();
704 application.Render(16);
706 TraceCallStack::NamedParams params;
707 params["width"] << 34;
708 params["height"] << 34;
709 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
716 int UtcDaliImageViewSyncLoading02(void)
718 ToolkitTestApplication application;
720 tet_infoline("ImageView Testing sync loading and size using string key property map");
722 // Sync loading, automatic atlasing for small size image
724 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
726 callStack.Enable(true);
728 ImageView imageView = ImageView::New();
730 // Sync loading is used
731 Property::Map syncLoadingMap;
732 syncLoadingMap["url"] = gImage_34_RGBA;
733 syncLoadingMap["desiredHeight"] = 34;
734 syncLoadingMap["desiredWidth"] = 34;
735 syncLoadingMap["synchronousLoading"] = true;
736 syncLoadingMap["atlasing"] = true;
737 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
739 application.GetScene().Add(imageView);
740 application.SendNotification();
741 application.Render(16);
743 TraceCallStack::NamedParams params;
744 params["width"] << 34;
745 params["height"] << 34;
746 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
753 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
755 ToolkitTestApplication application;
756 TestGlAbstraction& gl = application.GetGlAbstraction();
757 const std::vector<GLuint>& textures = gl.GetBoundTextures();
758 size_t numTextures = textures.size();
760 // Get encoded raw-buffer image and generate url
761 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
762 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
764 // Async loading, no atlasing for big size image
765 ImageView imageView = ImageView::New(url.GetUrl());
767 // By default, Aysnc loading is used
768 application.GetScene().Add(imageView);
769 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
770 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
772 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
774 application.SendNotification();
775 application.Render(16);
776 application.SendNotification();
778 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
779 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
784 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
786 ToolkitTestApplication application;
788 // Get encoded raw-buffer image and generate url
789 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
790 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
791 ImageUrl url2 = Toolkit::Image::GenerateUrl(buffer);
793 // Generate url is not equal to url2
794 // NOTE : This behavior may changed when ImageUrl compare operator changed.
795 DALI_TEST_CHECK(url != url2);
796 // Generate url's string is equal to url2's string
797 DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
799 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
800 url2 = Toolkit::Image::GenerateUrl(buffer2);
802 // Check whethere two url are not equal
803 DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
805 // Async loading, automatic atlasing for small size image
806 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
808 callStack.Enable(true);
810 Property::Map imageMap;
812 imageMap[ImageVisual::Property::URL] = url.GetUrl();
813 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 600;
814 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 600;
815 imageMap[ImageVisual::Property::ATLASING] = true;
817 // No atlasing with big image
818 ImageView imageView_bigdesired = ImageView::New();
819 imageView_bigdesired.SetProperty(ImageView::Property::IMAGE, imageMap);
820 imageView_bigdesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
822 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 0;
823 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 0;
825 // No atlasing with zero desired size
826 ImageView imageView_nodesired = ImageView::New();
827 imageView_nodesired.SetProperty(ImageView::Property::IMAGE, imageMap);
828 imageView_nodesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
830 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
831 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
833 ImageView imageView = ImageView::New();
834 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
835 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
837 // By default, Aysnc loading is used
838 // loading is not started if the actor is offScene
839 application.GetScene().Add(imageView);
840 application.GetScene().Add(imageView_bigdesired);
841 application.GetScene().Add(imageView_nodesired);
842 application.SendNotification();
843 application.Render(16);
845 // loading started, this waits for the loader thread for max 30 seconds
846 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
848 application.Render(16);
849 application.SendNotification();
851 // Change url to url2
852 imageMap[ImageVisual::Property::URL] = url2.GetUrl();
853 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
855 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
857 // loading started, this waits for the loader thread for max 30 seconds
858 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
860 application.SendNotification();
861 application.Render(16);
863 callStack.Enable(false);
865 TraceCallStack::NamedParams params;
866 params["width"] << 34;
867 params["height"] << 34;
868 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
873 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
875 ToolkitTestApplication application;
877 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
879 // Get encoded raw-buffer image and generate url
880 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
881 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
883 // Sync loading, automatic atlasing for small size image
885 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
887 callStack.Enable(true);
889 ImageView imageView = ImageView::New();
891 // Sync loading is used
892 Property::Map syncLoadingMap;
893 syncLoadingMap["url"] = url.GetUrl();
894 syncLoadingMap["alphaMaskUrl"] = gImage_34_RGBA;
895 syncLoadingMap["desiredHeight"] = 34;
896 syncLoadingMap["desiredWidth"] = 34;
897 syncLoadingMap["synchronousLoading"] = true;
898 syncLoadingMap["atlasing"] = true;
899 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
901 application.GetScene().Add(imageView);
902 application.SendNotification();
903 application.Render(16);
905 TraceCallStack::NamedParams params;
906 params["width"] << 34;
907 params["height"] << 34;
908 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
916 int UtcDaliImageViewEncodedBufferWithSvg(void)
918 ToolkitTestApplication application;
919 TestGlAbstraction& gl = application.GetGlAbstraction();
920 const std::vector<GLuint>& textures = gl.GetBoundTextures();
921 size_t numTextures = textures.size();
923 // Get encoded raw-buffer svg image and generate url
924 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(TEST_SVG_FILE_NAME, EncodedImageBuffer::ImageType::VECTOR_IMAGE);
925 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
927 // Async loading, no atlasing for big size image
928 ImageView imageView = ImageView::New(url.GetUrl());
930 // By default, Aysnc loading is used
931 application.GetScene().Add(imageView);
932 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
933 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
935 application.SendNotification();
936 application.Render(16);
938 // Load svg image + rasterize.
939 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
941 application.SendNotification();
942 application.Render(16);
943 application.SendNotification();
945 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
946 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
948 // Remove visual, for line coverage.
949 imageView.Unparent();
950 application.SendNotification();
951 application.Render(16);
956 int UtcDaliImageViewEncodedBufferWithAnimatedVectorImage(void)
958 ToolkitTestApplication application;
959 TestGlAbstraction& gl = application.GetGlAbstraction();
960 const std::vector<GLuint>& textures = gl.GetBoundTextures();
961 size_t numTextures = textures.size();
963 // Get encoded raw-buffer lottie image and generate url
964 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, EncodedImageBuffer::ImageType::ANIMATED_VECTOR_IMAGE);
965 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
967 // Async loading, no atlasing for big size image
968 ImageView imageView = ImageView::New(url.GetUrl());
970 // By default, Aysnc loading is used
971 application.GetScene().Add(imageView);
972 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
973 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
975 application.SendNotification();
976 application.Render(16);
978 // Load lottie image is sync. Only wait rasterize.
979 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
981 application.SendNotification();
982 application.Render(16);
983 application.SendNotification();
985 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
986 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
988 // Remove visual, for line coverage.
989 imageView.Unparent();
990 application.SendNotification();
991 application.Render(16);
996 int UtcDaliImageViewEncodedBufferWithInvalidImageType(void)
998 ToolkitTestApplication application;
999 TestGlAbstraction& gl = application.GetGlAbstraction();
1000 const std::vector<GLuint>& textures = gl.GetBoundTextures();
1001 size_t numTextures = textures.size();
1003 // Get encoded raw-buffer jpg image with invalid image type, and generate url
1004 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA, static_cast<EncodedImageBuffer::ImageType>(-1));
1005 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
1007 // Async loading, no atlasing for big size image
1008 ImageView imageView = ImageView::New(url.GetUrl());
1010 // By default, Aysnc loading is used
1011 application.GetScene().Add(imageView);
1012 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
1013 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1015 application.SendNotification();
1016 application.Render(16);
1019 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1021 application.SendNotification();
1022 application.Render(16);
1023 application.SendNotification();
1025 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
1026 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
1028 // Remove visual, for line coverage.
1029 imageView.Unparent();
1030 application.SendNotification();
1031 application.Render(16);
1036 int UtcDaliImageViewAddedTexture(void)
1038 ToolkitTestApplication application;
1040 tet_infoline("ImageView Testing image view with texture provided manager url");
1042 ImageView imageView = ImageView::New();
1044 // empty texture is ok, though pointless from app point of view
1046 std::string url = TextureManager::AddTexture(empty);
1047 DALI_TEST_CHECK(url.size() > 0u);
1049 Property::Map propertyMap;
1050 propertyMap[ImageVisual::Property::URL] = url;
1051 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1053 application.GetScene().Add(imageView);
1054 application.SendNotification();
1055 application.Render();
1060 int UtcDaliImageViewSizeWithBackground(void)
1062 ToolkitTestApplication application;
1066 ImageView imageView = ImageView::New();
1068 imageView.SetProperty(Control::Property::BACKGROUND,
1070 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1071 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1072 {ImageVisual::Property::DESIRED_WIDTH, width},
1073 {ImageVisual::Property::DESIRED_HEIGHT, height},
1076 application.GetScene().Add(imageView);
1077 application.SendNotification();
1078 application.Render();
1080 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
1081 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
1086 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
1088 ToolkitTestApplication application;
1090 int widthBackground = 100;
1091 int heightBackground = 200;
1095 ImageView imageView = ImageView::New();
1097 imageView.SetProperty(Control::Property::BACKGROUND,
1099 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1100 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1101 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1102 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground},
1105 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio, 600x600 pixels
1107 application.GetScene().Add(imageView);
1108 application.SendNotification();
1109 application.Render();
1111 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
1112 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
1117 int UtcDaliImageViewHeightForWidthBackground(void)
1119 ToolkitTestApplication application;
1121 int widthBackground = 100;
1122 int heightBackground = 200;
1124 ImageView imageView = ImageView::New();
1126 imageView.SetProperty(Control::Property::BACKGROUND,
1127 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1128 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1129 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1130 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}});
1132 application.GetScene().Add(imageView);
1133 application.SendNotification();
1134 application.Render();
1136 Control control = Control::DownCast(imageView);
1137 DALI_TEST_CHECK(control);
1138 DALI_TEST_EQUALS(imageView.GetHeightForWidth(123.f), control.GetHeightForWidth(123.f), TEST_LOCATION);
1139 DALI_TEST_EQUALS(imageView.GetWidthForHeight(321.f), control.GetWidthForHeight(321.f), TEST_LOCATION);
1144 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
1146 ToolkitTestApplication application;
1148 int widthBackground = 100;
1149 int heightBackground = 200;
1153 ImageView imageView = ImageView::New();
1155 imageView.SetProperty(Control::Property::BACKGROUND,
1156 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1157 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1158 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1159 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}}); // 1 to 2 ratio
1161 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio
1163 application.GetScene().Add(imageView);
1164 application.SendNotification();
1165 application.Render();
1167 DALI_TEST_EQUALS(imageView.GetHeightForWidth(width), (float)height, TEST_LOCATION);
1168 DALI_TEST_EQUALS(imageView.GetWidthForHeight(height), (float)width, TEST_LOCATION);
1173 int UtcDaliImageViewSetImageUrl(void)
1175 ToolkitTestApplication application;
1177 ImageView imageView = ImageView::New();
1178 imageView.SetImage(TEST_IMAGE_FILE_NAME);
1179 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
1181 imageView.SetImage(TEST_IMAGE_FILE_NAME2);
1182 TestUrl(imageView, TEST_IMAGE_FILE_NAME2);
1187 bool gResourceReadySignalFired = false;
1188 Vector3 gNaturalSize;
1190 void ResourceReadySignal(Control control)
1192 gResourceReadySignalFired = true;
1195 void OnResourceReadySignalSVG(Control control)
1197 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1198 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(control);
1199 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1200 Property::Map resultMap;
1201 imageVisual.CreatePropertyMap(resultMap);
1203 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1204 DALI_TEST_CHECK(transformValue);
1205 Property::Map* retMap = transformValue->GetMap();
1206 DALI_TEST_CHECK(retMap);
1208 // Fitting mode should not be applied at this point
1209 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::SIZE)->Get<Vector2>(), Vector2::ZERO, TEST_LOCATION);
1212 int UtcDaliImageViewCheckResourceReady(void)
1214 ToolkitTestApplication application;
1216 gResourceReadySignalFired = false;
1218 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1219 ImageView imageView = ImageView::New(TEST_GIF_FILE_NAME);
1221 imageView.SetProperty(Control::Property::BACKGROUND,
1222 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1223 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1224 {ImageVisual::Property::DESIRED_WIDTH, 100},
1225 {ImageVisual::Property::DESIRED_HEIGHT, 200}});
1227 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1229 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1231 application.GetScene().Add(imageView);
1233 // loading started, this waits for the loader thread
1234 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1236 application.SendNotification();
1237 application.Render(16);
1239 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1241 application.SendNotification();
1242 application.Render();
1244 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1246 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1251 int UtcDaliImageViewSetImageTypeChangesP(void)
1253 ToolkitTestApplication application;
1255 ImageView imageView = ImageView::New();
1256 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1258 application.GetScene().Add(imageView);
1262 Toolkit::Visual::Base visual;
1264 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1265 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1267 application.SendNotification();
1268 application.Render(16);
1270 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1272 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1273 DALI_TEST_CHECK(!visual); // Visual should be invalid
1276 imageView.SetImage("TEST_URL");
1278 application.SendNotification();
1279 application.Render(16);
1281 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1282 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1284 DALI_TEST_CHECK(value.Get(url)); // Value should NOT be empty
1285 DALI_TEST_CHECK(!value.Get(map)); // Value should be empty
1286 DALI_TEST_CHECK(visual); // Visual should be valid
1289 imageView.SetImage("");
1291 application.SendNotification();
1292 application.Render(16);
1294 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1295 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1297 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1299 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1300 DALI_TEST_CHECK(!visual); // Visual should be invalid
1302 // Set a URL in property map
1303 Property::Map propertyMap;
1304 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1305 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1307 application.SendNotification();
1308 application.Render(16);
1310 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1311 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1313 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1314 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1315 DALI_TEST_CHECK(visual); // Visual should be valid
1317 // Set a URL in property map again
1318 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1319 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1321 application.SendNotification();
1322 application.Render(16);
1324 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1325 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1327 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1328 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1329 DALI_TEST_CHECK(visual); // Visual should be valid
1331 // Set an empty URL in property map
1332 propertyMap[ImageVisual::Property::URL] = std::string();
1333 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1335 application.SendNotification();
1336 application.Render(16);
1338 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1339 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1341 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1342 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1343 DALI_TEST_CHECK(!visual); // Visual should be invalid
1345 // Set a URL in property map again
1346 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1347 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1349 application.SendNotification();
1350 application.Render(16);
1352 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1353 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1355 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1356 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1357 DALI_TEST_CHECK(visual); // Visual should be valid
1359 // Set an empty property map
1360 propertyMap.Clear();
1361 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1363 application.SendNotification();
1364 application.Render(16);
1366 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1367 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1369 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1370 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1371 DALI_TEST_CHECK(map.Empty()); // But PropertyMap should be empty
1372 DALI_TEST_CHECK(!visual); // Visual should be invalid
1377 int UtcDaliImageViewResourceUrlP(void)
1379 ToolkitTestApplication application;
1381 ImageView imageView = ImageView::New();
1382 DALI_TEST_CHECK(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>().empty());
1384 imageView.SetProperty(ImageView::Property::IMAGE, "TestString");
1385 DALI_TEST_EQUALS(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>(), "TestString", TEST_LOCATION);
1390 int UtcDaliImageViewReplaceImage(void)
1392 ToolkitTestApplication application;
1394 gResourceReadySignalFired = false;
1396 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1397 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1399 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1401 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1403 application.GetScene().Add(imageView);
1405 application.SendNotification();
1406 application.Render(16);
1408 // loading started, this waits for the loader thread for max 30 seconds
1409 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1411 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1413 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1415 gResourceReadySignalFired = false;
1417 imageView.SetImage(TEST_IMAGE_2);
1419 application.SendNotification();
1420 application.Render(16);
1422 // loading started, this waits for the loader thread for max 30 seconds
1423 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1425 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1427 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1429 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1434 int UtcDaliImageViewReloadAlphaMaskImage(void)
1436 ToolkitTestApplication application;
1438 gResourceReadySignalFired = false;
1440 ImageView dummy = ImageView::New();
1441 ImageView imageView = ImageView::New();
1442 Property::Map propertyMap;
1444 // To keep alpha mask cached, scene on some dummy image.
1445 // Note : If we don't cache alpha mask image, the reference count of mask image become zero.
1446 // In this case, we might need to wait mask image loading, which is not neccesary & can be changed behavior.
1447 propertyMap[ImageVisual::Property::URL] = gImage_600_RGB;
1448 propertyMap[ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
1449 dummy.SetProperty(ImageView::Property::IMAGE, propertyMap);
1451 application.GetScene().Add(dummy);
1453 application.SendNotification();
1454 application.Render(16);
1456 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1458 application.SendNotification();
1459 application.Render(16);
1461 propertyMap.Clear();
1462 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1463 propertyMap[ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
1464 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1466 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1468 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1470 application.GetScene().Add(imageView);
1472 application.SendNotification();
1473 application.Render(16);
1475 // Load image and use cached mask. Now we try to apply masking.
1476 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1478 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
1480 // Cancel apply masking.
1481 imageView.Unparent();
1483 application.SendNotification();
1484 application.Render(16);
1486 // Reload same image again.
1487 application.GetScene().Add(imageView);
1489 application.SendNotification();
1490 application.Render(16);
1492 // Finish apply masking.
1493 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1495 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1496 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1497 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1502 void OnRelayoutOverride(Size size)
1504 gNaturalSize = size; // Size Relayout is using
1507 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1509 ToolkitTestApplication application;
1511 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1512 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1513 imageView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1515 DummyControl dummyControl = DummyControl::New(true);
1516 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1517 dummyControl.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
1519 dummyControl.Add(imageView);
1520 dummyImpl.SetRelayoutCallback(&OnRelayoutOverride);
1521 application.GetScene().Add(dummyControl);
1523 application.SendNotification();
1524 application.Render();
1526 // loading started, this waits for the loader thread for max 30 seconds
1527 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1529 DALI_TEST_EQUALS(gNaturalSize.width, 1024.0f, TEST_LOCATION);
1530 DALI_TEST_EQUALS(gNaturalSize.height, 1024.0f, TEST_LOCATION);
1532 gNaturalSize = Vector3::ZERO;
1534 imageView.SetImage(gImage_600_RGB);
1536 // Waiting for resourceReady so SendNotifcation not called here.
1538 // loading started, this waits for the loader thread for max 30 seconds
1539 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1541 // Trigger a potential relayout
1542 application.SendNotification();
1543 application.Render();
1545 DALI_TEST_EQUALS(gNaturalSize.width, 600.0f, TEST_LOCATION);
1546 DALI_TEST_EQUALS(gNaturalSize.height, 600.0f, TEST_LOCATION);
1551 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1553 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1555 ToolkitTestApplication application;
1557 gResourceReadySignalFired = false;
1559 Property::Map imageMap;
1561 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1562 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1564 tet_infoline("Creating ImageView without URL so image does not start loading");
1565 ImageView imageView = ImageView::New();
1566 tet_infoline("Connect to image loaded signal before setting image");
1567 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1568 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1569 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1571 // loading started, this waits for the loader thread
1572 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1574 application.SendNotification();
1575 application.Render(16);
1577 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1582 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1584 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1586 ToolkitTestApplication application;
1588 gResourceReadySignalFired = false;
1590 Property::Map imageMap;
1592 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1593 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1595 ImageView imageView = ImageView::New();
1596 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1597 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1599 // loading started, this waits for the loader thread
1600 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1602 application.SendNotification();
1603 application.Render(16);
1605 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1606 gResourceReadySignalFired = false;
1608 ImageView imageViewWithExistingImage = ImageView::New();
1609 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1610 imageViewWithExistingImage.SetProperty(ImageView::Property::IMAGE, imageMap);
1612 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1617 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1619 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1621 ToolkitTestApplication application;
1623 gResourceReadySignalFired = false;
1625 Property::Map imageImmediateLoadingMap;
1626 imageImmediateLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1627 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1629 tet_infoline("Immediate load an image");
1630 ImageView imageView = ImageView::New();
1631 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1632 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
1634 // loading started, this waits for the loader thread
1635 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1637 application.SendNotification();
1638 application.Render(16);
1640 tet_infoline("Check image loaded");
1641 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1642 gResourceReadySignalFired = false;
1644 tet_infoline("Create another ImageView with the same URL");
1645 ImageView imageViewWithExistingImage = ImageView::New(gImage_34_RGBA);
1646 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1647 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1649 application.GetScene().Add(imageViewWithExistingImage);
1651 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1656 int UtcDaliImageViewPaddingProperty(void)
1658 ToolkitTestApplication application;
1660 ImageView imageView = ImageView::New();
1661 Property::Map imagePropertyMap;
1662 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1663 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
1664 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1665 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1666 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1667 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1668 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1669 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1670 application.GetScene().Add(imageView);
1672 application.SendNotification();
1673 application.Render();
1675 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1677 ImageView childImage = ImageView::New();
1678 childImage.SetBackgroundColor(Color::BLACK);
1679 childImage.SetProperty(Actor::Property::SIZE, Vector2(10.f, 10.f));
1680 imageView.Add(childImage);
1682 application.SendNotification();
1683 application.Render();
1685 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1686 DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
1688 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1689 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1690 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1691 Property::Map resultMap;
1692 imageVisual.CreatePropertyMap(resultMap);
1694 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1695 DALI_TEST_CHECK(transformValue);
1696 Property::Map* retMap = transformValue->GetMap();
1697 DALI_TEST_CHECK(retMap);
1699 // Image Visual should be positioned depending on ImageView's padding
1700 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1705 int UtcDaliImageViewPaddingProperty02(void)
1707 ToolkitTestApplication application;
1709 ImageView imageView = ImageView::New();
1710 Property::Map imagePropertyMap;
1711 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1712 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1713 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1714 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1715 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1716 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1717 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1718 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1719 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1720 application.GetScene().Add(imageView);
1722 application.SendNotification();
1723 application.Render();
1725 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1727 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1728 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1729 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1730 Property::Map resultMap;
1731 imageVisual.CreatePropertyMap(resultMap);
1733 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1734 DALI_TEST_CHECK(transformValue);
1735 Property::Map* retMap = transformValue->GetMap();
1736 DALI_TEST_CHECK(retMap);
1738 // Image Visual should be positioned depending on ImageView's padding
1739 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1744 int UtcDaliImageViewPaddingProperty03(void)
1746 tet_infoline("Test Setting Image Padding then removing it.");
1748 ToolkitTestApplication application;
1750 ImageView imageView = ImageView::New();
1751 Property::Map imagePropertyMap;
1752 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1753 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1754 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1755 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1756 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1757 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1758 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1759 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1760 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1761 application.GetScene().Add(imageView);
1763 application.SendNotification();
1764 application.Render();
1766 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1768 tet_infoline("Remove Padding and test Visual is position correctly");
1770 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1772 application.SendNotification();
1773 application.Render();
1775 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1776 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1777 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1778 Property::Map resultMap;
1779 imageVisual.CreatePropertyMap(resultMap);
1781 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1782 DALI_TEST_CHECK(transformValue);
1783 Property::Map* retMap = transformValue->GetMap();
1784 DALI_TEST_CHECK(retMap);
1786 // Image Visual should be positioned depending on ImageView's padding
1787 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1792 int UtcDaliImageViewPaddingProperty04(void)
1794 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1796 ToolkitTestApplication application;
1798 ImageView imageView = ImageView::New();
1799 Property::Map imagePropertyMap;
1800 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1801 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1802 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1803 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1804 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FILL;
1805 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1806 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1807 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1808 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1809 application.GetScene().Add(imageView);
1811 application.SendNotification();
1812 application.Render();
1814 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1816 tet_infoline("Remove Padding and test Visual is position correctly");
1818 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1820 application.SendNotification();
1821 application.Render();
1823 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1824 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1825 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1826 Property::Map resultMap;
1827 imageVisual.CreatePropertyMap(resultMap);
1829 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1830 DALI_TEST_CHECK(transformValue);
1831 Property::Map* retMap = transformValue->GetMap();
1832 DALI_TEST_CHECK(retMap);
1834 // Image Visual should be positioned depending on ImageView's padding
1835 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1840 int UtcDaliImageViewTransformTest01(void)
1842 tet_infoline("Test Setting a offset transform on the ImageView");
1844 ToolkitTestApplication application;
1846 ImageView imageView = ImageView::New();
1847 Property::Map imagePropertyMap;
1848 imagePropertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE)
1849 .Add(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/Kid1.svg")
1850 .Add(ImageVisual::Property::DESIRED_WIDTH, 120)
1851 .Add(ImageVisual::Property::DESIRED_HEIGHT, 120)
1852 .Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL)
1853 .Add(Visual::Property::TRANSFORM,
1854 Property::Map().Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1855 Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE))
1856 .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(8, 8)));
1858 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1859 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1860 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1861 application.GetScene().Add(imageView);
1863 application.SendNotification();
1864 application.Render();
1866 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1867 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1868 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1869 Property::Map resultMap;
1870 imageVisual.CreatePropertyMap(resultMap);
1872 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1873 DALI_TEST_CHECK(transformValue);
1874 Property::Map* retMap = transformValue->GetMap();
1875 DALI_TEST_CHECK(retMap);
1877 // Image Visual should be positioned depending on ImageView's padding
1878 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(8, 8), TEST_LOCATION);
1879 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);
1884 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1886 ToolkitTestApplication application;
1888 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1889 ImageView imageView = ImageView::New();
1890 Property::Map imageMap;
1891 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1892 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_34_RGBA;
1893 imageMap[Toolkit::ImageVisual::Property::ATLASING] = true;
1894 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1895 application.GetScene().Add(imageView);
1897 // Trigger a potential relayout
1898 application.SendNotification();
1899 application.Render();
1901 Vector3 naturalSize = imageView.GetNaturalSize();
1903 DALI_TEST_EQUALS(naturalSize.width, 34.0f, TEST_LOCATION);
1904 DALI_TEST_EQUALS(naturalSize.height, 34.0f, TEST_LOCATION);
1909 int UtcDaliImageViewFillMode(void)
1911 ToolkitTestApplication application;
1913 tet_infoline("Create an ImageVisual without padding and set the fill-mode to fill");
1915 ImageView imageView = ImageView::New();
1916 Property::Map imageMap;
1917 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1918 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB);
1919 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL);
1921 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1923 application.GetScene().Add(imageView);
1925 // Trigger a potential relayout
1926 application.SendNotification();
1927 application.Render();
1929 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1930 Property::Map returnedMap;
1931 visual.CreatePropertyMap(returnedMap);
1933 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1934 DALI_TEST_CHECK(value);
1935 Property::Map* map = value->GetMap();
1936 DALI_TEST_CHECK(map);
1938 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1939 DALI_TEST_CHECK(value);
1940 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION);
1942 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1943 DALI_TEST_CHECK(value);
1944 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1949 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1951 ToolkitTestApplication application;
1953 tet_infoline("Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )");
1954 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1956 ImageView imageView = ImageView::New();
1957 Property::Map imageMap;
1958 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1959 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1960 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
1962 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1963 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1965 application.GetScene().Add(imageView);
1967 // Trigger a potential relayout
1968 application.SendNotification();
1969 application.Render();
1971 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1972 Property::Map returnedMap;
1973 visual.CreatePropertyMap(returnedMap);
1975 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1976 DALI_TEST_CHECK(value);
1977 Property::Map* map = value->GetMap();
1978 DALI_TEST_CHECK(map);
1981 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1982 DALI_TEST_CHECK(value);
1983 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION);
1985 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1986 DALI_TEST_CHECK(value);
1987 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1989 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1990 DALI_TEST_CHECK(value);
1991 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
1996 int UtcDaliImageViewFittingModesFill(void)
1998 ToolkitTestApplication application;
2000 tet_infoline("Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )");
2001 tet_infoline(" There should be no need to change the transform, only size is changed to fit view");
2003 ImageView imageView = ImageView::New();
2004 Property::Map imageMap;
2005 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2006 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2007 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL);
2009 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2010 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2012 application.GetScene().Add(imageView);
2014 // Trigger a potential relayout
2015 application.SendNotification();
2016 application.Render();
2018 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2019 Property::Map returnedMap;
2020 visual.CreatePropertyMap(returnedMap);
2022 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2023 DALI_TEST_CHECK(value);
2024 Property::Map* map = value->GetMap();
2025 DALI_TEST_CHECK(map);
2027 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2028 DALI_TEST_CHECK(value);
2029 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Change the internal size according to the image view size
2031 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2032 DALI_TEST_CHECK(value);
2033 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2035 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2036 DALI_TEST_CHECK(value);
2037 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2042 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
2044 ToolkitTestApplication application;
2046 tet_infoline("Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )");
2047 tet_infoline(" offset or size is the same as view, but adjust internally using pixelArea ");
2049 ImageView imageView = ImageView::New();
2050 Property::Map imageMap;
2051 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2052 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2053 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO);
2055 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2056 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 500));
2058 application.GetScene().Add(imageView);
2060 // Trigger a potential relayout
2061 application.SendNotification();
2062 application.Render();
2064 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2065 Property::Map returnedMap;
2066 visual.CreatePropertyMap(returnedMap);
2068 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2069 DALI_TEST_CHECK(value);
2070 Property::Map* map = value->GetMap();
2071 DALI_TEST_CHECK(map);
2074 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2075 DALI_TEST_CHECK(value);
2076 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 500), TEST_LOCATION); // Change the internal size according to the image view size
2078 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2079 DALI_TEST_CHECK(value);
2080 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2082 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2083 DALI_TEST_CHECK(value);
2084 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2089 int UtcDaliImageViewFittingModesCenter01(void)
2091 ToolkitTestApplication application;
2093 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [700,700] )");
2094 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
2096 ImageView imageView = ImageView::New();
2097 Property::Map imageMap;
2098 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2099 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2100 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
2102 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2103 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
2105 application.GetScene().Add(imageView);
2107 // Trigger a potential relayout
2108 application.SendNotification();
2109 application.Render();
2111 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2112 Property::Map returnedMap;
2113 visual.CreatePropertyMap(returnedMap);
2115 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2116 DALI_TEST_CHECK(value);
2117 Property::Map* map = value->GetMap();
2118 DALI_TEST_CHECK(map);
2120 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2121 DALI_TEST_CHECK(value);
2122 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2124 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2125 DALI_TEST_CHECK(value);
2126 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2128 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2129 DALI_TEST_CHECK(value);
2130 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
2135 int UtcDaliImageViewFittingModesCenter02(void)
2137 ToolkitTestApplication application;
2139 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [500,500] )");
2140 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
2142 ImageView imageView = ImageView::New();
2143 Property::Map imageMap;
2144 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2145 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2146 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
2148 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2149 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
2151 application.GetScene().Add(imageView);
2153 // Trigger a potential relayout
2154 application.SendNotification();
2155 application.Render();
2157 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2158 Property::Map returnedMap;
2159 visual.CreatePropertyMap(returnedMap);
2161 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2162 DALI_TEST_CHECK(value);
2163 Property::Map* map = value->GetMap();
2164 DALI_TEST_CHECK(map);
2166 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2167 DALI_TEST_CHECK(value);
2168 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2170 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2171 DALI_TEST_CHECK(value);
2172 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2174 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2175 DALI_TEST_CHECK(value);
2176 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
2181 int UtcDaliImageViewFittingModesFitHeight01(void)
2183 ToolkitTestApplication application;
2185 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )");
2187 ImageView imageView = ImageView::New();
2188 Property::Map imageMap;
2189 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2190 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2191 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2193 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2194 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2196 application.GetScene().Add(imageView);
2198 // Trigger a potential relayout
2199 application.SendNotification();
2200 application.Render();
2202 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2203 Property::Map returnedMap;
2204 visual.CreatePropertyMap(returnedMap);
2206 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2207 DALI_TEST_CHECK(value);
2208 Property::Map* map = value->GetMap();
2209 DALI_TEST_CHECK(map);
2211 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2212 DALI_TEST_CHECK(value);
2213 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 700), TEST_LOCATION); // Change the internal size according to the image view size
2215 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2216 DALI_TEST_CHECK(value);
2217 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2219 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2220 DALI_TEST_CHECK(value);
2221 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2223 value = returnedMap.Find(DevelVisual::Property::VISUAL_FITTING_MODE);
2224 DALI_TEST_CHECK(value);
2225 DALI_TEST_EQUALS(value->Get<std::string>(), "FIT_HEIGHT", TEST_LOCATION); // OFFSET is zero
2230 int UtcDaliImageViewFittingModesFitHeight02(void)
2232 ToolkitTestApplication application;
2234 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )");
2236 ImageView imageView = ImageView::New();
2237 Property::Map imageMap;
2238 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2239 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2240 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2242 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2243 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2245 application.GetScene().Add(imageView);
2247 // Trigger a potential relayout
2248 application.SendNotification();
2249 application.Render();
2251 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2252 Property::Map returnedMap;
2253 visual.CreatePropertyMap(returnedMap);
2255 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2256 DALI_TEST_CHECK(value);
2257 Property::Map* map = value->GetMap();
2258 DALI_TEST_CHECK(map);
2260 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2261 DALI_TEST_CHECK(value);
2262 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2264 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2265 DALI_TEST_CHECK(value);
2266 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2268 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2269 DALI_TEST_CHECK(value);
2270 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2275 int UtcDaliImageViewFittingModesFitWidth01(void)
2277 ToolkitTestApplication application;
2279 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )");
2281 ImageView imageView = ImageView::New();
2282 Property::Map imageMap;
2283 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2284 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2285 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2287 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2288 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2290 application.GetScene().Add(imageView);
2292 // Trigger a potential relayout
2293 application.SendNotification();
2294 application.Render();
2296 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2297 Property::Map returnedMap;
2298 visual.CreatePropertyMap(returnedMap);
2300 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2301 DALI_TEST_CHECK(value);
2302 Property::Map* map = value->GetMap();
2303 DALI_TEST_CHECK(map);
2305 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2306 DALI_TEST_CHECK(value);
2307 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2309 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2310 DALI_TEST_CHECK(value);
2311 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2313 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2314 DALI_TEST_CHECK(value);
2315 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
2317 value = returnedMap.Find(DevelVisual::Property::VISUAL_FITTING_MODE);
2318 DALI_TEST_CHECK(value);
2319 DALI_TEST_EQUALS(value->Get<std::string>(), "FIT_WIDTH", TEST_LOCATION); // OFFSET is zero
2324 int UtcDaliImageViewFittingModesFitWidth02(void)
2326 ToolkitTestApplication application;
2328 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )");
2330 ImageView imageView = ImageView::New();
2331 Property::Map imageMap;
2332 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2333 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2334 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2336 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2337 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2339 application.GetScene().Add(imageView);
2341 // Trigger a potential relayout
2342 application.SendNotification();
2343 application.Render();
2345 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2346 Property::Map returnedMap;
2347 visual.CreatePropertyMap(returnedMap);
2349 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2350 DALI_TEST_CHECK(value);
2351 Property::Map* map = value->GetMap();
2352 DALI_TEST_CHECK(map);
2354 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2355 DALI_TEST_CHECK(value);
2356 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 600), TEST_LOCATION); // Change the internal size according to the image view size
2358 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2359 DALI_TEST_CHECK(value);
2360 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2362 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2363 DALI_TEST_CHECK(value);
2364 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2369 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2371 ToolkitTestApplication application;
2373 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2375 ImageView imageView = ImageView::New();
2377 // 1. Render using FittingMode::SHRINK_TO_FIT
2378 Property::Map imageMap;
2379 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2380 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2381 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2383 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2384 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2386 application.GetScene().Add(imageView);
2388 // Trigger a potential relayout
2389 application.SendNotification();
2390 application.Render();
2392 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2393 Property::Map returnedMap;
2394 visual.CreatePropertyMap(returnedMap);
2396 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2397 DALI_TEST_CHECK(value);
2398 Property::Map* map = value->GetMap();
2399 DALI_TEST_CHECK(map);
2401 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2402 DALI_TEST_CHECK(value);
2403 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2405 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2406 DALI_TEST_CHECK(value);
2407 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2409 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2410 DALI_TEST_CHECK(value);
2411 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2413 // 2. Render again using DevelVisaul::CENTER
2414 Property::Map imageMap2;
2415 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2416 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2417 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2419 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2420 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2422 application.GetScene().Add(imageView);
2424 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2426 // Trigger a potential relayout
2427 application.SendNotification();
2428 application.Render();
2430 returnedMap.Clear();
2431 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2433 visual.CreatePropertyMap(returnedMap);
2435 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2436 DALI_TEST_CHECK(value);
2437 map = value->GetMap();
2438 DALI_TEST_CHECK(map);
2440 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2441 DALI_TEST_CHECK(value);
2442 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2444 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2445 DALI_TEST_CHECK(value);
2446 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2448 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2449 DALI_TEST_CHECK(value);
2450 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2452 // 3. Render again using before fittingMode
2453 Property::Map imageMap3;
2454 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2455 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2456 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2458 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2459 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2461 application.GetScene().Add(imageView);
2463 // Trigger a potential relayout
2464 application.SendNotification();
2465 application.Render();
2467 returnedMap.Clear();
2468 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2469 visual.CreatePropertyMap(returnedMap);
2471 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2472 DALI_TEST_CHECK(value);
2473 map = value->GetMap();
2474 DALI_TEST_CHECK(map);
2476 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2477 DALI_TEST_CHECK(value);
2478 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2480 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2481 DALI_TEST_CHECK(value);
2482 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2484 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2485 DALI_TEST_CHECK(value);
2486 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2491 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2493 ToolkitTestApplication application;
2495 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2497 ImageView imageView = ImageView::New();
2499 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2500 Property::Map imageMap;
2501 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2502 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2503 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2505 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2506 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2508 application.GetScene().Add(imageView);
2510 // Trigger a potential relayout
2511 application.SendNotification();
2512 application.Render();
2514 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2515 Property::Map returnedMap;
2516 visual.CreatePropertyMap(returnedMap);
2518 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2519 DALI_TEST_CHECK(value);
2520 Property::Map* map = value->GetMap();
2521 DALI_TEST_CHECK(map);
2523 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2524 DALI_TEST_CHECK(value);
2525 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2527 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2528 DALI_TEST_CHECK(value);
2529 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2531 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2532 DALI_TEST_CHECK(value);
2533 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2535 // 2. Render again using DevelVisaul::CENTER
2536 Property::Map imageMap2;
2537 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2538 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2539 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2541 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2542 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2544 application.GetScene().Add(imageView);
2546 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2548 // Trigger a potential relayout
2549 application.SendNotification();
2550 application.Render();
2552 returnedMap.Clear();
2553 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2555 visual.CreatePropertyMap(returnedMap);
2557 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2558 DALI_TEST_CHECK(value);
2559 map = value->GetMap();
2560 DALI_TEST_CHECK(map);
2562 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2563 DALI_TEST_CHECK(value);
2564 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2566 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2567 DALI_TEST_CHECK(value);
2568 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2570 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2571 DALI_TEST_CHECK(value);
2572 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2574 // 3. Render again using before fittingMode
2575 Property::Map imageMap3;
2576 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2577 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2578 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2580 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2581 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2583 application.GetScene().Add(imageView);
2585 // Trigger a potential relayout
2586 application.SendNotification();
2587 application.Render();
2589 returnedMap.Clear();
2590 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2591 visual.CreatePropertyMap(returnedMap);
2593 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2594 DALI_TEST_CHECK(value);
2595 map = value->GetMap();
2596 DALI_TEST_CHECK(map);
2598 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2599 DALI_TEST_CHECK(value);
2600 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2602 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2603 DALI_TEST_CHECK(value);
2604 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2606 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2607 DALI_TEST_CHECK(value);
2608 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2613 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2615 ToolkitTestApplication application;
2617 tet_infoline("Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )");
2619 ImageView imageView = ImageView::New();
2620 Property::Map imageMap;
2621 imageMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE);
2622 imageMap.Add(Toolkit::ImageVisual::Property::URL, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME); // 249x169 image
2624 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2625 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
2627 application.GetScene().Add(imageView);
2629 // Trigger a potential relayout
2630 application.SendNotification();
2631 application.Render();
2633 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2634 Property::Map returnedMap;
2635 visual.CreatePropertyMap(returnedMap);
2637 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2638 DALI_TEST_CHECK(value);
2639 Property::Map* map = value->GetMap();
2640 DALI_TEST_CHECK(map);
2642 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2643 DALI_TEST_CHECK(value);
2644 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Relative size so will take up 100%
2646 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2647 DALI_TEST_CHECK(value);
2648 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2650 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2651 DALI_TEST_CHECK(value);
2652 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2657 int UtcDaliImageViewCustomShader(void)
2659 ToolkitTestApplication application;
2661 // Set a custom shader with an image url
2663 Property::Map properties;
2664 Property::Map shader;
2665 const std::string vertexShader = "Foobar";
2666 const std::string fragmentShader = "Foobar";
2667 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2668 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2670 properties[Visual::Property::TYPE] = Visual::IMAGE;
2671 properties[Visual::Property::SHADER] = shader;
2672 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2674 ImageView imageView = ImageView::New();
2675 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2677 application.GetScene().Add(imageView);
2679 application.SendNotification();
2680 application.Render();
2682 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2684 Renderer renderer = imageView.GetRendererAt(0);
2685 Shader shader2 = renderer.GetShader();
2686 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2687 Property::Map* map = value.GetMap();
2688 DALI_TEST_CHECK(map);
2690 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2691 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2693 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2694 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2697 // Set a custom shader after setting an image url
2699 Property::Map properties;
2700 Property::Map shader;
2701 const std::string vertexShader = "Foobar";
2702 const std::string fragmentShader = "Foobar";
2703 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2704 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2706 properties[Visual::Property::SHADER] = shader;
2708 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
2709 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2711 application.GetScene().Add(imageView);
2713 application.SendNotification();
2714 application.Render();
2716 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2718 Renderer renderer = imageView.GetRendererAt(0);
2719 Shader shader2 = renderer.GetShader();
2720 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2721 Property::Map* map = value.GetMap();
2722 DALI_TEST_CHECK(map);
2724 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2725 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2727 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2728 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2731 // Set a custom shader before setting an image url
2733 Property::Map properties;
2734 Property::Map shader;
2735 const std::string vertexShader = "Foobar";
2736 const std::string fragmentShader = "Foobar";
2737 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2738 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2740 properties[Visual::Property::SHADER] = shader;
2742 ImageView imageView = ImageView::New();
2743 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2744 imageView.SetProperty(ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME);
2746 application.GetScene().Add(imageView);
2748 application.SendNotification();
2749 application.Render();
2750 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2752 Renderer renderer = imageView.GetRendererAt(0);
2753 Shader shader2 = renderer.GetShader();
2754 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2755 Property::Map* map = value.GetMap();
2756 DALI_TEST_CHECK(map);
2758 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2759 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2761 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2762 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2765 // Set a custom shader after setting a property map
2767 Property::Map properties;
2768 Property::Map shader;
2769 const std::string vertexShader = "Foobar";
2770 const std::string fragmentShader = "Foobar";
2771 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2772 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2774 properties[Visual::Property::SHADER] = shader;
2776 Property::Map properties1;
2777 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2778 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2780 ImageView imageView = ImageView::New();
2781 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2782 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2784 application.GetScene().Add(imageView);
2786 application.SendNotification();
2787 application.Render();
2788 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2790 Renderer renderer = imageView.GetRendererAt(0);
2791 Shader shader2 = renderer.GetShader();
2792 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2793 Property::Map* map = value.GetMap();
2794 DALI_TEST_CHECK(map);
2796 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2797 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2799 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2800 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2803 // Set a custom shader before setting a property map
2805 Property::Map properties;
2806 Property::Map shader;
2807 const std::string vertexShader = "Foobar";
2808 const std::string fragmentShader = "Foobar";
2809 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2810 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2812 properties[Visual::Property::SHADER] = shader;
2814 Property::Map properties1;
2815 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2816 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2818 ImageView imageView = ImageView::New();
2819 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2820 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2822 application.GetScene().Add(imageView);
2824 application.SendNotification();
2825 application.Render();
2826 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2828 Renderer renderer = imageView.GetRendererAt(0);
2829 Shader shader2 = renderer.GetShader();
2830 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2831 Property::Map* map = value.GetMap();
2832 DALI_TEST_CHECK(map);
2834 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2835 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2837 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2838 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2846 static int gFailCounter = 0;
2847 const int MAX_RETRIES(3);
2849 void ReloadImage(ImageView imageView)
2851 Property::Map imageImmediateLoadingMap;
2852 imageImmediateLoadingMap[ImageVisual::Property::URL] = "Non-existant-image.jpg";
2853 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
2855 tet_infoline("Immediate load an image");
2856 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
2859 void ResourceFailedReload(Control control)
2865 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2867 tet_infoline("Test reloading failed image from within signal handler.");
2869 ToolkitTestApplication application;
2873 ImageView imageView = ImageView::New();
2874 imageView.ResourceReadySignal().Connect(&ResourceFailedReload);
2875 DALI_TEST_EQUALS(gFailCounter, 0, TEST_LOCATION);
2876 ReloadImage(imageView);
2878 // loading started, this waits for the loader thread to complete
2879 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2880 DALI_TEST_EQUALS(gFailCounter, 1, TEST_LOCATION);
2882 ReloadImage(imageView);
2883 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2884 DALI_TEST_EQUALS(gFailCounter, 2, TEST_LOCATION);
2886 ReloadImage(imageView);
2887 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2888 DALI_TEST_EQUALS(gFailCounter, 3, TEST_LOCATION);
2893 int UtcDaliImageViewLoadRemoteSVG(void)
2895 tet_infoline("Test load from a remote server.");
2897 ToolkitTestApplication application;
2900 Toolkit::ImageView imageView;
2901 imageView = Toolkit::ImageView::New();
2902 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2903 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2904 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2905 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2906 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2908 application.GetScene().Add(imageView);
2910 DALI_TEST_CHECK(imageView);
2912 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2914 application.SendNotification();
2916 // Wait for loading & rasterization
2917 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2919 application.SendNotification();
2920 application.Render();
2922 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2927 Toolkit::ImageView imageView;
2928 imageView = Toolkit::ImageView::New();
2929 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2930 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2931 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2932 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2934 application.GetScene().Add(imageView);
2936 DALI_TEST_CHECK(imageView);
2938 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2940 application.SendNotification();
2942 // Wait for loading & rasterization
2943 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2945 application.SendNotification();
2946 application.Render();
2948 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2954 int UtcDaliImageViewLoadRemoteLottie(void)
2956 tet_infoline("Test load from a remote server. (Note we don't support real download now. Just for line coverage)");
2958 ToolkitTestApplication application;
2961 Toolkit::ImageView imageView;
2962 imageView = Toolkit::ImageView::New();
2963 imageView.SetImage("https://lottie.json");
2964 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2965 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2966 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2967 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2969 application.GetScene().Add(imageView);
2971 DALI_TEST_CHECK(imageView);
2973 application.SendNotification();
2974 application.Render();
2976 // Do not check anything for here.
2982 int UtcDaliImageViewSyncSVGLoading(void)
2984 ToolkitTestApplication application;
2986 tet_infoline("ImageView Testing SVG image sync loading");
2989 ImageView imageView = ImageView::New();
2991 // Sync loading is used
2992 Property::Map syncLoadingMap;
2993 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2994 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2995 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2996 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2998 application.GetScene().Add(imageView);
2999 DALI_TEST_CHECK(imageView);
3001 application.SendNotification();
3002 Vector3 naturalSize = imageView.GetNaturalSize();
3004 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3005 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3010 int UtcDaliImageViewSyncSVGLoading02(void)
3012 ToolkitTestApplication application;
3014 tet_infoline("ImageView Testing SVG image sync loading");
3017 ImageView imageView = ImageView::New();
3019 // Sync loading is used
3020 Property::Map syncLoadingMap;
3021 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
3022 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
3023 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
3024 syncLoadingMap.Insert(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
3025 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
3026 imageView.ResourceReadySignal().Connect(&OnResourceReadySignalSVG);
3028 application.GetScene().Add(imageView);
3029 DALI_TEST_CHECK(imageView);
3031 application.SendNotification();
3032 application.Render();
3034 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
3035 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
3036 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
3037 Property::Map resultMap;
3038 imageVisual.CreatePropertyMap(resultMap);
3040 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
3041 DALI_TEST_CHECK(transformValue);
3042 Property::Map* retMap = transformValue->GetMap();
3043 DALI_TEST_CHECK(retMap);
3045 // Image Visual should be positioned depending on ImageView's padding
3046 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::SIZE)->Get<Vector2>(), Vector2(100, 100), TEST_LOCATION);
3048 Vector3 naturalSize = imageView.GetNaturalSize();
3049 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3050 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3055 int UtcDaliImageViewAsyncSVGLoading(void)
3057 ToolkitTestApplication application;
3059 tet_infoline("ImageView Testing SVG image async loading");
3062 ImageView imageView = ImageView::New();
3064 // Async loading is used - default value of SYNCHRONOUS_LOADING is false.
3065 Property::Map propertyMap;
3066 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
3067 propertyMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
3068 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
3070 application.GetScene().Add(imageView);
3071 DALI_TEST_CHECK(imageView);
3073 application.SendNotification();
3076 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3078 application.SendNotification();
3079 application.Render(16);
3081 Vector3 naturalSize = imageView.GetNaturalSize();
3082 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3083 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3088 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
3090 ToolkitTestApplication application;
3092 tet_infoline("ImageView Testing SVG image async loading");
3096 ImageView imageView = ImageView::New();
3098 // Sync loading is used
3099 Property::Map syncLoadingMap;
3100 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
3101 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
3103 // Check to set invalid value
3104 // The SYNCHRONOUS_LOADING property must be set to the bool value.
3105 // Check if error log is outputted when setting other value like string.
3106 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
3107 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5));
3108 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
3110 application.GetScene().Add(imageView);
3111 DALI_TEST_CHECK(imageView);
3113 application.SendNotification();
3116 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3118 application.SendNotification();
3119 application.Render(16);
3121 Vector3 naturalSize = imageView.GetNaturalSize();
3122 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3123 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3125 Property::Value value = imageView.GetProperty(ImageView::Property::IMAGE);
3126 Property::Map* map = value.GetMap();
3127 DALI_TEST_CHECK(map);
3129 Property::Value* sync = map->Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING);
3130 DALI_TEST_CHECK(sync);
3131 DALI_TEST_EQUALS(false, sync->Get<bool>(), TEST_LOCATION);
3136 int UtcDaliImageViewSvgLoadingFailureLocalFile(void)
3138 // Local svg file - invalid file path
3140 ToolkitTestApplication application;
3142 TestGlAbstraction& gl = application.GetGlAbstraction();
3143 TraceCallStack& textureTrace = gl.GetTextureTrace();
3144 textureTrace.Enable(true);
3146 gResourceReadySignalFired = false;
3148 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
3149 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3150 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3152 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3154 application.GetScene().Add(imageView);
3156 application.SendNotification();
3158 // loading started, this waits for the loader thread - load
3159 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3161 application.SendNotification();
3162 application.Render(16);
3164 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3165 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3166 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3168 // Should be shown a broken image
3169 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3170 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3173 // Local svg file - invalid file path without size set
3175 ToolkitTestApplication application;
3177 TestGlAbstraction& gl = application.GetGlAbstraction();
3178 TraceCallStack& textureTrace = gl.GetTextureTrace();
3179 textureTrace.Enable(true);
3181 gResourceReadySignalFired = false;
3182 textureTrace.Reset();
3184 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
3185 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3187 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3189 application.GetScene().Add(imageView);
3191 application.SendNotification();
3193 // loading started, this waits for the loader thread - load & rasterize
3194 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3196 application.SendNotification();
3197 application.Render(16);
3199 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3200 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3201 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3203 // Should be shown a broken image
3204 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3205 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3208 // Local svg file - invalid file
3210 ToolkitTestApplication application;
3212 TestGlAbstraction& gl = application.GetGlAbstraction();
3213 TraceCallStack& textureTrace = gl.GetTextureTrace();
3214 textureTrace.Enable(true);
3216 gResourceReadySignalFired = false;
3217 textureTrace.Reset();
3219 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.svg");
3220 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3221 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3223 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3225 application.GetScene().Add(imageView);
3227 application.SendNotification();
3229 // loading started, this waits for the loader thread - load & rasterize
3230 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3232 application.SendNotification();
3233 application.Render(16);
3235 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3236 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3237 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3239 // Should be shown a broken image
3240 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3241 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3247 int UtcDaliImageViewSvgLoadingFailureRemoteFile01(void)
3251 ToolkitTestApplication application;
3253 TestGlAbstraction& gl = application.GetGlAbstraction();
3254 TraceCallStack& textureTrace = gl.GetTextureTrace();
3255 textureTrace.Enable(true);
3257 gResourceReadySignalFired = false;
3259 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
3260 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3261 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3263 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3265 application.GetScene().Add(imageView);
3267 application.SendNotification();
3269 // loading started, this waits for the loader thread - load & rasterize
3270 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3272 application.SendNotification();
3273 application.Render(16);
3275 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3276 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3277 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3279 // Should be shown a broken image
3280 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3281 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3287 int UtcDaliImageViewSvgLoadingFailureRemoteFile02(void)
3289 // Remote svg file without size set
3291 ToolkitTestApplication application;
3293 TestGlAbstraction& gl = application.GetGlAbstraction();
3294 TraceCallStack& textureTrace = gl.GetTextureTrace();
3295 textureTrace.Enable(true);
3297 gResourceReadySignalFired = false;
3299 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
3300 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3302 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3304 application.GetScene().Add(imageView);
3306 application.SendNotification();
3308 // loading started, this waits for the loader thread - load & rasterize
3309 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3311 application.SendNotification();
3312 application.Render(16);
3314 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3315 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3316 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3318 // Should be shown a broken image
3319 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3320 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3326 int UtcDaliImageViewSvgRasterizationFailure(void)
3328 ToolkitTestApplication application;
3330 gResourceReadySignalFired = false;
3332 TestGlAbstraction& gl = application.GetGlAbstraction();
3333 TraceCallStack& textureTrace = gl.GetTextureTrace();
3334 textureTrace.Enable(true);
3336 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid1.svg");
3337 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3338 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3340 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3342 application.GetScene().Add(imageView);
3344 application.SendNotification();
3346 // Wait for loading & rasterization
3347 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3349 application.SendNotification();
3350 application.Render(16);
3352 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3353 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3354 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3356 // Should be shown a broken image
3357 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3358 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3363 int UtcDaliImageViewSvgChageSize(void)
3365 ToolkitTestApplication application;
3367 TestGlAbstraction& gl = application.GetGlAbstraction();
3368 TraceCallStack& textureTrace = gl.GetTextureTrace();
3369 textureTrace.Enable(true);
3371 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME);
3372 application.GetScene().Add(imageView);
3374 application.SendNotification();
3376 // Wait for loading & rasterization
3377 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3379 application.SendNotification();
3380 application.Render(16);
3382 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3384 // Change actor size, then rasterization should be done again
3385 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3387 application.SendNotification();
3389 // Wait for rasterization
3390 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3392 application.SendNotification();
3393 application.Render(16);
3395 // We should not load the file again.
3396 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3401 int UtcDaliImageViewSvgAtlasing(void)
3403 ToolkitTestApplication application;
3405 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
3407 callStack.Enable(true);
3409 Property::Map propertyMap;
3410 propertyMap["url"] = TEST_SVG_FILE_NAME;
3411 propertyMap["atlasing"] = true;
3413 ImageView imageView = ImageView::New();
3414 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
3415 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3416 application.GetScene().Add(imageView);
3418 application.SendNotification();
3420 // Wait for loading & rasterization
3421 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3423 application.SendNotification();
3424 application.Render(16);
3427 TraceCallStack::NamedParams params1;
3428 params1["width"] << 100;
3429 params1["height"] << 100;
3430 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params1), true, TEST_LOCATION);
3432 imageView.SetProperty(Actor::Property::SIZE, Vector2(600.f, 600.f));
3434 application.SendNotification();
3436 // Wait for rasterization
3437 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3441 application.SendNotification();
3442 application.Render(16);
3445 TraceCallStack::NamedParams params2;
3446 params2["width"] << 600;
3447 params2["height"] << 600;
3448 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexImage2D", params2), true, TEST_LOCATION);
3453 int UtcDaliImageViewTVGLoading(void)
3455 ToolkitTestApplication application;
3457 tet_infoline("ImageView Testing TVG image loading");
3460 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/test.tvg");
3461 application.GetScene().Add(imageView);
3462 DALI_TEST_CHECK(imageView);
3464 application.SendNotification();
3466 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3468 application.SendNotification();
3469 application.Render(16);
3471 Vector3 naturalSize = imageView.GetNaturalSize();
3473 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3474 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3479 int UtcDaliImageViewSvgDesiredSize01(void)
3481 ToolkitTestApplication application;
3483 TestGlAbstraction& gl = application.GetGlAbstraction();
3484 TraceCallStack& textureTrace = gl.GetTextureTrace();
3485 textureTrace.Enable(true);
3487 int desiredWidth = 100, desiredHeight = 150;
3488 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
3490 application.GetScene().Add(imageView);
3492 application.SendNotification();
3494 // Wait for loading & rasterization
3495 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3497 application.SendNotification();
3498 application.Render(16);
3501 std::stringstream out;
3502 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
3503 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
3509 int UtcDaliImageViewSvgDesiredSize02(void)
3511 ToolkitTestApplication application;
3513 TestGlAbstraction& gl = application.GetGlAbstraction();
3514 TraceCallStack& textureTrace = gl.GetTextureTrace();
3515 textureTrace.Enable(true);
3517 int desiredWidth = 150, desiredHeight = 100;
3518 ImageView imageView = ImageView::New();
3519 imageView[ImageView::Property::IMAGE] = Property::Map().Add("url", TEST_SVG_FILE_NAME).Add("desiredWidth", desiredWidth).Add("desiredHeight", desiredHeight);
3520 application.GetScene().Add(imageView);
3522 application.SendNotification();
3524 // Wait for loading & rasterization
3525 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3527 application.SendNotification();
3528 application.Render(16);
3531 std::stringstream out;
3532 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
3533 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
3539 int UtcDaliImageViewImageLoadFailure01(void)
3541 ToolkitTestApplication application;
3543 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3544 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3545 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3546 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3548 std::string brokenUrl;
3549 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3550 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3552 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3553 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3555 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3556 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3558 ImageView imageView = ImageView::New("invalidUrl.png");
3559 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3561 application.GetScene().Add(imageView);
3562 application.SendNotification();
3563 application.Render(16);
3565 // loading started, this waits for the loader thread
3566 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3571 int UtcDaliImageViewImageLoadFailure02(void)
3573 ToolkitTestApplication application;
3575 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3576 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
3577 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3578 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3580 std::string brokenUrl;
3581 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3582 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
3584 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3585 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3587 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3588 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3590 ImageView imageView = ImageView::New("invalidUrl.png");
3591 imageView.SetProperty(Actor::Property::SIZE, Vector2(30.f, 30.f));
3592 application.GetScene().Add(imageView);
3593 application.SendNotification();
3594 application.Render(16);
3596 // loading started, this waits for the loader thread
3597 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3602 int UtcDaliImageViewImageLoadFailure03(void)
3604 ToolkitTestApplication application;
3606 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3607 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
3608 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
3610 std::string brokenUrl;
3611 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3612 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3614 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3615 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3617 ImageView imageView = ImageView::New("invalidUrl.png");
3618 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3619 application.GetScene().Add(imageView);
3620 application.SendNotification();
3621 application.Render(16);
3623 // loading started, this waits for the loader thread
3624 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3629 int UtcDaliImageViewImageLoadFailure04(void)
3631 ToolkitTestApplication application;
3633 ImageView imageView = ImageView::New("invalidUrl.png");
3634 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3635 application.GetScene().Add(imageView);
3636 application.SendNotification();
3637 application.Render(16);
3639 // loading started, this waits for the loader thread
3640 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3642 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3643 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3644 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3645 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3647 ImageView imageView2 = ImageView::New("invalidUrl.png");
3648 imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3649 application.GetScene().Add(imageView2);
3651 std::string brokenUrl;
3652 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3653 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3655 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3656 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3658 application.SendNotification();
3659 application.Render(16);
3661 // loading started, this waits for the loader thread
3662 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3664 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3666 ImageView imageView3 = ImageView::New("invalidUrl.png");
3667 imageView3.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3668 application.GetScene().Add(imageView3);
3670 application.SendNotification();
3671 application.Render(16);
3673 // loading started, this waits for the loader thread
3674 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3681 static int gResourceReadySignalCounter = 0;
3683 void OnResourceReadySignal01(Control control)
3685 gResourceReadySignalCounter++;
3687 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3689 if(gResourceReadySignalCounter == 1)
3692 // It makes the first new visual be deleted immediately
3693 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3694 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3697 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3699 // Make the resource ready immediately
3700 control[ImageView::Property::IMAGE] = gImage_600_RGB;
3704 void OnResourceReadySignal02(Control control)
3706 if(++gResourceReadySignalCounter == 1)
3708 // It makes the first new visual be deleted immediately
3709 // The first image will not be loaded.
3710 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB).Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3711 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3715 ImageView gImageView1;
3716 ImageView gImageView2;
3717 ImageView gImageView3;
3718 ImageView gImageView4;
3720 void OnResourceReadySignal03(Control control)
3722 if(gResourceReadySignalCounter == 0)
3725 // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3726 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3728 // 2. Load a new image
3729 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3731 // 3. Use the new image again
3732 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3733 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3735 else if(gResourceReadySignalCounter == 1)
3737 // This is called from TextureManager::ProcessQueuedTextures().
3738 gImageView1.Unparent();
3739 gImageView1.Reset();
3741 gResourceReadySignalCounter++;
3744 void OnSimpleResourceReadySignal(Control control)
3746 // simply increate counter
3747 gResourceReadySignalCounter++;
3750 int gResourceReadySignal04ComesOrder = 0;
3752 void OnResourceReadySignal04(Control control)
3754 gResourceReadySignalCounter++;
3755 tet_printf("rc %d\n", gResourceReadySignalCounter);
3756 if(gResourceReadySignalCounter == 1)
3758 auto scene = gImageView1.GetParent();
3760 // Request load something
3761 // We hope this request result is return later than gImageView2.
3762 gImageView3 = ImageView::New(TEST_IMAGE_1);
3763 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3764 scene.Add(gImageView3);
3765 gImageView4 = ImageView::New(TEST_IMAGE_2);
3766 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3767 scene.Add(gImageView4);
3769 if(control == gImageView1)
3771 gResourceReadySignal04ComesOrder = 1;
3775 gResourceReadySignal04ComesOrder = 2;
3778 if(gResourceReadySignalCounter == 2)
3780 if(gResourceReadySignal04ComesOrder == 1 && control == gImageView2)
3782 // Scene off first one.
3783 gImageView1.Unparent();
3785 // Scene off second one.
3786 gImageView2.Unparent();
3788 else if(gResourceReadySignal04ComesOrder == 2 && control == gImageView1)
3790 // Scene off first one.
3791 gImageView2.Unparent();
3793 // Scene off second one.
3794 gImageView1.Unparent();
3798 // We can't check that this utc fail case. just pass always when we come here.
3799 gResourceReadySignal04ComesOrder = -1;
3802 // If we don't seperate index of FreeList area
3803 // and if we don't queue remove during obversing,
3804 // cache index become something invalid data.
3805 // In this case, some strange observer can be called.
3806 // For example, gImageView4.LoadComplete will be called.
3810 void OnResourceReadySignal05(Control control)
3812 gResourceReadySignalCounter++;
3814 // Request load with same image
3815 // NOTE : The url must not be same as gImageView1
3816 const int viewCount = 4;
3817 for(int i = 0; i < viewCount; ++i)
3819 gImageView1.Add(ImageView::New("invalid2.jpg"));
3823 int gResourceReadySignal06ComesOrder = 0;
3825 void OnResourceReadySignal06(Control control)
3827 gResourceReadySignalCounter++;
3828 if(gResourceReadySignalCounter == 1)
3830 auto scene = gImageView1.GetParent();
3832 // Request load something
3833 // We hope this request result is return later than gImageView2.
3836 map1[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
3837 map1[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
3839 gImageView3 = ImageView::New();
3840 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3841 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3844 map2[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
3845 map2[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_S;
3846 gImageView4 = ImageView::New();
3847 gImageView4.SetProperty(Toolkit::ImageView::Property::IMAGE, map2);
3848 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3850 if(control == gImageView1)
3852 gResourceReadySignal06ComesOrder = 1;
3856 gResourceReadySignal06ComesOrder = 2;
3859 if(gResourceReadySignalCounter == 2)
3861 if(gResourceReadySignal06ComesOrder == 1 && control == gImageView2)
3863 // Scene off first one.
3864 gImageView1.Unparent();
3866 // Scene off second one.
3867 gImageView2.Unparent();
3869 else if(gResourceReadySignal06ComesOrder == 2 && control == gImageView1)
3871 // Scene off first one.
3872 gImageView2.Unparent();
3874 // Scene off second one.
3875 gImageView1.Unparent();
3879 // We can't check that this utc fail case. just pass always when we come here.
3880 gResourceReadySignal06ComesOrder = -1;
3883 // If we don't seperate index of FreeList area
3884 // and if we don't queue remove during obversing,
3885 // cache index become something invalid data.
3886 // In this case, some strange observer can be called.
3887 // For example, gImageView4.LoadComplete will be called.
3891 void OnResourceReadySignal07(Control control)
3893 gResourceReadySignalCounter++;
3894 // Load masked image
3895 tet_printf("rc %d %d\n", gResourceReadySignalCounter, static_cast<bool>(gImageView2));
3899 auto scene = gImageView1.GetParent();
3902 map1[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
3903 map1[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
3905 gImageView2 = ImageView::New();
3906 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3907 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal07);
3909 scene.Add(gImageView2);
3913 void OnResourceReadySignal08(Control control)
3915 gResourceReadySignalCounter++;
3919 gImageView1.Unparent();
3920 gImageView1.Reset();
3924 gImageView2.Unparent();
3925 gImageView2.Reset();
3929 std::size_t gResourceReadySignal09Emitted = false;
3931 void OnResourceReadySignal09(Control control)
3933 gResourceReadySignalCounter++;
3935 if(gImageView1 && !gResourceReadySignal09Emitted)
3937 gResourceReadySignal09Emitted = true;
3938 gImageView1.ResourceReadySignal().Disconnect(&OnResourceReadySignal09);
3940 // Try to load cached invalid nine patch image. It will request load now.
3941 gImageView1.SetImage(TEST_INVALID_NPATCH_FILE_NAME_01);
3942 gImageView2.SetImage(TEST_INVALID_NPATCH_FILE_NAME_01);
3944 // Destroy all visuals immediatly.
3945 gImageView1.Unparent();
3946 gImageView1.Reset();
3947 gImageView2.Unparent();
3948 gImageView2.Reset();
3951 constexpr int gResourceReadySignal10MaxCounter = 5;
3953 void OnResourceReadySignal10(Control control)
3955 gResourceReadySignalCounter++;
3957 tet_printf("OnResourceReadySignal10 comes!\n");
3958 if(gResourceReadySignalCounter < gResourceReadySignal10MaxCounter)
3960 tet_printf("OnResourceReadySignal10 Set image\n");
3961 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, gImage_34_RGBA);
3962 tet_printf("OnResourceReadySignal10 Set image done\n");
3966 void OnResourceReadySignal11(Control control)
3968 gResourceReadySignalCounter++;
3972 auto scene = gImageView1.GetParent();
3974 // Try to load animated image visual here which is already cached, and then ignore forcely.
3977 map1[Toolkit::ImageVisual::Property::URL] = TEST_GIF_FILE_NAME;
3979 gImageView2 = ImageView::New();
3980 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3982 gImageView3 = ImageView::New();
3983 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3985 scene.Add(gImageView2);
3986 gImageView2.Unparent();
3988 scene.Add(gImageView3);
3989 gImageView3.Unparent();
3990 gImageView3.Reset(); // Destroy visual
3996 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3998 tet_infoline("Test setting image from within signal handler.");
4000 ToolkitTestApplication application;
4002 gResourceReadySignalCounter = 0;
4004 ImageView imageView = ImageView::New(gImage_34_RGBA);
4005 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal01);
4007 application.GetScene().Add(imageView);
4009 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4011 application.SendNotification();
4012 application.Render();
4014 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4016 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
4018 // Create a new ImageView to cache the image
4019 ImageView imageView1 = ImageView::New(gImage_600_RGB);
4020 application.GetScene().Add(imageView1);
4022 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4024 application.SendNotification();
4025 application.Render();
4028 gResourceReadySignalCounter = 0;
4030 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
4032 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4034 application.SendNotification();
4035 application.Render();
4037 // Run idle callback
4038 application.RunIdles();
4040 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4042 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
4047 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
4049 tet_infoline("Test setting image from within signal handler.");
4051 ToolkitTestApplication application;
4053 gResourceReadySignalCounter = 0;
4055 ImageView imageView = ImageView::New(gImage_34_RGBA);
4056 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal02);
4058 application.GetScene().Add(imageView);
4060 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4062 application.SendNotification();
4063 application.Render();
4065 // Wait for loading an image
4066 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4068 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4070 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
4075 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
4077 tet_infoline("Test setting image from within signal handler.");
4079 ToolkitTestApplication application;
4081 gResourceReadySignalCounter = 0;
4083 gImageView1 = ImageView::New(gImage_34_RGBA);
4084 application.GetScene().Add(gImageView1);
4087 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4089 gImageView2 = ImageView::New(gImage_600_RGB);
4090 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
4091 application.GetScene().Add(gImageView2);
4093 gImageView3 = ImageView::New();
4094 application.GetScene().Add(gImageView3);
4096 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4098 application.SendNotification();
4099 application.Render();
4104 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask01(void)
4106 tet_infoline("Test signal handler when image / mask image is broken.");
4108 ToolkitTestApplication application;
4110 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, const std::string& url, const std::string& mask, const char* location) {
4111 gResourceReadySignalCounter = 0;
4114 map[Toolkit::ImageVisual::Property::URL] = url;
4117 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
4119 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
4121 ImageView imageView = ImageView::New();
4122 imageView[Toolkit::ImageView::Property::IMAGE] = map;
4123 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
4124 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4126 application.GetScene().Add(imageView);
4127 application.SendNotification();
4128 application.Render();
4133 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
4135 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
4136 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
4138 imageView.Unparent();
4141 for(int synchronous = 0; synchronous <= 1; synchronous++)
4143 tet_printf("Test normal case (sync:%d)\n", synchronous);
4144 TestResourceReadyUrl(1, synchronous, gImage_600_RGB, "", TEST_LOCATION);
4145 TestResourceReadyUrl(3, synchronous, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 3 event trigger required : 2 image load + 1 apply mask
4147 tet_printf("Test broken image case (sync:%d)\n", synchronous);
4148 TestResourceReadyUrl(1, synchronous, "invalid.jpg", "", TEST_LOCATION);
4149 TestResourceReadyUrl(2, synchronous, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
4151 tet_printf("Test broken mask image case (sync:%d)\n", synchronous);
4152 TestResourceReadyUrl(2, synchronous, gImage_600_RGB, "invalid.png", TEST_LOCATION);
4154 tet_printf("Test broken both image, mask image case (sync:%d)\n", synchronous);
4155 TestResourceReadyUrl(2, synchronous, "invalid.jpg", "invalid.png", TEST_LOCATION);
4161 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask02(void)
4163 tet_infoline("Test signal handler when image try to use cached-and-broken mask image.");
4165 ToolkitTestApplication application;
4167 gResourceReadySignalCounter = 0;
4169 auto TestBrokenMaskResourceReadyUrl = [&application](const std::string& url, const char* location) {
4171 map[Toolkit::ImageVisual::Property::URL] = url;
4172 // Use invalid mask url
4173 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
4175 ImageView imageView = ImageView::New();
4176 imageView[Toolkit::ImageView::Property::IMAGE] = map;
4177 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
4178 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4180 application.GetScene().Add(imageView);
4182 // Don't unparent imageView, for keep the cache.
4185 // Use more than 4 images (The number of LocalImageLoadThread)
4186 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};
4188 int expectResourceReadySignalCounter = 0;
4190 for(auto& url : testUrlList)
4192 TestBrokenMaskResourceReadyUrl(url, TEST_LOCATION);
4193 expectResourceReadySignalCounter++;
4196 // Remain 1 signal due to we use #URL + 1 mask image.
4197 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(expectResourceReadySignalCounter + 1), true, TEST_LOCATION);
4198 application.SendNotification();
4199 application.Render();
4200 DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
4205 int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
4207 tet_infoline("Test signal handler various case.");
4209 auto TestResourceReadyUrl = [](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
4210 ToolkitTestApplication application;
4212 gResourceReadySignalCounter = 0;
4215 map[Toolkit::ImageVisual::Property::URL] = url;
4218 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
4220 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
4222 ImageView imageView = ImageView::New();
4223 imageView[Toolkit::ImageView::Property::IMAGE] = map;
4224 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
4225 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4227 application.GetScene().Add(imageView);
4228 application.SendNotification();
4229 application.Render();
4232 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
4234 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
4235 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
4236 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, location);
4238 imageView.Unparent();
4241 auto TestAuxiliaryResourceReadyUrl = [](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
4242 ToolkitTestApplication application;
4244 gResourceReadySignalCounter = 0;
4247 map[Toolkit::ImageVisual::Property::URL] = url;
4248 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE] = auxiliaryUrl;
4249 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA] = 0.5f;
4250 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
4252 ImageView imageView = ImageView::New();
4253 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4254 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4255 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4256 application.GetScene().Add(imageView);
4258 application.SendNotification();
4259 application.Render();
4264 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, location);
4267 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
4268 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
4269 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
4271 imageView.Unparent();
4274 // Case 1 : asynchronous loading
4275 tet_printf("Test invalid single simple image Asynchronous\n");
4278 TestResourceReadyUrl(1, 0, 1, gImage_600_RGB, "", TEST_LOCATION);
4279 TestResourceReadyUrl(2, 0, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // load & rasterize
4280 TestResourceReadyUrl(1, 0, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
4282 TestResourceReadyUrl(2, 0, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // 2 image loading - batch size
4283 TestResourceReadyUrl(2, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // load & rasterize
4285 TestResourceReadyUrl(3, 0, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 2 image loading + 1 applymask
4287 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
4290 TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
4291 TestResourceReadyUrl(1, 0, 0, "invalid.svg", "", TEST_LOCATION);
4292 TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
4293 TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION); // 1 image loading
4294 TestResourceReadyUrl(1, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
4296 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", "invalid.png", TEST_LOCATION); // 2 image loading
4297 TestResourceReadyUrl(2, 0, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); // 2 image loading
4298 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION); // 2 image loading
4300 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
4301 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
4302 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
4304 // Case 2 : Synchronous loading
4305 tet_printf("Test invalid single simple image Synchronous\n");
4308 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "", TEST_LOCATION);
4309 TestResourceReadyUrl(0, 1, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
4310 TestResourceReadyUrl(0, 1, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
4312 TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // first frame image loading sync + second frame image loading async
4314 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION);
4316 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
4319 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
4320 TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION);
4321 TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
4322 TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
4324 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "invalid.png", TEST_LOCATION);
4325 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION);
4326 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
4328 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
4329 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
4330 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
4335 int UtcDaliImageViewSetImageOnResourceReadySignal04(void)
4337 tet_infoline("Test texturemanager's remove queue works well within signal handler.");
4339 ToolkitTestApplication application;
4341 gResourceReadySignalCounter = 0;
4342 gResourceReadySignal04ComesOrder = 0;
4344 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
4345 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal04);
4346 application.GetScene().Add(gImageView1);
4348 gImageView2 = ImageView::New("invalid.png"); // request invalid image, to make loading failed fast.
4349 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal04);
4350 application.GetScene().Add(gImageView2);
4352 application.SendNotification();
4353 application.Render();
4355 tet_infoline("Try to load 2 invalid image");
4357 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4358 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4360 tet_infoline("load done");
4362 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
4363 if(gResourceReadySignal04ComesOrder == -1)
4365 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
4369 // gImageView3 and gImageView4 load must not be successed yet.
4370 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
4371 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
4373 application.SendNotification();
4374 application.Render();
4376 tet_infoline("Try to load 2 valid image");
4378 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4379 DALI_TEST_EQUALS(gResourceReadySignalCounter, 4, TEST_LOCATION);
4381 tet_infoline("load done");
4383 // gImageView3 and gImageView4 load must be successed now.
4384 DALI_TEST_EQUALS(gImageView3.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
4385 DALI_TEST_EQUALS(gImageView4.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
4390 int UtcDaliImageViewSetImageOnResourceReadySignal05(void)
4392 tet_infoline("Test multiple views with same image during ResourceReady load the image only 1 times");
4394 ToolkitTestApplication application;
4396 gResourceReadySignalCounter = 0;
4398 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
4399 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal05);
4400 application.GetScene().Add(gImageView1);
4402 application.SendNotification();
4403 application.Render();
4405 tet_infoline("Try to load 1 invalid.jpg image");
4406 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4407 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4409 tet_infoline("Try to load 1 invalid2.jpg image");
4410 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4412 tet_infoline("Now we don't have any image to be loaded. Check event thread trigger failed.");
4413 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
4415 gImageView1.Unparent();
4416 gImageView1.Reset();
4420 int UtcDaliImageViewSetImageOnResourceReadySignal06(void)
4422 tet_infoline("Test texturemanager's remove image & mask queue works well within signal handler.");
4424 ToolkitTestApplication application;
4426 gResourceReadySignalCounter = 0;
4427 gResourceReadySignal06ComesOrder = 0;
4430 map[Toolkit::ImageVisual::Property::URL] = "invalid.jpg";
4431 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
4433 gImageView1 = ImageView::New(); // request invalid image, to make loading failed fast.
4434 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4435 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal06);
4436 application.GetScene().Add(gImageView1);
4438 gImageView2 = ImageView::New(); // request invalid image, to make loading failed fast.
4439 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4440 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal06);
4441 application.GetScene().Add(gImageView2);
4443 application.SendNotification();
4444 application.Render();
4446 tet_infoline("Try to load 2 invalid image");
4448 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4449 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4451 tet_infoline("load done");
4453 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
4454 if(gResourceReadySignal06ComesOrder == -1)
4456 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
4460 // gImageView3 and gImageView4 load must not be successed yet.
4461 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
4462 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
4464 application.GetScene().Add(gImageView3);
4465 application.GetScene().Add(gImageView4);
4466 application.SendNotification();
4467 application.Render();
4469 tet_infoline("Try to load 2 valid image");
4471 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4472 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4474 tet_infoline("Note that resource ready should not come now.");
4475 tet_infoline("Try to load remained 2 valid image + apply masking");
4477 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
4478 DALI_TEST_EQUALS(gResourceReadySignalCounter, 4, TEST_LOCATION);
4480 tet_infoline("Check all resource ready comes now.");
4485 int UtcDaliImageViewSetImageOnResourceReadySignal07(void)
4487 tet_infoline("Test texturemanager's remove image & mask queue works well within signal handler 02.");
4489 ToolkitTestApplication application;
4491 gResourceReadySignalCounter = 0;
4494 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4496 // Clear image view for clear test
4500 gImageView1.Reset();
4504 gImageView2.Reset();
4507 gImageView1 = ImageView::New();
4508 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4509 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal07);
4510 application.GetScene().Add(gImageView1);
4512 application.SendNotification();
4513 application.Render();
4517 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4518 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4520 tet_infoline("load image1 done");
4522 // Load gImageView2 and mask
4524 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4525 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4527 // gImageView2 mask apply done
4529 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4530 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4532 tet_infoline("load image2 done");
4536 int UtcDaliImageViewSetImageOnResourceReadySignal08(void)
4538 tet_infoline("Test remove npatch images during resource ready");
4540 ToolkitTestApplication application;
4542 gResourceReadySignalCounter = 0;
4545 map[Toolkit::ImageVisual::Property::URL] = TEST_BROKEN_IMAGE_M;
4547 // Clear image view for clear test
4551 gImageView1.Reset();
4555 gImageView2.Reset();
4558 // Case 1 : Remove all images during resource ready.
4561 gImageView1 = ImageView::New();
4562 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4563 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal08);
4564 application.GetScene().Add(gImageView1);
4566 application.SendNotification();
4567 application.Render();
4570 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4571 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4573 application.SendNotification();
4574 application.Render();
4576 DALI_TEST_CHECK(true);
4580 // Exception should not happened
4581 DALI_TEST_CHECK(false);
4585 application.SendNotification();
4586 application.Render();
4588 gResourceReadySignalCounter = 0;
4590 // Case 2 : Remove all images when we use cached resource.
4593 gImageView1 = ImageView::New();
4594 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4595 gImageView1.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4596 application.GetScene().Add(gImageView1);
4598 application.SendNotification();
4599 application.Render();
4602 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4603 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4605 application.SendNotification();
4606 application.Render();
4608 gImageView2 = ImageView::New();
4609 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4610 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal08);
4611 application.GetScene().Add(gImageView2);
4612 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4614 application.SendNotification();
4615 application.Render();
4617 DALI_TEST_CHECK(true);
4621 // Exception should not happened
4622 DALI_TEST_CHECK(false);
4624 gResourceReadySignalCounter = 0;
4626 // Clear image view for clear test
4630 gImageView1.Reset();
4634 gImageView2.Reset();
4640 int UtcDaliImageViewSetImageOnResourceReadySignal09(void)
4642 tet_infoline("Test load invalid npatch images during invalid resource ready");
4644 ToolkitTestApplication application;
4646 gResourceReadySignalCounter = 0;
4649 map[Toolkit::ImageVisual::Property::URL] = TEST_INVALID_NPATCH_FILE_NAME_01;
4651 // Clear image view for clear test
4655 gImageView1.Reset();
4659 gImageView2.Reset();
4663 gImageView3.Reset();
4666 // Dummy view with npatch image
4667 ImageView dummyView = ImageView::New(TEST_BROKEN_IMAGE_M);
4668 application.GetScene().Add(dummyView);
4670 application.SendNotification();
4671 application.Render();
4672 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4673 application.SendNotification();
4674 application.Render();
4676 // Case 1 : Reload images during resource ready.
4679 gResourceReadySignal09Emitted = false;
4681 gImageView1 = ImageView::New();
4682 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4683 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal09);
4684 application.GetScene().Add(gImageView1);
4686 gImageView2 = ImageView::New();
4687 application.GetScene().Add(gImageView2);
4689 // Load TEST_INVALID_NPATCH_FILE_NAME_01
4690 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4692 // Load TEST_INVALID_NPATCH_FILE_NAME_01 one more times.
4693 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4695 application.SendNotification();
4696 application.Render();
4698 DALI_TEST_CHECK(true);
4702 // Exception should not happened
4703 DALI_TEST_CHECK(false);
4707 application.SendNotification();
4708 application.Render();
4710 gResourceReadySignalCounter = 0;
4712 // Case 2 : Remove all images when we use cached resource.
4715 gResourceReadySignal09Emitted = false;
4717 gImageView3 = ImageView::New();
4718 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4719 gImageView3.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4720 application.GetScene().Add(gImageView3);
4722 gImageView2 = ImageView::New();
4723 application.GetScene().Add(gImageView2);
4726 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4728 gImageView1 = ImageView::New();
4729 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4730 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal09);
4731 application.GetScene().Add(gImageView1);
4734 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4736 // Load TEST_INVALID_NPATCH_FILE_NAME_01 one more times.
4737 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4739 application.SendNotification();
4740 application.Render();
4742 DALI_TEST_CHECK(true);
4746 // Exception should not happened
4747 DALI_TEST_CHECK(false);
4749 gResourceReadySignalCounter = 0;
4751 // Clear image view for clear test
4755 gImageView1.Reset();
4759 gImageView2.Reset();
4763 gImageView3.Reset();
4769 int UtcDaliImageViewSetImageOnResourceReadySignal10(void)
4771 tet_infoline("Test ResourceReady signal comes more than 2 times.");
4773 ToolkitTestApplication application;
4775 gResourceReadySignalCounter = 0;
4777 // Clear image view for clear test
4781 gImageView1.Reset();
4784 // Dummy view to cache image.
4785 ImageView dummyView = ImageView::New(gImage_34_RGBA);
4786 application.GetScene().Add(dummyView);
4788 application.SendNotification();
4789 application.Render();
4790 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4791 application.SendNotification();
4792 application.Render();
4796 gImageView1 = ImageView::New();
4797 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, gImage_34_RGBA);
4798 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal10);
4799 application.GetScene().Add(gImageView1); // It will call resourceReady signal 1 time.
4801 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4803 DALI_TEST_GREATER(gResourceReadySignal10MaxCounter, gResourceReadySignalCounter, TEST_LOCATION); // Check whether resource ready call too much.
4805 for(int i = 0; i < gResourceReadySignal10MaxCounter; ++i)
4807 tet_printf("RunIdles\n");
4808 // Executes the idle callbacks.
4809 application.RunIdles();
4810 application.SendNotification();
4811 application.Render();
4812 tet_printf("RunIdles done\n");
4814 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4816 DALI_TEST_EQUALS(gResourceReadySignalCounter, gResourceReadySignal10MaxCounter, TEST_LOCATION);
4818 DALI_TEST_CHECK(true);
4822 // Exception should not happened
4823 DALI_TEST_CHECK(false);
4827 application.SendNotification();
4828 application.Render();
4830 gResourceReadySignalCounter = 0;
4832 gResourceReadySignalCounter = 0;
4834 // Clear image view for clear test
4838 gImageView1.Reset();
4844 int UtcDaliImageViewSetImageOnResourceReadySignal10WhenAddIdleFailed(void)
4846 tet_infoline("Test ResourceReady signal comes more than 2 times, but do not call again if AddIdle failed");
4848 ToolkitTestApplication application;
4850 gResourceReadySignalCounter = 0;
4852 // Clear image view for clear test
4856 gImageView1.Reset();
4859 // Dummy view to cache image.
4860 ImageView dummyView = ImageView::New(gImage_34_RGBA);
4861 application.GetScene().Add(dummyView);
4863 application.SendNotification();
4864 application.Render();
4865 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4866 application.SendNotification();
4867 application.Render();
4869 // Make AddIdle failed.
4870 ToolkitApplication::ADD_IDLE_SUCCESS = false;
4874 gImageView1 = ImageView::New();
4875 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, gImage_34_RGBA);
4876 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal10);
4877 application.GetScene().Add(gImageView1); // It will call resourceReady signal 1 time.
4879 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4881 DALI_TEST_GREATER(gResourceReadySignal10MaxCounter, gResourceReadySignalCounter, TEST_LOCATION); // Check whether resource ready call too much.
4883 for(int i = 0; i < gResourceReadySignal10MaxCounter; ++i)
4885 tet_printf("RunIdles\n");
4886 // Executes the idle callbacks.
4887 application.RunIdles();
4888 application.SendNotification();
4889 application.Render();
4890 tet_printf("RunIdles done\n");
4892 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4894 DALI_TEST_GREATER(gResourceReadySignal10MaxCounter, gResourceReadySignalCounter, TEST_LOCATION); // Check whether resource ready not called multiple times.
4896 DALI_TEST_CHECK(true);
4900 // Exception should not happened
4901 DALI_TEST_CHECK(false);
4904 ToolkitApplication::ADD_IDLE_SUCCESS = true;
4907 application.SendNotification();
4908 application.Render();
4910 gResourceReadySignalCounter = 0;
4912 gResourceReadySignalCounter = 0;
4914 // Clear image view for clear test
4918 gImageView1.Reset();
4924 int UtcDaliImageViewSetImageOnResourceReadySignal11(void)
4926 tet_infoline("Test ResourceReady Add AnimatedImageVisual and then Remove immediately.");
4928 ToolkitTestApplication application;
4930 gResourceReadySignalCounter = 0;
4932 // Clear image view for clear test
4936 gImageView1.Reset();
4940 gImageView2.Reset();
4944 gImageView3.Reset();
4949 gImageView1 = ImageView::New();
4950 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, TEST_GIF_FILE_NAME);
4951 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal11);
4952 application.GetScene().Add(gImageView1); // It will call resourceReady signal 1 time.
4954 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4956 DALI_TEST_EQUALS(gResourceReadySignalCounter, 0, TEST_LOCATION);
4958 application.SendNotification();
4959 application.Render();
4962 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4964 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4966 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4968 DALI_TEST_CHECK(true);
4972 // Exception should not happened
4973 DALI_TEST_CHECK(false);
4977 application.SendNotification();
4978 application.Render();
4980 gResourceReadySignalCounter = 0;
4982 // Clear image view for clear test
4986 gImageView1.Reset();
4990 gImageView2.Reset();
4994 gImageView3.Reset();
5000 int UtcDaliImageViewUseSameUrlWithAnimatedImageVisual(void)
5002 tet_infoline("Test multiple views with same image in animated image visual");
5003 ToolkitTestApplication application;
5005 gImageView1 = ImageView::New(TEST_WEBP_FILE_NAME);
5006 application.GetScene().Add(gImageView1);
5008 tet_infoline("Remove imageView and Create new imageView with same url");
5009 application.GetScene().Remove(gImageView1);
5010 gImageView2 = ImageView::New(TEST_WEBP_FILE_NAME);
5011 application.GetScene().Add(gImageView2);
5013 application.SendNotification();
5014 application.Render();
5016 tet_infoline("Check the ImageView load image successfully");
5017 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5021 int UtcDaliImageViewNpatchImageCacheTest01(void)
5023 tet_infoline("Test npatch image cached");
5025 ToolkitTestApplication application;
5026 ImageView imageView[2];
5028 auto& gl = application.GetGlAbstraction();
5029 gl.EnableTextureCallTrace(true);
5030 auto& textureCallStack = gl.GetTextureTrace();
5031 textureCallStack.Enable(true);
5032 textureCallStack.EnableLogging(true);
5034 auto TestNPatch = [&](int index, const std::string& nPatchImageUrl, const char* location) {
5035 if(imageView[index])
5037 imageView[index].Unparent();
5040 // Ensure remove npatch cache if required.
5041 application.SendNotification();
5042 application.Render();
5044 imageView[index] = ImageView::New(nPatchImageUrl);
5045 imageView[index].SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5046 application.GetScene().Add(imageView[index]);
5049 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
5050 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5052 application.SendNotification();
5053 application.Render();
5055 tet_printf("trace : \n%s\n", textureCallStack.GetTraceString().c_str());
5057 // Check we gen only 1 textures
5058 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 1, TEST_LOCATION);
5059 textureCallStack.Reset();
5061 // Let we use cached textures
5062 for(int i = 0; i < 10; i++)
5064 TestNPatch(1, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
5065 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
5068 application.SendNotification();
5069 application.Render();
5070 // Check we use cached npatch data so we don't generate new texture textures
5071 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 0, TEST_LOCATION);
5074 imageView[0].Unparent();
5075 imageView[0].Reset();
5076 imageView[1].Unparent();
5077 imageView[1].Reset();
5079 application.SendNotification();
5080 application.Render();
5082 textureCallStack.Reset();
5083 // Let we use deference textures
5084 TestNPatch(1, TEST_BROKEN_IMAGE_S, TEST_LOCATION);
5085 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5087 application.SendNotification();
5088 application.Render();
5089 // Try to load multiple times.
5090 for(int i = 0; i < 3; i++)
5092 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
5093 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5094 TestNPatch(1, TEST_BROKEN_IMAGE_S, TEST_LOCATION);
5095 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5097 application.SendNotification();
5098 application.Render();
5100 imageView[0].Unparent();
5101 imageView[0].Reset();
5102 imageView[1].Unparent();
5103 imageView[1].Reset();
5105 application.SendNotification();
5106 application.Render();
5108 // Check memory leak
5109 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), textureCallStack.CountMethod("DeleteTextures"), TEST_LOCATION);
5114 int UtcDaliImageViewNpatchImageCacheTest02(void)
5116 tet_infoline("Test npatch image cached with border");
5118 ToolkitTestApplication application;
5119 ImageView imageView[2];
5121 auto& gl = application.GetGlAbstraction();
5122 gl.EnableTextureCallTrace(true);
5123 auto& textureCallStack = gl.GetTextureTrace();
5124 textureCallStack.Enable(true);
5125 textureCallStack.EnableLogging(true);
5127 auto TestBorderImage = [&](int index, const std::string& normalImageUrl, const Rect<int> border, const char* location) {
5129 map[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::N_PATCH;
5130 map[Toolkit::ImageVisual::Property::URL] = normalImageUrl;
5131 map[Toolkit::ImageVisual::Property::BORDER] = border;
5133 imageView[index] = ImageView::New();
5134 imageView[index].SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5135 imageView[index].SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5136 application.GetScene().Add(imageView[index]);
5139 TestBorderImage(0, gImage_34_RGBA, Rect<int>(0, 0, 0, 0), TEST_LOCATION);
5140 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5142 application.SendNotification();
5143 application.Render();
5145 tet_printf("trace : \n%s\n", textureCallStack.GetTraceString().c_str());
5147 // Check we gen only 1 textures
5148 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 1, TEST_LOCATION);
5149 textureCallStack.Reset();
5151 // Let we use cached textures
5152 for(int i = 0; i < 10; i++)
5154 TestBorderImage(0, gImage_34_RGBA, Rect<int>(i, i + 1, i + 2, i + 3), TEST_LOCATION);
5155 TestBorderImage(1, gImage_34_RGBA, Rect<int>(i + 1, i, i + 3, i + 2), TEST_LOCATION);
5158 application.SendNotification();
5159 application.Render();
5161 // Check we use cached npatch data so we don't generate new texture textures
5162 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 0, TEST_LOCATION);
5167 int UtcDaliImageViewPlaceholderImage01(void)
5169 tet_infoline("Test imageView use placeholder image");
5171 ToolkitTestApplication application;
5173 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5175 ImageView imageView = ImageView::New();
5176 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5177 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5178 application.GetScene().Add(imageView);
5180 Property::Value value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5182 DALI_TEST_CHECK(value.Get(url));
5183 DALI_TEST_CHECK(url.empty());
5184 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5186 application.SendNotification();
5187 application.Render();
5189 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5190 DALI_TEST_CHECK(value.Get(url));
5191 DALI_TEST_CHECK(url == gImage_34_RGBA);
5193 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5194 application.SendNotification();
5195 application.Render();
5197 // Replace Image test
5198 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5199 map[ImageView::Property::PLACEHOLDER_IMAGE] = gImage_34_RGBA;
5200 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5201 application.SendNotification();
5202 application.Render();
5204 map[Toolkit::ImageVisual::Property::URL] = "";
5205 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5206 application.SendNotification();
5207 application.Render();
5209 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
5210 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5211 application.SendNotification();
5212 application.Render();
5214 // Replace Image test2
5215 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5216 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5217 application.SendNotification();
5218 application.Render();
5220 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
5221 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5222 application.SendNotification();
5223 application.Render();
5225 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5226 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5227 application.SendNotification();
5228 application.Render(900);
5230 map[Toolkit::ImageVisual::Property::URL] = "";
5231 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5232 application.SendNotification();
5233 application.Render();
5235 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5236 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5237 application.SendNotification();
5238 application.Render();
5243 int UtcDaliImageViewPlaceholderImage02(void)
5245 tet_infoline("Test imageView use placeholder image without resource ready");
5247 ToolkitTestApplication application;
5250 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5252 ImageView imageView = ImageView::New();
5253 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5254 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5255 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
5256 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
5257 application.GetScene().Add(imageView);
5259 Property::Value value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5261 DALI_TEST_CHECK(value.Get(url));
5262 DALI_TEST_CHECK(url.empty());
5264 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5265 application.SendNotification();
5266 application.Render();
5268 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5270 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5271 DALI_TEST_CHECK(value.Get(url));
5272 DALI_TEST_CHECK(url == gImage_34_RGBA);
5274 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
5275 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
5277 gResourceReadySignalFired = false;
5278 map[Toolkit::ImageVisual::Property::URL] = "";
5279 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5280 application.SendNotification();
5281 application.Render();
5283 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
5284 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
5289 int UtcDaliImageViewTransitionEffect01(void)
5291 tet_infoline("Test imageView use transition effect");
5293 ToolkitTestApplication application;
5295 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5296 map[Toolkit::Visual::Property::OPACITY] = 0.9f;
5298 ImageView imageView = ImageView::New();
5299 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5300 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5301 application.GetScene().Add(imageView);
5303 Property::Value value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5305 DALI_TEST_CHECK(value.Get(transition));
5306 DALI_TEST_CHECK(transition == false);
5307 imageView.SetProperty(Toolkit::ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
5309 application.SendNotification();
5310 application.Render();
5312 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5313 DALI_TEST_CHECK(value.Get(transition));
5314 DALI_TEST_CHECK(transition == true);
5316 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5317 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5318 application.SendNotification();
5319 application.Render();
5321 // Test transition effect with placeholder
5322 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5323 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5324 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5325 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5326 application.SendNotification();
5327 application.Render();
5329 map[Toolkit::ImageVisual::Property::URL] = "";
5330 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5331 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5332 application.SendNotification();
5333 application.Render();
5335 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5336 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5337 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5338 application.SendNotification();
5339 application.Render();
5341 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5342 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5343 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5344 application.SendNotification();
5346 map[Toolkit::ImageVisual::Property::URL] = "";
5347 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5348 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5349 application.SendNotification();
5350 application.Render();
5352 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5353 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5354 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, "");
5355 application.SendNotification();
5356 application.Render();
5358 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5359 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5360 application.SendNotification();
5361 application.Render();
5363 map[Toolkit::ImageVisual::Property::URL] = "";
5364 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5365 application.SendNotification();
5366 application.Render();
5368 // Test transition effect without placeholder
5369 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5370 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5371 application.SendNotification();
5372 application.Render();
5374 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5375 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5376 application.SendNotification();
5377 application.Render();
5379 map[Toolkit::ImageVisual::Property::URL] = "";
5380 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5381 application.SendNotification();
5382 application.Render();
5384 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5385 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5386 application.SendNotification();
5387 application.Render();
5389 imageView.SetImage(TEST_IMAGE_1);
5390 application.SendNotification();
5391 application.Render();
5393 imageView.SetImage(gImage_600_RGB);
5394 application.SendNotification();
5395 application.Render(9000);
5397 imageView.SetImage("");
5398 application.SendNotification();
5399 application.Render();
5401 imageView.SetImage(TEST_IMAGE_1);
5402 application.SendNotification();
5403 application.Render();
5406 imageView.Unparent();
5412 int UtcDaliImageViewTransitionEffect02(void)
5414 tet_infoline("Test imageView use transition effect with replace image");
5416 ToolkitTestApplication application;
5420 ImageView imageView = ImageView::New();
5421 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5422 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5423 application.GetScene().Add(imageView);
5425 Property::Value value;
5426 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5428 DALI_TEST_CHECK(value.Get(transition));
5429 DALI_TEST_CHECK(transition == false);
5430 imageView.SetProperty(Toolkit::ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
5432 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5434 DALI_TEST_CHECK(value.Get(url));
5435 DALI_TEST_CHECK(url.empty());
5436 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5437 application.SendNotification();
5438 application.Render();
5440 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, "");
5441 application.SendNotification();
5442 application.Render();
5444 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5445 application.SendNotification();
5446 application.Render();
5448 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5449 DALI_TEST_CHECK(value.Get(transition));
5450 DALI_TEST_CHECK(transition == true);
5452 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5453 DALI_TEST_CHECK(value.Get(url));
5454 DALI_TEST_CHECK(url == gImage_34_RGBA);
5456 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5457 application.SendNotification();
5458 application.Render();
5461 imageView.Unparent();
5467 int UtcDaliImageViewTransitionEffect03(void)
5469 tet_infoline("Test imageView use transition effect with placeholder");
5471 ToolkitTestApplication application;
5474 ImageView imageView = ImageView::New();
5475 imageView.SetImage("");
5476 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5477 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5478 imageView.SetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
5479 application.GetScene().Add(imageView);
5481 //DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5483 application.SendNotification();
5484 application.Render(16);
5486 tet_infoline("(1)");
5487 imageView.SetImage(gImage_600_RGB);
5488 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5489 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
5490 application.SendNotification();
5491 application.Render(16);
5493 Property::Value value;
5494 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5496 DALI_TEST_CHECK(value.Get(transition));
5497 DALI_TEST_CHECK(transition == true);
5499 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5501 DALI_TEST_CHECK(value.Get(url));
5502 DALI_TEST_CHECK(url == gImage_34_RGBA);
5504 imageView.SetImage("");
5505 application.SendNotification();
5506 application.Render(16);
5508 imageView.SetImage(TEST_IMAGE_1);
5509 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5510 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5511 application.SendNotification();
5512 application.Render(16);
5515 imageView.Unparent();
5521 int UtcDaliImageViewImageLoadFailureAndReload01(void)
5523 tet_infoline("Try to load invalid image first, and then reload after that image valid.");
5524 ToolkitTestApplication application;
5526 gResourceReadySignalFired = false;
5528 // Make overwritable image invalid first.
5531 ImageView imageView = ImageView::New(TEST_OVERWRITABLE_IMAGE_FILE_NAME);
5532 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
5533 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
5535 application.GetScene().Add(imageView);
5536 application.SendNotification();
5537 application.Render(16);
5539 // loading started, this waits for the loader thread
5540 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5542 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
5543 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
5544 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
5546 gResourceReadySignalFired = false;
5548 // Make overwritable image valid now.
5549 OverwriteImage(gImage_34_RGBA);
5552 Property::Map attributes;
5553 DevelControl::DoAction(imageView, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
5554 application.SendNotification();
5555 application.Render(16);
5557 // loading started, this waits for the loader thread
5558 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5560 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
5561 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
5562 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::READY, TEST_LOCATION);
5564 // Make overwritable image invalid end of test (for clean).
5567 gResourceReadySignalFired = false;
5572 int UtcDaliImageViewImageLoadFailureAndReload02(void)
5574 tet_infoline("Try to load invalid image first, and then reload after that image valid.");
5575 tet_infoline("This case, broken image was n-patch. So we should check whether Geometry / Shader changed after reload");
5576 ToolkitTestApplication application;
5578 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
5579 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
5580 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
5581 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
5583 gResourceReadySignalFired = false;
5585 // Make overwritable image invalid first.
5588 ImageView imageView = ImageView::New(TEST_OVERWRITABLE_IMAGE_FILE_NAME);
5589 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
5590 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
5592 application.GetScene().Add(imageView);
5593 application.SendNotification();
5594 application.Render(16);
5596 // loading started, this waits for the loader thread
5597 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5599 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
5600 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
5601 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
5603 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
5604 Geometry brokenGeometry = imageView.GetRendererAt(0u).GetGeometry();
5605 Shader brokenShader = imageView.GetRendererAt(0u).GetShader();
5606 DALI_TEST_CHECK(brokenGeometry);
5607 DALI_TEST_CHECK(brokenShader);
5609 gResourceReadySignalFired = false;
5611 // Make overwritable image valid now.
5612 OverwriteImage(gImage_34_RGBA);
5615 Property::Map attributes;
5616 DevelControl::DoAction(imageView, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
5617 application.SendNotification();
5618 application.Render(16);
5620 // loading started, this waits for the loader thread
5621 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5623 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
5624 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
5625 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::READY, TEST_LOCATION);
5627 // Check whether we don't use n-patch shader and geometry in this case.
5628 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
5629 DALI_TEST_CHECK(brokenGeometry != imageView.GetRendererAt(0u).GetGeometry());
5630 DALI_TEST_CHECK(brokenShader != imageView.GetRendererAt(0u).GetShader());
5632 // Make overwritable image invalid end of test (for clean).
5635 gResourceReadySignalFired = false;