2 * Copyright (c) 2023 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 void TestUrl(ImageView imageView, const std::string url)
90 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
92 std::string urlActual;
93 DALI_TEST_CHECK(value.Get(urlActual));
94 DALI_TEST_EQUALS(urlActual, url, TEST_LOCATION);
99 int UtcDaliImageViewNewP(void)
101 ToolkitTestApplication application;
103 ImageView imageView = ImageView::New();
105 DALI_TEST_CHECK(imageView);
110 int UtcDaliImageViewNewUrlP(void)
112 ToolkitTestApplication application;
114 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
115 DALI_TEST_CHECK(imageView);
117 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
122 int UtcDaliImageViewConstructorP(void)
124 ToolkitTestApplication application;
128 DALI_TEST_CHECK(!imageView);
133 int UtcDaliImageViewCopyConstructorP(void)
135 ToolkitTestApplication application;
137 // Initialize an object, ref count == 1
138 ImageView imageView = ImageView::New();
140 ImageView copy(imageView);
141 DALI_TEST_CHECK(copy);
146 int UtcDaliImageViewMoveConstructor(void)
148 ToolkitTestApplication application;
150 ImageView imageView = ImageView::New();
151 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
152 imageView.SetProperty(Actor::Property::SENSITIVE, false);
153 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
155 ImageView moved = std::move(imageView);
156 DALI_TEST_CHECK(moved);
157 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
158 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
159 DALI_TEST_CHECK(!imageView);
164 int UtcDaliImageViewAssignmentOperatorP(void)
166 ToolkitTestApplication application;
168 ImageView imageView = ImageView::New();
170 ImageView copy(imageView);
171 DALI_TEST_CHECK(copy);
172 DALI_TEST_EQUALS(imageView, copy, TEST_LOCATION);
177 int UtcDaliImageViewMoveAssignment(void)
179 ToolkitTestApplication application;
181 ImageView imageView = ImageView::New();
182 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
183 imageView.SetProperty(Actor::Property::SENSITIVE, false);
184 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
187 moved = std::move(imageView);
188 DALI_TEST_CHECK(moved);
189 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
190 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
191 DALI_TEST_CHECK(!imageView);
196 int UtcDaliImageViewDownCastP(void)
198 ToolkitTestApplication application;
200 ImageView imageView = ImageView::New();
202 BaseHandle object(imageView);
204 ImageView imageView2 = ImageView::DownCast(object);
205 DALI_TEST_CHECK(imageView2);
207 ImageView imageView3 = DownCast<ImageView>(object);
208 DALI_TEST_CHECK(imageView3);
213 int UtcDaliImageViewDownCastN(void)
215 ToolkitTestApplication application;
217 BaseHandle unInitializedObject;
219 ImageView imageView1 = ImageView::DownCast(unInitializedObject);
220 DALI_TEST_CHECK(!imageView1);
222 ImageView imageView2 = DownCast<ImageView>(unInitializedObject);
223 DALI_TEST_CHECK(!imageView2);
228 int UtcDaliImageViewTypeRegistry(void)
230 ToolkitTestApplication application;
232 TypeRegistry typeRegistry = TypeRegistry::Get();
233 DALI_TEST_CHECK(typeRegistry);
235 TypeInfo typeInfo = typeRegistry.GetTypeInfo("ImageView");
236 DALI_TEST_CHECK(typeInfo);
238 BaseHandle handle = typeInfo.CreateInstance();
239 DALI_TEST_CHECK(handle);
241 ImageView imageView = ImageView::DownCast(handle);
242 DALI_TEST_CHECK(imageView);
247 int UtcDaliImageViewSetGetProperty01(void)
249 ToolkitTestApplication application;
251 ImageView imageView = ImageView::New();
253 Property::Index idx = imageView.GetPropertyIndex("image");
254 DALI_TEST_EQUALS(idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION);
256 imageView.SetProperty(idx, TEST_IMAGE_FILE_NAME);
257 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
262 int UtcDaliImageViewPreMultipliedAlphaPng(void)
264 ToolkitTestApplication application;
266 // Set up trace debug
267 TestGlAbstraction& gl = application.GetGlAbstraction();
268 TraceCallStack& textureTrace = gl.GetTextureTrace();
269 textureTrace.Enable(true);
271 Property::Map imageMap;
272 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
273 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
275 ImageView imageView1 = ImageView::New();
276 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
278 application.GetScene().Add(imageView1);
280 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
282 DALI_TEST_CHECK(value.Get(enable));
283 DALI_TEST_CHECK(enable); // Default value is true
285 // loading started, this waits for the loader thread for max 30 seconds
286 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
288 application.SendNotification();
289 application.Render();
291 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
292 DALI_TEST_CHECK(value.Get(enable));
293 DALI_TEST_CHECK(enable); // Keep true
295 // conventional alpha blending
296 Renderer renderer1 = imageView1.GetRendererAt(0);
297 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
298 DALI_TEST_CHECK(value.Get(enable));
299 DALI_TEST_CHECK(enable);
301 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
302 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
303 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
304 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
305 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
306 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
307 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
308 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
310 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
311 textureTrace.Reset();
313 // Disable pre-multiplied alpha blending
314 imageView1.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
317 Property::Map attributes;
318 DevelControl::DoAction(imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
320 // loading started, this waits for the loader thread for max 30 seconds
321 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
323 application.SendNotification();
324 application.Render();
326 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
327 DALI_TEST_CHECK(value.Get(enable));
328 DALI_TEST_CHECK(!enable);
330 // conventional alpha blending
331 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
332 DALI_TEST_CHECK(value.Get(enable));
333 DALI_TEST_CHECK(!enable);
335 srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
336 destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
337 srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
338 destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
339 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
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 // Make a new ImageView using the same image
348 ImageView imageView2 = ImageView::New();
349 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
351 application.GetScene().Add(imageView2);
353 application.SendNotification();
354 application.Render();
356 Renderer renderer2 = imageView2.GetRendererAt(0);
357 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
358 DALI_TEST_CHECK(value.Get(enable));
359 DALI_TEST_CHECK(enable);
361 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
362 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
363 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
364 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
365 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
366 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
367 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
368 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
370 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
375 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
377 ToolkitTestApplication application;
379 // Set up trace debug
380 TestGlAbstraction& gl = application.GetGlAbstraction();
381 TraceCallStack& textureTrace = gl.GetTextureTrace();
382 textureTrace.Enable(true);
384 Property::Map imageMap;
385 imageMap[ImageVisual::Property::URL] = gImage_600_RGB;
386 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
388 ImageView imageView1 = ImageView::New();
389 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
391 application.GetScene().Add(imageView1);
393 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
395 DALI_TEST_CHECK(value.Get(enable));
396 DALI_TEST_CHECK(enable); // Default value is true
398 // loading started, this waits for the loader thread for max 30 seconds
399 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
401 application.SendNotification();
402 application.Render();
404 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
405 DALI_TEST_CHECK(value.Get(enable));
406 DALI_TEST_CHECK(!enable); // Should be false after loading
408 // conventional alpha blending
409 Renderer renderer1 = imageView1.GetRendererAt(0);
410 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
411 DALI_TEST_CHECK(value.Get(enable));
412 DALI_TEST_CHECK(!enable);
414 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
415 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
416 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
417 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
418 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
419 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
420 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
421 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
423 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
424 textureTrace.Reset();
426 ImageView imageView2 = ImageView::New();
427 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
429 // Disable pre-multiplied alpha blending
430 imageView2.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
432 application.GetScene().Add(imageView2);
434 application.SendNotification();
435 application.Render();
437 value = imageView2.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
438 DALI_TEST_CHECK(value.Get(enable));
439 DALI_TEST_CHECK(!enable);
441 // conventional alpha blending
442 Renderer renderer2 = imageView2.GetRendererAt(0);
443 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
444 DALI_TEST_CHECK(value.Get(enable));
445 DALI_TEST_CHECK(!enable);
447 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
448 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
449 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
450 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
451 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
452 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
453 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
454 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
456 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
461 int UtcDaliImageViewPixelArea(void)
463 // Test pixel area property
464 ToolkitTestApplication application;
466 static std::vector<UniformData> customUniforms =
468 UniformData("pixelArea", Property::Type::VECTOR4),
471 TestGraphicsController& graphics = application.GetGraphicsController();
472 graphics.AddCustomUniforms(customUniforms);
474 // Gif image, use AnimatedImageVisual internally
475 // Atlasing is applied to pack multiple frames, use custom wrap mode
476 ImageView gifView = ImageView::New();
477 const Vector4 pixelAreaVisual(0.f, 0.f, 2.f, 2.f);
478 gifView.SetProperty(ImageView::Property::IMAGE,
479 Property::Map().Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME).Add(ImageVisual::Property::PIXEL_AREA, pixelAreaVisual));
482 Integration::Scene stage = application.GetScene();
486 application.SendNotification();
487 application.Render(16);
489 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
491 application.SendNotification();
492 application.Render();
493 DALI_TEST_CHECK(gifView.GetRendererCount() == 1u);
495 const Vector4 fullTextureRect(0.f, 0.f, 1.f, 1.f);
496 // test that the pixel area value defined in the visual property map is registered on renderer
497 Renderer renderer = gifView.GetRendererAt(0);
498 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
499 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION);
501 // test that the shader has the default pixel area value registered.
502 Shader shader = renderer.GetShader();
503 pixelAreaValue = shader.GetProperty(shader.GetPropertyIndex("pixelArea"));
504 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION);
506 // test that the uniform uses the pixelArea property on the renderer.
507 TestGlAbstraction& gl = application.GetGlAbstraction();
508 Vector4 pixelAreaUniform;
509 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
510 DALI_TEST_EQUALS(pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
512 // set the pixelArea property on the control
513 const Vector4 pixelAreaControl(-1.f, -1.f, 3.f, 3.f);
514 gifView.SetProperty(ImageView::Property::PIXEL_AREA, pixelAreaControl);
515 application.SendNotification();
516 application.Render(16);
518 // check the pixelArea property on the control
519 pixelAreaValue = gifView.GetProperty(gifView.GetPropertyIndex("pixelArea"));
520 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION);
521 // test that the uniform uses the pixelArea property on the control.
522 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
523 DALI_TEST_EQUALS(pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
528 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
530 ToolkitTestApplication application;
531 TestGlAbstraction& gl = application.GetGlAbstraction();
532 const std::vector<GLuint>& textures = gl.GetBoundTextures();
533 size_t numTextures = textures.size();
535 // Async loading, no atlasing for big size image
536 ImageView imageView = ImageView::New(gImage_600_RGB);
538 // By default, Aysnc loading is used
539 application.GetScene().Add(imageView);
540 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
541 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
543 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
545 application.SendNotification();
546 application.Render(16);
547 application.SendNotification();
549 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
550 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
555 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
557 ToolkitTestApplication application;
559 //Async loading, automatic atlasing for small size image
560 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
562 callStack.Enable(true);
564 Property::Map imageMap;
566 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
567 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
568 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
569 imageMap[ImageVisual::Property::ATLASING] = true;
571 ImageView imageView = ImageView::New();
572 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
573 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
575 // By default, Aysnc loading is used
576 // loading is not started if the actor is offScene
578 application.GetScene().Add(imageView);
579 application.SendNotification();
580 application.Render(16);
581 application.Render(16);
582 application.SendNotification();
584 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
585 application.SendNotification();
586 application.Render(16);
587 application.Render(16);
588 application.SendNotification();
590 // loading started, this waits for the loader thread for max 30 seconds
591 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
593 application.SendNotification();
594 application.Render(16);
596 callStack.Enable(false);
598 TraceCallStack::NamedParams params;
599 params["width"] << 34;
600 params["height"] << 34;
601 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
606 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
608 ToolkitTestApplication application;
610 //Async loading, automatic atlasing for small size image
611 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
613 callStack.Enable(true);
615 Property::Map asyncLoadingMap;
616 asyncLoadingMap["url"] = gImage_34_RGBA;
617 asyncLoadingMap["desiredHeight"] = 34;
618 asyncLoadingMap["desiredWidth"] = 34;
619 asyncLoadingMap["synchronousLoading"] = false;
620 asyncLoadingMap["atlasing"] = true;
622 ImageView imageView = ImageView::New();
623 imageView.SetProperty(ImageView::Property::IMAGE, asyncLoadingMap);
625 application.GetScene().Add(imageView);
626 application.SendNotification();
627 application.Render(16);
628 application.Render(16);
629 application.SendNotification();
631 // loading started, this waits for the loader thread for max 30 seconds
632 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
634 application.SendNotification();
635 application.Render(16);
637 callStack.Enable(false);
639 TraceCallStack::NamedParams params;
640 params["width"] << 34;
641 params["height"] << 34;
642 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
647 int UtcDaliImageViewSyncLoading(void)
649 ToolkitTestApplication application;
651 tet_infoline("ImageView Testing sync loading and size using index key property map");
653 Property::Map syncLoadingMap;
654 syncLoadingMap[ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
655 syncLoadingMap[ImageVisual::Property::ATLASING] = true;
657 // Sync loading, no atlasing for big size image
659 ImageView imageView = ImageView::New();
661 // Sync loading is used
662 syncLoadingMap[ImageVisual::Property::URL] = gImage_600_RGB;
663 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
666 // Sync loading, automatic atlasing for small size image
668 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
670 callStack.Enable(true);
672 ImageView imageView = ImageView::New();
674 // Sync loading is used
675 syncLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
676 syncLoadingMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
677 syncLoadingMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
678 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
680 application.GetScene().Add(imageView);
681 application.SendNotification();
682 application.Render(16);
684 TraceCallStack::NamedParams params;
685 params["width"] << 34;
686 params["height"] << 34;
687 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
694 int UtcDaliImageViewSyncLoading02(void)
696 ToolkitTestApplication application;
698 tet_infoline("ImageView Testing sync loading and size using string key property map");
700 // Sync loading, automatic atlasing for small size image
702 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
704 callStack.Enable(true);
706 ImageView imageView = ImageView::New();
708 // Sync loading is used
709 Property::Map syncLoadingMap;
710 syncLoadingMap["url"] = gImage_34_RGBA;
711 syncLoadingMap["desiredHeight"] = 34;
712 syncLoadingMap["desiredWidth"] = 34;
713 syncLoadingMap["synchronousLoading"] = true;
714 syncLoadingMap["atlasing"] = true;
715 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
717 application.GetScene().Add(imageView);
718 application.SendNotification();
719 application.Render(16);
721 TraceCallStack::NamedParams params;
722 params["width"] << 34;
723 params["height"] << 34;
724 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
731 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
733 ToolkitTestApplication application;
734 TestGlAbstraction& gl = application.GetGlAbstraction();
735 const std::vector<GLuint>& textures = gl.GetBoundTextures();
736 size_t numTextures = textures.size();
738 // Get encoded raw-buffer image and generate url
739 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
740 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
742 // Async loading, no atlasing for big size image
743 ImageView imageView = ImageView::New(url.GetUrl());
745 // By default, Aysnc loading is used
746 application.GetScene().Add(imageView);
747 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
748 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
750 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
752 application.SendNotification();
753 application.Render(16);
754 application.SendNotification();
756 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
757 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
762 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
764 ToolkitTestApplication application;
766 // Get encoded raw-buffer image and generate url
767 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
768 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
769 ImageUrl url2 = Toolkit::Image::GenerateUrl(buffer);
771 // Generate url is not equal to url2
772 // NOTE : This behavior may changed when ImageUrl compare operator changed.
773 DALI_TEST_CHECK(url != url2);
774 // Generate url's string is equal to url2's string
775 DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
777 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
778 url2 = Toolkit::Image::GenerateUrl(buffer2);
780 // Check whethere two url are not equal
781 DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
783 // Async loading, automatic atlasing for small size image
784 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
786 callStack.Enable(true);
788 Property::Map imageMap;
790 imageMap[ImageVisual::Property::URL] = url.GetUrl();
791 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 600;
792 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 600;
793 imageMap[ImageVisual::Property::ATLASING] = true;
795 // No atlasing with big image
796 ImageView imageView_bigdesired = ImageView::New();
797 imageView_bigdesired.SetProperty(ImageView::Property::IMAGE, imageMap);
798 imageView_bigdesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
800 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 0;
801 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 0;
803 // No atlasing with zero desired size
804 ImageView imageView_nodesired = ImageView::New();
805 imageView_nodesired.SetProperty(ImageView::Property::IMAGE, imageMap);
806 imageView_nodesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
808 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
809 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
811 ImageView imageView = ImageView::New();
812 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
813 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
815 // By default, Aysnc loading is used
816 // loading is not started if the actor is offScene
817 application.GetScene().Add(imageView);
818 application.GetScene().Add(imageView_bigdesired);
819 application.GetScene().Add(imageView_nodesired);
820 application.SendNotification();
821 application.Render(16);
823 // loading started, this waits for the loader thread for max 30 seconds
824 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
826 application.Render(16);
827 application.SendNotification();
829 // Change url to url2
830 imageMap[ImageVisual::Property::URL] = url2.GetUrl();
831 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
833 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
834 application.SendNotification();
835 application.Render(16);
836 application.Render(16);
837 application.SendNotification();
839 // loading started, this waits for the loader thread for max 30 seconds
840 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
842 application.SendNotification();
843 application.Render(16);
845 callStack.Enable(false);
847 TraceCallStack::NamedParams params;
848 params["width"] << 34;
849 params["height"] << 34;
850 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
855 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
857 ToolkitTestApplication application;
859 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
861 // Get encoded raw-buffer image and generate url
862 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
863 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
865 // Sync loading, automatic atlasing for small size image
867 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
869 callStack.Enable(true);
871 ImageView imageView = ImageView::New();
873 // Sync loading is used
874 Property::Map syncLoadingMap;
875 syncLoadingMap["url"] = url.GetUrl();
876 syncLoadingMap["alphaMaskUrl"] = gImage_34_RGBA;
877 syncLoadingMap["desiredHeight"] = 34;
878 syncLoadingMap["desiredWidth"] = 34;
879 syncLoadingMap["synchronousLoading"] = true;
880 syncLoadingMap["atlasing"] = true;
881 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
883 application.GetScene().Add(imageView);
884 application.SendNotification();
885 application.Render(16);
887 TraceCallStack::NamedParams params;
888 params["width"] << 34;
889 params["height"] << 34;
890 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
898 int UtcDaliImageViewAddedTexture(void)
900 ToolkitTestApplication application;
902 tet_infoline("ImageView Testing image view with texture provided manager url");
904 ImageView imageView = ImageView::New();
906 // empty texture is ok, though pointless from app point of view
908 std::string url = TextureManager::AddTexture(empty);
909 DALI_TEST_CHECK(url.size() > 0u);
911 Property::Map propertyMap;
912 propertyMap[ImageVisual::Property::URL] = url;
913 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
915 application.GetScene().Add(imageView);
916 application.SendNotification();
917 application.Render();
922 int UtcDaliImageViewSizeWithBackground(void)
924 ToolkitTestApplication application;
928 ImageView imageView = ImageView::New();
930 imageView.SetProperty(Control::Property::BACKGROUND,
932 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
933 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
934 {ImageVisual::Property::DESIRED_WIDTH, width},
935 {ImageVisual::Property::DESIRED_HEIGHT, height},
938 application.GetScene().Add(imageView);
939 application.SendNotification();
940 application.Render();
942 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
943 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
948 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
950 ToolkitTestApplication application;
952 int widthBackground = 100;
953 int heightBackground = 200;
957 ImageView imageView = ImageView::New();
959 imageView.SetProperty(Control::Property::BACKGROUND,
961 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
962 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
963 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
964 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground},
967 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio, 600x600 pixels
969 application.GetScene().Add(imageView);
970 application.SendNotification();
971 application.Render();
973 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
974 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
979 int UtcDaliImageViewHeightForWidthBackground(void)
981 ToolkitTestApplication application;
983 int widthBackground = 100;
984 int heightBackground = 200;
986 ImageView imageView = ImageView::New();
988 imageView.SetProperty(Control::Property::BACKGROUND,
989 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
990 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
991 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
992 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}});
994 application.GetScene().Add(imageView);
995 application.SendNotification();
996 application.Render();
998 Control control = Control::DownCast(imageView);
999 DALI_TEST_CHECK(control);
1000 DALI_TEST_EQUALS(imageView.GetHeightForWidth(123.f), control.GetHeightForWidth(123.f), TEST_LOCATION);
1001 DALI_TEST_EQUALS(imageView.GetWidthForHeight(321.f), control.GetWidthForHeight(321.f), TEST_LOCATION);
1006 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
1008 ToolkitTestApplication application;
1010 int widthBackground = 100;
1011 int heightBackground = 200;
1015 ImageView imageView = ImageView::New();
1017 imageView.SetProperty(Control::Property::BACKGROUND,
1018 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1019 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1020 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1021 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}}); // 1 to 2 ratio
1023 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio
1025 application.GetScene().Add(imageView);
1026 application.SendNotification();
1027 application.Render();
1029 DALI_TEST_EQUALS(imageView.GetHeightForWidth(width), (float)height, TEST_LOCATION);
1030 DALI_TEST_EQUALS(imageView.GetWidthForHeight(height), (float)width, TEST_LOCATION);
1035 int UtcDaliImageViewSetImageUrl(void)
1037 ToolkitTestApplication application;
1039 ImageView imageView = ImageView::New();
1040 imageView.SetImage(TEST_IMAGE_FILE_NAME);
1041 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
1043 imageView.SetImage(TEST_IMAGE_FILE_NAME2);
1044 TestUrl(imageView, TEST_IMAGE_FILE_NAME2);
1049 bool gResourceReadySignalFired = false;
1050 Vector3 gNaturalSize;
1052 void ResourceReadySignal(Control control)
1054 gResourceReadySignalFired = true;
1057 void OnResourceReadySignalSVG(Control control)
1059 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1060 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(control);
1061 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1062 Property::Map resultMap;
1063 imageVisual.CreatePropertyMap(resultMap);
1065 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1066 DALI_TEST_CHECK(transformValue);
1067 Property::Map* retMap = transformValue->GetMap();
1068 DALI_TEST_CHECK(retMap);
1070 // Fitting mode should not be applied at this point
1071 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::SIZE)->Get<Vector2>(), Vector2::ZERO, TEST_LOCATION);
1074 int UtcDaliImageViewCheckResourceReady(void)
1076 ToolkitTestApplication application;
1078 gResourceReadySignalFired = false;
1080 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1081 ImageView imageView = ImageView::New(TEST_GIF_FILE_NAME);
1083 imageView.SetProperty(Control::Property::BACKGROUND,
1084 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1085 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1086 {ImageVisual::Property::DESIRED_WIDTH, 100},
1087 {ImageVisual::Property::DESIRED_HEIGHT, 200}});
1089 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1091 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1093 application.GetScene().Add(imageView);
1095 // loading started, this waits for the loader thread
1096 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1098 application.SendNotification();
1099 application.Render(16);
1101 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1103 application.SendNotification();
1104 application.Render();
1106 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1108 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1113 int UtcDaliImageViewSetImageTypeChangesP(void)
1115 ToolkitTestApplication application;
1117 ImageView imageView = ImageView::New();
1118 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1120 application.GetScene().Add(imageView);
1124 Toolkit::Visual::Base visual;
1126 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1127 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1129 application.SendNotification();
1130 application.Render(16);
1132 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1134 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1135 DALI_TEST_CHECK(!visual); // Visual should be invalid
1138 imageView.SetImage("TEST_URL");
1140 application.SendNotification();
1141 application.Render(16);
1143 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1144 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1146 DALI_TEST_CHECK(value.Get(url)); // Value should NOT be empty
1147 DALI_TEST_CHECK(!value.Get(map)); // Value should be empty
1148 DALI_TEST_CHECK(visual); // Visual should be valid
1151 imageView.SetImage("");
1153 application.SendNotification();
1154 application.Render(16);
1156 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1157 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1159 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1161 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1162 DALI_TEST_CHECK(!visual); // Visual should be invalid
1164 // Set a URL in property map
1165 Property::Map propertyMap;
1166 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1167 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1169 application.SendNotification();
1170 application.Render(16);
1172 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1173 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1175 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1176 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1177 DALI_TEST_CHECK(visual); // Visual should be valid
1179 // Set a URL in property map again
1180 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1181 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1183 application.SendNotification();
1184 application.Render(16);
1186 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1187 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1189 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1190 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1191 DALI_TEST_CHECK(visual); // Visual should be valid
1193 // Set an empty URL in property map
1194 propertyMap[ImageVisual::Property::URL] = std::string();
1195 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1197 application.SendNotification();
1198 application.Render(16);
1200 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1201 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1203 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1204 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1205 DALI_TEST_CHECK(!visual); // Visual should be invalid
1207 // Set a URL in property map again
1208 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1209 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1211 application.SendNotification();
1212 application.Render(16);
1214 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1215 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1217 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1218 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1219 DALI_TEST_CHECK(visual); // Visual should be valid
1221 // Set an empty property map
1222 propertyMap.Clear();
1223 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1225 application.SendNotification();
1226 application.Render(16);
1228 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1229 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1231 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1232 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1233 DALI_TEST_CHECK(map.Empty()); // But PropertyMap should be empty
1234 DALI_TEST_CHECK(!visual); // Visual should be invalid
1239 int UtcDaliImageViewResourceUrlP(void)
1241 ToolkitTestApplication application;
1243 ImageView imageView = ImageView::New();
1244 DALI_TEST_CHECK(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>().empty());
1246 imageView.SetProperty(ImageView::Property::IMAGE, "TestString");
1247 DALI_TEST_EQUALS(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>(), "TestString", TEST_LOCATION);
1252 int UtcDaliImageViewReplaceImage(void)
1254 ToolkitTestApplication application;
1256 gResourceReadySignalFired = false;
1258 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1259 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1261 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1263 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1265 application.GetScene().Add(imageView);
1267 application.SendNotification();
1268 application.Render(16);
1270 // loading started, this waits for the loader thread for max 30 seconds
1271 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1273 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1275 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1277 gResourceReadySignalFired = false;
1279 imageView.SetImage(TEST_IMAGE_2);
1281 application.SendNotification();
1282 application.Render(16);
1284 // loading started, this waits for the loader thread for max 30 seconds
1285 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1287 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1289 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1291 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1296 int UtcDaliImageViewReloadAlphaMaskImage(void)
1298 ToolkitTestApplication application;
1300 gResourceReadySignalFired = false;
1302 ImageView dummy = ImageView::New();
1303 ImageView imageView = ImageView::New();
1304 Property::Map propertyMap;
1306 // To keep alpha mask cached, scene on some dummy image.
1307 // Note : If we don't cache alpha mask image, the reference count of mask image become zero.
1308 // In this case, we might need to wait mask image loading, which is not neccesary & can be changed behavior.
1309 propertyMap[ImageVisual::Property::URL] = gImage_600_RGB;
1310 propertyMap[ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
1311 dummy.SetProperty(ImageView::Property::IMAGE, propertyMap);
1313 application.GetScene().Add(dummy);
1315 application.SendNotification();
1316 application.Render(16);
1318 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1320 application.SendNotification();
1321 application.Render(16);
1323 propertyMap.Clear();
1324 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1325 propertyMap[ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
1326 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1328 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1330 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1332 application.GetScene().Add(imageView);
1334 application.SendNotification();
1335 application.Render(16);
1337 // Load image and use cached mask. Now we try to apply masking.
1338 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1340 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
1342 // Cancel apply masking.
1343 imageView.Unparent();
1345 application.SendNotification();
1346 application.Render(16);
1348 // Reload same image again.
1349 application.GetScene().Add(imageView);
1351 application.SendNotification();
1352 application.Render(16);
1354 // Finish apply masking.
1355 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1357 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1358 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1359 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1364 void OnRelayoutOverride(Size size)
1366 gNaturalSize = size; // Size Relayout is using
1369 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1371 ToolkitTestApplication application;
1373 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1374 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1375 imageView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1377 DummyControl dummyControl = DummyControl::New(true);
1378 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1379 dummyControl.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
1381 dummyControl.Add(imageView);
1382 dummyImpl.SetRelayoutCallback(&OnRelayoutOverride);
1383 application.GetScene().Add(dummyControl);
1385 application.SendNotification();
1386 application.Render();
1388 // loading started, this waits for the loader thread for max 30 seconds
1389 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1391 DALI_TEST_EQUALS(gNaturalSize.width, 1024.0f, TEST_LOCATION);
1392 DALI_TEST_EQUALS(gNaturalSize.height, 1024.0f, TEST_LOCATION);
1394 gNaturalSize = Vector3::ZERO;
1396 imageView.SetImage(gImage_600_RGB);
1398 // Waiting for resourceReady so SendNotifcation not called here.
1400 // loading started, this waits for the loader thread for max 30 seconds
1401 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1403 // Trigger a potential relayout
1404 application.SendNotification();
1405 application.Render();
1407 DALI_TEST_EQUALS(gNaturalSize.width, 600.0f, TEST_LOCATION);
1408 DALI_TEST_EQUALS(gNaturalSize.height, 600.0f, TEST_LOCATION);
1413 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1415 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1417 ToolkitTestApplication application;
1419 gResourceReadySignalFired = false;
1421 Property::Map imageMap;
1423 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1424 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1426 tet_infoline("Creating ImageView without URL so image does not start loading");
1427 ImageView imageView = ImageView::New();
1428 tet_infoline("Connect to image loaded signal before setting image");
1429 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1430 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1431 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1433 // loading started, this waits for the loader thread
1434 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1436 application.SendNotification();
1437 application.Render(16);
1439 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1444 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1446 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1448 ToolkitTestApplication application;
1450 gResourceReadySignalFired = false;
1452 Property::Map imageMap;
1454 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1455 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1457 ImageView imageView = ImageView::New();
1458 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1459 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1461 // loading started, this waits for the loader thread
1462 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1464 application.SendNotification();
1465 application.Render(16);
1467 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1468 gResourceReadySignalFired = false;
1470 ImageView imageViewWithExistingImage = ImageView::New();
1471 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1472 imageViewWithExistingImage.SetProperty(ImageView::Property::IMAGE, imageMap);
1474 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1479 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1481 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1483 ToolkitTestApplication application;
1485 gResourceReadySignalFired = false;
1487 Property::Map imageImmediateLoadingMap;
1488 imageImmediateLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1489 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1491 tet_infoline("Immediate load an image");
1492 ImageView imageView = ImageView::New();
1493 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1494 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
1496 // loading started, this waits for the loader thread
1497 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1499 application.SendNotification();
1500 application.Render(16);
1502 tet_infoline("Check image loaded");
1503 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1504 gResourceReadySignalFired = false;
1506 tet_infoline("Create another ImageView with the same URL");
1507 ImageView imageViewWithExistingImage = ImageView::New(gImage_34_RGBA);
1508 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1509 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1511 application.GetScene().Add(imageViewWithExistingImage);
1513 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1518 int UtcDaliImageViewPaddingProperty(void)
1520 ToolkitTestApplication application;
1522 ImageView imageView = ImageView::New();
1523 Property::Map imagePropertyMap;
1524 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1525 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
1526 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1527 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1528 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1529 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1530 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1531 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1532 application.GetScene().Add(imageView);
1534 application.SendNotification();
1535 application.Render();
1537 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1539 ImageView childImage = ImageView::New();
1540 childImage.SetBackgroundColor(Color::BLACK);
1541 childImage.SetProperty(Actor::Property::SIZE, Vector2(10.f, 10.f));
1542 imageView.Add(childImage);
1544 application.SendNotification();
1545 application.Render();
1547 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1548 DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
1550 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1551 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1552 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1553 Property::Map resultMap;
1554 imageVisual.CreatePropertyMap(resultMap);
1556 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1557 DALI_TEST_CHECK(transformValue);
1558 Property::Map* retMap = transformValue->GetMap();
1559 DALI_TEST_CHECK(retMap);
1561 // Image Visual should be positioned depending on ImageView's padding
1562 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1567 int UtcDaliImageViewPaddingProperty02(void)
1569 ToolkitTestApplication application;
1571 ImageView imageView = ImageView::New();
1572 Property::Map imagePropertyMap;
1573 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1574 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1575 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1576 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1577 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1578 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1579 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1580 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1581 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1582 application.GetScene().Add(imageView);
1584 application.SendNotification();
1585 application.Render();
1587 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1589 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1590 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1591 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1592 Property::Map resultMap;
1593 imageVisual.CreatePropertyMap(resultMap);
1595 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1596 DALI_TEST_CHECK(transformValue);
1597 Property::Map* retMap = transformValue->GetMap();
1598 DALI_TEST_CHECK(retMap);
1600 // Image Visual should be positioned depending on ImageView's padding
1601 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1606 int UtcDaliImageViewPaddingProperty03(void)
1608 tet_infoline("Test Setting Image Padding then removing it.");
1610 ToolkitTestApplication application;
1612 ImageView imageView = ImageView::New();
1613 Property::Map imagePropertyMap;
1614 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1615 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1616 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1617 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1618 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1619 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1620 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1621 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1622 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1623 application.GetScene().Add(imageView);
1625 application.SendNotification();
1626 application.Render();
1628 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1630 tet_infoline("Remove Padding and test Visual is position correctly");
1632 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1634 application.SendNotification();
1635 application.Render();
1637 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1638 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1639 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1640 Property::Map resultMap;
1641 imageVisual.CreatePropertyMap(resultMap);
1643 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1644 DALI_TEST_CHECK(transformValue);
1645 Property::Map* retMap = transformValue->GetMap();
1646 DALI_TEST_CHECK(retMap);
1648 // Image Visual should be positioned depending on ImageView's padding
1649 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1654 int UtcDaliImageViewPaddingProperty04(void)
1656 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
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 "/Kid1.svg";
1664 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1665 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1666 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FILL;
1667 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1668 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1669 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1670 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1671 application.GetScene().Add(imageView);
1673 application.SendNotification();
1674 application.Render();
1676 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1678 tet_infoline("Remove Padding and test Visual is position correctly");
1680 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1682 application.SendNotification();
1683 application.Render();
1685 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1686 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1687 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1688 Property::Map resultMap;
1689 imageVisual.CreatePropertyMap(resultMap);
1691 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1692 DALI_TEST_CHECK(transformValue);
1693 Property::Map* retMap = transformValue->GetMap();
1694 DALI_TEST_CHECK(retMap);
1696 // Image Visual should be positioned depending on ImageView's padding
1697 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1702 int UtcDaliImageViewTransformTest01(void)
1704 tet_infoline("Test Setting a offset transform on the ImageView");
1706 ToolkitTestApplication application;
1708 ImageView imageView = ImageView::New();
1709 Property::Map imagePropertyMap;
1710 imagePropertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE)
1711 .Add(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/Kid1.svg")
1712 .Add(ImageVisual::Property::DESIRED_WIDTH, 120)
1713 .Add(ImageVisual::Property::DESIRED_HEIGHT, 120)
1714 .Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL)
1715 .Add(Visual::Property::TRANSFORM,
1716 Property::Map().Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1717 Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE))
1718 .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(8, 8)));
1720 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1721 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1722 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1723 application.GetScene().Add(imageView);
1725 application.SendNotification();
1726 application.Render();
1728 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1729 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1730 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1731 Property::Map resultMap;
1732 imageVisual.CreatePropertyMap(resultMap);
1734 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1735 DALI_TEST_CHECK(transformValue);
1736 Property::Map* retMap = transformValue->GetMap();
1737 DALI_TEST_CHECK(retMap);
1739 // Image Visual should be positioned depending on ImageView's padding
1740 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(8, 8), TEST_LOCATION);
1741 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);
1746 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1748 ToolkitTestApplication application;
1750 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1751 ImageView imageView = ImageView::New();
1752 Property::Map imageMap;
1753 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1754 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_34_RGBA;
1755 imageMap[Toolkit::ImageVisual::Property::ATLASING] = true;
1756 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1757 application.GetScene().Add(imageView);
1759 // Trigger a potential relayout
1760 application.SendNotification();
1761 application.Render();
1763 Vector3 naturalSize = imageView.GetNaturalSize();
1765 DALI_TEST_EQUALS(naturalSize.width, 34.0f, TEST_LOCATION);
1766 DALI_TEST_EQUALS(naturalSize.height, 34.0f, TEST_LOCATION);
1771 int UtcDaliImageViewFillMode(void)
1773 ToolkitTestApplication application;
1775 tet_infoline("Create an ImageVisual without padding and set the fill-mode to fill");
1777 ImageView imageView = ImageView::New();
1778 Property::Map imageMap;
1779 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1780 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB);
1781 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL);
1783 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1785 application.GetScene().Add(imageView);
1787 // Trigger a potential relayout
1788 application.SendNotification();
1789 application.Render();
1791 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1792 Property::Map returnedMap;
1793 visual.CreatePropertyMap(returnedMap);
1795 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1796 DALI_TEST_CHECK(value);
1797 Property::Map* map = value->GetMap();
1798 DALI_TEST_CHECK(map);
1800 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1801 DALI_TEST_CHECK(value);
1802 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION);
1804 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1805 DALI_TEST_CHECK(value);
1806 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1811 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1813 ToolkitTestApplication application;
1815 tet_infoline("Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )");
1816 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1818 ImageView imageView = ImageView::New();
1819 Property::Map imageMap;
1820 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1821 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1822 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
1824 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1825 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1827 application.GetScene().Add(imageView);
1829 // Trigger a potential relayout
1830 application.SendNotification();
1831 application.Render();
1833 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1834 Property::Map returnedMap;
1835 visual.CreatePropertyMap(returnedMap);
1837 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1838 DALI_TEST_CHECK(value);
1839 Property::Map* map = value->GetMap();
1840 DALI_TEST_CHECK(map);
1843 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1844 DALI_TEST_CHECK(value);
1845 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION);
1847 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1848 DALI_TEST_CHECK(value);
1849 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1851 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1852 DALI_TEST_CHECK(value);
1853 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
1858 int UtcDaliImageViewFittingModesFill(void)
1860 ToolkitTestApplication application;
1862 tet_infoline("Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )");
1863 tet_infoline(" There should be no need to change the transform, only size is changed to fit view");
1865 ImageView imageView = ImageView::New();
1866 Property::Map imageMap;
1867 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1868 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1869 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL);
1871 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1872 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1874 application.GetScene().Add(imageView);
1876 // Trigger a potential relayout
1877 application.SendNotification();
1878 application.Render();
1880 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1881 Property::Map returnedMap;
1882 visual.CreatePropertyMap(returnedMap);
1884 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1885 DALI_TEST_CHECK(value);
1886 Property::Map* map = value->GetMap();
1887 DALI_TEST_CHECK(map);
1889 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1890 DALI_TEST_CHECK(value);
1891 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Change the internal size according to the image view size
1893 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1894 DALI_TEST_CHECK(value);
1895 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1897 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1898 DALI_TEST_CHECK(value);
1899 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1904 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1906 ToolkitTestApplication application;
1908 tet_infoline("Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )");
1909 tet_infoline(" offset or size is the same as view, but adjust internally using pixelArea ");
1911 ImageView imageView = ImageView::New();
1912 Property::Map imageMap;
1913 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1914 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1915 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO);
1917 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1918 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 500));
1920 application.GetScene().Add(imageView);
1922 // Trigger a potential relayout
1923 application.SendNotification();
1924 application.Render();
1926 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1927 Property::Map returnedMap;
1928 visual.CreatePropertyMap(returnedMap);
1930 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1931 DALI_TEST_CHECK(value);
1932 Property::Map* map = value->GetMap();
1933 DALI_TEST_CHECK(map);
1936 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1937 DALI_TEST_CHECK(value);
1938 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 500), TEST_LOCATION); // Change the internal size according to the image view size
1940 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1941 DALI_TEST_CHECK(value);
1942 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1944 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1945 DALI_TEST_CHECK(value);
1946 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1951 int UtcDaliImageViewFittingModesCenter01(void)
1953 ToolkitTestApplication application;
1955 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [700,700] )");
1956 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1958 ImageView imageView = ImageView::New();
1959 Property::Map imageMap;
1960 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1961 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1962 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1964 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1965 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1967 application.GetScene().Add(imageView);
1969 // Trigger a potential relayout
1970 application.SendNotification();
1971 application.Render();
1973 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1974 Property::Map returnedMap;
1975 visual.CreatePropertyMap(returnedMap);
1977 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1978 DALI_TEST_CHECK(value);
1979 Property::Map* map = value->GetMap();
1980 DALI_TEST_CHECK(map);
1982 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1983 DALI_TEST_CHECK(value);
1984 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1986 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1987 DALI_TEST_CHECK(value);
1988 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1990 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1991 DALI_TEST_CHECK(value);
1992 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1997 int UtcDaliImageViewFittingModesCenter02(void)
1999 ToolkitTestApplication application;
2001 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [500,500] )");
2002 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
2004 ImageView imageView = ImageView::New();
2005 Property::Map imageMap;
2006 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2007 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2008 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
2010 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2011 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
2013 application.GetScene().Add(imageView);
2015 // Trigger a potential relayout
2016 application.SendNotification();
2017 application.Render();
2019 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2020 Property::Map returnedMap;
2021 visual.CreatePropertyMap(returnedMap);
2023 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2024 DALI_TEST_CHECK(value);
2025 Property::Map* map = value->GetMap();
2026 DALI_TEST_CHECK(map);
2028 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2029 DALI_TEST_CHECK(value);
2030 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2032 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2033 DALI_TEST_CHECK(value);
2034 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2036 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2037 DALI_TEST_CHECK(value);
2038 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
2043 int UtcDaliImageViewFittingModesFitHeight01(void)
2045 ToolkitTestApplication application;
2047 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )");
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::FIT_HEIGHT);
2055 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2056 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
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);
2073 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2074 DALI_TEST_CHECK(value);
2075 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 700), TEST_LOCATION); // Change the internal size according to the image view size
2077 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2078 DALI_TEST_CHECK(value);
2079 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2081 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2082 DALI_TEST_CHECK(value);
2083 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2088 int UtcDaliImageViewFittingModesFitHeight02(void)
2090 ToolkitTestApplication application;
2092 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )");
2094 ImageView imageView = ImageView::New();
2095 Property::Map imageMap;
2096 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2097 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2098 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2100 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2101 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2103 application.GetScene().Add(imageView);
2105 // Trigger a potential relayout
2106 application.SendNotification();
2107 application.Render();
2109 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2110 Property::Map returnedMap;
2111 visual.CreatePropertyMap(returnedMap);
2113 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2114 DALI_TEST_CHECK(value);
2115 Property::Map* map = value->GetMap();
2116 DALI_TEST_CHECK(map);
2118 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2119 DALI_TEST_CHECK(value);
2120 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2122 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2123 DALI_TEST_CHECK(value);
2124 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2126 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2127 DALI_TEST_CHECK(value);
2128 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2133 int UtcDaliImageViewFittingModesFitWidth01(void)
2135 ToolkitTestApplication application;
2137 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )");
2139 ImageView imageView = ImageView::New();
2140 Property::Map imageMap;
2141 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2142 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2143 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2145 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2146 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2148 application.GetScene().Add(imageView);
2150 // Trigger a potential relayout
2151 application.SendNotification();
2152 application.Render();
2154 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2155 Property::Map returnedMap;
2156 visual.CreatePropertyMap(returnedMap);
2158 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2159 DALI_TEST_CHECK(value);
2160 Property::Map* map = value->GetMap();
2161 DALI_TEST_CHECK(map);
2163 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2164 DALI_TEST_CHECK(value);
2165 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2167 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2168 DALI_TEST_CHECK(value);
2169 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2171 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2172 DALI_TEST_CHECK(value);
2173 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
2178 int UtcDaliImageViewFittingModesFitWidth02(void)
2180 ToolkitTestApplication application;
2182 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )");
2184 ImageView imageView = ImageView::New();
2185 Property::Map imageMap;
2186 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2187 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2188 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2190 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2191 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2193 application.GetScene().Add(imageView);
2195 // Trigger a potential relayout
2196 application.SendNotification();
2197 application.Render();
2199 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2200 Property::Map returnedMap;
2201 visual.CreatePropertyMap(returnedMap);
2203 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2204 DALI_TEST_CHECK(value);
2205 Property::Map* map = value->GetMap();
2206 DALI_TEST_CHECK(map);
2208 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2209 DALI_TEST_CHECK(value);
2210 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 600), TEST_LOCATION); // Change the internal size according to the image view size
2212 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2213 DALI_TEST_CHECK(value);
2214 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2216 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2217 DALI_TEST_CHECK(value);
2218 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2223 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2225 ToolkitTestApplication application;
2227 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2229 ImageView imageView = ImageView::New();
2231 // 1. Render using FittingMode::SHRINK_TO_FIT
2232 Property::Map imageMap;
2233 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2234 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2235 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2237 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2238 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2240 application.GetScene().Add(imageView);
2242 // Trigger a potential relayout
2243 application.SendNotification();
2244 application.Render();
2246 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2247 Property::Map returnedMap;
2248 visual.CreatePropertyMap(returnedMap);
2250 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2251 DALI_TEST_CHECK(value);
2252 Property::Map* map = value->GetMap();
2253 DALI_TEST_CHECK(map);
2255 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2256 DALI_TEST_CHECK(value);
2257 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2259 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2260 DALI_TEST_CHECK(value);
2261 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2263 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2264 DALI_TEST_CHECK(value);
2265 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2267 // 2. Render again using DevelVisaul::CENTER
2268 Property::Map imageMap2;
2269 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2270 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2271 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2273 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2274 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2276 application.GetScene().Add(imageView);
2278 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2280 // Trigger a potential relayout
2281 application.SendNotification();
2282 application.Render();
2284 returnedMap.Clear();
2285 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2287 visual.CreatePropertyMap(returnedMap);
2289 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2290 DALI_TEST_CHECK(value);
2291 map = value->GetMap();
2292 DALI_TEST_CHECK(map);
2294 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2295 DALI_TEST_CHECK(value);
2296 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2298 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2299 DALI_TEST_CHECK(value);
2300 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2302 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2303 DALI_TEST_CHECK(value);
2304 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2306 // 3. Render again using before fittingMode
2307 Property::Map imageMap3;
2308 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2309 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2310 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2312 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2313 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2315 application.GetScene().Add(imageView);
2317 // Trigger a potential relayout
2318 application.SendNotification();
2319 application.Render();
2321 returnedMap.Clear();
2322 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2323 visual.CreatePropertyMap(returnedMap);
2325 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2326 DALI_TEST_CHECK(value);
2327 map = value->GetMap();
2328 DALI_TEST_CHECK(map);
2330 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2331 DALI_TEST_CHECK(value);
2332 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2334 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2335 DALI_TEST_CHECK(value);
2336 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2338 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2339 DALI_TEST_CHECK(value);
2340 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2345 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2347 ToolkitTestApplication application;
2349 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2351 ImageView imageView = ImageView::New();
2353 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2354 Property::Map imageMap;
2355 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2356 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2357 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2359 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2360 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2362 application.GetScene().Add(imageView);
2364 // Trigger a potential relayout
2365 application.SendNotification();
2366 application.Render();
2368 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2369 Property::Map returnedMap;
2370 visual.CreatePropertyMap(returnedMap);
2372 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2373 DALI_TEST_CHECK(value);
2374 Property::Map* map = value->GetMap();
2375 DALI_TEST_CHECK(map);
2377 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2378 DALI_TEST_CHECK(value);
2379 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2381 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2382 DALI_TEST_CHECK(value);
2383 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2385 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2386 DALI_TEST_CHECK(value);
2387 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2389 // 2. Render again using DevelVisaul::CENTER
2390 Property::Map imageMap2;
2391 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2392 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2393 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2395 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2396 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2398 application.GetScene().Add(imageView);
2400 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2402 // Trigger a potential relayout
2403 application.SendNotification();
2404 application.Render();
2406 returnedMap.Clear();
2407 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2409 visual.CreatePropertyMap(returnedMap);
2411 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2412 DALI_TEST_CHECK(value);
2413 map = value->GetMap();
2414 DALI_TEST_CHECK(map);
2416 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2417 DALI_TEST_CHECK(value);
2418 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2420 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2421 DALI_TEST_CHECK(value);
2422 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2424 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2425 DALI_TEST_CHECK(value);
2426 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2428 // 3. Render again using before fittingMode
2429 Property::Map imageMap3;
2430 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2431 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2432 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2434 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2435 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2437 application.GetScene().Add(imageView);
2439 // Trigger a potential relayout
2440 application.SendNotification();
2441 application.Render();
2443 returnedMap.Clear();
2444 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2445 visual.CreatePropertyMap(returnedMap);
2447 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2448 DALI_TEST_CHECK(value);
2449 map = value->GetMap();
2450 DALI_TEST_CHECK(map);
2452 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2453 DALI_TEST_CHECK(value);
2454 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2456 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2457 DALI_TEST_CHECK(value);
2458 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2460 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2461 DALI_TEST_CHECK(value);
2462 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2467 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2469 ToolkitTestApplication application;
2471 tet_infoline("Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )");
2473 ImageView imageView = ImageView::New();
2474 Property::Map imageMap;
2475 imageMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE);
2476 imageMap.Add(Toolkit::ImageVisual::Property::URL, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME); // 249x169 image
2478 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2479 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
2481 application.GetScene().Add(imageView);
2483 // Trigger a potential relayout
2484 application.SendNotification();
2485 application.Render();
2487 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2488 Property::Map returnedMap;
2489 visual.CreatePropertyMap(returnedMap);
2491 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2492 DALI_TEST_CHECK(value);
2493 Property::Map* map = value->GetMap();
2494 DALI_TEST_CHECK(map);
2496 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2497 DALI_TEST_CHECK(value);
2498 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Relative size so will take up 100%
2500 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2501 DALI_TEST_CHECK(value);
2502 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2504 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2505 DALI_TEST_CHECK(value);
2506 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2511 int UtcDaliImageViewCustomShader(void)
2513 ToolkitTestApplication application;
2515 // Set a custom shader with an image url
2517 Property::Map properties;
2518 Property::Map shader;
2519 const std::string vertexShader = "Foobar";
2520 const std::string fragmentShader = "Foobar";
2521 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2522 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2524 properties[Visual::Property::TYPE] = Visual::IMAGE;
2525 properties[Visual::Property::SHADER] = shader;
2526 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2528 ImageView imageView = ImageView::New();
2529 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2531 application.GetScene().Add(imageView);
2533 application.SendNotification();
2534 application.Render();
2536 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2538 Renderer renderer = imageView.GetRendererAt(0);
2539 Shader shader2 = renderer.GetShader();
2540 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2541 Property::Map* map = value.GetMap();
2542 DALI_TEST_CHECK(map);
2544 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2545 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2547 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2548 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2551 // Set a custom shader after setting an image url
2553 Property::Map properties;
2554 Property::Map shader;
2555 const std::string vertexShader = "Foobar";
2556 const std::string fragmentShader = "Foobar";
2557 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2558 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2560 properties[Visual::Property::SHADER] = shader;
2562 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
2563 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2565 application.GetScene().Add(imageView);
2567 application.SendNotification();
2568 application.Render();
2570 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2572 Renderer renderer = imageView.GetRendererAt(0);
2573 Shader shader2 = renderer.GetShader();
2574 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2575 Property::Map* map = value.GetMap();
2576 DALI_TEST_CHECK(map);
2578 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2579 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2581 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2582 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2585 // Set a custom shader before setting an image url
2587 Property::Map properties;
2588 Property::Map shader;
2589 const std::string vertexShader = "Foobar";
2590 const std::string fragmentShader = "Foobar";
2591 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2592 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2594 properties[Visual::Property::SHADER] = shader;
2596 ImageView imageView = ImageView::New();
2597 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2598 imageView.SetProperty(ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME);
2600 application.GetScene().Add(imageView);
2602 application.SendNotification();
2603 application.Render();
2604 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2606 Renderer renderer = imageView.GetRendererAt(0);
2607 Shader shader2 = renderer.GetShader();
2608 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2609 Property::Map* map = value.GetMap();
2610 DALI_TEST_CHECK(map);
2612 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2613 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2615 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2616 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2619 // Set a custom shader after setting a property map
2621 Property::Map properties;
2622 Property::Map shader;
2623 const std::string vertexShader = "Foobar";
2624 const std::string fragmentShader = "Foobar";
2625 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2626 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2628 properties[Visual::Property::SHADER] = shader;
2630 Property::Map properties1;
2631 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2632 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2634 ImageView imageView = ImageView::New();
2635 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2636 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2638 application.GetScene().Add(imageView);
2640 application.SendNotification();
2641 application.Render();
2642 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2644 Renderer renderer = imageView.GetRendererAt(0);
2645 Shader shader2 = renderer.GetShader();
2646 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2647 Property::Map* map = value.GetMap();
2648 DALI_TEST_CHECK(map);
2650 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2651 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2653 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2654 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2657 // Set a custom shader before setting a property map
2659 Property::Map properties;
2660 Property::Map shader;
2661 const std::string vertexShader = "Foobar";
2662 const std::string fragmentShader = "Foobar";
2663 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2664 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2666 properties[Visual::Property::SHADER] = shader;
2668 Property::Map properties1;
2669 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2670 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2672 ImageView imageView = ImageView::New();
2673 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2674 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2676 application.GetScene().Add(imageView);
2678 application.SendNotification();
2679 application.Render();
2680 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2682 Renderer renderer = imageView.GetRendererAt(0);
2683 Shader shader2 = renderer.GetShader();
2684 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2685 Property::Map* map = value.GetMap();
2686 DALI_TEST_CHECK(map);
2688 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2689 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2691 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2692 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2700 static int gFailCounter = 0;
2701 const int MAX_RETRIES(3);
2703 void ReloadImage(ImageView imageView)
2705 Property::Map imageImmediateLoadingMap;
2706 imageImmediateLoadingMap[ImageVisual::Property::URL] = "Non-existant-image.jpg";
2707 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
2709 tet_infoline("Immediate load an image");
2710 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
2713 void ResourceFailedReload(Control control)
2719 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2721 tet_infoline("Test reloading failed image from within signal handler.");
2723 ToolkitTestApplication application;
2727 ImageView imageView = ImageView::New();
2728 imageView.ResourceReadySignal().Connect(&ResourceFailedReload);
2729 DALI_TEST_EQUALS(gFailCounter, 0, TEST_LOCATION);
2730 ReloadImage(imageView);
2732 // loading started, this waits for the loader thread to complete
2733 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2734 DALI_TEST_EQUALS(gFailCounter, 1, TEST_LOCATION);
2736 ReloadImage(imageView);
2737 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2738 DALI_TEST_EQUALS(gFailCounter, 2, TEST_LOCATION);
2740 ReloadImage(imageView);
2741 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2742 DALI_TEST_EQUALS(gFailCounter, 3, TEST_LOCATION);
2747 int UtcDaliImageViewLoadRemoteSVG(void)
2749 tet_infoline("Test load from a remote server.");
2751 ToolkitTestApplication application;
2754 Toolkit::ImageView imageView;
2755 imageView = Toolkit::ImageView::New();
2756 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2757 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2758 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2759 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2760 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2762 application.GetScene().Add(imageView);
2764 DALI_TEST_CHECK(imageView);
2766 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2768 application.SendNotification();
2770 // Wait for loading & rasterization
2771 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2773 application.SendNotification();
2774 application.Render();
2776 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2781 Toolkit::ImageView imageView;
2782 imageView = Toolkit::ImageView::New();
2783 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2784 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2785 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2786 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2788 application.GetScene().Add(imageView);
2790 DALI_TEST_CHECK(imageView);
2792 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2794 application.SendNotification();
2796 // Wait for loading & rasterization
2797 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2799 application.SendNotification();
2800 application.Render();
2802 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2808 int UtcDaliImageViewSyncSVGLoading(void)
2810 ToolkitTestApplication application;
2812 tet_infoline("ImageView Testing SVG image sync loading");
2815 ImageView imageView = ImageView::New();
2817 // Sync loading is used
2818 Property::Map syncLoadingMap;
2819 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2820 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2821 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2822 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2824 application.GetScene().Add(imageView);
2825 DALI_TEST_CHECK(imageView);
2827 application.SendNotification();
2828 Vector3 naturalSize = imageView.GetNaturalSize();
2830 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2831 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2836 int UtcDaliImageViewSyncSVGLoading02(void)
2838 ToolkitTestApplication application;
2840 tet_infoline("ImageView Testing SVG image sync loading");
2843 ImageView imageView = ImageView::New();
2845 // Sync loading is used
2846 Property::Map syncLoadingMap;
2847 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2848 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2849 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2850 syncLoadingMap.Insert(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
2851 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2852 imageView.ResourceReadySignal().Connect(&OnResourceReadySignalSVG);
2854 application.GetScene().Add(imageView);
2855 DALI_TEST_CHECK(imageView);
2857 application.SendNotification();
2858 application.Render();
2860 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
2861 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
2862 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
2863 Property::Map resultMap;
2864 imageVisual.CreatePropertyMap(resultMap);
2866 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
2867 DALI_TEST_CHECK(transformValue);
2868 Property::Map* retMap = transformValue->GetMap();
2869 DALI_TEST_CHECK(retMap);
2871 // Image Visual should be positioned depending on ImageView's padding
2872 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::SIZE)->Get<Vector2>(), Vector2(100, 100), TEST_LOCATION);
2874 Vector3 naturalSize = imageView.GetNaturalSize();
2875 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2876 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2881 int UtcDaliImageViewAsyncSVGLoading(void)
2883 ToolkitTestApplication application;
2885 tet_infoline("ImageView Testing SVG image async loading");
2888 ImageView imageView = ImageView::New();
2890 // Async loading is used - default value of SYNCHRONOUS_LOADING is false.
2891 Property::Map propertyMap;
2892 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2893 propertyMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2894 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
2896 application.GetScene().Add(imageView);
2897 DALI_TEST_CHECK(imageView);
2899 application.SendNotification();
2902 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2904 application.SendNotification();
2905 application.Render(16);
2907 Vector3 naturalSize = imageView.GetNaturalSize();
2908 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2909 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2914 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2916 ToolkitTestApplication application;
2918 tet_infoline("ImageView Testing SVG image async loading");
2922 ImageView imageView = ImageView::New();
2924 // Sync loading is used
2925 Property::Map syncLoadingMap;
2926 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2927 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2929 // Check to set invalid value
2930 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2931 // Check if error log is outputted when setting other value like string.
2932 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2933 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5));
2934 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2936 application.GetScene().Add(imageView);
2937 DALI_TEST_CHECK(imageView);
2939 application.SendNotification();
2942 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2944 application.SendNotification();
2945 application.Render(16);
2947 Vector3 naturalSize = imageView.GetNaturalSize();
2948 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2949 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2951 Property::Value value = imageView.GetProperty(ImageView::Property::IMAGE);
2952 Property::Map* map = value.GetMap();
2953 DALI_TEST_CHECK(map);
2955 Property::Value* sync = map->Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING);
2956 DALI_TEST_CHECK(sync);
2957 DALI_TEST_EQUALS(false, sync->Get<bool>(), TEST_LOCATION);
2962 int UtcDaliImageViewSvgLoadingFailureLocalFile(void)
2964 // Local svg file - invalid file path
2966 ToolkitTestApplication application;
2968 TestGlAbstraction& gl = application.GetGlAbstraction();
2969 TraceCallStack& textureTrace = gl.GetTextureTrace();
2970 textureTrace.Enable(true);
2972 gResourceReadySignalFired = false;
2974 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2975 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2976 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2978 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2980 application.GetScene().Add(imageView);
2982 application.SendNotification();
2984 // loading started, this waits for the loader thread - load
2985 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2987 application.SendNotification();
2988 application.Render(16);
2990 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2991 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2992 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2994 // Should be shown a broken image
2995 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2996 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2999 // Local svg file - invalid file path without size set
3001 ToolkitTestApplication application;
3003 TestGlAbstraction& gl = application.GetGlAbstraction();
3004 TraceCallStack& textureTrace = gl.GetTextureTrace();
3005 textureTrace.Enable(true);
3007 gResourceReadySignalFired = false;
3008 textureTrace.Reset();
3010 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
3011 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3013 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3015 application.GetScene().Add(imageView);
3017 application.SendNotification();
3019 // loading started, this waits for the loader thread - load & rasterize
3020 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3022 application.SendNotification();
3023 application.Render(16);
3025 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3026 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3027 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3029 // Should be shown a broken image
3030 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3031 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3034 // Local svg file - invalid file
3036 ToolkitTestApplication application;
3038 TestGlAbstraction& gl = application.GetGlAbstraction();
3039 TraceCallStack& textureTrace = gl.GetTextureTrace();
3040 textureTrace.Enable(true);
3042 gResourceReadySignalFired = false;
3043 textureTrace.Reset();
3045 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.svg");
3046 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3047 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3049 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3051 application.GetScene().Add(imageView);
3053 application.SendNotification();
3055 // loading started, this waits for the loader thread - load & rasterize
3056 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3058 application.SendNotification();
3059 application.Render(16);
3061 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3062 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3063 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3065 // Should be shown a broken image
3066 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3067 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3073 int UtcDaliImageViewSvgLoadingFailureRemoteFile01(void)
3077 ToolkitTestApplication application;
3079 TestGlAbstraction& gl = application.GetGlAbstraction();
3080 TraceCallStack& textureTrace = gl.GetTextureTrace();
3081 textureTrace.Enable(true);
3083 gResourceReadySignalFired = false;
3085 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
3086 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3087 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3089 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3091 application.GetScene().Add(imageView);
3093 application.SendNotification();
3095 // loading started, this waits for the loader thread - load & rasterize
3096 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3098 application.SendNotification();
3099 application.Render(16);
3101 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3102 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3103 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3105 // Should be shown a broken image
3106 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3107 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3113 int UtcDaliImageViewSvgLoadingFailureRemoteFile02(void)
3115 // Remote svg file without size set
3117 ToolkitTestApplication application;
3119 TestGlAbstraction& gl = application.GetGlAbstraction();
3120 TraceCallStack& textureTrace = gl.GetTextureTrace();
3121 textureTrace.Enable(true);
3123 gResourceReadySignalFired = false;
3125 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
3126 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3128 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3130 application.GetScene().Add(imageView);
3132 application.SendNotification();
3134 // loading started, this waits for the loader thread - load & rasterize
3135 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3137 application.SendNotification();
3138 application.Render(16);
3140 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3141 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3142 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3144 // Should be shown a broken image
3145 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3146 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3152 int UtcDaliImageViewSvgRasterizationFailure(void)
3154 ToolkitTestApplication application;
3156 gResourceReadySignalFired = false;
3158 TestGlAbstraction& gl = application.GetGlAbstraction();
3159 TraceCallStack& textureTrace = gl.GetTextureTrace();
3160 textureTrace.Enable(true);
3162 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid1.svg");
3163 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3164 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3166 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3168 application.GetScene().Add(imageView);
3170 application.SendNotification();
3172 // Wait for loading & rasterization
3173 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3175 application.SendNotification();
3176 application.Render(16);
3178 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3179 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3180 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3182 // Should be shown a broken image
3183 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3184 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3189 int UtcDaliImageViewSvgChageSize(void)
3191 ToolkitTestApplication application;
3193 TestGlAbstraction& gl = application.GetGlAbstraction();
3194 TraceCallStack& textureTrace = gl.GetTextureTrace();
3195 textureTrace.Enable(true);
3197 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME);
3198 application.GetScene().Add(imageView);
3200 application.SendNotification();
3202 // Wait for loading & rasterization
3203 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3205 application.SendNotification();
3206 application.Render(16);
3208 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3210 // Change actor size, then rasterization should be done again
3211 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3213 application.SendNotification();
3215 // Wait for rasterization
3216 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3218 application.SendNotification();
3219 application.Render(16);
3221 // We should not load the file again.
3222 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3227 int UtcDaliImageViewSvgAtlasing(void)
3229 ToolkitTestApplication application;
3231 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
3233 callStack.Enable(true);
3235 Property::Map propertyMap;
3236 propertyMap["url"] = TEST_SVG_FILE_NAME;
3237 propertyMap["atlasing"] = true;
3239 ImageView imageView = ImageView::New();
3240 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
3241 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3242 application.GetScene().Add(imageView);
3244 application.SendNotification();
3246 // Wait for loading & rasterization
3247 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3249 application.SendNotification();
3250 application.Render(16);
3253 TraceCallStack::NamedParams params1;
3254 params1["width"] << 100;
3255 params1["height"] << 100;
3256 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params1), true, TEST_LOCATION);
3258 imageView.SetProperty(Actor::Property::SIZE, Vector2(600.f, 600.f));
3260 application.SendNotification();
3262 // Wait for rasterization
3263 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3267 application.SendNotification();
3268 application.Render(16);
3271 TraceCallStack::NamedParams params2;
3272 params2["width"] << 600;
3273 params2["height"] << 600;
3274 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexImage2D", params2), true, TEST_LOCATION);
3279 int UtcDaliImageViewTVGLoading(void)
3281 ToolkitTestApplication application;
3283 tet_infoline("ImageView Testing TVG image loading");
3286 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/test.tvg");
3287 application.GetScene().Add(imageView);
3288 DALI_TEST_CHECK(imageView);
3290 application.SendNotification();
3292 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3294 application.SendNotification();
3295 application.Render(16);
3297 Vector3 naturalSize = imageView.GetNaturalSize();
3299 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3300 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3305 int UtcDaliImageViewSvgDesiredSize01(void)
3307 ToolkitTestApplication application;
3309 TestGlAbstraction& gl = application.GetGlAbstraction();
3310 TraceCallStack& textureTrace = gl.GetTextureTrace();
3311 textureTrace.Enable(true);
3313 int desiredWidth = 100, desiredHeight = 150;
3314 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
3316 application.GetScene().Add(imageView);
3318 application.SendNotification();
3320 // Wait for loading & rasterization
3321 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3323 application.SendNotification();
3324 application.Render(16);
3327 std::stringstream out;
3328 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
3329 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
3335 int UtcDaliImageViewSvgDesiredSize02(void)
3337 ToolkitTestApplication application;
3339 TestGlAbstraction& gl = application.GetGlAbstraction();
3340 TraceCallStack& textureTrace = gl.GetTextureTrace();
3341 textureTrace.Enable(true);
3343 int desiredWidth = 150, desiredHeight = 100;
3344 ImageView imageView = ImageView::New();
3345 imageView[ImageView::Property::IMAGE] = Property::Map().Add("url", TEST_SVG_FILE_NAME).Add("desiredWidth", desiredWidth).Add("desiredHeight", desiredHeight);
3346 application.GetScene().Add(imageView);
3348 application.SendNotification();
3350 // Wait for loading & rasterization
3351 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3353 application.SendNotification();
3354 application.Render(16);
3357 std::stringstream out;
3358 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
3359 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
3365 int UtcDaliImageViewImageLoadFailure01(void)
3367 ToolkitTestApplication application;
3369 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3370 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3371 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3372 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3374 std::string brokenUrl;
3375 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3376 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3378 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3379 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3381 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3382 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3384 ImageView imageView = ImageView::New("invalidUrl.png");
3385 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3387 application.GetScene().Add(imageView);
3388 application.SendNotification();
3389 application.Render(16);
3391 // loading started, this waits for the loader thread
3392 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3397 int UtcDaliImageViewImageLoadFailure02(void)
3399 ToolkitTestApplication application;
3401 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3402 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
3403 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3404 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3406 std::string brokenUrl;
3407 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3408 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
3410 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3411 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3413 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3414 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3416 ImageView imageView = ImageView::New("invalidUrl.png");
3417 imageView.SetProperty(Actor::Property::SIZE, Vector2(30.f, 30.f));
3418 application.GetScene().Add(imageView);
3419 application.SendNotification();
3420 application.Render(16);
3422 // loading started, this waits for the loader thread
3423 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3428 int UtcDaliImageViewImageLoadFailure03(void)
3430 ToolkitTestApplication application;
3432 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3433 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
3434 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
3436 std::string brokenUrl;
3437 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3438 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3440 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3441 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3443 ImageView imageView = ImageView::New("invalidUrl.png");
3444 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3445 application.GetScene().Add(imageView);
3446 application.SendNotification();
3447 application.Render(16);
3449 // loading started, this waits for the loader thread
3450 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3455 int UtcDaliImageViewImageLoadFailure04(void)
3457 ToolkitTestApplication application;
3459 ImageView imageView = ImageView::New("invalidUrl.png");
3460 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3461 application.GetScene().Add(imageView);
3462 application.SendNotification();
3463 application.Render(16);
3465 // loading started, this waits for the loader thread
3466 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3468 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3469 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3470 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3471 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3473 ImageView imageView2 = ImageView::New("invalidUrl.png");
3474 imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3475 application.GetScene().Add(imageView2);
3477 std::string brokenUrl;
3478 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3479 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3481 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3482 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3484 application.SendNotification();
3485 application.Render(16);
3487 // loading started, this waits for the loader thread
3488 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3490 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3492 ImageView imageView3 = ImageView::New("invalidUrl.png");
3493 imageView3.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3494 application.GetScene().Add(imageView3);
3496 application.SendNotification();
3497 application.Render(16);
3499 // loading started, this waits for the loader thread
3500 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3507 static int gResourceReadySignalCounter = 0;
3509 void OnResourceReadySignal01(Control control)
3511 gResourceReadySignalCounter++;
3513 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3515 if(gResourceReadySignalCounter == 1)
3518 // It makes the first new visual be deleted immediately
3519 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3520 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3523 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3525 // Make the resource ready immediately
3526 control[ImageView::Property::IMAGE] = gImage_600_RGB;
3530 void OnResourceReadySignal02(Control control)
3532 if(++gResourceReadySignalCounter == 1)
3534 // It makes the first new visual be deleted immediately
3535 // The first image will not be loaded.
3536 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB).Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3537 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3541 ImageView gImageView1;
3542 ImageView gImageView2;
3543 ImageView gImageView3;
3544 ImageView gImageView4;
3546 void OnResourceReadySignal03(Control control)
3548 if(gResourceReadySignalCounter == 0)
3551 // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3552 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3554 // 2. Load a new image
3555 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3557 // 3. Use the new image again
3558 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3559 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3561 else if(gResourceReadySignalCounter == 1)
3563 // This is called from TextureManager::ProcessQueuedTextures().
3564 gImageView1.Unparent();
3565 gImageView1.Reset();
3567 gResourceReadySignalCounter++;
3570 void OnSimpleResourceReadySignal(Control control)
3572 // simply increate counter
3573 gResourceReadySignalCounter++;
3576 int gResourceReadySignal04ComesOrder = 0;
3578 void OnResourceReadySignal04(Control control)
3580 gResourceReadySignalCounter++;
3581 tet_printf("rc %d\n", gResourceReadySignalCounter);
3582 if(gResourceReadySignalCounter == 1)
3584 auto scene = gImageView1.GetParent();
3586 // Request load something
3587 // We hope this request result is return later than gImageView2.
3588 gImageView3 = ImageView::New(TEST_IMAGE_1);
3589 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3590 scene.Add(gImageView3);
3591 gImageView4 = ImageView::New(TEST_IMAGE_2);
3592 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3593 scene.Add(gImageView4);
3595 if(control == gImageView1)
3597 gResourceReadySignal04ComesOrder = 1;
3601 gResourceReadySignal04ComesOrder = 2;
3604 if(gResourceReadySignalCounter == 2)
3606 if(gResourceReadySignal04ComesOrder == 1 && control == gImageView2)
3608 // Scene off first one.
3609 gImageView1.Unparent();
3611 // Scene off second one.
3612 gImageView2.Unparent();
3614 else if(gResourceReadySignal04ComesOrder == 2 && control == gImageView1)
3616 // Scene off first one.
3617 gImageView2.Unparent();
3619 // Scene off second one.
3620 gImageView1.Unparent();
3624 // We can't check that this utc fail case. just pass always when we come here.
3625 gResourceReadySignal04ComesOrder = -1;
3628 // If we don't seperate index of FreeList area
3629 // and if we don't queue remove during obversing,
3630 // cache index become something invalid data.
3631 // In this case, some strange observer can be called.
3632 // For example, gImageView4.LoadComplete will be called.
3636 void OnResourceReadySignal05(Control control)
3638 gResourceReadySignalCounter++;
3640 // Request load with same image
3641 // NOTE : The url must not be same as gImageView1
3642 const int viewCount = 4;
3643 for(int i = 0; i < viewCount; ++i)
3645 gImageView1.Add(ImageView::New("invalid2.jpg"));
3649 int gResourceReadySignal06ComesOrder = 0;
3651 void OnResourceReadySignal06(Control control)
3653 gResourceReadySignalCounter++;
3654 if(gResourceReadySignalCounter == 1)
3656 auto scene = gImageView1.GetParent();
3658 // Request load something
3659 // We hope this request result is return later than gImageView2.
3662 map1[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
3663 map1[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
3665 gImageView3 = ImageView::New();
3666 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3667 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3670 map2[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
3671 map2[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_S;
3672 gImageView4 = ImageView::New();
3673 gImageView4.SetProperty(Toolkit::ImageView::Property::IMAGE, map2);
3674 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3676 if(control == gImageView1)
3678 gResourceReadySignal06ComesOrder = 1;
3682 gResourceReadySignal06ComesOrder = 2;
3685 if(gResourceReadySignalCounter == 2)
3687 if(gResourceReadySignal06ComesOrder == 1 && control == gImageView2)
3689 // Scene off first one.
3690 gImageView1.Unparent();
3692 // Scene off second one.
3693 gImageView2.Unparent();
3695 else if(gResourceReadySignal06ComesOrder == 2 && control == gImageView1)
3697 // Scene off first one.
3698 gImageView2.Unparent();
3700 // Scene off second one.
3701 gImageView1.Unparent();
3705 // We can't check that this utc fail case. just pass always when we come here.
3706 gResourceReadySignal06ComesOrder = -1;
3709 // If we don't seperate index of FreeList area
3710 // and if we don't queue remove during obversing,
3711 // cache index become something invalid data.
3712 // In this case, some strange observer can be called.
3713 // For example, gImageView4.LoadComplete will be called.
3717 void OnResourceReadySignal07(Control control)
3719 gResourceReadySignalCounter++;
3720 // Load masked image
3721 tet_printf("rc %d %d\n", gResourceReadySignalCounter, static_cast<bool>(gImageView2));
3725 auto scene = gImageView1.GetParent();
3728 map1[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
3729 map1[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
3731 gImageView2 = ImageView::New();
3732 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3733 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal07);
3735 scene.Add(gImageView2);
3739 void OnResourceReadySignal08(Control control)
3741 gResourceReadySignalCounter++;
3745 gImageView1.Unparent();
3746 gImageView1.Reset();
3750 gImageView2.Unparent();
3751 gImageView2.Reset();
3755 std::size_t gResourceReadySignal09Emitted = false;
3757 void OnResourceReadySignal09(Control control)
3759 gResourceReadySignalCounter++;
3761 if(gImageView1 && !gResourceReadySignal09Emitted)
3763 gResourceReadySignal09Emitted = true;
3764 gImageView1.ResourceReadySignal().Disconnect(&OnResourceReadySignal09);
3766 // Try to load cached invalid nine patch image. It will request load now.
3767 gImageView1.SetImage(TEST_INVALID_NPATCH_FILE_NAME_01);
3768 gImageView2.SetImage(TEST_INVALID_NPATCH_FILE_NAME_01);
3770 // Destroy all visuals immediatly.
3771 gImageView1.Unparent();
3772 gImageView1.Reset();
3773 gImageView2.Unparent();
3774 gImageView2.Reset();
3780 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3782 tet_infoline("Test setting image from within signal handler.");
3784 ToolkitTestApplication application;
3786 gResourceReadySignalCounter = 0;
3788 ImageView imageView = ImageView::New(gImage_34_RGBA);
3789 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal01);
3791 application.GetScene().Add(imageView);
3793 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3795 application.SendNotification();
3796 application.Render();
3798 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3800 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3802 // Create a new ImageView to cache the image
3803 ImageView imageView1 = ImageView::New(gImage_600_RGB);
3804 application.GetScene().Add(imageView1);
3806 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3808 application.SendNotification();
3809 application.Render();
3812 gResourceReadySignalCounter = 0;
3814 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3816 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3818 application.SendNotification();
3819 application.Render();
3821 // Run idle callback
3822 application.RunIdles();
3824 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3826 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3831 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
3833 tet_infoline("Test setting image from within signal handler.");
3835 ToolkitTestApplication application;
3837 gResourceReadySignalCounter = 0;
3839 ImageView imageView = ImageView::New(gImage_34_RGBA);
3840 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal02);
3842 application.GetScene().Add(imageView);
3844 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3846 application.SendNotification();
3847 application.Render();
3849 // Wait for loading an image
3850 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3852 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3854 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3859 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3861 tet_infoline("Test setting image from within signal handler.");
3863 ToolkitTestApplication application;
3865 gResourceReadySignalCounter = 0;
3867 gImageView1 = ImageView::New(gImage_34_RGBA);
3868 application.GetScene().Add(gImageView1);
3871 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3873 gImageView2 = ImageView::New(gImage_600_RGB);
3874 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3875 application.GetScene().Add(gImageView2);
3877 gImageView3 = ImageView::New();
3878 application.GetScene().Add(gImageView3);
3880 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3882 application.SendNotification();
3883 application.Render();
3888 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask01(void)
3890 tet_infoline("Test signal handler when image / mask image is broken.");
3892 ToolkitTestApplication application;
3894 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, const std::string& url, const std::string& mask, const char* location) {
3895 gResourceReadySignalCounter = 0;
3898 map[Toolkit::ImageVisual::Property::URL] = url;
3901 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3903 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3905 ImageView imageView = ImageView::New();
3906 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3907 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3908 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3910 application.GetScene().Add(imageView);
3911 application.SendNotification();
3912 application.Render();
3917 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3919 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3920 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3922 imageView.Unparent();
3925 for(int synchronous = 0; synchronous <= 1; synchronous++)
3927 tet_printf("Test normal case (sync:%d)\n", synchronous);
3928 TestResourceReadyUrl(1, synchronous, gImage_600_RGB, "", TEST_LOCATION);
3929 TestResourceReadyUrl(3, synchronous, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 3 event trigger required : 2 image load + 1 apply mask
3931 tet_printf("Test broken image case (sync:%d)\n", synchronous);
3932 TestResourceReadyUrl(1, synchronous, "invalid.jpg", "", TEST_LOCATION);
3933 TestResourceReadyUrl(2, synchronous, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3935 tet_printf("Test broken mask image case (sync:%d)\n", synchronous);
3936 TestResourceReadyUrl(2, synchronous, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3938 tet_printf("Test broken both image, mask image case (sync:%d)\n", synchronous);
3939 TestResourceReadyUrl(2, synchronous, "invalid.jpg", "invalid.png", TEST_LOCATION);
3945 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask02(void)
3947 tet_infoline("Test signal handler when image try to use cached-and-broken mask image.");
3949 ToolkitTestApplication application;
3951 gResourceReadySignalCounter = 0;
3953 auto TestBrokenMaskResourceReadyUrl = [&application](const std::string& url, const char* location) {
3955 map[Toolkit::ImageVisual::Property::URL] = url;
3956 // Use invalid mask url
3957 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
3959 ImageView imageView = ImageView::New();
3960 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3961 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3962 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3964 application.GetScene().Add(imageView);
3966 // Don't unparent imageView, for keep the cache.
3969 // Use more than 4 images (The number of LocalImageLoadThread)
3970 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};
3972 int expectResourceReadySignalCounter = 0;
3974 for(auto& url : testUrlList)
3976 TestBrokenMaskResourceReadyUrl(url, TEST_LOCATION);
3977 expectResourceReadySignalCounter++;
3980 // Remain 1 signal due to we use #URL + 1 mask image.
3981 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(expectResourceReadySignalCounter + 1), true, TEST_LOCATION);
3982 application.SendNotification();
3983 application.Render();
3984 DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
3989 int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
3991 tet_infoline("Test signal handler various case.");
3993 auto TestResourceReadyUrl = [](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
3994 ToolkitTestApplication application;
3996 gResourceReadySignalCounter = 0;
3999 map[Toolkit::ImageVisual::Property::URL] = url;
4002 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
4004 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
4006 ImageView imageView = ImageView::New();
4007 imageView[Toolkit::ImageView::Property::IMAGE] = map;
4008 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
4009 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4011 application.GetScene().Add(imageView);
4012 application.SendNotification();
4013 application.Render();
4016 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
4018 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
4019 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
4020 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, location);
4022 imageView.Unparent();
4025 auto TestAuxiliaryResourceReadyUrl = [](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
4026 ToolkitTestApplication application;
4028 gResourceReadySignalCounter = 0;
4031 map[Toolkit::ImageVisual::Property::URL] = url;
4032 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE] = auxiliaryUrl;
4033 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA] = 0.5f;
4034 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
4036 ImageView imageView = ImageView::New();
4037 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4038 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4039 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4040 application.GetScene().Add(imageView);
4042 application.SendNotification();
4043 application.Render();
4048 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, location);
4051 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
4052 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
4053 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
4055 imageView.Unparent();
4058 // Case 1 : asynchronous loading
4059 tet_printf("Test invalid single simple image Asynchronous\n");
4062 TestResourceReadyUrl(1, 0, 1, gImage_600_RGB, "", TEST_LOCATION);
4063 TestResourceReadyUrl(2, 0, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // load & rasterize
4064 TestResourceReadyUrl(1, 0, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
4066 TestResourceReadyUrl(2, 0, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // 2 image loading - batch size
4067 TestResourceReadyUrl(2, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // load & rasterize
4069 TestResourceReadyUrl(3, 0, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 2 image loading + 1 applymask
4071 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
4074 TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
4075 TestResourceReadyUrl(1, 0, 0, "invalid.svg", "", TEST_LOCATION);
4076 TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
4077 TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION); // 1 image loading
4078 TestResourceReadyUrl(1, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
4080 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", "invalid.png", TEST_LOCATION); // 2 image loading
4081 TestResourceReadyUrl(2, 0, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); // 2 image loading
4082 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION); // 2 image loading
4084 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
4085 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
4086 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
4088 // Case 2 : Synchronous loading
4089 tet_printf("Test invalid single simple image Synchronous\n");
4092 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "", TEST_LOCATION);
4093 TestResourceReadyUrl(0, 1, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
4094 TestResourceReadyUrl(0, 1, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
4096 TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // first frame image loading sync + second frame image loading async
4098 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION);
4100 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
4103 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
4104 TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION);
4105 TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
4106 TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
4108 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "invalid.png", TEST_LOCATION);
4109 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION);
4110 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
4112 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
4113 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
4114 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
4119 int UtcDaliImageViewSetImageOnResourceReadySignal04(void)
4121 tet_infoline("Test texturemanager's remove queue works well within signal handler.");
4123 ToolkitTestApplication application;
4125 gResourceReadySignalCounter = 0;
4126 gResourceReadySignal04ComesOrder = 0;
4128 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
4129 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal04);
4130 application.GetScene().Add(gImageView1);
4132 gImageView2 = ImageView::New("invalid.png"); // request invalid image, to make loading failed fast.
4133 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal04);
4134 application.GetScene().Add(gImageView2);
4136 application.SendNotification();
4137 application.Render();
4139 tet_infoline("Try to load 2 invalid image");
4141 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4142 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4144 tet_infoline("load done");
4146 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
4147 if(gResourceReadySignal04ComesOrder == -1)
4149 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
4153 // gImageView3 and gImageView4 load must not be successed yet.
4154 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
4155 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
4157 application.SendNotification();
4158 application.Render();
4160 tet_infoline("Try to load 2 valid image");
4162 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4163 DALI_TEST_EQUALS(gResourceReadySignalCounter, 4, TEST_LOCATION);
4165 tet_infoline("load done");
4167 // gImageView3 and gImageView4 load must be successed now.
4168 DALI_TEST_EQUALS(gImageView3.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
4169 DALI_TEST_EQUALS(gImageView4.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
4174 int UtcDaliImageViewSetImageOnResourceReadySignal05(void)
4176 tet_infoline("Test multiple views with same image during ResourceReady load the image only 1 times");
4178 ToolkitTestApplication application;
4180 gResourceReadySignalCounter = 0;
4182 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
4183 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal05);
4184 application.GetScene().Add(gImageView1);
4186 application.SendNotification();
4187 application.Render();
4189 tet_infoline("Try to load 1 invalid.jpg image");
4190 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4191 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4193 tet_infoline("Try to load 1 invalid2.jpg image");
4194 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4196 tet_infoline("Now we don't have any image to be loaded. Check event thread trigger failed.");
4197 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
4199 gImageView1.Unparent();
4200 gImageView1.Reset();
4204 int UtcDaliImageViewSetImageOnResourceReadySignal06(void)
4206 tet_infoline("Test texturemanager's remove image & mask queue works well within signal handler.");
4208 ToolkitTestApplication application;
4210 gResourceReadySignalCounter = 0;
4211 gResourceReadySignal06ComesOrder = 0;
4214 map[Toolkit::ImageVisual::Property::URL] = "invalid.jpg";
4215 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
4217 gImageView1 = ImageView::New(); // request invalid image, to make loading failed fast.
4218 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4219 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal06);
4220 application.GetScene().Add(gImageView1);
4222 gImageView2 = ImageView::New(); // request invalid image, to make loading failed fast.
4223 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4224 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal06);
4225 application.GetScene().Add(gImageView2);
4227 application.SendNotification();
4228 application.Render();
4230 tet_infoline("Try to load 2 invalid image");
4232 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4233 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4235 tet_infoline("load done");
4237 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
4238 if(gResourceReadySignal06ComesOrder == -1)
4240 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
4244 // gImageView3 and gImageView4 load must not be successed yet.
4245 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
4246 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
4248 application.GetScene().Add(gImageView3);
4249 application.GetScene().Add(gImageView4);
4250 application.SendNotification();
4251 application.Render();
4253 tet_infoline("Try to load 2 valid image");
4255 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4256 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4258 tet_infoline("load done");
4263 int UtcDaliImageViewSetImageOnResourceReadySignal07(void)
4265 tet_infoline("Test texturemanager's remove image & mask queue works well within signal handler 02.");
4267 ToolkitTestApplication application;
4269 gResourceReadySignalCounter = 0;
4272 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4274 // Clear image view for clear test
4278 gImageView1.Reset();
4282 gImageView2.Reset();
4285 gImageView1 = ImageView::New();
4286 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4287 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal07);
4288 application.GetScene().Add(gImageView1);
4290 application.SendNotification();
4291 application.Render();
4295 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4296 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4298 tet_infoline("load image1 done");
4300 // Load gImageView2 and mask
4302 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4303 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4305 // gImageView2 mask apply done
4307 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4308 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4310 tet_infoline("load image2 done");
4314 int UtcDaliImageViewSetImageOnResourceReadySignal08(void)
4316 tet_infoline("Test remove npatch images during resource ready");
4318 ToolkitTestApplication application;
4320 gResourceReadySignalCounter = 0;
4323 map[Toolkit::ImageVisual::Property::URL] = TEST_BROKEN_IMAGE_M;
4325 // Clear image view for clear test
4329 gImageView1.Reset();
4333 gImageView2.Reset();
4336 // Case 1 : Remove all images during resource ready.
4339 gImageView1 = ImageView::New();
4340 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4341 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal08);
4342 application.GetScene().Add(gImageView1);
4344 application.SendNotification();
4345 application.Render();
4348 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4349 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4351 application.SendNotification();
4352 application.Render();
4354 DALI_TEST_CHECK(true);
4358 // Exception should not happened
4359 DALI_TEST_CHECK(false);
4363 application.SendNotification();
4364 application.Render();
4366 gResourceReadySignalCounter = 0;
4368 // Case 2 : Remove all images when we use cached resource.
4371 gImageView1 = ImageView::New();
4372 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4373 gImageView1.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4374 application.GetScene().Add(gImageView1);
4376 application.SendNotification();
4377 application.Render();
4380 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4381 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4383 application.SendNotification();
4384 application.Render();
4386 gImageView2 = ImageView::New();
4387 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4388 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal08);
4389 application.GetScene().Add(gImageView2);
4390 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4392 application.SendNotification();
4393 application.Render();
4395 DALI_TEST_CHECK(true);
4399 // Exception should not happened
4400 DALI_TEST_CHECK(false);
4402 gResourceReadySignalCounter = 0;
4404 // Clear image view for clear test
4408 gImageView1.Reset();
4412 gImageView2.Reset();
4418 int UtcDaliImageViewSetImageOnResourceReadySignal09(void)
4420 tet_infoline("Test load invalid npatch images during invalid resource ready");
4422 ToolkitTestApplication application;
4424 gResourceReadySignalCounter = 0;
4427 map[Toolkit::ImageVisual::Property::URL] = TEST_INVALID_NPATCH_FILE_NAME_01;
4429 // Clear image view for clear test
4433 gImageView1.Reset();
4437 gImageView2.Reset();
4441 gImageView3.Reset();
4444 // Dummy view with npatch image
4445 ImageView dummyView = ImageView::New(TEST_BROKEN_IMAGE_M);
4446 application.GetScene().Add(dummyView);
4448 application.SendNotification();
4449 application.Render();
4450 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4451 application.SendNotification();
4452 application.Render();
4454 // Case 1 : Reload images during resource ready.
4457 gResourceReadySignal09Emitted = false;
4459 gImageView1 = ImageView::New();
4460 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4461 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal09);
4462 application.GetScene().Add(gImageView1);
4464 gImageView2 = ImageView::New();
4465 application.GetScene().Add(gImageView2);
4467 // Load TEST_INVALID_NPATCH_FILE_NAME_01
4468 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4470 // Load TEST_INVALID_NPATCH_FILE_NAME_01 one more times.
4471 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4473 application.SendNotification();
4474 application.Render();
4476 DALI_TEST_CHECK(true);
4480 // Exception should not happened
4481 DALI_TEST_CHECK(false);
4485 application.SendNotification();
4486 application.Render();
4488 gResourceReadySignalCounter = 0;
4490 // Case 2 : Remove all images when we use cached resource.
4493 gResourceReadySignal09Emitted = false;
4495 gImageView3 = ImageView::New();
4496 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4497 gImageView3.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4498 application.GetScene().Add(gImageView3);
4500 gImageView2 = ImageView::New();
4501 application.GetScene().Add(gImageView2);
4504 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4506 gImageView1 = ImageView::New();
4507 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4508 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal09);
4509 application.GetScene().Add(gImageView1);
4512 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4514 // Load TEST_INVALID_NPATCH_FILE_NAME_01 one more times.
4515 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4517 application.SendNotification();
4518 application.Render();
4520 DALI_TEST_CHECK(true);
4524 // Exception should not happened
4525 DALI_TEST_CHECK(false);
4527 gResourceReadySignalCounter = 0;
4529 // Clear image view for clear test
4533 gImageView1.Reset();
4537 gImageView2.Reset();
4541 gImageView3.Reset();
4547 int UtcDaliImageViewUseSameUrlWithAnimatedImageVisual(void)
4549 tet_infoline("Test multiple views with same image in animated image visual");
4550 ToolkitTestApplication application;
4552 gImageView1 = ImageView::New(TEST_WEBP_FILE_NAME);
4553 application.GetScene().Add(gImageView1);
4555 tet_infoline("Remove imageView and Create new imageView with same url");
4556 application.GetScene().Remove(gImageView1);
4557 gImageView2 = ImageView::New(TEST_WEBP_FILE_NAME);
4558 application.GetScene().Add(gImageView2);
4560 application.SendNotification();
4561 application.Render();
4563 tet_infoline("Check the ImageView load image successfully");
4564 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4568 int UtcDaliImageViewNpatchImageCacheTest01(void)
4570 tet_infoline("Test npatch image cached");
4572 ToolkitTestApplication application;
4573 ImageView imageView[2];
4575 auto& gl = application.GetGlAbstraction();
4576 gl.EnableTextureCallTrace(true);
4577 auto& textureCallStack = gl.GetTextureTrace();
4578 textureCallStack.Enable(true);
4579 textureCallStack.EnableLogging(true);
4581 auto TestNPatch = [&](int index, const std::string& nPatchImageUrl, const char* location) {
4582 if(imageView[index])
4584 imageView[index].Unparent();
4587 // Ensure remove npatch cache if required.
4588 application.SendNotification();
4589 application.Render();
4591 imageView[index] = ImageView::New(nPatchImageUrl);
4592 imageView[index].SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4593 application.GetScene().Add(imageView[index]);
4596 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4597 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4599 application.SendNotification();
4600 application.Render();
4602 tet_printf("trace : \n%s\n", textureCallStack.GetTraceString().c_str());
4604 // Check we gen only 1 textures
4605 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 1, TEST_LOCATION);
4606 textureCallStack.Reset();
4608 // Let we use cached textures
4609 for(int i = 0; i < 10; i++)
4611 TestNPatch(1, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4612 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4615 application.SendNotification();
4616 application.Render();
4617 // Check we use cached npatch data so we don't generate new texture textures
4618 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 0, TEST_LOCATION);
4621 imageView[0].Unparent();
4622 imageView[0].Reset();
4623 imageView[1].Unparent();
4624 imageView[1].Reset();
4626 application.SendNotification();
4627 application.Render();
4629 textureCallStack.Reset();
4630 // Let we use deference textures
4631 TestNPatch(1, TEST_BROKEN_IMAGE_S, TEST_LOCATION);
4632 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4634 application.SendNotification();
4635 application.Render();
4636 // Try to load multiple times.
4637 for(int i = 0; i < 3; i++)
4639 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4640 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4641 TestNPatch(1, TEST_BROKEN_IMAGE_S, TEST_LOCATION);
4642 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4644 application.SendNotification();
4645 application.Render();
4647 imageView[0].Unparent();
4648 imageView[0].Reset();
4649 imageView[1].Unparent();
4650 imageView[1].Reset();
4652 application.SendNotification();
4653 application.Render();
4655 // Check memory leak
4656 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), textureCallStack.CountMethod("DeleteTextures"), TEST_LOCATION);
4661 int UtcDaliImageViewNpatchImageCacheTest02(void)
4663 tet_infoline("Test npatch image cached with border");
4665 ToolkitTestApplication application;
4666 ImageView imageView[2];
4668 auto& gl = application.GetGlAbstraction();
4669 gl.EnableTextureCallTrace(true);
4670 auto& textureCallStack = gl.GetTextureTrace();
4671 textureCallStack.Enable(true);
4672 textureCallStack.EnableLogging(true);
4674 auto TestBorderImage = [&](int index, const std::string& normalImageUrl, const Rect<int> border, const char* location) {
4676 map[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::N_PATCH;
4677 map[Toolkit::ImageVisual::Property::URL] = normalImageUrl;
4678 map[Toolkit::ImageVisual::Property::BORDER] = border;
4680 imageView[index] = ImageView::New();
4681 imageView[index].SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4682 imageView[index].SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4683 application.GetScene().Add(imageView[index]);
4686 TestBorderImage(0, gImage_34_RGBA, Rect<int>(0, 0, 0, 0), TEST_LOCATION);
4687 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4689 application.SendNotification();
4690 application.Render();
4692 tet_printf("trace : \n%s\n", textureCallStack.GetTraceString().c_str());
4694 // Check we gen only 1 textures
4695 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 1, TEST_LOCATION);
4696 textureCallStack.Reset();
4698 // Let we use cached textures
4699 for(int i = 0; i < 10; i++)
4701 TestBorderImage(0, gImage_34_RGBA, Rect<int>(i, i + 1, i + 2, i + 3), TEST_LOCATION);
4702 TestBorderImage(1, gImage_34_RGBA, Rect<int>(i + 1, i, i + 3, i + 2), TEST_LOCATION);
4705 application.SendNotification();
4706 application.Render();
4708 // Check we use cached npatch data so we don't generate new texture textures
4709 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 0, TEST_LOCATION);
4714 int UtcDaliImageViewPlaceholderImage01(void)
4716 tet_infoline("Test imageView use placeholder image");
4718 ToolkitTestApplication application;
4720 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4722 ImageView imageView = ImageView::New();
4723 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4724 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4725 application.GetScene().Add(imageView);
4727 Property::Value value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4729 DALI_TEST_CHECK(value.Get(url));
4730 DALI_TEST_CHECK(url.empty());
4731 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4733 application.SendNotification();
4734 application.Render();
4736 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4737 DALI_TEST_CHECK(value.Get(url));
4738 DALI_TEST_CHECK(url == gImage_34_RGBA);
4740 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4741 application.SendNotification();
4742 application.Render();
4744 // Replace Image test
4745 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4746 map[ImageView::Property::PLACEHOLDER_IMAGE] = gImage_34_RGBA;
4747 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4748 application.SendNotification();
4749 application.Render();
4751 map[Toolkit::ImageVisual::Property::URL] = "";
4752 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4753 application.SendNotification();
4754 application.Render();
4756 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
4757 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4758 application.SendNotification();
4759 application.Render();
4761 // Replace Image test2
4762 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4763 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4764 application.SendNotification();
4765 application.Render();
4767 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
4768 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4769 application.SendNotification();
4770 application.Render();
4772 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4773 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4774 application.SendNotification();
4775 application.Render(900);
4777 map[Toolkit::ImageVisual::Property::URL] = "";
4778 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4779 application.SendNotification();
4780 application.Render();
4782 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4783 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4784 application.SendNotification();
4785 application.Render();
4790 int UtcDaliImageViewPlaceholderImage02(void)
4792 tet_infoline("Test imageView use placeholder image without resource ready");
4794 ToolkitTestApplication application;
4797 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4799 ImageView imageView = ImageView::New();
4800 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4801 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4802 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
4803 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
4804 application.GetScene().Add(imageView);
4806 Property::Value value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4808 DALI_TEST_CHECK(value.Get(url));
4809 DALI_TEST_CHECK(url.empty());
4811 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4812 application.SendNotification();
4813 application.Render();
4815 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4817 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4818 DALI_TEST_CHECK(value.Get(url));
4819 DALI_TEST_CHECK(url == gImage_34_RGBA);
4821 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
4822 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
4824 gResourceReadySignalFired = false;
4825 map[Toolkit::ImageVisual::Property::URL] = "";
4826 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4827 application.SendNotification();
4828 application.Render();
4830 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
4831 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
4836 int UtcDaliImageViewTransitionEffect01(void)
4838 tet_infoline("Test imageView use transition effect");
4840 ToolkitTestApplication application;
4842 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4843 map[Toolkit::Visual::Property::OPACITY] = 0.9f;
4845 ImageView imageView = ImageView::New();
4846 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4847 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4848 application.GetScene().Add(imageView);
4850 Property::Value value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
4852 DALI_TEST_CHECK(value.Get(transition));
4853 DALI_TEST_CHECK(transition == false);
4854 imageView.SetProperty(Toolkit::ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
4856 application.SendNotification();
4857 application.Render();
4859 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
4860 DALI_TEST_CHECK(value.Get(transition));
4861 DALI_TEST_CHECK(transition == true);
4863 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4864 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4865 application.SendNotification();
4866 application.Render();
4868 // Test transition effect with placeholder
4869 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4870 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4871 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4872 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4873 application.SendNotification();
4874 application.Render();
4876 map[Toolkit::ImageVisual::Property::URL] = "";
4877 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4878 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4879 application.SendNotification();
4880 application.Render();
4882 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4883 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4884 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4885 application.SendNotification();
4886 application.Render();
4888 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4889 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4890 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4891 application.SendNotification();
4893 map[Toolkit::ImageVisual::Property::URL] = "";
4894 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4895 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4896 application.SendNotification();
4897 application.Render();
4899 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4900 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4901 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, "");
4902 application.SendNotification();
4903 application.Render();
4905 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4906 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4907 application.SendNotification();
4908 application.Render();
4910 map[Toolkit::ImageVisual::Property::URL] = "";
4911 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4912 application.SendNotification();
4913 application.Render();
4915 // Test transition effect without placeholder
4916 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4917 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4918 application.SendNotification();
4919 application.Render();
4921 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4922 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4923 application.SendNotification();
4924 application.Render();
4926 map[Toolkit::ImageVisual::Property::URL] = "";
4927 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4928 application.SendNotification();
4929 application.Render();
4931 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4932 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4933 application.SendNotification();
4934 application.Render();
4936 imageView.SetImage(TEST_IMAGE_1);
4937 application.SendNotification();
4938 application.Render();
4940 imageView.SetImage(gImage_600_RGB);
4941 application.SendNotification();
4942 application.Render(9000);
4944 imageView.SetImage("");
4945 application.SendNotification();
4946 application.Render();
4948 imageView.SetImage(TEST_IMAGE_1);
4949 application.SendNotification();
4950 application.Render();
4953 imageView.Unparent();
4959 int UtcDaliImageViewTransitionEffect02(void)
4961 tet_infoline("Test imageView use transition effect with replace image");
4963 ToolkitTestApplication application;
4967 ImageView imageView = ImageView::New();
4968 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4969 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4970 application.GetScene().Add(imageView);
4972 Property::Value value;
4973 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
4975 DALI_TEST_CHECK(value.Get(transition));
4976 DALI_TEST_CHECK(transition == false);
4977 imageView.SetProperty(Toolkit::ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
4979 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4981 DALI_TEST_CHECK(value.Get(url));
4982 DALI_TEST_CHECK(url.empty());
4983 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4984 application.SendNotification();
4985 application.Render();
4987 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, "");
4988 application.SendNotification();
4989 application.Render();
4991 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4992 application.SendNotification();
4993 application.Render();
4995 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
4996 DALI_TEST_CHECK(value.Get(transition));
4997 DALI_TEST_CHECK(transition == true);
4999 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5000 DALI_TEST_CHECK(value.Get(url));
5001 DALI_TEST_CHECK(url == gImage_34_RGBA);
5003 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5004 application.SendNotification();
5005 application.Render();
5008 imageView.Unparent();
5014 int UtcDaliImageViewTransitionEffect03(void)
5016 tet_infoline("Test imageView use transition effect with placeholder");
5018 ToolkitTestApplication application;
5021 ImageView imageView = ImageView::New();
5022 imageView.SetImage("");
5023 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5024 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5025 imageView.SetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
5026 application.GetScene().Add(imageView);
5028 //DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5030 application.SendNotification();
5031 application.Render(16);
5033 tet_infoline("(1)");
5034 imageView.SetImage(gImage_600_RGB);
5035 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5036 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
5037 application.SendNotification();
5038 application.Render(16);
5040 Property::Value value;
5041 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5043 DALI_TEST_CHECK(value.Get(transition));
5044 DALI_TEST_CHECK(transition == true);
5046 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5048 DALI_TEST_CHECK(value.Get(url));
5049 DALI_TEST_CHECK(url == gImage_34_RGBA);
5051 imageView.SetImage("");
5052 application.SendNotification();
5053 application.Render(16);
5055 imageView.SetImage(TEST_IMAGE_1);
5056 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5057 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5058 application.SendNotification();
5059 application.Render(16);
5062 imageView.Unparent();