2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
24 #include <dali-toolkit-test-suite-utils.h>
25 #include <toolkit-event-thread-callback.h>
26 #include <toolkit-vector-image-renderer.h>
27 #include "dummy-control.h"
29 #include <test-encoded-image-buffer.h>
30 #include <test-native-image.h>
32 #include <dali-toolkit/dali-toolkit.h>
33 #include <dali-toolkit/devel-api/controls/control-devel.h>
34 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
35 #include <dali-toolkit/devel-api/styling/style-manager-devel.h>
36 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
37 #include <dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h>
38 #include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
39 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
40 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
41 #include <dali-toolkit/public-api/image-loader/image-url.h>
42 #include <dali-toolkit/public-api/image-loader/image.h>
43 #include <dali/devel-api/scripting/scripting.h>
46 using namespace Toolkit;
48 void utc_dali_toolkit_image_view_startup(void)
50 test_return_value = TET_UNDEF;
53 void utc_dali_toolkit_image_view_cleanup(void)
55 test_return_value = TET_PASS;
60 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
61 const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
63 // resolution: 1024*1024
64 const char* TEST_IMAGE_1 = TEST_RESOURCE_DIR "/TB-gloss.png";
65 const char* TEST_IMAGE_2 = TEST_RESOURCE_DIR "/tb-norm.png";
67 const char* TEST_BROKEN_IMAGE_DEFAULT = TEST_RESOURCE_DIR "/broken.png";
68 const char* TEST_BROKEN_IMAGE_S = TEST_RESOURCE_DIR "/broken_s.9.png";
69 const char* TEST_BROKEN_IMAGE_M = TEST_RESOURCE_DIR "/broken_m.9.png";
70 const char* TEST_BROKEN_IMAGE_L = TEST_RESOURCE_DIR "/broken_l.9.png";
71 const char* TEST_BROKEN_IMAGE_01 = TEST_RESOURCE_DIR "/button-up.9.png";
72 const char* TEST_BROKEN_IMAGE_02 = TEST_RESOURCE_DIR "/heartsframe.9.png";
74 // resolution: 34*34, pixel format: RGBA8888
75 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
76 // resolution: 600*600, pixel format: RGB888
77 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
79 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
80 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
82 const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
83 const char* TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
85 void TestUrl(ImageView imageView, const std::string url)
87 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
89 std::string urlActual;
90 DALI_TEST_CHECK(value.Get(urlActual));
91 DALI_TEST_EQUALS(urlActual, url, TEST_LOCATION);
96 int UtcDaliImageViewNewP(void)
98 ToolkitTestApplication application;
100 ImageView imageView = ImageView::New();
102 DALI_TEST_CHECK(imageView);
107 int UtcDaliImageViewNewUrlP(void)
109 ToolkitTestApplication application;
111 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
112 DALI_TEST_CHECK(imageView);
114 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
119 int UtcDaliImageViewConstructorP(void)
121 ToolkitTestApplication application;
125 DALI_TEST_CHECK(!imageView);
130 int UtcDaliImageViewCopyConstructorP(void)
132 ToolkitTestApplication application;
134 // Initialize an object, ref count == 1
135 ImageView imageView = ImageView::New();
137 ImageView copy(imageView);
138 DALI_TEST_CHECK(copy);
143 int UtcDaliImageViewMoveConstructor(void)
145 ToolkitTestApplication application;
147 ImageView imageView = ImageView::New();
148 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
149 imageView.SetProperty(Actor::Property::SENSITIVE, false);
150 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
152 ImageView moved = std::move(imageView);
153 DALI_TEST_CHECK(moved);
154 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
155 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
156 DALI_TEST_CHECK(!imageView);
161 int UtcDaliImageViewAssignmentOperatorP(void)
163 ToolkitTestApplication application;
165 ImageView imageView = ImageView::New();
167 ImageView copy(imageView);
168 DALI_TEST_CHECK(copy);
169 DALI_TEST_EQUALS(imageView, copy, TEST_LOCATION);
174 int UtcDaliImageViewMoveAssignment(void)
176 ToolkitTestApplication application;
178 ImageView imageView = ImageView::New();
179 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
180 imageView.SetProperty(Actor::Property::SENSITIVE, false);
181 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
184 moved = std::move(imageView);
185 DALI_TEST_CHECK(moved);
186 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
187 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
188 DALI_TEST_CHECK(!imageView);
193 int UtcDaliImageViewDownCastP(void)
195 ToolkitTestApplication application;
197 ImageView imageView = ImageView::New();
199 BaseHandle object(imageView);
201 ImageView imageView2 = ImageView::DownCast(object);
202 DALI_TEST_CHECK(imageView2);
204 ImageView imageView3 = DownCast<ImageView>(object);
205 DALI_TEST_CHECK(imageView3);
210 int UtcDaliImageViewDownCastN(void)
212 ToolkitTestApplication application;
214 BaseHandle unInitializedObject;
216 ImageView imageView1 = ImageView::DownCast(unInitializedObject);
217 DALI_TEST_CHECK(!imageView1);
219 ImageView imageView2 = DownCast<ImageView>(unInitializedObject);
220 DALI_TEST_CHECK(!imageView2);
225 int UtcDaliImageViewTypeRegistry(void)
227 ToolkitTestApplication application;
229 TypeRegistry typeRegistry = TypeRegistry::Get();
230 DALI_TEST_CHECK(typeRegistry);
232 TypeInfo typeInfo = typeRegistry.GetTypeInfo("ImageView");
233 DALI_TEST_CHECK(typeInfo);
235 BaseHandle handle = typeInfo.CreateInstance();
236 DALI_TEST_CHECK(handle);
238 ImageView imageView = ImageView::DownCast(handle);
239 DALI_TEST_CHECK(imageView);
244 int UtcDaliImageViewSetGetProperty01(void)
246 ToolkitTestApplication application;
248 ImageView imageView = ImageView::New();
250 Property::Index idx = imageView.GetPropertyIndex("image");
251 DALI_TEST_EQUALS(idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION);
253 imageView.SetProperty(idx, TEST_IMAGE_FILE_NAME);
254 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
259 int UtcDaliImageViewPreMultipliedAlphaPng(void)
261 ToolkitTestApplication application;
263 // Set up trace debug
264 TestGlAbstraction& gl = application.GetGlAbstraction();
265 TraceCallStack& textureTrace = gl.GetTextureTrace();
266 textureTrace.Enable(true);
268 Property::Map imageMap;
269 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
270 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
272 ImageView imageView1 = ImageView::New();
273 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
275 application.GetScene().Add(imageView1);
277 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
279 DALI_TEST_CHECK(value.Get(enable));
280 DALI_TEST_CHECK(enable); // Default value is true
282 // loading started, this waits for the loader thread for max 30 seconds
283 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
285 application.SendNotification();
286 application.Render();
288 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
289 DALI_TEST_CHECK(value.Get(enable));
290 DALI_TEST_CHECK(enable); // Keep true
292 // conventional alpha blending
293 Renderer renderer1 = imageView1.GetRendererAt(0);
294 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
295 DALI_TEST_CHECK(value.Get(enable));
296 DALI_TEST_CHECK(enable);
298 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
299 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
300 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
301 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
302 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
303 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
304 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
305 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
307 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
308 textureTrace.Reset();
310 // Disable pre-multiplied alpha blending
311 imageView1.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
314 Property::Map attributes;
315 DevelControl::DoAction(imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
317 // loading started, this waits for the loader thread for max 30 seconds
318 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
320 application.SendNotification();
321 application.Render();
323 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
324 DALI_TEST_CHECK(value.Get(enable));
325 DALI_TEST_CHECK(!enable);
327 // conventional alpha blending
328 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
329 DALI_TEST_CHECK(value.Get(enable));
330 DALI_TEST_CHECK(!enable);
332 srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
333 destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
334 srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
335 destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
336 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
337 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
338 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
339 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
341 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
342 textureTrace.Reset();
344 // Make a new ImageView using the same image
345 ImageView imageView2 = ImageView::New();
346 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
348 application.GetScene().Add(imageView2);
350 application.SendNotification();
351 application.Render();
353 Renderer renderer2 = imageView2.GetRendererAt(0);
354 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
355 DALI_TEST_CHECK(value.Get(enable));
356 DALI_TEST_CHECK(enable);
358 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
359 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
360 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
361 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
362 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
363 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
364 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
365 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
367 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
372 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
374 ToolkitTestApplication application;
376 // Set up trace debug
377 TestGlAbstraction& gl = application.GetGlAbstraction();
378 TraceCallStack& textureTrace = gl.GetTextureTrace();
379 textureTrace.Enable(true);
381 Property::Map imageMap;
382 imageMap[ImageVisual::Property::URL] = gImage_600_RGB;
383 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
385 ImageView imageView1 = ImageView::New();
386 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
388 application.GetScene().Add(imageView1);
390 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
392 DALI_TEST_CHECK(value.Get(enable));
393 DALI_TEST_CHECK(enable); // Default value is true
395 // loading started, this waits for the loader thread for max 30 seconds
396 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
398 application.SendNotification();
399 application.Render();
401 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
402 DALI_TEST_CHECK(value.Get(enable));
403 DALI_TEST_CHECK(!enable); // Should be false after loading
405 // conventional alpha blending
406 Renderer renderer1 = imageView1.GetRendererAt(0);
407 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
408 DALI_TEST_CHECK(value.Get(enable));
409 DALI_TEST_CHECK(!enable);
411 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
412 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
413 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
414 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
415 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
416 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
417 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
418 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
420 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
421 textureTrace.Reset();
423 ImageView imageView2 = ImageView::New();
424 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
426 // Disable pre-multiplied alpha blending
427 imageView2.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
429 application.GetScene().Add(imageView2);
431 application.SendNotification();
432 application.Render();
434 value = imageView2.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
435 DALI_TEST_CHECK(value.Get(enable));
436 DALI_TEST_CHECK(!enable);
438 // conventional alpha blending
439 Renderer renderer2 = imageView2.GetRendererAt(0);
440 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
441 DALI_TEST_CHECK(value.Get(enable));
442 DALI_TEST_CHECK(!enable);
444 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
445 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
446 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
447 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
448 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
449 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
450 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
451 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
453 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
458 int UtcDaliImageViewPixelArea(void)
460 // Test pixel area property
461 ToolkitTestApplication application;
463 static std::vector<UniformData> customUniforms =
465 UniformData("pixelArea", Property::Type::VECTOR4),
468 TestGraphicsController& graphics = application.GetGraphicsController();
469 graphics.AddCustomUniforms(customUniforms);
471 // Gif image, use AnimatedImageVisual internally
472 // Atlasing is applied to pack multiple frames, use custom wrap mode
473 ImageView gifView = ImageView::New();
474 const Vector4 pixelAreaVisual(0.f, 0.f, 2.f, 2.f);
475 gifView.SetProperty(ImageView::Property::IMAGE,
476 Property::Map().Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME).Add(ImageVisual::Property::PIXEL_AREA, pixelAreaVisual));
479 Integration::Scene stage = application.GetScene();
483 application.SendNotification();
484 application.Render(16);
486 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
488 application.SendNotification();
489 application.Render();
490 DALI_TEST_CHECK(gifView.GetRendererCount() == 1u);
492 const Vector4 fullTextureRect(0.f, 0.f, 1.f, 1.f);
493 // test that the pixel area value defined in the visual property map is registered on renderer
494 Renderer renderer = gifView.GetRendererAt(0);
495 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
496 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION);
498 // test that the shader has the default pixel area value registered.
499 Shader shader = renderer.GetShader();
500 pixelAreaValue = shader.GetProperty(shader.GetPropertyIndex("pixelArea"));
501 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION);
503 // test that the uniform uses the pixelArea property on the renderer.
504 TestGlAbstraction& gl = application.GetGlAbstraction();
505 Vector4 pixelAreaUniform;
506 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
507 DALI_TEST_EQUALS(pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
509 // set the pixelArea property on the control
510 const Vector4 pixelAreaControl(-1.f, -1.f, 3.f, 3.f);
511 gifView.SetProperty(ImageView::Property::PIXEL_AREA, pixelAreaControl);
512 application.SendNotification();
513 application.Render(16);
515 // check the pixelArea property on the control
516 pixelAreaValue = gifView.GetProperty(gifView.GetPropertyIndex("pixelArea"));
517 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION);
518 // test that the uniform uses the pixelArea property on the control.
519 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
520 DALI_TEST_EQUALS(pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
525 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
527 ToolkitTestApplication application;
528 TestGlAbstraction& gl = application.GetGlAbstraction();
529 const std::vector<GLuint>& textures = gl.GetBoundTextures();
530 size_t numTextures = textures.size();
532 // Async loading, no atlasing for big size image
533 ImageView imageView = ImageView::New(gImage_600_RGB);
535 // By default, Aysnc loading is used
536 application.GetScene().Add(imageView);
537 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
538 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
540 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
542 application.SendNotification();
543 application.Render(16);
544 application.SendNotification();
546 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
547 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
552 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
554 ToolkitTestApplication application;
556 //Async loading, automatic atlasing for small size image
557 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
559 callStack.Enable(true);
561 Property::Map imageMap;
563 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
564 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
565 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
566 imageMap[ImageVisual::Property::ATLASING] = true;
568 ImageView imageView = ImageView::New();
569 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
570 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
572 // By default, Aysnc loading is used
573 // loading is not started if the actor is offScene
575 application.GetScene().Add(imageView);
576 application.SendNotification();
577 application.Render(16);
578 application.Render(16);
579 application.SendNotification();
581 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
582 application.SendNotification();
583 application.Render(16);
584 application.Render(16);
585 application.SendNotification();
587 // loading started, this waits for the loader thread for max 30 seconds
588 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
590 application.SendNotification();
591 application.Render(16);
593 callStack.Enable(false);
595 TraceCallStack::NamedParams params;
596 params["width"] << 34;
597 params["height"] << 34;
598 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
603 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
605 ToolkitTestApplication application;
607 //Async loading, automatic atlasing for small size image
608 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
610 callStack.Enable(true);
612 Property::Map asyncLoadingMap;
613 asyncLoadingMap["url"] = gImage_34_RGBA;
614 asyncLoadingMap["desiredHeight"] = 34;
615 asyncLoadingMap["desiredWidth"] = 34;
616 asyncLoadingMap["synchronousLoading"] = false;
617 asyncLoadingMap["atlasing"] = true;
619 ImageView imageView = ImageView::New();
620 imageView.SetProperty(ImageView::Property::IMAGE, asyncLoadingMap);
622 application.GetScene().Add(imageView);
623 application.SendNotification();
624 application.Render(16);
625 application.Render(16);
626 application.SendNotification();
628 // loading started, this waits for the loader thread for max 30 seconds
629 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
631 application.SendNotification();
632 application.Render(16);
634 callStack.Enable(false);
636 TraceCallStack::NamedParams params;
637 params["width"] << 34;
638 params["height"] << 34;
639 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
644 int UtcDaliImageViewSyncLoading(void)
646 ToolkitTestApplication application;
648 tet_infoline("ImageView Testing sync loading and size using index key property map");
650 Property::Map syncLoadingMap;
651 syncLoadingMap[ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
652 syncLoadingMap[ImageVisual::Property::ATLASING] = true;
654 // Sync loading, no atlasing for big size image
656 ImageView imageView = ImageView::New();
658 // Sync loading is used
659 syncLoadingMap[ImageVisual::Property::URL] = gImage_600_RGB;
660 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
663 // Sync loading, automatic atlasing for small size image
665 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
667 callStack.Enable(true);
669 ImageView imageView = ImageView::New();
671 // Sync loading is used
672 syncLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
673 syncLoadingMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
674 syncLoadingMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
675 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
677 application.GetScene().Add(imageView);
678 application.SendNotification();
679 application.Render(16);
681 TraceCallStack::NamedParams params;
682 params["width"] << 34;
683 params["height"] << 34;
684 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
691 int UtcDaliImageViewSyncLoading02(void)
693 ToolkitTestApplication application;
695 tet_infoline("ImageView Testing sync loading and size using string key property map");
697 // Sync loading, automatic atlasing for small size image
699 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
701 callStack.Enable(true);
703 ImageView imageView = ImageView::New();
705 // Sync loading is used
706 Property::Map syncLoadingMap;
707 syncLoadingMap["url"] = gImage_34_RGBA;
708 syncLoadingMap["desiredHeight"] = 34;
709 syncLoadingMap["desiredWidth"] = 34;
710 syncLoadingMap["synchronousLoading"] = true;
711 syncLoadingMap["atlasing"] = true;
712 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
714 application.GetScene().Add(imageView);
715 application.SendNotification();
716 application.Render(16);
718 TraceCallStack::NamedParams params;
719 params["width"] << 34;
720 params["height"] << 34;
721 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
728 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
730 ToolkitTestApplication application;
731 TestGlAbstraction& gl = application.GetGlAbstraction();
732 const std::vector<GLuint>& textures = gl.GetBoundTextures();
733 size_t numTextures = textures.size();
735 // Get encoded raw-buffer image and generate url
736 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
737 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
739 // Async loading, no atlasing for big size image
740 ImageView imageView = ImageView::New(url.GetUrl());
742 // By default, Aysnc loading is used
743 application.GetScene().Add(imageView);
744 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
745 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
747 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
749 application.SendNotification();
750 application.Render(16);
751 application.SendNotification();
753 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
754 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
759 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
761 ToolkitTestApplication application;
763 // Get encoded raw-buffer image and generate url
764 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
765 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
766 ImageUrl url2 = Toolkit::Image::GenerateUrl(buffer);
768 // Generate url is not equal to url2
769 // NOTE : This behavior may changed when ImageUrl compare operator changed.
770 DALI_TEST_CHECK(url != url2);
771 // Generate url's string is equal to url2's string
772 DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
774 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
775 url2 = Toolkit::Image::GenerateUrl(buffer2);
777 // Check whethere two url are not equal
778 DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
780 // Async loading, automatic atlasing for small size image
781 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
783 callStack.Enable(true);
785 Property::Map imageMap;
787 imageMap[ImageVisual::Property::URL] = url.GetUrl();
788 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 600;
789 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 600;
790 imageMap[ImageVisual::Property::ATLASING] = true;
792 // No atlasing with big image
793 ImageView imageView_bigdesired = ImageView::New();
794 imageView_bigdesired.SetProperty(ImageView::Property::IMAGE, imageMap);
795 imageView_bigdesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
797 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 0;
798 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 0;
800 // No atlasing with zero desired size
801 ImageView imageView_nodesired = ImageView::New();
802 imageView_nodesired.SetProperty(ImageView::Property::IMAGE, imageMap);
803 imageView_nodesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
805 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
806 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
808 ImageView imageView = ImageView::New();
809 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
810 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
812 // By default, Aysnc loading is used
813 // loading is not started if the actor is offScene
814 application.GetScene().Add(imageView);
815 application.GetScene().Add(imageView_bigdesired);
816 application.GetScene().Add(imageView_nodesired);
817 application.SendNotification();
818 application.Render(16);
820 // loading started, this waits for the loader thread for max 30 seconds
821 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
823 application.Render(16);
824 application.SendNotification();
826 // Change url to url2
827 imageMap[ImageVisual::Property::URL] = url2.GetUrl();
828 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
830 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
831 application.SendNotification();
832 application.Render(16);
833 application.Render(16);
834 application.SendNotification();
836 // loading started, this waits for the loader thread for max 30 seconds
837 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
839 application.SendNotification();
840 application.Render(16);
842 callStack.Enable(false);
844 TraceCallStack::NamedParams params;
845 params["width"] << 34;
846 params["height"] << 34;
847 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
852 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
854 ToolkitTestApplication application;
856 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
858 // Get encoded raw-buffer image and generate url
859 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
860 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
862 // Sync loading, automatic atlasing for small size image
864 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
866 callStack.Enable(true);
868 ImageView imageView = ImageView::New();
870 // Sync loading is used
871 Property::Map syncLoadingMap;
872 syncLoadingMap["url"] = url.GetUrl();
873 syncLoadingMap["alphaMaskUrl"] = gImage_34_RGBA;
874 syncLoadingMap["desiredHeight"] = 34;
875 syncLoadingMap["desiredWidth"] = 34;
876 syncLoadingMap["synchronousLoading"] = true;
877 syncLoadingMap["atlasing"] = true;
878 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
880 application.GetScene().Add(imageView);
881 application.SendNotification();
882 application.Render(16);
884 TraceCallStack::NamedParams params;
885 params["width"] << 34;
886 params["height"] << 34;
887 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
895 int UtcDaliImageViewAddedTexture(void)
897 ToolkitTestApplication application;
899 tet_infoline("ImageView Testing image view with texture provided manager url");
901 ImageView imageView = ImageView::New();
903 // empty texture is ok, though pointless from app point of view
905 std::string url = TextureManager::AddTexture(empty);
906 DALI_TEST_CHECK(url.size() > 0u);
908 Property::Map propertyMap;
909 propertyMap[ImageVisual::Property::URL] = url;
910 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
912 application.GetScene().Add(imageView);
913 application.SendNotification();
914 application.Render();
919 int UtcDaliImageViewSizeWithBackground(void)
921 ToolkitTestApplication application;
925 ImageView imageView = ImageView::New();
927 imageView.SetProperty(Control::Property::BACKGROUND,
929 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
930 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
931 {ImageVisual::Property::DESIRED_WIDTH, width},
932 {ImageVisual::Property::DESIRED_HEIGHT, height},
935 application.GetScene().Add(imageView);
936 application.SendNotification();
937 application.Render();
939 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
940 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
945 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
947 ToolkitTestApplication application;
949 int widthBackground = 100;
950 int heightBackground = 200;
954 ImageView imageView = ImageView::New();
956 imageView.SetProperty(Control::Property::BACKGROUND,
958 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
959 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
960 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
961 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground},
964 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio, 600x600 pixels
966 application.GetScene().Add(imageView);
967 application.SendNotification();
968 application.Render();
970 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
971 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
976 int UtcDaliImageViewHeightForWidthBackground(void)
978 ToolkitTestApplication application;
980 int widthBackground = 100;
981 int heightBackground = 200;
983 ImageView imageView = ImageView::New();
985 imageView.SetProperty(Control::Property::BACKGROUND,
986 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
987 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
988 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
989 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}});
991 application.GetScene().Add(imageView);
992 application.SendNotification();
993 application.Render();
995 Control control = Control::DownCast(imageView);
996 DALI_TEST_CHECK(control);
997 DALI_TEST_EQUALS(imageView.GetHeightForWidth(123.f), control.GetHeightForWidth(123.f), TEST_LOCATION);
998 DALI_TEST_EQUALS(imageView.GetWidthForHeight(321.f), control.GetWidthForHeight(321.f), TEST_LOCATION);
1003 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
1005 ToolkitTestApplication application;
1007 int widthBackground = 100;
1008 int heightBackground = 200;
1012 ImageView imageView = ImageView::New();
1014 imageView.SetProperty(Control::Property::BACKGROUND,
1015 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1016 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1017 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1018 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}}); // 1 to 2 ratio
1020 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio
1022 application.GetScene().Add(imageView);
1023 application.SendNotification();
1024 application.Render();
1026 DALI_TEST_EQUALS(imageView.GetHeightForWidth(width), (float)height, TEST_LOCATION);
1027 DALI_TEST_EQUALS(imageView.GetWidthForHeight(height), (float)width, TEST_LOCATION);
1032 int UtcDaliImageViewSetImageUrl(void)
1034 ToolkitTestApplication application;
1036 ImageView imageView = ImageView::New();
1037 imageView.SetImage(TEST_IMAGE_FILE_NAME);
1038 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
1040 imageView.SetImage(TEST_IMAGE_FILE_NAME2);
1041 TestUrl(imageView, TEST_IMAGE_FILE_NAME2);
1046 bool gResourceReadySignalFired = false;
1047 Vector3 gNaturalSize;
1049 void ResourceReadySignal(Control control)
1051 gResourceReadySignalFired = true;
1054 int UtcDaliImageViewCheckResourceReady(void)
1056 ToolkitTestApplication application;
1058 gResourceReadySignalFired = false;
1060 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1061 ImageView imageView = ImageView::New(TEST_GIF_FILE_NAME);
1063 imageView.SetProperty(Control::Property::BACKGROUND,
1064 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1065 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1066 {ImageVisual::Property::DESIRED_WIDTH, 100},
1067 {ImageVisual::Property::DESIRED_HEIGHT, 200}});
1069 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1071 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1073 application.GetScene().Add(imageView);
1075 // loading started, this waits for the loader thread
1076 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1078 application.SendNotification();
1079 application.Render(16);
1081 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1083 application.SendNotification();
1084 application.Render();
1086 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1088 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1093 int UtcDaliImageViewSetImageTypeChangesP(void)
1095 ToolkitTestApplication application;
1097 ImageView imageView = ImageView::New();
1098 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1100 application.GetScene().Add(imageView);
1104 Toolkit::Visual::Base visual;
1106 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1107 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1109 application.SendNotification();
1110 application.Render(16);
1112 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1114 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1115 DALI_TEST_CHECK(!visual); // Visual should be invalid
1118 imageView.SetImage("TEST_URL");
1120 application.SendNotification();
1121 application.Render(16);
1123 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1124 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1126 DALI_TEST_CHECK(value.Get(url)); // Value should NOT be empty
1127 DALI_TEST_CHECK(!value.Get(map)); // Value should be empty
1128 DALI_TEST_CHECK(visual); // Visual should be valid
1131 imageView.SetImage("");
1133 application.SendNotification();
1134 application.Render(16);
1136 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1137 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1139 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1141 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1142 DALI_TEST_CHECK(!visual); // Visual should be invalid
1144 // Set a URL in property map
1145 Property::Map propertyMap;
1146 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1147 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1149 application.SendNotification();
1150 application.Render(16);
1152 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1153 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1155 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1156 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1157 DALI_TEST_CHECK(visual); // Visual should be valid
1159 // Set a URL in property map again
1160 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1161 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1163 application.SendNotification();
1164 application.Render(16);
1166 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1167 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1169 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1170 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1171 DALI_TEST_CHECK(visual); // Visual should be valid
1173 // Set an empty URL in property map
1174 propertyMap[ImageVisual::Property::URL] = std::string();
1175 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1177 application.SendNotification();
1178 application.Render(16);
1180 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1181 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1183 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1184 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1185 DALI_TEST_CHECK(!visual); // Visual should be invalid
1187 // Set a URL in property map again
1188 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1189 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1191 application.SendNotification();
1192 application.Render(16);
1194 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1195 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1197 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1198 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1199 DALI_TEST_CHECK(visual); // Visual should be valid
1201 // Set an empty property map
1202 propertyMap.Clear();
1203 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1205 application.SendNotification();
1206 application.Render(16);
1208 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1209 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1211 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1212 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1213 DALI_TEST_CHECK(map.Empty()); // But PropertyMap should be empty
1214 DALI_TEST_CHECK(!visual); // Visual should be invalid
1219 int UtcDaliImageViewResourceUrlP(void)
1221 ToolkitTestApplication application;
1223 ImageView imageView = ImageView::New();
1224 DALI_TEST_CHECK(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>().empty());
1226 imageView.SetProperty(ImageView::Property::IMAGE, "TestString");
1227 DALI_TEST_EQUALS(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>(), "TestString", TEST_LOCATION);
1232 int UtcDaliImageViewReplaceImage(void)
1234 ToolkitTestApplication application;
1236 gResourceReadySignalFired = false;
1238 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1239 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1241 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1243 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1245 application.GetScene().Add(imageView);
1247 application.SendNotification();
1248 application.Render(16);
1250 // loading started, this waits for the loader thread for max 30 seconds
1251 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1253 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1255 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1257 gResourceReadySignalFired = false;
1259 imageView.SetImage(TEST_IMAGE_2);
1261 application.SendNotification();
1262 application.Render(16);
1264 // loading started, this waits for the loader thread for max 30 seconds
1265 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1267 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1269 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1271 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1276 void OnRelayoutOverride(Size size)
1278 gNaturalSize = size; // Size Relayout is using
1281 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1283 ToolkitTestApplication application;
1285 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1286 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1287 imageView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1289 DummyControl dummyControl = DummyControl::New(true);
1290 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1291 dummyControl.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
1293 dummyControl.Add(imageView);
1294 dummyImpl.SetRelayoutCallback(&OnRelayoutOverride);
1295 application.GetScene().Add(dummyControl);
1297 application.SendNotification();
1298 application.Render();
1300 // loading started, this waits for the loader thread for max 30 seconds
1301 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1303 DALI_TEST_EQUALS(gNaturalSize.width, 1024.0f, TEST_LOCATION);
1304 DALI_TEST_EQUALS(gNaturalSize.height, 1024.0f, TEST_LOCATION);
1306 gNaturalSize = Vector3::ZERO;
1308 imageView.SetImage(gImage_600_RGB);
1310 // Waiting for resourceReady so SendNotifcation not called here.
1312 // loading started, this waits for the loader thread for max 30 seconds
1313 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1315 // Trigger a potential relayout
1316 application.SendNotification();
1317 application.Render();
1319 DALI_TEST_EQUALS(gNaturalSize.width, 600.0f, TEST_LOCATION);
1320 DALI_TEST_EQUALS(gNaturalSize.height, 600.0f, TEST_LOCATION);
1325 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1327 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1329 ToolkitTestApplication application;
1331 gResourceReadySignalFired = false;
1333 Property::Map imageMap;
1335 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1336 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1338 tet_infoline("Creating ImageView without URL so image does not start loading");
1339 ImageView imageView = ImageView::New();
1340 tet_infoline("Connect to image loaded signal before setting image");
1341 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1342 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1343 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1345 // loading started, this waits for the loader thread
1346 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1348 application.SendNotification();
1349 application.Render(16);
1351 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1356 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1358 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1360 ToolkitTestApplication application;
1362 gResourceReadySignalFired = false;
1364 Property::Map imageMap;
1366 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1367 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1369 ImageView imageView = ImageView::New();
1370 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1371 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1373 // loading started, this waits for the loader thread
1374 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1376 application.SendNotification();
1377 application.Render(16);
1379 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1380 gResourceReadySignalFired = false;
1382 ImageView imageViewWithExistingImage = ImageView::New();
1383 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1384 imageViewWithExistingImage.SetProperty(ImageView::Property::IMAGE, imageMap);
1386 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1391 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1393 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1395 ToolkitTestApplication application;
1397 gResourceReadySignalFired = false;
1399 Property::Map imageImmediateLoadingMap;
1400 imageImmediateLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1401 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1403 tet_infoline("Immediate load an image");
1404 ImageView imageView = ImageView::New();
1405 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1406 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
1408 // loading started, this waits for the loader thread
1409 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1411 application.SendNotification();
1412 application.Render(16);
1414 tet_infoline("Check image loaded");
1415 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1416 gResourceReadySignalFired = false;
1418 tet_infoline("Create another ImageView with the same URL");
1419 ImageView imageViewWithExistingImage = ImageView::New(gImage_34_RGBA);
1420 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1421 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1423 application.GetScene().Add(imageViewWithExistingImage);
1425 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1430 int UtcDaliImageViewPaddingProperty(void)
1432 ToolkitTestApplication application;
1434 ImageView imageView = ImageView::New();
1435 Property::Map imagePropertyMap;
1436 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1437 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
1438 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1439 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1440 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1441 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1442 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1443 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1444 application.GetScene().Add(imageView);
1446 application.SendNotification();
1447 application.Render();
1449 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1451 ImageView childImage = ImageView::New();
1452 childImage.SetBackgroundColor(Color::BLACK);
1453 childImage.SetProperty(Actor::Property::SIZE, Vector2(10.f, 10.f));
1454 imageView.Add(childImage);
1456 application.SendNotification();
1457 application.Render();
1459 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1460 DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
1462 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1463 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1464 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1465 Property::Map resultMap;
1466 imageVisual.CreatePropertyMap(resultMap);
1468 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1469 DALI_TEST_CHECK(transformValue);
1470 Property::Map* retMap = transformValue->GetMap();
1471 DALI_TEST_CHECK(retMap);
1473 // Image Visual should be positioned depending on ImageView's padding
1474 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1479 int UtcDaliImageViewPaddingProperty02(void)
1481 ToolkitTestApplication application;
1483 ImageView imageView = ImageView::New();
1484 Property::Map imagePropertyMap;
1485 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1486 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1487 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1488 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1489 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1490 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1491 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1492 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1493 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1494 application.GetScene().Add(imageView);
1496 application.SendNotification();
1497 application.Render();
1499 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1501 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1502 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1503 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1504 Property::Map resultMap;
1505 imageVisual.CreatePropertyMap(resultMap);
1507 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1508 DALI_TEST_CHECK(transformValue);
1509 Property::Map* retMap = transformValue->GetMap();
1510 DALI_TEST_CHECK(retMap);
1512 // Image Visual should be positioned depending on ImageView's padding
1513 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1518 int UtcDaliImageViewPaddingProperty03(void)
1520 tet_infoline("Test Setting Image Padding then removing it.");
1522 ToolkitTestApplication application;
1524 ImageView imageView = ImageView::New();
1525 Property::Map imagePropertyMap;
1526 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1527 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1528 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1529 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1530 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1531 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1532 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1533 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1534 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1535 application.GetScene().Add(imageView);
1537 application.SendNotification();
1538 application.Render();
1540 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1542 tet_infoline("Remove Padding and test Visual is position correctly");
1544 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1546 application.SendNotification();
1547 application.Render();
1549 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1550 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1551 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1552 Property::Map resultMap;
1553 imageVisual.CreatePropertyMap(resultMap);
1555 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1556 DALI_TEST_CHECK(transformValue);
1557 Property::Map* retMap = transformValue->GetMap();
1558 DALI_TEST_CHECK(retMap);
1560 // Image Visual should be positioned depending on ImageView's padding
1561 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1566 int UtcDaliImageViewPaddingProperty04(void)
1568 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1570 ToolkitTestApplication application;
1572 ImageView imageView = ImageView::New();
1573 Property::Map imagePropertyMap;
1574 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1575 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1576 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1577 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1578 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FILL;
1579 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1580 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1581 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1582 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1583 application.GetScene().Add(imageView);
1585 application.SendNotification();
1586 application.Render();
1588 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1590 tet_infoline("Remove Padding and test Visual is position correctly");
1592 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1594 application.SendNotification();
1595 application.Render();
1597 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1598 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1599 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1600 Property::Map resultMap;
1601 imageVisual.CreatePropertyMap(resultMap);
1603 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1604 DALI_TEST_CHECK(transformValue);
1605 Property::Map* retMap = transformValue->GetMap();
1606 DALI_TEST_CHECK(retMap);
1608 // Image Visual should be positioned depending on ImageView's padding
1609 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1614 int UtcDaliImageViewTransformTest01(void)
1616 tet_infoline("Test Setting a offset transform on the ImageView");
1618 ToolkitTestApplication application;
1620 ImageView imageView = ImageView::New();
1621 Property::Map imagePropertyMap;
1622 imagePropertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE)
1623 .Add(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/Kid1.svg")
1624 .Add(ImageVisual::Property::DESIRED_WIDTH, 120)
1625 .Add(ImageVisual::Property::DESIRED_HEIGHT, 120)
1626 .Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL)
1627 .Add(Visual::Property::TRANSFORM,
1628 Property::Map().Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1629 Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE))
1630 .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(8, 8)));
1632 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1633 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1634 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1635 application.GetScene().Add(imageView);
1637 application.SendNotification();
1638 application.Render();
1640 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1641 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1642 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1643 Property::Map resultMap;
1644 imageVisual.CreatePropertyMap(resultMap);
1646 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1647 DALI_TEST_CHECK(transformValue);
1648 Property::Map* retMap = transformValue->GetMap();
1649 DALI_TEST_CHECK(retMap);
1651 // Image Visual should be positioned depending on ImageView's padding
1652 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(8, 8), TEST_LOCATION);
1653 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);
1658 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1660 ToolkitTestApplication application;
1662 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1663 ImageView imageView = ImageView::New();
1664 Property::Map imageMap;
1665 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1666 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_34_RGBA;
1667 imageMap[Toolkit::ImageVisual::Property::ATLASING] = true;
1668 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1669 application.GetScene().Add(imageView);
1671 // Trigger a potential relayout
1672 application.SendNotification();
1673 application.Render();
1675 Vector3 naturalSize = imageView.GetNaturalSize();
1677 DALI_TEST_EQUALS(naturalSize.width, 34.0f, TEST_LOCATION);
1678 DALI_TEST_EQUALS(naturalSize.height, 34.0f, TEST_LOCATION);
1683 int UtcDaliImageViewFillMode(void)
1685 ToolkitTestApplication application;
1687 tet_infoline("Create an ImageVisual without padding and set the fill-mode to fill");
1689 ImageView imageView = ImageView::New();
1690 Property::Map imageMap;
1691 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1692 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB);
1693 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL);
1695 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1697 application.GetScene().Add(imageView);
1699 // Trigger a potential relayout
1700 application.SendNotification();
1701 application.Render();
1703 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1704 Property::Map returnedMap;
1705 visual.CreatePropertyMap(returnedMap);
1707 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1708 DALI_TEST_CHECK(value);
1709 Property::Map* map = value->GetMap();
1710 DALI_TEST_CHECK(map);
1712 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1713 DALI_TEST_CHECK(value);
1714 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION);
1716 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1717 DALI_TEST_CHECK(value);
1718 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1723 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1725 ToolkitTestApplication application;
1727 tet_infoline("Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )");
1728 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1730 ImageView imageView = ImageView::New();
1731 Property::Map imageMap;
1732 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1733 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1734 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
1736 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1737 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1739 application.GetScene().Add(imageView);
1741 // Trigger a potential relayout
1742 application.SendNotification();
1743 application.Render();
1745 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1746 Property::Map returnedMap;
1747 visual.CreatePropertyMap(returnedMap);
1749 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1750 DALI_TEST_CHECK(value);
1751 Property::Map* map = value->GetMap();
1752 DALI_TEST_CHECK(map);
1755 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1756 DALI_TEST_CHECK(value);
1757 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION);
1759 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1760 DALI_TEST_CHECK(value);
1761 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1763 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1764 DALI_TEST_CHECK(value);
1765 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
1770 int UtcDaliImageViewFittingModesFill(void)
1772 ToolkitTestApplication application;
1774 tet_infoline("Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )");
1775 tet_infoline(" There should be no need to change the transform, only size is changed to fit view");
1777 ImageView imageView = ImageView::New();
1778 Property::Map imageMap;
1779 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1780 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1781 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL);
1783 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1784 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1786 application.GetScene().Add(imageView);
1788 // Trigger a potential relayout
1789 application.SendNotification();
1790 application.Render();
1792 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1793 Property::Map returnedMap;
1794 visual.CreatePropertyMap(returnedMap);
1796 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1797 DALI_TEST_CHECK(value);
1798 Property::Map* map = value->GetMap();
1799 DALI_TEST_CHECK(map);
1801 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1802 DALI_TEST_CHECK(value);
1803 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Change the internal size according to the image view size
1805 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1806 DALI_TEST_CHECK(value);
1807 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1809 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1810 DALI_TEST_CHECK(value);
1811 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1816 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1818 ToolkitTestApplication application;
1820 tet_infoline("Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )");
1821 tet_infoline(" offset or size is the same as view, but adjust internally using pixelArea ");
1823 ImageView imageView = ImageView::New();
1824 Property::Map imageMap;
1825 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1826 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1827 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO);
1829 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1830 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 500));
1832 application.GetScene().Add(imageView);
1834 // Trigger a potential relayout
1835 application.SendNotification();
1836 application.Render();
1838 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1839 Property::Map returnedMap;
1840 visual.CreatePropertyMap(returnedMap);
1842 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1843 DALI_TEST_CHECK(value);
1844 Property::Map* map = value->GetMap();
1845 DALI_TEST_CHECK(map);
1848 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1849 DALI_TEST_CHECK(value);
1850 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 500), TEST_LOCATION); // Change the internal size according to the image view size
1852 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1853 DALI_TEST_CHECK(value);
1854 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1856 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1857 DALI_TEST_CHECK(value);
1858 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1863 int UtcDaliImageViewFittingModesCenter01(void)
1865 ToolkitTestApplication application;
1867 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [700,700] )");
1868 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1870 ImageView imageView = ImageView::New();
1871 Property::Map imageMap;
1872 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1873 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1874 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1876 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1877 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1879 application.GetScene().Add(imageView);
1881 // Trigger a potential relayout
1882 application.SendNotification();
1883 application.Render();
1885 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1886 Property::Map returnedMap;
1887 visual.CreatePropertyMap(returnedMap);
1889 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1890 DALI_TEST_CHECK(value);
1891 Property::Map* map = value->GetMap();
1892 DALI_TEST_CHECK(map);
1894 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1895 DALI_TEST_CHECK(value);
1896 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1898 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1899 DALI_TEST_CHECK(value);
1900 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1902 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1903 DALI_TEST_CHECK(value);
1904 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1909 int UtcDaliImageViewFittingModesCenter02(void)
1911 ToolkitTestApplication application;
1913 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [500,500] )");
1914 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1916 ImageView imageView = ImageView::New();
1917 Property::Map imageMap;
1918 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1919 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1920 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1922 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1923 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1925 application.GetScene().Add(imageView);
1927 // Trigger a potential relayout
1928 application.SendNotification();
1929 application.Render();
1931 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1932 Property::Map returnedMap;
1933 visual.CreatePropertyMap(returnedMap);
1935 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1936 DALI_TEST_CHECK(value);
1937 Property::Map* map = value->GetMap();
1938 DALI_TEST_CHECK(map);
1940 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1941 DALI_TEST_CHECK(value);
1942 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1944 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1945 DALI_TEST_CHECK(value);
1946 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1948 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1949 DALI_TEST_CHECK(value);
1950 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1955 int UtcDaliImageViewFittingModesFitHeight01(void)
1957 ToolkitTestApplication application;
1959 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )");
1961 ImageView imageView = ImageView::New();
1962 Property::Map imageMap;
1963 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1964 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1965 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1967 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1968 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1970 application.GetScene().Add(imageView);
1972 // Trigger a potential relayout
1973 application.SendNotification();
1974 application.Render();
1976 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1977 Property::Map returnedMap;
1978 visual.CreatePropertyMap(returnedMap);
1980 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1981 DALI_TEST_CHECK(value);
1982 Property::Map* map = value->GetMap();
1983 DALI_TEST_CHECK(map);
1985 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1986 DALI_TEST_CHECK(value);
1987 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 700), TEST_LOCATION); // Change the internal size according to the image view size
1989 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1990 DALI_TEST_CHECK(value);
1991 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1993 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1994 DALI_TEST_CHECK(value);
1995 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2000 int UtcDaliImageViewFittingModesFitHeight02(void)
2002 ToolkitTestApplication application;
2004 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )");
2006 ImageView imageView = ImageView::New();
2007 Property::Map imageMap;
2008 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2009 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2010 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2012 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2013 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2015 application.GetScene().Add(imageView);
2017 // Trigger a potential relayout
2018 application.SendNotification();
2019 application.Render();
2021 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2022 Property::Map returnedMap;
2023 visual.CreatePropertyMap(returnedMap);
2025 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2026 DALI_TEST_CHECK(value);
2027 Property::Map* map = value->GetMap();
2028 DALI_TEST_CHECK(map);
2030 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2031 DALI_TEST_CHECK(value);
2032 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2034 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2035 DALI_TEST_CHECK(value);
2036 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2038 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2039 DALI_TEST_CHECK(value);
2040 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2045 int UtcDaliImageViewFittingModesFitWidth01(void)
2047 ToolkitTestApplication application;
2049 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )");
2051 ImageView imageView = ImageView::New();
2052 Property::Map imageMap;
2053 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2054 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2055 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2057 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2058 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2060 application.GetScene().Add(imageView);
2062 // Trigger a potential relayout
2063 application.SendNotification();
2064 application.Render();
2066 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2067 Property::Map returnedMap;
2068 visual.CreatePropertyMap(returnedMap);
2070 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2071 DALI_TEST_CHECK(value);
2072 Property::Map* map = value->GetMap();
2073 DALI_TEST_CHECK(map);
2075 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2076 DALI_TEST_CHECK(value);
2077 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2079 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2080 DALI_TEST_CHECK(value);
2081 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2083 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2084 DALI_TEST_CHECK(value);
2085 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
2090 int UtcDaliImageViewFittingModesFitWidth02(void)
2092 ToolkitTestApplication application;
2094 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )");
2096 ImageView imageView = ImageView::New();
2097 Property::Map imageMap;
2098 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2099 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2100 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2102 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2103 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2105 application.GetScene().Add(imageView);
2107 // Trigger a potential relayout
2108 application.SendNotification();
2109 application.Render();
2111 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2112 Property::Map returnedMap;
2113 visual.CreatePropertyMap(returnedMap);
2115 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2116 DALI_TEST_CHECK(value);
2117 Property::Map* map = value->GetMap();
2118 DALI_TEST_CHECK(map);
2120 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2121 DALI_TEST_CHECK(value);
2122 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 600), TEST_LOCATION); // Change the internal size according to the image view size
2124 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2125 DALI_TEST_CHECK(value);
2126 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2128 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2129 DALI_TEST_CHECK(value);
2130 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2135 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2137 ToolkitTestApplication application;
2139 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2141 ImageView imageView = ImageView::New();
2143 // 1. Render using FittingMode::SHRINK_TO_FIT
2144 Property::Map imageMap;
2145 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2146 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2147 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2149 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2150 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2152 application.GetScene().Add(imageView);
2154 // Trigger a potential relayout
2155 application.SendNotification();
2156 application.Render();
2158 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2159 Property::Map returnedMap;
2160 visual.CreatePropertyMap(returnedMap);
2162 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2163 DALI_TEST_CHECK(value);
2164 Property::Map* map = value->GetMap();
2165 DALI_TEST_CHECK(map);
2167 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2168 DALI_TEST_CHECK(value);
2169 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2171 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2172 DALI_TEST_CHECK(value);
2173 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2175 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2176 DALI_TEST_CHECK(value);
2177 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2179 // 2. Render again using DevelVisaul::CENTER
2180 Property::Map imageMap2;
2181 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2182 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2183 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2185 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2186 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2188 application.GetScene().Add(imageView);
2190 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2192 // Trigger a potential relayout
2193 application.SendNotification();
2194 application.Render();
2196 returnedMap.Clear();
2197 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2199 visual.CreatePropertyMap(returnedMap);
2201 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2202 DALI_TEST_CHECK(value);
2203 map = value->GetMap();
2204 DALI_TEST_CHECK(map);
2206 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2207 DALI_TEST_CHECK(value);
2208 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2210 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2211 DALI_TEST_CHECK(value);
2212 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2214 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2215 DALI_TEST_CHECK(value);
2216 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2218 // 3. Render again using before fittingMode
2219 Property::Map imageMap3;
2220 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2221 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2222 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2224 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2225 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2227 application.GetScene().Add(imageView);
2229 // Trigger a potential relayout
2230 application.SendNotification();
2231 application.Render();
2233 returnedMap.Clear();
2234 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2235 visual.CreatePropertyMap(returnedMap);
2237 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2238 DALI_TEST_CHECK(value);
2239 map = value->GetMap();
2240 DALI_TEST_CHECK(map);
2242 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2243 DALI_TEST_CHECK(value);
2244 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2246 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2247 DALI_TEST_CHECK(value);
2248 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2250 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2251 DALI_TEST_CHECK(value);
2252 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2257 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2259 ToolkitTestApplication application;
2261 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2263 ImageView imageView = ImageView::New();
2265 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2266 Property::Map imageMap;
2267 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2268 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2269 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2271 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2272 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2274 application.GetScene().Add(imageView);
2276 // Trigger a potential relayout
2277 application.SendNotification();
2278 application.Render();
2280 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2281 Property::Map returnedMap;
2282 visual.CreatePropertyMap(returnedMap);
2284 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2285 DALI_TEST_CHECK(value);
2286 Property::Map* map = value->GetMap();
2287 DALI_TEST_CHECK(map);
2289 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2290 DALI_TEST_CHECK(value);
2291 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2293 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2294 DALI_TEST_CHECK(value);
2295 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2297 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2298 DALI_TEST_CHECK(value);
2299 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2301 // 2. Render again using DevelVisaul::CENTER
2302 Property::Map imageMap2;
2303 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2304 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2305 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2307 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2308 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2310 application.GetScene().Add(imageView);
2312 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2314 // Trigger a potential relayout
2315 application.SendNotification();
2316 application.Render();
2318 returnedMap.Clear();
2319 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2321 visual.CreatePropertyMap(returnedMap);
2323 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2324 DALI_TEST_CHECK(value);
2325 map = value->GetMap();
2326 DALI_TEST_CHECK(map);
2328 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2329 DALI_TEST_CHECK(value);
2330 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2332 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2333 DALI_TEST_CHECK(value);
2334 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2336 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2337 DALI_TEST_CHECK(value);
2338 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2340 // 3. Render again using before fittingMode
2341 Property::Map imageMap3;
2342 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2343 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2344 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2346 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2347 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2349 application.GetScene().Add(imageView);
2351 // Trigger a potential relayout
2352 application.SendNotification();
2353 application.Render();
2355 returnedMap.Clear();
2356 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2357 visual.CreatePropertyMap(returnedMap);
2359 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2360 DALI_TEST_CHECK(value);
2361 map = value->GetMap();
2362 DALI_TEST_CHECK(map);
2364 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2365 DALI_TEST_CHECK(value);
2366 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2368 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2369 DALI_TEST_CHECK(value);
2370 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2372 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2373 DALI_TEST_CHECK(value);
2374 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2379 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2381 ToolkitTestApplication application;
2383 tet_infoline("Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )");
2385 ImageView imageView = ImageView::New();
2386 Property::Map imageMap;
2387 imageMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE);
2388 imageMap.Add(Toolkit::ImageVisual::Property::URL, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME); // 249x169 image
2390 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2391 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
2393 application.GetScene().Add(imageView);
2395 // Trigger a potential relayout
2396 application.SendNotification();
2397 application.Render();
2399 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2400 Property::Map returnedMap;
2401 visual.CreatePropertyMap(returnedMap);
2403 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2404 DALI_TEST_CHECK(value);
2405 Property::Map* map = value->GetMap();
2406 DALI_TEST_CHECK(map);
2408 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2409 DALI_TEST_CHECK(value);
2410 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Relative size so will take up 100%
2412 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2413 DALI_TEST_CHECK(value);
2414 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2416 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2417 DALI_TEST_CHECK(value);
2418 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2423 int UtcDaliImageViewCustomShader(void)
2425 ToolkitTestApplication application;
2427 // Set a custom shader with an image url
2429 Property::Map properties;
2430 Property::Map shader;
2431 const std::string vertexShader = "Foobar";
2432 const std::string fragmentShader = "Foobar";
2433 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2434 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2436 properties[Visual::Property::TYPE] = Visual::IMAGE;
2437 properties[Visual::Property::SHADER] = shader;
2438 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2440 ImageView imageView = ImageView::New();
2441 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2443 application.GetScene().Add(imageView);
2445 application.SendNotification();
2446 application.Render();
2448 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2450 Renderer renderer = imageView.GetRendererAt(0);
2451 Shader shader2 = renderer.GetShader();
2452 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2453 Property::Map* map = value.GetMap();
2454 DALI_TEST_CHECK(map);
2456 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2457 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2459 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2460 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2463 // Set a custom shader after setting an image url
2465 Property::Map properties;
2466 Property::Map shader;
2467 const std::string vertexShader = "Foobar";
2468 const std::string fragmentShader = "Foobar";
2469 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2470 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2472 properties[Visual::Property::SHADER] = shader;
2474 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
2475 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2477 application.GetScene().Add(imageView);
2479 application.SendNotification();
2480 application.Render();
2482 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2484 Renderer renderer = imageView.GetRendererAt(0);
2485 Shader shader2 = renderer.GetShader();
2486 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2487 Property::Map* map = value.GetMap();
2488 DALI_TEST_CHECK(map);
2490 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2491 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2493 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2494 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2497 // Set a custom shader before setting an image url
2499 Property::Map properties;
2500 Property::Map shader;
2501 const std::string vertexShader = "Foobar";
2502 const std::string fragmentShader = "Foobar";
2503 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2504 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2506 properties[Visual::Property::SHADER] = shader;
2508 ImageView imageView = ImageView::New();
2509 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2510 imageView.SetProperty(ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME);
2512 application.GetScene().Add(imageView);
2514 application.SendNotification();
2515 application.Render();
2516 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2518 Renderer renderer = imageView.GetRendererAt(0);
2519 Shader shader2 = renderer.GetShader();
2520 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2521 Property::Map* map = value.GetMap();
2522 DALI_TEST_CHECK(map);
2524 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2525 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2527 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2528 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2531 // Set a custom shader after setting a property map
2533 Property::Map properties;
2534 Property::Map shader;
2535 const std::string vertexShader = "Foobar";
2536 const std::string fragmentShader = "Foobar";
2537 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2538 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2540 properties[Visual::Property::SHADER] = shader;
2542 Property::Map properties1;
2543 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2544 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2546 ImageView imageView = ImageView::New();
2547 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2548 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2550 application.GetScene().Add(imageView);
2552 application.SendNotification();
2553 application.Render();
2554 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2556 Renderer renderer = imageView.GetRendererAt(0);
2557 Shader shader2 = renderer.GetShader();
2558 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2559 Property::Map* map = value.GetMap();
2560 DALI_TEST_CHECK(map);
2562 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2563 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2565 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2566 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2569 // Set a custom shader before setting a property map
2571 Property::Map properties;
2572 Property::Map shader;
2573 const std::string vertexShader = "Foobar";
2574 const std::string fragmentShader = "Foobar";
2575 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2576 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2578 properties[Visual::Property::SHADER] = shader;
2580 Property::Map properties1;
2581 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2582 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2584 ImageView imageView = ImageView::New();
2585 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2586 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2588 application.GetScene().Add(imageView);
2590 application.SendNotification();
2591 application.Render();
2592 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2594 Renderer renderer = imageView.GetRendererAt(0);
2595 Shader shader2 = renderer.GetShader();
2596 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2597 Property::Map* map = value.GetMap();
2598 DALI_TEST_CHECK(map);
2600 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2601 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2603 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2604 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2612 static int gFailCounter = 0;
2613 const int MAX_RETRIES(3);
2615 void ReloadImage(ImageView imageView)
2617 Property::Map imageImmediateLoadingMap;
2618 imageImmediateLoadingMap[ImageVisual::Property::URL] = "Non-existant-image.jpg";
2619 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
2621 tet_infoline("Immediate load an image");
2622 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
2625 void ResourceFailedReload(Control control)
2628 if(gFailCounter < MAX_RETRIES)
2630 ReloadImage(ImageView::DownCast(control));
2635 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2637 tet_infoline("Test reloading failed image from within signal handler.");
2639 ToolkitTestApplication application;
2643 ImageView imageView = ImageView::New();
2644 imageView.ResourceReadySignal().Connect(&ResourceFailedReload);
2645 DALI_TEST_EQUALS(gFailCounter, 0, TEST_LOCATION);
2646 ReloadImage(imageView);
2648 // loading started, this waits for the loader thread to complete
2649 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2650 application.SendNotification();
2652 DALI_TEST_EQUALS(gFailCounter, 1, TEST_LOCATION);
2654 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2655 application.SendNotification();
2657 DALI_TEST_EQUALS(gFailCounter, 2, TEST_LOCATION);
2659 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2660 application.SendNotification();
2661 DALI_TEST_EQUALS(gFailCounter, 3, TEST_LOCATION);
2666 int UtcDaliImageViewLoadRemoteSVG(void)
2668 tet_infoline("Test load from a remote server.");
2670 ToolkitTestApplication application;
2673 Toolkit::ImageView imageView;
2674 imageView = Toolkit::ImageView::New();
2675 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2676 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2677 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2678 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2679 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2681 application.GetScene().Add(imageView);
2683 DALI_TEST_CHECK(imageView);
2685 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2687 application.SendNotification();
2689 // Wait for loading & rasterization
2690 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2692 application.SendNotification();
2693 application.Render();
2695 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2700 Toolkit::ImageView imageView;
2701 imageView = Toolkit::ImageView::New();
2702 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2703 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2704 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2705 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2707 application.GetScene().Add(imageView);
2709 DALI_TEST_CHECK(imageView);
2711 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2713 application.SendNotification();
2715 // Wait for loading & rasterization
2716 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2718 application.SendNotification();
2719 application.Render();
2721 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2727 int UtcDaliImageViewSyncSVGLoading(void)
2729 ToolkitTestApplication application;
2731 tet_infoline("ImageView Testing SVG image sync loading");
2734 ImageView imageView = ImageView::New();
2736 // Sync loading is used
2737 Property::Map syncLoadingMap;
2738 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2739 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2740 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2741 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2743 application.GetScene().Add(imageView);
2744 DALI_TEST_CHECK(imageView);
2746 application.SendNotification();
2747 Vector3 naturalSize = imageView.GetNaturalSize();
2749 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2750 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2755 int UtcDaliImageViewAsyncSVGLoading(void)
2757 ToolkitTestApplication application;
2759 tet_infoline("ImageView Testing SVG image async loading");
2762 ImageView imageView = ImageView::New();
2764 // Async loading is used - default value of SYNCHRONOUS_LOADING is false.
2765 Property::Map propertyMap;
2766 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2767 propertyMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2768 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
2770 application.GetScene().Add(imageView);
2771 DALI_TEST_CHECK(imageView);
2773 application.SendNotification();
2776 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2778 application.SendNotification();
2779 application.Render(16);
2781 Vector3 naturalSize = imageView.GetNaturalSize();
2782 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2783 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2788 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2790 ToolkitTestApplication application;
2792 tet_infoline("ImageView Testing SVG image async loading");
2796 ImageView imageView = ImageView::New();
2798 // Sync loading is used
2799 Property::Map syncLoadingMap;
2800 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2801 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2803 // Check to set invalid value
2804 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2805 // Check if error log is outputted when setting other value like string.
2806 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2807 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5));
2808 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2810 application.GetScene().Add(imageView);
2811 DALI_TEST_CHECK(imageView);
2813 application.SendNotification();
2816 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2818 application.SendNotification();
2819 application.Render(16);
2821 Vector3 naturalSize = imageView.GetNaturalSize();
2822 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2823 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2825 Property::Value value = imageView.GetProperty(ImageView::Property::IMAGE);
2826 Property::Map* map = value.GetMap();
2827 DALI_TEST_CHECK(map);
2829 Property::Value* sync = map->Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING);
2830 DALI_TEST_CHECK(sync);
2831 DALI_TEST_EQUALS(false, sync->Get<bool>(), TEST_LOCATION);
2836 int UtcDaliImageViewSvgLoadingFailure(void)
2838 // Local svg file - invalid file path
2840 ToolkitTestApplication application;
2842 TestGlAbstraction& gl = application.GetGlAbstraction();
2843 TraceCallStack& textureTrace = gl.GetTextureTrace();
2844 textureTrace.Enable(true);
2846 gResourceReadySignalFired = false;
2848 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2849 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2850 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2852 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2854 application.GetScene().Add(imageView);
2856 application.SendNotification();
2858 // loading started, this waits for the loader thread - load
2859 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2861 application.SendNotification();
2862 application.Render(16);
2864 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2865 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2866 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2868 // Should be shown a broken image
2869 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2870 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2873 // Local svg file - invalid file path without size set
2875 ToolkitTestApplication application;
2877 TestGlAbstraction& gl = application.GetGlAbstraction();
2878 TraceCallStack& textureTrace = gl.GetTextureTrace();
2879 textureTrace.Enable(true);
2881 gResourceReadySignalFired = false;
2882 textureTrace.Reset();
2884 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2885 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2887 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2889 application.GetScene().Add(imageView);
2891 application.SendNotification();
2893 // loading started, this waits for the loader thread - load & rasterize
2894 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2896 application.SendNotification();
2897 application.Render(16);
2899 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2900 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2901 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2903 // Should be shown a broken image
2904 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2905 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2908 // Local svg file - invalid file
2910 ToolkitTestApplication application;
2912 TestGlAbstraction& gl = application.GetGlAbstraction();
2913 TraceCallStack& textureTrace = gl.GetTextureTrace();
2914 textureTrace.Enable(true);
2916 gResourceReadySignalFired = false;
2917 textureTrace.Reset();
2919 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.svg");
2920 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2921 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2923 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2925 application.GetScene().Add(imageView);
2927 application.SendNotification();
2929 // loading started, this waits for the loader thread - load & rasterize
2930 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2932 application.SendNotification();
2933 application.Render(16);
2935 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2936 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2937 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2939 // Should be shown a broken image
2940 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2941 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2946 ToolkitTestApplication application;
2948 TestGlAbstraction& gl = application.GetGlAbstraction();
2949 TraceCallStack& textureTrace = gl.GetTextureTrace();
2950 textureTrace.Enable(true);
2952 gResourceReadySignalFired = false;
2953 textureTrace.Reset();
2955 ImageView imageView = ImageView::New("https://bar.org/foobar.svg");
2956 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2957 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2959 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2961 application.GetScene().Add(imageView);
2963 application.SendNotification();
2965 // loading started, this waits for the loader thread - load & rasterize
2966 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2968 application.SendNotification();
2969 application.Render(16);
2971 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2972 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2973 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2975 // Should be shown a broken image
2976 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2977 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2980 // Remote svg file without size set
2982 ToolkitTestApplication application;
2984 TestGlAbstraction& gl = application.GetGlAbstraction();
2985 TraceCallStack& textureTrace = gl.GetTextureTrace();
2986 textureTrace.Enable(true);
2988 gResourceReadySignalFired = false;
2989 textureTrace.Reset();
2991 ImageView imageView = ImageView::New("https://bar.org/foobar.svg");
2992 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2994 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2996 application.GetScene().Add(imageView);
2998 application.SendNotification();
3000 // loading started, this waits for the loader thread - load & rasterize
3001 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3003 application.SendNotification();
3004 application.Render(16);
3006 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3007 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3008 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3010 // Should be shown a broken image
3011 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3012 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3018 int UtcDaliImageViewSvgRasterizationFailure(void)
3020 ToolkitTestApplication application;
3022 gResourceReadySignalFired = false;
3024 TestGlAbstraction& gl = application.GetGlAbstraction();
3025 TraceCallStack& textureTrace = gl.GetTextureTrace();
3026 textureTrace.Enable(true);
3028 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid1.svg");
3029 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3030 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3032 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3034 application.GetScene().Add(imageView);
3036 application.SendNotification();
3038 // Wait for loading & rasterization
3039 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3041 application.SendNotification();
3042 application.Render(16);
3044 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3045 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3046 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3048 // Should be shown a broken image
3049 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3050 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3055 int UtcDaliImageViewSvgChageSize(void)
3057 ToolkitTestApplication application;
3059 TestGlAbstraction& gl = application.GetGlAbstraction();
3060 TraceCallStack& textureTrace = gl.GetTextureTrace();
3061 textureTrace.Enable(true);
3063 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME);
3064 application.GetScene().Add(imageView);
3066 application.SendNotification();
3068 // Wait for loading & rasterization
3069 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3071 application.SendNotification();
3072 application.Render(16);
3074 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3076 // Change actor size, then rasterization should be done again
3077 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3079 application.SendNotification();
3081 // Wait for rasterization
3082 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3084 application.SendNotification();
3085 application.Render(16);
3087 // We should not load the file again.
3088 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3093 int UtcDaliImageViewSvgAtlasing(void)
3095 ToolkitTestApplication application;
3097 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
3099 callStack.Enable(true);
3101 Property::Map propertyMap;
3102 propertyMap["url"] = TEST_SVG_FILE_NAME;
3103 propertyMap["atlasing"] = true;
3105 ImageView imageView = ImageView::New();
3106 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
3107 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3108 application.GetScene().Add(imageView);
3110 application.SendNotification();
3112 // Wait for loading & rasterization
3113 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3115 application.SendNotification();
3116 application.Render(16);
3119 TraceCallStack::NamedParams params1;
3120 params1["width"] << 100;
3121 params1["height"] << 100;
3122 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params1), true, TEST_LOCATION);
3124 imageView.SetProperty(Actor::Property::SIZE, Vector2(600.f, 600.f));
3126 application.SendNotification();
3128 // Wait for rasterization
3129 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3133 application.SendNotification();
3134 application.Render(16);
3137 TraceCallStack::NamedParams params2;
3138 params2["width"] << 600;
3139 params2["height"] << 600;
3140 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexImage2D", params2), true, TEST_LOCATION);
3145 int UtcDaliImageViewTVGLoading(void)
3147 ToolkitTestApplication application;
3149 tet_infoline("ImageView Testing TVG image loading");
3152 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/test.tvg");
3153 application.GetScene().Add(imageView);
3154 DALI_TEST_CHECK(imageView);
3156 application.SendNotification();
3158 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3160 application.SendNotification();
3161 application.Render(16);
3163 Vector3 naturalSize = imageView.GetNaturalSize();
3165 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3166 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3171 int UtcDaliImageViewImageLoadFailure01(void)
3173 ToolkitTestApplication application;
3175 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3176 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3177 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3178 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3180 std::string brokenUrl;
3181 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3182 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3184 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3185 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3187 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3188 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3190 ImageView imageView = ImageView::New("invalidUrl.png");
3191 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3193 application.GetScene().Add(imageView);
3194 application.SendNotification();
3195 application.Render(16);
3197 // loading started, this waits for the loader thread
3198 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3203 int UtcDaliImageViewImageLoadFailure02(void)
3205 ToolkitTestApplication application;
3207 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3208 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
3209 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3210 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3212 std::string brokenUrl;
3213 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3214 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
3216 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3217 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3219 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3220 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3222 ImageView imageView = ImageView::New("invalidUrl.png");
3223 imageView.SetProperty(Actor::Property::SIZE, Vector2(30.f, 30.f));
3224 application.GetScene().Add(imageView);
3225 application.SendNotification();
3226 application.Render(16);
3228 // loading started, this waits for the loader thread
3229 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3234 int UtcDaliImageViewImageLoadFailure03(void)
3236 ToolkitTestApplication application;
3238 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3239 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
3240 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
3242 std::string brokenUrl;
3243 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3244 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3246 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3247 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3249 ImageView imageView = ImageView::New("invalidUrl.png");
3250 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3251 application.GetScene().Add(imageView);
3252 application.SendNotification();
3253 application.Render(16);
3255 // loading started, this waits for the loader thread
3256 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3261 int UtcDaliImageViewImageLoadFailure04(void)
3263 ToolkitTestApplication application;
3265 ImageView imageView = ImageView::New("invalidUrl.png");
3266 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3267 application.GetScene().Add(imageView);
3268 application.SendNotification();
3269 application.Render(16);
3271 // loading started, this waits for the loader thread
3272 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3274 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3275 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3276 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3277 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3279 ImageView imageView2 = ImageView::New("invalidUrl.png");
3280 imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3281 application.GetScene().Add(imageView2);
3283 std::string brokenUrl;
3284 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3285 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3287 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3288 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3290 application.SendNotification();
3291 application.Render(16);
3293 // loading started, this waits for the loader thread
3294 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3296 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3298 ImageView imageView3 = ImageView::New("invalidUrl.png");
3299 imageView3.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3300 application.GetScene().Add(imageView3);
3302 application.SendNotification();
3303 application.Render(16);
3305 // loading started, this waits for the loader thread
3306 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3313 static int gResourceReadySignalCounter = 0;
3315 void OnResourceReadySignal01(Control control)
3317 gResourceReadySignalCounter++;
3319 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3321 if(gResourceReadySignalCounter == 1)
3324 // It makes the first new visual be deleted immediately
3325 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3326 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3329 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3331 // Make the resource ready immediately
3332 control[ImageView::Property::IMAGE] = gImage_600_RGB;
3336 void OnResourceReadySignal02(Control control)
3338 if(++gResourceReadySignalCounter == 1)
3340 // It makes the first new visual be deleted immediately
3341 // The first image will not be loaded.
3342 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB).Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3343 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3347 ImageView gImageView1;
3348 ImageView gImageView2;
3349 ImageView gImageView3;
3350 ImageView gImageView4;
3352 void OnResourceReadySignal03(Control control)
3354 if(gResourceReadySignalCounter == 0)
3357 // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3358 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3360 // 2. Load a new image
3361 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3363 // 3. Use the new image again
3364 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3365 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3367 else if(gResourceReadySignalCounter == 1)
3369 // This is called from TextureManager::ProcessQueuedTextures().
3370 gImageView1.Unparent();
3371 gImageView1.Reset();
3373 gResourceReadySignalCounter++;
3376 void OnSimpleResourceReadySignal(Control control)
3378 // simply increate counter
3379 gResourceReadySignalCounter++;
3382 int gResourceReadySignal04ComesOrder = 0;
3384 void OnResourceReadySignal04(Control control)
3386 gResourceReadySignalCounter++;
3387 tet_printf("rc %d\n", gResourceReadySignalCounter);
3388 if(gResourceReadySignalCounter == 1)
3390 auto scene = gImageView1.GetParent();
3392 // Request load something
3393 // We hope this request result is return later than gImageView2.
3394 gImageView3 = ImageView::New(TEST_IMAGE_1);
3395 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3396 scene.Add(gImageView3);
3397 gImageView4 = ImageView::New(TEST_IMAGE_2);
3398 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3399 scene.Add(gImageView4);
3401 if(control == gImageView1)
3403 gResourceReadySignal04ComesOrder = 1;
3407 gResourceReadySignal04ComesOrder = 2;
3410 if(gResourceReadySignalCounter == 2)
3412 if(gResourceReadySignal04ComesOrder == 1 && control == gImageView2)
3414 // Scene off first one.
3415 gImageView1.Unparent();
3417 // Scene off second one.
3418 gImageView2.Unparent();
3420 else if(gResourceReadySignal04ComesOrder == 2 && control == gImageView1)
3422 // Scene off first one.
3423 gImageView2.Unparent();
3425 // Scene off second one.
3426 gImageView1.Unparent();
3430 // We can't check that this utc fail case. just pass always when we come here.
3431 gResourceReadySignal04ComesOrder = -1;
3434 // If we don't seperate index of FreeList area
3435 // and if we don't queue remove during obversing,
3436 // cache index become something invalid data.
3437 // In this case, some strange observer can be called.
3438 // For example, gImageView4.LoadComplete will be called.
3444 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3446 tet_infoline("Test setting image from within signal handler.");
3448 ToolkitTestApplication application;
3450 gResourceReadySignalCounter = 0;
3452 ImageView imageView = ImageView::New(gImage_34_RGBA);
3453 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal01);
3455 application.GetScene().Add(imageView);
3457 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3459 application.SendNotification();
3460 application.Render();
3462 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3464 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3466 // Create a new ImageView to cache the image
3467 ImageView imageView1 = ImageView::New(gImage_600_RGB);
3468 application.GetScene().Add(imageView1);
3470 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3472 application.SendNotification();
3473 application.Render();
3476 gResourceReadySignalCounter = 0;
3478 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3480 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3482 application.SendNotification();
3483 application.Render();
3485 // Run idle callback
3486 application.RunIdles();
3488 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3490 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3495 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
3497 tet_infoline("Test setting image from within signal handler.");
3499 ToolkitTestApplication application;
3501 gResourceReadySignalCounter = 0;
3503 ImageView imageView = ImageView::New(gImage_34_RGBA);
3504 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal02);
3506 application.GetScene().Add(imageView);
3508 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3510 application.SendNotification();
3511 application.Render();
3513 // Wait for loading an image
3514 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3516 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3518 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3523 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3525 tet_infoline("Test setting image from within signal handler.");
3527 ToolkitTestApplication application;
3529 gResourceReadySignalCounter = 0;
3531 gImageView1 = ImageView::New(gImage_34_RGBA);
3532 application.GetScene().Add(gImageView1);
3535 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3537 gImageView2 = ImageView::New(gImage_600_RGB);
3538 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3539 application.GetScene().Add(gImageView2);
3541 gImageView3 = ImageView::New();
3542 application.GetScene().Add(gImageView3);
3544 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3546 application.SendNotification();
3547 application.Render();
3552 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask01(void)
3554 tet_infoline("Test signal handler when image / mask image is broken.");
3556 ToolkitTestApplication application;
3558 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, const std::string& url, const std::string& mask, const char* location) {
3559 gResourceReadySignalCounter = 0;
3562 map[Toolkit::ImageVisual::Property::URL] = url;
3565 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3567 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3569 ImageView imageView = ImageView::New();
3570 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3571 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3572 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3574 application.GetScene().Add(imageView);
3575 application.SendNotification();
3576 application.Render();
3581 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3583 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3584 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3586 imageView.Unparent();
3589 for(int synchronous = 0; synchronous <= 1; synchronous++)
3591 tet_printf("Test normal case (sync:%d)\n", synchronous);
3592 TestResourceReadyUrl(1, synchronous, gImage_600_RGB, "", TEST_LOCATION);
3593 TestResourceReadyUrl(3, synchronous, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 3 event trigger required : 2 image load + 1 apply mask
3595 tet_printf("Test broken image case (sync:%d)\n", synchronous);
3596 TestResourceReadyUrl(1, synchronous, "invalid.jpg", "", TEST_LOCATION);
3597 TestResourceReadyUrl(2, synchronous, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3599 tet_printf("Test broken mask image case (sync:%d)\n", synchronous);
3600 TestResourceReadyUrl(2, synchronous, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3602 tet_printf("Test broken both image, mask image case (sync:%d)\n", synchronous);
3603 TestResourceReadyUrl(2, synchronous, "invalid.jpg", "invalid.png", TEST_LOCATION);
3609 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask02(void)
3611 tet_infoline("Test signal handler when image try to use cached-and-broken mask image.");
3613 ToolkitTestApplication application;
3615 gResourceReadySignalCounter = 0;
3617 auto TestBrokenMaskResourceReadyUrl = [&application](const std::string& url, const char* location) {
3619 map[Toolkit::ImageVisual::Property::URL] = url;
3620 // Use invalid mask url
3621 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
3623 ImageView imageView = ImageView::New();
3624 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3625 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3626 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3628 application.GetScene().Add(imageView);
3629 application.SendNotification();
3630 application.Render();
3632 // Don't unparent imageView, for keep the cache.
3635 // Use more than 4 images (The number of LocalImageLoadThread)
3636 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};
3638 int expectResourceReadySignalCounter = 0;
3640 for(auto& url : testUrlList)
3642 TestBrokenMaskResourceReadyUrl(url, TEST_LOCATION);
3643 expectResourceReadySignalCounter++;
3646 // Remain 1 signal due to we use #URL + 1 mask image.
3647 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(expectResourceReadySignalCounter + 1), true, TEST_LOCATION);
3649 DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
3654 int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
3656 tet_infoline("Test signal handler various case.");
3658 auto TestResourceReadyUrl = [](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
3659 ToolkitTestApplication application;
3661 gResourceReadySignalCounter = 0;
3664 map[Toolkit::ImageVisual::Property::URL] = url;
3667 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3669 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3671 ImageView imageView = ImageView::New();
3672 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3673 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3674 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3676 application.GetScene().Add(imageView);
3677 application.SendNotification();
3678 application.Render();
3681 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3683 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3684 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3685 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3687 imageView.Unparent();
3690 auto TestAuxiliaryResourceReadyUrl = [](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
3691 ToolkitTestApplication application;
3693 gResourceReadySignalCounter = 0;
3696 map[Toolkit::ImageVisual::Property::URL] = url;
3697 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE] = auxiliaryUrl;
3698 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA] = 0.5f;
3699 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3701 ImageView imageView = ImageView::New();
3702 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
3703 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
3704 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3705 application.GetScene().Add(imageView);
3707 application.SendNotification();
3708 application.Render();
3713 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, location);
3716 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3717 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3718 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3720 imageView.Unparent();
3723 // Case 1 : asynchronous loading
3724 tet_printf("Test invalid single simple image Asynchronous\n");
3727 TestResourceReadyUrl(1, 0, 1, gImage_600_RGB, "", TEST_LOCATION);
3728 TestResourceReadyUrl(2, 0, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // load & rasterize
3729 TestResourceReadyUrl(1, 0, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
3731 TestResourceReadyUrl(2, 0, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // 2 image loading - batch size
3732 TestResourceReadyUrl(1, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // 1 rasterize
3734 TestResourceReadyUrl(3, 0, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 2 image loading + 1 applymask
3736 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
3739 TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
3740 TestResourceReadyUrl(1, 0, 0, "invalid.svg", "", TEST_LOCATION);
3741 TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
3742 TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION); // 1 image loading
3743 TestResourceReadyUrl(0, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
3745 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", "invalid.png", TEST_LOCATION); // 2 image loading
3746 TestResourceReadyUrl(2, 0, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); // 2 image loading
3747 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION); // 2 image loading
3749 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
3750 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
3751 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
3753 // Case 2 : Synchronous loading
3754 tet_printf("Test invalid single simple image Synchronous\n");
3757 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "", TEST_LOCATION);
3758 TestResourceReadyUrl(0, 1, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
3759 TestResourceReadyUrl(0, 1, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
3761 TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // first frame image loading sync + second frame image loading async
3762 TestResourceReadyUrl(0, 1, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
3764 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION);
3766 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
3769 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
3770 TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION);
3771 TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
3772 TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
3773 TestResourceReadyUrl(0, 1, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
3775 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "invalid.png", TEST_LOCATION);
3776 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3777 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3779 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
3780 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
3781 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
3786 int UtcDaliImageViewSetImageOnResourceReadySignal04(void)
3788 tet_infoline("Test texturemanager's remove queue works well within signal handler.");
3790 ToolkitTestApplication application;
3792 gResourceReadySignalCounter = 0;
3793 gResourceReadySignal04ComesOrder = 0;
3795 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
3796 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3797 application.GetScene().Add(gImageView1);
3799 gImageView2 = ImageView::New("invalid.png"); // request invalid image, to make loading failed fast.
3800 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3801 application.GetScene().Add(gImageView2);
3803 application.SendNotification();
3804 application.Render();
3806 tet_infoline("Try to load 2 invalid image");
3808 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3809 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3811 tet_infoline("load done");
3813 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
3814 if(gResourceReadySignal04ComesOrder == -1)
3816 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
3820 // gImageView3 and gImageView4 load must not be successed yet.
3821 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
3822 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
3824 application.SendNotification();
3825 application.Render();
3827 tet_infoline("Try to load 2 valid image");
3829 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3830 DALI_TEST_EQUALS(gResourceReadySignalCounter, 4, TEST_LOCATION);
3832 tet_infoline("load done");
3834 // gImageView3 and gImageView4 load must be successed now.
3835 DALI_TEST_EQUALS(gImageView3.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
3836 DALI_TEST_EQUALS(gImageView4.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);