2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
24 #include <dali-toolkit-test-suite-utils.h>
25 #include <toolkit-event-thread-callback.h>
26 #include "dummy-control.h"
28 #include <test-encoded-image-buffer.h>
29 #include <test-native-image.h>
31 #include <dali-toolkit/dali-toolkit.h>
32 #include <dali-toolkit/devel-api/controls/control-devel.h>
33 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
34 #include <dali-toolkit/devel-api/styling/style-manager-devel.h>
35 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
36 #include <dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h>
37 #include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
38 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
39 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
40 #include <dali-toolkit/public-api/image-loader/image-url.h>
41 #include <dali-toolkit/public-api/image-loader/image.h>
42 #include <dali/devel-api/scripting/scripting.h>
45 using namespace Toolkit;
47 void utc_dali_toolkit_image_view_startup(void)
49 test_return_value = TET_UNDEF;
52 void utc_dali_toolkit_image_view_cleanup(void)
54 test_return_value = TET_PASS;
59 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
60 const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
62 // resolution: 1024*1024
63 const char* TEST_IMAGE_1 = TEST_RESOURCE_DIR "/TB-gloss.png";
64 const char* TEST_IMAGE_2 = TEST_RESOURCE_DIR "/tb-norm.png";
66 const char* TEST_BROKEN_IMAGE_DEFAULT = TEST_RESOURCE_DIR "/broken.png";
67 const char* TEST_BROKEN_IMAGE_S = TEST_RESOURCE_DIR "/broken_s.9.png";
68 const char* TEST_BROKEN_IMAGE_M = TEST_RESOURCE_DIR "/broken_m.9.png";
69 const char* TEST_BROKEN_IMAGE_L = TEST_RESOURCE_DIR "/broken_l.9.png";
70 const char* TEST_BROKEN_IMAGE_01 = TEST_RESOURCE_DIR "/button-up.9.png";
71 const char* TEST_BROKEN_IMAGE_02 = TEST_RESOURCE_DIR "/heartsframe.9.png";
73 // resolution: 34*34, pixel format: RGBA8888
74 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
75 // resolution: 600*600, pixel format: RGB888
76 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
78 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
79 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
81 const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
82 const char* TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
84 void TestUrl(ImageView imageView, const std::string url)
86 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
88 std::string urlActual;
89 DALI_TEST_CHECK(value.Get(urlActual));
90 DALI_TEST_EQUALS(urlActual, url, TEST_LOCATION);
95 int UtcDaliImageViewNewP(void)
97 ToolkitTestApplication application;
99 ImageView imageView = ImageView::New();
101 DALI_TEST_CHECK(imageView);
106 int UtcDaliImageViewNewUrlP(void)
108 ToolkitTestApplication application;
110 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
111 DALI_TEST_CHECK(imageView);
113 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
118 int UtcDaliImageViewConstructorP(void)
120 ToolkitTestApplication application;
124 DALI_TEST_CHECK(!imageView);
129 int UtcDaliImageViewCopyConstructorP(void)
131 ToolkitTestApplication application;
133 // Initialize an object, ref count == 1
134 ImageView imageView = ImageView::New();
136 ImageView copy(imageView);
137 DALI_TEST_CHECK(copy);
142 int UtcDaliImageViewMoveConstructor(void)
144 ToolkitTestApplication application;
146 ImageView imageView = ImageView::New();
147 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
148 imageView.SetProperty(Actor::Property::SENSITIVE, false);
149 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
151 ImageView moved = std::move(imageView);
152 DALI_TEST_CHECK(moved);
153 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
154 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
155 DALI_TEST_CHECK(!imageView);
160 int UtcDaliImageViewAssignmentOperatorP(void)
162 ToolkitTestApplication application;
164 ImageView imageView = ImageView::New();
166 ImageView copy(imageView);
167 DALI_TEST_CHECK(copy);
168 DALI_TEST_EQUALS(imageView, copy, TEST_LOCATION);
173 int UtcDaliImageViewMoveAssignment(void)
175 ToolkitTestApplication application;
177 ImageView imageView = ImageView::New();
178 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
179 imageView.SetProperty(Actor::Property::SENSITIVE, false);
180 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
183 moved = std::move(imageView);
184 DALI_TEST_CHECK(moved);
185 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
186 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
187 DALI_TEST_CHECK(!imageView);
192 int UtcDaliImageViewDownCastP(void)
194 ToolkitTestApplication application;
196 ImageView imageView = ImageView::New();
198 BaseHandle object(imageView);
200 ImageView imageView2 = ImageView::DownCast(object);
201 DALI_TEST_CHECK(imageView2);
203 ImageView imageView3 = DownCast<ImageView>(object);
204 DALI_TEST_CHECK(imageView3);
209 int UtcDaliImageViewDownCastN(void)
211 ToolkitTestApplication application;
213 BaseHandle unInitializedObject;
215 ImageView imageView1 = ImageView::DownCast(unInitializedObject);
216 DALI_TEST_CHECK(!imageView1);
218 ImageView imageView2 = DownCast<ImageView>(unInitializedObject);
219 DALI_TEST_CHECK(!imageView2);
224 int UtcDaliImageViewTypeRegistry(void)
226 ToolkitTestApplication application;
228 TypeRegistry typeRegistry = TypeRegistry::Get();
229 DALI_TEST_CHECK(typeRegistry);
231 TypeInfo typeInfo = typeRegistry.GetTypeInfo("ImageView");
232 DALI_TEST_CHECK(typeInfo);
234 BaseHandle handle = typeInfo.CreateInstance();
235 DALI_TEST_CHECK(handle);
237 ImageView imageView = ImageView::DownCast(handle);
238 DALI_TEST_CHECK(imageView);
243 int UtcDaliImageViewSetGetProperty01(void)
245 ToolkitTestApplication application;
247 ImageView imageView = ImageView::New();
249 Property::Index idx = imageView.GetPropertyIndex("image");
250 DALI_TEST_EQUALS(idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION);
252 imageView.SetProperty(idx, TEST_IMAGE_FILE_NAME);
253 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
258 int UtcDaliImageViewPreMultipliedAlphaPng(void)
260 ToolkitTestApplication application;
262 // Set up trace debug
263 TestGlAbstraction& gl = application.GetGlAbstraction();
264 TraceCallStack& textureTrace = gl.GetTextureTrace();
265 textureTrace.Enable(true);
267 Property::Map imageMap;
268 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
269 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
271 ImageView imageView1 = ImageView::New();
272 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
274 application.GetScene().Add(imageView1);
276 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
278 DALI_TEST_CHECK(value.Get(enable));
279 DALI_TEST_CHECK(enable); // Default value is true
281 // loading started, this waits for the loader thread for max 30 seconds
282 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
284 application.SendNotification();
285 application.Render();
287 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
288 DALI_TEST_CHECK(value.Get(enable));
289 DALI_TEST_CHECK(enable); // Keep true
291 // conventional alpha blending
292 Renderer renderer1 = imageView1.GetRendererAt(0);
293 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
294 DALI_TEST_CHECK(value.Get(enable));
295 DALI_TEST_CHECK(enable);
297 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
298 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
299 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
300 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
301 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
302 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
303 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
304 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
306 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
307 textureTrace.Reset();
309 // Disable pre-multiplied alpha blending
310 imageView1.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
313 Property::Map attributes;
314 DevelControl::DoAction(imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
316 // loading started, this waits for the loader thread for max 30 seconds
317 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
319 application.SendNotification();
320 application.Render();
322 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
323 DALI_TEST_CHECK(value.Get(enable));
324 DALI_TEST_CHECK(!enable);
326 // conventional alpha blending
327 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
328 DALI_TEST_CHECK(value.Get(enable));
329 DALI_TEST_CHECK(!enable);
331 srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
332 destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
333 srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
334 destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
335 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
336 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
337 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
338 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
340 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
341 textureTrace.Reset();
343 // Make a new ImageView using the same image
344 ImageView imageView2 = ImageView::New();
345 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
347 application.GetScene().Add(imageView2);
349 application.SendNotification();
350 application.Render();
352 Renderer renderer2 = imageView2.GetRendererAt(0);
353 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
354 DALI_TEST_CHECK(value.Get(enable));
355 DALI_TEST_CHECK(enable);
357 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
358 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
359 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
360 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
361 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
362 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
363 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
364 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
366 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
371 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
373 ToolkitTestApplication application;
375 // Set up trace debug
376 TestGlAbstraction& gl = application.GetGlAbstraction();
377 TraceCallStack& textureTrace = gl.GetTextureTrace();
378 textureTrace.Enable(true);
380 Property::Map imageMap;
381 imageMap[ImageVisual::Property::URL] = gImage_600_RGB;
382 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
384 ImageView imageView1 = ImageView::New();
385 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
387 application.GetScene().Add(imageView1);
389 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
391 DALI_TEST_CHECK(value.Get(enable));
392 DALI_TEST_CHECK(enable); // Default value is true
394 // loading started, this waits for the loader thread for max 30 seconds
395 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
397 application.SendNotification();
398 application.Render();
400 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
401 DALI_TEST_CHECK(value.Get(enable));
402 DALI_TEST_CHECK(!enable); // Should be false after loading
404 // conventional alpha blending
405 Renderer renderer1 = imageView1.GetRendererAt(0);
406 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
407 DALI_TEST_CHECK(value.Get(enable));
408 DALI_TEST_CHECK(!enable);
410 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
411 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
412 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
413 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
414 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
415 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
416 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
417 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
419 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
420 textureTrace.Reset();
422 ImageView imageView2 = ImageView::New();
423 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
425 // Disable pre-multiplied alpha blending
426 imageView2.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
428 application.GetScene().Add(imageView2);
430 application.SendNotification();
431 application.Render();
433 value = imageView2.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
434 DALI_TEST_CHECK(value.Get(enable));
435 DALI_TEST_CHECK(!enable);
437 // conventional alpha blending
438 Renderer renderer2 = imageView2.GetRendererAt(0);
439 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
440 DALI_TEST_CHECK(value.Get(enable));
441 DALI_TEST_CHECK(!enable);
443 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
444 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
445 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
446 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
447 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
448 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
449 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
450 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
452 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
457 int UtcDaliImageViewPixelArea(void)
459 // Test pixel area property
460 ToolkitTestApplication application;
462 static std::vector<UniformData> customUniforms =
464 UniformData("pixelArea", Property::Type::VECTOR4),
467 TestGraphicsController& graphics = application.GetGraphicsController();
468 graphics.AddCustomUniforms(customUniforms);
470 // Gif image, use AnimatedImageVisual internally
471 // Atlasing is applied to pack multiple frames, use custom wrap mode
472 ImageView gifView = ImageView::New();
473 const Vector4 pixelAreaVisual(0.f, 0.f, 2.f, 2.f);
474 gifView.SetProperty(ImageView::Property::IMAGE,
475 Property::Map().Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME).Add(ImageVisual::Property::PIXEL_AREA, pixelAreaVisual));
478 Integration::Scene stage = application.GetScene();
482 application.SendNotification();
483 application.Render(16);
485 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
487 application.SendNotification();
488 application.Render();
489 DALI_TEST_CHECK(gifView.GetRendererCount() == 1u);
491 const Vector4 fullTextureRect(0.f, 0.f, 1.f, 1.f);
492 // test that the pixel area value defined in the visual property map is registered on renderer
493 Renderer renderer = gifView.GetRendererAt(0);
494 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
495 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION);
497 // test that the shader has the default pixel area value registered.
498 Shader shader = renderer.GetShader();
499 pixelAreaValue = shader.GetProperty(shader.GetPropertyIndex("pixelArea"));
500 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION);
502 // test that the uniform uses the pixelArea property on the renderer.
503 TestGlAbstraction& gl = application.GetGlAbstraction();
504 Vector4 pixelAreaUniform;
505 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
506 DALI_TEST_EQUALS(pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
508 // set the pixelArea property on the control
509 const Vector4 pixelAreaControl(-1.f, -1.f, 3.f, 3.f);
510 gifView.SetProperty(ImageView::Property::PIXEL_AREA, pixelAreaControl);
511 application.SendNotification();
512 application.Render(16);
514 // check the pixelArea property on the control
515 pixelAreaValue = gifView.GetProperty(gifView.GetPropertyIndex("pixelArea"));
516 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION);
517 // test that the uniform uses the pixelArea property on the control.
518 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
519 DALI_TEST_EQUALS(pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
524 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
526 ToolkitTestApplication application;
527 TestGlAbstraction& gl = application.GetGlAbstraction();
528 const std::vector<GLuint>& textures = gl.GetBoundTextures();
529 size_t numTextures = textures.size();
531 // Async loading, no atlasing for big size image
532 ImageView imageView = ImageView::New(gImage_600_RGB);
534 // By default, Aysnc loading is used
535 application.GetScene().Add(imageView);
536 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
537 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
539 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
541 application.SendNotification();
542 application.Render(16);
543 application.SendNotification();
545 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
546 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
551 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
553 ToolkitTestApplication application;
555 //Async loading, automatic atlasing for small size image
556 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
558 callStack.Enable(true);
560 Property::Map imageMap;
562 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
563 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
564 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
565 imageMap[ImageVisual::Property::ATLASING] = true;
567 ImageView imageView = ImageView::New();
568 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
569 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
571 // By default, Aysnc loading is used
572 // loading is not started if the actor is offScene
574 application.GetScene().Add(imageView);
575 application.SendNotification();
576 application.Render(16);
577 application.Render(16);
578 application.SendNotification();
580 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
581 application.SendNotification();
582 application.Render(16);
583 application.Render(16);
584 application.SendNotification();
586 // loading started, this waits for the loader thread for max 30 seconds
587 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
589 application.SendNotification();
590 application.Render(16);
592 callStack.Enable(false);
594 TraceCallStack::NamedParams params;
595 params["width"] << 34;
596 params["height"] << 34;
597 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
602 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
604 ToolkitTestApplication application;
606 //Async loading, automatic atlasing for small size image
607 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
609 callStack.Enable(true);
611 Property::Map asyncLoadingMap;
612 asyncLoadingMap["url"] = gImage_34_RGBA;
613 asyncLoadingMap["desiredHeight"] = 34;
614 asyncLoadingMap["desiredWidth"] = 34;
615 asyncLoadingMap["synchronousLoading"] = false;
616 asyncLoadingMap["atlasing"] = true;
618 ImageView imageView = ImageView::New();
619 imageView.SetProperty(ImageView::Property::IMAGE, asyncLoadingMap);
621 application.GetScene().Add(imageView);
622 application.SendNotification();
623 application.Render(16);
624 application.Render(16);
625 application.SendNotification();
627 // loading started, this waits for the loader thread for max 30 seconds
628 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
630 application.SendNotification();
631 application.Render(16);
633 callStack.Enable(false);
635 TraceCallStack::NamedParams params;
636 params["width"] << 34;
637 params["height"] << 34;
638 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
643 int UtcDaliImageViewSyncLoading(void)
645 ToolkitTestApplication application;
647 tet_infoline("ImageView Testing sync loading and size using index key property map");
649 Property::Map syncLoadingMap;
650 syncLoadingMap[ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
651 syncLoadingMap[ImageVisual::Property::ATLASING] = true;
653 // Sync loading, no atlasing for big size image
655 ImageView imageView = ImageView::New();
657 // Sync loading is used
658 syncLoadingMap[ImageVisual::Property::URL] = gImage_600_RGB;
659 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
662 // Sync loading, automatic atlasing for small size image
664 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
666 callStack.Enable(true);
668 ImageView imageView = ImageView::New();
670 // Sync loading is used
671 syncLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
672 syncLoadingMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
673 syncLoadingMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
674 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
676 application.GetScene().Add(imageView);
677 application.SendNotification();
678 application.Render(16);
680 TraceCallStack::NamedParams params;
681 params["width"] << 34;
682 params["height"] << 34;
683 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
690 int UtcDaliImageViewSyncLoading02(void)
692 ToolkitTestApplication application;
694 tet_infoline("ImageView Testing sync loading and size using string key property map");
696 // Sync loading, automatic atlasing for small size image
698 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
700 callStack.Enable(true);
702 ImageView imageView = ImageView::New();
704 // Sync loading is used
705 Property::Map syncLoadingMap;
706 syncLoadingMap["url"] = gImage_34_RGBA;
707 syncLoadingMap["desiredHeight"] = 34;
708 syncLoadingMap["desiredWidth"] = 34;
709 syncLoadingMap["synchronousLoading"] = true;
710 syncLoadingMap["atlasing"] = true;
711 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
713 application.GetScene().Add(imageView);
714 application.SendNotification();
715 application.Render(16);
717 TraceCallStack::NamedParams params;
718 params["width"] << 34;
719 params["height"] << 34;
720 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
727 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
729 ToolkitTestApplication application;
730 TestGlAbstraction& gl = application.GetGlAbstraction();
731 const std::vector<GLuint>& textures = gl.GetBoundTextures();
732 size_t numTextures = textures.size();
734 // Get encoded raw-buffer image and generate url
735 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
736 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
738 // Async loading, no atlasing for big size image
739 ImageView imageView = ImageView::New(url.GetUrl());
741 // By default, Aysnc loading is used
742 application.GetScene().Add(imageView);
743 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
744 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
746 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
748 application.SendNotification();
749 application.Render(16);
750 application.SendNotification();
752 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
753 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
758 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
760 ToolkitTestApplication application;
762 // Get encoded raw-buffer image and generate url
763 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
764 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
765 ImageUrl url2 = Toolkit::Image::GenerateUrl(buffer);
767 // Generate url is not equal to url2
768 // NOTE : This behavior may changed when ImageUrl compare operator changed.
769 DALI_TEST_CHECK(url != url2);
770 // Generate url's string is equal to url2's string
771 DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
773 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
774 url2 = Toolkit::Image::GenerateUrl(buffer2);
776 // Check whethere two url are not equal
777 DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
779 // Async loading, automatic atlasing for small size image
780 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
782 callStack.Enable(true);
784 Property::Map imageMap;
786 imageMap[ImageVisual::Property::URL] = url.GetUrl();
787 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
788 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
789 imageMap[ImageVisual::Property::ATLASING] = true;
791 ImageView imageView = ImageView::New();
792 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
793 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
795 // By default, Aysnc loading is used
796 // loading is not started if the actor is offScene
798 application.GetScene().Add(imageView);
799 application.SendNotification();
800 application.Render(16);
801 application.Render(16);
802 application.SendNotification();
804 // Change url to url2
805 imageMap[ImageVisual::Property::URL] = url2.GetUrl();
806 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
808 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
809 application.SendNotification();
810 application.Render(16);
811 application.Render(16);
812 application.SendNotification();
814 // loading started, this waits for the loader thread for max 30 seconds
815 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
817 application.SendNotification();
818 application.Render(16);
820 callStack.Enable(false);
822 TraceCallStack::NamedParams params;
823 params["width"] << 34;
824 params["height"] << 34;
825 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
830 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
832 ToolkitTestApplication application;
834 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
836 // Get encoded raw-buffer image and generate url
837 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
838 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
840 // Sync loading, automatic atlasing for small size image
842 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
844 callStack.Enable(true);
846 ImageView imageView = ImageView::New();
848 // Sync loading is used
849 Property::Map syncLoadingMap;
850 syncLoadingMap["url"] = url.GetUrl();
851 syncLoadingMap["desiredHeight"] = 34;
852 syncLoadingMap["desiredWidth"] = 34;
853 syncLoadingMap["synchronousLoading"] = true;
854 syncLoadingMap["atlasing"] = true;
855 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
857 application.GetScene().Add(imageView);
858 application.SendNotification();
859 application.Render(16);
861 TraceCallStack::NamedParams params;
862 params["width"] << 34;
863 params["height"] << 34;
864 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
872 int UtcDaliImageViewAddedTexture(void)
874 ToolkitTestApplication application;
876 tet_infoline("ImageView Testing image view with texture provided manager url");
878 ImageView imageView = ImageView::New();
880 // empty texture is ok, though pointless from app point of view
882 std::string url = TextureManager::AddTexture(empty);
883 DALI_TEST_CHECK(url.size() > 0u);
885 Property::Map propertyMap;
886 propertyMap[ImageVisual::Property::URL] = url;
887 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
889 application.GetScene().Add(imageView);
890 application.SendNotification();
891 application.Render();
896 int UtcDaliImageViewSizeWithBackground(void)
898 ToolkitTestApplication application;
902 ImageView imageView = ImageView::New();
904 imageView.SetProperty(Control::Property::BACKGROUND,
906 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
907 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
908 {ImageVisual::Property::DESIRED_WIDTH, width},
909 {ImageVisual::Property::DESIRED_HEIGHT, height},
912 application.GetScene().Add(imageView);
913 application.SendNotification();
914 application.Render();
916 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
917 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
922 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
924 ToolkitTestApplication application;
926 int widthBackground = 100;
927 int heightBackground = 200;
931 ImageView imageView = ImageView::New();
933 imageView.SetProperty(Control::Property::BACKGROUND,
935 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
936 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
937 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
938 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground},
941 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio, 600x600 pixels
943 application.GetScene().Add(imageView);
944 application.SendNotification();
945 application.Render();
947 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
948 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
953 int UtcDaliImageViewHeightForWidthBackground(void)
955 ToolkitTestApplication application;
957 int widthBackground = 100;
958 int heightBackground = 200;
960 ImageView imageView = ImageView::New();
962 imageView.SetProperty(Control::Property::BACKGROUND,
963 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
964 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
965 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
966 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}});
968 application.GetScene().Add(imageView);
969 application.SendNotification();
970 application.Render();
972 Control control = Control::DownCast(imageView);
973 DALI_TEST_CHECK(control);
974 DALI_TEST_EQUALS(imageView.GetHeightForWidth(123.f), control.GetHeightForWidth(123.f), TEST_LOCATION);
975 DALI_TEST_EQUALS(imageView.GetWidthForHeight(321.f), control.GetWidthForHeight(321.f), TEST_LOCATION);
980 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
982 ToolkitTestApplication application;
984 int widthBackground = 100;
985 int heightBackground = 200;
989 ImageView imageView = ImageView::New();
991 imageView.SetProperty(Control::Property::BACKGROUND,
992 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
993 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
994 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
995 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}}); // 1 to 2 ratio
997 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio
999 application.GetScene().Add(imageView);
1000 application.SendNotification();
1001 application.Render();
1003 DALI_TEST_EQUALS(imageView.GetHeightForWidth(width), (float)height, TEST_LOCATION);
1004 DALI_TEST_EQUALS(imageView.GetWidthForHeight(height), (float)width, TEST_LOCATION);
1009 int UtcDaliImageViewSetImageUrl(void)
1011 ToolkitTestApplication application;
1013 ImageView imageView = ImageView::New();
1014 imageView.SetImage(TEST_IMAGE_FILE_NAME);
1015 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
1017 imageView.SetImage(TEST_IMAGE_FILE_NAME2);
1018 TestUrl(imageView, TEST_IMAGE_FILE_NAME2);
1023 bool gResourceReadySignalFired = false;
1024 Vector3 gNaturalSize;
1026 void ResourceReadySignal(Control control)
1028 gResourceReadySignalFired = true;
1031 int UtcDaliImageViewCheckResourceReady(void)
1033 ToolkitTestApplication application;
1035 gResourceReadySignalFired = false;
1037 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1038 ImageView imageView = ImageView::New(TEST_GIF_FILE_NAME);
1040 imageView.SetProperty(Control::Property::BACKGROUND,
1041 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1042 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1043 {ImageVisual::Property::DESIRED_WIDTH, 100},
1044 {ImageVisual::Property::DESIRED_HEIGHT, 200}});
1046 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1048 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1050 application.GetScene().Add(imageView);
1052 // loading started, this waits for the loader thread
1053 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1055 application.SendNotification();
1056 application.Render(16);
1058 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1060 application.SendNotification();
1061 application.Render();
1063 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1065 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1070 int UtcDaliImageViewSetImageTypeChangesP(void)
1072 ToolkitTestApplication application;
1074 ImageView imageView = ImageView::New();
1075 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1077 application.GetScene().Add(imageView);
1081 Toolkit::Visual::Base visual;
1083 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1084 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1086 application.SendNotification();
1087 application.Render(16);
1089 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1091 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1092 DALI_TEST_CHECK(!visual); // Visual should be invalid
1095 imageView.SetImage("TEST_URL");
1097 application.SendNotification();
1098 application.Render(16);
1100 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1101 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1103 DALI_TEST_CHECK(value.Get(url)); // Value should NOT be empty
1104 DALI_TEST_CHECK(!value.Get(map)); // Value should be empty
1105 DALI_TEST_CHECK(visual); // Visual should be valid
1108 imageView.SetImage("");
1110 application.SendNotification();
1111 application.Render(16);
1113 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1114 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1116 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1118 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1119 DALI_TEST_CHECK(!visual); // Visual should be invalid
1121 // Set a URL in property map
1122 Property::Map propertyMap;
1123 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1124 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1126 application.SendNotification();
1127 application.Render(16);
1129 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1130 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1132 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1133 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1134 DALI_TEST_CHECK(visual); // Visual should be valid
1136 // Set a URL in property map again
1137 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1138 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
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 be empty
1147 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1148 DALI_TEST_CHECK(visual); // Visual should be valid
1150 // Set an empty URL in property map
1151 propertyMap[ImageVisual::Property::URL] = std::string();
1152 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1154 application.SendNotification();
1155 application.Render(16);
1157 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1158 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1160 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1161 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1162 DALI_TEST_CHECK(!visual); // Visual should be invalid
1164 // Set a URL in property map again
1165 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1166 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1168 application.SendNotification();
1169 application.Render(16);
1171 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1172 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1174 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1175 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1176 DALI_TEST_CHECK(visual); // Visual should be valid
1178 // Set an empty property map
1179 propertyMap.Clear();
1180 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1182 application.SendNotification();
1183 application.Render(16);
1185 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1186 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1188 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1189 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1190 DALI_TEST_CHECK(map.Empty()); // But PropertyMap should be empty
1191 DALI_TEST_CHECK(!visual); // Visual should be invalid
1196 int UtcDaliImageViewResourceUrlP(void)
1198 ToolkitTestApplication application;
1200 ImageView imageView = ImageView::New();
1201 DALI_TEST_CHECK(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>().empty());
1203 imageView.SetProperty(ImageView::Property::IMAGE, "TestString");
1204 DALI_TEST_EQUALS(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>(), "TestString", TEST_LOCATION);
1209 int UtcDaliImageViewReplaceImage(void)
1211 ToolkitTestApplication application;
1213 gResourceReadySignalFired = false;
1215 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1216 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1218 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1220 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1222 application.GetScene().Add(imageView);
1224 application.SendNotification();
1225 application.Render(16);
1227 // loading started, this waits for the loader thread for max 30 seconds
1228 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1230 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1232 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1234 gResourceReadySignalFired = false;
1236 imageView.SetImage(TEST_IMAGE_2);
1238 application.SendNotification();
1239 application.Render(16);
1241 // loading started, this waits for the loader thread for max 30 seconds
1242 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1244 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1246 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1248 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1253 void OnRelayoutOverride(Size size)
1255 gNaturalSize = size; // Size Relayout is using
1258 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1260 ToolkitTestApplication application;
1262 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1263 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1264 imageView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1266 DummyControl dummyControl = DummyControl::New(true);
1267 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1268 dummyControl.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
1270 dummyControl.Add(imageView);
1271 dummyImpl.SetRelayoutCallback(&OnRelayoutOverride);
1272 application.GetScene().Add(dummyControl);
1274 application.SendNotification();
1275 application.Render();
1277 // loading started, this waits for the loader thread for max 30 seconds
1278 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1280 DALI_TEST_EQUALS(gNaturalSize.width, 1024.0f, TEST_LOCATION);
1281 DALI_TEST_EQUALS(gNaturalSize.height, 1024.0f, TEST_LOCATION);
1283 gNaturalSize = Vector3::ZERO;
1285 imageView.SetImage(gImage_600_RGB);
1287 // Waiting for resourceReady so SendNotifcation not called here.
1289 // loading started, this waits for the loader thread for max 30 seconds
1290 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1292 // Trigger a potential relayout
1293 application.SendNotification();
1294 application.Render();
1296 DALI_TEST_EQUALS(gNaturalSize.width, 600.0f, TEST_LOCATION);
1297 DALI_TEST_EQUALS(gNaturalSize.height, 600.0f, TEST_LOCATION);
1302 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1304 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1306 ToolkitTestApplication application;
1308 gResourceReadySignalFired = false;
1310 Property::Map imageMap;
1312 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1313 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1315 tet_infoline("Creating ImageView without URL so image does not start loading");
1316 ImageView imageView = ImageView::New();
1317 tet_infoline("Connect to image loaded signal before setting image");
1318 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1319 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1320 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1322 // loading started, this waits for the loader thread
1323 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1325 application.SendNotification();
1326 application.Render(16);
1328 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1333 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1335 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1337 ToolkitTestApplication application;
1339 gResourceReadySignalFired = false;
1341 Property::Map imageMap;
1343 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1344 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1346 ImageView imageView = ImageView::New();
1347 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1348 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1350 // loading started, this waits for the loader thread
1351 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1353 application.SendNotification();
1354 application.Render(16);
1356 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1357 gResourceReadySignalFired = false;
1359 ImageView imageViewWithExistingImage = ImageView::New();
1360 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1361 imageViewWithExistingImage.SetProperty(ImageView::Property::IMAGE, imageMap);
1363 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1368 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1370 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1372 ToolkitTestApplication application;
1374 gResourceReadySignalFired = false;
1376 Property::Map imageImmediateLoadingMap;
1377 imageImmediateLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1378 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1380 tet_infoline("Immediate load an image");
1381 ImageView imageView = ImageView::New();
1382 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1383 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
1385 // loading started, this waits for the loader thread
1386 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1388 application.SendNotification();
1389 application.Render(16);
1391 tet_infoline("Check image loaded");
1392 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1393 gResourceReadySignalFired = false;
1395 tet_infoline("Create another ImageView with the same URL");
1396 ImageView imageViewWithExistingImage = ImageView::New(gImage_34_RGBA);
1397 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1398 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1400 application.GetScene().Add(imageViewWithExistingImage);
1402 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1407 int UtcDaliImageViewPaddingProperty(void)
1409 ToolkitTestApplication application;
1411 ImageView imageView = ImageView::New();
1412 Property::Map imagePropertyMap;
1413 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1414 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
1415 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1416 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1417 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1418 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1419 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1420 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1421 application.GetScene().Add(imageView);
1423 application.SendNotification();
1424 application.Render();
1426 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1428 ImageView childImage = ImageView::New();
1429 childImage.SetBackgroundColor(Color::BLACK);
1430 childImage.SetProperty(Actor::Property::SIZE, Vector2(10.f, 10.f));
1431 imageView.Add(childImage);
1433 application.SendNotification();
1434 application.Render();
1436 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1437 DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
1439 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1440 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1441 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1442 Property::Map resultMap;
1443 imageVisual.CreatePropertyMap(resultMap);
1445 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1446 DALI_TEST_CHECK(transformValue);
1447 Property::Map* retMap = transformValue->GetMap();
1448 DALI_TEST_CHECK(retMap);
1450 // Image Visual should be positioned depending on ImageView's padding
1451 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1456 int UtcDaliImageViewPaddingProperty02(void)
1458 ToolkitTestApplication application;
1460 ImageView imageView = ImageView::New();
1461 Property::Map imagePropertyMap;
1462 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1463 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1464 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1465 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1466 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1467 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1468 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1469 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1470 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1471 application.GetScene().Add(imageView);
1473 application.SendNotification();
1474 application.Render();
1476 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1478 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1479 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1480 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1481 Property::Map resultMap;
1482 imageVisual.CreatePropertyMap(resultMap);
1484 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1485 DALI_TEST_CHECK(transformValue);
1486 Property::Map* retMap = transformValue->GetMap();
1487 DALI_TEST_CHECK(retMap);
1489 // Image Visual should be positioned depending on ImageView's padding
1490 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1495 int UtcDaliImageViewPaddingProperty03(void)
1497 tet_infoline("Test Setting Image Padding then removing it.");
1499 ToolkitTestApplication application;
1501 ImageView imageView = ImageView::New();
1502 Property::Map imagePropertyMap;
1503 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1504 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1505 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1506 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1507 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1508 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1509 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1510 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1511 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1512 application.GetScene().Add(imageView);
1514 application.SendNotification();
1515 application.Render();
1517 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1519 tet_infoline("Remove Padding and test Visual is position correctly");
1521 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1523 application.SendNotification();
1524 application.Render();
1526 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1527 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1528 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1529 Property::Map resultMap;
1530 imageVisual.CreatePropertyMap(resultMap);
1532 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1533 DALI_TEST_CHECK(transformValue);
1534 Property::Map* retMap = transformValue->GetMap();
1535 DALI_TEST_CHECK(retMap);
1537 // Image Visual should be positioned depending on ImageView's padding
1538 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1543 int UtcDaliImageViewPaddingProperty04(void)
1545 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1547 ToolkitTestApplication application;
1549 ImageView imageView = ImageView::New();
1550 Property::Map imagePropertyMap;
1551 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1552 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1553 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1554 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1555 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FILL;
1556 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1557 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1558 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1559 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1560 application.GetScene().Add(imageView);
1562 application.SendNotification();
1563 application.Render();
1565 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1567 tet_infoline("Remove Padding and test Visual is position correctly");
1569 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1571 application.SendNotification();
1572 application.Render();
1574 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1575 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1576 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1577 Property::Map resultMap;
1578 imageVisual.CreatePropertyMap(resultMap);
1580 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1581 DALI_TEST_CHECK(transformValue);
1582 Property::Map* retMap = transformValue->GetMap();
1583 DALI_TEST_CHECK(retMap);
1585 // Image Visual should be positioned depending on ImageView's padding
1586 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1591 int UtcDaliImageViewTransformTest01(void)
1593 tet_infoline("Test Setting a offset transform on the ImageView");
1595 ToolkitTestApplication application;
1597 ImageView imageView = ImageView::New();
1598 Property::Map imagePropertyMap;
1599 imagePropertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE)
1600 .Add(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/Kid1.svg")
1601 .Add(ImageVisual::Property::DESIRED_WIDTH, 120)
1602 .Add(ImageVisual::Property::DESIRED_HEIGHT, 120)
1603 .Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL)
1604 .Add(Visual::Property::TRANSFORM,
1605 Property::Map().Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1606 Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE))
1607 .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(8, 8)));
1609 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1610 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1611 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1612 application.GetScene().Add(imageView);
1614 application.SendNotification();
1615 application.Render();
1617 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1618 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1619 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1620 Property::Map resultMap;
1621 imageVisual.CreatePropertyMap(resultMap);
1623 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1624 DALI_TEST_CHECK(transformValue);
1625 Property::Map* retMap = transformValue->GetMap();
1626 DALI_TEST_CHECK(retMap);
1628 // Image Visual should be positioned depending on ImageView's padding
1629 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(8, 8), TEST_LOCATION);
1630 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);
1635 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1637 ToolkitTestApplication application;
1639 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1640 ImageView imageView = ImageView::New();
1641 Property::Map imageMap;
1642 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1643 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_34_RGBA;
1644 imageMap[Toolkit::ImageVisual::Property::ATLASING] = true;
1645 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1646 application.GetScene().Add(imageView);
1648 // Trigger a potential relayout
1649 application.SendNotification();
1650 application.Render();
1652 Vector3 naturalSize = imageView.GetNaturalSize();
1654 DALI_TEST_EQUALS(naturalSize.width, 34.0f, TEST_LOCATION);
1655 DALI_TEST_EQUALS(naturalSize.height, 34.0f, TEST_LOCATION);
1660 int UtcDaliImageViewFillMode(void)
1662 ToolkitTestApplication application;
1664 tet_infoline("Create an ImageVisual without padding and set the fill-mode to fill");
1666 ImageView imageView = ImageView::New();
1667 Property::Map imageMap;
1668 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1669 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB);
1670 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL);
1672 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1674 application.GetScene().Add(imageView);
1676 // Trigger a potential relayout
1677 application.SendNotification();
1678 application.Render();
1680 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1681 Property::Map returnedMap;
1682 visual.CreatePropertyMap(returnedMap);
1684 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1685 DALI_TEST_CHECK(value);
1686 Property::Map* map = value->GetMap();
1687 DALI_TEST_CHECK(map);
1689 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1690 DALI_TEST_CHECK(value);
1691 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION);
1693 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1694 DALI_TEST_CHECK(value);
1695 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1700 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1702 ToolkitTestApplication application;
1704 tet_infoline("Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )");
1705 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1707 ImageView imageView = ImageView::New();
1708 Property::Map imageMap;
1709 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1710 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1711 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
1713 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1714 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1716 application.GetScene().Add(imageView);
1718 // Trigger a potential relayout
1719 application.SendNotification();
1720 application.Render();
1722 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1723 Property::Map returnedMap;
1724 visual.CreatePropertyMap(returnedMap);
1726 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1727 DALI_TEST_CHECK(value);
1728 Property::Map* map = value->GetMap();
1729 DALI_TEST_CHECK(map);
1732 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1733 DALI_TEST_CHECK(value);
1734 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION);
1736 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1737 DALI_TEST_CHECK(value);
1738 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1740 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1741 DALI_TEST_CHECK(value);
1742 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
1747 int UtcDaliImageViewFittingModesFill(void)
1749 ToolkitTestApplication application;
1751 tet_infoline("Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )");
1752 tet_infoline(" There should be no need to change the transform, only size is changed to fit view");
1754 ImageView imageView = ImageView::New();
1755 Property::Map imageMap;
1756 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1757 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1758 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL);
1760 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1761 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1763 application.GetScene().Add(imageView);
1765 // Trigger a potential relayout
1766 application.SendNotification();
1767 application.Render();
1769 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1770 Property::Map returnedMap;
1771 visual.CreatePropertyMap(returnedMap);
1773 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1774 DALI_TEST_CHECK(value);
1775 Property::Map* map = value->GetMap();
1776 DALI_TEST_CHECK(map);
1778 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1779 DALI_TEST_CHECK(value);
1780 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Change the internal size according to the image view size
1782 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1783 DALI_TEST_CHECK(value);
1784 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1786 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1787 DALI_TEST_CHECK(value);
1788 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1793 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1795 ToolkitTestApplication application;
1797 tet_infoline("Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )");
1798 tet_infoline(" offset or size is the same as view, but adjust internally using pixelArea ");
1800 ImageView imageView = ImageView::New();
1801 Property::Map imageMap;
1802 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1803 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1804 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO);
1806 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1807 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 500));
1809 application.GetScene().Add(imageView);
1811 // Trigger a potential relayout
1812 application.SendNotification();
1813 application.Render();
1815 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1816 Property::Map returnedMap;
1817 visual.CreatePropertyMap(returnedMap);
1819 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1820 DALI_TEST_CHECK(value);
1821 Property::Map* map = value->GetMap();
1822 DALI_TEST_CHECK(map);
1825 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1826 DALI_TEST_CHECK(value);
1827 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 500), TEST_LOCATION); // Change the internal size according to the image view size
1829 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1830 DALI_TEST_CHECK(value);
1831 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1833 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1834 DALI_TEST_CHECK(value);
1835 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1840 int UtcDaliImageViewFittingModesCenter01(void)
1842 ToolkitTestApplication application;
1844 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [700,700] )");
1845 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1847 ImageView imageView = ImageView::New();
1848 Property::Map imageMap;
1849 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1850 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1851 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1853 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1854 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1856 application.GetScene().Add(imageView);
1858 // Trigger a potential relayout
1859 application.SendNotification();
1860 application.Render();
1862 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1863 Property::Map returnedMap;
1864 visual.CreatePropertyMap(returnedMap);
1866 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1867 DALI_TEST_CHECK(value);
1868 Property::Map* map = value->GetMap();
1869 DALI_TEST_CHECK(map);
1871 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1872 DALI_TEST_CHECK(value);
1873 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1875 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1876 DALI_TEST_CHECK(value);
1877 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1879 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1880 DALI_TEST_CHECK(value);
1881 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1886 int UtcDaliImageViewFittingModesCenter02(void)
1888 ToolkitTestApplication application;
1890 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [500,500] )");
1891 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1893 ImageView imageView = ImageView::New();
1894 Property::Map imageMap;
1895 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1896 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1897 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1899 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1900 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1902 application.GetScene().Add(imageView);
1904 // Trigger a potential relayout
1905 application.SendNotification();
1906 application.Render();
1908 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1909 Property::Map returnedMap;
1910 visual.CreatePropertyMap(returnedMap);
1912 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1913 DALI_TEST_CHECK(value);
1914 Property::Map* map = value->GetMap();
1915 DALI_TEST_CHECK(map);
1917 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1918 DALI_TEST_CHECK(value);
1919 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1921 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1922 DALI_TEST_CHECK(value);
1923 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1925 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1926 DALI_TEST_CHECK(value);
1927 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1932 int UtcDaliImageViewFittingModesFitHeight01(void)
1934 ToolkitTestApplication application;
1936 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )");
1938 ImageView imageView = ImageView::New();
1939 Property::Map imageMap;
1940 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1941 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1942 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1944 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1945 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1947 application.GetScene().Add(imageView);
1949 // Trigger a potential relayout
1950 application.SendNotification();
1951 application.Render();
1953 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1954 Property::Map returnedMap;
1955 visual.CreatePropertyMap(returnedMap);
1957 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1958 DALI_TEST_CHECK(value);
1959 Property::Map* map = value->GetMap();
1960 DALI_TEST_CHECK(map);
1962 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1963 DALI_TEST_CHECK(value);
1964 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 700), TEST_LOCATION); // Change the internal size according to the image view size
1966 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1967 DALI_TEST_CHECK(value);
1968 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1970 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1971 DALI_TEST_CHECK(value);
1972 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1977 int UtcDaliImageViewFittingModesFitHeight02(void)
1979 ToolkitTestApplication application;
1981 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )");
1983 ImageView imageView = ImageView::New();
1984 Property::Map imageMap;
1985 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1986 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
1987 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1989 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1990 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
1992 application.GetScene().Add(imageView);
1994 // Trigger a potential relayout
1995 application.SendNotification();
1996 application.Render();
1998 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1999 Property::Map returnedMap;
2000 visual.CreatePropertyMap(returnedMap);
2002 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2003 DALI_TEST_CHECK(value);
2004 Property::Map* map = value->GetMap();
2005 DALI_TEST_CHECK(map);
2007 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2008 DALI_TEST_CHECK(value);
2009 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2011 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2012 DALI_TEST_CHECK(value);
2013 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2015 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2016 DALI_TEST_CHECK(value);
2017 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2022 int UtcDaliImageViewFittingModesFitWidth01(void)
2024 ToolkitTestApplication application;
2026 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )");
2028 ImageView imageView = ImageView::New();
2029 Property::Map imageMap;
2030 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2031 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2032 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2034 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2035 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2037 application.GetScene().Add(imageView);
2039 // Trigger a potential relayout
2040 application.SendNotification();
2041 application.Render();
2043 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2044 Property::Map returnedMap;
2045 visual.CreatePropertyMap(returnedMap);
2047 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2048 DALI_TEST_CHECK(value);
2049 Property::Map* map = value->GetMap();
2050 DALI_TEST_CHECK(map);
2052 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2053 DALI_TEST_CHECK(value);
2054 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2056 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2057 DALI_TEST_CHECK(value);
2058 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2060 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2061 DALI_TEST_CHECK(value);
2062 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
2067 int UtcDaliImageViewFittingModesFitWidth02(void)
2069 ToolkitTestApplication application;
2071 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )");
2073 ImageView imageView = ImageView::New();
2074 Property::Map imageMap;
2075 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2076 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2077 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2079 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2080 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2082 application.GetScene().Add(imageView);
2084 // Trigger a potential relayout
2085 application.SendNotification();
2086 application.Render();
2088 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2089 Property::Map returnedMap;
2090 visual.CreatePropertyMap(returnedMap);
2092 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2093 DALI_TEST_CHECK(value);
2094 Property::Map* map = value->GetMap();
2095 DALI_TEST_CHECK(map);
2097 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2098 DALI_TEST_CHECK(value);
2099 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 600), TEST_LOCATION); // Change the internal size according to the image view size
2101 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2102 DALI_TEST_CHECK(value);
2103 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2105 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2106 DALI_TEST_CHECK(value);
2107 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2112 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2114 ToolkitTestApplication application;
2116 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2118 ImageView imageView = ImageView::New();
2120 // 1. Render using FittingMode::SHRINK_TO_FIT
2121 Property::Map imageMap;
2122 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2123 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2124 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2126 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2127 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2129 application.GetScene().Add(imageView);
2131 // Trigger a potential relayout
2132 application.SendNotification();
2133 application.Render();
2135 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2136 Property::Map returnedMap;
2137 visual.CreatePropertyMap(returnedMap);
2139 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2140 DALI_TEST_CHECK(value);
2141 Property::Map* map = value->GetMap();
2142 DALI_TEST_CHECK(map);
2144 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2145 DALI_TEST_CHECK(value);
2146 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2148 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2149 DALI_TEST_CHECK(value);
2150 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2152 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2153 DALI_TEST_CHECK(value);
2154 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2156 // 2. Render again using DevelVisaul::CENTER
2157 Property::Map imageMap2;
2158 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2159 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2160 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2162 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2163 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2165 application.GetScene().Add(imageView);
2167 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2169 // Trigger a potential relayout
2170 application.SendNotification();
2171 application.Render();
2173 returnedMap.Clear();
2174 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2176 visual.CreatePropertyMap(returnedMap);
2178 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2179 DALI_TEST_CHECK(value);
2180 map = value->GetMap();
2181 DALI_TEST_CHECK(map);
2183 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2184 DALI_TEST_CHECK(value);
2185 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2187 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2188 DALI_TEST_CHECK(value);
2189 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2191 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2192 DALI_TEST_CHECK(value);
2193 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2195 // 3. Render again using before fittingMode
2196 Property::Map imageMap3;
2197 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2198 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2199 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2201 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2202 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2204 application.GetScene().Add(imageView);
2206 // Trigger a potential relayout
2207 application.SendNotification();
2208 application.Render();
2210 returnedMap.Clear();
2211 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2212 visual.CreatePropertyMap(returnedMap);
2214 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2215 DALI_TEST_CHECK(value);
2216 map = value->GetMap();
2217 DALI_TEST_CHECK(map);
2219 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2220 DALI_TEST_CHECK(value);
2221 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2223 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2224 DALI_TEST_CHECK(value);
2225 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2227 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2228 DALI_TEST_CHECK(value);
2229 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2234 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2236 ToolkitTestApplication application;
2238 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2240 ImageView imageView = ImageView::New();
2242 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2243 Property::Map imageMap;
2244 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2245 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2246 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2248 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2249 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2251 application.GetScene().Add(imageView);
2253 // Trigger a potential relayout
2254 application.SendNotification();
2255 application.Render();
2257 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2258 Property::Map returnedMap;
2259 visual.CreatePropertyMap(returnedMap);
2261 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2262 DALI_TEST_CHECK(value);
2263 Property::Map* map = value->GetMap();
2264 DALI_TEST_CHECK(map);
2266 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2267 DALI_TEST_CHECK(value);
2268 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2270 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2271 DALI_TEST_CHECK(value);
2272 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2274 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2275 DALI_TEST_CHECK(value);
2276 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2278 // 2. Render again using DevelVisaul::CENTER
2279 Property::Map imageMap2;
2280 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2281 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2282 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2284 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2285 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2287 application.GetScene().Add(imageView);
2289 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2291 // Trigger a potential relayout
2292 application.SendNotification();
2293 application.Render();
2295 returnedMap.Clear();
2296 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2298 visual.CreatePropertyMap(returnedMap);
2300 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2301 DALI_TEST_CHECK(value);
2302 map = value->GetMap();
2303 DALI_TEST_CHECK(map);
2305 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2306 DALI_TEST_CHECK(value);
2307 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2309 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2310 DALI_TEST_CHECK(value);
2311 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2313 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2314 DALI_TEST_CHECK(value);
2315 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2317 // 3. Render again using before fittingMode
2318 Property::Map imageMap3;
2319 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2320 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2321 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2323 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2324 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2326 application.GetScene().Add(imageView);
2328 // Trigger a potential relayout
2329 application.SendNotification();
2330 application.Render();
2332 returnedMap.Clear();
2333 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2334 visual.CreatePropertyMap(returnedMap);
2336 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2337 DALI_TEST_CHECK(value);
2338 map = value->GetMap();
2339 DALI_TEST_CHECK(map);
2341 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2342 DALI_TEST_CHECK(value);
2343 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2345 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2346 DALI_TEST_CHECK(value);
2347 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2349 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2350 DALI_TEST_CHECK(value);
2351 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2356 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2358 ToolkitTestApplication application;
2360 tet_infoline("Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )");
2362 ImageView imageView = ImageView::New();
2363 Property::Map imageMap;
2364 imageMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE);
2365 imageMap.Add(Toolkit::ImageVisual::Property::URL, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME); // 249x169 image
2367 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2368 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
2370 application.GetScene().Add(imageView);
2372 // Trigger a potential relayout
2373 application.SendNotification();
2374 application.Render();
2376 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2377 Property::Map returnedMap;
2378 visual.CreatePropertyMap(returnedMap);
2380 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2381 DALI_TEST_CHECK(value);
2382 Property::Map* map = value->GetMap();
2383 DALI_TEST_CHECK(map);
2385 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2386 DALI_TEST_CHECK(value);
2387 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Relative size so will take up 100%
2389 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2390 DALI_TEST_CHECK(value);
2391 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2393 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2394 DALI_TEST_CHECK(value);
2395 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2400 int UtcDaliImageViewCustomShader(void)
2402 ToolkitTestApplication application;
2404 // Set a custom shader with an image url
2406 Property::Map properties;
2407 Property::Map shader;
2408 const std::string vertexShader = "Foobar";
2409 const std::string fragmentShader = "Foobar";
2410 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2411 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2413 properties[Visual::Property::TYPE] = Visual::IMAGE;
2414 properties[Visual::Property::SHADER] = shader;
2415 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2417 ImageView imageView = ImageView::New();
2418 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2420 application.GetScene().Add(imageView);
2422 application.SendNotification();
2423 application.Render();
2425 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2427 Renderer renderer = imageView.GetRendererAt(0);
2428 Shader shader2 = renderer.GetShader();
2429 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2430 Property::Map* map = value.GetMap();
2431 DALI_TEST_CHECK(map);
2433 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2434 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2436 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2437 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2440 // Set a custom shader after setting an image url
2442 Property::Map properties;
2443 Property::Map shader;
2444 const std::string vertexShader = "Foobar";
2445 const std::string fragmentShader = "Foobar";
2446 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2447 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2449 properties[Visual::Property::SHADER] = shader;
2451 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
2452 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2454 application.GetScene().Add(imageView);
2456 application.SendNotification();
2457 application.Render();
2459 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2461 Renderer renderer = imageView.GetRendererAt(0);
2462 Shader shader2 = renderer.GetShader();
2463 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2464 Property::Map* map = value.GetMap();
2465 DALI_TEST_CHECK(map);
2467 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2468 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2470 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2471 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2474 // Set a custom shader before setting an image url
2476 Property::Map properties;
2477 Property::Map shader;
2478 const std::string vertexShader = "Foobar";
2479 const std::string fragmentShader = "Foobar";
2480 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2481 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2483 properties[Visual::Property::SHADER] = shader;
2485 ImageView imageView = ImageView::New();
2486 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2487 imageView.SetProperty(ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME);
2489 application.GetScene().Add(imageView);
2491 application.SendNotification();
2492 application.Render();
2493 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2495 Renderer renderer = imageView.GetRendererAt(0);
2496 Shader shader2 = renderer.GetShader();
2497 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2498 Property::Map* map = value.GetMap();
2499 DALI_TEST_CHECK(map);
2501 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2502 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2504 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2505 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2508 // Set a custom shader after setting a property map
2510 Property::Map properties;
2511 Property::Map shader;
2512 const std::string vertexShader = "Foobar";
2513 const std::string fragmentShader = "Foobar";
2514 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2515 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2517 properties[Visual::Property::SHADER] = shader;
2519 Property::Map properties1;
2520 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2521 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2523 ImageView imageView = ImageView::New();
2524 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2525 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2527 application.GetScene().Add(imageView);
2529 application.SendNotification();
2530 application.Render();
2531 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2533 Renderer renderer = imageView.GetRendererAt(0);
2534 Shader shader2 = renderer.GetShader();
2535 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2536 Property::Map* map = value.GetMap();
2537 DALI_TEST_CHECK(map);
2539 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2540 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2542 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2543 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2546 // Set a custom shader before setting a property map
2548 Property::Map properties;
2549 Property::Map shader;
2550 const std::string vertexShader = "Foobar";
2551 const std::string fragmentShader = "Foobar";
2552 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2553 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2555 properties[Visual::Property::SHADER] = shader;
2557 Property::Map properties1;
2558 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2559 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2561 ImageView imageView = ImageView::New();
2562 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2563 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2565 application.GetScene().Add(imageView);
2567 application.SendNotification();
2568 application.Render();
2569 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2571 Renderer renderer = imageView.GetRendererAt(0);
2572 Shader shader2 = renderer.GetShader();
2573 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2574 Property::Map* map = value.GetMap();
2575 DALI_TEST_CHECK(map);
2577 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2578 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2580 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2581 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2589 static int gFailCounter = 0;
2590 const int MAX_RETRIES(3);
2592 void ReloadImage(ImageView imageView)
2594 Property::Map imageImmediateLoadingMap;
2595 imageImmediateLoadingMap[ImageVisual::Property::URL] = "Non-existant-image.jpg";
2596 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
2598 tet_infoline("Immediate load an image");
2599 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
2602 void ResourceFailedReload(Control control)
2605 if(gFailCounter < MAX_RETRIES)
2607 ReloadImage(ImageView::DownCast(control));
2612 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2614 tet_infoline("Test reloading failed image from within signal handler.");
2616 ToolkitTestApplication application;
2620 ImageView imageView = ImageView::New();
2621 imageView.ResourceReadySignal().Connect(&ResourceFailedReload);
2622 DALI_TEST_EQUALS(gFailCounter, 0, TEST_LOCATION);
2623 ReloadImage(imageView);
2625 // loading started, this waits for the loader thread to complete
2626 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2627 application.SendNotification();
2629 DALI_TEST_EQUALS(gFailCounter, 1, TEST_LOCATION);
2631 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2632 application.SendNotification();
2634 DALI_TEST_EQUALS(gFailCounter, 2, TEST_LOCATION);
2636 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2637 application.SendNotification();
2638 DALI_TEST_EQUALS(gFailCounter, 3, TEST_LOCATION);
2643 int UtcDaliImageViewLoadRemoteSVG(void)
2645 tet_infoline("Test load from a remote server.");
2647 ToolkitTestApplication application;
2650 Toolkit::ImageView imageView;
2651 imageView = Toolkit::ImageView::New();
2652 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2653 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2654 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2655 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2656 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2658 application.GetScene().Add(imageView);
2660 DALI_TEST_CHECK(imageView);
2662 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2664 application.SendNotification();
2666 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2668 application.SendNotification();
2669 application.Render();
2671 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2676 Toolkit::ImageView imageView;
2677 imageView = Toolkit::ImageView::New();
2678 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2679 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2680 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2681 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2683 application.GetScene().Add(imageView);
2685 DALI_TEST_CHECK(imageView);
2687 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2689 application.SendNotification();
2691 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2693 application.SendNotification();
2694 application.Render();
2696 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2702 int UtcDaliImageViewSyncSVGLoading(void)
2704 ToolkitTestApplication application;
2706 tet_infoline("ImageView Testing SVG image sync loading");
2708 // Sync loading, automatic atlasing for small size image
2710 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2712 callStack.Enable(true);
2714 ImageView imageView = ImageView::New();
2716 // Sync loading is used
2717 Property::Map syncLoadingMap;
2718 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2719 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2720 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2721 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2723 application.GetScene().Add(imageView);
2724 DALI_TEST_CHECK(imageView);
2726 application.SendNotification();
2727 application.Render(16);
2728 Vector3 naturalSize = imageView.GetNaturalSize();
2730 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2731 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2736 int UtcDaliImageViewAsyncSVGLoading(void)
2738 ToolkitTestApplication application;
2740 tet_infoline("ImageView Testing SVG image async loading");
2742 // Sync loading, automatic atlasing for small size image
2744 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2746 callStack.Enable(true);
2748 ImageView imageView = ImageView::New();
2750 // Sync loading is used
2751 Property::Map syncLoadingMap;
2752 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2753 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2754 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2755 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2757 application.GetScene().Add(imageView);
2758 DALI_TEST_CHECK(imageView);
2760 application.SendNotification();
2761 application.Render(16);
2762 Vector3 naturalSize = imageView.GetNaturalSize();
2764 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2765 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2770 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2772 ToolkitTestApplication application;
2774 tet_infoline("ImageView Testing SVG image async loading");
2776 // Sync loading, automatic atlasing for small size image
2778 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2780 callStack.Enable(true);
2782 ImageView imageView = ImageView::New();
2784 // Sync loading is used
2785 Property::Map syncLoadingMap;
2786 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2787 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2789 // Check to set invalid value
2790 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2791 // Check if error log is outputted when setting other value like string.
2792 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2793 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5));
2794 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2796 application.GetScene().Add(imageView);
2797 DALI_TEST_CHECK(imageView);
2799 application.SendNotification();
2800 application.Render(16);
2801 Vector3 naturalSize = imageView.GetNaturalSize();
2802 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2803 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2805 Property::Value value = imageView.GetProperty(ImageView::Property::IMAGE);
2806 Property::Map* map = value.GetMap();
2807 DALI_TEST_CHECK(map);
2809 Property::Value* sync = map->Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING);
2810 DALI_TEST_CHECK(sync);
2811 DALI_TEST_EQUALS(false, sync->Get<bool>(), TEST_LOCATION);
2816 int UtcDaliImageViewSvgLoadingFailure(void)
2818 ToolkitTestApplication application;
2820 TestGlAbstraction& gl = application.GetGlAbstraction();
2821 TraceCallStack& textureTrace = gl.GetTextureTrace();
2822 textureTrace.Enable(true);
2824 // Local svg file - invalid file path
2826 gResourceReadySignalFired = false;
2828 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2829 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2830 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2832 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2834 application.GetScene().Add(imageView);
2836 application.SendNotification();
2837 application.Render(16);
2839 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2840 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2841 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2843 // Should be shown a broken image
2844 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2845 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2848 // Local svg file - invalid file path without size set
2850 gResourceReadySignalFired = false;
2851 textureTrace.Reset();
2853 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2854 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2856 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2858 application.GetScene().Add(imageView);
2860 application.SendNotification();
2861 application.Render(16);
2863 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2864 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2865 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2867 // Should be shown a broken image
2868 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2869 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2872 // Local svg file - invalid file
2874 gResourceReadySignalFired = false;
2875 textureTrace.Reset();
2877 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.svg");
2878 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2879 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2881 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2883 application.GetScene().Add(imageView);
2885 application.SendNotification();
2886 application.Render(16);
2888 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2889 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2890 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2892 // Should be shown a broken image
2893 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2894 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2899 gResourceReadySignalFired = false;
2900 textureTrace.Reset();
2902 ImageView imageView = ImageView::New("https://bar.org/foobar.svg");
2903 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2904 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2906 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2908 application.GetScene().Add(imageView);
2910 application.SendNotification();
2912 // loading started, this waits for the loader thread
2913 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2915 application.SendNotification();
2916 application.Render(16);
2918 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2919 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2920 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2922 // Should be shown a broken image
2923 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2924 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2927 // Remote svg file without size set
2929 gResourceReadySignalFired = false;
2930 textureTrace.Reset();
2932 ImageView imageView = ImageView::New("https://bar.org/foobar.svg");
2933 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2935 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2937 application.GetScene().Add(imageView);
2939 application.SendNotification();
2941 // loading started, this waits for the loader thread
2942 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2944 application.SendNotification();
2945 application.Render(16);
2947 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2948 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2949 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2951 // Should be shown a broken image
2952 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2953 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2959 int UtcDaliImageViewSvgRasterizationFailure(void)
2961 ToolkitTestApplication application;
2963 gResourceReadySignalFired = false;
2965 TestGlAbstraction& gl = application.GetGlAbstraction();
2966 TraceCallStack& textureTrace = gl.GetTextureTrace();
2967 textureTrace.Enable(true);
2969 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid1.svg");
2970 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2971 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2973 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2975 application.GetScene().Add(imageView);
2977 application.SendNotification();
2979 // loading started, this waits for the loader thread
2980 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2982 application.SendNotification();
2983 application.Render(16);
2985 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2986 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2987 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2989 // Should be shown a broken image
2990 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2991 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2996 int UtcDaliImageViewTVGLoading(void)
2998 ToolkitTestApplication application;
3000 tet_infoline("ImageView Testing TVG image loading");
3003 ImageView imageView = ImageView::New();
3005 imageView.SetImage(TEST_RESOURCE_DIR "/test.tvg");
3007 application.GetScene().Add(imageView);
3008 DALI_TEST_CHECK(imageView);
3009 Vector3 naturalSize = imageView.GetNaturalSize();
3011 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3012 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3017 int UtcDaliImageViewImageLoadFailure01(void)
3019 ToolkitTestApplication application;
3021 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3022 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3023 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3024 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3026 std::string brokenUrl;
3027 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3028 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3030 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3031 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3033 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3034 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3036 ImageView imageView = ImageView::New("invalidUrl.png");
3037 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3039 application.GetScene().Add(imageView);
3040 application.SendNotification();
3041 application.Render(16);
3043 // loading started, this waits for the loader thread
3044 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3049 int UtcDaliImageViewImageLoadFailure02(void)
3051 ToolkitTestApplication application;
3053 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3054 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
3055 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3056 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3058 std::string brokenUrl;
3059 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3060 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
3062 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3063 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3065 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3066 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3068 ImageView imageView = ImageView::New("invalidUrl.png");
3069 imageView.SetProperty(Actor::Property::SIZE, Vector2(30.f, 30.f));
3070 application.GetScene().Add(imageView);
3071 application.SendNotification();
3072 application.Render(16);
3074 // loading started, this waits for the loader thread
3075 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3080 int UtcDaliImageViewImageLoadFailure03(void)
3082 ToolkitTestApplication application;
3084 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3085 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
3086 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
3088 std::string brokenUrl;
3089 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3090 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3092 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3093 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3095 ImageView imageView = ImageView::New("invalidUrl.png");
3096 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3097 application.GetScene().Add(imageView);
3098 application.SendNotification();
3099 application.Render(16);
3101 // loading started, this waits for the loader thread
3102 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3107 int UtcDaliImageViewImageLoadFailure04(void)
3109 ToolkitTestApplication application;
3111 ImageView imageView = ImageView::New("invalidUrl.png");
3112 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3113 application.GetScene().Add(imageView);
3114 application.SendNotification();
3115 application.Render(16);
3117 // loading started, this waits for the loader thread
3118 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3120 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3121 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3122 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3123 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3125 ImageView imageView2 = ImageView::New("invalidUrl.png");
3126 imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3127 application.GetScene().Add(imageView2);
3129 std::string brokenUrl;
3130 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3131 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3133 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3134 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3136 application.SendNotification();
3137 application.Render(16);
3139 // loading started, this waits for the loader thread
3140 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3142 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3144 ImageView imageView3 = ImageView::New("invalidUrl.png");
3145 imageView3.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3146 application.GetScene().Add(imageView3);
3148 application.SendNotification();
3149 application.Render(16);
3151 // loading started, this waits for the loader thread
3152 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3159 static int gResourceReadySignalCounter = 0;
3161 void OnResourceReadySignal01(Control control)
3163 gResourceReadySignalCounter++;
3165 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3167 if(gResourceReadySignalCounter == 1)
3170 // It makes the first new visual be deleted immediately
3171 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3172 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3175 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3177 // Make the resource ready immediately
3178 control[ImageView::Property::IMAGE] = gImage_600_RGB;
3182 void OnResourceReadySignal02(Control control)
3184 if(++gResourceReadySignalCounter == 1)
3186 // It makes the first new visual be deleted immediately
3187 // The first image will not be loaded.
3188 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB).Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3189 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3193 ImageView gImageView1;
3194 ImageView gImageView2;
3195 ImageView gImageView3;
3196 ImageView gImageView4;
3198 void OnResourceReadySignal03(Control control)
3200 if(gResourceReadySignalCounter == 0)
3203 // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3204 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3206 // 2. Load a new image
3207 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3209 // 3. Use the new image again
3210 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3211 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3213 else if(gResourceReadySignalCounter == 1)
3215 // This is called from TextureManager::ProcessQueuedTextures().
3216 gImageView1.Unparent();
3217 gImageView1.Reset();
3219 gResourceReadySignalCounter++;
3222 void OnSimpleResourceReadySignal(Control control)
3224 // simply increate counter
3225 gResourceReadySignalCounter++;
3228 int gResourceReadySignal04ComesOrder = 0;
3230 void OnResourceReadySignal04(Control control)
3232 gResourceReadySignalCounter++;
3233 tet_printf("rc %d\n", gResourceReadySignalCounter);
3234 if(gResourceReadySignalCounter == 1)
3236 auto scene = gImageView1.GetParent();
3238 // Request load something
3239 // We hope this request result is return later than gImageView2.
3240 gImageView3 = ImageView::New(TEST_IMAGE_1);
3241 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3242 scene.Add(gImageView3);
3243 gImageView4 = ImageView::New(TEST_IMAGE_2);
3244 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3245 scene.Add(gImageView4);
3247 if(control == gImageView1)
3249 gResourceReadySignal04ComesOrder = 1;
3253 gResourceReadySignal04ComesOrder = 2;
3256 if(gResourceReadySignalCounter == 2)
3258 if(gResourceReadySignal04ComesOrder == 1 && control == gImageView2)
3260 // Scene off first one.
3261 gImageView1.Unparent();
3263 // Scene off second one.
3264 gImageView2.Unparent();
3266 else if(gResourceReadySignal04ComesOrder == 2 && control == gImageView1)
3268 // Scene off first one.
3269 gImageView2.Unparent();
3271 // Scene off second one.
3272 gImageView1.Unparent();
3276 // We can't check that this utc fail case. just pass always when we come here.
3277 gResourceReadySignal04ComesOrder = -1;
3280 // If we don't seperate index of FreeList area
3281 // and if we don't queue remove during obversing,
3282 // cache index become something invalid data.
3283 // In this case, some strange observer can be called.
3284 // For example, gImageView4.LoadComplete will be called.
3290 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3292 tet_infoline("Test setting image from within signal handler.");
3294 ToolkitTestApplication application;
3296 gResourceReadySignalCounter = 0;
3298 ImageView imageView = ImageView::New(gImage_34_RGBA);
3299 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal01);
3301 application.GetScene().Add(imageView);
3303 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3305 application.SendNotification();
3306 application.Render();
3308 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3310 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3312 // Create a new ImageView to cache the image
3313 ImageView imageView1 = ImageView::New(gImage_600_RGB);
3314 application.GetScene().Add(imageView1);
3316 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3318 application.SendNotification();
3319 application.Render();
3322 gResourceReadySignalCounter = 0;
3324 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3326 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3328 application.SendNotification();
3329 application.Render();
3331 // Run idle callback
3332 application.RunIdles();
3334 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3336 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3341 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
3343 tet_infoline("Test setting image from within signal handler.");
3345 ToolkitTestApplication application;
3347 gResourceReadySignalCounter = 0;
3349 ImageView imageView = ImageView::New(gImage_34_RGBA);
3350 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal02);
3352 application.GetScene().Add(imageView);
3354 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3356 application.SendNotification();
3357 application.Render();
3359 // Wait for loading an image
3360 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3362 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3364 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3369 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3371 tet_infoline("Test setting image from within signal handler.");
3373 ToolkitTestApplication application;
3375 gResourceReadySignalCounter = 0;
3377 gImageView1 = ImageView::New(gImage_34_RGBA);
3378 application.GetScene().Add(gImageView1);
3381 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3383 gImageView2 = ImageView::New(gImage_600_RGB);
3384 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3385 application.GetScene().Add(gImageView2);
3387 gImageView3 = ImageView::New();
3388 application.GetScene().Add(gImageView3);
3390 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3392 application.SendNotification();
3393 application.Render();
3398 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask01(void)
3400 tet_infoline("Test signal handler when image / mask image is broken.");
3402 ToolkitTestApplication application;
3404 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, const std::string& url, const std::string& mask, const char* location) {
3405 gResourceReadySignalCounter = 0;
3408 map[Toolkit::ImageVisual::Property::URL] = url;
3411 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3413 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3415 ImageView imageView = ImageView::New();
3416 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3417 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3418 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3420 application.GetScene().Add(imageView);
3421 application.SendNotification();
3422 application.Render();
3427 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3429 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3430 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3432 imageView.Unparent();
3435 for(int synchronous = 0; synchronous <= 1; synchronous++)
3437 tet_printf("Test normal case (sync:%d)\n", synchronous);
3438 TestResourceReadyUrl(1, synchronous, gImage_600_RGB, "", TEST_LOCATION);
3439 TestResourceReadyUrl(3, synchronous, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 3 event trigger required : 2 image load + 1 apply mask
3441 tet_printf("Test broken image case (sync:%d)\n", synchronous);
3442 TestResourceReadyUrl(1, synchronous, "invalid.jpg", "", TEST_LOCATION);
3443 TestResourceReadyUrl(2, synchronous, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3445 tet_printf("Test broken mask image case (sync:%d)\n", synchronous);
3446 TestResourceReadyUrl(2, synchronous, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3448 tet_printf("Test broken both image, mask image case (sync:%d)\n", synchronous);
3449 TestResourceReadyUrl(2, synchronous, "invalid.jpg", "invalid.png", TEST_LOCATION);
3455 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask02(void)
3457 tet_infoline("Test signal handler when image try to use cached-and-broken mask image.");
3459 ToolkitTestApplication application;
3461 gResourceReadySignalCounter = 0;
3463 auto TestBrokenMaskResourceReadyUrl = [&application](const std::string& url, const char* location) {
3465 map[Toolkit::ImageVisual::Property::URL] = url;
3466 // Use invalid mask url
3467 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
3469 ImageView imageView = ImageView::New();
3470 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3471 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3472 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3474 application.GetScene().Add(imageView);
3475 application.SendNotification();
3476 application.Render();
3478 // Don't unparent imageView, for keep the cache.
3481 // Use more than 4 images (The number of LocalImageLoadThread)
3482 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};
3484 int expectResourceReadySignalCounter = 0;
3486 for(auto& url : testUrlList)
3488 TestBrokenMaskResourceReadyUrl(url, TEST_LOCATION);
3489 expectResourceReadySignalCounter++;
3492 // Remain 1 signal due to we use #URL + 1 mask image.
3493 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(expectResourceReadySignalCounter + 1), true, TEST_LOCATION);
3495 DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
3500 int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
3502 tet_infoline("Test signal handler various case.");
3504 ToolkitTestApplication application;
3506 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
3507 gResourceReadySignalCounter = 0;
3510 map[Toolkit::ImageVisual::Property::URL] = url;
3513 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3515 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3517 ImageView imageView = ImageView::New();
3518 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3519 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3520 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3522 application.GetScene().Add(imageView);
3523 application.SendNotification();
3524 application.Render();
3527 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3529 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3530 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3531 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3533 imageView.Unparent();
3536 auto TestAuxiliaryResourceReadyUrl = [&application](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
3537 gResourceReadySignalCounter = 0;
3540 map[Toolkit::ImageVisual::Property::URL] = url;
3541 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE] = auxiliaryUrl;
3542 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA] = 0.5f;
3543 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3545 ImageView imageView = ImageView::New();
3546 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
3547 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
3548 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3549 application.GetScene().Add(imageView);
3551 application.SendNotification();
3552 application.Render();
3557 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, location);
3560 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3561 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3562 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3564 imageView.Unparent();
3567 // Case 1 : asynchronous loading
3568 tet_printf("Test invalid single simple image Asynchronous\n");
3571 TestResourceReadyUrl(1, 0, 1, gImage_600_RGB, "", TEST_LOCATION);
3572 TestResourceReadyUrl(1, 0, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // 1 rasterize
3573 TestResourceReadyUrl(1, 0, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
3575 TestResourceReadyUrl(2, 0, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // 2 image loading - batch size
3576 TestResourceReadyUrl(1, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // 1 rasterize
3578 TestResourceReadyUrl(3, 0, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 2 image loading + 1 applymask
3580 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
3583 TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
3584 TestResourceReadyUrl(0, 0, 0, "invalid.svg", "", TEST_LOCATION); // 0 rasterize
3585 TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
3586 TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION); // 1 image loading
3587 TestResourceReadyUrl(0, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
3589 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", "invalid.png", TEST_LOCATION); // 2 image loading
3590 TestResourceReadyUrl(2, 0, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); // 2 image loading
3591 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION); // 2 image loading
3593 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
3594 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
3595 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
3597 // Case 2 : Synchronous loading
3598 tet_printf("Test invalid single simple image Synchronous\n");
3601 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "", TEST_LOCATION);
3602 TestResourceReadyUrl(0, 1, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
3603 TestResourceReadyUrl(0, 1, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
3605 TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // first frame image loading sync + second frame image loading async
3606 TestResourceReadyUrl(0, 1, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
3608 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION);
3610 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
3613 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
3614 TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION); // 0 rasterize
3615 TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
3616 TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
3617 TestResourceReadyUrl(0, 1, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
3619 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "invalid.png", TEST_LOCATION);
3620 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3621 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3623 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
3624 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
3625 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
3630 int UtcDaliImageViewSetImageOnResourceReadySignal04(void)
3632 tet_infoline("Test texturemanager's remove queue works well within signal handler.");
3634 ToolkitTestApplication application;
3636 gResourceReadySignalCounter = 0;
3637 gResourceReadySignal04ComesOrder = 0;
3639 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
3640 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3641 application.GetScene().Add(gImageView1);
3643 gImageView2 = ImageView::New("invalid.png"); // request invalid image, to make loading failed fast.
3644 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3645 application.GetScene().Add(gImageView2);
3647 application.SendNotification();
3648 application.Render();
3650 tet_infoline("Try to load 2 invalid image");
3652 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3653 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3655 tet_infoline("load done");
3657 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
3658 if(gResourceReadySignal04ComesOrder == -1)
3660 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
3664 // gImageView3 and gImageView4 load must not be successed yet.
3665 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
3666 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
3668 application.SendNotification();
3669 application.Render();
3671 tet_infoline("Try to load 2 valid image");
3673 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3674 DALI_TEST_EQUALS(gResourceReadySignalCounter, 4, TEST_LOCATION);
3676 tet_infoline("load done");
3678 // gImageView3 and gImageView4 load must be successed now.
3679 DALI_TEST_EQUALS(gImageView3.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
3680 DALI_TEST_EQUALS(gImageView4.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);