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);
580 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
582 // loading started, this waits for the loader thread for max 30 seconds
583 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
585 application.SendNotification();
586 application.Render(16);
588 callStack.Enable(false);
590 TraceCallStack::NamedParams params;
591 params["width"] << 34;
592 params["height"] << 34;
593 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
598 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
600 ToolkitTestApplication application;
602 //Async loading, automatic atlasing for small size image
603 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
605 callStack.Enable(true);
607 Property::Map asyncLoadingMap;
608 asyncLoadingMap["url"] = gImage_34_RGBA;
609 asyncLoadingMap["desiredHeight"] = 34;
610 asyncLoadingMap["desiredWidth"] = 34;
611 asyncLoadingMap["synchronousLoading"] = false;
612 asyncLoadingMap["atlasing"] = true;
614 ImageView imageView = ImageView::New();
615 imageView.SetProperty(ImageView::Property::IMAGE, asyncLoadingMap);
617 application.GetScene().Add(imageView);
619 // loading started, this waits for the loader thread for max 30 seconds
620 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
622 application.SendNotification();
623 application.Render(16);
625 callStack.Enable(false);
627 TraceCallStack::NamedParams params;
628 params["width"] << 34;
629 params["height"] << 34;
630 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
635 int UtcDaliImageViewSyncLoading(void)
637 ToolkitTestApplication application;
639 tet_infoline("ImageView Testing sync loading and size using index key property map");
641 Property::Map syncLoadingMap;
642 syncLoadingMap[ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
643 syncLoadingMap[ImageVisual::Property::ATLASING] = true;
645 // Sync loading, no atlasing for big size image
647 ImageView imageView = ImageView::New();
649 // Sync loading is used
650 syncLoadingMap[ImageVisual::Property::URL] = gImage_600_RGB;
651 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
654 // Sync loading, automatic atlasing for small size image
656 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
658 callStack.Enable(true);
660 ImageView imageView = ImageView::New();
662 // Sync loading is used
663 syncLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
664 syncLoadingMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
665 syncLoadingMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
666 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
668 application.GetScene().Add(imageView);
669 application.SendNotification();
670 application.Render(16);
672 TraceCallStack::NamedParams params;
673 params["width"] << 34;
674 params["height"] << 34;
675 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
682 int UtcDaliImageViewSyncLoading02(void)
684 ToolkitTestApplication application;
686 tet_infoline("ImageView Testing sync loading and size using string key property map");
688 // Sync loading, automatic atlasing for small size image
690 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
692 callStack.Enable(true);
694 ImageView imageView = ImageView::New();
696 // Sync loading is used
697 Property::Map syncLoadingMap;
698 syncLoadingMap["url"] = gImage_34_RGBA;
699 syncLoadingMap["desiredHeight"] = 34;
700 syncLoadingMap["desiredWidth"] = 34;
701 syncLoadingMap["synchronousLoading"] = true;
702 syncLoadingMap["atlasing"] = true;
703 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
705 application.GetScene().Add(imageView);
706 application.SendNotification();
707 application.Render(16);
709 TraceCallStack::NamedParams params;
710 params["width"] << 34;
711 params["height"] << 34;
712 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
719 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
721 ToolkitTestApplication application;
722 TestGlAbstraction& gl = application.GetGlAbstraction();
723 const std::vector<GLuint>& textures = gl.GetBoundTextures();
724 size_t numTextures = textures.size();
726 // Get encoded raw-buffer image and generate url
727 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
728 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
730 // Async loading, no atlasing for big size image
731 ImageView imageView = ImageView::New(url.GetUrl());
733 // By default, Aysnc loading is used
734 application.GetScene().Add(imageView);
735 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
736 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
738 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
740 application.SendNotification();
741 application.Render(16);
742 application.SendNotification();
744 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
745 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
750 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
752 ToolkitTestApplication application;
754 // Get encoded raw-buffer image and generate url
755 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
756 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
757 ImageUrl url2 = Toolkit::Image::GenerateUrl(buffer);
759 // Generate url is not equal to url2
760 // NOTE : This behavior may changed when ImageUrl compare operator changed.
761 DALI_TEST_CHECK(url != url2);
762 // Generate url's string is equal to url2's string
763 DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
765 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
766 url2 = Toolkit::Image::GenerateUrl(buffer2);
768 // Check whethere two url are not equal
769 DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
771 // Async loading, automatic atlasing for small size image
772 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
774 callStack.Enable(true);
776 Property::Map imageMap;
778 imageMap[ImageVisual::Property::URL] = url.GetUrl();
779 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 600;
780 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 600;
781 imageMap[ImageVisual::Property::ATLASING] = true;
783 // No atlasing with big image
784 ImageView imageView_bigdesired = ImageView::New();
785 imageView_bigdesired.SetProperty(ImageView::Property::IMAGE, imageMap);
786 imageView_bigdesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
788 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 0;
789 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 0;
791 // No atlasing with zero desired size
792 ImageView imageView_nodesired = ImageView::New();
793 imageView_nodesired.SetProperty(ImageView::Property::IMAGE, imageMap);
794 imageView_nodesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
796 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
797 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
799 ImageView imageView = ImageView::New();
800 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
801 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
803 // By default, Aysnc loading is used
804 // loading is not started if the actor is offScene
805 application.GetScene().Add(imageView);
806 application.GetScene().Add(imageView_bigdesired);
807 application.GetScene().Add(imageView_nodesired);
808 application.SendNotification();
809 application.Render(16);
811 // loading started, this waits for the loader thread for max 30 seconds
812 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
814 application.Render(16);
815 application.SendNotification();
817 // Change url to url2
818 imageMap[ImageVisual::Property::URL] = url2.GetUrl();
819 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
821 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
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.SendNotification();
827 application.Render(16);
829 callStack.Enable(false);
831 TraceCallStack::NamedParams params;
832 params["width"] << 34;
833 params["height"] << 34;
834 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
839 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
841 ToolkitTestApplication application;
843 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
845 // Get encoded raw-buffer image and generate url
846 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
847 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
849 // Sync loading, automatic atlasing for small size image
851 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
853 callStack.Enable(true);
855 ImageView imageView = ImageView::New();
857 // Sync loading is used
858 Property::Map syncLoadingMap;
859 syncLoadingMap["url"] = url.GetUrl();
860 syncLoadingMap["alphaMaskUrl"] = gImage_34_RGBA;
861 syncLoadingMap["desiredHeight"] = 34;
862 syncLoadingMap["desiredWidth"] = 34;
863 syncLoadingMap["synchronousLoading"] = true;
864 syncLoadingMap["atlasing"] = true;
865 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
867 application.GetScene().Add(imageView);
868 application.SendNotification();
869 application.Render(16);
871 TraceCallStack::NamedParams params;
872 params["width"] << 34;
873 params["height"] << 34;
874 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
882 int UtcDaliImageViewEncodedBufferWithSvg(void)
884 ToolkitTestApplication application;
885 TestGlAbstraction& gl = application.GetGlAbstraction();
886 const std::vector<GLuint>& textures = gl.GetBoundTextures();
887 size_t numTextures = textures.size();
889 // Get encoded raw-buffer svg image and generate url
890 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(TEST_SVG_FILE_NAME, EncodedImageBuffer::ImageType::VECTOR_IMAGE);
891 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
893 // Async loading, no atlasing for big size image
894 ImageView imageView = ImageView::New(url.GetUrl());
896 // By default, Aysnc loading is used
897 application.GetScene().Add(imageView);
898 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
899 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
901 application.SendNotification();
902 application.Render(16);
904 // Load svg image + rasterize.
905 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
907 application.SendNotification();
908 application.Render(16);
909 application.SendNotification();
911 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
912 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
914 // Remove visual, for line coverage.
915 imageView.Unparent();
916 application.SendNotification();
917 application.Render(16);
922 int UtcDaliImageViewEncodedBufferWithAnimatedVectorImage(void)
924 ToolkitTestApplication application;
925 TestGlAbstraction& gl = application.GetGlAbstraction();
926 const std::vector<GLuint>& textures = gl.GetBoundTextures();
927 size_t numTextures = textures.size();
929 // Get encoded raw-buffer lottie image and generate url
930 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, EncodedImageBuffer::ImageType::ANIMATED_VECTOR_IMAGE);
931 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
933 // Async loading, no atlasing for big size image
934 ImageView imageView = ImageView::New(url.GetUrl());
936 // By default, Aysnc loading is used
937 application.GetScene().Add(imageView);
938 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
939 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
941 application.SendNotification();
942 application.Render(16);
944 // Load lottie image is sync. Only wait rasterize.
945 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
947 application.SendNotification();
948 application.Render(16);
949 application.SendNotification();
951 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
952 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
954 // Remove visual, for line coverage.
955 imageView.Unparent();
956 application.SendNotification();
957 application.Render(16);
962 int UtcDaliImageViewAddedTexture(void)
964 ToolkitTestApplication application;
966 tet_infoline("ImageView Testing image view with texture provided manager url");
968 ImageView imageView = ImageView::New();
970 // empty texture is ok, though pointless from app point of view
972 std::string url = TextureManager::AddTexture(empty);
973 DALI_TEST_CHECK(url.size() > 0u);
975 Property::Map propertyMap;
976 propertyMap[ImageVisual::Property::URL] = url;
977 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
979 application.GetScene().Add(imageView);
980 application.SendNotification();
981 application.Render();
986 int UtcDaliImageViewSizeWithBackground(void)
988 ToolkitTestApplication application;
992 ImageView imageView = ImageView::New();
994 imageView.SetProperty(Control::Property::BACKGROUND,
996 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
997 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
998 {ImageVisual::Property::DESIRED_WIDTH, width},
999 {ImageVisual::Property::DESIRED_HEIGHT, height},
1002 application.GetScene().Add(imageView);
1003 application.SendNotification();
1004 application.Render();
1006 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
1007 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
1012 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
1014 ToolkitTestApplication application;
1016 int widthBackground = 100;
1017 int heightBackground = 200;
1021 ImageView imageView = ImageView::New();
1023 imageView.SetProperty(Control::Property::BACKGROUND,
1025 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1026 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1027 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1028 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground},
1031 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio, 600x600 pixels
1033 application.GetScene().Add(imageView);
1034 application.SendNotification();
1035 application.Render();
1037 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
1038 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
1043 int UtcDaliImageViewHeightForWidthBackground(void)
1045 ToolkitTestApplication application;
1047 int widthBackground = 100;
1048 int heightBackground = 200;
1050 ImageView imageView = ImageView::New();
1052 imageView.SetProperty(Control::Property::BACKGROUND,
1053 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1054 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1055 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1056 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}});
1058 application.GetScene().Add(imageView);
1059 application.SendNotification();
1060 application.Render();
1062 Control control = Control::DownCast(imageView);
1063 DALI_TEST_CHECK(control);
1064 DALI_TEST_EQUALS(imageView.GetHeightForWidth(123.f), control.GetHeightForWidth(123.f), TEST_LOCATION);
1065 DALI_TEST_EQUALS(imageView.GetWidthForHeight(321.f), control.GetWidthForHeight(321.f), TEST_LOCATION);
1070 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
1072 ToolkitTestApplication application;
1074 int widthBackground = 100;
1075 int heightBackground = 200;
1079 ImageView imageView = ImageView::New();
1081 imageView.SetProperty(Control::Property::BACKGROUND,
1082 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1083 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1084 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1085 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}}); // 1 to 2 ratio
1087 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio
1089 application.GetScene().Add(imageView);
1090 application.SendNotification();
1091 application.Render();
1093 DALI_TEST_EQUALS(imageView.GetHeightForWidth(width), (float)height, TEST_LOCATION);
1094 DALI_TEST_EQUALS(imageView.GetWidthForHeight(height), (float)width, TEST_LOCATION);
1099 int UtcDaliImageViewSetImageUrl(void)
1101 ToolkitTestApplication application;
1103 ImageView imageView = ImageView::New();
1104 imageView.SetImage(TEST_IMAGE_FILE_NAME);
1105 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
1107 imageView.SetImage(TEST_IMAGE_FILE_NAME2);
1108 TestUrl(imageView, TEST_IMAGE_FILE_NAME2);
1113 bool gResourceReadySignalFired = false;
1114 Vector3 gNaturalSize;
1116 void ResourceReadySignal(Control control)
1118 gResourceReadySignalFired = true;
1121 void OnResourceReadySignalSVG(Control control)
1123 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1124 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(control);
1125 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1126 Property::Map resultMap;
1127 imageVisual.CreatePropertyMap(resultMap);
1129 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1130 DALI_TEST_CHECK(transformValue);
1131 Property::Map* retMap = transformValue->GetMap();
1132 DALI_TEST_CHECK(retMap);
1134 // Fitting mode should not be applied at this point
1135 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::SIZE)->Get<Vector2>(), Vector2::ZERO, TEST_LOCATION);
1138 int UtcDaliImageViewCheckResourceReady(void)
1140 ToolkitTestApplication application;
1142 gResourceReadySignalFired = false;
1144 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1145 ImageView imageView = ImageView::New(TEST_GIF_FILE_NAME);
1147 imageView.SetProperty(Control::Property::BACKGROUND,
1148 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1149 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1150 {ImageVisual::Property::DESIRED_WIDTH, 100},
1151 {ImageVisual::Property::DESIRED_HEIGHT, 200}});
1153 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1155 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1157 application.GetScene().Add(imageView);
1159 // loading started, this waits for the loader thread
1160 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1162 application.SendNotification();
1163 application.Render(16);
1165 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1167 application.SendNotification();
1168 application.Render();
1170 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1172 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1177 int UtcDaliImageViewSetImageTypeChangesP(void)
1179 ToolkitTestApplication application;
1181 ImageView imageView = ImageView::New();
1182 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1184 application.GetScene().Add(imageView);
1188 Toolkit::Visual::Base visual;
1190 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1191 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1193 application.SendNotification();
1194 application.Render(16);
1196 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1198 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1199 DALI_TEST_CHECK(!visual); // Visual should be invalid
1202 imageView.SetImage("TEST_URL");
1204 application.SendNotification();
1205 application.Render(16);
1207 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1208 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1210 DALI_TEST_CHECK(value.Get(url)); // Value should NOT be empty
1211 DALI_TEST_CHECK(!value.Get(map)); // Value should be empty
1212 DALI_TEST_CHECK(visual); // Visual should be valid
1215 imageView.SetImage("");
1217 application.SendNotification();
1218 application.Render(16);
1220 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1221 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1223 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1225 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1226 DALI_TEST_CHECK(!visual); // Visual should be invalid
1228 // Set a URL in property map
1229 Property::Map propertyMap;
1230 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1231 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1233 application.SendNotification();
1234 application.Render(16);
1236 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1237 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1239 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1240 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1241 DALI_TEST_CHECK(visual); // Visual should be valid
1243 // Set a URL in property map again
1244 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1245 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1247 application.SendNotification();
1248 application.Render(16);
1250 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1251 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1253 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1254 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1255 DALI_TEST_CHECK(visual); // Visual should be valid
1257 // Set an empty URL in property map
1258 propertyMap[ImageVisual::Property::URL] = std::string();
1259 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1261 application.SendNotification();
1262 application.Render(16);
1264 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1265 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1267 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1268 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1269 DALI_TEST_CHECK(!visual); // Visual should be invalid
1271 // Set a URL in property map again
1272 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1273 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1275 application.SendNotification();
1276 application.Render(16);
1278 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1279 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1281 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1282 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1283 DALI_TEST_CHECK(visual); // Visual should be valid
1285 // Set an empty property map
1286 propertyMap.Clear();
1287 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1289 application.SendNotification();
1290 application.Render(16);
1292 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1293 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1295 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1296 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1297 DALI_TEST_CHECK(map.Empty()); // But PropertyMap should be empty
1298 DALI_TEST_CHECK(!visual); // Visual should be invalid
1303 int UtcDaliImageViewResourceUrlP(void)
1305 ToolkitTestApplication application;
1307 ImageView imageView = ImageView::New();
1308 DALI_TEST_CHECK(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>().empty());
1310 imageView.SetProperty(ImageView::Property::IMAGE, "TestString");
1311 DALI_TEST_EQUALS(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>(), "TestString", TEST_LOCATION);
1316 int UtcDaliImageViewReplaceImage(void)
1318 ToolkitTestApplication application;
1320 gResourceReadySignalFired = false;
1322 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1323 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1325 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1327 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1329 application.GetScene().Add(imageView);
1331 application.SendNotification();
1332 application.Render(16);
1334 // loading started, this waits for the loader thread for max 30 seconds
1335 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1337 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1339 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1341 gResourceReadySignalFired = false;
1343 imageView.SetImage(TEST_IMAGE_2);
1345 application.SendNotification();
1346 application.Render(16);
1348 // loading started, this waits for the loader thread for max 30 seconds
1349 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1351 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1353 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1355 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1360 int UtcDaliImageViewReloadAlphaMaskImage(void)
1362 ToolkitTestApplication application;
1364 gResourceReadySignalFired = false;
1366 ImageView dummy = ImageView::New();
1367 ImageView imageView = ImageView::New();
1368 Property::Map propertyMap;
1370 // To keep alpha mask cached, scene on some dummy image.
1371 // Note : If we don't cache alpha mask image, the reference count of mask image become zero.
1372 // In this case, we might need to wait mask image loading, which is not neccesary & can be changed behavior.
1373 propertyMap[ImageVisual::Property::URL] = gImage_600_RGB;
1374 propertyMap[ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
1375 dummy.SetProperty(ImageView::Property::IMAGE, propertyMap);
1377 application.GetScene().Add(dummy);
1379 application.SendNotification();
1380 application.Render(16);
1382 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1384 application.SendNotification();
1385 application.Render(16);
1387 propertyMap.Clear();
1388 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1389 propertyMap[ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
1390 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1392 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1394 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1396 application.GetScene().Add(imageView);
1398 application.SendNotification();
1399 application.Render(16);
1401 // Load image and use cached mask. Now we try to apply masking.
1402 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1404 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
1406 // Cancel apply masking.
1407 imageView.Unparent();
1409 application.SendNotification();
1410 application.Render(16);
1412 // Reload same image again.
1413 application.GetScene().Add(imageView);
1415 application.SendNotification();
1416 application.Render(16);
1418 // Finish apply masking.
1419 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1421 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1422 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1423 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1428 void OnRelayoutOverride(Size size)
1430 gNaturalSize = size; // Size Relayout is using
1433 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1435 ToolkitTestApplication application;
1437 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1438 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1439 imageView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1441 DummyControl dummyControl = DummyControl::New(true);
1442 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1443 dummyControl.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
1445 dummyControl.Add(imageView);
1446 dummyImpl.SetRelayoutCallback(&OnRelayoutOverride);
1447 application.GetScene().Add(dummyControl);
1449 application.SendNotification();
1450 application.Render();
1452 // loading started, this waits for the loader thread for max 30 seconds
1453 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1455 DALI_TEST_EQUALS(gNaturalSize.width, 1024.0f, TEST_LOCATION);
1456 DALI_TEST_EQUALS(gNaturalSize.height, 1024.0f, TEST_LOCATION);
1458 gNaturalSize = Vector3::ZERO;
1460 imageView.SetImage(gImage_600_RGB);
1462 // Waiting for resourceReady so SendNotifcation not called here.
1464 // loading started, this waits for the loader thread for max 30 seconds
1465 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1467 // Trigger a potential relayout
1468 application.SendNotification();
1469 application.Render();
1471 DALI_TEST_EQUALS(gNaturalSize.width, 600.0f, TEST_LOCATION);
1472 DALI_TEST_EQUALS(gNaturalSize.height, 600.0f, TEST_LOCATION);
1477 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1479 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1481 ToolkitTestApplication application;
1483 gResourceReadySignalFired = false;
1485 Property::Map imageMap;
1487 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1488 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1490 tet_infoline("Creating ImageView without URL so image does not start loading");
1491 ImageView imageView = ImageView::New();
1492 tet_infoline("Connect to image loaded signal before setting image");
1493 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1494 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1495 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1497 // loading started, this waits for the loader thread
1498 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1500 application.SendNotification();
1501 application.Render(16);
1503 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1508 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1510 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1512 ToolkitTestApplication application;
1514 gResourceReadySignalFired = false;
1516 Property::Map imageMap;
1518 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1519 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1521 ImageView imageView = ImageView::New();
1522 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1523 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1525 // loading started, this waits for the loader thread
1526 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1528 application.SendNotification();
1529 application.Render(16);
1531 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1532 gResourceReadySignalFired = false;
1534 ImageView imageViewWithExistingImage = ImageView::New();
1535 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1536 imageViewWithExistingImage.SetProperty(ImageView::Property::IMAGE, imageMap);
1538 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1543 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1545 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1547 ToolkitTestApplication application;
1549 gResourceReadySignalFired = false;
1551 Property::Map imageImmediateLoadingMap;
1552 imageImmediateLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1553 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1555 tet_infoline("Immediate load an image");
1556 ImageView imageView = ImageView::New();
1557 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1558 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
1560 // loading started, this waits for the loader thread
1561 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1563 application.SendNotification();
1564 application.Render(16);
1566 tet_infoline("Check image loaded");
1567 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1568 gResourceReadySignalFired = false;
1570 tet_infoline("Create another ImageView with the same URL");
1571 ImageView imageViewWithExistingImage = ImageView::New(gImage_34_RGBA);
1572 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1573 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1575 application.GetScene().Add(imageViewWithExistingImage);
1577 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1582 int UtcDaliImageViewPaddingProperty(void)
1584 ToolkitTestApplication application;
1586 ImageView imageView = ImageView::New();
1587 Property::Map imagePropertyMap;
1588 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1589 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
1590 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1591 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1592 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1593 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1594 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1595 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1596 application.GetScene().Add(imageView);
1598 application.SendNotification();
1599 application.Render();
1601 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1603 ImageView childImage = ImageView::New();
1604 childImage.SetBackgroundColor(Color::BLACK);
1605 childImage.SetProperty(Actor::Property::SIZE, Vector2(10.f, 10.f));
1606 imageView.Add(childImage);
1608 application.SendNotification();
1609 application.Render();
1611 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1612 DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
1614 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1615 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1616 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1617 Property::Map resultMap;
1618 imageVisual.CreatePropertyMap(resultMap);
1620 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1621 DALI_TEST_CHECK(transformValue);
1622 Property::Map* retMap = transformValue->GetMap();
1623 DALI_TEST_CHECK(retMap);
1625 // Image Visual should be positioned depending on ImageView's padding
1626 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1631 int UtcDaliImageViewPaddingProperty02(void)
1633 ToolkitTestApplication application;
1635 ImageView imageView = ImageView::New();
1636 Property::Map imagePropertyMap;
1637 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1638 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1639 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1640 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1641 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1642 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1643 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1644 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1645 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1646 application.GetScene().Add(imageView);
1648 application.SendNotification();
1649 application.Render();
1651 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1653 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1654 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1655 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1656 Property::Map resultMap;
1657 imageVisual.CreatePropertyMap(resultMap);
1659 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1660 DALI_TEST_CHECK(transformValue);
1661 Property::Map* retMap = transformValue->GetMap();
1662 DALI_TEST_CHECK(retMap);
1664 // Image Visual should be positioned depending on ImageView's padding
1665 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1670 int UtcDaliImageViewPaddingProperty03(void)
1672 tet_infoline("Test Setting Image Padding then removing it.");
1674 ToolkitTestApplication application;
1676 ImageView imageView = ImageView::New();
1677 Property::Map imagePropertyMap;
1678 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1679 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1680 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1681 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1682 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1683 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1684 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1685 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1686 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1687 application.GetScene().Add(imageView);
1689 application.SendNotification();
1690 application.Render();
1692 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1694 tet_infoline("Remove Padding and test Visual is position correctly");
1696 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1698 application.SendNotification();
1699 application.Render();
1701 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1702 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1703 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1704 Property::Map resultMap;
1705 imageVisual.CreatePropertyMap(resultMap);
1707 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1708 DALI_TEST_CHECK(transformValue);
1709 Property::Map* retMap = transformValue->GetMap();
1710 DALI_TEST_CHECK(retMap);
1712 // Image Visual should be positioned depending on ImageView's padding
1713 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1718 int UtcDaliImageViewPaddingProperty04(void)
1720 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1722 ToolkitTestApplication application;
1724 ImageView imageView = ImageView::New();
1725 Property::Map imagePropertyMap;
1726 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1727 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1728 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1729 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1730 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FILL;
1731 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1732 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1733 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1734 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1735 application.GetScene().Add(imageView);
1737 application.SendNotification();
1738 application.Render();
1740 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1742 tet_infoline("Remove Padding and test Visual is position correctly");
1744 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1746 application.SendNotification();
1747 application.Render();
1749 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1750 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1751 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1752 Property::Map resultMap;
1753 imageVisual.CreatePropertyMap(resultMap);
1755 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1756 DALI_TEST_CHECK(transformValue);
1757 Property::Map* retMap = transformValue->GetMap();
1758 DALI_TEST_CHECK(retMap);
1760 // Image Visual should be positioned depending on ImageView's padding
1761 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1766 int UtcDaliImageViewTransformTest01(void)
1768 tet_infoline("Test Setting a offset transform on the ImageView");
1770 ToolkitTestApplication application;
1772 ImageView imageView = ImageView::New();
1773 Property::Map imagePropertyMap;
1774 imagePropertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE)
1775 .Add(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/Kid1.svg")
1776 .Add(ImageVisual::Property::DESIRED_WIDTH, 120)
1777 .Add(ImageVisual::Property::DESIRED_HEIGHT, 120)
1778 .Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL)
1779 .Add(Visual::Property::TRANSFORM,
1780 Property::Map().Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1781 Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE))
1782 .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(8, 8)));
1784 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1785 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1786 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1787 application.GetScene().Add(imageView);
1789 application.SendNotification();
1790 application.Render();
1792 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1793 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1794 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1795 Property::Map resultMap;
1796 imageVisual.CreatePropertyMap(resultMap);
1798 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1799 DALI_TEST_CHECK(transformValue);
1800 Property::Map* retMap = transformValue->GetMap();
1801 DALI_TEST_CHECK(retMap);
1803 // Image Visual should be positioned depending on ImageView's padding
1804 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(8, 8), TEST_LOCATION);
1805 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);
1810 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1812 ToolkitTestApplication application;
1814 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1815 ImageView imageView = ImageView::New();
1816 Property::Map imageMap;
1817 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1818 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_34_RGBA;
1819 imageMap[Toolkit::ImageVisual::Property::ATLASING] = true;
1820 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1821 application.GetScene().Add(imageView);
1823 // Trigger a potential relayout
1824 application.SendNotification();
1825 application.Render();
1827 Vector3 naturalSize = imageView.GetNaturalSize();
1829 DALI_TEST_EQUALS(naturalSize.width, 34.0f, TEST_LOCATION);
1830 DALI_TEST_EQUALS(naturalSize.height, 34.0f, TEST_LOCATION);
1835 int UtcDaliImageViewFillMode(void)
1837 ToolkitTestApplication application;
1839 tet_infoline("Create an ImageVisual without padding and set the fill-mode to fill");
1841 ImageView imageView = ImageView::New();
1842 Property::Map imageMap;
1843 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1844 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB);
1845 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL);
1847 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1849 application.GetScene().Add(imageView);
1851 // Trigger a potential relayout
1852 application.SendNotification();
1853 application.Render();
1855 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1856 Property::Map returnedMap;
1857 visual.CreatePropertyMap(returnedMap);
1859 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1860 DALI_TEST_CHECK(value);
1861 Property::Map* map = value->GetMap();
1862 DALI_TEST_CHECK(map);
1864 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1865 DALI_TEST_CHECK(value);
1866 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION);
1868 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1869 DALI_TEST_CHECK(value);
1870 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1875 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1877 ToolkitTestApplication application;
1879 tet_infoline("Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )");
1880 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1882 ImageView imageView = ImageView::New();
1883 Property::Map imageMap;
1884 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1885 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1886 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
1888 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1889 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1891 application.GetScene().Add(imageView);
1893 // Trigger a potential relayout
1894 application.SendNotification();
1895 application.Render();
1897 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1898 Property::Map returnedMap;
1899 visual.CreatePropertyMap(returnedMap);
1901 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1902 DALI_TEST_CHECK(value);
1903 Property::Map* map = value->GetMap();
1904 DALI_TEST_CHECK(map);
1907 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1908 DALI_TEST_CHECK(value);
1909 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION);
1911 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1912 DALI_TEST_CHECK(value);
1913 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1915 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1916 DALI_TEST_CHECK(value);
1917 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
1922 int UtcDaliImageViewFittingModesFill(void)
1924 ToolkitTestApplication application;
1926 tet_infoline("Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )");
1927 tet_infoline(" There should be no need to change the transform, only size is changed to fit view");
1929 ImageView imageView = ImageView::New();
1930 Property::Map imageMap;
1931 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1932 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1933 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL);
1935 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1936 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1938 application.GetScene().Add(imageView);
1940 // Trigger a potential relayout
1941 application.SendNotification();
1942 application.Render();
1944 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1945 Property::Map returnedMap;
1946 visual.CreatePropertyMap(returnedMap);
1948 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1949 DALI_TEST_CHECK(value);
1950 Property::Map* map = value->GetMap();
1951 DALI_TEST_CHECK(map);
1953 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1954 DALI_TEST_CHECK(value);
1955 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Change the internal size according to the image view size
1957 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1958 DALI_TEST_CHECK(value);
1959 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1961 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1962 DALI_TEST_CHECK(value);
1963 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1968 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1970 ToolkitTestApplication application;
1972 tet_infoline("Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )");
1973 tet_infoline(" offset or size is the same as view, but adjust internally using pixelArea ");
1975 ImageView imageView = ImageView::New();
1976 Property::Map imageMap;
1977 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1978 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1979 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO);
1981 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1982 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 500));
1984 application.GetScene().Add(imageView);
1986 // Trigger a potential relayout
1987 application.SendNotification();
1988 application.Render();
1990 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1991 Property::Map returnedMap;
1992 visual.CreatePropertyMap(returnedMap);
1994 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1995 DALI_TEST_CHECK(value);
1996 Property::Map* map = value->GetMap();
1997 DALI_TEST_CHECK(map);
2000 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2001 DALI_TEST_CHECK(value);
2002 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 500), TEST_LOCATION); // Change the internal size according to the image view size
2004 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2005 DALI_TEST_CHECK(value);
2006 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2008 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2009 DALI_TEST_CHECK(value);
2010 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2015 int UtcDaliImageViewFittingModesCenter01(void)
2017 ToolkitTestApplication application;
2019 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [700,700] )");
2020 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
2022 ImageView imageView = ImageView::New();
2023 Property::Map imageMap;
2024 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2025 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2026 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
2028 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2029 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
2031 application.GetScene().Add(imageView);
2033 // Trigger a potential relayout
2034 application.SendNotification();
2035 application.Render();
2037 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2038 Property::Map returnedMap;
2039 visual.CreatePropertyMap(returnedMap);
2041 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2042 DALI_TEST_CHECK(value);
2043 Property::Map* map = value->GetMap();
2044 DALI_TEST_CHECK(map);
2046 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2047 DALI_TEST_CHECK(value);
2048 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2050 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2051 DALI_TEST_CHECK(value);
2052 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2054 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2055 DALI_TEST_CHECK(value);
2056 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
2061 int UtcDaliImageViewFittingModesCenter02(void)
2063 ToolkitTestApplication application;
2065 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [500,500] )");
2066 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
2068 ImageView imageView = ImageView::New();
2069 Property::Map imageMap;
2070 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2071 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2072 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
2074 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2075 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
2077 application.GetScene().Add(imageView);
2079 // Trigger a potential relayout
2080 application.SendNotification();
2081 application.Render();
2083 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2084 Property::Map returnedMap;
2085 visual.CreatePropertyMap(returnedMap);
2087 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2088 DALI_TEST_CHECK(value);
2089 Property::Map* map = value->GetMap();
2090 DALI_TEST_CHECK(map);
2092 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2093 DALI_TEST_CHECK(value);
2094 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2096 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2097 DALI_TEST_CHECK(value);
2098 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2100 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2101 DALI_TEST_CHECK(value);
2102 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
2107 int UtcDaliImageViewFittingModesFitHeight01(void)
2109 ToolkitTestApplication application;
2111 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )");
2113 ImageView imageView = ImageView::New();
2114 Property::Map imageMap;
2115 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2116 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2117 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2119 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2120 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2122 application.GetScene().Add(imageView);
2124 // Trigger a potential relayout
2125 application.SendNotification();
2126 application.Render();
2128 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2129 Property::Map returnedMap;
2130 visual.CreatePropertyMap(returnedMap);
2132 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2133 DALI_TEST_CHECK(value);
2134 Property::Map* map = value->GetMap();
2135 DALI_TEST_CHECK(map);
2137 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2138 DALI_TEST_CHECK(value);
2139 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 700), TEST_LOCATION); // Change the internal size according to the image view size
2141 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2142 DALI_TEST_CHECK(value);
2143 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2145 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2146 DALI_TEST_CHECK(value);
2147 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2152 int UtcDaliImageViewFittingModesFitHeight02(void)
2154 ToolkitTestApplication application;
2156 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )");
2158 ImageView imageView = ImageView::New();
2159 Property::Map imageMap;
2160 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2161 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2162 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2164 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2165 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2167 application.GetScene().Add(imageView);
2169 // Trigger a potential relayout
2170 application.SendNotification();
2171 application.Render();
2173 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2174 Property::Map returnedMap;
2175 visual.CreatePropertyMap(returnedMap);
2177 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2178 DALI_TEST_CHECK(value);
2179 Property::Map* map = value->GetMap();
2180 DALI_TEST_CHECK(map);
2182 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2183 DALI_TEST_CHECK(value);
2184 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2186 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2187 DALI_TEST_CHECK(value);
2188 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2190 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2191 DALI_TEST_CHECK(value);
2192 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2197 int UtcDaliImageViewFittingModesFitWidth01(void)
2199 ToolkitTestApplication application;
2201 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )");
2203 ImageView imageView = ImageView::New();
2204 Property::Map imageMap;
2205 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2206 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2207 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2209 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2210 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2212 application.GetScene().Add(imageView);
2214 // Trigger a potential relayout
2215 application.SendNotification();
2216 application.Render();
2218 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2219 Property::Map returnedMap;
2220 visual.CreatePropertyMap(returnedMap);
2222 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2223 DALI_TEST_CHECK(value);
2224 Property::Map* map = value->GetMap();
2225 DALI_TEST_CHECK(map);
2227 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2228 DALI_TEST_CHECK(value);
2229 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2231 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2232 DALI_TEST_CHECK(value);
2233 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2235 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2236 DALI_TEST_CHECK(value);
2237 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
2242 int UtcDaliImageViewFittingModesFitWidth02(void)
2244 ToolkitTestApplication application;
2246 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )");
2248 ImageView imageView = ImageView::New();
2249 Property::Map imageMap;
2250 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2251 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2252 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2254 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2255 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2257 application.GetScene().Add(imageView);
2259 // Trigger a potential relayout
2260 application.SendNotification();
2261 application.Render();
2263 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2264 Property::Map returnedMap;
2265 visual.CreatePropertyMap(returnedMap);
2267 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2268 DALI_TEST_CHECK(value);
2269 Property::Map* map = value->GetMap();
2270 DALI_TEST_CHECK(map);
2272 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2273 DALI_TEST_CHECK(value);
2274 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 600), TEST_LOCATION); // Change the internal size according to the image view size
2276 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2277 DALI_TEST_CHECK(value);
2278 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2280 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2281 DALI_TEST_CHECK(value);
2282 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2287 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2289 ToolkitTestApplication application;
2291 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2293 ImageView imageView = ImageView::New();
2295 // 1. Render using FittingMode::SHRINK_TO_FIT
2296 Property::Map imageMap;
2297 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2298 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2299 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2301 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2302 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2304 application.GetScene().Add(imageView);
2306 // Trigger a potential relayout
2307 application.SendNotification();
2308 application.Render();
2310 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2311 Property::Map returnedMap;
2312 visual.CreatePropertyMap(returnedMap);
2314 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2315 DALI_TEST_CHECK(value);
2316 Property::Map* map = value->GetMap();
2317 DALI_TEST_CHECK(map);
2319 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2320 DALI_TEST_CHECK(value);
2321 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2323 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2324 DALI_TEST_CHECK(value);
2325 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2327 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2328 DALI_TEST_CHECK(value);
2329 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2331 // 2. Render again using DevelVisaul::CENTER
2332 Property::Map imageMap2;
2333 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2334 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2335 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2337 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2338 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2340 application.GetScene().Add(imageView);
2342 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2344 // Trigger a potential relayout
2345 application.SendNotification();
2346 application.Render();
2348 returnedMap.Clear();
2349 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2351 visual.CreatePropertyMap(returnedMap);
2353 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2354 DALI_TEST_CHECK(value);
2355 map = value->GetMap();
2356 DALI_TEST_CHECK(map);
2358 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2359 DALI_TEST_CHECK(value);
2360 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2362 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2363 DALI_TEST_CHECK(value);
2364 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2366 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2367 DALI_TEST_CHECK(value);
2368 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2370 // 3. Render again using before fittingMode
2371 Property::Map imageMap3;
2372 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2373 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2374 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2376 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2377 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2379 application.GetScene().Add(imageView);
2381 // Trigger a potential relayout
2382 application.SendNotification();
2383 application.Render();
2385 returnedMap.Clear();
2386 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2387 visual.CreatePropertyMap(returnedMap);
2389 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2390 DALI_TEST_CHECK(value);
2391 map = value->GetMap();
2392 DALI_TEST_CHECK(map);
2394 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2395 DALI_TEST_CHECK(value);
2396 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2398 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2399 DALI_TEST_CHECK(value);
2400 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2402 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2403 DALI_TEST_CHECK(value);
2404 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2409 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2411 ToolkitTestApplication application;
2413 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2415 ImageView imageView = ImageView::New();
2417 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2418 Property::Map imageMap;
2419 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2420 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2421 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2423 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2424 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2426 application.GetScene().Add(imageView);
2428 // Trigger a potential relayout
2429 application.SendNotification();
2430 application.Render();
2432 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2433 Property::Map returnedMap;
2434 visual.CreatePropertyMap(returnedMap);
2436 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2437 DALI_TEST_CHECK(value);
2438 Property::Map* map = value->GetMap();
2439 DALI_TEST_CHECK(map);
2441 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2442 DALI_TEST_CHECK(value);
2443 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2445 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2446 DALI_TEST_CHECK(value);
2447 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2449 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2450 DALI_TEST_CHECK(value);
2451 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2453 // 2. Render again using DevelVisaul::CENTER
2454 Property::Map imageMap2;
2455 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2456 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2457 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2459 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2460 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2462 application.GetScene().Add(imageView);
2464 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2466 // Trigger a potential relayout
2467 application.SendNotification();
2468 application.Render();
2470 returnedMap.Clear();
2471 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2473 visual.CreatePropertyMap(returnedMap);
2475 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2476 DALI_TEST_CHECK(value);
2477 map = value->GetMap();
2478 DALI_TEST_CHECK(map);
2480 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2481 DALI_TEST_CHECK(value);
2482 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2484 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2485 DALI_TEST_CHECK(value);
2486 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2488 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2489 DALI_TEST_CHECK(value);
2490 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2492 // 3. Render again using before fittingMode
2493 Property::Map imageMap3;
2494 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2495 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2496 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2498 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2499 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2501 application.GetScene().Add(imageView);
2503 // Trigger a potential relayout
2504 application.SendNotification();
2505 application.Render();
2507 returnedMap.Clear();
2508 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2509 visual.CreatePropertyMap(returnedMap);
2511 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2512 DALI_TEST_CHECK(value);
2513 map = value->GetMap();
2514 DALI_TEST_CHECK(map);
2516 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2517 DALI_TEST_CHECK(value);
2518 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2520 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2521 DALI_TEST_CHECK(value);
2522 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2524 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2525 DALI_TEST_CHECK(value);
2526 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2531 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2533 ToolkitTestApplication application;
2535 tet_infoline("Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )");
2537 ImageView imageView = ImageView::New();
2538 Property::Map imageMap;
2539 imageMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE);
2540 imageMap.Add(Toolkit::ImageVisual::Property::URL, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME); // 249x169 image
2542 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2543 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
2545 application.GetScene().Add(imageView);
2547 // Trigger a potential relayout
2548 application.SendNotification();
2549 application.Render();
2551 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2552 Property::Map returnedMap;
2553 visual.CreatePropertyMap(returnedMap);
2555 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2556 DALI_TEST_CHECK(value);
2557 Property::Map* map = value->GetMap();
2558 DALI_TEST_CHECK(map);
2560 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2561 DALI_TEST_CHECK(value);
2562 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Relative size so will take up 100%
2564 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2565 DALI_TEST_CHECK(value);
2566 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2568 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2569 DALI_TEST_CHECK(value);
2570 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2575 int UtcDaliImageViewCustomShader(void)
2577 ToolkitTestApplication application;
2579 // Set a custom shader with an image url
2581 Property::Map properties;
2582 Property::Map shader;
2583 const std::string vertexShader = "Foobar";
2584 const std::string fragmentShader = "Foobar";
2585 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2586 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2588 properties[Visual::Property::TYPE] = Visual::IMAGE;
2589 properties[Visual::Property::SHADER] = shader;
2590 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2592 ImageView imageView = ImageView::New();
2593 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2595 application.GetScene().Add(imageView);
2597 application.SendNotification();
2598 application.Render();
2600 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2602 Renderer renderer = imageView.GetRendererAt(0);
2603 Shader shader2 = renderer.GetShader();
2604 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2605 Property::Map* map = value.GetMap();
2606 DALI_TEST_CHECK(map);
2608 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2609 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2611 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2612 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2615 // Set a custom shader after setting an image url
2617 Property::Map properties;
2618 Property::Map shader;
2619 const std::string vertexShader = "Foobar";
2620 const std::string fragmentShader = "Foobar";
2621 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2622 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2624 properties[Visual::Property::SHADER] = shader;
2626 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
2627 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2629 application.GetScene().Add(imageView);
2631 application.SendNotification();
2632 application.Render();
2634 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2636 Renderer renderer = imageView.GetRendererAt(0);
2637 Shader shader2 = renderer.GetShader();
2638 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2639 Property::Map* map = value.GetMap();
2640 DALI_TEST_CHECK(map);
2642 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2643 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2645 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2646 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2649 // Set a custom shader before setting an image url
2651 Property::Map properties;
2652 Property::Map shader;
2653 const std::string vertexShader = "Foobar";
2654 const std::string fragmentShader = "Foobar";
2655 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2656 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2658 properties[Visual::Property::SHADER] = shader;
2660 ImageView imageView = ImageView::New();
2661 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2662 imageView.SetProperty(ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME);
2664 application.GetScene().Add(imageView);
2666 application.SendNotification();
2667 application.Render();
2668 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2670 Renderer renderer = imageView.GetRendererAt(0);
2671 Shader shader2 = renderer.GetShader();
2672 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2673 Property::Map* map = value.GetMap();
2674 DALI_TEST_CHECK(map);
2676 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2677 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2679 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2680 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2683 // Set a custom shader after setting a property map
2685 Property::Map properties;
2686 Property::Map shader;
2687 const std::string vertexShader = "Foobar";
2688 const std::string fragmentShader = "Foobar";
2689 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2690 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2692 properties[Visual::Property::SHADER] = shader;
2694 Property::Map properties1;
2695 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2696 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2698 ImageView imageView = ImageView::New();
2699 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2700 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2702 application.GetScene().Add(imageView);
2704 application.SendNotification();
2705 application.Render();
2706 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2708 Renderer renderer = imageView.GetRendererAt(0);
2709 Shader shader2 = renderer.GetShader();
2710 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2711 Property::Map* map = value.GetMap();
2712 DALI_TEST_CHECK(map);
2714 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2715 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2717 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2718 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2721 // Set a custom shader before setting a property map
2723 Property::Map properties;
2724 Property::Map shader;
2725 const std::string vertexShader = "Foobar";
2726 const std::string fragmentShader = "Foobar";
2727 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2728 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2730 properties[Visual::Property::SHADER] = shader;
2732 Property::Map properties1;
2733 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2734 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2736 ImageView imageView = ImageView::New();
2737 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2738 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2740 application.GetScene().Add(imageView);
2742 application.SendNotification();
2743 application.Render();
2744 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2746 Renderer renderer = imageView.GetRendererAt(0);
2747 Shader shader2 = renderer.GetShader();
2748 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2749 Property::Map* map = value.GetMap();
2750 DALI_TEST_CHECK(map);
2752 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2753 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2755 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2756 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2764 static int gFailCounter = 0;
2765 const int MAX_RETRIES(3);
2767 void ReloadImage(ImageView imageView)
2769 Property::Map imageImmediateLoadingMap;
2770 imageImmediateLoadingMap[ImageVisual::Property::URL] = "Non-existant-image.jpg";
2771 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
2773 tet_infoline("Immediate load an image");
2774 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
2777 void ResourceFailedReload(Control control)
2783 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2785 tet_infoline("Test reloading failed image from within signal handler.");
2787 ToolkitTestApplication application;
2791 ImageView imageView = ImageView::New();
2792 imageView.ResourceReadySignal().Connect(&ResourceFailedReload);
2793 DALI_TEST_EQUALS(gFailCounter, 0, TEST_LOCATION);
2794 ReloadImage(imageView);
2796 // loading started, this waits for the loader thread to complete
2797 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2798 DALI_TEST_EQUALS(gFailCounter, 1, TEST_LOCATION);
2800 ReloadImage(imageView);
2801 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2802 DALI_TEST_EQUALS(gFailCounter, 2, TEST_LOCATION);
2804 ReloadImage(imageView);
2805 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2806 DALI_TEST_EQUALS(gFailCounter, 3, TEST_LOCATION);
2811 int UtcDaliImageViewLoadRemoteSVG(void)
2813 tet_infoline("Test load from a remote server.");
2815 ToolkitTestApplication application;
2818 Toolkit::ImageView imageView;
2819 imageView = Toolkit::ImageView::New();
2820 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2821 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2822 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2823 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2824 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2826 application.GetScene().Add(imageView);
2828 DALI_TEST_CHECK(imageView);
2830 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2832 application.SendNotification();
2834 // Wait for loading & rasterization
2835 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2837 application.SendNotification();
2838 application.Render();
2840 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2845 Toolkit::ImageView imageView;
2846 imageView = Toolkit::ImageView::New();
2847 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2848 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2849 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2850 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2852 application.GetScene().Add(imageView);
2854 DALI_TEST_CHECK(imageView);
2856 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2858 application.SendNotification();
2860 // Wait for loading & rasterization
2861 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2863 application.SendNotification();
2864 application.Render();
2866 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2872 int UtcDaliImageViewLoadRemoteLottie(void)
2874 tet_infoline("Test load from a remote server. (Note we don't support real download now. Just for line coverage)");
2876 ToolkitTestApplication application;
2879 Toolkit::ImageView imageView;
2880 imageView = Toolkit::ImageView::New();
2881 imageView.SetImage("https://lottie.json");
2882 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2883 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2884 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2885 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2887 application.GetScene().Add(imageView);
2889 DALI_TEST_CHECK(imageView);
2891 application.SendNotification();
2892 application.Render();
2894 // Do not check anything for here.
2900 int UtcDaliImageViewSyncSVGLoading(void)
2902 ToolkitTestApplication application;
2904 tet_infoline("ImageView Testing SVG image sync loading");
2907 ImageView imageView = ImageView::New();
2909 // Sync loading is used
2910 Property::Map syncLoadingMap;
2911 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2912 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2913 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2914 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2916 application.GetScene().Add(imageView);
2917 DALI_TEST_CHECK(imageView);
2919 application.SendNotification();
2920 Vector3 naturalSize = imageView.GetNaturalSize();
2922 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2923 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2928 int UtcDaliImageViewSyncSVGLoading02(void)
2930 ToolkitTestApplication application;
2932 tet_infoline("ImageView Testing SVG image sync loading");
2935 ImageView imageView = ImageView::New();
2937 // Sync loading is used
2938 Property::Map syncLoadingMap;
2939 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2940 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2941 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2942 syncLoadingMap.Insert(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
2943 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2944 imageView.ResourceReadySignal().Connect(&OnResourceReadySignalSVG);
2946 application.GetScene().Add(imageView);
2947 DALI_TEST_CHECK(imageView);
2949 application.SendNotification();
2950 application.Render();
2952 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
2953 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
2954 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
2955 Property::Map resultMap;
2956 imageVisual.CreatePropertyMap(resultMap);
2958 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
2959 DALI_TEST_CHECK(transformValue);
2960 Property::Map* retMap = transformValue->GetMap();
2961 DALI_TEST_CHECK(retMap);
2963 // Image Visual should be positioned depending on ImageView's padding
2964 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::SIZE)->Get<Vector2>(), Vector2(100, 100), TEST_LOCATION);
2966 Vector3 naturalSize = imageView.GetNaturalSize();
2967 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2968 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2973 int UtcDaliImageViewAsyncSVGLoading(void)
2975 ToolkitTestApplication application;
2977 tet_infoline("ImageView Testing SVG image async loading");
2980 ImageView imageView = ImageView::New();
2982 // Async loading is used - default value of SYNCHRONOUS_LOADING is false.
2983 Property::Map propertyMap;
2984 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2985 propertyMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2986 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
2988 application.GetScene().Add(imageView);
2989 DALI_TEST_CHECK(imageView);
2991 application.SendNotification();
2994 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2996 application.SendNotification();
2997 application.Render(16);
2999 Vector3 naturalSize = imageView.GetNaturalSize();
3000 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3001 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3006 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
3008 ToolkitTestApplication application;
3010 tet_infoline("ImageView Testing SVG image async loading");
3014 ImageView imageView = ImageView::New();
3016 // Sync loading is used
3017 Property::Map syncLoadingMap;
3018 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
3019 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
3021 // Check to set invalid value
3022 // The SYNCHRONOUS_LOADING property must be set to the bool value.
3023 // Check if error log is outputted when setting other value like string.
3024 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
3025 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5));
3026 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
3028 application.GetScene().Add(imageView);
3029 DALI_TEST_CHECK(imageView);
3031 application.SendNotification();
3034 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3036 application.SendNotification();
3037 application.Render(16);
3039 Vector3 naturalSize = imageView.GetNaturalSize();
3040 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3041 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3043 Property::Value value = imageView.GetProperty(ImageView::Property::IMAGE);
3044 Property::Map* map = value.GetMap();
3045 DALI_TEST_CHECK(map);
3047 Property::Value* sync = map->Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING);
3048 DALI_TEST_CHECK(sync);
3049 DALI_TEST_EQUALS(false, sync->Get<bool>(), TEST_LOCATION);
3054 int UtcDaliImageViewSvgLoadingFailureLocalFile(void)
3056 // Local svg file - invalid file path
3058 ToolkitTestApplication application;
3060 TestGlAbstraction& gl = application.GetGlAbstraction();
3061 TraceCallStack& textureTrace = gl.GetTextureTrace();
3062 textureTrace.Enable(true);
3064 gResourceReadySignalFired = false;
3066 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
3067 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3068 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3070 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3072 application.GetScene().Add(imageView);
3074 application.SendNotification();
3076 // loading started, this waits for the loader thread - load
3077 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3079 application.SendNotification();
3080 application.Render(16);
3082 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3083 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3084 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3086 // Should be shown a broken image
3087 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3088 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3091 // Local svg file - invalid file path without size set
3093 ToolkitTestApplication application;
3095 TestGlAbstraction& gl = application.GetGlAbstraction();
3096 TraceCallStack& textureTrace = gl.GetTextureTrace();
3097 textureTrace.Enable(true);
3099 gResourceReadySignalFired = false;
3100 textureTrace.Reset();
3102 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
3103 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3105 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3107 application.GetScene().Add(imageView);
3109 application.SendNotification();
3111 // loading started, this waits for the loader thread - load & rasterize
3112 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3114 application.SendNotification();
3115 application.Render(16);
3117 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3118 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3119 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3121 // Should be shown a broken image
3122 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3123 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3126 // Local svg file - invalid file
3128 ToolkitTestApplication application;
3130 TestGlAbstraction& gl = application.GetGlAbstraction();
3131 TraceCallStack& textureTrace = gl.GetTextureTrace();
3132 textureTrace.Enable(true);
3134 gResourceReadySignalFired = false;
3135 textureTrace.Reset();
3137 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.svg");
3138 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3139 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3141 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3143 application.GetScene().Add(imageView);
3145 application.SendNotification();
3147 // loading started, this waits for the loader thread - load & rasterize
3148 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3150 application.SendNotification();
3151 application.Render(16);
3153 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3154 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3155 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3157 // Should be shown a broken image
3158 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3159 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3165 int UtcDaliImageViewSvgLoadingFailureRemoteFile01(void)
3169 ToolkitTestApplication application;
3171 TestGlAbstraction& gl = application.GetGlAbstraction();
3172 TraceCallStack& textureTrace = gl.GetTextureTrace();
3173 textureTrace.Enable(true);
3175 gResourceReadySignalFired = false;
3177 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
3178 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3179 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3181 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3183 application.GetScene().Add(imageView);
3185 application.SendNotification();
3187 // loading started, this waits for the loader thread - load & rasterize
3188 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3190 application.SendNotification();
3191 application.Render(16);
3193 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3194 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3195 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3197 // Should be shown a broken image
3198 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3199 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3205 int UtcDaliImageViewSvgLoadingFailureRemoteFile02(void)
3207 // Remote svg file without size set
3209 ToolkitTestApplication application;
3211 TestGlAbstraction& gl = application.GetGlAbstraction();
3212 TraceCallStack& textureTrace = gl.GetTextureTrace();
3213 textureTrace.Enable(true);
3215 gResourceReadySignalFired = false;
3217 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
3218 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3220 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3222 application.GetScene().Add(imageView);
3224 application.SendNotification();
3226 // loading started, this waits for the loader thread - load & rasterize
3227 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3229 application.SendNotification();
3230 application.Render(16);
3232 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3233 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3234 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3236 // Should be shown a broken image
3237 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3238 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3244 int UtcDaliImageViewSvgRasterizationFailure(void)
3246 ToolkitTestApplication application;
3248 gResourceReadySignalFired = false;
3250 TestGlAbstraction& gl = application.GetGlAbstraction();
3251 TraceCallStack& textureTrace = gl.GetTextureTrace();
3252 textureTrace.Enable(true);
3254 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid1.svg");
3255 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3256 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3258 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3260 application.GetScene().Add(imageView);
3262 application.SendNotification();
3264 // Wait for loading & rasterization
3265 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3267 application.SendNotification();
3268 application.Render(16);
3270 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3271 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3272 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3274 // Should be shown a broken image
3275 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3276 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3281 int UtcDaliImageViewSvgChageSize(void)
3283 ToolkitTestApplication application;
3285 TestGlAbstraction& gl = application.GetGlAbstraction();
3286 TraceCallStack& textureTrace = gl.GetTextureTrace();
3287 textureTrace.Enable(true);
3289 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME);
3290 application.GetScene().Add(imageView);
3292 application.SendNotification();
3294 // Wait for loading & rasterization
3295 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3297 application.SendNotification();
3298 application.Render(16);
3300 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3302 // Change actor size, then rasterization should be done again
3303 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3305 application.SendNotification();
3307 // Wait for rasterization
3308 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3310 application.SendNotification();
3311 application.Render(16);
3313 // We should not load the file again.
3314 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3319 int UtcDaliImageViewSvgAtlasing(void)
3321 ToolkitTestApplication application;
3323 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
3325 callStack.Enable(true);
3327 Property::Map propertyMap;
3328 propertyMap["url"] = TEST_SVG_FILE_NAME;
3329 propertyMap["atlasing"] = true;
3331 ImageView imageView = ImageView::New();
3332 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
3333 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3334 application.GetScene().Add(imageView);
3336 application.SendNotification();
3338 // Wait for loading & rasterization
3339 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3341 application.SendNotification();
3342 application.Render(16);
3345 TraceCallStack::NamedParams params1;
3346 params1["width"] << 100;
3347 params1["height"] << 100;
3348 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params1), true, TEST_LOCATION);
3350 imageView.SetProperty(Actor::Property::SIZE, Vector2(600.f, 600.f));
3352 application.SendNotification();
3354 // Wait for rasterization
3355 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3359 application.SendNotification();
3360 application.Render(16);
3363 TraceCallStack::NamedParams params2;
3364 params2["width"] << 600;
3365 params2["height"] << 600;
3366 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexImage2D", params2), true, TEST_LOCATION);
3371 int UtcDaliImageViewTVGLoading(void)
3373 ToolkitTestApplication application;
3375 tet_infoline("ImageView Testing TVG image loading");
3378 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/test.tvg");
3379 application.GetScene().Add(imageView);
3380 DALI_TEST_CHECK(imageView);
3382 application.SendNotification();
3384 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3386 application.SendNotification();
3387 application.Render(16);
3389 Vector3 naturalSize = imageView.GetNaturalSize();
3391 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3392 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3397 int UtcDaliImageViewSvgDesiredSize01(void)
3399 ToolkitTestApplication application;
3401 TestGlAbstraction& gl = application.GetGlAbstraction();
3402 TraceCallStack& textureTrace = gl.GetTextureTrace();
3403 textureTrace.Enable(true);
3405 int desiredWidth = 100, desiredHeight = 150;
3406 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
3408 application.GetScene().Add(imageView);
3410 application.SendNotification();
3412 // Wait for loading & rasterization
3413 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3415 application.SendNotification();
3416 application.Render(16);
3419 std::stringstream out;
3420 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
3421 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
3427 int UtcDaliImageViewSvgDesiredSize02(void)
3429 ToolkitTestApplication application;
3431 TestGlAbstraction& gl = application.GetGlAbstraction();
3432 TraceCallStack& textureTrace = gl.GetTextureTrace();
3433 textureTrace.Enable(true);
3435 int desiredWidth = 150, desiredHeight = 100;
3436 ImageView imageView = ImageView::New();
3437 imageView[ImageView::Property::IMAGE] = Property::Map().Add("url", TEST_SVG_FILE_NAME).Add("desiredWidth", desiredWidth).Add("desiredHeight", desiredHeight);
3438 application.GetScene().Add(imageView);
3440 application.SendNotification();
3442 // Wait for loading & rasterization
3443 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3445 application.SendNotification();
3446 application.Render(16);
3449 std::stringstream out;
3450 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
3451 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
3457 int UtcDaliImageViewImageLoadFailure01(void)
3459 ToolkitTestApplication application;
3461 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3462 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3463 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3464 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3466 std::string brokenUrl;
3467 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3468 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3470 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3471 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3473 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3474 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3476 ImageView imageView = ImageView::New("invalidUrl.png");
3477 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3479 application.GetScene().Add(imageView);
3480 application.SendNotification();
3481 application.Render(16);
3483 // loading started, this waits for the loader thread
3484 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3489 int UtcDaliImageViewImageLoadFailure02(void)
3491 ToolkitTestApplication application;
3493 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3494 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
3495 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3496 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3498 std::string brokenUrl;
3499 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3500 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
3502 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3503 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3505 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3506 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3508 ImageView imageView = ImageView::New("invalidUrl.png");
3509 imageView.SetProperty(Actor::Property::SIZE, Vector2(30.f, 30.f));
3510 application.GetScene().Add(imageView);
3511 application.SendNotification();
3512 application.Render(16);
3514 // loading started, this waits for the loader thread
3515 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3520 int UtcDaliImageViewImageLoadFailure03(void)
3522 ToolkitTestApplication application;
3524 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3525 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
3526 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
3528 std::string brokenUrl;
3529 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3530 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3532 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3533 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3535 ImageView imageView = ImageView::New("invalidUrl.png");
3536 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3537 application.GetScene().Add(imageView);
3538 application.SendNotification();
3539 application.Render(16);
3541 // loading started, this waits for the loader thread
3542 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3547 int UtcDaliImageViewImageLoadFailure04(void)
3549 ToolkitTestApplication application;
3551 ImageView imageView = ImageView::New("invalidUrl.png");
3552 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3553 application.GetScene().Add(imageView);
3554 application.SendNotification();
3555 application.Render(16);
3557 // loading started, this waits for the loader thread
3558 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3560 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3561 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3562 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3563 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3565 ImageView imageView2 = ImageView::New("invalidUrl.png");
3566 imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3567 application.GetScene().Add(imageView2);
3569 std::string brokenUrl;
3570 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3571 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3573 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3574 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3576 application.SendNotification();
3577 application.Render(16);
3579 // loading started, this waits for the loader thread
3580 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3582 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3584 ImageView imageView3 = ImageView::New("invalidUrl.png");
3585 imageView3.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3586 application.GetScene().Add(imageView3);
3588 application.SendNotification();
3589 application.Render(16);
3591 // loading started, this waits for the loader thread
3592 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3599 static int gResourceReadySignalCounter = 0;
3601 void OnResourceReadySignal01(Control control)
3603 gResourceReadySignalCounter++;
3605 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3607 if(gResourceReadySignalCounter == 1)
3610 // It makes the first new visual be deleted immediately
3611 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3612 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3615 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3617 // Make the resource ready immediately
3618 control[ImageView::Property::IMAGE] = gImage_600_RGB;
3622 void OnResourceReadySignal02(Control control)
3624 if(++gResourceReadySignalCounter == 1)
3626 // It makes the first new visual be deleted immediately
3627 // The first image will not be loaded.
3628 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB).Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3629 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3633 ImageView gImageView1;
3634 ImageView gImageView2;
3635 ImageView gImageView3;
3636 ImageView gImageView4;
3638 void OnResourceReadySignal03(Control control)
3640 if(gResourceReadySignalCounter == 0)
3643 // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3644 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3646 // 2. Load a new image
3647 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3649 // 3. Use the new image again
3650 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3651 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3653 else if(gResourceReadySignalCounter == 1)
3655 // This is called from TextureManager::ProcessQueuedTextures().
3656 gImageView1.Unparent();
3657 gImageView1.Reset();
3659 gResourceReadySignalCounter++;
3662 void OnSimpleResourceReadySignal(Control control)
3664 // simply increate counter
3665 gResourceReadySignalCounter++;
3668 int gResourceReadySignal04ComesOrder = 0;
3670 void OnResourceReadySignal04(Control control)
3672 gResourceReadySignalCounter++;
3673 tet_printf("rc %d\n", gResourceReadySignalCounter);
3674 if(gResourceReadySignalCounter == 1)
3676 auto scene = gImageView1.GetParent();
3678 // Request load something
3679 // We hope this request result is return later than gImageView2.
3680 gImageView3 = ImageView::New(TEST_IMAGE_1);
3681 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3682 scene.Add(gImageView3);
3683 gImageView4 = ImageView::New(TEST_IMAGE_2);
3684 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3685 scene.Add(gImageView4);
3687 if(control == gImageView1)
3689 gResourceReadySignal04ComesOrder = 1;
3693 gResourceReadySignal04ComesOrder = 2;
3696 if(gResourceReadySignalCounter == 2)
3698 if(gResourceReadySignal04ComesOrder == 1 && control == gImageView2)
3700 // Scene off first one.
3701 gImageView1.Unparent();
3703 // Scene off second one.
3704 gImageView2.Unparent();
3706 else if(gResourceReadySignal04ComesOrder == 2 && control == gImageView1)
3708 // Scene off first one.
3709 gImageView2.Unparent();
3711 // Scene off second one.
3712 gImageView1.Unparent();
3716 // We can't check that this utc fail case. just pass always when we come here.
3717 gResourceReadySignal04ComesOrder = -1;
3720 // If we don't seperate index of FreeList area
3721 // and if we don't queue remove during obversing,
3722 // cache index become something invalid data.
3723 // In this case, some strange observer can be called.
3724 // For example, gImageView4.LoadComplete will be called.
3728 void OnResourceReadySignal05(Control control)
3730 gResourceReadySignalCounter++;
3732 // Request load with same image
3733 // NOTE : The url must not be same as gImageView1
3734 const int viewCount = 4;
3735 for(int i = 0; i < viewCount; ++i)
3737 gImageView1.Add(ImageView::New("invalid2.jpg"));
3741 int gResourceReadySignal06ComesOrder = 0;
3743 void OnResourceReadySignal06(Control control)
3745 gResourceReadySignalCounter++;
3746 if(gResourceReadySignalCounter == 1)
3748 auto scene = gImageView1.GetParent();
3750 // Request load something
3751 // We hope this request result is return later than gImageView2.
3754 map1[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
3755 map1[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
3757 gImageView3 = ImageView::New();
3758 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3759 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3762 map2[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
3763 map2[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_S;
3764 gImageView4 = ImageView::New();
3765 gImageView4.SetProperty(Toolkit::ImageView::Property::IMAGE, map2);
3766 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3768 if(control == gImageView1)
3770 gResourceReadySignal06ComesOrder = 1;
3774 gResourceReadySignal06ComesOrder = 2;
3777 if(gResourceReadySignalCounter == 2)
3779 if(gResourceReadySignal06ComesOrder == 1 && control == gImageView2)
3781 // Scene off first one.
3782 gImageView1.Unparent();
3784 // Scene off second one.
3785 gImageView2.Unparent();
3787 else if(gResourceReadySignal06ComesOrder == 2 && control == gImageView1)
3789 // Scene off first one.
3790 gImageView2.Unparent();
3792 // Scene off second one.
3793 gImageView1.Unparent();
3797 // We can't check that this utc fail case. just pass always when we come here.
3798 gResourceReadySignal06ComesOrder = -1;
3801 // If we don't seperate index of FreeList area
3802 // and if we don't queue remove during obversing,
3803 // cache index become something invalid data.
3804 // In this case, some strange observer can be called.
3805 // For example, gImageView4.LoadComplete will be called.
3809 void OnResourceReadySignal07(Control control)
3811 gResourceReadySignalCounter++;
3812 // Load masked image
3813 tet_printf("rc %d %d\n", gResourceReadySignalCounter, static_cast<bool>(gImageView2));
3817 auto scene = gImageView1.GetParent();
3820 map1[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
3821 map1[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
3823 gImageView2 = ImageView::New();
3824 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3825 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal07);
3827 scene.Add(gImageView2);
3831 void OnResourceReadySignal08(Control control)
3833 gResourceReadySignalCounter++;
3837 gImageView1.Unparent();
3838 gImageView1.Reset();
3842 gImageView2.Unparent();
3843 gImageView2.Reset();
3847 std::size_t gResourceReadySignal09Emitted = false;
3849 void OnResourceReadySignal09(Control control)
3851 gResourceReadySignalCounter++;
3853 if(gImageView1 && !gResourceReadySignal09Emitted)
3855 gResourceReadySignal09Emitted = true;
3856 gImageView1.ResourceReadySignal().Disconnect(&OnResourceReadySignal09);
3858 // Try to load cached invalid nine patch image. It will request load now.
3859 gImageView1.SetImage(TEST_INVALID_NPATCH_FILE_NAME_01);
3860 gImageView2.SetImage(TEST_INVALID_NPATCH_FILE_NAME_01);
3862 // Destroy all visuals immediatly.
3863 gImageView1.Unparent();
3864 gImageView1.Reset();
3865 gImageView2.Unparent();
3866 gImageView2.Reset();
3869 constexpr int gResourceReadySignal10MaxCounter = 5;
3871 void OnResourceReadySignal10(Control control)
3873 gResourceReadySignalCounter++;
3875 tet_printf("OnResourceReadySignal10 comes!\n");
3876 if(gResourceReadySignalCounter < gResourceReadySignal10MaxCounter)
3878 tet_printf("OnResourceReadySignal10 Set image\n");
3879 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, gImage_34_RGBA);
3880 tet_printf("OnResourceReadySignal10 Set image done\n");
3884 void OnResourceReadySignal11(Control control)
3886 gResourceReadySignalCounter++;
3890 auto scene = gImageView1.GetParent();
3892 // Try to load animated image visual here which is already cached, and then ignore forcely.
3895 map1[Toolkit::ImageVisual::Property::URL] = TEST_GIF_FILE_NAME;
3897 gImageView2 = ImageView::New();
3898 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3900 gImageView3 = ImageView::New();
3901 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3903 scene.Add(gImageView2);
3904 gImageView2.Unparent();
3906 scene.Add(gImageView3);
3907 gImageView3.Unparent();
3908 gImageView3.Reset(); // Destroy visual
3914 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3916 tet_infoline("Test setting image from within signal handler.");
3918 ToolkitTestApplication application;
3920 gResourceReadySignalCounter = 0;
3922 ImageView imageView = ImageView::New(gImage_34_RGBA);
3923 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal01);
3925 application.GetScene().Add(imageView);
3927 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3929 application.SendNotification();
3930 application.Render();
3932 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3934 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3936 // Create a new ImageView to cache the image
3937 ImageView imageView1 = ImageView::New(gImage_600_RGB);
3938 application.GetScene().Add(imageView1);
3940 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3942 application.SendNotification();
3943 application.Render();
3946 gResourceReadySignalCounter = 0;
3948 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3950 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3952 application.SendNotification();
3953 application.Render();
3955 // Run idle callback
3956 application.RunIdles();
3958 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3960 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3965 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
3967 tet_infoline("Test setting image from within signal handler.");
3969 ToolkitTestApplication application;
3971 gResourceReadySignalCounter = 0;
3973 ImageView imageView = ImageView::New(gImage_34_RGBA);
3974 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal02);
3976 application.GetScene().Add(imageView);
3978 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3980 application.SendNotification();
3981 application.Render();
3983 // Wait for loading an image
3984 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3986 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3988 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3993 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3995 tet_infoline("Test setting image from within signal handler.");
3997 ToolkitTestApplication application;
3999 gResourceReadySignalCounter = 0;
4001 gImageView1 = ImageView::New(gImage_34_RGBA);
4002 application.GetScene().Add(gImageView1);
4005 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4007 gImageView2 = ImageView::New(gImage_600_RGB);
4008 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
4009 application.GetScene().Add(gImageView2);
4011 gImageView3 = ImageView::New();
4012 application.GetScene().Add(gImageView3);
4014 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4016 application.SendNotification();
4017 application.Render();
4022 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask01(void)
4024 tet_infoline("Test signal handler when image / mask image is broken.");
4026 ToolkitTestApplication application;
4028 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, const std::string& url, const std::string& mask, const char* location) {
4029 gResourceReadySignalCounter = 0;
4032 map[Toolkit::ImageVisual::Property::URL] = url;
4035 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
4037 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
4039 ImageView imageView = ImageView::New();
4040 imageView[Toolkit::ImageView::Property::IMAGE] = map;
4041 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
4042 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4044 application.GetScene().Add(imageView);
4045 application.SendNotification();
4046 application.Render();
4051 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
4053 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
4054 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
4056 imageView.Unparent();
4059 for(int synchronous = 0; synchronous <= 1; synchronous++)
4061 tet_printf("Test normal case (sync:%d)\n", synchronous);
4062 TestResourceReadyUrl(1, synchronous, gImage_600_RGB, "", TEST_LOCATION);
4063 TestResourceReadyUrl(3, synchronous, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 3 event trigger required : 2 image load + 1 apply mask
4065 tet_printf("Test broken image case (sync:%d)\n", synchronous);
4066 TestResourceReadyUrl(1, synchronous, "invalid.jpg", "", TEST_LOCATION);
4067 TestResourceReadyUrl(2, synchronous, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
4069 tet_printf("Test broken mask image case (sync:%d)\n", synchronous);
4070 TestResourceReadyUrl(2, synchronous, gImage_600_RGB, "invalid.png", TEST_LOCATION);
4072 tet_printf("Test broken both image, mask image case (sync:%d)\n", synchronous);
4073 TestResourceReadyUrl(2, synchronous, "invalid.jpg", "invalid.png", TEST_LOCATION);
4079 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask02(void)
4081 tet_infoline("Test signal handler when image try to use cached-and-broken mask image.");
4083 ToolkitTestApplication application;
4085 gResourceReadySignalCounter = 0;
4087 auto TestBrokenMaskResourceReadyUrl = [&application](const std::string& url, const char* location) {
4089 map[Toolkit::ImageVisual::Property::URL] = url;
4090 // Use invalid mask url
4091 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
4093 ImageView imageView = ImageView::New();
4094 imageView[Toolkit::ImageView::Property::IMAGE] = map;
4095 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
4096 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4098 application.GetScene().Add(imageView);
4100 // Don't unparent imageView, for keep the cache.
4103 // Use more than 4 images (The number of LocalImageLoadThread)
4104 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};
4106 int expectResourceReadySignalCounter = 0;
4108 for(auto& url : testUrlList)
4110 TestBrokenMaskResourceReadyUrl(url, TEST_LOCATION);
4111 expectResourceReadySignalCounter++;
4114 // Remain 1 signal due to we use #URL + 1 mask image.
4115 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(expectResourceReadySignalCounter + 1), true, TEST_LOCATION);
4116 application.SendNotification();
4117 application.Render();
4118 DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
4123 int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
4125 tet_infoline("Test signal handler various case.");
4127 auto TestResourceReadyUrl = [](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
4128 ToolkitTestApplication application;
4130 gResourceReadySignalCounter = 0;
4133 map[Toolkit::ImageVisual::Property::URL] = url;
4136 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
4138 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
4140 ImageView imageView = ImageView::New();
4141 imageView[Toolkit::ImageView::Property::IMAGE] = map;
4142 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
4143 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4145 application.GetScene().Add(imageView);
4146 application.SendNotification();
4147 application.Render();
4150 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
4152 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
4153 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
4154 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, location);
4156 imageView.Unparent();
4159 auto TestAuxiliaryResourceReadyUrl = [](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
4160 ToolkitTestApplication application;
4162 gResourceReadySignalCounter = 0;
4165 map[Toolkit::ImageVisual::Property::URL] = url;
4166 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE] = auxiliaryUrl;
4167 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA] = 0.5f;
4168 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
4170 ImageView imageView = ImageView::New();
4171 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4172 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4173 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4174 application.GetScene().Add(imageView);
4176 application.SendNotification();
4177 application.Render();
4182 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, location);
4185 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
4186 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
4187 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
4189 imageView.Unparent();
4192 // Case 1 : asynchronous loading
4193 tet_printf("Test invalid single simple image Asynchronous\n");
4196 TestResourceReadyUrl(1, 0, 1, gImage_600_RGB, "", TEST_LOCATION);
4197 TestResourceReadyUrl(2, 0, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // load & rasterize
4198 TestResourceReadyUrl(1, 0, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
4200 TestResourceReadyUrl(2, 0, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // 2 image loading - batch size
4201 TestResourceReadyUrl(2, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // load & rasterize
4203 TestResourceReadyUrl(3, 0, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 2 image loading + 1 applymask
4205 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
4208 TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
4209 TestResourceReadyUrl(1, 0, 0, "invalid.svg", "", TEST_LOCATION);
4210 TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
4211 TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION); // 1 image loading
4212 TestResourceReadyUrl(1, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
4214 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", "invalid.png", TEST_LOCATION); // 2 image loading
4215 TestResourceReadyUrl(2, 0, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); // 2 image loading
4216 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION); // 2 image loading
4218 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
4219 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
4220 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
4222 // Case 2 : Synchronous loading
4223 tet_printf("Test invalid single simple image Synchronous\n");
4226 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "", TEST_LOCATION);
4227 TestResourceReadyUrl(0, 1, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
4228 TestResourceReadyUrl(0, 1, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
4230 TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // first frame image loading sync + second frame image loading async
4232 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION);
4234 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
4237 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
4238 TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION);
4239 TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
4240 TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
4242 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "invalid.png", TEST_LOCATION);
4243 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION);
4244 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
4246 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
4247 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
4248 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
4253 int UtcDaliImageViewSetImageOnResourceReadySignal04(void)
4255 tet_infoline("Test texturemanager's remove queue works well within signal handler.");
4257 ToolkitTestApplication application;
4259 gResourceReadySignalCounter = 0;
4260 gResourceReadySignal04ComesOrder = 0;
4262 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
4263 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal04);
4264 application.GetScene().Add(gImageView1);
4266 gImageView2 = ImageView::New("invalid.png"); // request invalid image, to make loading failed fast.
4267 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal04);
4268 application.GetScene().Add(gImageView2);
4270 application.SendNotification();
4271 application.Render();
4273 tet_infoline("Try to load 2 invalid image");
4275 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4276 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4278 tet_infoline("load done");
4280 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
4281 if(gResourceReadySignal04ComesOrder == -1)
4283 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
4287 // gImageView3 and gImageView4 load must not be successed yet.
4288 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
4289 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
4291 application.SendNotification();
4292 application.Render();
4294 tet_infoline("Try to load 2 valid image");
4296 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4297 DALI_TEST_EQUALS(gResourceReadySignalCounter, 4, TEST_LOCATION);
4299 tet_infoline("load done");
4301 // gImageView3 and gImageView4 load must be successed now.
4302 DALI_TEST_EQUALS(gImageView3.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
4303 DALI_TEST_EQUALS(gImageView4.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
4308 int UtcDaliImageViewSetImageOnResourceReadySignal05(void)
4310 tet_infoline("Test multiple views with same image during ResourceReady load the image only 1 times");
4312 ToolkitTestApplication application;
4314 gResourceReadySignalCounter = 0;
4316 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
4317 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal05);
4318 application.GetScene().Add(gImageView1);
4320 application.SendNotification();
4321 application.Render();
4323 tet_infoline("Try to load 1 invalid.jpg image");
4324 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4325 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4327 tet_infoline("Try to load 1 invalid2.jpg image");
4328 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4330 tet_infoline("Now we don't have any image to be loaded. Check event thread trigger failed.");
4331 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
4333 gImageView1.Unparent();
4334 gImageView1.Reset();
4338 int UtcDaliImageViewSetImageOnResourceReadySignal06(void)
4340 tet_infoline("Test texturemanager's remove image & mask queue works well within signal handler.");
4342 ToolkitTestApplication application;
4344 gResourceReadySignalCounter = 0;
4345 gResourceReadySignal06ComesOrder = 0;
4348 map[Toolkit::ImageVisual::Property::URL] = "invalid.jpg";
4349 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
4351 gImageView1 = ImageView::New(); // request invalid image, to make loading failed fast.
4352 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4353 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal06);
4354 application.GetScene().Add(gImageView1);
4356 gImageView2 = ImageView::New(); // request invalid image, to make loading failed fast.
4357 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4358 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal06);
4359 application.GetScene().Add(gImageView2);
4361 application.SendNotification();
4362 application.Render();
4364 tet_infoline("Try to load 2 invalid image");
4366 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4367 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4369 tet_infoline("load done");
4371 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
4372 if(gResourceReadySignal06ComesOrder == -1)
4374 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
4378 // gImageView3 and gImageView4 load must not be successed yet.
4379 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
4380 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
4382 application.GetScene().Add(gImageView3);
4383 application.GetScene().Add(gImageView4);
4384 application.SendNotification();
4385 application.Render();
4387 tet_infoline("Try to load 2 valid image");
4389 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4390 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4392 tet_infoline("load done");
4397 int UtcDaliImageViewSetImageOnResourceReadySignal07(void)
4399 tet_infoline("Test texturemanager's remove image & mask queue works well within signal handler 02.");
4401 ToolkitTestApplication application;
4403 gResourceReadySignalCounter = 0;
4406 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4408 // Clear image view for clear test
4412 gImageView1.Reset();
4416 gImageView2.Reset();
4419 gImageView1 = ImageView::New();
4420 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4421 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal07);
4422 application.GetScene().Add(gImageView1);
4424 application.SendNotification();
4425 application.Render();
4429 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4430 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4432 tet_infoline("load image1 done");
4434 // Load gImageView2 and mask
4436 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4437 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4439 // gImageView2 mask apply done
4441 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4442 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4444 tet_infoline("load image2 done");
4448 int UtcDaliImageViewSetImageOnResourceReadySignal08(void)
4450 tet_infoline("Test remove npatch images during resource ready");
4452 ToolkitTestApplication application;
4454 gResourceReadySignalCounter = 0;
4457 map[Toolkit::ImageVisual::Property::URL] = TEST_BROKEN_IMAGE_M;
4459 // Clear image view for clear test
4463 gImageView1.Reset();
4467 gImageView2.Reset();
4470 // Case 1 : Remove all images during resource ready.
4473 gImageView1 = ImageView::New();
4474 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4475 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal08);
4476 application.GetScene().Add(gImageView1);
4478 application.SendNotification();
4479 application.Render();
4482 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4483 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4485 application.SendNotification();
4486 application.Render();
4488 DALI_TEST_CHECK(true);
4492 // Exception should not happened
4493 DALI_TEST_CHECK(false);
4497 application.SendNotification();
4498 application.Render();
4500 gResourceReadySignalCounter = 0;
4502 // Case 2 : Remove all images when we use cached resource.
4505 gImageView1 = ImageView::New();
4506 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4507 gImageView1.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4508 application.GetScene().Add(gImageView1);
4510 application.SendNotification();
4511 application.Render();
4514 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4515 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4517 application.SendNotification();
4518 application.Render();
4520 gImageView2 = ImageView::New();
4521 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4522 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal08);
4523 application.GetScene().Add(gImageView2);
4524 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4526 application.SendNotification();
4527 application.Render();
4529 DALI_TEST_CHECK(true);
4533 // Exception should not happened
4534 DALI_TEST_CHECK(false);
4536 gResourceReadySignalCounter = 0;
4538 // Clear image view for clear test
4542 gImageView1.Reset();
4546 gImageView2.Reset();
4552 int UtcDaliImageViewSetImageOnResourceReadySignal09(void)
4554 tet_infoline("Test load invalid npatch images during invalid resource ready");
4556 ToolkitTestApplication application;
4558 gResourceReadySignalCounter = 0;
4561 map[Toolkit::ImageVisual::Property::URL] = TEST_INVALID_NPATCH_FILE_NAME_01;
4563 // Clear image view for clear test
4567 gImageView1.Reset();
4571 gImageView2.Reset();
4575 gImageView3.Reset();
4578 // Dummy view with npatch image
4579 ImageView dummyView = ImageView::New(TEST_BROKEN_IMAGE_M);
4580 application.GetScene().Add(dummyView);
4582 application.SendNotification();
4583 application.Render();
4584 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4585 application.SendNotification();
4586 application.Render();
4588 // Case 1 : Reload images during resource ready.
4591 gResourceReadySignal09Emitted = false;
4593 gImageView1 = ImageView::New();
4594 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4595 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal09);
4596 application.GetScene().Add(gImageView1);
4598 gImageView2 = ImageView::New();
4599 application.GetScene().Add(gImageView2);
4601 // Load TEST_INVALID_NPATCH_FILE_NAME_01
4602 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4604 // Load TEST_INVALID_NPATCH_FILE_NAME_01 one more times.
4605 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4607 application.SendNotification();
4608 application.Render();
4610 DALI_TEST_CHECK(true);
4614 // Exception should not happened
4615 DALI_TEST_CHECK(false);
4619 application.SendNotification();
4620 application.Render();
4622 gResourceReadySignalCounter = 0;
4624 // Case 2 : Remove all images when we use cached resource.
4627 gResourceReadySignal09Emitted = false;
4629 gImageView3 = ImageView::New();
4630 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4631 gImageView3.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4632 application.GetScene().Add(gImageView3);
4634 gImageView2 = ImageView::New();
4635 application.GetScene().Add(gImageView2);
4638 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4640 gImageView1 = ImageView::New();
4641 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4642 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal09);
4643 application.GetScene().Add(gImageView1);
4646 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4648 // Load TEST_INVALID_NPATCH_FILE_NAME_01 one more times.
4649 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4651 application.SendNotification();
4652 application.Render();
4654 DALI_TEST_CHECK(true);
4658 // Exception should not happened
4659 DALI_TEST_CHECK(false);
4661 gResourceReadySignalCounter = 0;
4663 // Clear image view for clear test
4667 gImageView1.Reset();
4671 gImageView2.Reset();
4675 gImageView3.Reset();
4681 int UtcDaliImageViewSetImageOnResourceReadySignal10(void)
4683 tet_infoline("Test ResourceReady signal comes more than 2 times.");
4685 ToolkitTestApplication application;
4687 gResourceReadySignalCounter = 0;
4689 // Clear image view for clear test
4693 gImageView1.Reset();
4696 // Dummy view to cache image.
4697 ImageView dummyView = ImageView::New(gImage_34_RGBA);
4698 application.GetScene().Add(dummyView);
4700 application.SendNotification();
4701 application.Render();
4702 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4703 application.SendNotification();
4704 application.Render();
4708 gImageView1 = ImageView::New();
4709 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, gImage_34_RGBA);
4710 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal10);
4711 application.GetScene().Add(gImageView1); // It will call resourceReady signal 1 time.
4713 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4715 DALI_TEST_GREATER(gResourceReadySignal10MaxCounter, gResourceReadySignalCounter, TEST_LOCATION); // Check whether resource ready call too much.
4717 for(int i = 0; i < gResourceReadySignal10MaxCounter; ++i)
4719 tet_printf("RunIdles\n");
4720 // Executes the idle callbacks.
4721 application.RunIdles();
4722 application.SendNotification();
4723 application.Render();
4724 tet_printf("RunIdles done\n");
4726 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4728 DALI_TEST_EQUALS(gResourceReadySignalCounter, gResourceReadySignal10MaxCounter, TEST_LOCATION);
4730 DALI_TEST_CHECK(true);
4734 // Exception should not happened
4735 DALI_TEST_CHECK(false);
4739 application.SendNotification();
4740 application.Render();
4742 gResourceReadySignalCounter = 0;
4744 gResourceReadySignalCounter = 0;
4746 // Clear image view for clear test
4750 gImageView1.Reset();
4756 int UtcDaliImageViewSetImageOnResourceReadySignal11(void)
4758 tet_infoline("Test ResourceReady Add AnimatedImageVisual and then Remove immediately.");
4760 ToolkitTestApplication application;
4762 gResourceReadySignalCounter = 0;
4764 // Clear image view for clear test
4768 gImageView1.Reset();
4772 gImageView2.Reset();
4776 gImageView3.Reset();
4781 gImageView1 = ImageView::New();
4782 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, TEST_GIF_FILE_NAME);
4783 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal11);
4784 application.GetScene().Add(gImageView1); // It will call resourceReady signal 1 time.
4786 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4788 DALI_TEST_EQUALS(gResourceReadySignalCounter, 0, TEST_LOCATION);
4790 application.SendNotification();
4791 application.Render();
4794 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4796 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4798 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4800 DALI_TEST_CHECK(true);
4804 // Exception should not happened
4805 DALI_TEST_CHECK(false);
4809 application.SendNotification();
4810 application.Render();
4812 gResourceReadySignalCounter = 0;
4814 // Clear image view for clear test
4818 gImageView1.Reset();
4822 gImageView2.Reset();
4826 gImageView3.Reset();
4832 int UtcDaliImageViewUseSameUrlWithAnimatedImageVisual(void)
4834 tet_infoline("Test multiple views with same image in animated image visual");
4835 ToolkitTestApplication application;
4837 gImageView1 = ImageView::New(TEST_WEBP_FILE_NAME);
4838 application.GetScene().Add(gImageView1);
4840 tet_infoline("Remove imageView and Create new imageView with same url");
4841 application.GetScene().Remove(gImageView1);
4842 gImageView2 = ImageView::New(TEST_WEBP_FILE_NAME);
4843 application.GetScene().Add(gImageView2);
4845 application.SendNotification();
4846 application.Render();
4848 tet_infoline("Check the ImageView load image successfully");
4849 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4853 int UtcDaliImageViewNpatchImageCacheTest01(void)
4855 tet_infoline("Test npatch image cached");
4857 ToolkitTestApplication application;
4858 ImageView imageView[2];
4860 auto& gl = application.GetGlAbstraction();
4861 gl.EnableTextureCallTrace(true);
4862 auto& textureCallStack = gl.GetTextureTrace();
4863 textureCallStack.Enable(true);
4864 textureCallStack.EnableLogging(true);
4866 auto TestNPatch = [&](int index, const std::string& nPatchImageUrl, const char* location) {
4867 if(imageView[index])
4869 imageView[index].Unparent();
4872 // Ensure remove npatch cache if required.
4873 application.SendNotification();
4874 application.Render();
4876 imageView[index] = ImageView::New(nPatchImageUrl);
4877 imageView[index].SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4878 application.GetScene().Add(imageView[index]);
4881 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4882 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4884 application.SendNotification();
4885 application.Render();
4887 tet_printf("trace : \n%s\n", textureCallStack.GetTraceString().c_str());
4889 // Check we gen only 1 textures
4890 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 1, TEST_LOCATION);
4891 textureCallStack.Reset();
4893 // Let we use cached textures
4894 for(int i = 0; i < 10; i++)
4896 TestNPatch(1, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4897 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4900 application.SendNotification();
4901 application.Render();
4902 // Check we use cached npatch data so we don't generate new texture textures
4903 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 0, TEST_LOCATION);
4906 imageView[0].Unparent();
4907 imageView[0].Reset();
4908 imageView[1].Unparent();
4909 imageView[1].Reset();
4911 application.SendNotification();
4912 application.Render();
4914 textureCallStack.Reset();
4915 // Let we use deference textures
4916 TestNPatch(1, TEST_BROKEN_IMAGE_S, TEST_LOCATION);
4917 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4919 application.SendNotification();
4920 application.Render();
4921 // Try to load multiple times.
4922 for(int i = 0; i < 3; i++)
4924 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4925 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4926 TestNPatch(1, TEST_BROKEN_IMAGE_S, TEST_LOCATION);
4927 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4929 application.SendNotification();
4930 application.Render();
4932 imageView[0].Unparent();
4933 imageView[0].Reset();
4934 imageView[1].Unparent();
4935 imageView[1].Reset();
4937 application.SendNotification();
4938 application.Render();
4940 // Check memory leak
4941 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), textureCallStack.CountMethod("DeleteTextures"), TEST_LOCATION);
4946 int UtcDaliImageViewNpatchImageCacheTest02(void)
4948 tet_infoline("Test npatch image cached with border");
4950 ToolkitTestApplication application;
4951 ImageView imageView[2];
4953 auto& gl = application.GetGlAbstraction();
4954 gl.EnableTextureCallTrace(true);
4955 auto& textureCallStack = gl.GetTextureTrace();
4956 textureCallStack.Enable(true);
4957 textureCallStack.EnableLogging(true);
4959 auto TestBorderImage = [&](int index, const std::string& normalImageUrl, const Rect<int> border, const char* location) {
4961 map[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::N_PATCH;
4962 map[Toolkit::ImageVisual::Property::URL] = normalImageUrl;
4963 map[Toolkit::ImageVisual::Property::BORDER] = border;
4965 imageView[index] = ImageView::New();
4966 imageView[index].SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4967 imageView[index].SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4968 application.GetScene().Add(imageView[index]);
4971 TestBorderImage(0, gImage_34_RGBA, Rect<int>(0, 0, 0, 0), TEST_LOCATION);
4972 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4974 application.SendNotification();
4975 application.Render();
4977 tet_printf("trace : \n%s\n", textureCallStack.GetTraceString().c_str());
4979 // Check we gen only 1 textures
4980 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 1, TEST_LOCATION);
4981 textureCallStack.Reset();
4983 // Let we use cached textures
4984 for(int i = 0; i < 10; i++)
4986 TestBorderImage(0, gImage_34_RGBA, Rect<int>(i, i + 1, i + 2, i + 3), TEST_LOCATION);
4987 TestBorderImage(1, gImage_34_RGBA, Rect<int>(i + 1, i, i + 3, i + 2), TEST_LOCATION);
4990 application.SendNotification();
4991 application.Render();
4993 // Check we use cached npatch data so we don't generate new texture textures
4994 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 0, TEST_LOCATION);
4999 int UtcDaliImageViewPlaceholderImage01(void)
5001 tet_infoline("Test imageView use placeholder image");
5003 ToolkitTestApplication application;
5005 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5007 ImageView imageView = ImageView::New();
5008 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5009 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5010 application.GetScene().Add(imageView);
5012 Property::Value value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5014 DALI_TEST_CHECK(value.Get(url));
5015 DALI_TEST_CHECK(url.empty());
5016 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5018 application.SendNotification();
5019 application.Render();
5021 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5022 DALI_TEST_CHECK(value.Get(url));
5023 DALI_TEST_CHECK(url == gImage_34_RGBA);
5025 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5026 application.SendNotification();
5027 application.Render();
5029 // Replace Image test
5030 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5031 map[ImageView::Property::PLACEHOLDER_IMAGE] = gImage_34_RGBA;
5032 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5033 application.SendNotification();
5034 application.Render();
5036 map[Toolkit::ImageVisual::Property::URL] = "";
5037 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5038 application.SendNotification();
5039 application.Render();
5041 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
5042 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5043 application.SendNotification();
5044 application.Render();
5046 // Replace Image test2
5047 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5048 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5049 application.SendNotification();
5050 application.Render();
5052 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
5053 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5054 application.SendNotification();
5055 application.Render();
5057 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5058 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5059 application.SendNotification();
5060 application.Render(900);
5062 map[Toolkit::ImageVisual::Property::URL] = "";
5063 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5064 application.SendNotification();
5065 application.Render();
5067 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5068 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5069 application.SendNotification();
5070 application.Render();
5075 int UtcDaliImageViewPlaceholderImage02(void)
5077 tet_infoline("Test imageView use placeholder image without resource ready");
5079 ToolkitTestApplication application;
5082 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5084 ImageView imageView = ImageView::New();
5085 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5086 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5087 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
5088 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
5089 application.GetScene().Add(imageView);
5091 Property::Value value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5093 DALI_TEST_CHECK(value.Get(url));
5094 DALI_TEST_CHECK(url.empty());
5096 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5097 application.SendNotification();
5098 application.Render();
5100 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5102 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5103 DALI_TEST_CHECK(value.Get(url));
5104 DALI_TEST_CHECK(url == gImage_34_RGBA);
5106 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
5107 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
5109 gResourceReadySignalFired = false;
5110 map[Toolkit::ImageVisual::Property::URL] = "";
5111 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5112 application.SendNotification();
5113 application.Render();
5115 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
5116 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
5121 int UtcDaliImageViewTransitionEffect01(void)
5123 tet_infoline("Test imageView use transition effect");
5125 ToolkitTestApplication application;
5127 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5128 map[Toolkit::Visual::Property::OPACITY] = 0.9f;
5130 ImageView imageView = ImageView::New();
5131 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5132 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5133 application.GetScene().Add(imageView);
5135 Property::Value value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5137 DALI_TEST_CHECK(value.Get(transition));
5138 DALI_TEST_CHECK(transition == false);
5139 imageView.SetProperty(Toolkit::ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
5141 application.SendNotification();
5142 application.Render();
5144 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5145 DALI_TEST_CHECK(value.Get(transition));
5146 DALI_TEST_CHECK(transition == true);
5148 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5149 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5150 application.SendNotification();
5151 application.Render();
5153 // Test transition effect with placeholder
5154 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5155 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5156 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5157 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5158 application.SendNotification();
5159 application.Render();
5161 map[Toolkit::ImageVisual::Property::URL] = "";
5162 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5163 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5164 application.SendNotification();
5165 application.Render();
5167 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5168 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5169 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5170 application.SendNotification();
5171 application.Render();
5173 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5174 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5175 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5176 application.SendNotification();
5178 map[Toolkit::ImageVisual::Property::URL] = "";
5179 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5180 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5181 application.SendNotification();
5182 application.Render();
5184 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5185 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5186 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, "");
5187 application.SendNotification();
5188 application.Render();
5190 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5191 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5192 application.SendNotification();
5193 application.Render();
5195 map[Toolkit::ImageVisual::Property::URL] = "";
5196 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5197 application.SendNotification();
5198 application.Render();
5200 // Test transition effect without placeholder
5201 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5202 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5203 application.SendNotification();
5204 application.Render();
5206 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5207 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5208 application.SendNotification();
5209 application.Render();
5211 map[Toolkit::ImageVisual::Property::URL] = "";
5212 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5213 application.SendNotification();
5214 application.Render();
5216 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5217 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5218 application.SendNotification();
5219 application.Render();
5221 imageView.SetImage(TEST_IMAGE_1);
5222 application.SendNotification();
5223 application.Render();
5225 imageView.SetImage(gImage_600_RGB);
5226 application.SendNotification();
5227 application.Render(9000);
5229 imageView.SetImage("");
5230 application.SendNotification();
5231 application.Render();
5233 imageView.SetImage(TEST_IMAGE_1);
5234 application.SendNotification();
5235 application.Render();
5238 imageView.Unparent();
5244 int UtcDaliImageViewTransitionEffect02(void)
5246 tet_infoline("Test imageView use transition effect with replace image");
5248 ToolkitTestApplication application;
5252 ImageView imageView = ImageView::New();
5253 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5254 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5255 application.GetScene().Add(imageView);
5257 Property::Value value;
5258 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5260 DALI_TEST_CHECK(value.Get(transition));
5261 DALI_TEST_CHECK(transition == false);
5262 imageView.SetProperty(Toolkit::ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
5264 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5266 DALI_TEST_CHECK(value.Get(url));
5267 DALI_TEST_CHECK(url.empty());
5268 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5269 application.SendNotification();
5270 application.Render();
5272 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, "");
5273 application.SendNotification();
5274 application.Render();
5276 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5277 application.SendNotification();
5278 application.Render();
5280 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5281 DALI_TEST_CHECK(value.Get(transition));
5282 DALI_TEST_CHECK(transition == true);
5284 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5285 DALI_TEST_CHECK(value.Get(url));
5286 DALI_TEST_CHECK(url == gImage_34_RGBA);
5288 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5289 application.SendNotification();
5290 application.Render();
5293 imageView.Unparent();
5299 int UtcDaliImageViewTransitionEffect03(void)
5301 tet_infoline("Test imageView use transition effect with placeholder");
5303 ToolkitTestApplication application;
5306 ImageView imageView = ImageView::New();
5307 imageView.SetImage("");
5308 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5309 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5310 imageView.SetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
5311 application.GetScene().Add(imageView);
5313 //DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5315 application.SendNotification();
5316 application.Render(16);
5318 tet_infoline("(1)");
5319 imageView.SetImage(gImage_600_RGB);
5320 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5321 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
5322 application.SendNotification();
5323 application.Render(16);
5325 Property::Value value;
5326 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5328 DALI_TEST_CHECK(value.Get(transition));
5329 DALI_TEST_CHECK(transition == true);
5331 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5333 DALI_TEST_CHECK(value.Get(url));
5334 DALI_TEST_CHECK(url == gImage_34_RGBA);
5336 imageView.SetImage("");
5337 application.SendNotification();
5338 application.Render(16);
5340 imageView.SetImage(TEST_IMAGE_1);
5341 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5342 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5343 application.SendNotification();
5344 application.Render(16);
5347 imageView.Unparent();