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] = 600;
788 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 600;
789 imageMap[ImageVisual::Property::ATLASING] = true;
791 // No atlasing with big image
792 ImageView imageView_bigdesired = ImageView::New();
793 imageView_bigdesired.SetProperty(ImageView::Property::IMAGE, imageMap);
794 imageView_bigdesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
796 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 0;
797 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 0;
799 // No atlasing with zero desired size
800 ImageView imageView_nodesired = ImageView::New();
801 imageView_nodesired.SetProperty(ImageView::Property::IMAGE, imageMap);
802 imageView_nodesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
804 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
805 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
807 ImageView imageView = ImageView::New();
808 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
809 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
811 // By default, Aysnc loading is used
812 // loading is not started if the actor is offScene
813 application.GetScene().Add(imageView);
814 application.GetScene().Add(imageView_bigdesired);
815 application.GetScene().Add(imageView_nodesired);
816 application.SendNotification();
817 application.Render(16);
819 // loading started, this waits for the loader thread for max 30 seconds
820 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
822 application.Render(16);
823 application.SendNotification();
825 // Change url to url2
826 imageMap[ImageVisual::Property::URL] = url2.GetUrl();
827 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
829 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
830 application.SendNotification();
831 application.Render(16);
832 application.Render(16);
833 application.SendNotification();
835 // loading started, this waits for the loader thread for max 30 seconds
836 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
838 application.SendNotification();
839 application.Render(16);
841 callStack.Enable(false);
843 TraceCallStack::NamedParams params;
844 params["width"] << 34;
845 params["height"] << 34;
846 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
851 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
853 ToolkitTestApplication application;
855 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
857 // Get encoded raw-buffer image and generate url
858 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
859 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
861 // Sync loading, automatic atlasing for small size image
863 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
865 callStack.Enable(true);
867 ImageView imageView = ImageView::New();
869 // Sync loading is used
870 Property::Map syncLoadingMap;
871 syncLoadingMap["url"] = url.GetUrl();
872 syncLoadingMap["alphaMaskUrl"] = gImage_34_RGBA;
873 syncLoadingMap["desiredHeight"] = 34;
874 syncLoadingMap["desiredWidth"] = 34;
875 syncLoadingMap["synchronousLoading"] = true;
876 syncLoadingMap["atlasing"] = true;
877 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
879 application.GetScene().Add(imageView);
880 application.SendNotification();
881 application.Render(16);
883 TraceCallStack::NamedParams params;
884 params["width"] << 34;
885 params["height"] << 34;
886 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
894 int UtcDaliImageViewAddedTexture(void)
896 ToolkitTestApplication application;
898 tet_infoline("ImageView Testing image view with texture provided manager url");
900 ImageView imageView = ImageView::New();
902 // empty texture is ok, though pointless from app point of view
904 std::string url = TextureManager::AddTexture(empty);
905 DALI_TEST_CHECK(url.size() > 0u);
907 Property::Map propertyMap;
908 propertyMap[ImageVisual::Property::URL] = url;
909 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
911 application.GetScene().Add(imageView);
912 application.SendNotification();
913 application.Render();
918 int UtcDaliImageViewSizeWithBackground(void)
920 ToolkitTestApplication application;
924 ImageView imageView = ImageView::New();
926 imageView.SetProperty(Control::Property::BACKGROUND,
928 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
929 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
930 {ImageVisual::Property::DESIRED_WIDTH, width},
931 {ImageVisual::Property::DESIRED_HEIGHT, height},
934 application.GetScene().Add(imageView);
935 application.SendNotification();
936 application.Render();
938 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
939 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
944 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
946 ToolkitTestApplication application;
948 int widthBackground = 100;
949 int heightBackground = 200;
953 ImageView imageView = ImageView::New();
955 imageView.SetProperty(Control::Property::BACKGROUND,
957 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
958 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
959 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
960 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground},
963 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio, 600x600 pixels
965 application.GetScene().Add(imageView);
966 application.SendNotification();
967 application.Render();
969 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
970 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
975 int UtcDaliImageViewHeightForWidthBackground(void)
977 ToolkitTestApplication application;
979 int widthBackground = 100;
980 int heightBackground = 200;
982 ImageView imageView = ImageView::New();
984 imageView.SetProperty(Control::Property::BACKGROUND,
985 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
986 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
987 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
988 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}});
990 application.GetScene().Add(imageView);
991 application.SendNotification();
992 application.Render();
994 Control control = Control::DownCast(imageView);
995 DALI_TEST_CHECK(control);
996 DALI_TEST_EQUALS(imageView.GetHeightForWidth(123.f), control.GetHeightForWidth(123.f), TEST_LOCATION);
997 DALI_TEST_EQUALS(imageView.GetWidthForHeight(321.f), control.GetWidthForHeight(321.f), TEST_LOCATION);
1002 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
1004 ToolkitTestApplication application;
1006 int widthBackground = 100;
1007 int heightBackground = 200;
1011 ImageView imageView = ImageView::New();
1013 imageView.SetProperty(Control::Property::BACKGROUND,
1014 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1015 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1016 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1017 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}}); // 1 to 2 ratio
1019 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio
1021 application.GetScene().Add(imageView);
1022 application.SendNotification();
1023 application.Render();
1025 DALI_TEST_EQUALS(imageView.GetHeightForWidth(width), (float)height, TEST_LOCATION);
1026 DALI_TEST_EQUALS(imageView.GetWidthForHeight(height), (float)width, TEST_LOCATION);
1031 int UtcDaliImageViewSetImageUrl(void)
1033 ToolkitTestApplication application;
1035 ImageView imageView = ImageView::New();
1036 imageView.SetImage(TEST_IMAGE_FILE_NAME);
1037 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
1039 imageView.SetImage(TEST_IMAGE_FILE_NAME2);
1040 TestUrl(imageView, TEST_IMAGE_FILE_NAME2);
1045 bool gResourceReadySignalFired = false;
1046 Vector3 gNaturalSize;
1048 void ResourceReadySignal(Control control)
1050 gResourceReadySignalFired = true;
1053 int UtcDaliImageViewCheckResourceReady(void)
1055 ToolkitTestApplication application;
1057 gResourceReadySignalFired = false;
1059 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1060 ImageView imageView = ImageView::New(TEST_GIF_FILE_NAME);
1062 imageView.SetProperty(Control::Property::BACKGROUND,
1063 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1064 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1065 {ImageVisual::Property::DESIRED_WIDTH, 100},
1066 {ImageVisual::Property::DESIRED_HEIGHT, 200}});
1068 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1070 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1072 application.GetScene().Add(imageView);
1074 // loading started, this waits for the loader thread
1075 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1077 application.SendNotification();
1078 application.Render(16);
1080 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1082 application.SendNotification();
1083 application.Render();
1085 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1087 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1092 int UtcDaliImageViewSetImageTypeChangesP(void)
1094 ToolkitTestApplication application;
1096 ImageView imageView = ImageView::New();
1097 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1099 application.GetScene().Add(imageView);
1103 Toolkit::Visual::Base visual;
1105 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1106 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1108 application.SendNotification();
1109 application.Render(16);
1111 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1113 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1114 DALI_TEST_CHECK(!visual); // Visual should be invalid
1117 imageView.SetImage("TEST_URL");
1119 application.SendNotification();
1120 application.Render(16);
1122 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1123 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1125 DALI_TEST_CHECK(value.Get(url)); // Value should NOT be empty
1126 DALI_TEST_CHECK(!value.Get(map)); // Value should be empty
1127 DALI_TEST_CHECK(visual); // Visual should be valid
1130 imageView.SetImage("");
1132 application.SendNotification();
1133 application.Render(16);
1135 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1136 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1138 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1140 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1141 DALI_TEST_CHECK(!visual); // Visual should be invalid
1143 // Set a URL in property map
1144 Property::Map propertyMap;
1145 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1146 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1148 application.SendNotification();
1149 application.Render(16);
1151 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1152 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1154 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1155 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1156 DALI_TEST_CHECK(visual); // Visual should be valid
1158 // Set a URL in property map again
1159 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1160 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1162 application.SendNotification();
1163 application.Render(16);
1165 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1166 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1168 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1169 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1170 DALI_TEST_CHECK(visual); // Visual should be valid
1172 // Set an empty URL in property map
1173 propertyMap[ImageVisual::Property::URL] = std::string();
1174 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1176 application.SendNotification();
1177 application.Render(16);
1179 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1180 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1182 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1183 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1184 DALI_TEST_CHECK(!visual); // Visual should be invalid
1186 // Set a URL in property map again
1187 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1188 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1190 application.SendNotification();
1191 application.Render(16);
1193 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1194 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1196 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1197 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1198 DALI_TEST_CHECK(visual); // Visual should be valid
1200 // Set an empty property map
1201 propertyMap.Clear();
1202 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1204 application.SendNotification();
1205 application.Render(16);
1207 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1208 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1210 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1211 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1212 DALI_TEST_CHECK(map.Empty()); // But PropertyMap should be empty
1213 DALI_TEST_CHECK(!visual); // Visual should be invalid
1218 int UtcDaliImageViewResourceUrlP(void)
1220 ToolkitTestApplication application;
1222 ImageView imageView = ImageView::New();
1223 DALI_TEST_CHECK(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>().empty());
1225 imageView.SetProperty(ImageView::Property::IMAGE, "TestString");
1226 DALI_TEST_EQUALS(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>(), "TestString", TEST_LOCATION);
1231 int UtcDaliImageViewReplaceImage(void)
1233 ToolkitTestApplication application;
1235 gResourceReadySignalFired = false;
1237 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1238 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1240 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1242 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1244 application.GetScene().Add(imageView);
1246 application.SendNotification();
1247 application.Render(16);
1249 // loading started, this waits for the loader thread for max 30 seconds
1250 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1252 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1254 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1256 gResourceReadySignalFired = false;
1258 imageView.SetImage(TEST_IMAGE_2);
1260 application.SendNotification();
1261 application.Render(16);
1263 // loading started, this waits for the loader thread for max 30 seconds
1264 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1266 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1268 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1270 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1275 void OnRelayoutOverride(Size size)
1277 gNaturalSize = size; // Size Relayout is using
1280 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1282 ToolkitTestApplication application;
1284 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1285 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1286 imageView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1288 DummyControl dummyControl = DummyControl::New(true);
1289 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1290 dummyControl.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
1292 dummyControl.Add(imageView);
1293 dummyImpl.SetRelayoutCallback(&OnRelayoutOverride);
1294 application.GetScene().Add(dummyControl);
1296 application.SendNotification();
1297 application.Render();
1299 // loading started, this waits for the loader thread for max 30 seconds
1300 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1302 DALI_TEST_EQUALS(gNaturalSize.width, 1024.0f, TEST_LOCATION);
1303 DALI_TEST_EQUALS(gNaturalSize.height, 1024.0f, TEST_LOCATION);
1305 gNaturalSize = Vector3::ZERO;
1307 imageView.SetImage(gImage_600_RGB);
1309 // Waiting for resourceReady so SendNotifcation not called here.
1311 // loading started, this waits for the loader thread for max 30 seconds
1312 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1314 // Trigger a potential relayout
1315 application.SendNotification();
1316 application.Render();
1318 DALI_TEST_EQUALS(gNaturalSize.width, 600.0f, TEST_LOCATION);
1319 DALI_TEST_EQUALS(gNaturalSize.height, 600.0f, TEST_LOCATION);
1324 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1326 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1328 ToolkitTestApplication application;
1330 gResourceReadySignalFired = false;
1332 Property::Map imageMap;
1334 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1335 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1337 tet_infoline("Creating ImageView without URL so image does not start loading");
1338 ImageView imageView = ImageView::New();
1339 tet_infoline("Connect to image loaded signal before setting image");
1340 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1341 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1342 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1344 // loading started, this waits for the loader thread
1345 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1347 application.SendNotification();
1348 application.Render(16);
1350 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1355 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1357 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1359 ToolkitTestApplication application;
1361 gResourceReadySignalFired = false;
1363 Property::Map imageMap;
1365 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1366 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1368 ImageView imageView = ImageView::New();
1369 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1370 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1372 // loading started, this waits for the loader thread
1373 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1375 application.SendNotification();
1376 application.Render(16);
1378 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1379 gResourceReadySignalFired = false;
1381 ImageView imageViewWithExistingImage = ImageView::New();
1382 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1383 imageViewWithExistingImage.SetProperty(ImageView::Property::IMAGE, imageMap);
1385 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1390 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1392 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1394 ToolkitTestApplication application;
1396 gResourceReadySignalFired = false;
1398 Property::Map imageImmediateLoadingMap;
1399 imageImmediateLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1400 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1402 tet_infoline("Immediate load an image");
1403 ImageView imageView = ImageView::New();
1404 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1405 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
1407 // loading started, this waits for the loader thread
1408 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1410 application.SendNotification();
1411 application.Render(16);
1413 tet_infoline("Check image loaded");
1414 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1415 gResourceReadySignalFired = false;
1417 tet_infoline("Create another ImageView with the same URL");
1418 ImageView imageViewWithExistingImage = ImageView::New(gImage_34_RGBA);
1419 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1420 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1422 application.GetScene().Add(imageViewWithExistingImage);
1424 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1429 int UtcDaliImageViewPaddingProperty(void)
1431 ToolkitTestApplication application;
1433 ImageView imageView = ImageView::New();
1434 Property::Map imagePropertyMap;
1435 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1436 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
1437 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1438 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1439 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1440 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1441 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1442 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1443 application.GetScene().Add(imageView);
1445 application.SendNotification();
1446 application.Render();
1448 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1450 ImageView childImage = ImageView::New();
1451 childImage.SetBackgroundColor(Color::BLACK);
1452 childImage.SetProperty(Actor::Property::SIZE, Vector2(10.f, 10.f));
1453 imageView.Add(childImage);
1455 application.SendNotification();
1456 application.Render();
1458 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1459 DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
1461 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1462 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1463 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1464 Property::Map resultMap;
1465 imageVisual.CreatePropertyMap(resultMap);
1467 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1468 DALI_TEST_CHECK(transformValue);
1469 Property::Map* retMap = transformValue->GetMap();
1470 DALI_TEST_CHECK(retMap);
1472 // Image Visual should be positioned depending on ImageView's padding
1473 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1478 int UtcDaliImageViewPaddingProperty02(void)
1480 ToolkitTestApplication application;
1482 ImageView imageView = ImageView::New();
1483 Property::Map imagePropertyMap;
1484 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1485 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1486 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1487 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1488 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1489 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1490 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1491 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1492 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1493 application.GetScene().Add(imageView);
1495 application.SendNotification();
1496 application.Render();
1498 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1500 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1501 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1502 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1503 Property::Map resultMap;
1504 imageVisual.CreatePropertyMap(resultMap);
1506 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1507 DALI_TEST_CHECK(transformValue);
1508 Property::Map* retMap = transformValue->GetMap();
1509 DALI_TEST_CHECK(retMap);
1511 // Image Visual should be positioned depending on ImageView's padding
1512 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1517 int UtcDaliImageViewPaddingProperty03(void)
1519 tet_infoline("Test Setting Image Padding then removing it.");
1521 ToolkitTestApplication application;
1523 ImageView imageView = ImageView::New();
1524 Property::Map imagePropertyMap;
1525 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1526 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1527 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1528 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1529 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1530 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1531 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1532 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1533 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1534 application.GetScene().Add(imageView);
1536 application.SendNotification();
1537 application.Render();
1539 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1541 tet_infoline("Remove Padding and test Visual is position correctly");
1543 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1545 application.SendNotification();
1546 application.Render();
1548 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1549 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1550 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1551 Property::Map resultMap;
1552 imageVisual.CreatePropertyMap(resultMap);
1554 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1555 DALI_TEST_CHECK(transformValue);
1556 Property::Map* retMap = transformValue->GetMap();
1557 DALI_TEST_CHECK(retMap);
1559 // Image Visual should be positioned depending on ImageView's padding
1560 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1565 int UtcDaliImageViewPaddingProperty04(void)
1567 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1569 ToolkitTestApplication application;
1571 ImageView imageView = ImageView::New();
1572 Property::Map imagePropertyMap;
1573 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1574 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1575 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1576 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1577 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FILL;
1578 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1579 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1580 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1581 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1582 application.GetScene().Add(imageView);
1584 application.SendNotification();
1585 application.Render();
1587 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1589 tet_infoline("Remove Padding and test Visual is position correctly");
1591 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1593 application.SendNotification();
1594 application.Render();
1596 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1597 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1598 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1599 Property::Map resultMap;
1600 imageVisual.CreatePropertyMap(resultMap);
1602 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1603 DALI_TEST_CHECK(transformValue);
1604 Property::Map* retMap = transformValue->GetMap();
1605 DALI_TEST_CHECK(retMap);
1607 // Image Visual should be positioned depending on ImageView's padding
1608 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1613 int UtcDaliImageViewTransformTest01(void)
1615 tet_infoline("Test Setting a offset transform on the ImageView");
1617 ToolkitTestApplication application;
1619 ImageView imageView = ImageView::New();
1620 Property::Map imagePropertyMap;
1621 imagePropertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE)
1622 .Add(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/Kid1.svg")
1623 .Add(ImageVisual::Property::DESIRED_WIDTH, 120)
1624 .Add(ImageVisual::Property::DESIRED_HEIGHT, 120)
1625 .Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL)
1626 .Add(Visual::Property::TRANSFORM,
1627 Property::Map().Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1628 Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE))
1629 .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(8, 8)));
1631 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1632 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1633 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1634 application.GetScene().Add(imageView);
1636 application.SendNotification();
1637 application.Render();
1639 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1640 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1641 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1642 Property::Map resultMap;
1643 imageVisual.CreatePropertyMap(resultMap);
1645 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1646 DALI_TEST_CHECK(transformValue);
1647 Property::Map* retMap = transformValue->GetMap();
1648 DALI_TEST_CHECK(retMap);
1650 // Image Visual should be positioned depending on ImageView's padding
1651 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(8, 8), TEST_LOCATION);
1652 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);
1657 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1659 ToolkitTestApplication application;
1661 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1662 ImageView imageView = ImageView::New();
1663 Property::Map imageMap;
1664 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1665 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_34_RGBA;
1666 imageMap[Toolkit::ImageVisual::Property::ATLASING] = true;
1667 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1668 application.GetScene().Add(imageView);
1670 // Trigger a potential relayout
1671 application.SendNotification();
1672 application.Render();
1674 Vector3 naturalSize = imageView.GetNaturalSize();
1676 DALI_TEST_EQUALS(naturalSize.width, 34.0f, TEST_LOCATION);
1677 DALI_TEST_EQUALS(naturalSize.height, 34.0f, TEST_LOCATION);
1682 int UtcDaliImageViewFillMode(void)
1684 ToolkitTestApplication application;
1686 tet_infoline("Create an ImageVisual without padding and set the fill-mode to fill");
1688 ImageView imageView = ImageView::New();
1689 Property::Map imageMap;
1690 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1691 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB);
1692 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL);
1694 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1696 application.GetScene().Add(imageView);
1698 // Trigger a potential relayout
1699 application.SendNotification();
1700 application.Render();
1702 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1703 Property::Map returnedMap;
1704 visual.CreatePropertyMap(returnedMap);
1706 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1707 DALI_TEST_CHECK(value);
1708 Property::Map* map = value->GetMap();
1709 DALI_TEST_CHECK(map);
1711 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1712 DALI_TEST_CHECK(value);
1713 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION);
1715 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1716 DALI_TEST_CHECK(value);
1717 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1722 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1724 ToolkitTestApplication application;
1726 tet_infoline("Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )");
1727 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1729 ImageView imageView = ImageView::New();
1730 Property::Map imageMap;
1731 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1732 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1733 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
1735 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1736 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1738 application.GetScene().Add(imageView);
1740 // Trigger a potential relayout
1741 application.SendNotification();
1742 application.Render();
1744 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1745 Property::Map returnedMap;
1746 visual.CreatePropertyMap(returnedMap);
1748 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1749 DALI_TEST_CHECK(value);
1750 Property::Map* map = value->GetMap();
1751 DALI_TEST_CHECK(map);
1754 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1755 DALI_TEST_CHECK(value);
1756 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION);
1758 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1759 DALI_TEST_CHECK(value);
1760 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1762 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1763 DALI_TEST_CHECK(value);
1764 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
1769 int UtcDaliImageViewFittingModesFill(void)
1771 ToolkitTestApplication application;
1773 tet_infoline("Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )");
1774 tet_infoline(" There should be no need to change the transform, only size is changed to fit view");
1776 ImageView imageView = ImageView::New();
1777 Property::Map imageMap;
1778 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1779 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1780 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL);
1782 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1783 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1785 application.GetScene().Add(imageView);
1787 // Trigger a potential relayout
1788 application.SendNotification();
1789 application.Render();
1791 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1792 Property::Map returnedMap;
1793 visual.CreatePropertyMap(returnedMap);
1795 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1796 DALI_TEST_CHECK(value);
1797 Property::Map* map = value->GetMap();
1798 DALI_TEST_CHECK(map);
1800 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1801 DALI_TEST_CHECK(value);
1802 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Change the internal size according to the image view size
1804 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1805 DALI_TEST_CHECK(value);
1806 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1808 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1809 DALI_TEST_CHECK(value);
1810 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1815 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1817 ToolkitTestApplication application;
1819 tet_infoline("Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )");
1820 tet_infoline(" offset or size is the same as view, but adjust internally using pixelArea ");
1822 ImageView imageView = ImageView::New();
1823 Property::Map imageMap;
1824 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1825 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1826 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO);
1828 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1829 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 500));
1831 application.GetScene().Add(imageView);
1833 // Trigger a potential relayout
1834 application.SendNotification();
1835 application.Render();
1837 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1838 Property::Map returnedMap;
1839 visual.CreatePropertyMap(returnedMap);
1841 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1842 DALI_TEST_CHECK(value);
1843 Property::Map* map = value->GetMap();
1844 DALI_TEST_CHECK(map);
1847 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1848 DALI_TEST_CHECK(value);
1849 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 500), TEST_LOCATION); // Change the internal size according to the image view size
1851 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1852 DALI_TEST_CHECK(value);
1853 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1855 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1856 DALI_TEST_CHECK(value);
1857 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1862 int UtcDaliImageViewFittingModesCenter01(void)
1864 ToolkitTestApplication application;
1866 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [700,700] )");
1867 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1869 ImageView imageView = ImageView::New();
1870 Property::Map imageMap;
1871 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1872 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1873 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1875 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1876 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1878 application.GetScene().Add(imageView);
1880 // Trigger a potential relayout
1881 application.SendNotification();
1882 application.Render();
1884 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1885 Property::Map returnedMap;
1886 visual.CreatePropertyMap(returnedMap);
1888 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1889 DALI_TEST_CHECK(value);
1890 Property::Map* map = value->GetMap();
1891 DALI_TEST_CHECK(map);
1893 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1894 DALI_TEST_CHECK(value);
1895 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1897 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1898 DALI_TEST_CHECK(value);
1899 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1901 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1902 DALI_TEST_CHECK(value);
1903 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1908 int UtcDaliImageViewFittingModesCenter02(void)
1910 ToolkitTestApplication application;
1912 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [500,500] )");
1913 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1915 ImageView imageView = ImageView::New();
1916 Property::Map imageMap;
1917 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1918 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1919 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1921 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1922 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1924 application.GetScene().Add(imageView);
1926 // Trigger a potential relayout
1927 application.SendNotification();
1928 application.Render();
1930 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1931 Property::Map returnedMap;
1932 visual.CreatePropertyMap(returnedMap);
1934 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1935 DALI_TEST_CHECK(value);
1936 Property::Map* map = value->GetMap();
1937 DALI_TEST_CHECK(map);
1939 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1940 DALI_TEST_CHECK(value);
1941 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1943 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1944 DALI_TEST_CHECK(value);
1945 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1947 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1948 DALI_TEST_CHECK(value);
1949 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1954 int UtcDaliImageViewFittingModesFitHeight01(void)
1956 ToolkitTestApplication application;
1958 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )");
1960 ImageView imageView = ImageView::New();
1961 Property::Map imageMap;
1962 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1963 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1964 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1966 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1967 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1969 application.GetScene().Add(imageView);
1971 // Trigger a potential relayout
1972 application.SendNotification();
1973 application.Render();
1975 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1976 Property::Map returnedMap;
1977 visual.CreatePropertyMap(returnedMap);
1979 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1980 DALI_TEST_CHECK(value);
1981 Property::Map* map = value->GetMap();
1982 DALI_TEST_CHECK(map);
1984 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1985 DALI_TEST_CHECK(value);
1986 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 700), TEST_LOCATION); // Change the internal size according to the image view size
1988 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1989 DALI_TEST_CHECK(value);
1990 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1992 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1993 DALI_TEST_CHECK(value);
1994 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1999 int UtcDaliImageViewFittingModesFitHeight02(void)
2001 ToolkitTestApplication application;
2003 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )");
2005 ImageView imageView = ImageView::New();
2006 Property::Map imageMap;
2007 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2008 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2009 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2011 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2012 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2014 application.GetScene().Add(imageView);
2016 // Trigger a potential relayout
2017 application.SendNotification();
2018 application.Render();
2020 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2021 Property::Map returnedMap;
2022 visual.CreatePropertyMap(returnedMap);
2024 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2025 DALI_TEST_CHECK(value);
2026 Property::Map* map = value->GetMap();
2027 DALI_TEST_CHECK(map);
2029 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2030 DALI_TEST_CHECK(value);
2031 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2033 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2034 DALI_TEST_CHECK(value);
2035 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2037 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2038 DALI_TEST_CHECK(value);
2039 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2044 int UtcDaliImageViewFittingModesFitWidth01(void)
2046 ToolkitTestApplication application;
2048 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )");
2050 ImageView imageView = ImageView::New();
2051 Property::Map imageMap;
2052 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2053 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2054 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2056 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2057 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2059 application.GetScene().Add(imageView);
2061 // Trigger a potential relayout
2062 application.SendNotification();
2063 application.Render();
2065 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2066 Property::Map returnedMap;
2067 visual.CreatePropertyMap(returnedMap);
2069 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2070 DALI_TEST_CHECK(value);
2071 Property::Map* map = value->GetMap();
2072 DALI_TEST_CHECK(map);
2074 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2075 DALI_TEST_CHECK(value);
2076 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2078 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2079 DALI_TEST_CHECK(value);
2080 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2082 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2083 DALI_TEST_CHECK(value);
2084 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
2089 int UtcDaliImageViewFittingModesFitWidth02(void)
2091 ToolkitTestApplication application;
2093 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )");
2095 ImageView imageView = ImageView::New();
2096 Property::Map imageMap;
2097 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2098 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2099 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2101 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2102 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2104 application.GetScene().Add(imageView);
2106 // Trigger a potential relayout
2107 application.SendNotification();
2108 application.Render();
2110 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2111 Property::Map returnedMap;
2112 visual.CreatePropertyMap(returnedMap);
2114 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2115 DALI_TEST_CHECK(value);
2116 Property::Map* map = value->GetMap();
2117 DALI_TEST_CHECK(map);
2119 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2120 DALI_TEST_CHECK(value);
2121 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 600), TEST_LOCATION); // Change the internal size according to the image view size
2123 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2124 DALI_TEST_CHECK(value);
2125 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2127 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2128 DALI_TEST_CHECK(value);
2129 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2134 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2136 ToolkitTestApplication application;
2138 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2140 ImageView imageView = ImageView::New();
2142 // 1. Render using FittingMode::SHRINK_TO_FIT
2143 Property::Map imageMap;
2144 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2145 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2146 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2148 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2149 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2151 application.GetScene().Add(imageView);
2153 // Trigger a potential relayout
2154 application.SendNotification();
2155 application.Render();
2157 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2158 Property::Map returnedMap;
2159 visual.CreatePropertyMap(returnedMap);
2161 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2162 DALI_TEST_CHECK(value);
2163 Property::Map* map = value->GetMap();
2164 DALI_TEST_CHECK(map);
2166 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2167 DALI_TEST_CHECK(value);
2168 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2170 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2171 DALI_TEST_CHECK(value);
2172 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2174 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2175 DALI_TEST_CHECK(value);
2176 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2178 // 2. Render again using DevelVisaul::CENTER
2179 Property::Map imageMap2;
2180 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2181 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2182 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2184 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2185 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2187 application.GetScene().Add(imageView);
2189 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2191 // Trigger a potential relayout
2192 application.SendNotification();
2193 application.Render();
2195 returnedMap.Clear();
2196 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2198 visual.CreatePropertyMap(returnedMap);
2200 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2201 DALI_TEST_CHECK(value);
2202 map = value->GetMap();
2203 DALI_TEST_CHECK(map);
2205 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2206 DALI_TEST_CHECK(value);
2207 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2209 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2210 DALI_TEST_CHECK(value);
2211 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2213 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2214 DALI_TEST_CHECK(value);
2215 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2217 // 3. Render again using before fittingMode
2218 Property::Map imageMap3;
2219 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2220 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2221 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2223 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2224 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2226 application.GetScene().Add(imageView);
2228 // Trigger a potential relayout
2229 application.SendNotification();
2230 application.Render();
2232 returnedMap.Clear();
2233 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2234 visual.CreatePropertyMap(returnedMap);
2236 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2237 DALI_TEST_CHECK(value);
2238 map = value->GetMap();
2239 DALI_TEST_CHECK(map);
2241 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2242 DALI_TEST_CHECK(value);
2243 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2245 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2246 DALI_TEST_CHECK(value);
2247 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2249 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2250 DALI_TEST_CHECK(value);
2251 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2256 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2258 ToolkitTestApplication application;
2260 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2262 ImageView imageView = ImageView::New();
2264 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2265 Property::Map imageMap;
2266 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2267 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2268 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2270 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2271 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2273 application.GetScene().Add(imageView);
2275 // Trigger a potential relayout
2276 application.SendNotification();
2277 application.Render();
2279 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2280 Property::Map returnedMap;
2281 visual.CreatePropertyMap(returnedMap);
2283 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2284 DALI_TEST_CHECK(value);
2285 Property::Map* map = value->GetMap();
2286 DALI_TEST_CHECK(map);
2288 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2289 DALI_TEST_CHECK(value);
2290 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2292 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2293 DALI_TEST_CHECK(value);
2294 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2296 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2297 DALI_TEST_CHECK(value);
2298 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2300 // 2. Render again using DevelVisaul::CENTER
2301 Property::Map imageMap2;
2302 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2303 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2304 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2306 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2307 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2309 application.GetScene().Add(imageView);
2311 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2313 // Trigger a potential relayout
2314 application.SendNotification();
2315 application.Render();
2317 returnedMap.Clear();
2318 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2320 visual.CreatePropertyMap(returnedMap);
2322 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2323 DALI_TEST_CHECK(value);
2324 map = value->GetMap();
2325 DALI_TEST_CHECK(map);
2327 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2328 DALI_TEST_CHECK(value);
2329 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2331 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2332 DALI_TEST_CHECK(value);
2333 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2335 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2336 DALI_TEST_CHECK(value);
2337 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2339 // 3. Render again using before fittingMode
2340 Property::Map imageMap3;
2341 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2342 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2343 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2345 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2346 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2348 application.GetScene().Add(imageView);
2350 // Trigger a potential relayout
2351 application.SendNotification();
2352 application.Render();
2354 returnedMap.Clear();
2355 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2356 visual.CreatePropertyMap(returnedMap);
2358 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2359 DALI_TEST_CHECK(value);
2360 map = value->GetMap();
2361 DALI_TEST_CHECK(map);
2363 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2364 DALI_TEST_CHECK(value);
2365 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2367 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2368 DALI_TEST_CHECK(value);
2369 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2371 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2372 DALI_TEST_CHECK(value);
2373 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2378 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2380 ToolkitTestApplication application;
2382 tet_infoline("Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )");
2384 ImageView imageView = ImageView::New();
2385 Property::Map imageMap;
2386 imageMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE);
2387 imageMap.Add(Toolkit::ImageVisual::Property::URL, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME); // 249x169 image
2389 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2390 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
2392 application.GetScene().Add(imageView);
2394 // Trigger a potential relayout
2395 application.SendNotification();
2396 application.Render();
2398 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2399 Property::Map returnedMap;
2400 visual.CreatePropertyMap(returnedMap);
2402 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2403 DALI_TEST_CHECK(value);
2404 Property::Map* map = value->GetMap();
2405 DALI_TEST_CHECK(map);
2407 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2408 DALI_TEST_CHECK(value);
2409 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Relative size so will take up 100%
2411 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2412 DALI_TEST_CHECK(value);
2413 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2415 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2416 DALI_TEST_CHECK(value);
2417 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2422 int UtcDaliImageViewCustomShader(void)
2424 ToolkitTestApplication application;
2426 // Set a custom shader with an image url
2428 Property::Map properties;
2429 Property::Map shader;
2430 const std::string vertexShader = "Foobar";
2431 const std::string fragmentShader = "Foobar";
2432 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2433 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2435 properties[Visual::Property::TYPE] = Visual::IMAGE;
2436 properties[Visual::Property::SHADER] = shader;
2437 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2439 ImageView imageView = ImageView::New();
2440 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2442 application.GetScene().Add(imageView);
2444 application.SendNotification();
2445 application.Render();
2447 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2449 Renderer renderer = imageView.GetRendererAt(0);
2450 Shader shader2 = renderer.GetShader();
2451 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2452 Property::Map* map = value.GetMap();
2453 DALI_TEST_CHECK(map);
2455 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2456 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2458 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2459 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2462 // Set a custom shader after setting an image url
2464 Property::Map properties;
2465 Property::Map shader;
2466 const std::string vertexShader = "Foobar";
2467 const std::string fragmentShader = "Foobar";
2468 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2469 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2471 properties[Visual::Property::SHADER] = shader;
2473 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
2474 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2476 application.GetScene().Add(imageView);
2478 application.SendNotification();
2479 application.Render();
2481 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2483 Renderer renderer = imageView.GetRendererAt(0);
2484 Shader shader2 = renderer.GetShader();
2485 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2486 Property::Map* map = value.GetMap();
2487 DALI_TEST_CHECK(map);
2489 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2490 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2492 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2493 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2496 // Set a custom shader before setting an image url
2498 Property::Map properties;
2499 Property::Map shader;
2500 const std::string vertexShader = "Foobar";
2501 const std::string fragmentShader = "Foobar";
2502 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2503 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2505 properties[Visual::Property::SHADER] = shader;
2507 ImageView imageView = ImageView::New();
2508 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2509 imageView.SetProperty(ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME);
2511 application.GetScene().Add(imageView);
2513 application.SendNotification();
2514 application.Render();
2515 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2517 Renderer renderer = imageView.GetRendererAt(0);
2518 Shader shader2 = renderer.GetShader();
2519 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2520 Property::Map* map = value.GetMap();
2521 DALI_TEST_CHECK(map);
2523 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2524 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2526 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2527 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2530 // Set a custom shader after setting a property map
2532 Property::Map properties;
2533 Property::Map shader;
2534 const std::string vertexShader = "Foobar";
2535 const std::string fragmentShader = "Foobar";
2536 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2537 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2539 properties[Visual::Property::SHADER] = shader;
2541 Property::Map properties1;
2542 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2543 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2545 ImageView imageView = ImageView::New();
2546 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2547 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2549 application.GetScene().Add(imageView);
2551 application.SendNotification();
2552 application.Render();
2553 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2555 Renderer renderer = imageView.GetRendererAt(0);
2556 Shader shader2 = renderer.GetShader();
2557 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2558 Property::Map* map = value.GetMap();
2559 DALI_TEST_CHECK(map);
2561 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2562 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2564 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2565 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2568 // Set a custom shader before setting a property map
2570 Property::Map properties;
2571 Property::Map shader;
2572 const std::string vertexShader = "Foobar";
2573 const std::string fragmentShader = "Foobar";
2574 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2575 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2577 properties[Visual::Property::SHADER] = shader;
2579 Property::Map properties1;
2580 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2581 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2583 ImageView imageView = ImageView::New();
2584 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2585 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2587 application.GetScene().Add(imageView);
2589 application.SendNotification();
2590 application.Render();
2591 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2593 Renderer renderer = imageView.GetRendererAt(0);
2594 Shader shader2 = renderer.GetShader();
2595 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2596 Property::Map* map = value.GetMap();
2597 DALI_TEST_CHECK(map);
2599 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2600 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2602 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2603 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2611 static int gFailCounter = 0;
2612 const int MAX_RETRIES(3);
2614 void ReloadImage(ImageView imageView)
2616 Property::Map imageImmediateLoadingMap;
2617 imageImmediateLoadingMap[ImageVisual::Property::URL] = "Non-existant-image.jpg";
2618 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
2620 tet_infoline("Immediate load an image");
2621 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
2624 void ResourceFailedReload(Control control)
2627 if(gFailCounter < MAX_RETRIES)
2629 ReloadImage(ImageView::DownCast(control));
2634 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2636 tet_infoline("Test reloading failed image from within signal handler.");
2638 ToolkitTestApplication application;
2642 ImageView imageView = ImageView::New();
2643 imageView.ResourceReadySignal().Connect(&ResourceFailedReload);
2644 DALI_TEST_EQUALS(gFailCounter, 0, TEST_LOCATION);
2645 ReloadImage(imageView);
2647 // loading started, this waits for the loader thread to complete
2648 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2649 application.SendNotification();
2651 DALI_TEST_EQUALS(gFailCounter, 1, TEST_LOCATION);
2653 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2654 application.SendNotification();
2656 DALI_TEST_EQUALS(gFailCounter, 2, TEST_LOCATION);
2658 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2659 application.SendNotification();
2660 DALI_TEST_EQUALS(gFailCounter, 3, TEST_LOCATION);
2665 int UtcDaliImageViewLoadRemoteSVG(void)
2667 tet_infoline("Test load from a remote server.");
2669 ToolkitTestApplication application;
2672 Toolkit::ImageView imageView;
2673 imageView = Toolkit::ImageView::New();
2674 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2675 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2676 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2677 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2678 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2680 application.GetScene().Add(imageView);
2682 DALI_TEST_CHECK(imageView);
2684 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2686 application.SendNotification();
2688 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2690 application.SendNotification();
2691 application.Render();
2693 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2698 Toolkit::ImageView imageView;
2699 imageView = Toolkit::ImageView::New();
2700 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2701 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2702 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2703 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2705 application.GetScene().Add(imageView);
2707 DALI_TEST_CHECK(imageView);
2709 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2711 application.SendNotification();
2713 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2715 application.SendNotification();
2716 application.Render();
2718 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2724 int UtcDaliImageViewSyncSVGLoading(void)
2726 ToolkitTestApplication application;
2728 tet_infoline("ImageView Testing SVG image sync loading");
2730 // Sync loading, automatic atlasing for small size image
2732 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2734 callStack.Enable(true);
2736 ImageView imageView = ImageView::New();
2738 // Sync loading is used
2739 Property::Map syncLoadingMap;
2740 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2741 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2742 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2743 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2745 application.GetScene().Add(imageView);
2746 DALI_TEST_CHECK(imageView);
2748 application.SendNotification();
2749 application.Render(16);
2750 Vector3 naturalSize = imageView.GetNaturalSize();
2752 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2753 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2758 int UtcDaliImageViewAsyncSVGLoading(void)
2760 ToolkitTestApplication application;
2762 tet_infoline("ImageView Testing SVG image async loading");
2764 // Sync loading, automatic atlasing for small size image
2766 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2768 callStack.Enable(true);
2770 ImageView imageView = ImageView::New();
2772 // Sync loading is used
2773 Property::Map syncLoadingMap;
2774 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2775 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2776 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2777 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2779 application.GetScene().Add(imageView);
2780 DALI_TEST_CHECK(imageView);
2782 application.SendNotification();
2783 application.Render(16);
2784 Vector3 naturalSize = imageView.GetNaturalSize();
2786 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2787 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2792 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2794 ToolkitTestApplication application;
2796 tet_infoline("ImageView Testing SVG image async loading");
2798 // Sync loading, automatic atlasing for small size image
2800 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2802 callStack.Enable(true);
2804 ImageView imageView = ImageView::New();
2806 // Sync loading is used
2807 Property::Map syncLoadingMap;
2808 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2809 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2811 // Check to set invalid value
2812 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2813 // Check if error log is outputted when setting other value like string.
2814 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2815 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5));
2816 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2818 application.GetScene().Add(imageView);
2819 DALI_TEST_CHECK(imageView);
2821 application.SendNotification();
2822 application.Render(16);
2823 Vector3 naturalSize = imageView.GetNaturalSize();
2824 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2825 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2827 Property::Value value = imageView.GetProperty(ImageView::Property::IMAGE);
2828 Property::Map* map = value.GetMap();
2829 DALI_TEST_CHECK(map);
2831 Property::Value* sync = map->Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING);
2832 DALI_TEST_CHECK(sync);
2833 DALI_TEST_EQUALS(false, sync->Get<bool>(), TEST_LOCATION);
2838 int UtcDaliImageViewSvgLoadingFailure(void)
2840 ToolkitTestApplication application;
2842 TestGlAbstraction& gl = application.GetGlAbstraction();
2843 TraceCallStack& textureTrace = gl.GetTextureTrace();
2844 textureTrace.Enable(true);
2846 // Local svg file - invalid file path
2848 gResourceReadySignalFired = false;
2850 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2851 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2852 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2854 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2856 application.GetScene().Add(imageView);
2858 application.SendNotification();
2859 application.Render(16);
2861 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2862 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2863 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2865 // Should be shown a broken image
2866 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2867 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2870 // Local svg file - invalid file path without size set
2872 gResourceReadySignalFired = false;
2873 textureTrace.Reset();
2875 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2876 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2878 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2880 application.GetScene().Add(imageView);
2882 application.SendNotification();
2883 application.Render(16);
2885 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2886 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2887 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2889 // Should be shown a broken image
2890 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2891 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2894 // Local svg file - invalid file
2896 gResourceReadySignalFired = false;
2897 textureTrace.Reset();
2899 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.svg");
2900 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2901 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2903 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2905 application.GetScene().Add(imageView);
2907 application.SendNotification();
2908 application.Render(16);
2910 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2911 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2912 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2914 // Should be shown a broken image
2915 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2916 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2921 gResourceReadySignalFired = false;
2922 textureTrace.Reset();
2924 ImageView imageView = ImageView::New("https://bar.org/foobar.svg");
2925 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2926 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2928 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2930 application.GetScene().Add(imageView);
2932 application.SendNotification();
2934 // loading started, this waits for the loader thread
2935 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2937 application.SendNotification();
2938 application.Render(16);
2940 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2941 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2942 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2944 // Should be shown a broken image
2945 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2946 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2949 // Remote svg file without size set
2951 gResourceReadySignalFired = false;
2952 textureTrace.Reset();
2954 ImageView imageView = ImageView::New("https://bar.org/foobar.svg");
2955 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2957 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2959 application.GetScene().Add(imageView);
2961 application.SendNotification();
2963 // loading started, this waits for the loader thread
2964 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2966 application.SendNotification();
2967 application.Render(16);
2969 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2970 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2971 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2973 // Should be shown a broken image
2974 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2975 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2981 int UtcDaliImageViewSvgRasterizationFailure(void)
2983 ToolkitTestApplication application;
2985 gResourceReadySignalFired = false;
2987 TestGlAbstraction& gl = application.GetGlAbstraction();
2988 TraceCallStack& textureTrace = gl.GetTextureTrace();
2989 textureTrace.Enable(true);
2991 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid1.svg");
2992 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2993 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2995 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2997 application.GetScene().Add(imageView);
2999 application.SendNotification();
3001 // loading started, this waits for the loader thread
3002 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3004 application.SendNotification();
3005 application.Render(16);
3007 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3008 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3009 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3011 // Should be shown a broken image
3012 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3013 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3018 int UtcDaliImageViewTVGLoading(void)
3020 ToolkitTestApplication application;
3022 tet_infoline("ImageView Testing TVG image loading");
3025 ImageView imageView = ImageView::New();
3027 imageView.SetImage(TEST_RESOURCE_DIR "/test.tvg");
3029 application.GetScene().Add(imageView);
3030 DALI_TEST_CHECK(imageView);
3031 Vector3 naturalSize = imageView.GetNaturalSize();
3033 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3034 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3039 int UtcDaliImageViewImageLoadFailure01(void)
3041 ToolkitTestApplication application;
3043 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3044 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3045 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3046 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3048 std::string brokenUrl;
3049 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3050 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3052 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3053 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3055 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3056 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3058 ImageView imageView = ImageView::New("invalidUrl.png");
3059 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3061 application.GetScene().Add(imageView);
3062 application.SendNotification();
3063 application.Render(16);
3065 // loading started, this waits for the loader thread
3066 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3071 int UtcDaliImageViewImageLoadFailure02(void)
3073 ToolkitTestApplication application;
3075 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3076 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
3077 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3078 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3080 std::string brokenUrl;
3081 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3082 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
3084 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3085 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3087 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3088 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3090 ImageView imageView = ImageView::New("invalidUrl.png");
3091 imageView.SetProperty(Actor::Property::SIZE, Vector2(30.f, 30.f));
3092 application.GetScene().Add(imageView);
3093 application.SendNotification();
3094 application.Render(16);
3096 // loading started, this waits for the loader thread
3097 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3102 int UtcDaliImageViewImageLoadFailure03(void)
3104 ToolkitTestApplication application;
3106 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3107 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
3108 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
3110 std::string brokenUrl;
3111 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3112 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3114 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3115 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3117 ImageView imageView = ImageView::New("invalidUrl.png");
3118 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3119 application.GetScene().Add(imageView);
3120 application.SendNotification();
3121 application.Render(16);
3123 // loading started, this waits for the loader thread
3124 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3129 int UtcDaliImageViewImageLoadFailure04(void)
3131 ToolkitTestApplication application;
3133 ImageView imageView = ImageView::New("invalidUrl.png");
3134 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3135 application.GetScene().Add(imageView);
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 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3143 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3144 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3145 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3147 ImageView imageView2 = ImageView::New("invalidUrl.png");
3148 imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3149 application.GetScene().Add(imageView2);
3151 std::string brokenUrl;
3152 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3153 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3155 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3156 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3158 application.SendNotification();
3159 application.Render(16);
3161 // loading started, this waits for the loader thread
3162 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3164 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3166 ImageView imageView3 = ImageView::New("invalidUrl.png");
3167 imageView3.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3168 application.GetScene().Add(imageView3);
3170 application.SendNotification();
3171 application.Render(16);
3173 // loading started, this waits for the loader thread
3174 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3181 static int gResourceReadySignalCounter = 0;
3183 void OnResourceReadySignal01(Control control)
3185 gResourceReadySignalCounter++;
3187 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3189 if(gResourceReadySignalCounter == 1)
3192 // It makes the first new visual be deleted immediately
3193 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3194 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3197 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3199 // Make the resource ready immediately
3200 control[ImageView::Property::IMAGE] = gImage_600_RGB;
3204 void OnResourceReadySignal02(Control control)
3206 if(++gResourceReadySignalCounter == 1)
3208 // It makes the first new visual be deleted immediately
3209 // The first image will not be loaded.
3210 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB).Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3211 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3215 ImageView gImageView1;
3216 ImageView gImageView2;
3217 ImageView gImageView3;
3218 ImageView gImageView4;
3220 void OnResourceReadySignal03(Control control)
3222 if(gResourceReadySignalCounter == 0)
3225 // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3226 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3228 // 2. Load a new image
3229 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3231 // 3. Use the new image again
3232 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3233 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3235 else if(gResourceReadySignalCounter == 1)
3237 // This is called from TextureManager::ProcessQueuedTextures().
3238 gImageView1.Unparent();
3239 gImageView1.Reset();
3241 gResourceReadySignalCounter++;
3244 void OnSimpleResourceReadySignal(Control control)
3246 // simply increate counter
3247 gResourceReadySignalCounter++;
3250 int gResourceReadySignal04ComesOrder = 0;
3252 void OnResourceReadySignal04(Control control)
3254 gResourceReadySignalCounter++;
3255 tet_printf("rc %d\n", gResourceReadySignalCounter);
3256 if(gResourceReadySignalCounter == 1)
3258 auto scene = gImageView1.GetParent();
3260 // Request load something
3261 // We hope this request result is return later than gImageView2.
3262 gImageView3 = ImageView::New(TEST_IMAGE_1);
3263 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3264 scene.Add(gImageView3);
3265 gImageView4 = ImageView::New(TEST_IMAGE_2);
3266 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3267 scene.Add(gImageView4);
3269 if(control == gImageView1)
3271 gResourceReadySignal04ComesOrder = 1;
3275 gResourceReadySignal04ComesOrder = 2;
3278 if(gResourceReadySignalCounter == 2)
3280 if(gResourceReadySignal04ComesOrder == 1 && control == gImageView2)
3282 // Scene off first one.
3283 gImageView1.Unparent();
3285 // Scene off second one.
3286 gImageView2.Unparent();
3288 else if(gResourceReadySignal04ComesOrder == 2 && control == gImageView1)
3290 // Scene off first one.
3291 gImageView2.Unparent();
3293 // Scene off second one.
3294 gImageView1.Unparent();
3298 // We can't check that this utc fail case. just pass always when we come here.
3299 gResourceReadySignal04ComesOrder = -1;
3302 // If we don't seperate index of FreeList area
3303 // and if we don't queue remove during obversing,
3304 // cache index become something invalid data.
3305 // In this case, some strange observer can be called.
3306 // For example, gImageView4.LoadComplete will be called.
3312 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3314 tet_infoline("Test setting image from within signal handler.");
3316 ToolkitTestApplication application;
3318 gResourceReadySignalCounter = 0;
3320 ImageView imageView = ImageView::New(gImage_34_RGBA);
3321 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal01);
3323 application.GetScene().Add(imageView);
3325 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3327 application.SendNotification();
3328 application.Render();
3330 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3332 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3334 // Create a new ImageView to cache the image
3335 ImageView imageView1 = ImageView::New(gImage_600_RGB);
3336 application.GetScene().Add(imageView1);
3338 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3340 application.SendNotification();
3341 application.Render();
3344 gResourceReadySignalCounter = 0;
3346 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3348 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3350 application.SendNotification();
3351 application.Render();
3353 // Run idle callback
3354 application.RunIdles();
3356 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3358 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3363 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
3365 tet_infoline("Test setting image from within signal handler.");
3367 ToolkitTestApplication application;
3369 gResourceReadySignalCounter = 0;
3371 ImageView imageView = ImageView::New(gImage_34_RGBA);
3372 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal02);
3374 application.GetScene().Add(imageView);
3376 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3378 application.SendNotification();
3379 application.Render();
3381 // Wait for loading an image
3382 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3384 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3386 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3391 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3393 tet_infoline("Test setting image from within signal handler.");
3395 ToolkitTestApplication application;
3397 gResourceReadySignalCounter = 0;
3399 gImageView1 = ImageView::New(gImage_34_RGBA);
3400 application.GetScene().Add(gImageView1);
3403 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3405 gImageView2 = ImageView::New(gImage_600_RGB);
3406 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3407 application.GetScene().Add(gImageView2);
3409 gImageView3 = ImageView::New();
3410 application.GetScene().Add(gImageView3);
3412 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3414 application.SendNotification();
3415 application.Render();
3420 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask01(void)
3422 tet_infoline("Test signal handler when image / mask image is broken.");
3424 ToolkitTestApplication application;
3426 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, const std::string& url, const std::string& mask, const char* location) {
3427 gResourceReadySignalCounter = 0;
3430 map[Toolkit::ImageVisual::Property::URL] = url;
3433 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3435 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3437 ImageView imageView = ImageView::New();
3438 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3439 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3440 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3442 application.GetScene().Add(imageView);
3443 application.SendNotification();
3444 application.Render();
3449 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3451 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3452 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3454 imageView.Unparent();
3457 for(int synchronous = 0; synchronous <= 1; synchronous++)
3459 tet_printf("Test normal case (sync:%d)\n", synchronous);
3460 TestResourceReadyUrl(1, synchronous, gImage_600_RGB, "", TEST_LOCATION);
3461 TestResourceReadyUrl(3, synchronous, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 3 event trigger required : 2 image load + 1 apply mask
3463 tet_printf("Test broken image case (sync:%d)\n", synchronous);
3464 TestResourceReadyUrl(1, synchronous, "invalid.jpg", "", TEST_LOCATION);
3465 TestResourceReadyUrl(2, synchronous, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3467 tet_printf("Test broken mask image case (sync:%d)\n", synchronous);
3468 TestResourceReadyUrl(2, synchronous, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3470 tet_printf("Test broken both image, mask image case (sync:%d)\n", synchronous);
3471 TestResourceReadyUrl(2, synchronous, "invalid.jpg", "invalid.png", TEST_LOCATION);
3477 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask02(void)
3479 tet_infoline("Test signal handler when image try to use cached-and-broken mask image.");
3481 ToolkitTestApplication application;
3483 gResourceReadySignalCounter = 0;
3485 auto TestBrokenMaskResourceReadyUrl = [&application](const std::string& url, const char* location) {
3487 map[Toolkit::ImageVisual::Property::URL] = url;
3488 // Use invalid mask url
3489 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
3491 ImageView imageView = ImageView::New();
3492 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3493 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3494 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3496 application.GetScene().Add(imageView);
3497 application.SendNotification();
3498 application.Render();
3500 // Don't unparent imageView, for keep the cache.
3503 // Use more than 4 images (The number of LocalImageLoadThread)
3504 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};
3506 int expectResourceReadySignalCounter = 0;
3508 for(auto& url : testUrlList)
3510 TestBrokenMaskResourceReadyUrl(url, TEST_LOCATION);
3511 expectResourceReadySignalCounter++;
3514 // Remain 1 signal due to we use #URL + 1 mask image.
3515 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(expectResourceReadySignalCounter + 1), true, TEST_LOCATION);
3517 DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
3522 int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
3524 tet_infoline("Test signal handler various case.");
3526 ToolkitTestApplication application;
3528 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
3529 gResourceReadySignalCounter = 0;
3532 map[Toolkit::ImageVisual::Property::URL] = url;
3535 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3537 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3539 ImageView imageView = ImageView::New();
3540 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3541 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3542 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3544 application.GetScene().Add(imageView);
3545 application.SendNotification();
3546 application.Render();
3549 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3551 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3552 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3553 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3555 imageView.Unparent();
3558 auto TestAuxiliaryResourceReadyUrl = [&application](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
3559 gResourceReadySignalCounter = 0;
3562 map[Toolkit::ImageVisual::Property::URL] = url;
3563 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE] = auxiliaryUrl;
3564 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA] = 0.5f;
3565 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3567 ImageView imageView = ImageView::New();
3568 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
3569 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
3570 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3571 application.GetScene().Add(imageView);
3573 application.SendNotification();
3574 application.Render();
3579 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, location);
3582 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3583 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3584 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3586 imageView.Unparent();
3589 // Case 1 : asynchronous loading
3590 tet_printf("Test invalid single simple image Asynchronous\n");
3593 TestResourceReadyUrl(1, 0, 1, gImage_600_RGB, "", TEST_LOCATION);
3594 TestResourceReadyUrl(1, 0, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // 1 rasterize
3595 TestResourceReadyUrl(1, 0, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
3597 TestResourceReadyUrl(2, 0, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // 2 image loading - batch size
3598 TestResourceReadyUrl(1, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // 1 rasterize
3600 TestResourceReadyUrl(3, 0, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 2 image loading + 1 applymask
3602 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
3605 TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
3606 TestResourceReadyUrl(0, 0, 0, "invalid.svg", "", TEST_LOCATION); // 0 rasterize
3607 TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
3608 TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION); // 1 image loading
3609 TestResourceReadyUrl(0, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
3611 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", "invalid.png", TEST_LOCATION); // 2 image loading
3612 TestResourceReadyUrl(2, 0, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); // 2 image loading
3613 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION); // 2 image loading
3615 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
3616 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
3617 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
3619 // Case 2 : Synchronous loading
3620 tet_printf("Test invalid single simple image Synchronous\n");
3623 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "", TEST_LOCATION);
3624 TestResourceReadyUrl(0, 1, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
3625 TestResourceReadyUrl(0, 1, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
3627 TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // first frame image loading sync + second frame image loading async
3628 TestResourceReadyUrl(0, 1, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
3630 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION);
3632 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
3635 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
3636 TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION); // 0 rasterize
3637 TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
3638 TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
3639 TestResourceReadyUrl(0, 1, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
3641 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "invalid.png", TEST_LOCATION);
3642 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3643 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3645 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
3646 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
3647 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
3652 int UtcDaliImageViewSetImageOnResourceReadySignal04(void)
3654 tet_infoline("Test texturemanager's remove queue works well within signal handler.");
3656 ToolkitTestApplication application;
3658 gResourceReadySignalCounter = 0;
3659 gResourceReadySignal04ComesOrder = 0;
3661 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
3662 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3663 application.GetScene().Add(gImageView1);
3665 gImageView2 = ImageView::New("invalid.png"); // request invalid image, to make loading failed fast.
3666 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3667 application.GetScene().Add(gImageView2);
3669 application.SendNotification();
3670 application.Render();
3672 tet_infoline("Try to load 2 invalid image");
3674 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3675 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3677 tet_infoline("load done");
3679 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
3680 if(gResourceReadySignal04ComesOrder == -1)
3682 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
3686 // gImageView3 and gImageView4 load must not be successed yet.
3687 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
3688 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
3690 application.SendNotification();
3691 application.Render();
3693 tet_infoline("Try to load 2 valid image");
3695 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3696 DALI_TEST_EQUALS(gResourceReadySignalCounter, 4, TEST_LOCATION);
3698 tet_infoline("load done");
3700 // gImageView3 and gImageView4 load must be successed now.
3701 DALI_TEST_EQUALS(gImageView3.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
3702 DALI_TEST_EQUALS(gImageView4.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);