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 UtcDaliImageViewEncodedBufferWithInvalidImageType(void)
964 ToolkitTestApplication application;
965 TestGlAbstraction& gl = application.GetGlAbstraction();
966 const std::vector<GLuint>& textures = gl.GetBoundTextures();
967 size_t numTextures = textures.size();
969 // Get encoded raw-buffer jpg image with invalid image type, and generate url
970 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA, static_cast<EncodedImageBuffer::ImageType>(-1));
971 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
973 // Async loading, no atlasing for big size image
974 ImageView imageView = ImageView::New(url.GetUrl());
976 // By default, Aysnc loading is used
977 application.GetScene().Add(imageView);
978 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
979 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
981 application.SendNotification();
982 application.Render(16);
985 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
987 application.SendNotification();
988 application.Render(16);
989 application.SendNotification();
991 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
992 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
994 // Remove visual, for line coverage.
995 imageView.Unparent();
996 application.SendNotification();
997 application.Render(16);
1002 int UtcDaliImageViewAddedTexture(void)
1004 ToolkitTestApplication application;
1006 tet_infoline("ImageView Testing image view with texture provided manager url");
1008 ImageView imageView = ImageView::New();
1010 // empty texture is ok, though pointless from app point of view
1012 std::string url = TextureManager::AddTexture(empty);
1013 DALI_TEST_CHECK(url.size() > 0u);
1015 Property::Map propertyMap;
1016 propertyMap[ImageVisual::Property::URL] = url;
1017 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1019 application.GetScene().Add(imageView);
1020 application.SendNotification();
1021 application.Render();
1026 int UtcDaliImageViewSizeWithBackground(void)
1028 ToolkitTestApplication application;
1032 ImageView imageView = ImageView::New();
1034 imageView.SetProperty(Control::Property::BACKGROUND,
1036 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1037 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1038 {ImageVisual::Property::DESIRED_WIDTH, width},
1039 {ImageVisual::Property::DESIRED_HEIGHT, height},
1042 application.GetScene().Add(imageView);
1043 application.SendNotification();
1044 application.Render();
1046 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
1047 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
1052 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
1054 ToolkitTestApplication application;
1056 int widthBackground = 100;
1057 int heightBackground = 200;
1061 ImageView imageView = ImageView::New();
1063 imageView.SetProperty(Control::Property::BACKGROUND,
1065 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1066 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1067 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1068 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground},
1071 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio, 600x600 pixels
1073 application.GetScene().Add(imageView);
1074 application.SendNotification();
1075 application.Render();
1077 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
1078 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
1083 int UtcDaliImageViewHeightForWidthBackground(void)
1085 ToolkitTestApplication application;
1087 int widthBackground = 100;
1088 int heightBackground = 200;
1090 ImageView imageView = ImageView::New();
1092 imageView.SetProperty(Control::Property::BACKGROUND,
1093 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1094 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1095 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1096 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}});
1098 application.GetScene().Add(imageView);
1099 application.SendNotification();
1100 application.Render();
1102 Control control = Control::DownCast(imageView);
1103 DALI_TEST_CHECK(control);
1104 DALI_TEST_EQUALS(imageView.GetHeightForWidth(123.f), control.GetHeightForWidth(123.f), TEST_LOCATION);
1105 DALI_TEST_EQUALS(imageView.GetWidthForHeight(321.f), control.GetWidthForHeight(321.f), TEST_LOCATION);
1110 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
1112 ToolkitTestApplication application;
1114 int widthBackground = 100;
1115 int heightBackground = 200;
1119 ImageView imageView = ImageView::New();
1121 imageView.SetProperty(Control::Property::BACKGROUND,
1122 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1123 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1124 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
1125 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}}); // 1 to 2 ratio
1127 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio
1129 application.GetScene().Add(imageView);
1130 application.SendNotification();
1131 application.Render();
1133 DALI_TEST_EQUALS(imageView.GetHeightForWidth(width), (float)height, TEST_LOCATION);
1134 DALI_TEST_EQUALS(imageView.GetWidthForHeight(height), (float)width, TEST_LOCATION);
1139 int UtcDaliImageViewSetImageUrl(void)
1141 ToolkitTestApplication application;
1143 ImageView imageView = ImageView::New();
1144 imageView.SetImage(TEST_IMAGE_FILE_NAME);
1145 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
1147 imageView.SetImage(TEST_IMAGE_FILE_NAME2);
1148 TestUrl(imageView, TEST_IMAGE_FILE_NAME2);
1153 bool gResourceReadySignalFired = false;
1154 Vector3 gNaturalSize;
1156 void ResourceReadySignal(Control control)
1158 gResourceReadySignalFired = true;
1161 void OnResourceReadySignalSVG(Control control)
1163 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1164 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(control);
1165 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1166 Property::Map resultMap;
1167 imageVisual.CreatePropertyMap(resultMap);
1169 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1170 DALI_TEST_CHECK(transformValue);
1171 Property::Map* retMap = transformValue->GetMap();
1172 DALI_TEST_CHECK(retMap);
1174 // Fitting mode should not be applied at this point
1175 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::SIZE)->Get<Vector2>(), Vector2::ZERO, TEST_LOCATION);
1178 int UtcDaliImageViewCheckResourceReady(void)
1180 ToolkitTestApplication application;
1182 gResourceReadySignalFired = false;
1184 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1185 ImageView imageView = ImageView::New(TEST_GIF_FILE_NAME);
1187 imageView.SetProperty(Control::Property::BACKGROUND,
1188 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1189 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1190 {ImageVisual::Property::DESIRED_WIDTH, 100},
1191 {ImageVisual::Property::DESIRED_HEIGHT, 200}});
1193 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1195 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1197 application.GetScene().Add(imageView);
1199 // loading started, this waits for the loader thread
1200 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1202 application.SendNotification();
1203 application.Render(16);
1205 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1207 application.SendNotification();
1208 application.Render();
1210 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1212 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1217 int UtcDaliImageViewSetImageTypeChangesP(void)
1219 ToolkitTestApplication application;
1221 ImageView imageView = ImageView::New();
1222 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1224 application.GetScene().Add(imageView);
1228 Toolkit::Visual::Base visual;
1230 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1231 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1233 application.SendNotification();
1234 application.Render(16);
1236 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1238 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1239 DALI_TEST_CHECK(!visual); // Visual should be invalid
1242 imageView.SetImage("TEST_URL");
1244 application.SendNotification();
1245 application.Render(16);
1247 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1248 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1250 DALI_TEST_CHECK(value.Get(url)); // Value should NOT be empty
1251 DALI_TEST_CHECK(!value.Get(map)); // Value should be empty
1252 DALI_TEST_CHECK(visual); // Visual should be valid
1255 imageView.SetImage("");
1257 application.SendNotification();
1258 application.Render(16);
1260 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1261 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1263 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1265 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1266 DALI_TEST_CHECK(!visual); // Visual should be invalid
1268 // Set a URL in property map
1269 Property::Map propertyMap;
1270 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1271 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1273 application.SendNotification();
1274 application.Render(16);
1276 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1277 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1279 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1280 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1281 DALI_TEST_CHECK(visual); // Visual should be valid
1283 // Set a URL in property map again
1284 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1285 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1287 application.SendNotification();
1288 application.Render(16);
1290 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1291 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1293 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1294 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1295 DALI_TEST_CHECK(visual); // Visual should be valid
1297 // Set an empty URL in property map
1298 propertyMap[ImageVisual::Property::URL] = std::string();
1299 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1301 application.SendNotification();
1302 application.Render(16);
1304 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1305 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1307 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1308 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1309 DALI_TEST_CHECK(!visual); // Visual should be invalid
1311 // Set a URL in property map again
1312 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1313 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1315 application.SendNotification();
1316 application.Render(16);
1318 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1319 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1321 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1322 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1323 DALI_TEST_CHECK(visual); // Visual should be valid
1325 // Set an empty property map
1326 propertyMap.Clear();
1327 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1329 application.SendNotification();
1330 application.Render(16);
1332 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1333 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1335 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1336 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1337 DALI_TEST_CHECK(map.Empty()); // But PropertyMap should be empty
1338 DALI_TEST_CHECK(!visual); // Visual should be invalid
1343 int UtcDaliImageViewResourceUrlP(void)
1345 ToolkitTestApplication application;
1347 ImageView imageView = ImageView::New();
1348 DALI_TEST_CHECK(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>().empty());
1350 imageView.SetProperty(ImageView::Property::IMAGE, "TestString");
1351 DALI_TEST_EQUALS(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>(), "TestString", TEST_LOCATION);
1356 int UtcDaliImageViewReplaceImage(void)
1358 ToolkitTestApplication application;
1360 gResourceReadySignalFired = false;
1362 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1363 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1365 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1367 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1369 application.GetScene().Add(imageView);
1371 application.SendNotification();
1372 application.Render(16);
1374 // loading started, this waits for the loader thread for max 30 seconds
1375 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1377 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1379 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1381 gResourceReadySignalFired = false;
1383 imageView.SetImage(TEST_IMAGE_2);
1385 application.SendNotification();
1386 application.Render(16);
1388 // loading started, this waits for the loader thread for max 30 seconds
1389 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1391 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1393 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1395 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1400 int UtcDaliImageViewReloadAlphaMaskImage(void)
1402 ToolkitTestApplication application;
1404 gResourceReadySignalFired = false;
1406 ImageView dummy = ImageView::New();
1407 ImageView imageView = ImageView::New();
1408 Property::Map propertyMap;
1410 // To keep alpha mask cached, scene on some dummy image.
1411 // Note : If we don't cache alpha mask image, the reference count of mask image become zero.
1412 // In this case, we might need to wait mask image loading, which is not neccesary & can be changed behavior.
1413 propertyMap[ImageVisual::Property::URL] = gImage_600_RGB;
1414 propertyMap[ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
1415 dummy.SetProperty(ImageView::Property::IMAGE, propertyMap);
1417 application.GetScene().Add(dummy);
1419 application.SendNotification();
1420 application.Render(16);
1422 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1424 application.SendNotification();
1425 application.Render(16);
1427 propertyMap.Clear();
1428 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1429 propertyMap[ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
1430 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1432 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1434 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1436 application.GetScene().Add(imageView);
1438 application.SendNotification();
1439 application.Render(16);
1441 // Load image and use cached mask. Now we try to apply masking.
1442 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1444 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
1446 // Cancel apply masking.
1447 imageView.Unparent();
1449 application.SendNotification();
1450 application.Render(16);
1452 // Reload same image again.
1453 application.GetScene().Add(imageView);
1455 application.SendNotification();
1456 application.Render(16);
1458 // Finish apply masking.
1459 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1461 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1462 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1463 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1468 void OnRelayoutOverride(Size size)
1470 gNaturalSize = size; // Size Relayout is using
1473 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1475 ToolkitTestApplication application;
1477 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1478 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1479 imageView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1481 DummyControl dummyControl = DummyControl::New(true);
1482 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1483 dummyControl.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
1485 dummyControl.Add(imageView);
1486 dummyImpl.SetRelayoutCallback(&OnRelayoutOverride);
1487 application.GetScene().Add(dummyControl);
1489 application.SendNotification();
1490 application.Render();
1492 // loading started, this waits for the loader thread for max 30 seconds
1493 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1495 DALI_TEST_EQUALS(gNaturalSize.width, 1024.0f, TEST_LOCATION);
1496 DALI_TEST_EQUALS(gNaturalSize.height, 1024.0f, TEST_LOCATION);
1498 gNaturalSize = Vector3::ZERO;
1500 imageView.SetImage(gImage_600_RGB);
1502 // Waiting for resourceReady so SendNotifcation not called here.
1504 // loading started, this waits for the loader thread for max 30 seconds
1505 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1507 // Trigger a potential relayout
1508 application.SendNotification();
1509 application.Render();
1511 DALI_TEST_EQUALS(gNaturalSize.width, 600.0f, TEST_LOCATION);
1512 DALI_TEST_EQUALS(gNaturalSize.height, 600.0f, TEST_LOCATION);
1517 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1519 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1521 ToolkitTestApplication application;
1523 gResourceReadySignalFired = false;
1525 Property::Map imageMap;
1527 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1528 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1530 tet_infoline("Creating ImageView without URL so image does not start loading");
1531 ImageView imageView = ImageView::New();
1532 tet_infoline("Connect to image loaded signal before setting image");
1533 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1534 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1535 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1537 // loading started, this waits for the loader thread
1538 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1540 application.SendNotification();
1541 application.Render(16);
1543 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1548 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1550 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1552 ToolkitTestApplication application;
1554 gResourceReadySignalFired = false;
1556 Property::Map imageMap;
1558 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1559 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1561 ImageView imageView = ImageView::New();
1562 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1563 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1565 // loading started, this waits for the loader thread
1566 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1568 application.SendNotification();
1569 application.Render(16);
1571 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1572 gResourceReadySignalFired = false;
1574 ImageView imageViewWithExistingImage = ImageView::New();
1575 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1576 imageViewWithExistingImage.SetProperty(ImageView::Property::IMAGE, imageMap);
1578 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1583 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1585 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1587 ToolkitTestApplication application;
1589 gResourceReadySignalFired = false;
1591 Property::Map imageImmediateLoadingMap;
1592 imageImmediateLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1593 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1595 tet_infoline("Immediate load an image");
1596 ImageView imageView = ImageView::New();
1597 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1598 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
1600 // loading started, this waits for the loader thread
1601 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1603 application.SendNotification();
1604 application.Render(16);
1606 tet_infoline("Check image loaded");
1607 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1608 gResourceReadySignalFired = false;
1610 tet_infoline("Create another ImageView with the same URL");
1611 ImageView imageViewWithExistingImage = ImageView::New(gImage_34_RGBA);
1612 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1613 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1615 application.GetScene().Add(imageViewWithExistingImage);
1617 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1622 int UtcDaliImageViewPaddingProperty(void)
1624 ToolkitTestApplication application;
1626 ImageView imageView = ImageView::New();
1627 Property::Map imagePropertyMap;
1628 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1629 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
1630 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1631 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1632 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1633 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1634 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1635 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1636 application.GetScene().Add(imageView);
1638 application.SendNotification();
1639 application.Render();
1641 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1643 ImageView childImage = ImageView::New();
1644 childImage.SetBackgroundColor(Color::BLACK);
1645 childImage.SetProperty(Actor::Property::SIZE, Vector2(10.f, 10.f));
1646 imageView.Add(childImage);
1648 application.SendNotification();
1649 application.Render();
1651 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1652 DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
1654 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1655 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1656 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1657 Property::Map resultMap;
1658 imageVisual.CreatePropertyMap(resultMap);
1660 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1661 DALI_TEST_CHECK(transformValue);
1662 Property::Map* retMap = transformValue->GetMap();
1663 DALI_TEST_CHECK(retMap);
1665 // Image Visual should be positioned depending on ImageView's padding
1666 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1671 int UtcDaliImageViewPaddingProperty02(void)
1673 ToolkitTestApplication application;
1675 ImageView imageView = ImageView::New();
1676 Property::Map imagePropertyMap;
1677 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1678 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1679 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1680 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1681 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1682 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1683 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1684 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1685 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1686 application.GetScene().Add(imageView);
1688 application.SendNotification();
1689 application.Render();
1691 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1693 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1694 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1695 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1696 Property::Map resultMap;
1697 imageVisual.CreatePropertyMap(resultMap);
1699 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1700 DALI_TEST_CHECK(transformValue);
1701 Property::Map* retMap = transformValue->GetMap();
1702 DALI_TEST_CHECK(retMap);
1704 // Image Visual should be positioned depending on ImageView's padding
1705 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1710 int UtcDaliImageViewPaddingProperty03(void)
1712 tet_infoline("Test Setting Image Padding then removing it.");
1714 ToolkitTestApplication application;
1716 ImageView imageView = ImageView::New();
1717 Property::Map imagePropertyMap;
1718 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1719 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1720 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1721 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1722 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1723 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1724 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1725 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1726 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1727 application.GetScene().Add(imageView);
1729 application.SendNotification();
1730 application.Render();
1732 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1734 tet_infoline("Remove Padding and test Visual is position correctly");
1736 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1738 application.SendNotification();
1739 application.Render();
1741 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1742 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1743 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1744 Property::Map resultMap;
1745 imageVisual.CreatePropertyMap(resultMap);
1747 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1748 DALI_TEST_CHECK(transformValue);
1749 Property::Map* retMap = transformValue->GetMap();
1750 DALI_TEST_CHECK(retMap);
1752 // Image Visual should be positioned depending on ImageView's padding
1753 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1758 int UtcDaliImageViewPaddingProperty04(void)
1760 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1762 ToolkitTestApplication application;
1764 ImageView imageView = ImageView::New();
1765 Property::Map imagePropertyMap;
1766 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1767 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1768 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1769 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1770 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FILL;
1771 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1772 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1773 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1774 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1775 application.GetScene().Add(imageView);
1777 application.SendNotification();
1778 application.Render();
1780 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1782 tet_infoline("Remove Padding and test Visual is position correctly");
1784 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1786 application.SendNotification();
1787 application.Render();
1789 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1790 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1791 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1792 Property::Map resultMap;
1793 imageVisual.CreatePropertyMap(resultMap);
1795 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1796 DALI_TEST_CHECK(transformValue);
1797 Property::Map* retMap = transformValue->GetMap();
1798 DALI_TEST_CHECK(retMap);
1800 // Image Visual should be positioned depending on ImageView's padding
1801 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1806 int UtcDaliImageViewTransformTest01(void)
1808 tet_infoline("Test Setting a offset transform on the ImageView");
1810 ToolkitTestApplication application;
1812 ImageView imageView = ImageView::New();
1813 Property::Map imagePropertyMap;
1814 imagePropertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE)
1815 .Add(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/Kid1.svg")
1816 .Add(ImageVisual::Property::DESIRED_WIDTH, 120)
1817 .Add(ImageVisual::Property::DESIRED_HEIGHT, 120)
1818 .Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL)
1819 .Add(Visual::Property::TRANSFORM,
1820 Property::Map().Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1821 Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE))
1822 .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(8, 8)));
1824 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1825 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1826 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1827 application.GetScene().Add(imageView);
1829 application.SendNotification();
1830 application.Render();
1832 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1833 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1834 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1835 Property::Map resultMap;
1836 imageVisual.CreatePropertyMap(resultMap);
1838 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1839 DALI_TEST_CHECK(transformValue);
1840 Property::Map* retMap = transformValue->GetMap();
1841 DALI_TEST_CHECK(retMap);
1843 // Image Visual should be positioned depending on ImageView's padding
1844 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(8, 8), TEST_LOCATION);
1845 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);
1850 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1852 ToolkitTestApplication application;
1854 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1855 ImageView imageView = ImageView::New();
1856 Property::Map imageMap;
1857 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1858 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_34_RGBA;
1859 imageMap[Toolkit::ImageVisual::Property::ATLASING] = true;
1860 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1861 application.GetScene().Add(imageView);
1863 // Trigger a potential relayout
1864 application.SendNotification();
1865 application.Render();
1867 Vector3 naturalSize = imageView.GetNaturalSize();
1869 DALI_TEST_EQUALS(naturalSize.width, 34.0f, TEST_LOCATION);
1870 DALI_TEST_EQUALS(naturalSize.height, 34.0f, TEST_LOCATION);
1875 int UtcDaliImageViewFillMode(void)
1877 ToolkitTestApplication application;
1879 tet_infoline("Create an ImageVisual without padding and set the fill-mode to fill");
1881 ImageView imageView = ImageView::New();
1882 Property::Map imageMap;
1883 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1884 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB);
1885 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL);
1887 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1889 application.GetScene().Add(imageView);
1891 // Trigger a potential relayout
1892 application.SendNotification();
1893 application.Render();
1895 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1896 Property::Map returnedMap;
1897 visual.CreatePropertyMap(returnedMap);
1899 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1900 DALI_TEST_CHECK(value);
1901 Property::Map* map = value->GetMap();
1902 DALI_TEST_CHECK(map);
1904 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1905 DALI_TEST_CHECK(value);
1906 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION);
1908 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1909 DALI_TEST_CHECK(value);
1910 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1915 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1917 ToolkitTestApplication application;
1919 tet_infoline("Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )");
1920 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1922 ImageView imageView = ImageView::New();
1923 Property::Map imageMap;
1924 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1925 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1926 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
1928 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1929 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1931 application.GetScene().Add(imageView);
1933 // Trigger a potential relayout
1934 application.SendNotification();
1935 application.Render();
1937 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1938 Property::Map returnedMap;
1939 visual.CreatePropertyMap(returnedMap);
1941 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1942 DALI_TEST_CHECK(value);
1943 Property::Map* map = value->GetMap();
1944 DALI_TEST_CHECK(map);
1947 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1948 DALI_TEST_CHECK(value);
1949 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION);
1951 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1952 DALI_TEST_CHECK(value);
1953 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1955 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1956 DALI_TEST_CHECK(value);
1957 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
1962 int UtcDaliImageViewFittingModesFill(void)
1964 ToolkitTestApplication application;
1966 tet_infoline("Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )");
1967 tet_infoline(" There should be no need to change the transform, only size is changed to fit view");
1969 ImageView imageView = ImageView::New();
1970 Property::Map imageMap;
1971 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1972 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1973 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL);
1975 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1976 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1978 application.GetScene().Add(imageView);
1980 // Trigger a potential relayout
1981 application.SendNotification();
1982 application.Render();
1984 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1985 Property::Map returnedMap;
1986 visual.CreatePropertyMap(returnedMap);
1988 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1989 DALI_TEST_CHECK(value);
1990 Property::Map* map = value->GetMap();
1991 DALI_TEST_CHECK(map);
1993 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1994 DALI_TEST_CHECK(value);
1995 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Change the internal size according to the image view size
1997 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1998 DALI_TEST_CHECK(value);
1999 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2001 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2002 DALI_TEST_CHECK(value);
2003 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2008 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
2010 ToolkitTestApplication application;
2012 tet_infoline("Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )");
2013 tet_infoline(" offset or size is the same as view, but adjust internally using pixelArea ");
2015 ImageView imageView = ImageView::New();
2016 Property::Map imageMap;
2017 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2018 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2019 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO);
2021 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2022 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 500));
2024 application.GetScene().Add(imageView);
2026 // Trigger a potential relayout
2027 application.SendNotification();
2028 application.Render();
2030 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2031 Property::Map returnedMap;
2032 visual.CreatePropertyMap(returnedMap);
2034 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2035 DALI_TEST_CHECK(value);
2036 Property::Map* map = value->GetMap();
2037 DALI_TEST_CHECK(map);
2040 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2041 DALI_TEST_CHECK(value);
2042 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 500), TEST_LOCATION); // Change the internal size according to the image view size
2044 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2045 DALI_TEST_CHECK(value);
2046 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2048 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2049 DALI_TEST_CHECK(value);
2050 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2055 int UtcDaliImageViewFittingModesCenter01(void)
2057 ToolkitTestApplication application;
2059 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [700,700] )");
2060 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
2062 ImageView imageView = ImageView::New();
2063 Property::Map imageMap;
2064 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2065 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2066 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
2068 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2069 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
2071 application.GetScene().Add(imageView);
2073 // Trigger a potential relayout
2074 application.SendNotification();
2075 application.Render();
2077 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2078 Property::Map returnedMap;
2079 visual.CreatePropertyMap(returnedMap);
2081 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2082 DALI_TEST_CHECK(value);
2083 Property::Map* map = value->GetMap();
2084 DALI_TEST_CHECK(map);
2086 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2087 DALI_TEST_CHECK(value);
2088 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2090 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2091 DALI_TEST_CHECK(value);
2092 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2094 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2095 DALI_TEST_CHECK(value);
2096 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
2101 int UtcDaliImageViewFittingModesCenter02(void)
2103 ToolkitTestApplication application;
2105 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [500,500] )");
2106 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
2108 ImageView imageView = ImageView::New();
2109 Property::Map imageMap;
2110 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2111 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2112 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
2114 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2115 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
2117 application.GetScene().Add(imageView);
2119 // Trigger a potential relayout
2120 application.SendNotification();
2121 application.Render();
2123 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2124 Property::Map returnedMap;
2125 visual.CreatePropertyMap(returnedMap);
2127 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2128 DALI_TEST_CHECK(value);
2129 Property::Map* map = value->GetMap();
2130 DALI_TEST_CHECK(map);
2132 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2133 DALI_TEST_CHECK(value);
2134 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2136 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2137 DALI_TEST_CHECK(value);
2138 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2140 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2141 DALI_TEST_CHECK(value);
2142 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
2147 int UtcDaliImageViewFittingModesFitHeight01(void)
2149 ToolkitTestApplication application;
2151 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )");
2153 ImageView imageView = ImageView::New();
2154 Property::Map imageMap;
2155 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2156 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2157 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2159 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2160 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2162 application.GetScene().Add(imageView);
2164 // Trigger a potential relayout
2165 application.SendNotification();
2166 application.Render();
2168 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2169 Property::Map returnedMap;
2170 visual.CreatePropertyMap(returnedMap);
2172 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2173 DALI_TEST_CHECK(value);
2174 Property::Map* map = value->GetMap();
2175 DALI_TEST_CHECK(map);
2177 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2178 DALI_TEST_CHECK(value);
2179 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 700), TEST_LOCATION); // Change the internal size according to the image view size
2181 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2182 DALI_TEST_CHECK(value);
2183 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2185 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2186 DALI_TEST_CHECK(value);
2187 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2192 int UtcDaliImageViewFittingModesFitHeight02(void)
2194 ToolkitTestApplication application;
2196 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )");
2198 ImageView imageView = ImageView::New();
2199 Property::Map imageMap;
2200 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2201 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2202 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
2204 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2205 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2207 application.GetScene().Add(imageView);
2209 // Trigger a potential relayout
2210 application.SendNotification();
2211 application.Render();
2213 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2214 Property::Map returnedMap;
2215 visual.CreatePropertyMap(returnedMap);
2217 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2218 DALI_TEST_CHECK(value);
2219 Property::Map* map = value->GetMap();
2220 DALI_TEST_CHECK(map);
2222 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2223 DALI_TEST_CHECK(value);
2224 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2226 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2227 DALI_TEST_CHECK(value);
2228 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2230 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2231 DALI_TEST_CHECK(value);
2232 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2237 int UtcDaliImageViewFittingModesFitWidth01(void)
2239 ToolkitTestApplication application;
2241 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )");
2243 ImageView imageView = ImageView::New();
2244 Property::Map imageMap;
2245 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2246 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2247 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2249 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2250 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2252 application.GetScene().Add(imageView);
2254 // Trigger a potential relayout
2255 application.SendNotification();
2256 application.Render();
2258 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2259 Property::Map returnedMap;
2260 visual.CreatePropertyMap(returnedMap);
2262 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2263 DALI_TEST_CHECK(value);
2264 Property::Map* map = value->GetMap();
2265 DALI_TEST_CHECK(map);
2267 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2268 DALI_TEST_CHECK(value);
2269 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2271 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2272 DALI_TEST_CHECK(value);
2273 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2275 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2276 DALI_TEST_CHECK(value);
2277 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
2282 int UtcDaliImageViewFittingModesFitWidth02(void)
2284 ToolkitTestApplication application;
2286 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )");
2288 ImageView imageView = ImageView::New();
2289 Property::Map imageMap;
2290 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2291 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2292 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2294 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2295 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2297 application.GetScene().Add(imageView);
2299 // Trigger a potential relayout
2300 application.SendNotification();
2301 application.Render();
2303 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2304 Property::Map returnedMap;
2305 visual.CreatePropertyMap(returnedMap);
2307 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2308 DALI_TEST_CHECK(value);
2309 Property::Map* map = value->GetMap();
2310 DALI_TEST_CHECK(map);
2312 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2313 DALI_TEST_CHECK(value);
2314 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 600), TEST_LOCATION); // Change the internal size according to the image view size
2316 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2317 DALI_TEST_CHECK(value);
2318 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2320 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2321 DALI_TEST_CHECK(value);
2322 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2327 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2329 ToolkitTestApplication application;
2331 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2333 ImageView imageView = ImageView::New();
2335 // 1. Render using FittingMode::SHRINK_TO_FIT
2336 Property::Map imageMap;
2337 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2338 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2339 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2341 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2342 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2344 application.GetScene().Add(imageView);
2346 // Trigger a potential relayout
2347 application.SendNotification();
2348 application.Render();
2350 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2351 Property::Map returnedMap;
2352 visual.CreatePropertyMap(returnedMap);
2354 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2355 DALI_TEST_CHECK(value);
2356 Property::Map* map = value->GetMap();
2357 DALI_TEST_CHECK(map);
2359 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2360 DALI_TEST_CHECK(value);
2361 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2363 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2364 DALI_TEST_CHECK(value);
2365 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2367 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2368 DALI_TEST_CHECK(value);
2369 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2371 // 2. Render again using DevelVisaul::CENTER
2372 Property::Map imageMap2;
2373 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2374 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2375 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2377 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2378 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2380 application.GetScene().Add(imageView);
2382 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2384 // Trigger a potential relayout
2385 application.SendNotification();
2386 application.Render();
2388 returnedMap.Clear();
2389 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2391 visual.CreatePropertyMap(returnedMap);
2393 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2394 DALI_TEST_CHECK(value);
2395 map = value->GetMap();
2396 DALI_TEST_CHECK(map);
2398 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2399 DALI_TEST_CHECK(value);
2400 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2402 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2403 DALI_TEST_CHECK(value);
2404 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2406 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2407 DALI_TEST_CHECK(value);
2408 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2410 // 3. Render again using before fittingMode
2411 Property::Map imageMap3;
2412 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2413 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2414 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2416 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2417 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2419 application.GetScene().Add(imageView);
2421 // Trigger a potential relayout
2422 application.SendNotification();
2423 application.Render();
2425 returnedMap.Clear();
2426 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2427 visual.CreatePropertyMap(returnedMap);
2429 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2430 DALI_TEST_CHECK(value);
2431 map = value->GetMap();
2432 DALI_TEST_CHECK(map);
2434 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2435 DALI_TEST_CHECK(value);
2436 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2438 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2439 DALI_TEST_CHECK(value);
2440 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2442 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2443 DALI_TEST_CHECK(value);
2444 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2449 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2451 ToolkitTestApplication application;
2453 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2455 ImageView imageView = ImageView::New();
2457 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2458 Property::Map imageMap;
2459 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2460 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2461 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2463 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2464 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2466 application.GetScene().Add(imageView);
2468 // Trigger a potential relayout
2469 application.SendNotification();
2470 application.Render();
2472 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2473 Property::Map returnedMap;
2474 visual.CreatePropertyMap(returnedMap);
2476 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2477 DALI_TEST_CHECK(value);
2478 Property::Map* map = value->GetMap();
2479 DALI_TEST_CHECK(map);
2481 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2482 DALI_TEST_CHECK(value);
2483 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2485 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2486 DALI_TEST_CHECK(value);
2487 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2489 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2490 DALI_TEST_CHECK(value);
2491 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2493 // 2. Render again using DevelVisaul::CENTER
2494 Property::Map imageMap2;
2495 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2496 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2497 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2499 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2500 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2502 application.GetScene().Add(imageView);
2504 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2506 // Trigger a potential relayout
2507 application.SendNotification();
2508 application.Render();
2510 returnedMap.Clear();
2511 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2513 visual.CreatePropertyMap(returnedMap);
2515 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2516 DALI_TEST_CHECK(value);
2517 map = value->GetMap();
2518 DALI_TEST_CHECK(map);
2520 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2521 DALI_TEST_CHECK(value);
2522 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2524 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2525 DALI_TEST_CHECK(value);
2526 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2528 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2529 DALI_TEST_CHECK(value);
2530 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2532 // 3. Render again using before fittingMode
2533 Property::Map imageMap3;
2534 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2535 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2536 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2538 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2539 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2541 application.GetScene().Add(imageView);
2543 // Trigger a potential relayout
2544 application.SendNotification();
2545 application.Render();
2547 returnedMap.Clear();
2548 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2549 visual.CreatePropertyMap(returnedMap);
2551 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2552 DALI_TEST_CHECK(value);
2553 map = value->GetMap();
2554 DALI_TEST_CHECK(map);
2556 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2557 DALI_TEST_CHECK(value);
2558 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2560 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2561 DALI_TEST_CHECK(value);
2562 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2564 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2565 DALI_TEST_CHECK(value);
2566 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2571 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2573 ToolkitTestApplication application;
2575 tet_infoline("Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )");
2577 ImageView imageView = ImageView::New();
2578 Property::Map imageMap;
2579 imageMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE);
2580 imageMap.Add(Toolkit::ImageVisual::Property::URL, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME); // 249x169 image
2582 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2583 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
2585 application.GetScene().Add(imageView);
2587 // Trigger a potential relayout
2588 application.SendNotification();
2589 application.Render();
2591 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2592 Property::Map returnedMap;
2593 visual.CreatePropertyMap(returnedMap);
2595 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2596 DALI_TEST_CHECK(value);
2597 Property::Map* map = value->GetMap();
2598 DALI_TEST_CHECK(map);
2600 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2601 DALI_TEST_CHECK(value);
2602 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Relative size so will take up 100%
2604 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2605 DALI_TEST_CHECK(value);
2606 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2608 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2609 DALI_TEST_CHECK(value);
2610 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2615 int UtcDaliImageViewCustomShader(void)
2617 ToolkitTestApplication application;
2619 // Set a custom shader with an image url
2621 Property::Map properties;
2622 Property::Map shader;
2623 const std::string vertexShader = "Foobar";
2624 const std::string fragmentShader = "Foobar";
2625 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2626 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2628 properties[Visual::Property::TYPE] = Visual::IMAGE;
2629 properties[Visual::Property::SHADER] = shader;
2630 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2632 ImageView imageView = ImageView::New();
2633 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2635 application.GetScene().Add(imageView);
2637 application.SendNotification();
2638 application.Render();
2640 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2642 Renderer renderer = imageView.GetRendererAt(0);
2643 Shader shader2 = renderer.GetShader();
2644 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2645 Property::Map* map = value.GetMap();
2646 DALI_TEST_CHECK(map);
2648 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2649 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2651 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2652 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2655 // Set a custom shader after setting an image url
2657 Property::Map properties;
2658 Property::Map shader;
2659 const std::string vertexShader = "Foobar";
2660 const std::string fragmentShader = "Foobar";
2661 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2662 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2664 properties[Visual::Property::SHADER] = shader;
2666 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
2667 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2669 application.GetScene().Add(imageView);
2671 application.SendNotification();
2672 application.Render();
2674 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2676 Renderer renderer = imageView.GetRendererAt(0);
2677 Shader shader2 = renderer.GetShader();
2678 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2679 Property::Map* map = value.GetMap();
2680 DALI_TEST_CHECK(map);
2682 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2683 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2685 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2686 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2689 // Set a custom shader before setting an image url
2691 Property::Map properties;
2692 Property::Map shader;
2693 const std::string vertexShader = "Foobar";
2694 const std::string fragmentShader = "Foobar";
2695 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2696 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2698 properties[Visual::Property::SHADER] = shader;
2700 ImageView imageView = ImageView::New();
2701 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2702 imageView.SetProperty(ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME);
2704 application.GetScene().Add(imageView);
2706 application.SendNotification();
2707 application.Render();
2708 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2710 Renderer renderer = imageView.GetRendererAt(0);
2711 Shader shader2 = renderer.GetShader();
2712 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2713 Property::Map* map = value.GetMap();
2714 DALI_TEST_CHECK(map);
2716 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2717 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2719 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2720 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2723 // Set a custom shader after setting a property map
2725 Property::Map properties;
2726 Property::Map shader;
2727 const std::string vertexShader = "Foobar";
2728 const std::string fragmentShader = "Foobar";
2729 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2730 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2732 properties[Visual::Property::SHADER] = shader;
2734 Property::Map properties1;
2735 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2736 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2738 ImageView imageView = ImageView::New();
2739 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2740 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2742 application.GetScene().Add(imageView);
2744 application.SendNotification();
2745 application.Render();
2746 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2748 Renderer renderer = imageView.GetRendererAt(0);
2749 Shader shader2 = renderer.GetShader();
2750 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2751 Property::Map* map = value.GetMap();
2752 DALI_TEST_CHECK(map);
2754 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2755 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2757 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2758 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2761 // Set a custom shader before setting a property map
2763 Property::Map properties;
2764 Property::Map shader;
2765 const std::string vertexShader = "Foobar";
2766 const std::string fragmentShader = "Foobar";
2767 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2768 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2770 properties[Visual::Property::SHADER] = shader;
2772 Property::Map properties1;
2773 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2774 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2776 ImageView imageView = ImageView::New();
2777 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2778 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2780 application.GetScene().Add(imageView);
2782 application.SendNotification();
2783 application.Render();
2784 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2786 Renderer renderer = imageView.GetRendererAt(0);
2787 Shader shader2 = renderer.GetShader();
2788 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2789 Property::Map* map = value.GetMap();
2790 DALI_TEST_CHECK(map);
2792 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2793 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2795 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2796 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2804 static int gFailCounter = 0;
2805 const int MAX_RETRIES(3);
2807 void ReloadImage(ImageView imageView)
2809 Property::Map imageImmediateLoadingMap;
2810 imageImmediateLoadingMap[ImageVisual::Property::URL] = "Non-existant-image.jpg";
2811 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
2813 tet_infoline("Immediate load an image");
2814 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
2817 void ResourceFailedReload(Control control)
2823 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2825 tet_infoline("Test reloading failed image from within signal handler.");
2827 ToolkitTestApplication application;
2831 ImageView imageView = ImageView::New();
2832 imageView.ResourceReadySignal().Connect(&ResourceFailedReload);
2833 DALI_TEST_EQUALS(gFailCounter, 0, TEST_LOCATION);
2834 ReloadImage(imageView);
2836 // loading started, this waits for the loader thread to complete
2837 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2838 DALI_TEST_EQUALS(gFailCounter, 1, TEST_LOCATION);
2840 ReloadImage(imageView);
2841 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2842 DALI_TEST_EQUALS(gFailCounter, 2, TEST_LOCATION);
2844 ReloadImage(imageView);
2845 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2846 DALI_TEST_EQUALS(gFailCounter, 3, TEST_LOCATION);
2851 int UtcDaliImageViewLoadRemoteSVG(void)
2853 tet_infoline("Test load from a remote server.");
2855 ToolkitTestApplication application;
2858 Toolkit::ImageView imageView;
2859 imageView = Toolkit::ImageView::New();
2860 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2861 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2862 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2863 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2864 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2866 application.GetScene().Add(imageView);
2868 DALI_TEST_CHECK(imageView);
2870 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2872 application.SendNotification();
2874 // Wait for loading & rasterization
2875 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2877 application.SendNotification();
2878 application.Render();
2880 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2885 Toolkit::ImageView imageView;
2886 imageView = Toolkit::ImageView::New();
2887 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2888 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2889 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2890 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2892 application.GetScene().Add(imageView);
2894 DALI_TEST_CHECK(imageView);
2896 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2898 application.SendNotification();
2900 // Wait for loading & rasterization
2901 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2903 application.SendNotification();
2904 application.Render();
2906 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2912 int UtcDaliImageViewLoadRemoteLottie(void)
2914 tet_infoline("Test load from a remote server. (Note we don't support real download now. Just for line coverage)");
2916 ToolkitTestApplication application;
2919 Toolkit::ImageView imageView;
2920 imageView = Toolkit::ImageView::New();
2921 imageView.SetImage("https://lottie.json");
2922 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2923 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2924 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2925 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2927 application.GetScene().Add(imageView);
2929 DALI_TEST_CHECK(imageView);
2931 application.SendNotification();
2932 application.Render();
2934 // Do not check anything for here.
2940 int UtcDaliImageViewSyncSVGLoading(void)
2942 ToolkitTestApplication application;
2944 tet_infoline("ImageView Testing SVG image sync loading");
2947 ImageView imageView = ImageView::New();
2949 // Sync loading is used
2950 Property::Map syncLoadingMap;
2951 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2952 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2953 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2954 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2956 application.GetScene().Add(imageView);
2957 DALI_TEST_CHECK(imageView);
2959 application.SendNotification();
2960 Vector3 naturalSize = imageView.GetNaturalSize();
2962 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2963 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2968 int UtcDaliImageViewSyncSVGLoading02(void)
2970 ToolkitTestApplication application;
2972 tet_infoline("ImageView Testing SVG image sync loading");
2975 ImageView imageView = ImageView::New();
2977 // Sync loading is used
2978 Property::Map syncLoadingMap;
2979 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2980 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2981 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2982 syncLoadingMap.Insert(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
2983 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2984 imageView.ResourceReadySignal().Connect(&OnResourceReadySignalSVG);
2986 application.GetScene().Add(imageView);
2987 DALI_TEST_CHECK(imageView);
2989 application.SendNotification();
2990 application.Render();
2992 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
2993 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
2994 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
2995 Property::Map resultMap;
2996 imageVisual.CreatePropertyMap(resultMap);
2998 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
2999 DALI_TEST_CHECK(transformValue);
3000 Property::Map* retMap = transformValue->GetMap();
3001 DALI_TEST_CHECK(retMap);
3003 // Image Visual should be positioned depending on ImageView's padding
3004 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::SIZE)->Get<Vector2>(), Vector2(100, 100), TEST_LOCATION);
3006 Vector3 naturalSize = imageView.GetNaturalSize();
3007 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3008 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3013 int UtcDaliImageViewAsyncSVGLoading(void)
3015 ToolkitTestApplication application;
3017 tet_infoline("ImageView Testing SVG image async loading");
3020 ImageView imageView = ImageView::New();
3022 // Async loading is used - default value of SYNCHRONOUS_LOADING is false.
3023 Property::Map propertyMap;
3024 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
3025 propertyMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
3026 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
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);
3046 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
3048 ToolkitTestApplication application;
3050 tet_infoline("ImageView Testing SVG image async loading");
3054 ImageView imageView = ImageView::New();
3056 // Sync loading is used
3057 Property::Map syncLoadingMap;
3058 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
3059 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
3061 // Check to set invalid value
3062 // The SYNCHRONOUS_LOADING property must be set to the bool value.
3063 // Check if error log is outputted when setting other value like string.
3064 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
3065 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5));
3066 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
3068 application.GetScene().Add(imageView);
3069 DALI_TEST_CHECK(imageView);
3071 application.SendNotification();
3074 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3076 application.SendNotification();
3077 application.Render(16);
3079 Vector3 naturalSize = imageView.GetNaturalSize();
3080 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3081 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3083 Property::Value value = imageView.GetProperty(ImageView::Property::IMAGE);
3084 Property::Map* map = value.GetMap();
3085 DALI_TEST_CHECK(map);
3087 Property::Value* sync = map->Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING);
3088 DALI_TEST_CHECK(sync);
3089 DALI_TEST_EQUALS(false, sync->Get<bool>(), TEST_LOCATION);
3094 int UtcDaliImageViewSvgLoadingFailureLocalFile(void)
3096 // Local svg file - invalid file path
3098 ToolkitTestApplication application;
3100 TestGlAbstraction& gl = application.GetGlAbstraction();
3101 TraceCallStack& textureTrace = gl.GetTextureTrace();
3102 textureTrace.Enable(true);
3104 gResourceReadySignalFired = false;
3106 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
3107 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3108 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3110 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3112 application.GetScene().Add(imageView);
3114 application.SendNotification();
3116 // loading started, this waits for the loader thread - load
3117 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3119 application.SendNotification();
3120 application.Render(16);
3122 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3123 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3124 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3126 // Should be shown a broken image
3127 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3128 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3131 // Local svg file - invalid file path without size set
3133 ToolkitTestApplication application;
3135 TestGlAbstraction& gl = application.GetGlAbstraction();
3136 TraceCallStack& textureTrace = gl.GetTextureTrace();
3137 textureTrace.Enable(true);
3139 gResourceReadySignalFired = false;
3140 textureTrace.Reset();
3142 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
3143 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3145 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3147 application.GetScene().Add(imageView);
3149 application.SendNotification();
3151 // loading started, this waits for the loader thread - load & rasterize
3152 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3154 application.SendNotification();
3155 application.Render(16);
3157 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3158 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3159 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3161 // Should be shown a broken image
3162 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3163 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3166 // Local svg file - invalid file
3168 ToolkitTestApplication application;
3170 TestGlAbstraction& gl = application.GetGlAbstraction();
3171 TraceCallStack& textureTrace = gl.GetTextureTrace();
3172 textureTrace.Enable(true);
3174 gResourceReadySignalFired = false;
3175 textureTrace.Reset();
3177 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.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 UtcDaliImageViewSvgLoadingFailureRemoteFile01(void)
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.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3219 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3221 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3223 application.GetScene().Add(imageView);
3225 application.SendNotification();
3227 // loading started, this waits for the loader thread - load & rasterize
3228 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3230 application.SendNotification();
3231 application.Render(16);
3233 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3234 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3235 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3237 // Should be shown a broken image
3238 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3239 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3245 int UtcDaliImageViewSvgLoadingFailureRemoteFile02(void)
3247 // Remote svg file without size set
3249 ToolkitTestApplication application;
3251 TestGlAbstraction& gl = application.GetGlAbstraction();
3252 TraceCallStack& textureTrace = gl.GetTextureTrace();
3253 textureTrace.Enable(true);
3255 gResourceReadySignalFired = false;
3257 ImageView imageView = ImageView::New("https://127.0.0.1/foobar.svg");
3258 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3260 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3262 application.GetScene().Add(imageView);
3264 application.SendNotification();
3266 // loading started, this waits for the loader thread - load & rasterize
3267 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3269 application.SendNotification();
3270 application.Render(16);
3272 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3273 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3274 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3276 // Should be shown a broken image
3277 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3278 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3284 int UtcDaliImageViewSvgRasterizationFailure(void)
3286 ToolkitTestApplication application;
3288 gResourceReadySignalFired = false;
3290 TestGlAbstraction& gl = application.GetGlAbstraction();
3291 TraceCallStack& textureTrace = gl.GetTextureTrace();
3292 textureTrace.Enable(true);
3294 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid1.svg");
3295 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3296 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
3298 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
3300 application.GetScene().Add(imageView);
3302 application.SendNotification();
3304 // Wait for loading & rasterization
3305 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3307 application.SendNotification();
3308 application.Render(16);
3310 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3311 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3312 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
3314 // Should be shown a broken image
3315 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
3316 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
3321 int UtcDaliImageViewSvgChageSize(void)
3323 ToolkitTestApplication application;
3325 TestGlAbstraction& gl = application.GetGlAbstraction();
3326 TraceCallStack& textureTrace = gl.GetTextureTrace();
3327 textureTrace.Enable(true);
3329 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME);
3330 application.GetScene().Add(imageView);
3332 application.SendNotification();
3334 // Wait for loading & rasterization
3335 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3337 application.SendNotification();
3338 application.Render(16);
3340 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3342 // Change actor size, then rasterization should be done again
3343 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3345 application.SendNotification();
3347 // Wait for rasterization
3348 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3350 application.SendNotification();
3351 application.Render(16);
3353 // We should not load the file again.
3354 DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
3359 int UtcDaliImageViewSvgAtlasing(void)
3361 ToolkitTestApplication application;
3363 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
3365 callStack.Enable(true);
3367 Property::Map propertyMap;
3368 propertyMap["url"] = TEST_SVG_FILE_NAME;
3369 propertyMap["atlasing"] = true;
3371 ImageView imageView = ImageView::New();
3372 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
3373 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3374 application.GetScene().Add(imageView);
3376 application.SendNotification();
3378 // Wait for loading & rasterization
3379 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3381 application.SendNotification();
3382 application.Render(16);
3385 TraceCallStack::NamedParams params1;
3386 params1["width"] << 100;
3387 params1["height"] << 100;
3388 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params1), true, TEST_LOCATION);
3390 imageView.SetProperty(Actor::Property::SIZE, Vector2(600.f, 600.f));
3392 application.SendNotification();
3394 // Wait for rasterization
3395 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3399 application.SendNotification();
3400 application.Render(16);
3403 TraceCallStack::NamedParams params2;
3404 params2["width"] << 600;
3405 params2["height"] << 600;
3406 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexImage2D", params2), true, TEST_LOCATION);
3411 int UtcDaliImageViewTVGLoading(void)
3413 ToolkitTestApplication application;
3415 tet_infoline("ImageView Testing TVG image loading");
3418 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/test.tvg");
3419 application.GetScene().Add(imageView);
3420 DALI_TEST_CHECK(imageView);
3422 application.SendNotification();
3424 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3426 application.SendNotification();
3427 application.Render(16);
3429 Vector3 naturalSize = imageView.GetNaturalSize();
3431 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
3432 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
3437 int UtcDaliImageViewSvgDesiredSize01(void)
3439 ToolkitTestApplication application;
3441 TestGlAbstraction& gl = application.GetGlAbstraction();
3442 TraceCallStack& textureTrace = gl.GetTextureTrace();
3443 textureTrace.Enable(true);
3445 int desiredWidth = 100, desiredHeight = 150;
3446 ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
3448 application.GetScene().Add(imageView);
3450 application.SendNotification();
3452 // Wait for loading & rasterization
3453 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3455 application.SendNotification();
3456 application.Render(16);
3459 std::stringstream out;
3460 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
3461 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
3467 int UtcDaliImageViewSvgDesiredSize02(void)
3469 ToolkitTestApplication application;
3471 TestGlAbstraction& gl = application.GetGlAbstraction();
3472 TraceCallStack& textureTrace = gl.GetTextureTrace();
3473 textureTrace.Enable(true);
3475 int desiredWidth = 150, desiredHeight = 100;
3476 ImageView imageView = ImageView::New();
3477 imageView[ImageView::Property::IMAGE] = Property::Map().Add("url", TEST_SVG_FILE_NAME).Add("desiredWidth", desiredWidth).Add("desiredHeight", desiredHeight);
3478 application.GetScene().Add(imageView);
3480 application.SendNotification();
3482 // Wait for loading & rasterization
3483 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3485 application.SendNotification();
3486 application.Render(16);
3489 std::stringstream out;
3490 out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
3491 DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
3497 int UtcDaliImageViewImageLoadFailure01(void)
3499 ToolkitTestApplication application;
3501 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3502 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3503 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3504 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3506 std::string brokenUrl;
3507 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3508 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3510 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3511 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3513 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3514 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3516 ImageView imageView = ImageView::New("invalidUrl.png");
3517 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3519 application.GetScene().Add(imageView);
3520 application.SendNotification();
3521 application.Render(16);
3523 // loading started, this waits for the loader thread
3524 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3529 int UtcDaliImageViewImageLoadFailure02(void)
3531 ToolkitTestApplication application;
3533 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3534 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
3535 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
3536 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3538 std::string brokenUrl;
3539 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3540 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
3542 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3543 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
3545 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3546 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3548 ImageView imageView = ImageView::New("invalidUrl.png");
3549 imageView.SetProperty(Actor::Property::SIZE, Vector2(30.f, 30.f));
3550 application.GetScene().Add(imageView);
3551 application.SendNotification();
3552 application.Render(16);
3554 // loading started, this waits for the loader thread
3555 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3560 int UtcDaliImageViewImageLoadFailure03(void)
3562 ToolkitTestApplication application;
3564 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3565 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
3566 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
3568 std::string brokenUrl;
3569 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3570 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3572 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3573 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3575 ImageView imageView = ImageView::New("invalidUrl.png");
3576 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3577 application.GetScene().Add(imageView);
3578 application.SendNotification();
3579 application.Render(16);
3581 // loading started, this waits for the loader thread
3582 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3587 int UtcDaliImageViewImageLoadFailure04(void)
3589 ToolkitTestApplication application;
3591 ImageView imageView = ImageView::New("invalidUrl.png");
3592 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3593 application.GetScene().Add(imageView);
3594 application.SendNotification();
3595 application.Render(16);
3597 // loading started, this waits for the loader thread
3598 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3600 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3601 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3602 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3603 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3605 ImageView imageView2 = ImageView::New("invalidUrl.png");
3606 imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3607 application.GetScene().Add(imageView2);
3609 std::string brokenUrl;
3610 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3611 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3613 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3614 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3616 application.SendNotification();
3617 application.Render(16);
3619 // loading started, this waits for the loader thread
3620 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3622 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3624 ImageView imageView3 = ImageView::New("invalidUrl.png");
3625 imageView3.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3626 application.GetScene().Add(imageView3);
3628 application.SendNotification();
3629 application.Render(16);
3631 // loading started, this waits for the loader thread
3632 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3639 static int gResourceReadySignalCounter = 0;
3641 void OnResourceReadySignal01(Control control)
3643 gResourceReadySignalCounter++;
3645 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3647 if(gResourceReadySignalCounter == 1)
3650 // It makes the first new visual be deleted immediately
3651 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3652 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3655 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3657 // Make the resource ready immediately
3658 control[ImageView::Property::IMAGE] = gImage_600_RGB;
3662 void OnResourceReadySignal02(Control control)
3664 if(++gResourceReadySignalCounter == 1)
3666 // It makes the first new visual be deleted immediately
3667 // The first image will not be loaded.
3668 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB).Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3669 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3673 ImageView gImageView1;
3674 ImageView gImageView2;
3675 ImageView gImageView3;
3676 ImageView gImageView4;
3678 void OnResourceReadySignal03(Control control)
3680 if(gResourceReadySignalCounter == 0)
3683 // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3684 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3686 // 2. Load a new image
3687 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3689 // 3. Use the new image again
3690 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3691 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3693 else if(gResourceReadySignalCounter == 1)
3695 // This is called from TextureManager::ProcessQueuedTextures().
3696 gImageView1.Unparent();
3697 gImageView1.Reset();
3699 gResourceReadySignalCounter++;
3702 void OnSimpleResourceReadySignal(Control control)
3704 // simply increate counter
3705 gResourceReadySignalCounter++;
3708 int gResourceReadySignal04ComesOrder = 0;
3710 void OnResourceReadySignal04(Control control)
3712 gResourceReadySignalCounter++;
3713 tet_printf("rc %d\n", gResourceReadySignalCounter);
3714 if(gResourceReadySignalCounter == 1)
3716 auto scene = gImageView1.GetParent();
3718 // Request load something
3719 // We hope this request result is return later than gImageView2.
3720 gImageView3 = ImageView::New(TEST_IMAGE_1);
3721 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3722 scene.Add(gImageView3);
3723 gImageView4 = ImageView::New(TEST_IMAGE_2);
3724 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal04);
3725 scene.Add(gImageView4);
3727 if(control == gImageView1)
3729 gResourceReadySignal04ComesOrder = 1;
3733 gResourceReadySignal04ComesOrder = 2;
3736 if(gResourceReadySignalCounter == 2)
3738 if(gResourceReadySignal04ComesOrder == 1 && control == gImageView2)
3740 // Scene off first one.
3741 gImageView1.Unparent();
3743 // Scene off second one.
3744 gImageView2.Unparent();
3746 else if(gResourceReadySignal04ComesOrder == 2 && control == gImageView1)
3748 // Scene off first one.
3749 gImageView2.Unparent();
3751 // Scene off second one.
3752 gImageView1.Unparent();
3756 // We can't check that this utc fail case. just pass always when we come here.
3757 gResourceReadySignal04ComesOrder = -1;
3760 // If we don't seperate index of FreeList area
3761 // and if we don't queue remove during obversing,
3762 // cache index become something invalid data.
3763 // In this case, some strange observer can be called.
3764 // For example, gImageView4.LoadComplete will be called.
3768 void OnResourceReadySignal05(Control control)
3770 gResourceReadySignalCounter++;
3772 // Request load with same image
3773 // NOTE : The url must not be same as gImageView1
3774 const int viewCount = 4;
3775 for(int i = 0; i < viewCount; ++i)
3777 gImageView1.Add(ImageView::New("invalid2.jpg"));
3781 int gResourceReadySignal06ComesOrder = 0;
3783 void OnResourceReadySignal06(Control control)
3785 gResourceReadySignalCounter++;
3786 if(gResourceReadySignalCounter == 1)
3788 auto scene = gImageView1.GetParent();
3790 // Request load something
3791 // We hope this request result is return later than gImageView2.
3794 map1[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
3795 map1[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
3797 gImageView3 = ImageView::New();
3798 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3799 gImageView3.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3802 map2[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
3803 map2[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_S;
3804 gImageView4 = ImageView::New();
3805 gImageView4.SetProperty(Toolkit::ImageView::Property::IMAGE, map2);
3806 gImageView4.ResourceReadySignal().Connect(&OnResourceReadySignal06);
3808 if(control == gImageView1)
3810 gResourceReadySignal06ComesOrder = 1;
3814 gResourceReadySignal06ComesOrder = 2;
3817 if(gResourceReadySignalCounter == 2)
3819 if(gResourceReadySignal06ComesOrder == 1 && control == gImageView2)
3821 // Scene off first one.
3822 gImageView1.Unparent();
3824 // Scene off second one.
3825 gImageView2.Unparent();
3827 else if(gResourceReadySignal06ComesOrder == 2 && control == gImageView1)
3829 // Scene off first one.
3830 gImageView2.Unparent();
3832 // Scene off second one.
3833 gImageView1.Unparent();
3837 // We can't check that this utc fail case. just pass always when we come here.
3838 gResourceReadySignal06ComesOrder = -1;
3841 // If we don't seperate index of FreeList area
3842 // and if we don't queue remove during obversing,
3843 // cache index become something invalid data.
3844 // In this case, some strange observer can be called.
3845 // For example, gImageView4.LoadComplete will be called.
3849 void OnResourceReadySignal07(Control control)
3851 gResourceReadySignalCounter++;
3852 // Load masked image
3853 tet_printf("rc %d %d\n", gResourceReadySignalCounter, static_cast<bool>(gImageView2));
3857 auto scene = gImageView1.GetParent();
3860 map1[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
3861 map1[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = TEST_BROKEN_IMAGE_DEFAULT;
3863 gImageView2 = ImageView::New();
3864 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3865 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal07);
3867 scene.Add(gImageView2);
3871 void OnResourceReadySignal08(Control control)
3873 gResourceReadySignalCounter++;
3877 gImageView1.Unparent();
3878 gImageView1.Reset();
3882 gImageView2.Unparent();
3883 gImageView2.Reset();
3887 std::size_t gResourceReadySignal09Emitted = false;
3889 void OnResourceReadySignal09(Control control)
3891 gResourceReadySignalCounter++;
3893 if(gImageView1 && !gResourceReadySignal09Emitted)
3895 gResourceReadySignal09Emitted = true;
3896 gImageView1.ResourceReadySignal().Disconnect(&OnResourceReadySignal09);
3898 // Try to load cached invalid nine patch image. It will request load now.
3899 gImageView1.SetImage(TEST_INVALID_NPATCH_FILE_NAME_01);
3900 gImageView2.SetImage(TEST_INVALID_NPATCH_FILE_NAME_01);
3902 // Destroy all visuals immediatly.
3903 gImageView1.Unparent();
3904 gImageView1.Reset();
3905 gImageView2.Unparent();
3906 gImageView2.Reset();
3909 constexpr int gResourceReadySignal10MaxCounter = 5;
3911 void OnResourceReadySignal10(Control control)
3913 gResourceReadySignalCounter++;
3915 tet_printf("OnResourceReadySignal10 comes!\n");
3916 if(gResourceReadySignalCounter < gResourceReadySignal10MaxCounter)
3918 tet_printf("OnResourceReadySignal10 Set image\n");
3919 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, gImage_34_RGBA);
3920 tet_printf("OnResourceReadySignal10 Set image done\n");
3924 void OnResourceReadySignal11(Control control)
3926 gResourceReadySignalCounter++;
3930 auto scene = gImageView1.GetParent();
3932 // Try to load animated image visual here which is already cached, and then ignore forcely.
3935 map1[Toolkit::ImageVisual::Property::URL] = TEST_GIF_FILE_NAME;
3937 gImageView2 = ImageView::New();
3938 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3940 gImageView3 = ImageView::New();
3941 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map1);
3943 scene.Add(gImageView2);
3944 gImageView2.Unparent();
3946 scene.Add(gImageView3);
3947 gImageView3.Unparent();
3948 gImageView3.Reset(); // Destroy visual
3954 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3956 tet_infoline("Test setting image from within signal handler.");
3958 ToolkitTestApplication application;
3960 gResourceReadySignalCounter = 0;
3962 ImageView imageView = ImageView::New(gImage_34_RGBA);
3963 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal01);
3965 application.GetScene().Add(imageView);
3967 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3969 application.SendNotification();
3970 application.Render();
3972 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3974 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3976 // Create a new ImageView to cache the image
3977 ImageView imageView1 = ImageView::New(gImage_600_RGB);
3978 application.GetScene().Add(imageView1);
3980 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3982 application.SendNotification();
3983 application.Render();
3986 gResourceReadySignalCounter = 0;
3988 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3990 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3992 application.SendNotification();
3993 application.Render();
3995 // Run idle callback
3996 application.RunIdles();
3998 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4000 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
4005 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
4007 tet_infoline("Test setting image from within signal handler.");
4009 ToolkitTestApplication application;
4011 gResourceReadySignalCounter = 0;
4013 ImageView imageView = ImageView::New(gImage_34_RGBA);
4014 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal02);
4016 application.GetScene().Add(imageView);
4018 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4020 application.SendNotification();
4021 application.Render();
4023 // Wait for loading an image
4024 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4026 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4028 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
4033 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
4035 tet_infoline("Test setting image from within signal handler.");
4037 ToolkitTestApplication application;
4039 gResourceReadySignalCounter = 0;
4041 gImageView1 = ImageView::New(gImage_34_RGBA);
4042 application.GetScene().Add(gImageView1);
4045 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4047 gImageView2 = ImageView::New(gImage_600_RGB);
4048 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
4049 application.GetScene().Add(gImageView2);
4051 gImageView3 = ImageView::New();
4052 application.GetScene().Add(gImageView3);
4054 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4056 application.SendNotification();
4057 application.Render();
4062 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask01(void)
4064 tet_infoline("Test signal handler when image / mask image is broken.");
4066 ToolkitTestApplication application;
4068 auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, const std::string& url, const std::string& mask, const char* location) {
4069 gResourceReadySignalCounter = 0;
4072 map[Toolkit::ImageVisual::Property::URL] = url;
4075 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
4077 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
4079 ImageView imageView = ImageView::New();
4080 imageView[Toolkit::ImageView::Property::IMAGE] = map;
4081 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
4082 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4084 application.GetScene().Add(imageView);
4085 application.SendNotification();
4086 application.Render();
4091 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
4093 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
4094 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
4096 imageView.Unparent();
4099 for(int synchronous = 0; synchronous <= 1; synchronous++)
4101 tet_printf("Test normal case (sync:%d)\n", synchronous);
4102 TestResourceReadyUrl(1, synchronous, gImage_600_RGB, "", TEST_LOCATION);
4103 TestResourceReadyUrl(3, synchronous, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 3 event trigger required : 2 image load + 1 apply mask
4105 tet_printf("Test broken image case (sync:%d)\n", synchronous);
4106 TestResourceReadyUrl(1, synchronous, "invalid.jpg", "", TEST_LOCATION);
4107 TestResourceReadyUrl(2, synchronous, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
4109 tet_printf("Test broken mask image case (sync:%d)\n", synchronous);
4110 TestResourceReadyUrl(2, synchronous, gImage_600_RGB, "invalid.png", TEST_LOCATION);
4112 tet_printf("Test broken both image, mask image case (sync:%d)\n", synchronous);
4113 TestResourceReadyUrl(2, synchronous, "invalid.jpg", "invalid.png", TEST_LOCATION);
4119 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask02(void)
4121 tet_infoline("Test signal handler when image try to use cached-and-broken mask image.");
4123 ToolkitTestApplication application;
4125 gResourceReadySignalCounter = 0;
4127 auto TestBrokenMaskResourceReadyUrl = [&application](const std::string& url, const char* location) {
4129 map[Toolkit::ImageVisual::Property::URL] = url;
4130 // Use invalid mask url
4131 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
4133 ImageView imageView = ImageView::New();
4134 imageView[Toolkit::ImageView::Property::IMAGE] = map;
4135 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
4136 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4138 application.GetScene().Add(imageView);
4140 // Don't unparent imageView, for keep the cache.
4143 // Use more than 4 images (The number of LocalImageLoadThread)
4144 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};
4146 int expectResourceReadySignalCounter = 0;
4148 for(auto& url : testUrlList)
4150 TestBrokenMaskResourceReadyUrl(url, TEST_LOCATION);
4151 expectResourceReadySignalCounter++;
4154 // Remain 1 signal due to we use #URL + 1 mask image.
4155 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(expectResourceReadySignalCounter + 1), true, TEST_LOCATION);
4156 application.SendNotification();
4157 application.Render();
4158 DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
4163 int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
4165 tet_infoline("Test signal handler various case.");
4167 auto TestResourceReadyUrl = [](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
4168 ToolkitTestApplication application;
4170 gResourceReadySignalCounter = 0;
4173 map[Toolkit::ImageVisual::Property::URL] = url;
4176 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
4178 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
4180 ImageView imageView = ImageView::New();
4181 imageView[Toolkit::ImageView::Property::IMAGE] = map;
4182 imageView[Actor::Property::SIZE] = Vector2(100.0f, 200.0f);
4183 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4185 application.GetScene().Add(imageView);
4186 application.SendNotification();
4187 application.Render();
4190 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
4192 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
4193 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
4194 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, location);
4196 imageView.Unparent();
4199 auto TestAuxiliaryResourceReadyUrl = [](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
4200 ToolkitTestApplication application;
4202 gResourceReadySignalCounter = 0;
4205 map[Toolkit::ImageVisual::Property::URL] = url;
4206 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE] = auxiliaryUrl;
4207 map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA] = 0.5f;
4208 map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
4210 ImageView imageView = ImageView::New();
4211 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4212 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4213 imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4214 application.GetScene().Add(imageView);
4216 application.SendNotification();
4217 application.Render();
4222 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, location);
4225 tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
4226 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
4227 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
4229 imageView.Unparent();
4232 // Case 1 : asynchronous loading
4233 tet_printf("Test invalid single simple image Asynchronous\n");
4236 TestResourceReadyUrl(1, 0, 1, gImage_600_RGB, "", TEST_LOCATION);
4237 TestResourceReadyUrl(2, 0, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // load & rasterize
4238 TestResourceReadyUrl(1, 0, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
4240 TestResourceReadyUrl(2, 0, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // 2 image loading - batch size
4241 TestResourceReadyUrl(2, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // load & rasterize
4243 TestResourceReadyUrl(3, 0, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 2 image loading + 1 applymask
4245 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
4248 TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
4249 TestResourceReadyUrl(1, 0, 0, "invalid.svg", "", TEST_LOCATION);
4250 TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
4251 TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION); // 1 image loading
4252 TestResourceReadyUrl(1, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
4254 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", "invalid.png", TEST_LOCATION); // 2 image loading
4255 TestResourceReadyUrl(2, 0, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); // 2 image loading
4256 TestResourceReadyUrl(2, 0, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION); // 2 image loading
4258 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
4259 TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
4260 TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
4262 // Case 2 : Synchronous loading
4263 tet_printf("Test invalid single simple image Synchronous\n");
4266 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "", TEST_LOCATION);
4267 TestResourceReadyUrl(0, 1, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
4268 TestResourceReadyUrl(0, 1, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
4270 TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // first frame image loading sync + second frame image loading async
4272 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION);
4274 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
4277 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
4278 TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION);
4279 TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
4280 TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
4282 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "invalid.png", TEST_LOCATION);
4283 TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION);
4284 TestResourceReadyUrl(0, 1, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
4286 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
4287 TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
4288 TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
4293 int UtcDaliImageViewSetImageOnResourceReadySignal04(void)
4295 tet_infoline("Test texturemanager's remove queue works well within signal handler.");
4297 ToolkitTestApplication application;
4299 gResourceReadySignalCounter = 0;
4300 gResourceReadySignal04ComesOrder = 0;
4302 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
4303 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal04);
4304 application.GetScene().Add(gImageView1);
4306 gImageView2 = ImageView::New("invalid.png"); // request invalid image, to make loading failed fast.
4307 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal04);
4308 application.GetScene().Add(gImageView2);
4310 application.SendNotification();
4311 application.Render();
4313 tet_infoline("Try to load 2 invalid image");
4315 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4316 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4318 tet_infoline("load done");
4320 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
4321 if(gResourceReadySignal04ComesOrder == -1)
4323 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
4327 // gImageView3 and gImageView4 load must not be successed yet.
4328 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
4329 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
4331 application.SendNotification();
4332 application.Render();
4334 tet_infoline("Try to load 2 valid image");
4336 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4337 DALI_TEST_EQUALS(gResourceReadySignalCounter, 4, TEST_LOCATION);
4339 tet_infoline("load done");
4341 // gImageView3 and gImageView4 load must be successed now.
4342 DALI_TEST_EQUALS(gImageView3.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
4343 DALI_TEST_EQUALS(gImageView4.GetRendererAt(0).GetTextures().GetTextureCount(), 1u, TEST_LOCATION);
4348 int UtcDaliImageViewSetImageOnResourceReadySignal05(void)
4350 tet_infoline("Test multiple views with same image during ResourceReady load the image only 1 times");
4352 ToolkitTestApplication application;
4354 gResourceReadySignalCounter = 0;
4356 gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
4357 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal05);
4358 application.GetScene().Add(gImageView1);
4360 application.SendNotification();
4361 application.Render();
4363 tet_infoline("Try to load 1 invalid.jpg image");
4364 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4365 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4367 tet_infoline("Try to load 1 invalid2.jpg image");
4368 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4370 tet_infoline("Now we don't have any image to be loaded. Check event thread trigger failed.");
4371 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
4373 gImageView1.Unparent();
4374 gImageView1.Reset();
4378 int UtcDaliImageViewSetImageOnResourceReadySignal06(void)
4380 tet_infoline("Test texturemanager's remove image & mask queue works well within signal handler.");
4382 ToolkitTestApplication application;
4384 gResourceReadySignalCounter = 0;
4385 gResourceReadySignal06ComesOrder = 0;
4388 map[Toolkit::ImageVisual::Property::URL] = "invalid.jpg";
4389 map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
4391 gImageView1 = ImageView::New(); // request invalid image, to make loading failed fast.
4392 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4393 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal06);
4394 application.GetScene().Add(gImageView1);
4396 gImageView2 = ImageView::New(); // request invalid image, to make loading failed fast.
4397 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4398 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal06);
4399 application.GetScene().Add(gImageView2);
4401 application.SendNotification();
4402 application.Render();
4404 tet_infoline("Try to load 2 invalid image");
4406 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4407 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4409 tet_infoline("load done");
4411 // We can test this UTC only if gImageView1 and gImageView2 loaded done.
4412 if(gResourceReadySignal06ComesOrder == -1)
4414 tet_infoline("Bad news.. gImageView3 or gImageView4 loaded faster than others. just skip this UTC");
4418 // gImageView3 and gImageView4 load must not be successed yet.
4419 DALI_TEST_EQUALS(gImageView3.GetRendererCount(), 0u, TEST_LOCATION);
4420 DALI_TEST_EQUALS(gImageView4.GetRendererCount(), 0u, TEST_LOCATION);
4422 application.GetScene().Add(gImageView3);
4423 application.GetScene().Add(gImageView4);
4424 application.SendNotification();
4425 application.Render();
4427 tet_infoline("Try to load 2 valid image");
4429 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4430 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4432 tet_infoline("Note that resource ready should not come now.");
4433 tet_infoline("Try to load remained 2 valid image + apply masking");
4435 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
4436 DALI_TEST_EQUALS(gResourceReadySignalCounter, 4, TEST_LOCATION);
4438 tet_infoline("Check all resource ready comes now.");
4443 int UtcDaliImageViewSetImageOnResourceReadySignal07(void)
4445 tet_infoline("Test texturemanager's remove image & mask queue works well within signal handler 02.");
4447 ToolkitTestApplication application;
4449 gResourceReadySignalCounter = 0;
4452 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
4454 // Clear image view for clear test
4458 gImageView1.Reset();
4462 gImageView2.Reset();
4465 gImageView1 = ImageView::New();
4466 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4467 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal07);
4468 application.GetScene().Add(gImageView1);
4470 application.SendNotification();
4471 application.Render();
4475 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4476 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4478 tet_infoline("load image1 done");
4480 // Load gImageView2 and mask
4482 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
4483 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4485 // gImageView2 mask apply done
4487 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4488 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4490 tet_infoline("load image2 done");
4494 int UtcDaliImageViewSetImageOnResourceReadySignal08(void)
4496 tet_infoline("Test remove npatch images during resource ready");
4498 ToolkitTestApplication application;
4500 gResourceReadySignalCounter = 0;
4503 map[Toolkit::ImageVisual::Property::URL] = TEST_BROKEN_IMAGE_M;
4505 // Clear image view for clear test
4509 gImageView1.Reset();
4513 gImageView2.Reset();
4516 // Case 1 : Remove all images during resource ready.
4519 gImageView1 = ImageView::New();
4520 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4521 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal08);
4522 application.GetScene().Add(gImageView1);
4524 application.SendNotification();
4525 application.Render();
4528 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4529 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4531 application.SendNotification();
4532 application.Render();
4534 DALI_TEST_CHECK(true);
4538 // Exception should not happened
4539 DALI_TEST_CHECK(false);
4543 application.SendNotification();
4544 application.Render();
4546 gResourceReadySignalCounter = 0;
4548 // Case 2 : Remove all images when we use cached resource.
4551 gImageView1 = ImageView::New();
4552 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4553 gImageView1.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4554 application.GetScene().Add(gImageView1);
4556 application.SendNotification();
4557 application.Render();
4560 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4561 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4563 application.SendNotification();
4564 application.Render();
4566 gImageView2 = ImageView::New();
4567 gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4568 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal08);
4569 application.GetScene().Add(gImageView2);
4570 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
4572 application.SendNotification();
4573 application.Render();
4575 DALI_TEST_CHECK(true);
4579 // Exception should not happened
4580 DALI_TEST_CHECK(false);
4582 gResourceReadySignalCounter = 0;
4584 // Clear image view for clear test
4588 gImageView1.Reset();
4592 gImageView2.Reset();
4598 int UtcDaliImageViewSetImageOnResourceReadySignal09(void)
4600 tet_infoline("Test load invalid npatch images during invalid resource ready");
4602 ToolkitTestApplication application;
4604 gResourceReadySignalCounter = 0;
4607 map[Toolkit::ImageVisual::Property::URL] = TEST_INVALID_NPATCH_FILE_NAME_01;
4609 // Clear image view for clear test
4613 gImageView1.Reset();
4617 gImageView2.Reset();
4621 gImageView3.Reset();
4624 // Dummy view with npatch image
4625 ImageView dummyView = ImageView::New(TEST_BROKEN_IMAGE_M);
4626 application.GetScene().Add(dummyView);
4628 application.SendNotification();
4629 application.Render();
4630 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4631 application.SendNotification();
4632 application.Render();
4634 // Case 1 : Reload images during resource ready.
4637 gResourceReadySignal09Emitted = false;
4639 gImageView1 = ImageView::New();
4640 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4641 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal09);
4642 application.GetScene().Add(gImageView1);
4644 gImageView2 = ImageView::New();
4645 application.GetScene().Add(gImageView2);
4647 // Load TEST_INVALID_NPATCH_FILE_NAME_01
4648 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4650 // Load TEST_INVALID_NPATCH_FILE_NAME_01 one more times.
4651 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4653 application.SendNotification();
4654 application.Render();
4656 DALI_TEST_CHECK(true);
4660 // Exception should not happened
4661 DALI_TEST_CHECK(false);
4665 application.SendNotification();
4666 application.Render();
4668 gResourceReadySignalCounter = 0;
4670 // Case 2 : Remove all images when we use cached resource.
4673 gResourceReadySignal09Emitted = false;
4675 gImageView3 = ImageView::New();
4676 gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4677 gImageView3.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
4678 application.GetScene().Add(gImageView3);
4680 gImageView2 = ImageView::New();
4681 application.GetScene().Add(gImageView2);
4684 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4686 gImageView1 = ImageView::New();
4687 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
4688 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal09);
4689 application.GetScene().Add(gImageView1);
4692 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4694 // Load TEST_INVALID_NPATCH_FILE_NAME_01 one more times.
4695 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4697 application.SendNotification();
4698 application.Render();
4700 DALI_TEST_CHECK(true);
4704 // Exception should not happened
4705 DALI_TEST_CHECK(false);
4707 gResourceReadySignalCounter = 0;
4709 // Clear image view for clear test
4713 gImageView1.Reset();
4717 gImageView2.Reset();
4721 gImageView3.Reset();
4727 int UtcDaliImageViewSetImageOnResourceReadySignal10(void)
4729 tet_infoline("Test ResourceReady signal comes more than 2 times.");
4731 ToolkitTestApplication application;
4733 gResourceReadySignalCounter = 0;
4735 // Clear image view for clear test
4739 gImageView1.Reset();
4742 // Dummy view to cache image.
4743 ImageView dummyView = ImageView::New(gImage_34_RGBA);
4744 application.GetScene().Add(dummyView);
4746 application.SendNotification();
4747 application.Render();
4748 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4749 application.SendNotification();
4750 application.Render();
4754 gImageView1 = ImageView::New();
4755 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, gImage_34_RGBA);
4756 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal10);
4757 application.GetScene().Add(gImageView1); // It will call resourceReady signal 1 time.
4759 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4761 DALI_TEST_GREATER(gResourceReadySignal10MaxCounter, gResourceReadySignalCounter, TEST_LOCATION); // Check whether resource ready call too much.
4763 for(int i = 0; i < gResourceReadySignal10MaxCounter; ++i)
4765 tet_printf("RunIdles\n");
4766 // Executes the idle callbacks.
4767 application.RunIdles();
4768 application.SendNotification();
4769 application.Render();
4770 tet_printf("RunIdles done\n");
4772 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4774 DALI_TEST_EQUALS(gResourceReadySignalCounter, gResourceReadySignal10MaxCounter, TEST_LOCATION);
4776 DALI_TEST_CHECK(true);
4780 // Exception should not happened
4781 DALI_TEST_CHECK(false);
4785 application.SendNotification();
4786 application.Render();
4788 gResourceReadySignalCounter = 0;
4790 gResourceReadySignalCounter = 0;
4792 // Clear image view for clear test
4796 gImageView1.Reset();
4802 int UtcDaliImageViewSetImageOnResourceReadySignal11(void)
4804 tet_infoline("Test ResourceReady Add AnimatedImageVisual and then Remove immediately.");
4806 ToolkitTestApplication application;
4808 gResourceReadySignalCounter = 0;
4810 // Clear image view for clear test
4814 gImageView1.Reset();
4818 gImageView2.Reset();
4822 gImageView3.Reset();
4827 gImageView1 = ImageView::New();
4828 gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, TEST_GIF_FILE_NAME);
4829 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal11);
4830 application.GetScene().Add(gImageView1); // It will call resourceReady signal 1 time.
4832 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4834 DALI_TEST_EQUALS(gResourceReadySignalCounter, 0, TEST_LOCATION);
4836 application.SendNotification();
4837 application.Render();
4840 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4842 tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
4844 DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
4846 DALI_TEST_CHECK(true);
4850 // Exception should not happened
4851 DALI_TEST_CHECK(false);
4855 application.SendNotification();
4856 application.Render();
4858 gResourceReadySignalCounter = 0;
4860 // Clear image view for clear test
4864 gImageView1.Reset();
4868 gImageView2.Reset();
4872 gImageView3.Reset();
4878 int UtcDaliImageViewUseSameUrlWithAnimatedImageVisual(void)
4880 tet_infoline("Test multiple views with same image in animated image visual");
4881 ToolkitTestApplication application;
4883 gImageView1 = ImageView::New(TEST_WEBP_FILE_NAME);
4884 application.GetScene().Add(gImageView1);
4886 tet_infoline("Remove imageView and Create new imageView with same url");
4887 application.GetScene().Remove(gImageView1);
4888 gImageView2 = ImageView::New(TEST_WEBP_FILE_NAME);
4889 application.GetScene().Add(gImageView2);
4891 application.SendNotification();
4892 application.Render();
4894 tet_infoline("Check the ImageView load image successfully");
4895 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4899 int UtcDaliImageViewNpatchImageCacheTest01(void)
4901 tet_infoline("Test npatch image cached");
4903 ToolkitTestApplication application;
4904 ImageView imageView[2];
4906 auto& gl = application.GetGlAbstraction();
4907 gl.EnableTextureCallTrace(true);
4908 auto& textureCallStack = gl.GetTextureTrace();
4909 textureCallStack.Enable(true);
4910 textureCallStack.EnableLogging(true);
4912 auto TestNPatch = [&](int index, const std::string& nPatchImageUrl, const char* location) {
4913 if(imageView[index])
4915 imageView[index].Unparent();
4918 // Ensure remove npatch cache if required.
4919 application.SendNotification();
4920 application.Render();
4922 imageView[index] = ImageView::New(nPatchImageUrl);
4923 imageView[index].SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
4924 application.GetScene().Add(imageView[index]);
4927 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4928 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4930 application.SendNotification();
4931 application.Render();
4933 tet_printf("trace : \n%s\n", textureCallStack.GetTraceString().c_str());
4935 // Check we gen only 1 textures
4936 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 1, TEST_LOCATION);
4937 textureCallStack.Reset();
4939 // Let we use cached textures
4940 for(int i = 0; i < 10; i++)
4942 TestNPatch(1, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4943 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4946 application.SendNotification();
4947 application.Render();
4948 // Check we use cached npatch data so we don't generate new texture textures
4949 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 0, TEST_LOCATION);
4952 imageView[0].Unparent();
4953 imageView[0].Reset();
4954 imageView[1].Unparent();
4955 imageView[1].Reset();
4957 application.SendNotification();
4958 application.Render();
4960 textureCallStack.Reset();
4961 // Let we use deference textures
4962 TestNPatch(1, TEST_BROKEN_IMAGE_S, TEST_LOCATION);
4963 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4965 application.SendNotification();
4966 application.Render();
4967 // Try to load multiple times.
4968 for(int i = 0; i < 3; i++)
4970 TestNPatch(0, TEST_BROKEN_IMAGE_M, TEST_LOCATION);
4971 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4972 TestNPatch(1, TEST_BROKEN_IMAGE_S, TEST_LOCATION);
4973 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
4975 application.SendNotification();
4976 application.Render();
4978 imageView[0].Unparent();
4979 imageView[0].Reset();
4980 imageView[1].Unparent();
4981 imageView[1].Reset();
4983 application.SendNotification();
4984 application.Render();
4986 // Check memory leak
4987 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), textureCallStack.CountMethod("DeleteTextures"), TEST_LOCATION);
4992 int UtcDaliImageViewNpatchImageCacheTest02(void)
4994 tet_infoline("Test npatch image cached with border");
4996 ToolkitTestApplication application;
4997 ImageView imageView[2];
4999 auto& gl = application.GetGlAbstraction();
5000 gl.EnableTextureCallTrace(true);
5001 auto& textureCallStack = gl.GetTextureTrace();
5002 textureCallStack.Enable(true);
5003 textureCallStack.EnableLogging(true);
5005 auto TestBorderImage = [&](int index, const std::string& normalImageUrl, const Rect<int> border, const char* location) {
5007 map[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::N_PATCH;
5008 map[Toolkit::ImageVisual::Property::URL] = normalImageUrl;
5009 map[Toolkit::ImageVisual::Property::BORDER] = border;
5011 imageView[index] = ImageView::New();
5012 imageView[index].SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5013 imageView[index].SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5014 application.GetScene().Add(imageView[index]);
5017 TestBorderImage(0, gImage_34_RGBA, Rect<int>(0, 0, 0, 0), TEST_LOCATION);
5018 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5020 application.SendNotification();
5021 application.Render();
5023 tet_printf("trace : \n%s\n", textureCallStack.GetTraceString().c_str());
5025 // Check we gen only 1 textures
5026 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 1, TEST_LOCATION);
5027 textureCallStack.Reset();
5029 // Let we use cached textures
5030 for(int i = 0; i < 10; i++)
5032 TestBorderImage(0, gImage_34_RGBA, Rect<int>(i, i + 1, i + 2, i + 3), TEST_LOCATION);
5033 TestBorderImage(1, gImage_34_RGBA, Rect<int>(i + 1, i, i + 3, i + 2), TEST_LOCATION);
5036 application.SendNotification();
5037 application.Render();
5039 // Check we use cached npatch data so we don't generate new texture textures
5040 DALI_TEST_EQUALS(textureCallStack.CountMethod("GenTextures"), 0, TEST_LOCATION);
5045 int UtcDaliImageViewPlaceholderImage01(void)
5047 tet_infoline("Test imageView use placeholder image");
5049 ToolkitTestApplication application;
5051 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5053 ImageView imageView = ImageView::New();
5054 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5055 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5056 application.GetScene().Add(imageView);
5058 Property::Value value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5060 DALI_TEST_CHECK(value.Get(url));
5061 DALI_TEST_CHECK(url.empty());
5062 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5064 application.SendNotification();
5065 application.Render();
5067 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5068 DALI_TEST_CHECK(value.Get(url));
5069 DALI_TEST_CHECK(url == gImage_34_RGBA);
5071 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5072 application.SendNotification();
5073 application.Render();
5075 // Replace Image test
5076 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5077 map[ImageView::Property::PLACEHOLDER_IMAGE] = gImage_34_RGBA;
5078 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5079 application.SendNotification();
5080 application.Render();
5082 map[Toolkit::ImageVisual::Property::URL] = "";
5083 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5084 application.SendNotification();
5085 application.Render();
5087 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
5088 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5089 application.SendNotification();
5090 application.Render();
5092 // Replace Image test2
5093 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5094 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5095 application.SendNotification();
5096 application.Render();
5098 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_2;
5099 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5100 application.SendNotification();
5101 application.Render();
5103 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5104 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5105 application.SendNotification();
5106 application.Render(900);
5108 map[Toolkit::ImageVisual::Property::URL] = "";
5109 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5110 application.SendNotification();
5111 application.Render();
5113 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5114 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5115 application.SendNotification();
5116 application.Render();
5121 int UtcDaliImageViewPlaceholderImage02(void)
5123 tet_infoline("Test imageView use placeholder image without resource ready");
5125 ToolkitTestApplication application;
5128 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
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 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
5134 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
5135 application.GetScene().Add(imageView);
5137 Property::Value value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5139 DALI_TEST_CHECK(value.Get(url));
5140 DALI_TEST_CHECK(url.empty());
5142 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5143 application.SendNotification();
5144 application.Render();
5146 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5148 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5149 DALI_TEST_CHECK(value.Get(url));
5150 DALI_TEST_CHECK(url == gImage_34_RGBA);
5152 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
5153 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
5155 gResourceReadySignalFired = false;
5156 map[Toolkit::ImageVisual::Property::URL] = "";
5157 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5158 application.SendNotification();
5159 application.Render();
5161 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
5162 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
5167 int UtcDaliImageViewTransitionEffect01(void)
5169 tet_infoline("Test imageView use transition effect");
5171 ToolkitTestApplication application;
5173 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5174 map[Toolkit::Visual::Property::OPACITY] = 0.9f;
5176 ImageView imageView = ImageView::New();
5177 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5178 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5179 application.GetScene().Add(imageView);
5181 Property::Value value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5183 DALI_TEST_CHECK(value.Get(transition));
5184 DALI_TEST_CHECK(transition == false);
5185 imageView.SetProperty(Toolkit::ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
5187 application.SendNotification();
5188 application.Render();
5190 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5191 DALI_TEST_CHECK(value.Get(transition));
5192 DALI_TEST_CHECK(transition == true);
5194 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5195 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5196 application.SendNotification();
5197 application.Render();
5199 // Test transition effect with placeholder
5200 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5201 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5202 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5203 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5204 application.SendNotification();
5205 application.Render();
5207 map[Toolkit::ImageVisual::Property::URL] = "";
5208 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5209 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5210 application.SendNotification();
5211 application.Render();
5213 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5214 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5215 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5216 application.SendNotification();
5217 application.Render();
5219 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5220 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5221 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5222 application.SendNotification();
5224 map[Toolkit::ImageVisual::Property::URL] = "";
5225 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5226 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5227 application.SendNotification();
5228 application.Render();
5230 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5231 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5232 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, "");
5233 application.SendNotification();
5234 application.Render();
5236 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5237 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5238 application.SendNotification();
5239 application.Render();
5241 map[Toolkit::ImageVisual::Property::URL] = "";
5242 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5243 application.SendNotification();
5244 application.Render();
5246 // Test transition effect without placeholder
5247 map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_1;
5248 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5249 application.SendNotification();
5250 application.Render();
5252 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5253 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5254 application.SendNotification();
5255 application.Render();
5257 map[Toolkit::ImageVisual::Property::URL] = "";
5258 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5259 application.SendNotification();
5260 application.Render();
5262 map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
5263 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5264 application.SendNotification();
5265 application.Render();
5267 imageView.SetImage(TEST_IMAGE_1);
5268 application.SendNotification();
5269 application.Render();
5271 imageView.SetImage(gImage_600_RGB);
5272 application.SendNotification();
5273 application.Render(9000);
5275 imageView.SetImage("");
5276 application.SendNotification();
5277 application.Render();
5279 imageView.SetImage(TEST_IMAGE_1);
5280 application.SendNotification();
5281 application.Render();
5284 imageView.Unparent();
5290 int UtcDaliImageViewTransitionEffect02(void)
5292 tet_infoline("Test imageView use transition effect with replace image");
5294 ToolkitTestApplication application;
5298 ImageView imageView = ImageView::New();
5299 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5300 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5301 application.GetScene().Add(imageView);
5303 Property::Value value;
5304 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5306 DALI_TEST_CHECK(value.Get(transition));
5307 DALI_TEST_CHECK(transition == false);
5308 imageView.SetProperty(Toolkit::ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
5310 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5312 DALI_TEST_CHECK(value.Get(url));
5313 DALI_TEST_CHECK(url.empty());
5314 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5315 application.SendNotification();
5316 application.Render();
5318 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, "");
5319 application.SendNotification();
5320 application.Render();
5322 imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5323 application.SendNotification();
5324 application.Render();
5326 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5327 DALI_TEST_CHECK(value.Get(transition));
5328 DALI_TEST_CHECK(transition == true);
5330 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5331 DALI_TEST_CHECK(value.Get(url));
5332 DALI_TEST_CHECK(url == gImage_34_RGBA);
5334 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
5335 application.SendNotification();
5336 application.Render();
5339 imageView.Unparent();
5345 int UtcDaliImageViewTransitionEffect03(void)
5347 tet_infoline("Test imageView use transition effect with placeholder");
5349 ToolkitTestApplication application;
5352 ImageView imageView = ImageView::New();
5353 imageView.SetImage("");
5354 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
5355 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5356 imageView.SetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
5357 application.GetScene().Add(imageView);
5359 //DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5361 application.SendNotification();
5362 application.Render(16);
5364 tet_infoline("(1)");
5365 imageView.SetImage(gImage_600_RGB);
5366 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5367 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
5368 application.SendNotification();
5369 application.Render(16);
5371 Property::Value value;
5372 value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
5374 DALI_TEST_CHECK(value.Get(transition));
5375 DALI_TEST_CHECK(transition == true);
5377 value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
5379 DALI_TEST_CHECK(value.Get(url));
5380 DALI_TEST_CHECK(url == gImage_34_RGBA);
5382 imageView.SetImage("");
5383 application.SendNotification();
5384 application.Render(16);
5386 imageView.SetImage(TEST_IMAGE_1);
5387 imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
5388 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
5389 application.SendNotification();
5390 application.Render(16);
5393 imageView.Unparent();