2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
24 #include <dali-toolkit-test-suite-utils.h>
25 #include <toolkit-event-thread-callback.h>
26 #include <toolkit-vector-image-renderer.h>
27 #include "dummy-control.h"
29 #include <test-encoded-image-buffer.h>
30 #include <test-native-image.h>
32 #include <dali-toolkit/dali-toolkit.h>
33 #include <dali-toolkit/devel-api/controls/control-devel.h>
34 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
35 #include <dali-toolkit/devel-api/styling/style-manager-devel.h>
36 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
37 #include <dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h>
38 #include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
39 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
40 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
41 #include <dali-toolkit/public-api/image-loader/image-url.h>
42 #include <dali-toolkit/public-api/image-loader/image.h>
43 #include <dali/devel-api/scripting/scripting.h>
46 using namespace Toolkit;
48 void utc_dali_toolkit_image_view_startup(void)
50 test_return_value = TET_UNDEF;
53 void utc_dali_toolkit_image_view_cleanup(void)
55 test_return_value = TET_PASS;
60 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
61 const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
63 // resolution: 1024*1024
64 const char* TEST_IMAGE_1 = TEST_RESOURCE_DIR "/TB-gloss.png";
65 const char* TEST_IMAGE_2 = TEST_RESOURCE_DIR "/tb-norm.png";
67 const char* TEST_BROKEN_IMAGE_DEFAULT = TEST_RESOURCE_DIR "/broken.png";
68 const char* TEST_BROKEN_IMAGE_S = TEST_RESOURCE_DIR "/broken_s.9.png";
69 const char* TEST_BROKEN_IMAGE_M = TEST_RESOURCE_DIR "/broken_m.9.png";
70 const char* TEST_BROKEN_IMAGE_L = TEST_RESOURCE_DIR "/broken_l.9.png";
71 const char* TEST_BROKEN_IMAGE_01 = TEST_RESOURCE_DIR "/button-up.9.png";
72 const char* TEST_BROKEN_IMAGE_02 = TEST_RESOURCE_DIR "/heartsframe.9.png";
74 const char* TEST_INVALID_NPATCH_FILE_NAME_01 = "invalid1.9.png";
76 // resolution: 34*34, pixel format: RGBA8888
77 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
78 // resolution: 600*600, pixel format: RGB888
79 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
81 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
82 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
84 const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
85 const char* TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
86 const char* TEST_WEBP_FILE_NAME = TEST_RESOURCE_DIR "/dali-logo.webp";
88 void TestUrl(ImageView imageView, const std::string url)
90 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
92 std::string urlActual;
93 DALI_TEST_CHECK(value.Get(urlActual));
94 DALI_TEST_EQUALS(urlActual, url, TEST_LOCATION);
99 int UtcDaliImageViewNewP(void)
101 ToolkitTestApplication application;
103 ImageView imageView = ImageView::New();
105 DALI_TEST_CHECK(imageView);
110 int UtcDaliImageViewNewUrlP(void)
112 ToolkitTestApplication application;
114 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
115 DALI_TEST_CHECK(imageView);
117 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
122 int UtcDaliImageViewConstructorP(void)
124 ToolkitTestApplication application;
128 DALI_TEST_CHECK(!imageView);
133 int UtcDaliImageViewCopyConstructorP(void)
135 ToolkitTestApplication application;
137 // Initialize an object, ref count == 1
138 ImageView imageView = ImageView::New();
140 ImageView copy(imageView);
141 DALI_TEST_CHECK(copy);
146 int UtcDaliImageViewMoveConstructor(void)
148 ToolkitTestApplication application;
150 ImageView imageView = ImageView::New();
151 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
152 imageView.SetProperty(Actor::Property::SENSITIVE, false);
153 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
155 ImageView moved = std::move(imageView);
156 DALI_TEST_CHECK(moved);
157 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
158 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
159 DALI_TEST_CHECK(!imageView);
164 int UtcDaliImageViewAssignmentOperatorP(void)
166 ToolkitTestApplication application;
168 ImageView imageView = ImageView::New();
170 ImageView copy(imageView);
171 DALI_TEST_CHECK(copy);
172 DALI_TEST_EQUALS(imageView, copy, TEST_LOCATION);
177 int UtcDaliImageViewMoveAssignment(void)
179 ToolkitTestApplication application;
181 ImageView imageView = ImageView::New();
182 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
183 imageView.SetProperty(Actor::Property::SENSITIVE, false);
184 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
187 moved = std::move(imageView);
188 DALI_TEST_CHECK(moved);
189 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
190 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
191 DALI_TEST_CHECK(!imageView);
196 int UtcDaliImageViewDownCastP(void)
198 ToolkitTestApplication application;
200 ImageView imageView = ImageView::New();
202 BaseHandle object(imageView);
204 ImageView imageView2 = ImageView::DownCast(object);
205 DALI_TEST_CHECK(imageView2);
207 ImageView imageView3 = DownCast<ImageView>(object);
208 DALI_TEST_CHECK(imageView3);
213 int UtcDaliImageViewDownCastN(void)
215 ToolkitTestApplication application;
217 BaseHandle unInitializedObject;
219 ImageView imageView1 = ImageView::DownCast(unInitializedObject);
220 DALI_TEST_CHECK(!imageView1);
222 ImageView imageView2 = DownCast<ImageView>(unInitializedObject);
223 DALI_TEST_CHECK(!imageView2);
228 int UtcDaliImageViewTypeRegistry(void)
230 ToolkitTestApplication application;
232 TypeRegistry typeRegistry = TypeRegistry::Get();
233 DALI_TEST_CHECK(typeRegistry);
235 TypeInfo typeInfo = typeRegistry.GetTypeInfo("ImageView");
236 DALI_TEST_CHECK(typeInfo);
238 BaseHandle handle = typeInfo.CreateInstance();
239 DALI_TEST_CHECK(handle);
241 ImageView imageView = ImageView::DownCast(handle);
242 DALI_TEST_CHECK(imageView);
247 int UtcDaliImageViewSetGetProperty01(void)
249 ToolkitTestApplication application;
251 ImageView imageView = ImageView::New();
253 Property::Index idx = imageView.GetPropertyIndex("image");
254 DALI_TEST_EQUALS(idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION);
256 imageView.SetProperty(idx, TEST_IMAGE_FILE_NAME);
257 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
262 int UtcDaliImageViewPreMultipliedAlphaPng(void)
264 ToolkitTestApplication application;
266 // Set up trace debug
267 TestGlAbstraction& gl = application.GetGlAbstraction();
268 TraceCallStack& textureTrace = gl.GetTextureTrace();
269 textureTrace.Enable(true);
271 Property::Map imageMap;
272 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
273 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
275 ImageView imageView1 = ImageView::New();
276 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
278 application.GetScene().Add(imageView1);
280 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
282 DALI_TEST_CHECK(value.Get(enable));
283 DALI_TEST_CHECK(enable); // Default value is true
285 // loading started, this waits for the loader thread for max 30 seconds
286 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
288 application.SendNotification();
289 application.Render();
291 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
292 DALI_TEST_CHECK(value.Get(enable));
293 DALI_TEST_CHECK(enable); // Keep true
295 // conventional alpha blending
296 Renderer renderer1 = imageView1.GetRendererAt(0);
297 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
298 DALI_TEST_CHECK(value.Get(enable));
299 DALI_TEST_CHECK(enable);
301 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
302 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
303 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
304 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
305 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
306 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
307 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
308 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
310 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
311 textureTrace.Reset();
313 // Disable pre-multiplied alpha blending
314 imageView1.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
317 Property::Map attributes;
318 DevelControl::DoAction(imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
320 // loading started, this waits for the loader thread for max 30 seconds
321 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
323 application.SendNotification();
324 application.Render();
326 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
327 DALI_TEST_CHECK(value.Get(enable));
328 DALI_TEST_CHECK(!enable);
330 // conventional alpha blending
331 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
332 DALI_TEST_CHECK(value.Get(enable));
333 DALI_TEST_CHECK(!enable);
335 srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
336 destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
337 srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
338 destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
339 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
340 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
341 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
342 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
344 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
345 textureTrace.Reset();
347 // Make a new ImageView using the same image
348 ImageView imageView2 = ImageView::New();
349 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
351 application.GetScene().Add(imageView2);
353 application.SendNotification();
354 application.Render();
356 Renderer renderer2 = imageView2.GetRendererAt(0);
357 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
358 DALI_TEST_CHECK(value.Get(enable));
359 DALI_TEST_CHECK(enable);
361 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
362 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
363 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
364 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
365 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
366 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
367 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
368 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
370 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
375 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
377 ToolkitTestApplication application;
379 // Set up trace debug
380 TestGlAbstraction& gl = application.GetGlAbstraction();
381 TraceCallStack& textureTrace = gl.GetTextureTrace();
382 textureTrace.Enable(true);
384 Property::Map imageMap;
385 imageMap[ImageVisual::Property::URL] = gImage_600_RGB;
386 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
388 ImageView imageView1 = ImageView::New();
389 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
391 application.GetScene().Add(imageView1);
393 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
395 DALI_TEST_CHECK(value.Get(enable));
396 DALI_TEST_CHECK(enable); // Default value is true
398 // loading started, this waits for the loader thread for max 30 seconds
399 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
401 application.SendNotification();
402 application.Render();
404 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
405 DALI_TEST_CHECK(value.Get(enable));
406 DALI_TEST_CHECK(!enable); // Should be false after loading
408 // conventional alpha blending
409 Renderer renderer1 = imageView1.GetRendererAt(0);
410 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
411 DALI_TEST_CHECK(value.Get(enable));
412 DALI_TEST_CHECK(!enable);
414 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
415 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
416 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
417 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
418 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
419 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
420 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
421 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
423 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
424 textureTrace.Reset();
426 ImageView imageView2 = ImageView::New();
427 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
429 // Disable pre-multiplied alpha blending
430 imageView2.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
432 application.GetScene().Add(imageView2);
434 application.SendNotification();
435 application.Render();
437 value = imageView2.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
438 DALI_TEST_CHECK(value.Get(enable));
439 DALI_TEST_CHECK(!enable);
441 // conventional alpha blending
442 Renderer renderer2 = imageView2.GetRendererAt(0);
443 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
444 DALI_TEST_CHECK(value.Get(enable));
445 DALI_TEST_CHECK(!enable);
447 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
448 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
449 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
450 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
451 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
452 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
453 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
454 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
456 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
461 int UtcDaliImageViewPixelArea(void)
463 // Test pixel area property
464 ToolkitTestApplication application;
466 static std::vector<UniformData> customUniforms =
468 UniformData("pixelArea", Property::Type::VECTOR4),
471 TestGraphicsController& graphics = application.GetGraphicsController();
472 graphics.AddCustomUniforms(customUniforms);
474 // Gif image, use AnimatedImageVisual internally
475 // Atlasing is applied to pack multiple frames, use custom wrap mode
476 ImageView gifView = ImageView::New();
477 const Vector4 pixelAreaVisual(0.f, 0.f, 2.f, 2.f);
478 gifView.SetProperty(ImageView::Property::IMAGE,
479 Property::Map().Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME).Add(ImageVisual::Property::PIXEL_AREA, pixelAreaVisual));
482 Integration::Scene stage = application.GetScene();
486 application.SendNotification();
487 application.Render(16);
489 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
491 application.SendNotification();
492 application.Render();
493 DALI_TEST_CHECK(gifView.GetRendererCount() == 1u);
495 const Vector4 fullTextureRect(0.f, 0.f, 1.f, 1.f);
496 // test that the pixel area value defined in the visual property map is registered on renderer
497 Renderer renderer = gifView.GetRendererAt(0);
498 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
499 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION);
501 // test that the shader has the default pixel area value registered.
502 Shader shader = renderer.GetShader();
503 pixelAreaValue = shader.GetProperty(shader.GetPropertyIndex("pixelArea"));
504 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION);
506 // test that the uniform uses the pixelArea property on the renderer.
507 TestGlAbstraction& gl = application.GetGlAbstraction();
508 Vector4 pixelAreaUniform;
509 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
510 DALI_TEST_EQUALS(pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
512 // set the pixelArea property on the control
513 const Vector4 pixelAreaControl(-1.f, -1.f, 3.f, 3.f);
514 gifView.SetProperty(ImageView::Property::PIXEL_AREA, pixelAreaControl);
515 application.SendNotification();
516 application.Render(16);
518 // check the pixelArea property on the control
519 pixelAreaValue = gifView.GetProperty(gifView.GetPropertyIndex("pixelArea"));
520 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION);
521 // test that the uniform uses the pixelArea property on the control.
522 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
523 DALI_TEST_EQUALS(pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
528 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
530 ToolkitTestApplication application;
531 TestGlAbstraction& gl = application.GetGlAbstraction();
532 const std::vector<GLuint>& textures = gl.GetBoundTextures();
533 size_t numTextures = textures.size();
535 // Async loading, no atlasing for big size image
536 ImageView imageView = ImageView::New(gImage_600_RGB);
538 // By default, Aysnc loading is used
539 application.GetScene().Add(imageView);
540 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
541 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
543 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
545 application.SendNotification();
546 application.Render(16);
547 application.SendNotification();
549 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
550 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
555 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
557 ToolkitTestApplication application;
559 //Async loading, automatic atlasing for small size image
560 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
562 callStack.Enable(true);
564 Property::Map imageMap;
566 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
567 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
568 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
569 imageMap[ImageVisual::Property::ATLASING] = true;
571 ImageView imageView = ImageView::New();
572 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
573 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
575 // By default, Aysnc loading is used
576 // loading is not started if the actor is offScene
578 application.GetScene().Add(imageView);
579 application.SendNotification();
580 application.Render(16);
581 application.Render(16);
582 application.SendNotification();
584 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
585 application.SendNotification();
586 application.Render(16);
587 application.Render(16);
588 application.SendNotification();
590 // loading started, this waits for the loader thread for max 30 seconds
591 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
593 application.SendNotification();
594 application.Render(16);
596 callStack.Enable(false);
598 TraceCallStack::NamedParams params;
599 params["width"] << 34;
600 params["height"] << 34;
601 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
606 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
608 ToolkitTestApplication application;
610 //Async loading, automatic atlasing for small size image
611 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
613 callStack.Enable(true);
615 Property::Map asyncLoadingMap;
616 asyncLoadingMap["url"] = gImage_34_RGBA;
617 asyncLoadingMap["desiredHeight"] = 34;
618 asyncLoadingMap["desiredWidth"] = 34;
619 asyncLoadingMap["synchronousLoading"] = false;
620 asyncLoadingMap["atlasing"] = true;
622 ImageView imageView = ImageView::New();
623 imageView.SetProperty(ImageView::Property::IMAGE, asyncLoadingMap);
625 application.GetScene().Add(imageView);
626 application.SendNotification();
627 application.Render(16);
628 application.Render(16);
629 application.SendNotification();
631 // loading started, this waits for the loader thread for max 30 seconds
632 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
634 application.SendNotification();
635 application.Render(16);
637 callStack.Enable(false);
639 TraceCallStack::NamedParams params;
640 params["width"] << 34;
641 params["height"] << 34;
642 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
647 int UtcDaliImageViewSyncLoading(void)
649 ToolkitTestApplication application;
651 tet_infoline("ImageView Testing sync loading and size using index key property map");
653 Property::Map syncLoadingMap;
654 syncLoadingMap[ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
655 syncLoadingMap[ImageVisual::Property::ATLASING] = true;
657 // Sync loading, no atlasing for big size image
659 ImageView imageView = ImageView::New();
661 // Sync loading is used
662 syncLoadingMap[ImageVisual::Property::URL] = gImage_600_RGB;
663 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
666 // Sync loading, automatic atlasing for small size image
668 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
670 callStack.Enable(true);
672 ImageView imageView = ImageView::New();
674 // Sync loading is used
675 syncLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
676 syncLoadingMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
677 syncLoadingMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
678 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
680 application.GetScene().Add(imageView);
681 application.SendNotification();
682 application.Render(16);
684 TraceCallStack::NamedParams params;
685 params["width"] << 34;
686 params["height"] << 34;
687 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
694 int UtcDaliImageViewSyncLoading02(void)
696 ToolkitTestApplication application;
698 tet_infoline("ImageView Testing sync loading and size using string key property map");
700 // Sync loading, automatic atlasing for small size image
702 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
704 callStack.Enable(true);
706 ImageView imageView = ImageView::New();
708 // Sync loading is used
709 Property::Map syncLoadingMap;
710 syncLoadingMap["url"] = gImage_34_RGBA;
711 syncLoadingMap["desiredHeight"] = 34;
712 syncLoadingMap["desiredWidth"] = 34;
713 syncLoadingMap["synchronousLoading"] = true;
714 syncLoadingMap["atlasing"] = true;
715 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
717 application.GetScene().Add(imageView);
718 application.SendNotification();
719 application.Render(16);
721 TraceCallStack::NamedParams params;
722 params["width"] << 34;
723 params["height"] << 34;
724 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
731 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
733 ToolkitTestApplication application;
734 TestGlAbstraction& gl = application.GetGlAbstraction();
735 const std::vector<GLuint>& textures = gl.GetBoundTextures();
736 size_t numTextures = textures.size();
738 // Get encoded raw-buffer image and generate url
739 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
740 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
742 // Async loading, no atlasing for big size image
743 ImageView imageView = ImageView::New(url.GetUrl());
745 // By default, Aysnc loading is used
746 application.GetScene().Add(imageView);
747 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
748 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
750 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
752 application.SendNotification();
753 application.Render(16);
754 application.SendNotification();
756 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
757 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
762 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
764 ToolkitTestApplication application;
766 // Get encoded raw-buffer image and generate url
767 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
768 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
769 ImageUrl url2 = Toolkit::Image::GenerateUrl(buffer);
771 // Generate url is not equal to url2
772 // NOTE : This behavior may changed when ImageUrl compare operator changed.
773 DALI_TEST_CHECK(url != url2);
774 // Generate url's string is equal to url2's string
775 DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
777 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
778 url2 = Toolkit::Image::GenerateUrl(buffer2);
780 // Check whethere two url are not equal
781 DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
783 // Async loading, automatic atlasing for small size image
784 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
786 callStack.Enable(true);
788 Property::Map imageMap;
790 imageMap[ImageVisual::Property::URL] = url.GetUrl();
791 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 600;
792 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 600;
793 imageMap[ImageVisual::Property::ATLASING] = true;
795 // No atlasing with big image
796 ImageView imageView_bigdesired = ImageView::New();
797 imageView_bigdesired.SetProperty(ImageView::Property::IMAGE, imageMap);
798 imageView_bigdesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
800 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 0;
801 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 0;
803 // No atlasing with zero desired size
804 ImageView imageView_nodesired = ImageView::New();
805 imageView_nodesired.SetProperty(ImageView::Property::IMAGE, imageMap);
806 imageView_nodesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
808 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
809 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
811 ImageView imageView = ImageView::New();
812 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
813 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
815 // By default, Aysnc loading is used
816 // loading is not started if the actor is offScene
817 application.GetScene().Add(imageView);
818 application.GetScene().Add(imageView_bigdesired);
819 application.GetScene().Add(imageView_nodesired);
820 application.SendNotification();
821 application.Render(16);
823 // loading started, this waits for the loader thread for max 30 seconds
824 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
826 application.Render(16);
827 application.SendNotification();
829 // Change url to url2
830 imageMap[ImageVisual::Property::URL] = url2.GetUrl();
831 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
833 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
834 application.SendNotification();
835 application.Render(16);
836 application.Render(16);
837 application.SendNotification();
839 // loading started, this waits for the loader thread for max 30 seconds
840 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
842 application.SendNotification();
843 application.Render(16);
845 callStack.Enable(false);
847 TraceCallStack::NamedParams params;
848 params["width"] << 34;
849 params["height"] << 34;
850 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
855 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
857 ToolkitTestApplication application;
859 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
861 // Get encoded raw-buffer image and generate url
862 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
863 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
865 // Sync loading, automatic atlasing for small size image
867 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
869 callStack.Enable(true);
871 ImageView imageView = ImageView::New();
873 // Sync loading is used
874 Property::Map syncLoadingMap;
875 syncLoadingMap["url"] = url.GetUrl();
876 syncLoadingMap["alphaMaskUrl"] = gImage_34_RGBA;
877 syncLoadingMap["desiredHeight"] = 34;
878 syncLoadingMap["desiredWidth"] = 34;
879 syncLoadingMap["synchronousLoading"] = true;
880 syncLoadingMap["atlasing"] = true;
881 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
883 application.GetScene().Add(imageView);
884 application.SendNotification();
885 application.Render(16);
887 TraceCallStack::NamedParams params;
888 params["width"] << 34;
889 params["height"] << 34;
890 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
898 int UtcDaliImageViewAddedTexture(void)
900 ToolkitTestApplication application;
902 tet_infoline("ImageView Testing image view with texture provided manager url");
904 ImageView imageView = ImageView::New();
906 // empty texture is ok, though pointless from app point of view
908 std::string url = TextureManager::AddTexture(empty);
909 DALI_TEST_CHECK(url.size() > 0u);
911 Property::Map propertyMap;
912 propertyMap[ImageVisual::Property::URL] = url;
913 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
915 application.GetScene().Add(imageView);
916 application.SendNotification();
917 application.Render();
922 int UtcDaliImageViewSizeWithBackground(void)
924 ToolkitTestApplication application;
928 ImageView imageView = ImageView::New();
930 imageView.SetProperty(Control::Property::BACKGROUND,
932 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
933 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
934 {ImageVisual::Property::DESIRED_WIDTH, width},
935 {ImageVisual::Property::DESIRED_HEIGHT, height},
938 application.GetScene().Add(imageView);
939 application.SendNotification();
940 application.Render();
942 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
943 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
948 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
950 ToolkitTestApplication application;
952 int widthBackground = 100;
953 int heightBackground = 200;
957 ImageView imageView = ImageView::New();
959 imageView.SetProperty(Control::Property::BACKGROUND,
961 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
962 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
963 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
964 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground},
967 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio, 600x600 pixels
969 application.GetScene().Add(imageView);
970 application.SendNotification();
971 application.Render();
973 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
974 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
979 int UtcDaliImageViewHeightForWidthBackground(void)
981 ToolkitTestApplication application;
983 int widthBackground = 100;
984 int heightBackground = 200;
986 ImageView imageView = ImageView::New();
988 imageView.SetProperty(Control::Property::BACKGROUND,
989 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
990 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
991 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
992 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}});
994 application.GetScene().Add(imageView);
995 application.SendNotification();
996 application.Render();
998 Control control = Control::DownCast(imageView);
999 DALI_TEST_CHECK(control);
1000 DALI_TEST_EQUALS(imageView.GetHeightForWidth(123.f), control.GetHeightForWidth(123.f), TEST_LOCATION);
1001 DALI_TEST_EQUALS(imageView.GetWidthForHeight(321.f), control.GetWidthForHeight(321.f), TEST_LOCATION);
1006 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
1008 ToolkitTestApplication application;
1010 int widthBackground = 100;
1011 int heightBackground = 200;
1015 ImageView imageView = ImageView::New();
1017 imageView.SetProperty(Control::Property::BACKGROUND,
1018 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1019 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1020 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1021 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}}); // 1 to 2 ratio
1023 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio
1025 application.GetScene().Add(imageView);
1026 application.SendNotification();
1027 application.Render();
1029 DALI_TEST_EQUALS(imageView.GetHeightForWidth(width), (float)height, TEST_LOCATION);
1030 DALI_TEST_EQUALS(imageView.GetWidthForHeight(height), (float)width, TEST_LOCATION);
1035 int UtcDaliImageViewSetImageUrl(void)
1037 ToolkitTestApplication application;
1039 ImageView imageView = ImageView::New();
1040 imageView.SetImage(TEST_IMAGE_FILE_NAME);
1041 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
1043 imageView.SetImage(TEST_IMAGE_FILE_NAME2);
1044 TestUrl(imageView, TEST_IMAGE_FILE_NAME2);
1049 bool gResourceReadySignalFired = false;
1050 Vector3 gNaturalSize;
1052 void ResourceReadySignal(Control control)
1054 gResourceReadySignalFired = true;
1057 int UtcDaliImageViewCheckResourceReady(void)
1059 ToolkitTestApplication application;
1061 gResourceReadySignalFired = false;
1063 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1064 ImageView imageView = ImageView::New(TEST_GIF_FILE_NAME);
1066 imageView.SetProperty(Control::Property::BACKGROUND,
1067 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1068 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1069 {ImageVisual::Property::DESIRED_WIDTH, 100},
1070 {ImageVisual::Property::DESIRED_HEIGHT, 200}});
1072 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1074 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1076 application.GetScene().Add(imageView);
1078 // loading started, this waits for the loader thread
1079 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1081 application.SendNotification();
1082 application.Render(16);
1084 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1086 application.SendNotification();
1087 application.Render();
1089 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1091 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1096 int UtcDaliImageViewSetImageTypeChangesP(void)
1098 ToolkitTestApplication application;
1100 ImageView imageView = ImageView::New();
1101 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1103 application.GetScene().Add(imageView);
1107 Toolkit::Visual::Base visual;
1109 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1110 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1112 application.SendNotification();
1113 application.Render(16);
1115 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1117 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1118 DALI_TEST_CHECK(!visual); // Visual should be invalid
1121 imageView.SetImage("TEST_URL");
1123 application.SendNotification();
1124 application.Render(16);
1126 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1127 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1129 DALI_TEST_CHECK(value.Get(url)); // Value should NOT be empty
1130 DALI_TEST_CHECK(!value.Get(map)); // Value should be empty
1131 DALI_TEST_CHECK(visual); // Visual should be valid
1134 imageView.SetImage("");
1136 application.SendNotification();
1137 application.Render(16);
1139 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1140 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1142 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1144 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1145 DALI_TEST_CHECK(!visual); // Visual should be invalid
1147 // Set a URL in property map
1148 Property::Map propertyMap;
1149 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1150 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1152 application.SendNotification();
1153 application.Render(16);
1155 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1156 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1158 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1159 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1160 DALI_TEST_CHECK(visual); // Visual should be valid
1162 // Set a URL in property map again
1163 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1164 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1166 application.SendNotification();
1167 application.Render(16);
1169 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1170 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1172 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1173 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1174 DALI_TEST_CHECK(visual); // Visual should be valid
1176 // Set an empty URL in property map
1177 propertyMap[ImageVisual::Property::URL] = std::string();
1178 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1180 application.SendNotification();
1181 application.Render(16);
1183 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1184 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1186 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1187 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1188 DALI_TEST_CHECK(!visual); // Visual should be invalid
1190 // Set a URL in property map again
1191 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1192 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1194 application.SendNotification();
1195 application.Render(16);
1197 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1198 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1200 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1201 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1202 DALI_TEST_CHECK(visual); // Visual should be valid
1204 // Set an empty property map
1205 propertyMap.Clear();
1206 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1208 application.SendNotification();
1209 application.Render(16);
1211 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1212 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1214 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1215 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1216 DALI_TEST_CHECK(map.Empty()); // But PropertyMap should be empty
1217 DALI_TEST_CHECK(!visual); // Visual should be invalid
1222 int UtcDaliImageViewResourceUrlP(void)
1224 ToolkitTestApplication application;
1226 ImageView imageView = ImageView::New();
1227 DALI_TEST_CHECK(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>().empty());
1229 imageView.SetProperty(ImageView::Property::IMAGE, "TestString");
1230 DALI_TEST_EQUALS(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>(), "TestString", TEST_LOCATION);
1235 int UtcDaliImageViewReplaceImage(void)
1237 ToolkitTestApplication application;
1239 gResourceReadySignalFired = false;
1241 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1242 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1244 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1246 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1248 application.GetScene().Add(imageView);
1250 application.SendNotification();
1251 application.Render(16);
1253 // loading started, this waits for the loader thread for max 30 seconds
1254 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1256 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1258 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1260 gResourceReadySignalFired = false;
1262 imageView.SetImage(TEST_IMAGE_2);
1264 application.SendNotification();
1265 application.Render(16);
1267 // loading started, this waits for the loader thread for max 30 seconds
1268 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1270 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1272 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1274 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1279 int UtcDaliImageViewReloadAlphaMaskImage(void)
1281 ToolkitTestApplication application;
1283 gResourceReadySignalFired = false;
1285 ImageView dummy = ImageView::New();
1286 ImageView imageView = ImageView::New();
1287 Property::Map propertyMap;
1289 // To keep alpha mask cached, scene on some dummy image.
1290 // Note : If we don't cache alpha mask image, the reference count of mask image become zero.
1291 // In this case, we might need to wait mask image loading, which is not neccesary & can be changed behavior.
1292 propertyMap[ImageVisual::Property::URL] = gImage_600_RGB;
1293 propertyMap[ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
1294 dummy.SetProperty(ImageView::Property::IMAGE, propertyMap);
1296 application.GetScene().Add(dummy);
1298 application.SendNotification();
1299 application.Render(16);
1301 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1303 application.SendNotification();
1304 application.Render(16);
1306 propertyMap.Clear();
1307 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1308 propertyMap[ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
1309 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1311 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1313 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1315 application.GetScene().Add(imageView);
1317 application.SendNotification();
1318 application.Render(16);
1320 // Load image and use cached mask. Now we try to apply masking.
1321 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1323 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
1325 // Cancel apply masking.
1326 imageView.Unparent();
1328 application.SendNotification();
1329 application.Render(16);
1331 // Reload same image again.
1332 application.GetScene().Add(imageView);
1334 application.SendNotification();
1335 application.Render(16);
1337 // Finish apply masking.
1338 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1340 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1341 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1342 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1347 void OnRelayoutOverride(Size size)
1349 gNaturalSize = size; // Size Relayout is using
1352 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1354 ToolkitTestApplication application;
1356 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1357 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1358 imageView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1360 DummyControl dummyControl = DummyControl::New(true);
1361 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1362 dummyControl.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
1364 dummyControl.Add(imageView);
1365 dummyImpl.SetRelayoutCallback(&OnRelayoutOverride);
1366 application.GetScene().Add(dummyControl);
1368 application.SendNotification();
1369 application.Render();
1371 // loading started, this waits for the loader thread for max 30 seconds
1372 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1374 DALI_TEST_EQUALS(gNaturalSize.width, 1024.0f, TEST_LOCATION);
1375 DALI_TEST_EQUALS(gNaturalSize.height, 1024.0f, TEST_LOCATION);
1377 gNaturalSize = Vector3::ZERO;
1379 imageView.SetImage(gImage_600_RGB);
1381 // Waiting for resourceReady so SendNotifcation not called here.
1383 // loading started, this waits for the loader thread for max 30 seconds
1384 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1386 // Trigger a potential relayout
1387 application.SendNotification();
1388 application.Render();
1390 DALI_TEST_EQUALS(gNaturalSize.width, 600.0f, TEST_LOCATION);
1391 DALI_TEST_EQUALS(gNaturalSize.height, 600.0f, TEST_LOCATION);
1396 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1398 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1400 ToolkitTestApplication application;
1402 gResourceReadySignalFired = false;
1404 Property::Map imageMap;
1406 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1407 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1409 tet_infoline("Creating ImageView without URL so image does not start loading");
1410 ImageView imageView = ImageView::New();
1411 tet_infoline("Connect to image loaded signal before setting image");
1412 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1413 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1414 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1416 // loading started, this waits for the loader thread
1417 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1419 application.SendNotification();
1420 application.Render(16);
1422 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1427 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1429 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1431 ToolkitTestApplication application;
1433 gResourceReadySignalFired = false;
1435 Property::Map imageMap;
1437 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1438 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1440 ImageView imageView = ImageView::New();
1441 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1442 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1444 // loading started, this waits for the loader thread
1445 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1447 application.SendNotification();
1448 application.Render(16);
1450 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1451 gResourceReadySignalFired = false;
1453 ImageView imageViewWithExistingImage = ImageView::New();
1454 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1455 imageViewWithExistingImage.SetProperty(ImageView::Property::IMAGE, imageMap);
1457 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1462 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1464 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1466 ToolkitTestApplication application;
1468 gResourceReadySignalFired = false;
1470 Property::Map imageImmediateLoadingMap;
1471 imageImmediateLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1472 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1474 tet_infoline("Immediate load an image");
1475 ImageView imageView = ImageView::New();
1476 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1477 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
1479 // loading started, this waits for the loader thread
1480 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1482 application.SendNotification();
1483 application.Render(16);
1485 tet_infoline("Check image loaded");
1486 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1487 gResourceReadySignalFired = false;
1489 tet_infoline("Create another ImageView with the same URL");
1490 ImageView imageViewWithExistingImage = ImageView::New(gImage_34_RGBA);
1491 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1492 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1494 application.GetScene().Add(imageViewWithExistingImage);
1496 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1501 int UtcDaliImageViewPaddingProperty(void)
1503 ToolkitTestApplication application;
1505 ImageView imageView = ImageView::New();
1506 Property::Map imagePropertyMap;
1507 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1508 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
1509 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1510 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1511 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1512 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1513 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1514 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1515 application.GetScene().Add(imageView);
1517 application.SendNotification();
1518 application.Render();
1520 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1522 ImageView childImage = ImageView::New();
1523 childImage.SetBackgroundColor(Color::BLACK);
1524 childImage.SetProperty(Actor::Property::SIZE, Vector2(10.f, 10.f));
1525 imageView.Add(childImage);
1527 application.SendNotification();
1528 application.Render();
1530 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1531 DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
1533 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1534 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1535 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1536 Property::Map resultMap;
1537 imageVisual.CreatePropertyMap(resultMap);
1539 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1540 DALI_TEST_CHECK(transformValue);
1541 Property::Map* retMap = transformValue->GetMap();
1542 DALI_TEST_CHECK(retMap);
1544 // Image Visual should be positioned depending on ImageView's padding
1545 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1550 int UtcDaliImageViewPaddingProperty02(void)
1552 ToolkitTestApplication application;
1554 ImageView imageView = ImageView::New();
1555 Property::Map imagePropertyMap;
1556 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1557 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1558 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1559 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1560 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1561 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1562 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1563 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1564 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1565 application.GetScene().Add(imageView);
1567 application.SendNotification();
1568 application.Render();
1570 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1572 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1573 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1574 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1575 Property::Map resultMap;
1576 imageVisual.CreatePropertyMap(resultMap);
1578 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1579 DALI_TEST_CHECK(transformValue);
1580 Property::Map* retMap = transformValue->GetMap();
1581 DALI_TEST_CHECK(retMap);
1583 // Image Visual should be positioned depending on ImageView's padding
1584 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1589 int UtcDaliImageViewPaddingProperty03(void)
1591 tet_infoline("Test Setting Image Padding then removing it.");
1593 ToolkitTestApplication application;
1595 ImageView imageView = ImageView::New();
1596 Property::Map imagePropertyMap;
1597 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1598 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1599 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1600 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1601 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1602 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1603 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1604 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1605 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1606 application.GetScene().Add(imageView);
1608 application.SendNotification();
1609 application.Render();
1611 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1613 tet_infoline("Remove Padding and test Visual is position correctly");
1615 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1617 application.SendNotification();
1618 application.Render();
1620 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1621 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1622 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1623 Property::Map resultMap;
1624 imageVisual.CreatePropertyMap(resultMap);
1626 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1627 DALI_TEST_CHECK(transformValue);
1628 Property::Map* retMap = transformValue->GetMap();
1629 DALI_TEST_CHECK(retMap);
1631 // Image Visual should be positioned depending on ImageView's padding
1632 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1637 int UtcDaliImageViewPaddingProperty04(void)
1639 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1641 ToolkitTestApplication application;
1643 ImageView imageView = ImageView::New();
1644 Property::Map imagePropertyMap;
1645 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1646 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1647 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1648 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1649 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FILL;
1650 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1651 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1652 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1653 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1654 application.GetScene().Add(imageView);
1656 application.SendNotification();
1657 application.Render();
1659 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1661 tet_infoline("Remove Padding and test Visual is position correctly");
1663 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1665 application.SendNotification();
1666 application.Render();
1668 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1669 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1670 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1671 Property::Map resultMap;
1672 imageVisual.CreatePropertyMap(resultMap);
1674 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1675 DALI_TEST_CHECK(transformValue);
1676 Property::Map* retMap = transformValue->GetMap();
1677 DALI_TEST_CHECK(retMap);
1679 // Image Visual should be positioned depending on ImageView's padding
1680 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1685 int UtcDaliImageViewTransformTest01(void)
1687 tet_infoline("Test Setting a offset transform on the ImageView");
1689 ToolkitTestApplication application;
1691 ImageView imageView = ImageView::New();
1692 Property::Map imagePropertyMap;
1693 imagePropertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE)
1694 .Add(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/Kid1.svg")
1695 .Add(ImageVisual::Property::DESIRED_WIDTH, 120)
1696 .Add(ImageVisual::Property::DESIRED_HEIGHT, 120)
1697 .Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL)
1698 .Add(Visual::Property::TRANSFORM,
1699 Property::Map().Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1700 Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE))
1701 .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(8, 8)));
1703 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1704 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1705 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1706 application.GetScene().Add(imageView);
1708 application.SendNotification();
1709 application.Render();
1711 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1712 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1713 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1714 Property::Map resultMap;
1715 imageVisual.CreatePropertyMap(resultMap);
1717 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1718 DALI_TEST_CHECK(transformValue);
1719 Property::Map* retMap = transformValue->GetMap();
1720 DALI_TEST_CHECK(retMap);
1722 // Image Visual should be positioned depending on ImageView's padding
1723 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(8, 8), TEST_LOCATION);
1724 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);
1729 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1731 ToolkitTestApplication application;
1733 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1734 ImageView imageView = ImageView::New();
1735 Property::Map imageMap;
1736 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1737 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_34_RGBA;
1738 imageMap[Toolkit::ImageVisual::Property::ATLASING] = true;
1739 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1740 application.GetScene().Add(imageView);
1742 // Trigger a potential relayout
1743 application.SendNotification();
1744 application.Render();
1746 Vector3 naturalSize = imageView.GetNaturalSize();
1748 DALI_TEST_EQUALS(naturalSize.width, 34.0f, TEST_LOCATION);
1749 DALI_TEST_EQUALS(naturalSize.height, 34.0f, TEST_LOCATION);
1754 int UtcDaliImageViewFillMode(void)
1756 ToolkitTestApplication application;
1758 tet_infoline("Create an ImageVisual without padding and set the fill-mode to fill");
1760 ImageView imageView = ImageView::New();
1761 Property::Map imageMap;
1762 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1763 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB);
1764 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL);
1766 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1768 application.GetScene().Add(imageView);
1770 // Trigger a potential relayout
1771 application.SendNotification();
1772 application.Render();
1774 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1775 Property::Map returnedMap;
1776 visual.CreatePropertyMap(returnedMap);
1778 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1779 DALI_TEST_CHECK(value);
1780 Property::Map* map = value->GetMap();
1781 DALI_TEST_CHECK(map);
1783 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1784 DALI_TEST_CHECK(value);
1785 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION);
1787 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1788 DALI_TEST_CHECK(value);
1789 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1794 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1796 ToolkitTestApplication application;
1798 tet_infoline("Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )");
1799 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1801 ImageView imageView = ImageView::New();
1802 Property::Map imageMap;
1803 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1804 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1805 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
1807 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1808 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1810 application.GetScene().Add(imageView);
1812 // Trigger a potential relayout
1813 application.SendNotification();
1814 application.Render();
1816 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1817 Property::Map returnedMap;
1818 visual.CreatePropertyMap(returnedMap);
1820 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1821 DALI_TEST_CHECK(value);
1822 Property::Map* map = value->GetMap();
1823 DALI_TEST_CHECK(map);
1826 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1827 DALI_TEST_CHECK(value);
1828 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION);
1830 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1831 DALI_TEST_CHECK(value);
1832 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1834 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1835 DALI_TEST_CHECK(value);
1836 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
1841 int UtcDaliImageViewFittingModesFill(void)
1843 ToolkitTestApplication application;
1845 tet_infoline("Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )");
1846 tet_infoline(" There should be no need to change the transform, only size is changed to fit view");
1848 ImageView imageView = ImageView::New();
1849 Property::Map imageMap;
1850 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1851 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1852 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL);
1854 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1855 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1857 application.GetScene().Add(imageView);
1859 // Trigger a potential relayout
1860 application.SendNotification();
1861 application.Render();
1863 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1864 Property::Map returnedMap;
1865 visual.CreatePropertyMap(returnedMap);
1867 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1868 DALI_TEST_CHECK(value);
1869 Property::Map* map = value->GetMap();
1870 DALI_TEST_CHECK(map);
1872 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1873 DALI_TEST_CHECK(value);
1874 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Change the internal size according to the image view size
1876 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1877 DALI_TEST_CHECK(value);
1878 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1880 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1881 DALI_TEST_CHECK(value);
1882 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1887 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1889 ToolkitTestApplication application;
1891 tet_infoline("Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )");
1892 tet_infoline(" offset or size is the same as view, but adjust internally using pixelArea ");
1894 ImageView imageView = ImageView::New();
1895 Property::Map imageMap;
1896 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1897 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1898 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO);
1900 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1901 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 500));
1903 application.GetScene().Add(imageView);
1905 // Trigger a potential relayout
1906 application.SendNotification();
1907 application.Render();
1909 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1910 Property::Map returnedMap;
1911 visual.CreatePropertyMap(returnedMap);
1913 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1914 DALI_TEST_CHECK(value);
1915 Property::Map* map = value->GetMap();
1916 DALI_TEST_CHECK(map);
1919 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1920 DALI_TEST_CHECK(value);
1921 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 500), TEST_LOCATION); // Change the internal size according to the image view size
1923 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1924 DALI_TEST_CHECK(value);
1925 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1927 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1928 DALI_TEST_CHECK(value);
1929 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1934 int UtcDaliImageViewFittingModesCenter01(void)
1936 ToolkitTestApplication application;
1938 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [700,700] )");
1939 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1941 ImageView imageView = ImageView::New();
1942 Property::Map imageMap;
1943 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1944 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1945 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1947 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1948 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1950 application.GetScene().Add(imageView);
1952 // Trigger a potential relayout
1953 application.SendNotification();
1954 application.Render();
1956 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1957 Property::Map returnedMap;
1958 visual.CreatePropertyMap(returnedMap);
1960 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1961 DALI_TEST_CHECK(value);
1962 Property::Map* map = value->GetMap();
1963 DALI_TEST_CHECK(map);
1965 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1966 DALI_TEST_CHECK(value);
1967 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1969 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1970 DALI_TEST_CHECK(value);
1971 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1973 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1974 DALI_TEST_CHECK(value);
1975 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1980 int UtcDaliImageViewFittingModesCenter02(void)
1982 ToolkitTestApplication application;
1984 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [500,500] )");
1985 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1987 ImageView imageView = ImageView::New();
1988 Property::Map imageMap;
1989 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1990 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1991 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1993 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1994 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1996 application.GetScene().Add(imageView);
1998 // Trigger a potential relayout
1999 application.SendNotification();
2000 application.Render();
2002 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2003 Property::Map returnedMap;
2004 visual.CreatePropertyMap(returnedMap);
2006 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2007 DALI_TEST_CHECK(value);
2008 Property::Map* map = value->GetMap();
2009 DALI_TEST_CHECK(map);
2011 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2012 DALI_TEST_CHECK(value);
2013 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2015 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2016 DALI_TEST_CHECK(value);
2017 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2019 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2020 DALI_TEST_CHECK(value);
2021 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
2026 int UtcDaliImageViewFittingModesFitHeight01(void)
2028 ToolkitTestApplication application;
2030 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )");
2032 ImageView imageView = ImageView::New();
2033 Property::Map imageMap;
2034 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2035 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2036 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2038 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2039 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2041 application.GetScene().Add(imageView);
2043 // Trigger a potential relayout
2044 application.SendNotification();
2045 application.Render();
2047 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2048 Property::Map returnedMap;
2049 visual.CreatePropertyMap(returnedMap);
2051 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2052 DALI_TEST_CHECK(value);
2053 Property::Map* map = value->GetMap();
2054 DALI_TEST_CHECK(map);
2056 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2057 DALI_TEST_CHECK(value);
2058 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 700), TEST_LOCATION); // Change the internal size according to the image view size
2060 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2061 DALI_TEST_CHECK(value);
2062 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2064 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2065 DALI_TEST_CHECK(value);
2066 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2071 int UtcDaliImageViewFittingModesFitHeight02(void)
2073 ToolkitTestApplication application;
2075 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )");
2077 ImageView imageView = ImageView::New();
2078 Property::Map imageMap;
2079 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2080 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2081 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2083 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2084 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2086 application.GetScene().Add(imageView);
2088 // Trigger a potential relayout
2089 application.SendNotification();
2090 application.Render();
2092 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2093 Property::Map returnedMap;
2094 visual.CreatePropertyMap(returnedMap);
2096 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2097 DALI_TEST_CHECK(value);
2098 Property::Map* map = value->GetMap();
2099 DALI_TEST_CHECK(map);
2101 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2102 DALI_TEST_CHECK(value);
2103 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2105 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2106 DALI_TEST_CHECK(value);
2107 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2109 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2110 DALI_TEST_CHECK(value);
2111 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2116 int UtcDaliImageViewFittingModesFitWidth01(void)
2118 ToolkitTestApplication application;
2120 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )");
2122 ImageView imageView = ImageView::New();
2123 Property::Map imageMap;
2124 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2125 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2126 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2128 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2129 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2131 application.GetScene().Add(imageView);
2133 // Trigger a potential relayout
2134 application.SendNotification();
2135 application.Render();
2137 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2138 Property::Map returnedMap;
2139 visual.CreatePropertyMap(returnedMap);
2141 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2142 DALI_TEST_CHECK(value);
2143 Property::Map* map = value->GetMap();
2144 DALI_TEST_CHECK(map);
2146 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2147 DALI_TEST_CHECK(value);
2148 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2150 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2151 DALI_TEST_CHECK(value);
2152 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2154 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2155 DALI_TEST_CHECK(value);
2156 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
2161 int UtcDaliImageViewFittingModesFitWidth02(void)
2163 ToolkitTestApplication application;
2165 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )");
2167 ImageView imageView = ImageView::New();
2168 Property::Map imageMap;
2169 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2170 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2171 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2173 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2174 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2176 application.GetScene().Add(imageView);
2178 // Trigger a potential relayout
2179 application.SendNotification();
2180 application.Render();
2182 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2183 Property::Map returnedMap;
2184 visual.CreatePropertyMap(returnedMap);
2186 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2187 DALI_TEST_CHECK(value);
2188 Property::Map* map = value->GetMap();
2189 DALI_TEST_CHECK(map);
2191 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2192 DALI_TEST_CHECK(value);
2193 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 600), TEST_LOCATION); // Change the internal size according to the image view size
2195 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2196 DALI_TEST_CHECK(value);
2197 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2199 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2200 DALI_TEST_CHECK(value);
2201 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2206 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2208 ToolkitTestApplication application;
2210 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2212 ImageView imageView = ImageView::New();
2214 // 1. Render using FittingMode::SHRINK_TO_FIT
2215 Property::Map imageMap;
2216 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2217 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2218 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2220 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2221 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2223 application.GetScene().Add(imageView);
2225 // Trigger a potential relayout
2226 application.SendNotification();
2227 application.Render();
2229 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2230 Property::Map returnedMap;
2231 visual.CreatePropertyMap(returnedMap);
2233 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2234 DALI_TEST_CHECK(value);
2235 Property::Map* map = value->GetMap();
2236 DALI_TEST_CHECK(map);
2238 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2239 DALI_TEST_CHECK(value);
2240 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2242 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2243 DALI_TEST_CHECK(value);
2244 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2246 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2247 DALI_TEST_CHECK(value);
2248 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2250 // 2. Render again using DevelVisaul::CENTER
2251 Property::Map imageMap2;
2252 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2253 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2254 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2256 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2257 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2259 application.GetScene().Add(imageView);
2261 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2263 // Trigger a potential relayout
2264 application.SendNotification();
2265 application.Render();
2267 returnedMap.Clear();
2268 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2270 visual.CreatePropertyMap(returnedMap);
2272 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2273 DALI_TEST_CHECK(value);
2274 map = value->GetMap();
2275 DALI_TEST_CHECK(map);
2277 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2278 DALI_TEST_CHECK(value);
2279 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2281 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2282 DALI_TEST_CHECK(value);
2283 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2285 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2286 DALI_TEST_CHECK(value);
2287 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2289 // 3. Render again using before fittingMode
2290 Property::Map imageMap3;
2291 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2292 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2293 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2295 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2296 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2298 application.GetScene().Add(imageView);
2300 // Trigger a potential relayout
2301 application.SendNotification();
2302 application.Render();
2304 returnedMap.Clear();
2305 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2306 visual.CreatePropertyMap(returnedMap);
2308 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2309 DALI_TEST_CHECK(value);
2310 map = value->GetMap();
2311 DALI_TEST_CHECK(map);
2313 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2314 DALI_TEST_CHECK(value);
2315 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2317 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2318 DALI_TEST_CHECK(value);
2319 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2321 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2322 DALI_TEST_CHECK(value);
2323 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2328 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2330 ToolkitTestApplication application;
2332 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2334 ImageView imageView = ImageView::New();
2336 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2337 Property::Map imageMap;
2338 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2339 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2340 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2342 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2343 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2345 application.GetScene().Add(imageView);
2347 // Trigger a potential relayout
2348 application.SendNotification();
2349 application.Render();
2351 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2352 Property::Map returnedMap;
2353 visual.CreatePropertyMap(returnedMap);
2355 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2356 DALI_TEST_CHECK(value);
2357 Property::Map* map = value->GetMap();
2358 DALI_TEST_CHECK(map);
2360 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2361 DALI_TEST_CHECK(value);
2362 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2364 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2365 DALI_TEST_CHECK(value);
2366 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2368 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2369 DALI_TEST_CHECK(value);
2370 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2372 // 2. Render again using DevelVisaul::CENTER
2373 Property::Map imageMap2;
2374 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2375 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2376 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2378 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2379 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2381 application.GetScene().Add(imageView);
2383 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2385 // Trigger a potential relayout
2386 application.SendNotification();
2387 application.Render();
2389 returnedMap.Clear();
2390 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2392 visual.CreatePropertyMap(returnedMap);
2394 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2395 DALI_TEST_CHECK(value);
2396 map = value->GetMap();
2397 DALI_TEST_CHECK(map);
2399 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2400 DALI_TEST_CHECK(value);
2401 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2403 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2404 DALI_TEST_CHECK(value);
2405 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2407 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2408 DALI_TEST_CHECK(value);
2409 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2411 // 3. Render again using before fittingMode
2412 Property::Map imageMap3;
2413 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2414 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2415 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2417 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2418 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2420 application.GetScene().Add(imageView);
2422 // Trigger a potential relayout
2423 application.SendNotification();
2424 application.Render();
2426 returnedMap.Clear();
2427 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2428 visual.CreatePropertyMap(returnedMap);
2430 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2431 DALI_TEST_CHECK(value);
2432 map = value->GetMap();
2433 DALI_TEST_CHECK(map);
2435 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2436 DALI_TEST_CHECK(value);
2437 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2439 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2440 DALI_TEST_CHECK(value);
2441 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2443 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2444 DALI_TEST_CHECK(value);
2445 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2450 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2452 ToolkitTestApplication application;
2454 tet_infoline("Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )");
2456 ImageView imageView = ImageView::New();
2457 Property::Map imageMap;
2458 imageMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE);
2459 imageMap.Add(Toolkit::ImageVisual::Property::URL, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME); // 249x169 image
2461 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2462 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
2464 application.GetScene().Add(imageView);
2466 // Trigger a potential relayout
2467 application.SendNotification();
2468 application.Render();
2470 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2471 Property::Map returnedMap;
2472 visual.CreatePropertyMap(returnedMap);
2474 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2475 DALI_TEST_CHECK(value);
2476 Property::Map* map = value->GetMap();
2477 DALI_TEST_CHECK(map);
2479 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2480 DALI_TEST_CHECK(value);
2481 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Relative size so will take up 100%
2483 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2484 DALI_TEST_CHECK(value);
2485 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2487 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2488 DALI_TEST_CHECK(value);
2489 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2494 int UtcDaliImageViewCustomShader(void)
2496 ToolkitTestApplication application;
2498 // Set a custom shader with an image url
2500 Property::Map properties;
2501 Property::Map shader;
2502 const std::string vertexShader = "Foobar";
2503 const std::string fragmentShader = "Foobar";
2504 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2505 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2507 properties[Visual::Property::TYPE] = Visual::IMAGE;
2508 properties[Visual::Property::SHADER] = shader;
2509 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2511 ImageView imageView = ImageView::New();
2512 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2514 application.GetScene().Add(imageView);
2516 application.SendNotification();
2517 application.Render();
2519 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2521 Renderer renderer = imageView.GetRendererAt(0);
2522 Shader shader2 = renderer.GetShader();
2523 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2524 Property::Map* map = value.GetMap();
2525 DALI_TEST_CHECK(map);
2527 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2528 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2530 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2531 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2534 // Set a custom shader after setting an image url
2536 Property::Map properties;
2537 Property::Map shader;
2538 const std::string vertexShader = "Foobar";
2539 const std::string fragmentShader = "Foobar";
2540 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2541 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2543 properties[Visual::Property::SHADER] = shader;
2545 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
2546 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2548 application.GetScene().Add(imageView);
2550 application.SendNotification();
2551 application.Render();
2553 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2555 Renderer renderer = imageView.GetRendererAt(0);
2556 Shader shader2 = renderer.GetShader();
2557 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2558 Property::Map* map = value.GetMap();
2559 DALI_TEST_CHECK(map);
2561 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2562 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2564 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2565 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2568 // Set a custom shader before setting an image url
2570 Property::Map properties;
2571 Property::Map shader;
2572 const std::string vertexShader = "Foobar";
2573 const std::string fragmentShader = "Foobar";
2574 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2575 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2577 properties[Visual::Property::SHADER] = shader;
2579 ImageView imageView = ImageView::New();
2580 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2581 imageView.SetProperty(ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME);
2583 application.GetScene().Add(imageView);
2585 application.SendNotification();
2586 application.Render();
2587 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2589 Renderer renderer = imageView.GetRendererAt(0);
2590 Shader shader2 = renderer.GetShader();
2591 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2592 Property::Map* map = value.GetMap();
2593 DALI_TEST_CHECK(map);
2595 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2596 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2598 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2599 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2602 // Set a custom shader after setting a property map
2604 Property::Map properties;
2605 Property::Map shader;
2606 const std::string vertexShader = "Foobar";
2607 const std::string fragmentShader = "Foobar";
2608 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2609 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2611 properties[Visual::Property::SHADER] = shader;
2613 Property::Map properties1;
2614 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2615 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2617 ImageView imageView = ImageView::New();
2618 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2619 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2621 application.GetScene().Add(imageView);
2623 application.SendNotification();
2624 application.Render();
2625 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2627 Renderer renderer = imageView.GetRendererAt(0);
2628 Shader shader2 = renderer.GetShader();
2629 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2630 Property::Map* map = value.GetMap();
2631 DALI_TEST_CHECK(map);
2633 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2634 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2636 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2637 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2640 // Set a custom shader before setting a property map
2642 Property::Map properties;
2643 Property::Map shader;
2644 const std::string vertexShader = "Foobar";
2645 const std::string fragmentShader = "Foobar";
2646 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2647 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2649 properties[Visual::Property::SHADER] = shader;
2651 Property::Map properties1;
2652 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2653 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2655 ImageView imageView = ImageView::New();
2656 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2657 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2659 application.GetScene().Add(imageView);
2661 application.SendNotification();
2662 application.Render();
2663 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2665 Renderer renderer = imageView.GetRendererAt(0);
2666 Shader shader2 = renderer.GetShader();
2667 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2668 Property::Map* map = value.GetMap();
2669 DALI_TEST_CHECK(map);
2671 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2672 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2674 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2675 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2683 static int gFailCounter = 0;
2684 const int MAX_RETRIES(3);
2686 void ReloadImage(ImageView imageView)
2688 Property::Map imageImmediateLoadingMap;
2689 imageImmediateLoadingMap[ImageVisual::Property::URL] = "Non-existant-image.jpg";
2690 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
2692 tet_infoline("Immediate load an image");
2693 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
2696 void ResourceFailedReload(Control control)
2702 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2704 tet_infoline("Test reloading failed image from within signal handler.");
2706 ToolkitTestApplication application;
2710 ImageView imageView = ImageView::New();
2711 imageView.ResourceReadySignal().Connect(&ResourceFailedReload);
2712 DALI_TEST_EQUALS(gFailCounter, 0, TEST_LOCATION);
2713 ReloadImage(imageView);
2715 // loading started, this waits for the loader thread to complete
2716 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2717 DALI_TEST_EQUALS(gFailCounter, 1, TEST_LOCATION);
2719 ReloadImage(imageView);
2720 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2721 DALI_TEST_EQUALS(gFailCounter, 2, TEST_LOCATION);
2723 ReloadImage(imageView);
2724 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2725 DALI_TEST_EQUALS(gFailCounter, 3, TEST_LOCATION);
2730 int UtcDaliImageViewLoadRemoteSVG(void)
2732 tet_infoline("Test load from a remote server.");
2734 ToolkitTestApplication application;
2737 Toolkit::ImageView imageView;
2738 imageView = Toolkit::ImageView::New();
2739 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2740 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2741 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2742 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2743 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2745 application.GetScene().Add(imageView);
2747 DALI_TEST_CHECK(imageView);
2749 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2751 application.SendNotification();
2753 // Wait for loading & rasterization
2754 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2756 application.SendNotification();
2757 application.Render();
2759 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2764 Toolkit::ImageView imageView;
2765 imageView = Toolkit::ImageView::New();
2766 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2767 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2768 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2769 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2771 application.GetScene().Add(imageView);
2773 DALI_TEST_CHECK(imageView);
2775 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2777 application.SendNotification();
2779 // Wait for loading & rasterization
2780 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2782 application.SendNotification();
2783 application.Render();
2785 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2791 int UtcDaliImageViewSyncSVGLoading(void)
2793 ToolkitTestApplication application;
2795 tet_infoline("ImageView Testing SVG image sync loading");
2798 ImageView imageView = ImageView::New();
2800 // Sync loading is used
2801 Property::Map syncLoadingMap;
2802 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2803 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2804 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2805 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2807 application.GetScene().Add(imageView);
2808 DALI_TEST_CHECK(imageView);
2810 application.SendNotification();
2811 Vector3 naturalSize = imageView.GetNaturalSize();
2813 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2814 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2819 int UtcDaliImageViewAsyncSVGLoading(void)
2821 ToolkitTestApplication application;
2823 tet_infoline("ImageView Testing SVG image async loading");
2826 ImageView imageView = ImageView::New();
2828 // Async loading is used - default value of SYNCHRONOUS_LOADING is false.
2829 Property::Map propertyMap;
2830 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2831 propertyMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2832 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
2834 application.GetScene().Add(imageView);
2835 DALI_TEST_CHECK(imageView);
2837 application.SendNotification();
2840 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2842 application.SendNotification();
2843 application.Render(16);
2845 Vector3 naturalSize = imageView.GetNaturalSize();
2846 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2847 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2852 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2854 ToolkitTestApplication application;
2856 tet_infoline("ImageView Testing SVG image async loading");
2860 ImageView imageView = ImageView::New();
2862 // Sync loading is used
2863 Property::Map syncLoadingMap;
2864 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2865 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2867 // Check to set invalid value
2868 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2869 // Check if error log is outputted when setting other value like string.
2870 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2871 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5));
2872 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2874 application.GetScene().Add(imageView);
2875 DALI_TEST_CHECK(imageView);
2877 application.SendNotification();
2880 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2882 application.SendNotification();
2883 application.Render(16);
2885 Vector3 naturalSize = imageView.GetNaturalSize();
2886 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2887 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2889 Property::Value value = imageView.GetProperty(ImageView::Property::IMAGE);
2890 Property::Map* map = value.GetMap();
2891 DALI_TEST_CHECK(map);
2893 Property::Value* sync = map->Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING);
2894 DALI_TEST_CHECK(sync);
2895 DALI_TEST_EQUALS(false, sync->Get<bool>(), TEST_LOCATION);
2900 int UtcDaliImageViewSvgLoadingFailureLocalFile(void)
2902 // Local svg file - invalid file path
2904 ToolkitTestApplication application;
2906 TestGlAbstraction& gl = application.GetGlAbstraction();
2907 TraceCallStack& textureTrace = gl.GetTextureTrace();
2908 textureTrace.Enable(true);
2910 gResourceReadySignalFired = false;
2912 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2913 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2914 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2916 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2918 application.GetScene().Add(imageView);
2920 application.SendNotification();
2922 // loading started, this waits for the loader thread - load
2923 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2925 application.SendNotification();
2926 application.Render(16);
2928 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2929 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2930 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2932 // Should be shown a broken image
2933 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2934 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2937 // Local svg file - invalid file path without size set
2939 ToolkitTestApplication application;
2941 TestGlAbstraction& gl = application.GetGlAbstraction();
2942 TraceCallStack& textureTrace = gl.GetTextureTrace();
2943 textureTrace.Enable(true);
2945 gResourceReadySignalFired = false;
2946 textureTrace.Reset();
2948 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2949 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2951 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2953 application.GetScene().Add(imageView);
2955 application.SendNotification();
2957 // loading started, this waits for the loader thread - load & rasterize
2958 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2960 application.SendNotification();
2961 application.Render(16);
2963 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2964 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2965 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2967 // Should be shown a broken image
2968 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2969 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2972 // Local svg file - invalid file
2974 ToolkitTestApplication application;
2976 TestGlAbstraction& gl = application.GetGlAbstraction();
2977 TraceCallStack& textureTrace = gl.GetTextureTrace();
2978 textureTrace.Enable(true);
2980 gResourceReadySignalFired = false;
2981 textureTrace.Reset();
2983 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.svg");
2984 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2985 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2987 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2989 application.GetScene().Add(imageView);
2991 application.SendNotification();
2993 // loading started, this waits for the loader thread - load & rasterize
2994 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2996 application.SendNotification();
2997 application.Render(16);
2999 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3000 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3001 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3003 // Should be shown a broken image
3004 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3005 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3011 int UtcDaliImageViewSvgLoadingFailureRemoteFile01(void)
3015 ToolkitTestApplication application;
3017 TestGlAbstraction& gl = application.GetGlAbstraction();
3018 TraceCallStack& textureTrace = gl.GetTextureTrace();
3019 textureTrace.Enable(true);
3021 gResourceReadySignalFired = false;
3023 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
3024 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3025 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3027 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3029 application.GetScene().Add(imageView);
3031 application.SendNotification();
3033 // loading started, this waits for the loader thread - load & rasterize
3034 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3036 application.SendNotification();
3037 application.Render(16);
3039 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3040 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3041 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3043 // Should be shown a broken image
3044 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3045 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3051 int UtcDaliImageViewSvgLoadingFailureRemoteFile02(void)
3053 // Remote svg file without size set
3055 ToolkitTestApplication application;
3057 TestGlAbstraction& gl = application.GetGlAbstraction();
3058 TraceCallStack& textureTrace = gl.GetTextureTrace();
3059 textureTrace.Enable(true);
3061 gResourceReadySignalFired = false;
3063 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
3064 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3066 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3068 application.GetScene().Add(imageView);
3070 application.SendNotification();
3072 // loading started, this waits for the loader thread - load & rasterize
3073 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3075 application.SendNotification();
3076 application.Render(16);
3078 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3079 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3080 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3082 // Should be shown a broken image
3083 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3084 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3090 int UtcDaliImageViewSvgRasterizationFailure(void)
3092 ToolkitTestApplication application;
3094 gResourceReadySignalFired = false;
3096 TestGlAbstraction& gl = application.GetGlAbstraction();
3097 TraceCallStack& textureTrace = gl.GetTextureTrace();
3098 textureTrace.Enable(true);
3100 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid1.svg");
3101 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3102 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3104 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3106 application.GetScene().Add(imageView);
3108 application.SendNotification();
3110 // Wait for loading & rasterization
3111 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3113 application.SendNotification();
3114 application.Render(16);
3116 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3117 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3118 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3120 // Should be shown a broken image
3121 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3122 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3127 int UtcDaliImageViewSvgChageSize(void)
3129 ToolkitTestApplication application;
3131 TestGlAbstraction& gl = application.GetGlAbstraction();
3132 TraceCallStack& textureTrace = gl.GetTextureTrace();
3133 textureTrace.Enable(true);
3135 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME);
3136 application.GetScene().Add(imageView);
3138 application.SendNotification();
3140 // Wait for loading & rasterization
3141 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3143 application.SendNotification();
3144 application.Render(16);
3146 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3148 // Change actor size, then rasterization should be done again
3149 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3151 application.SendNotification();
3153 // Wait for rasterization
3154 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3156 application.SendNotification();
3157 application.Render(16);
3159 // We should not load the file again.
3160 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3165 int UtcDaliImageViewSvgAtlasing(void)
3167 ToolkitTestApplication application;
3169 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
3171 callStack.Enable(true);
3173 Property::Map propertyMap;
3174 propertyMap["url"] = TEST_SVG_FILE_NAME;
3175 propertyMap["atlasing"] = true;
3177 ImageView imageView = ImageView::New();
3178 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
3179 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3180 application.GetScene().Add(imageView);
3182 application.SendNotification();
3184 // Wait for loading & rasterization
3185 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3187 application.SendNotification();
3188 application.Render(16);
3191 TraceCallStack::NamedParams params1;
3192 params1["width"] << 100;
3193 params1["height"] << 100;
3194 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params1), true, TEST_LOCATION);
3196 imageView.SetProperty(Actor::Property::SIZE, Vector2(600.f, 600.f));
3198 application.SendNotification();
3200 // Wait for rasterization
3201 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3205 application.SendNotification();
3206 application.Render(16);
3209 TraceCallStack::NamedParams params2;
3210 params2["width"] << 600;
3211 params2["height"] << 600;
3212 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexImage2D", params2), true, TEST_LOCATION);
3217 int UtcDaliImageViewTVGLoading(void)
3219 ToolkitTestApplication application;
3221 tet_infoline("ImageView Testing TVG image loading");
3224 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/test.tvg");
3225 application.GetScene().Add(imageView);
3226 DALI_TEST_CHECK(imageView);
3228 application.SendNotification();
3230 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3232 application.SendNotification();
3233 application.Render(16);
3235 Vector3 naturalSize = imageView.GetNaturalSize();
3237 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3238 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3243 int UtcDaliImageViewSvgDesiredSize01(void)
3245 ToolkitTestApplication application;
3247 TestGlAbstraction& gl = application.GetGlAbstraction();
3248 TraceCallStack& textureTrace = gl.GetTextureTrace();
3249 textureTrace.Enable(true);
3251 int desiredWidth = 100, desiredHeight = 150;
3252 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
3254 application.GetScene().Add(imageView);
3256 application.SendNotification();
3258 // Wait for loading & rasterization
3259 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3261 application.SendNotification();
3262 application.Render(16);
3265 std::stringstream out;
3266 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
3267 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
3273 int UtcDaliImageViewSvgDesiredSize02(void)
3275 ToolkitTestApplication application;
3277 TestGlAbstraction& gl = application.GetGlAbstraction();
3278 TraceCallStack& textureTrace = gl.GetTextureTrace();
3279 textureTrace.Enable(true);
3281 int desiredWidth = 150, desiredHeight = 100;
3282 ImageView imageView = ImageView::New();
3283 imageView[ImageView::Property::IMAGE] = Property::Map().Add("url", TEST_SVG_FILE_NAME).Add("desiredWidth", desiredWidth).Add("desiredHeight", desiredHeight);
3284 application.GetScene().Add(imageView);
3286 application.SendNotification();
3288 // Wait for loading & rasterization
3289 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3291 application.SendNotification();
3292 application.Render(16);
3295 std::stringstream out;
3296 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
3297 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
3303 int UtcDaliImageViewImageLoadFailure01(void)
3305 ToolkitTestApplication application;
3307 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3308 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3309 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3310 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3312 std::string brokenUrl;
3313 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3314 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3316 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3317 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3319 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3320 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3322 ImageView imageView = ImageView::New("invalidUrl.png");
3323 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3325 application.GetScene().Add(imageView);
3326 application.SendNotification();
3327 application.Render(16);
3329 // loading started, this waits for the loader thread
3330 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3335 int UtcDaliImageViewImageLoadFailure02(void)
3337 ToolkitTestApplication application;
3339 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3340 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
3341 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3342 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3344 std::string brokenUrl;
3345 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3346 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
3348 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3349 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3351 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3352 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3354 ImageView imageView = ImageView::New("invalidUrl.png");
3355 imageView.SetProperty(Actor::Property::SIZE, Vector2(30.f, 30.f));
3356 application.GetScene().Add(imageView);
3357 application.SendNotification();
3358 application.Render(16);
3360 // loading started, this waits for the loader thread
3361 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3366 int UtcDaliImageViewImageLoadFailure03(void)
3368 ToolkitTestApplication application;
3370 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3371 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
3372 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
3374 std::string brokenUrl;
3375 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3376 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3378 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3379 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3381 ImageView imageView = ImageView::New("invalidUrl.png");
3382 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3383 application.GetScene().Add(imageView);
3384 application.SendNotification();
3385 application.Render(16);
3387 // loading started, this waits for the loader thread
3388 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3393 int UtcDaliImageViewImageLoadFailure04(void)
3395 ToolkitTestApplication application;
3397 ImageView imageView = ImageView::New("invalidUrl.png");
3398 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3399 application.GetScene().Add(imageView);
3400 application.SendNotification();
3401 application.Render(16);
3403 // loading started, this waits for the loader thread
3404 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3406 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3407 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3408 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3409 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3411 ImageView imageView2 = ImageView::New("invalidUrl.png");
3412 imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3413 application.GetScene().Add(imageView2);
3415 std::string brokenUrl;
3416 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3417 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3419 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3420 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3422 application.SendNotification();
3423 application.Render(16);
3425 // loading started, this waits for the loader thread
3426 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3428 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3430 ImageView imageView3 = ImageView::New("invalidUrl.png");
3431 imageView3.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3432 application.GetScene().Add(imageView3);
3434 application.SendNotification();
3435 application.Render(16);
3437 // loading started, this waits for the loader thread
3438 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3445 static int gResourceReadySignalCounter = 0;
3447 void OnResourceReadySignal01(Control control)
3449 gResourceReadySignalCounter++;
3451 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3453 if(gResourceReadySignalCounter == 1)
3456 // It makes the first new visual be deleted immediately
3457 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3458 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3461 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3463 // Make the resource ready immediately
3464 control[ImageView::Property::IMAGE] = gImage_600_RGB;
3468 void OnResourceReadySignal02(Control control)
3470 if(++gResourceReadySignalCounter == 1)
3472 // It makes the first new visual be deleted immediately
3473 // The first image will not be loaded.
3474 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB).Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3475 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3479 ImageView gImageView1;
3480 ImageView gImageView2;
3481 ImageView gImageView3;
3482 ImageView gImageView4;
3484 void OnResourceReadySignal03(Control control)
3486 if(gResourceReadySignalCounter == 0)
3489 // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3490 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3492 // 2. Load a new image
3493 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3495 // 3. Use the new image again
3496 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3497 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3499 else if(gResourceReadySignalCounter == 1)
3501 // This is called from TextureManager::ProcessQueuedTextures().
3502 gImageView1.Unparent();
3503 gImageView1.Reset();
3505 gResourceReadySignalCounter++;
3508 void OnSimpleResourceReadySignal(Control control)
3510 // simply increate counter
3511 gResourceReadySignalCounter++;
3514 int gResourceReadySignal04ComesOrder = 0;
3516 void OnResourceReadySignal04(Control control)
3518 gResourceReadySignalCounter++;
3519 tet_printf("rc %d\n", gResourceReadySignalCounter);
3520 if(gResourceReadySignalCounter == 1)
3522 auto scene = gImageView1.GetParent();
3524 // Request load something
3525 // We hope this request result is return later than gImageView2.
3526 gImageView3 = ImageView::New(TEST_IMAGE_1);
3527 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3528 scene.Add(gImageView3);
3529 gImageView4 = ImageView::New(TEST_IMAGE_2);
3530 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3531 scene.Add(gImageView4);
3533 if(control == gImageView1)
3535 gResourceReadySignal04ComesOrder = 1;
3539 gResourceReadySignal04ComesOrder = 2;
3542 if(gResourceReadySignalCounter == 2)
3544 if(gResourceReadySignal04ComesOrder == 1 && control == gImageView2)
3546 // Scene off first one.
3547 gImageView1.Unparent();
3549 // Scene off second one.
3550 gImageView2.Unparent();
3552 else if(gResourceReadySignal04ComesOrder == 2 && control == gImageView1)
3554 // Scene off first one.
3555 gImageView2.Unparent();
3557 // Scene off second one.
3558 gImageView1.Unparent();
3562 // We can't check that this utc fail case. just pass always when we come here.
3563 gResourceReadySignal04ComesOrder = -1;
3566 // If we don't seperate index of FreeList area
3567 // and if we don't queue remove during obversing,
3568 // cache index become something invalid data.
3569 // In this case, some strange observer can be called.
3570 // For example, gImageView4.LoadComplete will be called.
3574 void OnResourceReadySignal05(Control control)
3576 gResourceReadySignalCounter++;
3578 // Request load with same image
3579 // NOTE : The url must not be same as gImageView1
3580 const int viewCount = 4;
3581 for(int i = 0; i < viewCount; ++i)
3583 gImageView1.Add(ImageView::New("invalid2.jpg"));
3587 int gResourceReadySignal06ComesOrder = 0;
3589 void OnResourceReadySignal06(Control control)
3591 gResourceReadySignalCounter++;
3592 if(gResourceReadySignalCounter == 1)
3594 auto scene = gImageView1.GetParent();
3596 // Request load something
3597 // We hope this request result is return later than gImageView2.
3600 map1[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
3601 map1[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
3603 gImageView3 = ImageView::New();
3604 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3605 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3608 map2[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
3609 map2[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_S;
3610 gImageView4 = ImageView::New();
3611 gImageView4.SetProperty(Toolkit::ImageView::Property::IMAGE, map2);
3612 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3614 if(control == gImageView1)
3616 gResourceReadySignal06ComesOrder = 1;
3620 gResourceReadySignal06ComesOrder = 2;
3623 if(gResourceReadySignalCounter == 2)
3625 if(gResourceReadySignal06ComesOrder == 1 && control == gImageView2)
3627 // Scene off first one.
3628 gImageView1.Unparent();
3630 // Scene off second one.
3631 gImageView2.Unparent();
3633 else if(gResourceReadySignal06ComesOrder == 2 && control == gImageView1)
3635 // Scene off first one.
3636 gImageView2.Unparent();
3638 // Scene off second one.
3639 gImageView1.Unparent();
3643 // We can't check that this utc fail case. just pass always when we come here.
3644 gResourceReadySignal06ComesOrder = -1;
3647 // If we don't seperate index of FreeList area
3648 // and if we don't queue remove during obversing,
3649 // cache index become something invalid data.
3650 // In this case, some strange observer can be called.
3651 // For example, gImageView4.LoadComplete will be called.
3655 void OnResourceReadySignal07(Control control)
3657 gResourceReadySignalCounter++;
3658 // Load masked image
3659 tet_printf("rc %d %d\n", gResourceReadySignalCounter, static_cast<bool>(gImageView2));
3663 auto scene = gImageView1.GetParent();
3666 map1[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
3667 map1[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
3669 gImageView2 = ImageView::New();
3670 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3671 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal07);
3673 scene.Add(gImageView2);
3677 void OnResourceReadySignal08(Control control)
3679 gResourceReadySignalCounter++;
3683 gImageView1.Unparent();
3684 gImageView1.Reset();
3688 gImageView2.Unparent();
3689 gImageView2.Reset();
3693 std::size_t gResourceReadySignal09Emitted = false;
3695 void OnResourceReadySignal09(Control control)
3697 gResourceReadySignalCounter++;
3699 if(gImageView1 && !gResourceReadySignal09Emitted)
3701 gResourceReadySignal09Emitted = true;
3702 gImageView1.ResourceReadySignal().Disconnect(&OnResourceReadySignal09);
3704 // Try to load cached invalid nine patch image. It will request load now.
3705 gImageView1.SetImage(TEST_INVALID_NPATCH_FILE_NAME_01);
3706 gImageView2.SetImage(TEST_INVALID_NPATCH_FILE_NAME_01);
3708 // Destroy all visuals immediatly.
3709 gImageView1.Unparent();
3710 gImageView1.Reset();
3711 gImageView2.Unparent();
3712 gImageView2.Reset();
3718 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3720 tet_infoline("Test setting image from within signal handler.");
3722 ToolkitTestApplication application;
3724 gResourceReadySignalCounter = 0;
3726 ImageView imageView = ImageView::New(gImage_34_RGBA);
3727 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal01);
3729 application.GetScene().Add(imageView);
3731 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3733 application.SendNotification();
3734 application.Render();
3736 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3738 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3740 // Create a new ImageView to cache the image
3741 ImageView imageView1 = ImageView::New(gImage_600_RGB);
3742 application.GetScene().Add(imageView1);
3744 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3746 application.SendNotification();
3747 application.Render();
3750 gResourceReadySignalCounter = 0;
3752 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3754 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3756 application.SendNotification();
3757 application.Render();
3759 // Run idle callback
3760 application.RunIdles();
3762 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3764 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3769 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
3771 tet_infoline("Test setting image from within signal handler.");
3773 ToolkitTestApplication application;
3775 gResourceReadySignalCounter = 0;
3777 ImageView imageView = ImageView::New(gImage_34_RGBA);
3778 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal02);
3780 application.GetScene().Add(imageView);
3782 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3784 application.SendNotification();
3785 application.Render();
3787 // Wait for loading an image
3788 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3790 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3792 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3797 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3799 tet_infoline("Test setting image from within signal handler.");
3801 ToolkitTestApplication application;
3803 gResourceReadySignalCounter = 0;
3805 gImageView1 = ImageView::New(gImage_34_RGBA);
3806 application.GetScene().Add(gImageView1);
3809 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3811 gImageView2 = ImageView::New(gImage_600_RGB);
3812 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3813 application.GetScene().Add(gImageView2);
3815 gImageView3 = ImageView::New();
3816 application.GetScene().Add(gImageView3);
3818 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3820 application.SendNotification();
3821 application.Render();
3826 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask01(void)
3828 tet_infoline("Test signal handler when image / mask image is broken.");
3830 ToolkitTestApplication application;
3832 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, const std::string& url, const std::string& mask, const char* location) {
3833 gResourceReadySignalCounter = 0;
3836 map[Toolkit::ImageVisual::Property::URL] = url;
3839 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3841 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3843 ImageView imageView = ImageView::New();
3844 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3845 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3846 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3848 application.GetScene().Add(imageView);
3849 application.SendNotification();
3850 application.Render();
3855 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3857 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3858 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3860 imageView.Unparent();
3863 for(int synchronous = 0; synchronous <= 1; synchronous++)
3865 tet_printf("Test normal case (sync:%d)\n", synchronous);
3866 TestResourceReadyUrl(1, synchronous, gImage_600_RGB, "", TEST_LOCATION);
3867 TestResourceReadyUrl(3, synchronous, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 3 event trigger required : 2 image load + 1 apply mask
3869 tet_printf("Test broken image case (sync:%d)\n", synchronous);
3870 TestResourceReadyUrl(1, synchronous, "invalid.jpg", "", TEST_LOCATION);
3871 TestResourceReadyUrl(2, synchronous, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3873 tet_printf("Test broken mask image case (sync:%d)\n", synchronous);
3874 TestResourceReadyUrl(2, synchronous, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3876 tet_printf("Test broken both image, mask image case (sync:%d)\n", synchronous);
3877 TestResourceReadyUrl(2, synchronous, "invalid.jpg", "invalid.png", TEST_LOCATION);
3883 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask02(void)
3885 tet_infoline("Test signal handler when image try to use cached-and-broken mask image.");
3887 ToolkitTestApplication application;
3889 gResourceReadySignalCounter = 0;
3891 auto TestBrokenMaskResourceReadyUrl = [&application](const std::string& url, const char* location) {
3893 map[Toolkit::ImageVisual::Property::URL] = url;
3894 // Use invalid mask url
3895 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
3897 ImageView imageView = ImageView::New();
3898 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3899 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3900 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3902 application.GetScene().Add(imageView);
3904 // Don't unparent imageView, for keep the cache.
3907 // Use more than 4 images (The number of LocalImageLoadThread)
3908 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};
3910 int expectResourceReadySignalCounter = 0;
3912 for(auto& url : testUrlList)
3914 TestBrokenMaskResourceReadyUrl(url, TEST_LOCATION);
3915 expectResourceReadySignalCounter++;
3918 // Remain 1 signal due to we use #URL + 1 mask image.
3919 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(expectResourceReadySignalCounter + 1), true, TEST_LOCATION);
3920 application.SendNotification();
3921 application.Render();
3922 DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
3927 int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
3929 tet_infoline("Test signal handler various case.");
3931 auto TestResourceReadyUrl = [](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
3932 ToolkitTestApplication application;
3934 gResourceReadySignalCounter = 0;
3937 map[Toolkit::ImageVisual::Property::URL] = url;
3940 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3942 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3944 ImageView imageView = ImageView::New();
3945 imageView[Toolkit::ImageView::Property::IMAGE] = map;
3946 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
3947 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3949 application.GetScene().Add(imageView);
3950 application.SendNotification();
3951 application.Render();
3954 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3956 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3957 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3958 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, location);
3960 imageView.Unparent();
3963 auto TestAuxiliaryResourceReadyUrl = [](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
3964 ToolkitTestApplication application;
3966 gResourceReadySignalCounter = 0;
3969 map[Toolkit::ImageVisual::Property::URL] = url;
3970 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE] = auxiliaryUrl;
3971 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA] = 0.5f;
3972 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3974 ImageView imageView = ImageView::New();
3975 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
3976 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
3977 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3978 application.GetScene().Add(imageView);
3980 application.SendNotification();
3981 application.Render();
3986 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, location);
3989 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3990 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3991 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3993 imageView.Unparent();
3996 // Case 1 : asynchronous loading
3997 tet_printf("Test invalid single simple image Asynchronous\n");
4000 TestResourceReadyUrl(1, 0, 1, gImage_600_RGB, "", TEST_LOCATION);
4001 TestResourceReadyUrl(2, 0, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // load & rasterize
4002 TestResourceReadyUrl(1, 0, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
4004 TestResourceReadyUrl(2, 0, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // 2 image loading - batch size
4005 TestResourceReadyUrl(2, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // load & rasterize
4007 TestResourceReadyUrl(3, 0, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 2 image loading + 1 applymask
4009 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
4012 TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
4013 TestResourceReadyUrl(1, 0, 0, "invalid.svg", "", TEST_LOCATION);
4014 TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
4015 TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION); // 1 image loading
4016 TestResourceReadyUrl(1, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
4018 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", "invalid.png", TEST_LOCATION); // 2 image loading
4019 TestResourceReadyUrl(2, 0, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); // 2 image loading
4020 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION); // 2 image loading
4022 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
4023 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
4024 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
4026 // Case 2 : Synchronous loading
4027 tet_printf("Test invalid single simple image Synchronous\n");
4030 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "", TEST_LOCATION);
4031 TestResourceReadyUrl(0, 1, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
4032 TestResourceReadyUrl(0, 1, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
4034 TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // first frame image loading sync + second frame image loading async
4036 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION);
4038 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
4041 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
4042 TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION);
4043 TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
4044 TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
4046 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "invalid.png", TEST_LOCATION);
4047 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION);
4048 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
4050 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
4051 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
4052 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
4057 int UtcDaliImageViewSetImageOnResourceReadySignal04(void)
4059 tet_infoline("Test texturemanager's remove queue works well within signal handler.");
4061 ToolkitTestApplication application;
4063 gResourceReadySignalCounter = 0;
4064 gResourceReadySignal04ComesOrder = 0;
4066 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
4067 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal04);
4068 application.GetScene().Add(gImageView1);
4070 gImageView2 = ImageView::New("invalid.png"); // request invalid image, to make loading failed fast.
4071 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal04);
4072 application.GetScene().Add(gImageView2);
4074 application.SendNotification();
4075 application.Render();
4077 tet_infoline("Try to load 2 invalid image");
4079 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4080 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4082 tet_infoline("load done");
4084 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
4085 if(gResourceReadySignal04ComesOrder == -1)
4087 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
4091 // gImageView3 and gImageView4 load must not be successed yet.
4092 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
4093 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
4095 application.SendNotification();
4096 application.Render();
4098 tet_infoline("Try to load 2 valid image");
4100 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4101 DALI_TEST_EQUALS(gResourceReadySignalCounter, 4, TEST_LOCATION);
4103 tet_infoline("load done");
4105 // gImageView3 and gImageView4 load must be successed now.
4106 DALI_TEST_EQUALS(gImageView3.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
4107 DALI_TEST_EQUALS(gImageView4.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
4112 int UtcDaliImageViewSetImageOnResourceReadySignal05(void)
4114 tet_infoline("Test multiple views with same image during ResourceReady load the image only 1 times");
4116 ToolkitTestApplication application;
4118 gResourceReadySignalCounter = 0;
4120 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
4121 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal05);
4122 application.GetScene().Add(gImageView1);
4124 application.SendNotification();
4125 application.Render();
4127 tet_infoline("Try to load 1 invalid.jpg image");
4128 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4129 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4131 tet_infoline("Try to load 1 invalid2.jpg image");
4132 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4134 tet_infoline("Now we don't have any image to be loaded. Check event thread trigger failed.");
4135 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
4137 gImageView1.Unparent();
4138 gImageView1.Reset();
4142 int UtcDaliImageViewSetImageOnResourceReadySignal06(void)
4144 tet_infoline("Test texturemanager's remove image & mask queue works well within signal handler.");
4146 ToolkitTestApplication application;
4148 gResourceReadySignalCounter = 0;
4149 gResourceReadySignal06ComesOrder = 0;
4152 map[Toolkit::ImageVisual::Property::URL] = "invalid.jpg";
4153 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
4155 gImageView1 = ImageView::New(); // request invalid image, to make loading failed fast.
4156 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4157 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal06);
4158 application.GetScene().Add(gImageView1);
4160 gImageView2 = ImageView::New(); // request invalid image, to make loading failed fast.
4161 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4162 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal06);
4163 application.GetScene().Add(gImageView2);
4165 application.SendNotification();
4166 application.Render();
4168 tet_infoline("Try to load 2 invalid image");
4170 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4171 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4173 tet_infoline("load done");
4175 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
4176 if(gResourceReadySignal06ComesOrder == -1)
4178 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
4182 // gImageView3 and gImageView4 load must not be successed yet.
4183 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
4184 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
4186 application.GetScene().Add(gImageView3);
4187 application.GetScene().Add(gImageView4);
4188 application.SendNotification();
4189 application.Render();
4191 tet_infoline("Try to load 2 valid image");
4193 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4194 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4196 tet_infoline("load done");
4201 int UtcDaliImageViewSetImageOnResourceReadySignal07(void)
4203 tet_infoline("Test texturemanager's remove image & mask queue works well within signal handler 02.");
4205 ToolkitTestApplication application;
4207 gResourceReadySignalCounter = 0;
4210 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4212 // Clear image view for clear test
4216 gImageView1.Reset();
4220 gImageView2.Reset();
4223 gImageView1 = ImageView::New();
4224 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4225 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal07);
4226 application.GetScene().Add(gImageView1);
4228 application.SendNotification();
4229 application.Render();
4233 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4234 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4236 tet_infoline("load image1 done");
4238 // Load gImageView2 and mask
4240 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4241 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4243 // gImageView2 mask apply done
4245 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4246 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4248 tet_infoline("load image2 done");
4252 int UtcDaliImageViewSetImageOnResourceReadySignal08(void)
4254 tet_infoline("Test remove npatch images during resource ready");
4256 ToolkitTestApplication application;
4258 gResourceReadySignalCounter = 0;
4261 map[Toolkit::ImageVisual::Property::URL] = TEST_BROKEN_IMAGE_M;
4263 // Clear image view for clear test
4267 gImageView1.Reset();
4271 gImageView2.Reset();
4274 // Case 1 : Remove all images during resource ready.
4277 gImageView1 = ImageView::New();
4278 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4279 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal08);
4280 application.GetScene().Add(gImageView1);
4282 application.SendNotification();
4283 application.Render();
4286 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4287 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4289 application.SendNotification();
4290 application.Render();
4292 DALI_TEST_CHECK(true);
4296 // Exception should not happened
4297 DALI_TEST_CHECK(false);
4301 application.SendNotification();
4302 application.Render();
4304 gResourceReadySignalCounter = 0;
4306 // Case 2 : Remove all images when we use cached resource.
4309 gImageView1 = ImageView::New();
4310 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4311 gImageView1.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4312 application.GetScene().Add(gImageView1);
4314 application.SendNotification();
4315 application.Render();
4318 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4319 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4321 application.SendNotification();
4322 application.Render();
4324 gImageView2 = ImageView::New();
4325 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4326 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal08);
4327 application.GetScene().Add(gImageView2);
4328 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4330 application.SendNotification();
4331 application.Render();
4333 DALI_TEST_CHECK(true);
4337 // Exception should not happened
4338 DALI_TEST_CHECK(false);
4340 gResourceReadySignalCounter = 0;
4342 // Clear image view for clear test
4346 gImageView1.Reset();
4350 gImageView2.Reset();
4356 int UtcDaliImageViewSetImageOnResourceReadySignal09(void)
4358 tet_infoline("Test load invalid npatch images during invalid resource ready");
4360 ToolkitTestApplication application;
4362 gResourceReadySignalCounter = 0;
4365 map[Toolkit::ImageVisual::Property::URL] = TEST_INVALID_NPATCH_FILE_NAME_01;
4367 // Clear image view for clear test
4371 gImageView1.Reset();
4375 gImageView2.Reset();
4379 gImageView3.Reset();
4382 // Dummy view with npatch image
4383 ImageView dummyView = ImageView::New(TEST_BROKEN_IMAGE_M);
4384 application.GetScene().Add(dummyView);
4386 application.SendNotification();
4387 application.Render();
4388 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4389 application.SendNotification();
4390 application.Render();
4392 // Case 1 : Reload images during resource ready.
4395 gResourceReadySignal09Emitted = false;
4397 gImageView1 = ImageView::New();
4398 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4399 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal09);
4400 application.GetScene().Add(gImageView1);
4402 gImageView2 = ImageView::New();
4403 application.GetScene().Add(gImageView2);
4405 // Load TEST_INVALID_NPATCH_FILE_NAME_01
4406 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4408 // Load TEST_INVALID_NPATCH_FILE_NAME_01 one more times.
4409 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4411 application.SendNotification();
4412 application.Render();
4414 DALI_TEST_CHECK(true);
4418 // Exception should not happened
4419 DALI_TEST_CHECK(false);
4423 application.SendNotification();
4424 application.Render();
4426 gResourceReadySignalCounter = 0;
4428 // Case 2 : Remove all images when we use cached resource.
4431 gResourceReadySignal09Emitted = false;
4433 gImageView3 = ImageView::New();
4434 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4435 gImageView3.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4436 application.GetScene().Add(gImageView3);
4438 gImageView2 = ImageView::New();
4439 application.GetScene().Add(gImageView2);
4442 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4444 gImageView1 = ImageView::New();
4445 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4446 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal09);
4447 application.GetScene().Add(gImageView1);
4450 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4452 // Load TEST_INVALID_NPATCH_FILE_NAME_01 one more times.
4453 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4455 application.SendNotification();
4456 application.Render();
4458 DALI_TEST_CHECK(true);
4462 // Exception should not happened
4463 DALI_TEST_CHECK(false);
4465 gResourceReadySignalCounter = 0;
4467 // Clear image view for clear test
4471 gImageView1.Reset();
4475 gImageView2.Reset();
4479 gImageView3.Reset();
4485 int UtcDaliImageViewUseSameUrlWithAnimatedImageVisual(void)
4487 tet_infoline("Test multiple views with same image in animated image visual");
4488 ToolkitTestApplication application;
4490 gImageView1 = ImageView::New(TEST_WEBP_FILE_NAME);
4491 application.GetScene().Add(gImageView1);
4493 tet_infoline("Remove imageView and Create new imageView with same url");
4494 application.GetScene().Remove(gImageView1);
4495 gImageView2 = ImageView::New(TEST_WEBP_FILE_NAME);
4496 application.GetScene().Add(gImageView2);
4498 application.SendNotification();
4499 application.Render();
4501 tet_infoline("Check the ImageView load image successfully");
4502 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4506 int UtcDaliImageViewNpatchImageCacheTest01(void)
4508 tet_infoline("Test npatch image cached");
4510 ToolkitTestApplication application;
4511 ImageView imageView[2];
4513 auto& gl = application.GetGlAbstraction();
4514 gl.EnableTextureCallTrace(true);
4515 auto& textureCallStack = gl.GetTextureTrace();
4516 textureCallStack.Enable(true);
4517 textureCallStack.EnableLogging(true);
4519 auto TestNPatch = [&](int index, const std::string& nPatchImageUrl, const char* location) {
4520 if(imageView[index])
4522 imageView[index].Unparent();
4525 // Ensure remove npatch cache if required.
4526 application.SendNotification();
4527 application.Render();
4529 imageView[index] = ImageView::New(nPatchImageUrl);
4530 imageView[index].SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4531 application.GetScene().Add(imageView[index]);
4534 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4535 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4537 application.SendNotification();
4538 application.Render();
4540 tet_printf("trace : \n%s\n", textureCallStack.GetTraceString().c_str());
4542 // Check we gen only 1 textures
4543 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 1, TEST_LOCATION);
4544 textureCallStack.Reset();
4546 // Let we use cached textures
4547 for(int i = 0; i < 10; i++)
4549 TestNPatch(1, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4550 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4553 application.SendNotification();
4554 application.Render();
4555 // Check we use cached npatch data so we don't generate new texture textures
4556 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 0, TEST_LOCATION);
4559 imageView[0].Unparent();
4560 imageView[0].Reset();
4561 imageView[1].Unparent();
4562 imageView[1].Reset();
4564 application.SendNotification();
4565 application.Render();
4567 textureCallStack.Reset();
4568 // Let we use deference textures
4569 TestNPatch(1, TEST_BROKEN_IMAGE_S, TEST_LOCATION);
4570 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4572 application.SendNotification();
4573 application.Render();
4574 // Try to load multiple times.
4575 for(int i = 0; i < 3; i++)
4577 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4578 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4579 TestNPatch(1, TEST_BROKEN_IMAGE_S, TEST_LOCATION);
4580 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4582 application.SendNotification();
4583 application.Render();
4585 imageView[0].Unparent();
4586 imageView[0].Reset();
4587 imageView[1].Unparent();
4588 imageView[1].Reset();
4590 application.SendNotification();
4591 application.Render();
4593 // Check memory leak
4594 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), textureCallStack.CountMethod("DeleteTextures"), TEST_LOCATION);
4599 int UtcDaliImageViewNpatchImageCacheTest02(void)
4601 tet_infoline("Test npatch image cached with border");
4603 ToolkitTestApplication application;
4604 ImageView imageView[2];
4606 auto& gl = application.GetGlAbstraction();
4607 gl.EnableTextureCallTrace(true);
4608 auto& textureCallStack = gl.GetTextureTrace();
4609 textureCallStack.Enable(true);
4610 textureCallStack.EnableLogging(true);
4612 auto TestBorderImage = [&](int index, const std::string& normalImageUrl, const Rect<int> border, const char* location) {
4614 map[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::N_PATCH;
4615 map[Toolkit::ImageVisual::Property::URL] = normalImageUrl;
4616 map[Toolkit::ImageVisual::Property::BORDER] = border;
4618 imageView[index] = ImageView::New();
4619 imageView[index].SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4620 imageView[index].SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4621 application.GetScene().Add(imageView[index]);
4624 TestBorderImage(0, gImage_34_RGBA, Rect<int>(0, 0, 0, 0), TEST_LOCATION);
4625 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4627 application.SendNotification();
4628 application.Render();
4630 tet_printf("trace : \n%s\n", textureCallStack.GetTraceString().c_str());
4632 // Check we gen only 1 textures
4633 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 1, TEST_LOCATION);
4634 textureCallStack.Reset();
4636 // Let we use cached textures
4637 for(int i = 0; i < 10; i++)
4639 TestBorderImage(0, gImage_34_RGBA, Rect<int>(i, i + 1, i + 2, i + 3), TEST_LOCATION);
4640 TestBorderImage(1, gImage_34_RGBA, Rect<int>(i + 1, i, i + 3, i + 2), TEST_LOCATION);
4643 application.SendNotification();
4644 application.Render();
4646 // Check we use cached npatch data so we don't generate new texture textures
4647 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 0, TEST_LOCATION);
4652 int UtcDaliImageViewPlaceholderImage01(void)
4654 tet_infoline("Test imageView use placeholder image");
4656 ToolkitTestApplication application;
4658 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4660 ImageView imageView = ImageView::New();
4661 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4662 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4663 application.GetScene().Add(imageView);
4665 Property::Value value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4667 DALI_TEST_CHECK(value.Get(url));
4668 DALI_TEST_CHECK(url.empty());
4669 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4671 application.SendNotification();
4672 application.Render();
4674 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4675 DALI_TEST_CHECK(value.Get(url));
4676 DALI_TEST_CHECK(url == gImage_34_RGBA);
4678 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4679 application.SendNotification();
4680 application.Render();
4682 // Replace Image test
4683 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4684 map[ImageView::Property::PLACEHOLDER_IMAGE] = gImage_34_RGBA;
4685 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4686 application.SendNotification();
4687 application.Render();
4689 map[Toolkit::ImageVisual::Property::URL] = "";
4690 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4691 application.SendNotification();
4692 application.Render();
4694 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
4695 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4696 application.SendNotification();
4697 application.Render();
4699 // Replace Image test2
4700 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4701 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4702 application.SendNotification();
4703 application.Render();
4705 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
4706 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4707 application.SendNotification();
4708 application.Render();
4710 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4711 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4712 application.SendNotification();
4713 application.Render(900);
4715 map[Toolkit::ImageVisual::Property::URL] = "";
4716 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4717 application.SendNotification();
4718 application.Render();
4720 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4721 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4722 application.SendNotification();
4723 application.Render();
4728 int UtcDaliImageViewPlaceholderImage02(void)
4730 tet_infoline("Test imageView use placeholder image without resource ready");
4732 ToolkitTestApplication application;
4735 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4737 ImageView imageView = ImageView::New();
4738 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4739 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4740 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
4741 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
4742 application.GetScene().Add(imageView);
4744 Property::Value value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4746 DALI_TEST_CHECK(value.Get(url));
4747 DALI_TEST_CHECK(url.empty());
4749 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4750 application.SendNotification();
4751 application.Render();
4753 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4755 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4756 DALI_TEST_CHECK(value.Get(url));
4757 DALI_TEST_CHECK(url == gImage_34_RGBA);
4759 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
4760 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
4762 gResourceReadySignalFired = false;
4763 map[Toolkit::ImageVisual::Property::URL] = "";
4764 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4765 application.SendNotification();
4766 application.Render();
4768 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
4769 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
4774 int UtcDaliImageViewTransitionEffect01(void)
4776 tet_infoline("Test imageView use transition effect");
4778 ToolkitTestApplication application;
4780 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4781 map[Toolkit::Visual::Property::OPACITY] = 0.9f;
4783 ImageView imageView = ImageView::New();
4784 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4785 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4786 application.GetScene().Add(imageView);
4788 Property::Value value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
4790 DALI_TEST_CHECK(value.Get(transition));
4791 DALI_TEST_CHECK(transition == false);
4792 imageView.SetProperty(Toolkit::ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
4794 application.SendNotification();
4795 application.Render();
4797 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
4798 DALI_TEST_CHECK(value.Get(transition));
4799 DALI_TEST_CHECK(transition == true);
4801 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4802 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4803 application.SendNotification();
4804 application.Render();
4806 // Test transition effect with placeholder
4807 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4808 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4809 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4810 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4811 application.SendNotification();
4812 application.Render();
4814 map[Toolkit::ImageVisual::Property::URL] = "";
4815 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4816 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4817 application.SendNotification();
4818 application.Render();
4820 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4821 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4822 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4823 application.SendNotification();
4824 application.Render();
4826 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4827 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4828 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4829 application.SendNotification();
4831 map[Toolkit::ImageVisual::Property::URL] = "";
4832 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4833 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4834 application.SendNotification();
4835 application.Render();
4837 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4838 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4839 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, "");
4840 application.SendNotification();
4841 application.Render();
4843 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4844 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4845 application.SendNotification();
4846 application.Render();
4848 map[Toolkit::ImageVisual::Property::URL] = "";
4849 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4850 application.SendNotification();
4851 application.Render();
4853 // Test transition effect without placeholder
4854 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4855 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4856 application.SendNotification();
4857 application.Render();
4859 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4860 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4861 application.SendNotification();
4862 application.Render();
4864 map[Toolkit::ImageVisual::Property::URL] = "";
4865 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4866 application.SendNotification();
4867 application.Render();
4869 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
4870 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4871 application.SendNotification();
4872 application.Render();
4874 imageView.SetImage(TEST_IMAGE_1);
4875 application.SendNotification();
4876 application.Render();
4878 imageView.SetImage(gImage_600_RGB);
4879 application.SendNotification();
4880 application.Render(9000);
4882 imageView.SetImage("");
4883 application.SendNotification();
4884 application.Render();
4886 imageView.SetImage(TEST_IMAGE_1);
4887 application.SendNotification();
4888 application.Render();
4891 imageView.Unparent();
4897 int UtcDaliImageViewTransitionEffect02(void)
4899 tet_infoline("Test imageView use transition effect with replace image");
4901 ToolkitTestApplication application;
4905 ImageView imageView = ImageView::New();
4906 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4907 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4908 application.GetScene().Add(imageView);
4910 Property::Value value;
4911 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
4913 DALI_TEST_CHECK(value.Get(transition));
4914 DALI_TEST_CHECK(transition == false);
4915 imageView.SetProperty(Toolkit::ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
4917 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4919 DALI_TEST_CHECK(value.Get(url));
4920 DALI_TEST_CHECK(url.empty());
4921 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4922 application.SendNotification();
4923 application.Render();
4925 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, "");
4926 application.SendNotification();
4927 application.Render();
4929 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4930 application.SendNotification();
4931 application.Render();
4933 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
4934 DALI_TEST_CHECK(value.Get(transition));
4935 DALI_TEST_CHECK(transition == true);
4937 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4938 DALI_TEST_CHECK(value.Get(url));
4939 DALI_TEST_CHECK(url == gImage_34_RGBA);
4941 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4942 application.SendNotification();
4943 application.Render();
4946 imageView.Unparent();
4952 int UtcDaliImageViewTransitionEffect03(void)
4954 tet_infoline("Test imageView use transition effect with placeholder");
4956 ToolkitTestApplication application;
4959 ImageView imageView = ImageView::New();
4960 imageView.SetImage("");
4961 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4962 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4963 imageView.SetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
4964 application.GetScene().Add(imageView);
4966 //DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4968 application.SendNotification();
4969 application.Render(16);
4971 tet_infoline("(1)");
4972 imageView.SetImage(gImage_600_RGB);
4973 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4974 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4975 application.SendNotification();
4976 application.Render(16);
4978 Property::Value value;
4979 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
4981 DALI_TEST_CHECK(value.Get(transition));
4982 DALI_TEST_CHECK(transition == true);
4984 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
4986 DALI_TEST_CHECK(value.Get(url));
4987 DALI_TEST_CHECK(url == gImage_34_RGBA);
4989 imageView.SetImage("");
4990 application.SendNotification();
4991 application.Render(16);
4993 imageView.SetImage(TEST_IMAGE_1);
4994 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
4995 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4996 application.SendNotification();
4997 application.Render(16);
5000 imageView.Unparent();