2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
24 #include <dali-toolkit-test-suite-utils.h>
25 #include <toolkit-event-thread-callback.h>
26 #include "dummy-control.h"
28 #include <test-encoded-image-buffer.h>
29 #include <test-native-image.h>
31 #include <dali-toolkit/dali-toolkit.h>
32 #include <dali-toolkit/devel-api/controls/control-devel.h>
33 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
34 #include <dali-toolkit/devel-api/styling/style-manager-devel.h>
35 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
36 #include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
37 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
38 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
39 #include <dali-toolkit/public-api/image-loader/image-url.h>
40 #include <dali-toolkit/public-api/image-loader/image.h>
41 #include <dali/devel-api/scripting/scripting.h>
44 using namespace Toolkit;
46 void utc_dali_toolkit_image_view_startup(void)
48 test_return_value = TET_UNDEF;
51 void utc_dali_toolkit_image_view_cleanup(void)
53 test_return_value = TET_PASS;
58 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
59 const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
61 const char* TEST_IMAGE_1 = TEST_RESOURCE_DIR "/TB-gloss.png";
62 const char* TEST_IMAGE_2 = TEST_RESOURCE_DIR "/tb-norm.png";
64 const char* TEST_BROKEN_IMAGE_DEFAULT = TEST_RESOURCE_DIR "/broken.png";
65 const char* TEST_BROKEN_IMAGE_S = TEST_RESOURCE_DIR "/broken_s.9.png";
66 const char* TEST_BROKEN_IMAGE_M = TEST_RESOURCE_DIR "/broken_m.9.png";
67 const char* TEST_BROKEN_IMAGE_L = TEST_RESOURCE_DIR "/broken_l.9.png";
68 const char* TEST_BROKEN_IMAGE_01 = TEST_RESOURCE_DIR "/button-up.9.png";
69 const char* TEST_BROKEN_IMAGE_02 = TEST_RESOURCE_DIR "/heartsframe.9.png";
71 // resolution: 34*34, pixel format: RGBA8888
72 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
73 // resolution: 600*600, pixel format: RGB888
74 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
76 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
77 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
79 const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
81 void TestUrl(ImageView imageView, const std::string url)
83 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
85 std::string urlActual;
86 DALI_TEST_CHECK(value.Get(urlActual));
87 DALI_TEST_EQUALS(urlActual, url, TEST_LOCATION);
92 int UtcDaliImageViewNewP(void)
94 ToolkitTestApplication application;
96 ImageView imageView = ImageView::New();
98 DALI_TEST_CHECK(imageView);
103 int UtcDaliImageViewNewUrlP(void)
105 ToolkitTestApplication application;
107 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
108 DALI_TEST_CHECK(imageView);
110 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
115 int UtcDaliImageViewConstructorP(void)
117 ToolkitTestApplication application;
121 DALI_TEST_CHECK(!imageView);
126 int UtcDaliImageViewCopyConstructorP(void)
128 ToolkitTestApplication application;
130 // Initialize an object, ref count == 1
131 ImageView imageView = ImageView::New();
133 ImageView copy(imageView);
134 DALI_TEST_CHECK(copy);
139 int UtcDaliImageViewMoveConstructor(void)
141 ToolkitTestApplication application;
143 ImageView imageView = ImageView::New();
144 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
145 imageView.SetProperty(Actor::Property::SENSITIVE, false);
146 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
148 ImageView moved = std::move(imageView);
149 DALI_TEST_CHECK(moved);
150 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
151 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
152 DALI_TEST_CHECK(!imageView);
157 int UtcDaliImageViewAssignmentOperatorP(void)
159 ToolkitTestApplication application;
161 ImageView imageView = ImageView::New();
163 ImageView copy(imageView);
164 DALI_TEST_CHECK(copy);
165 DALI_TEST_EQUALS(imageView, copy, TEST_LOCATION);
170 int UtcDaliImageViewMoveAssignment(void)
172 ToolkitTestApplication application;
174 ImageView imageView = ImageView::New();
175 DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
176 imageView.SetProperty(Actor::Property::SENSITIVE, false);
177 DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
180 moved = std::move(imageView);
181 DALI_TEST_CHECK(moved);
182 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
183 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
184 DALI_TEST_CHECK(!imageView);
189 int UtcDaliImageViewDownCastP(void)
191 ToolkitTestApplication application;
193 ImageView imageView = ImageView::New();
195 BaseHandle object(imageView);
197 ImageView imageView2 = ImageView::DownCast(object);
198 DALI_TEST_CHECK(imageView2);
200 ImageView imageView3 = DownCast<ImageView>(object);
201 DALI_TEST_CHECK(imageView3);
206 int UtcDaliImageViewDownCastN(void)
208 ToolkitTestApplication application;
210 BaseHandle unInitializedObject;
212 ImageView imageView1 = ImageView::DownCast(unInitializedObject);
213 DALI_TEST_CHECK(!imageView1);
215 ImageView imageView2 = DownCast<ImageView>(unInitializedObject);
216 DALI_TEST_CHECK(!imageView2);
221 int UtcDaliImageViewTypeRegistry(void)
223 ToolkitTestApplication application;
225 TypeRegistry typeRegistry = TypeRegistry::Get();
226 DALI_TEST_CHECK(typeRegistry);
228 TypeInfo typeInfo = typeRegistry.GetTypeInfo("ImageView");
229 DALI_TEST_CHECK(typeInfo);
231 BaseHandle handle = typeInfo.CreateInstance();
232 DALI_TEST_CHECK(handle);
234 ImageView imageView = ImageView::DownCast(handle);
235 DALI_TEST_CHECK(imageView);
240 int UtcDaliImageViewSetGetProperty01(void)
242 ToolkitTestApplication application;
244 ImageView imageView = ImageView::New();
246 Property::Index idx = imageView.GetPropertyIndex("image");
247 DALI_TEST_EQUALS(idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION);
249 imageView.SetProperty(idx, TEST_IMAGE_FILE_NAME);
250 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
255 int UtcDaliImageViewPreMultipliedAlphaPng(void)
257 ToolkitTestApplication application;
259 // Set up trace debug
260 TestGlAbstraction& gl = application.GetGlAbstraction();
261 TraceCallStack& textureTrace = gl.GetTextureTrace();
262 textureTrace.Enable(true);
264 Property::Map imageMap;
265 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
266 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
268 ImageView imageView1 = ImageView::New();
269 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
271 application.GetScene().Add(imageView1);
273 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
275 DALI_TEST_CHECK(value.Get(enable));
276 DALI_TEST_CHECK(enable); // Default value is true
278 // loading started, this waits for the loader thread for max 30 seconds
279 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
281 application.SendNotification();
282 application.Render();
284 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
285 DALI_TEST_CHECK(value.Get(enable));
286 DALI_TEST_CHECK(enable); // Keep true
288 // conventional alpha blending
289 Renderer renderer1 = imageView1.GetRendererAt(0);
290 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
291 DALI_TEST_CHECK(value.Get(enable));
292 DALI_TEST_CHECK(enable);
294 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
295 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
296 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
297 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
298 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
299 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
300 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
301 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
303 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
304 textureTrace.Reset();
306 // Disable pre-multiplied alpha blending
307 imageView1.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
310 Property::Map attributes;
311 DevelControl::DoAction(imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
313 // loading started, this waits for the loader thread for max 30 seconds
314 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
316 application.SendNotification();
317 application.Render();
319 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
320 DALI_TEST_CHECK(value.Get(enable));
321 DALI_TEST_CHECK(!enable);
323 // conventional alpha blending
324 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
325 DALI_TEST_CHECK(value.Get(enable));
326 DALI_TEST_CHECK(!enable);
328 srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
329 destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
330 srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
331 destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
332 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
333 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
334 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
335 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
337 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
338 textureTrace.Reset();
340 // Make a new ImageView using the same image
341 ImageView imageView2 = ImageView::New();
342 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
344 application.GetScene().Add(imageView2);
346 application.SendNotification();
347 application.Render();
349 Renderer renderer2 = imageView2.GetRendererAt(0);
350 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
351 DALI_TEST_CHECK(value.Get(enable));
352 DALI_TEST_CHECK(enable);
354 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
355 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
356 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
357 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
358 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
359 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
360 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
361 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
363 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
368 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
370 ToolkitTestApplication application;
372 // Set up trace debug
373 TestGlAbstraction& gl = application.GetGlAbstraction();
374 TraceCallStack& textureTrace = gl.GetTextureTrace();
375 textureTrace.Enable(true);
377 Property::Map imageMap;
378 imageMap[ImageVisual::Property::URL] = gImage_600_RGB;
379 imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
381 ImageView imageView1 = ImageView::New();
382 imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
384 application.GetScene().Add(imageView1);
386 Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
388 DALI_TEST_CHECK(value.Get(enable));
389 DALI_TEST_CHECK(enable); // Default value is true
391 // loading started, this waits for the loader thread for max 30 seconds
392 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
394 application.SendNotification();
395 application.Render();
397 value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
398 DALI_TEST_CHECK(value.Get(enable));
399 DALI_TEST_CHECK(!enable); // Should be false after loading
401 // conventional alpha blending
402 Renderer renderer1 = imageView1.GetRendererAt(0);
403 value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
404 DALI_TEST_CHECK(value.Get(enable));
405 DALI_TEST_CHECK(!enable);
407 int srcFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
408 int destFactorRgb = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
409 int srcFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
410 int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
411 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
412 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
413 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
414 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
416 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
417 textureTrace.Reset();
419 ImageView imageView2 = ImageView::New();
420 imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
422 // Disable pre-multiplied alpha blending
423 imageView2.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
425 application.GetScene().Add(imageView2);
427 application.SendNotification();
428 application.Render();
430 value = imageView2.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
431 DALI_TEST_CHECK(value.Get(enable));
432 DALI_TEST_CHECK(!enable);
434 // conventional alpha blending
435 Renderer renderer2 = imageView2.GetRendererAt(0);
436 value = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
437 DALI_TEST_CHECK(value.Get(enable));
438 DALI_TEST_CHECK(!enable);
440 srcFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
441 destFactorRgb = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
442 srcFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
443 destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
444 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
445 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
446 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
447 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
449 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
454 int UtcDaliImageViewPixelArea(void)
456 // Test pixel area property
457 ToolkitTestApplication application;
459 static std::vector<UniformData> customUniforms =
461 UniformData("pixelArea", Property::Type::VECTOR4),
464 TestGraphicsController& graphics = application.GetGraphicsController();
465 graphics.AddCustomUniforms(customUniforms);
467 // Gif image, use AnimatedImageVisual internally
468 // Atlasing is applied to pack multiple frames, use custom wrap mode
469 ImageView gifView = ImageView::New();
470 const Vector4 pixelAreaVisual(0.f, 0.f, 2.f, 2.f);
471 gifView.SetProperty(ImageView::Property::IMAGE,
472 Property::Map().Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME).Add(ImageVisual::Property::PIXEL_AREA, pixelAreaVisual));
475 Integration::Scene stage = application.GetScene();
479 application.SendNotification();
480 application.Render(16);
482 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
484 application.SendNotification();
485 application.Render();
486 DALI_TEST_CHECK(gifView.GetRendererCount() == 1u);
488 const Vector4 fullTextureRect(0.f, 0.f, 1.f, 1.f);
489 // test that the pixel area value defined in the visual property map is registered on renderer
490 Renderer renderer = gifView.GetRendererAt(0);
491 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
492 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION);
494 // test that the shader has the default pixel area value registered.
495 Shader shader = renderer.GetShader();
496 pixelAreaValue = shader.GetProperty(shader.GetPropertyIndex("pixelArea"));
497 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION);
499 // test that the uniform uses the pixelArea property on the renderer.
500 TestGlAbstraction& gl = application.GetGlAbstraction();
501 Vector4 pixelAreaUniform;
502 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
503 DALI_TEST_EQUALS(pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
505 // set the pixelArea property on the control
506 const Vector4 pixelAreaControl(-1.f, -1.f, 3.f, 3.f);
507 gifView.SetProperty(ImageView::Property::PIXEL_AREA, pixelAreaControl);
508 application.SendNotification();
509 application.Render(16);
511 // check the pixelArea property on the control
512 pixelAreaValue = gifView.GetProperty(gifView.GetPropertyIndex("pixelArea"));
513 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION);
514 // test that the uniform uses the pixelArea property on the control.
515 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
516 DALI_TEST_EQUALS(pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
521 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
523 ToolkitTestApplication application;
524 TestGlAbstraction& gl = application.GetGlAbstraction();
525 const std::vector<GLuint>& textures = gl.GetBoundTextures();
526 size_t numTextures = textures.size();
528 // Async loading, no atlasing for big size image
529 ImageView imageView = ImageView::New(gImage_600_RGB);
531 // By default, Aysnc loading is used
532 application.GetScene().Add(imageView);
533 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
534 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
536 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
538 application.SendNotification();
539 application.Render(16);
540 application.SendNotification();
542 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
543 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
548 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
550 ToolkitTestApplication application;
552 //Async loading, automatic atlasing for small size image
553 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
555 callStack.Enable(true);
557 Property::Map imageMap;
559 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
560 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
561 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
562 imageMap[ImageVisual::Property::ATLASING] = true;
564 ImageView imageView = ImageView::New();
565 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
566 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
568 // By default, Aysnc loading is used
569 // loading is not started if the actor is offScene
571 application.GetScene().Add(imageView);
572 application.SendNotification();
573 application.Render(16);
574 application.Render(16);
575 application.SendNotification();
577 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
578 application.SendNotification();
579 application.Render(16);
580 application.Render(16);
581 application.SendNotification();
583 // loading started, this waits for the loader thread for max 30 seconds
584 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
586 application.SendNotification();
587 application.Render(16);
589 callStack.Enable(false);
591 TraceCallStack::NamedParams params;
592 params["width"] << 34;
593 params["height"] << 34;
594 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
599 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
601 ToolkitTestApplication application;
603 //Async loading, automatic atlasing for small size image
604 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
606 callStack.Enable(true);
608 Property::Map asyncLoadingMap;
609 asyncLoadingMap["url"] = gImage_34_RGBA;
610 asyncLoadingMap["desiredHeight"] = 34;
611 asyncLoadingMap["desiredWidth"] = 34;
612 asyncLoadingMap["synchronousLoading"] = false;
613 asyncLoadingMap["atlasing"] = true;
615 ImageView imageView = ImageView::New();
616 imageView.SetProperty(ImageView::Property::IMAGE, asyncLoadingMap);
618 application.GetScene().Add(imageView);
619 application.SendNotification();
620 application.Render(16);
621 application.Render(16);
622 application.SendNotification();
624 // loading started, this waits for the loader thread for max 30 seconds
625 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
627 application.SendNotification();
628 application.Render(16);
630 callStack.Enable(false);
632 TraceCallStack::NamedParams params;
633 params["width"] << 34;
634 params["height"] << 34;
635 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
640 int UtcDaliImageViewSyncLoading(void)
642 ToolkitTestApplication application;
644 tet_infoline("ImageView Testing sync loading and size using index key property map");
646 Property::Map syncLoadingMap;
647 syncLoadingMap[ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
648 syncLoadingMap[ImageVisual::Property::ATLASING] = true;
650 // Sync loading, no atlasing for big size image
652 ImageView imageView = ImageView::New();
654 // Sync loading is used
655 syncLoadingMap[ImageVisual::Property::URL] = gImage_600_RGB;
656 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
659 // Sync loading, automatic atlasing for small size image
661 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
663 callStack.Enable(true);
665 ImageView imageView = ImageView::New();
667 // Sync loading is used
668 syncLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
669 syncLoadingMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
670 syncLoadingMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
671 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
673 application.GetScene().Add(imageView);
674 application.SendNotification();
675 application.Render(16);
677 TraceCallStack::NamedParams params;
678 params["width"] << 34;
679 params["height"] << 34;
680 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
687 int UtcDaliImageViewSyncLoading02(void)
689 ToolkitTestApplication application;
691 tet_infoline("ImageView Testing sync loading and size using string key property map");
693 // Sync loading, automatic atlasing for small size image
695 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
697 callStack.Enable(true);
699 ImageView imageView = ImageView::New();
701 // Sync loading is used
702 Property::Map syncLoadingMap;
703 syncLoadingMap["url"] = gImage_34_RGBA;
704 syncLoadingMap["desiredHeight"] = 34;
705 syncLoadingMap["desiredWidth"] = 34;
706 syncLoadingMap["synchronousLoading"] = true;
707 syncLoadingMap["atlasing"] = true;
708 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
710 application.GetScene().Add(imageView);
711 application.SendNotification();
712 application.Render(16);
714 TraceCallStack::NamedParams params;
715 params["width"] << 34;
716 params["height"] << 34;
717 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
724 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
726 ToolkitTestApplication application;
727 TestGlAbstraction& gl = application.GetGlAbstraction();
728 const std::vector<GLuint>& textures = gl.GetBoundTextures();
729 size_t numTextures = textures.size();
731 // Get encoded raw-buffer image and generate url
732 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
733 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
735 // Async loading, no atlasing for big size image
736 ImageView imageView = ImageView::New(url.GetUrl());
738 // By default, Aysnc loading is used
739 application.GetScene().Add(imageView);
740 imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
741 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
743 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
745 application.SendNotification();
746 application.Render(16);
747 application.SendNotification();
749 const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
750 DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
755 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
757 ToolkitTestApplication application;
759 // Get encoded raw-buffer image and generate url
760 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
761 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
762 ImageUrl url2 = Toolkit::Image::GenerateUrl(buffer);
764 // Generate url is not equal to url2
765 // NOTE : This behavior may changed when ImageUrl compare operator changed.
766 DALI_TEST_CHECK(url != url2);
767 // Generate url's string is equal to url2's string
768 DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
770 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
771 url2 = Toolkit::Image::GenerateUrl(buffer2);
773 // Check whethere two url are not equal
774 DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
776 // Async loading, automatic atlasing for small size image
777 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
779 callStack.Enable(true);
781 Property::Map imageMap;
783 imageMap[ImageVisual::Property::URL] = url.GetUrl();
784 imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
785 imageMap[ImageVisual::Property::DESIRED_WIDTH] = 34;
786 imageMap[ImageVisual::Property::ATLASING] = true;
788 ImageView imageView = ImageView::New();
789 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
790 imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
792 // By default, Aysnc loading is used
793 // loading is not started if the actor is offScene
795 application.GetScene().Add(imageView);
796 application.SendNotification();
797 application.Render(16);
798 application.Render(16);
799 application.SendNotification();
801 // Change url to url2
802 imageMap[ImageVisual::Property::URL] = url2.GetUrl();
803 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
805 imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
806 application.SendNotification();
807 application.Render(16);
808 application.Render(16);
809 application.SendNotification();
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.SendNotification();
815 application.Render(16);
817 callStack.Enable(false);
819 TraceCallStack::NamedParams params;
820 params["width"] << 34;
821 params["height"] << 34;
822 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
827 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
829 ToolkitTestApplication application;
831 tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
833 // Get encoded raw-buffer image and generate url
834 EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
835 ImageUrl url = Toolkit::Image::GenerateUrl(buffer);
837 // Sync loading, automatic atlasing for small size image
839 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
841 callStack.Enable(true);
843 ImageView imageView = ImageView::New();
845 // Sync loading is used
846 Property::Map syncLoadingMap;
847 syncLoadingMap["url"] = url.GetUrl();
848 syncLoadingMap["desiredHeight"] = 34;
849 syncLoadingMap["desiredWidth"] = 34;
850 syncLoadingMap["synchronousLoading"] = true;
851 syncLoadingMap["atlasing"] = true;
852 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
854 application.GetScene().Add(imageView);
855 application.SendNotification();
856 application.Render(16);
858 TraceCallStack::NamedParams params;
859 params["width"] << 34;
860 params["height"] << 34;
861 DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
869 int UtcDaliImageViewAddedTexture(void)
871 ToolkitTestApplication application;
873 tet_infoline("ImageView Testing image view with texture provided manager url");
875 ImageView imageView = ImageView::New();
877 // empty texture is ok, though pointless from app point of view
879 std::string url = TextureManager::AddTexture(empty);
880 DALI_TEST_CHECK(url.size() > 0u);
882 Property::Map propertyMap;
883 propertyMap[ImageVisual::Property::URL] = url;
884 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
886 application.GetScene().Add(imageView);
887 application.SendNotification();
888 application.Render();
893 int UtcDaliImageViewSizeWithBackground(void)
895 ToolkitTestApplication application;
899 ImageView imageView = ImageView::New();
901 imageView.SetProperty(Control::Property::BACKGROUND,
903 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
904 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
905 {ImageVisual::Property::DESIRED_WIDTH, width},
906 {ImageVisual::Property::DESIRED_HEIGHT, height},
909 application.GetScene().Add(imageView);
910 application.SendNotification();
911 application.Render();
913 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
914 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
919 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
921 ToolkitTestApplication application;
923 int widthBackground = 100;
924 int heightBackground = 200;
928 ImageView imageView = ImageView::New();
930 imageView.SetProperty(Control::Property::BACKGROUND,
932 {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
933 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
934 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
935 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground},
938 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio, 600x600 pixels
940 application.GetScene().Add(imageView);
941 application.SendNotification();
942 application.Render();
944 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
945 DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
950 int UtcDaliImageViewHeightForWidthBackground(void)
952 ToolkitTestApplication application;
954 int widthBackground = 100;
955 int heightBackground = 200;
957 ImageView imageView = ImageView::New();
959 imageView.SetProperty(Control::Property::BACKGROUND,
960 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
961 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
962 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
963 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}});
965 application.GetScene().Add(imageView);
966 application.SendNotification();
967 application.Render();
969 Control control = Control::DownCast(imageView);
970 DALI_TEST_CHECK(control);
971 DALI_TEST_EQUALS(imageView.GetHeightForWidth(123.f), control.GetHeightForWidth(123.f), TEST_LOCATION);
972 DALI_TEST_EQUALS(imageView.GetWidthForHeight(321.f), control.GetWidthForHeight(321.f), TEST_LOCATION);
977 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
979 ToolkitTestApplication application;
981 int widthBackground = 100;
982 int heightBackground = 200;
986 ImageView imageView = ImageView::New();
988 imageView.SetProperty(Control::Property::BACKGROUND,
989 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
990 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
991 {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
992 {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}}); // 1 to 2 ratio
994 imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio
996 application.GetScene().Add(imageView);
997 application.SendNotification();
998 application.Render();
1000 DALI_TEST_EQUALS(imageView.GetHeightForWidth(width), (float)height, TEST_LOCATION);
1001 DALI_TEST_EQUALS(imageView.GetWidthForHeight(height), (float)width, TEST_LOCATION);
1006 int UtcDaliImageViewSetImageUrl(void)
1008 ToolkitTestApplication application;
1010 ImageView imageView = ImageView::New();
1011 imageView.SetImage(TEST_IMAGE_FILE_NAME);
1012 TestUrl(imageView, TEST_IMAGE_FILE_NAME);
1014 imageView.SetImage(TEST_IMAGE_FILE_NAME2);
1015 TestUrl(imageView, TEST_IMAGE_FILE_NAME2);
1020 bool gResourceReadySignalFired = false;
1021 Vector3 gNaturalSize;
1023 void ResourceReadySignal(Control control)
1025 gResourceReadySignalFired = true;
1028 int UtcDaliImageViewCheckResourceReady(void)
1030 ToolkitTestApplication application;
1032 gResourceReadySignalFired = false;
1034 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1035 ImageView imageView = ImageView::New(TEST_GIF_FILE_NAME);
1037 imageView.SetProperty(Control::Property::BACKGROUND,
1038 {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1039 {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1040 {ImageVisual::Property::DESIRED_WIDTH, 100},
1041 {ImageVisual::Property::DESIRED_HEIGHT, 200}});
1043 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1045 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1047 application.GetScene().Add(imageView);
1049 // loading started, this waits for the loader thread
1050 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1052 application.SendNotification();
1053 application.Render(16);
1055 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1057 application.SendNotification();
1058 application.Render();
1060 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1062 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1067 int UtcDaliImageViewSetImageTypeChangesP(void)
1069 ToolkitTestApplication application;
1071 ImageView imageView = ImageView::New();
1072 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1074 application.GetScene().Add(imageView);
1078 Toolkit::Visual::Base visual;
1080 Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1081 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1083 application.SendNotification();
1084 application.Render(16);
1086 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1088 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1089 DALI_TEST_CHECK(!visual); // Visual should be invalid
1092 imageView.SetImage("TEST_URL");
1094 application.SendNotification();
1095 application.Render(16);
1097 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1098 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1100 DALI_TEST_CHECK(value.Get(url)); // Value should NOT be empty
1101 DALI_TEST_CHECK(!value.Get(map)); // Value should be empty
1102 DALI_TEST_CHECK(visual); // Visual should be valid
1105 imageView.SetImage("");
1107 application.SendNotification();
1108 application.Render(16);
1110 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1111 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1113 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1115 DALI_TEST_CHECK(map.Empty()); // Value should be empty
1116 DALI_TEST_CHECK(!visual); // Visual should be invalid
1118 // Set a URL in property map
1119 Property::Map propertyMap;
1120 propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1121 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1123 application.SendNotification();
1124 application.Render(16);
1126 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1127 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1129 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1130 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1131 DALI_TEST_CHECK(visual); // Visual should be valid
1133 // Set a URL in property map again
1134 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1135 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1137 application.SendNotification();
1138 application.Render(16);
1140 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1141 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1143 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1144 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1145 DALI_TEST_CHECK(visual); // Visual should be valid
1147 // Set an empty URL in property map
1148 propertyMap[ImageVisual::Property::URL] = std::string();
1149 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1151 application.SendNotification();
1152 application.Render(16);
1154 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1155 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1157 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1158 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1159 DALI_TEST_CHECK(!visual); // Visual should be invalid
1161 // Set a URL in property map again
1162 propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1163 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1165 application.SendNotification();
1166 application.Render(16);
1168 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1169 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1171 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1172 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1173 DALI_TEST_CHECK(visual); // Visual should be valid
1175 // Set an empty property map
1176 propertyMap.Clear();
1177 imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1179 application.SendNotification();
1180 application.Render(16);
1182 value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1183 visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1185 DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1186 DALI_TEST_CHECK(value.Get(map)); // Value should NOT be empty
1187 DALI_TEST_CHECK(map.Empty()); // But PropertyMap should be empty
1188 DALI_TEST_CHECK(!visual); // Visual should be invalid
1193 int UtcDaliImageViewResourceUrlP(void)
1195 ToolkitTestApplication application;
1197 ImageView imageView = ImageView::New();
1198 DALI_TEST_CHECK(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>().empty());
1200 imageView.SetProperty(ImageView::Property::IMAGE, "TestString");
1201 DALI_TEST_EQUALS(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>(), "TestString", TEST_LOCATION);
1206 int UtcDaliImageViewReplaceImage(void)
1208 ToolkitTestApplication application;
1210 gResourceReadySignalFired = false;
1212 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1213 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1215 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1217 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1219 application.GetScene().Add(imageView);
1221 application.SendNotification();
1222 application.Render(16);
1224 // loading started, this waits for the loader thread for max 30 seconds
1225 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1227 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1229 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1231 gResourceReadySignalFired = false;
1233 imageView.SetImage(TEST_IMAGE_2);
1235 application.SendNotification();
1236 application.Render(16);
1238 // loading started, this waits for the loader thread for max 30 seconds
1239 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1241 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1243 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1245 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1250 void OnRelayoutOverride(Size size)
1252 gNaturalSize = size; // Size Relayout is using
1255 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1257 ToolkitTestApplication application;
1259 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1260 ImageView imageView = ImageView::New(TEST_IMAGE_1);
1261 imageView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1263 DummyControl dummyControl = DummyControl::New(true);
1264 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1265 dummyControl.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
1267 dummyControl.Add(imageView);
1268 dummyImpl.SetRelayoutCallback(&OnRelayoutOverride);
1269 application.GetScene().Add(dummyControl);
1271 application.SendNotification();
1272 application.Render();
1274 // loading started, this waits for the loader thread for max 30 seconds
1275 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1277 DALI_TEST_EQUALS(gNaturalSize.width, 1024.0f, TEST_LOCATION);
1278 DALI_TEST_EQUALS(gNaturalSize.height, 1024.0f, TEST_LOCATION);
1280 gNaturalSize = Vector3::ZERO;
1282 imageView.SetImage(gImage_600_RGB);
1284 // Waiting for resourceReady so SendNotifcation not called here.
1286 // loading started, this waits for the loader thread for max 30 seconds
1287 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1289 // Trigger a potential relayout
1290 application.SendNotification();
1291 application.Render();
1293 DALI_TEST_EQUALS(gNaturalSize.width, 600.0f, TEST_LOCATION);
1294 DALI_TEST_EQUALS(gNaturalSize.height, 600.0f, TEST_LOCATION);
1299 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1301 tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1303 ToolkitTestApplication application;
1305 gResourceReadySignalFired = false;
1307 Property::Map imageMap;
1309 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1310 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1312 tet_infoline("Creating ImageView without URL so image does not start loading");
1313 ImageView imageView = ImageView::New();
1314 tet_infoline("Connect to image loaded signal before setting image");
1315 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1316 tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1317 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1319 // loading started, this waits for the loader thread
1320 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1322 application.SendNotification();
1323 application.Render(16);
1325 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1330 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1332 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1334 ToolkitTestApplication application;
1336 gResourceReadySignalFired = false;
1338 Property::Map imageMap;
1340 imageMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1341 imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1343 ImageView imageView = ImageView::New();
1344 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1345 imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1347 // loading started, this waits for the loader thread
1348 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1350 application.SendNotification();
1351 application.Render(16);
1353 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1354 gResourceReadySignalFired = false;
1356 ImageView imageViewWithExistingImage = ImageView::New();
1357 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1358 imageViewWithExistingImage.SetProperty(ImageView::Property::IMAGE, imageMap);
1360 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1365 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1367 tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1369 ToolkitTestApplication application;
1371 gResourceReadySignalFired = false;
1373 Property::Map imageImmediateLoadingMap;
1374 imageImmediateLoadingMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1375 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1377 tet_infoline("Immediate load an image");
1378 ImageView imageView = ImageView::New();
1379 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1380 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
1382 // loading started, this waits for the loader thread
1383 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1385 application.SendNotification();
1386 application.Render(16);
1388 tet_infoline("Check image loaded");
1389 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1390 gResourceReadySignalFired = false;
1392 tet_infoline("Create another ImageView with the same URL");
1393 ImageView imageViewWithExistingImage = ImageView::New(gImage_34_RGBA);
1394 tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1395 imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1397 application.GetScene().Add(imageViewWithExistingImage);
1399 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1404 int UtcDaliImageViewPaddingProperty(void)
1406 ToolkitTestApplication application;
1408 ImageView imageView = ImageView::New();
1409 Property::Map imagePropertyMap;
1410 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1411 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
1412 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1413 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1414 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1415 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1416 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1417 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1418 application.GetScene().Add(imageView);
1420 application.SendNotification();
1421 application.Render();
1423 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1425 ImageView childImage = ImageView::New();
1426 childImage.SetBackgroundColor(Color::BLACK);
1427 childImage.SetProperty(Actor::Property::SIZE, Vector2(10.f, 10.f));
1428 imageView.Add(childImage);
1430 application.SendNotification();
1431 application.Render();
1433 // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1434 DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
1436 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1437 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1438 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1439 Property::Map resultMap;
1440 imageVisual.CreatePropertyMap(resultMap);
1442 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1443 DALI_TEST_CHECK(transformValue);
1444 Property::Map* retMap = transformValue->GetMap();
1445 DALI_TEST_CHECK(retMap);
1447 // Image Visual should be positioned depending on ImageView's padding
1448 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1453 int UtcDaliImageViewPaddingProperty02(void)
1455 ToolkitTestApplication application;
1457 ImageView imageView = ImageView::New();
1458 Property::Map imagePropertyMap;
1459 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1460 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1461 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1462 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1463 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1464 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1465 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1466 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1467 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1468 application.GetScene().Add(imageView);
1470 application.SendNotification();
1471 application.Render();
1473 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1475 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1476 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1477 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1478 Property::Map resultMap;
1479 imageVisual.CreatePropertyMap(resultMap);
1481 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1482 DALI_TEST_CHECK(transformValue);
1483 Property::Map* retMap = transformValue->GetMap();
1484 DALI_TEST_CHECK(retMap);
1486 // Image Visual should be positioned depending on ImageView's padding
1487 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1492 int UtcDaliImageViewPaddingProperty03(void)
1494 tet_infoline("Test Setting Image Padding then removing it.");
1496 ToolkitTestApplication application;
1498 ImageView imageView = ImageView::New();
1499 Property::Map imagePropertyMap;
1500 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1501 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1502 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1503 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1504 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1505 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1506 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1507 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1508 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1509 application.GetScene().Add(imageView);
1511 application.SendNotification();
1512 application.Render();
1514 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1516 tet_infoline("Remove Padding and test Visual is position correctly");
1518 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1520 application.SendNotification();
1521 application.Render();
1523 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1524 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1525 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1526 Property::Map resultMap;
1527 imageVisual.CreatePropertyMap(resultMap);
1529 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1530 DALI_TEST_CHECK(transformValue);
1531 Property::Map* retMap = transformValue->GetMap();
1532 DALI_TEST_CHECK(retMap);
1534 // Image Visual should be positioned depending on ImageView's padding
1535 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1540 int UtcDaliImageViewPaddingProperty04(void)
1542 tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1544 ToolkitTestApplication application;
1546 ImageView imageView = ImageView::New();
1547 Property::Map imagePropertyMap;
1548 imagePropertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1549 imagePropertyMap[Toolkit::ImageVisual::Property::URL] = TEST_RESOURCE_DIR "/Kid1.svg";
1550 imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH] = 128;
1551 imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1552 imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FILL;
1553 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1554 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1555 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1556 imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1557 application.GetScene().Add(imageView);
1559 application.SendNotification();
1560 application.Render();
1562 DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1564 tet_infoline("Remove Padding and test Visual is position correctly");
1566 imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1568 application.SendNotification();
1569 application.Render();
1571 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1572 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1573 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1574 Property::Map resultMap;
1575 imageVisual.CreatePropertyMap(resultMap);
1577 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1578 DALI_TEST_CHECK(transformValue);
1579 Property::Map* retMap = transformValue->GetMap();
1580 DALI_TEST_CHECK(retMap);
1582 // Image Visual should be positioned depending on ImageView's padding
1583 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1588 int UtcDaliImageViewTransformTest01(void)
1590 tet_infoline("Test Setting a offset transform on the ImageView");
1592 ToolkitTestApplication application;
1594 ImageView imageView = ImageView::New();
1595 Property::Map imagePropertyMap;
1596 imagePropertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE)
1597 .Add(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/Kid1.svg")
1598 .Add(ImageVisual::Property::DESIRED_WIDTH, 120)
1599 .Add(ImageVisual::Property::DESIRED_HEIGHT, 120)
1600 .Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL)
1601 .Add(Visual::Property::TRANSFORM,
1602 Property::Map().Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1603 Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE))
1604 .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(8, 8)));
1606 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1607 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1608 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1609 application.GetScene().Add(imageView);
1611 application.SendNotification();
1612 application.Render();
1614 // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1615 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1616 Toolkit::Visual::Base imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1617 Property::Map resultMap;
1618 imageVisual.CreatePropertyMap(resultMap);
1620 Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1621 DALI_TEST_CHECK(transformValue);
1622 Property::Map* retMap = transformValue->GetMap();
1623 DALI_TEST_CHECK(retMap);
1625 // Image Visual should be positioned depending on ImageView's padding
1626 DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(8, 8), TEST_LOCATION);
1627 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);
1632 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1634 ToolkitTestApplication application;
1636 // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1637 ImageView imageView = ImageView::New();
1638 Property::Map imageMap;
1639 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
1640 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_34_RGBA;
1641 imageMap[Toolkit::ImageVisual::Property::ATLASING] = true;
1642 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1643 application.GetScene().Add(imageView);
1645 // Trigger a potential relayout
1646 application.SendNotification();
1647 application.Render();
1649 Vector3 naturalSize = imageView.GetNaturalSize();
1651 DALI_TEST_EQUALS(naturalSize.width, 34.0f, TEST_LOCATION);
1652 DALI_TEST_EQUALS(naturalSize.height, 34.0f, TEST_LOCATION);
1657 int UtcDaliImageViewFillMode(void)
1659 ToolkitTestApplication application;
1661 tet_infoline("Create an ImageVisual without padding and set the fill-mode to fill");
1663 ImageView imageView = ImageView::New();
1664 Property::Map imageMap;
1665 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1666 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB);
1667 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL);
1669 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1671 application.GetScene().Add(imageView);
1673 // Trigger a potential relayout
1674 application.SendNotification();
1675 application.Render();
1677 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1678 Property::Map returnedMap;
1679 visual.CreatePropertyMap(returnedMap);
1681 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1682 DALI_TEST_CHECK(value);
1683 Property::Map* map = value->GetMap();
1684 DALI_TEST_CHECK(map);
1686 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1687 DALI_TEST_CHECK(value);
1688 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION);
1690 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1691 DALI_TEST_CHECK(value);
1692 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1697 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1699 ToolkitTestApplication application;
1701 tet_infoline("Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )");
1702 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1704 ImageView imageView = ImageView::New();
1705 Property::Map imageMap;
1706 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1707 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1708 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
1710 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1711 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1713 application.GetScene().Add(imageView);
1715 // Trigger a potential relayout
1716 application.SendNotification();
1717 application.Render();
1719 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1720 Property::Map returnedMap;
1721 visual.CreatePropertyMap(returnedMap);
1723 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1724 DALI_TEST_CHECK(value);
1725 Property::Map* map = value->GetMap();
1726 DALI_TEST_CHECK(map);
1729 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1730 DALI_TEST_CHECK(value);
1731 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION);
1733 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1734 DALI_TEST_CHECK(value);
1735 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1737 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1738 DALI_TEST_CHECK(value);
1739 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
1744 int UtcDaliImageViewFittingModesFill(void)
1746 ToolkitTestApplication application;
1748 tet_infoline("Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )");
1749 tet_infoline(" There should be no need to change the transform, only size is changed to fit view");
1751 ImageView imageView = ImageView::New();
1752 Property::Map imageMap;
1753 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1754 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1755 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL);
1757 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1758 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1760 application.GetScene().Add(imageView);
1762 // Trigger a potential relayout
1763 application.SendNotification();
1764 application.Render();
1766 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1767 Property::Map returnedMap;
1768 visual.CreatePropertyMap(returnedMap);
1770 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1771 DALI_TEST_CHECK(value);
1772 Property::Map* map = value->GetMap();
1773 DALI_TEST_CHECK(map);
1775 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1776 DALI_TEST_CHECK(value);
1777 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Change the internal size according to the image view size
1779 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1780 DALI_TEST_CHECK(value);
1781 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1783 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1784 DALI_TEST_CHECK(value);
1785 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1790 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1792 ToolkitTestApplication application;
1794 tet_infoline("Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )");
1795 tet_infoline(" offset or size is the same as view, but adjust internally using pixelArea ");
1797 ImageView imageView = ImageView::New();
1798 Property::Map imageMap;
1799 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1800 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1801 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO);
1803 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1804 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 500));
1806 application.GetScene().Add(imageView);
1808 // Trigger a potential relayout
1809 application.SendNotification();
1810 application.Render();
1812 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1813 Property::Map returnedMap;
1814 visual.CreatePropertyMap(returnedMap);
1816 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1817 DALI_TEST_CHECK(value);
1818 Property::Map* map = value->GetMap();
1819 DALI_TEST_CHECK(map);
1822 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1823 DALI_TEST_CHECK(value);
1824 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 500), TEST_LOCATION); // Change the internal size according to the image view size
1826 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1827 DALI_TEST_CHECK(value);
1828 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1830 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1831 DALI_TEST_CHECK(value);
1832 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1837 int UtcDaliImageViewFittingModesCenter01(void)
1839 ToolkitTestApplication application;
1841 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [700,700] )");
1842 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1844 ImageView imageView = ImageView::New();
1845 Property::Map imageMap;
1846 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1847 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1848 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1850 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1851 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1853 application.GetScene().Add(imageView);
1855 // Trigger a potential relayout
1856 application.SendNotification();
1857 application.Render();
1859 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1860 Property::Map returnedMap;
1861 visual.CreatePropertyMap(returnedMap);
1863 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1864 DALI_TEST_CHECK(value);
1865 Property::Map* map = value->GetMap();
1866 DALI_TEST_CHECK(map);
1868 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1869 DALI_TEST_CHECK(value);
1870 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1872 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1873 DALI_TEST_CHECK(value);
1874 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1876 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1877 DALI_TEST_CHECK(value);
1878 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1883 int UtcDaliImageViewFittingModesCenter02(void)
1885 ToolkitTestApplication application;
1887 tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [500,500] )");
1888 tet_infoline(" There should be need to change the transform, offset is adjusted to fit inside");
1890 ImageView imageView = ImageView::New();
1891 Property::Map imageMap;
1892 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1893 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1894 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1896 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1897 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1899 application.GetScene().Add(imageView);
1901 // Trigger a potential relayout
1902 application.SendNotification();
1903 application.Render();
1905 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1906 Property::Map returnedMap;
1907 visual.CreatePropertyMap(returnedMap);
1909 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1910 DALI_TEST_CHECK(value);
1911 Property::Map* map = value->GetMap();
1912 DALI_TEST_CHECK(map);
1914 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1915 DALI_TEST_CHECK(value);
1916 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1918 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1919 DALI_TEST_CHECK(value);
1920 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1922 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1923 DALI_TEST_CHECK(value);
1924 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1929 int UtcDaliImageViewFittingModesFitHeight01(void)
1931 ToolkitTestApplication application;
1933 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )");
1935 ImageView imageView = ImageView::New();
1936 Property::Map imageMap;
1937 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1938 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1939 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1941 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1942 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1944 application.GetScene().Add(imageView);
1946 // Trigger a potential relayout
1947 application.SendNotification();
1948 application.Render();
1950 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1951 Property::Map returnedMap;
1952 visual.CreatePropertyMap(returnedMap);
1954 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1955 DALI_TEST_CHECK(value);
1956 Property::Map* map = value->GetMap();
1957 DALI_TEST_CHECK(map);
1959 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1960 DALI_TEST_CHECK(value);
1961 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 700), TEST_LOCATION); // Change the internal size according to the image view size
1963 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1964 DALI_TEST_CHECK(value);
1965 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1967 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1968 DALI_TEST_CHECK(value);
1969 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1974 int UtcDaliImageViewFittingModesFitHeight02(void)
1976 ToolkitTestApplication application;
1978 tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )");
1980 ImageView imageView = ImageView::New();
1981 Property::Map imageMap;
1982 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1983 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
1984 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1986 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1987 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
1989 application.GetScene().Add(imageView);
1991 // Trigger a potential relayout
1992 application.SendNotification();
1993 application.Render();
1995 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1996 Property::Map returnedMap;
1997 visual.CreatePropertyMap(returnedMap);
1999 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2000 DALI_TEST_CHECK(value);
2001 Property::Map* map = value->GetMap();
2002 DALI_TEST_CHECK(map);
2004 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2005 DALI_TEST_CHECK(value);
2006 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2008 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2009 DALI_TEST_CHECK(value);
2010 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2012 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2013 DALI_TEST_CHECK(value);
2014 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2019 int UtcDaliImageViewFittingModesFitWidth01(void)
2021 ToolkitTestApplication application;
2023 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )");
2025 ImageView imageView = ImageView::New();
2026 Property::Map imageMap;
2027 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2028 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2029 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2031 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2032 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2034 application.GetScene().Add(imageView);
2036 // Trigger a potential relayout
2037 application.SendNotification();
2038 application.Render();
2040 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2041 Property::Map returnedMap;
2042 visual.CreatePropertyMap(returnedMap);
2044 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2045 DALI_TEST_CHECK(value);
2046 Property::Map* map = value->GetMap();
2047 DALI_TEST_CHECK(map);
2049 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2050 DALI_TEST_CHECK(value);
2051 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2053 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2054 DALI_TEST_CHECK(value);
2055 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2057 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2058 DALI_TEST_CHECK(value);
2059 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
2064 int UtcDaliImageViewFittingModesFitWidth02(void)
2066 ToolkitTestApplication application;
2068 tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )");
2070 ImageView imageView = ImageView::New();
2071 Property::Map imageMap;
2072 imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2073 imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2074 imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2076 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2077 imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2079 application.GetScene().Add(imageView);
2081 // Trigger a potential relayout
2082 application.SendNotification();
2083 application.Render();
2085 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2086 Property::Map returnedMap;
2087 visual.CreatePropertyMap(returnedMap);
2089 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2090 DALI_TEST_CHECK(value);
2091 Property::Map* map = value->GetMap();
2092 DALI_TEST_CHECK(map);
2094 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2095 DALI_TEST_CHECK(value);
2096 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 600), TEST_LOCATION); // Change the internal size according to the image view size
2098 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2099 DALI_TEST_CHECK(value);
2100 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2102 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2103 DALI_TEST_CHECK(value);
2104 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2109 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2111 ToolkitTestApplication application;
2113 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2115 ImageView imageView = ImageView::New();
2117 // 1. Render using FittingMode::SHRINK_TO_FIT
2118 Property::Map imageMap;
2119 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2120 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2121 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2123 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2124 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2126 application.GetScene().Add(imageView);
2128 // Trigger a potential relayout
2129 application.SendNotification();
2130 application.Render();
2132 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2133 Property::Map returnedMap;
2134 visual.CreatePropertyMap(returnedMap);
2136 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2137 DALI_TEST_CHECK(value);
2138 Property::Map* map = value->GetMap();
2139 DALI_TEST_CHECK(map);
2141 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2142 DALI_TEST_CHECK(value);
2143 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2145 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2146 DALI_TEST_CHECK(value);
2147 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2149 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2150 DALI_TEST_CHECK(value);
2151 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2153 // 2. Render again using DevelVisaul::CENTER
2154 Property::Map imageMap2;
2155 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2156 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2157 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2159 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2160 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2162 application.GetScene().Add(imageView);
2164 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2166 // Trigger a potential relayout
2167 application.SendNotification();
2168 application.Render();
2170 returnedMap.Clear();
2171 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2173 visual.CreatePropertyMap(returnedMap);
2175 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2176 DALI_TEST_CHECK(value);
2177 map = value->GetMap();
2178 DALI_TEST_CHECK(map);
2180 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2181 DALI_TEST_CHECK(value);
2182 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2184 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2185 DALI_TEST_CHECK(value);
2186 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2188 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2189 DALI_TEST_CHECK(value);
2190 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2192 // 3. Render again using before fittingMode
2193 Property::Map imageMap3;
2194 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2195 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2196 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2198 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2199 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2201 application.GetScene().Add(imageView);
2203 // Trigger a potential relayout
2204 application.SendNotification();
2205 application.Render();
2207 returnedMap.Clear();
2208 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2209 visual.CreatePropertyMap(returnedMap);
2211 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2212 DALI_TEST_CHECK(value);
2213 map = value->GetMap();
2214 DALI_TEST_CHECK(map);
2216 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2217 DALI_TEST_CHECK(value);
2218 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2220 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2221 DALI_TEST_CHECK(value);
2222 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2224 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2225 DALI_TEST_CHECK(value);
2226 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2231 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2233 ToolkitTestApplication application;
2235 tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2237 ImageView imageView = ImageView::New();
2239 // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2240 Property::Map imageMap;
2241 imageMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2242 imageMap[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2243 imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2245 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2246 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2248 application.GetScene().Add(imageView);
2250 // Trigger a potential relayout
2251 application.SendNotification();
2252 application.Render();
2254 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2255 Property::Map returnedMap;
2256 visual.CreatePropertyMap(returnedMap);
2258 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2259 DALI_TEST_CHECK(value);
2260 Property::Map* map = value->GetMap();
2261 DALI_TEST_CHECK(map);
2263 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2264 DALI_TEST_CHECK(value);
2265 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2267 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2268 DALI_TEST_CHECK(value);
2269 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2271 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2272 DALI_TEST_CHECK(value);
2273 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2275 // 2. Render again using DevelVisaul::CENTER
2276 Property::Map imageMap2;
2277 imageMap2[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2278 imageMap2[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2279 imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2281 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2282 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2284 application.GetScene().Add(imageView);
2286 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2288 // Trigger a potential relayout
2289 application.SendNotification();
2290 application.Render();
2292 returnedMap.Clear();
2293 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2295 visual.CreatePropertyMap(returnedMap);
2297 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2298 DALI_TEST_CHECK(value);
2299 map = value->GetMap();
2300 DALI_TEST_CHECK(map);
2302 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2303 DALI_TEST_CHECK(value);
2304 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2306 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2307 DALI_TEST_CHECK(value);
2308 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2310 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2311 DALI_TEST_CHECK(value);
2312 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2314 // 3. Render again using before fittingMode
2315 Property::Map imageMap3;
2316 imageMap3[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2317 imageMap3[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
2318 imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2320 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2321 imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2323 application.GetScene().Add(imageView);
2325 // Trigger a potential relayout
2326 application.SendNotification();
2327 application.Render();
2329 returnedMap.Clear();
2330 visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2331 visual.CreatePropertyMap(returnedMap);
2333 value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2334 DALI_TEST_CHECK(value);
2335 map = value->GetMap();
2336 DALI_TEST_CHECK(map);
2338 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2339 DALI_TEST_CHECK(value);
2340 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2342 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2343 DALI_TEST_CHECK(value);
2344 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2346 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2347 DALI_TEST_CHECK(value);
2348 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2353 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2355 ToolkitTestApplication application;
2357 tet_infoline("Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )");
2359 ImageView imageView = ImageView::New();
2360 Property::Map imageMap;
2361 imageMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE);
2362 imageMap.Add(Toolkit::ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME); // 249x169 image
2364 imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2365 imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
2367 application.GetScene().Add(imageView);
2369 // Trigger a potential relayout
2370 application.SendNotification();
2371 application.Render();
2373 Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2374 Property::Map returnedMap;
2375 visual.CreatePropertyMap(returnedMap);
2377 Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2378 DALI_TEST_CHECK(value);
2379 Property::Map* map = value->GetMap();
2380 DALI_TEST_CHECK(map);
2382 value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2383 DALI_TEST_CHECK(value);
2384 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Relative size so will take up 100%
2386 value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2387 DALI_TEST_CHECK(value);
2388 DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2390 value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2391 DALI_TEST_CHECK(value);
2392 DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2397 int UtcDaliImageViewCustomShader(void)
2399 ToolkitTestApplication application;
2401 // Set a custom shader with an image url
2403 Property::Map properties;
2404 Property::Map shader;
2405 const std::string vertexShader = "Foobar";
2406 const std::string fragmentShader = "Foobar";
2407 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2408 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2410 properties[Visual::Property::TYPE] = Visual::IMAGE;
2411 properties[Visual::Property::SHADER] = shader;
2412 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2414 ImageView imageView = ImageView::New();
2415 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2417 application.GetScene().Add(imageView);
2419 application.SendNotification();
2420 application.Render();
2422 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2424 Renderer renderer = imageView.GetRendererAt(0);
2425 Shader shader2 = renderer.GetShader();
2426 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2427 Property::Map* map = value.GetMap();
2428 DALI_TEST_CHECK(map);
2430 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2431 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2433 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2434 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2437 // Set a custom shader after setting an image url
2439 Property::Map properties;
2440 Property::Map shader;
2441 const std::string vertexShader = "Foobar";
2442 const std::string fragmentShader = "Foobar";
2443 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2444 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2446 properties[Visual::Property::SHADER] = shader;
2448 ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
2449 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2451 application.GetScene().Add(imageView);
2453 application.SendNotification();
2454 application.Render();
2456 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2458 Renderer renderer = imageView.GetRendererAt(0);
2459 Shader shader2 = renderer.GetShader();
2460 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2461 Property::Map* map = value.GetMap();
2462 DALI_TEST_CHECK(map);
2464 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2465 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2467 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2468 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2471 // Set a custom shader before setting an image url
2473 Property::Map properties;
2474 Property::Map shader;
2475 const std::string vertexShader = "Foobar";
2476 const std::string fragmentShader = "Foobar";
2477 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2478 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2480 properties[Visual::Property::SHADER] = shader;
2482 ImageView imageView = ImageView::New();
2483 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2484 imageView.SetProperty(ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME);
2486 application.GetScene().Add(imageView);
2488 application.SendNotification();
2489 application.Render();
2490 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2492 Renderer renderer = imageView.GetRendererAt(0);
2493 Shader shader2 = renderer.GetShader();
2494 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2495 Property::Map* map = value.GetMap();
2496 DALI_TEST_CHECK(map);
2498 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2499 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2501 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2502 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2505 // Set a custom shader after setting a property map
2507 Property::Map properties;
2508 Property::Map shader;
2509 const std::string vertexShader = "Foobar";
2510 const std::string fragmentShader = "Foobar";
2511 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2512 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2514 properties[Visual::Property::SHADER] = shader;
2516 Property::Map properties1;
2517 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2518 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2520 ImageView imageView = ImageView::New();
2521 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2522 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2524 application.GetScene().Add(imageView);
2526 application.SendNotification();
2527 application.Render();
2528 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2530 Renderer renderer = imageView.GetRendererAt(0);
2531 Shader shader2 = renderer.GetShader();
2532 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2533 Property::Map* map = value.GetMap();
2534 DALI_TEST_CHECK(map);
2536 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2537 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2539 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2540 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2543 // Set a custom shader before setting a property map
2545 Property::Map properties;
2546 Property::Map shader;
2547 const std::string vertexShader = "Foobar";
2548 const std::string fragmentShader = "Foobar";
2549 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2550 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2552 properties[Visual::Property::SHADER] = shader;
2554 Property::Map properties1;
2555 properties1[Visual::Property::TYPE] = Visual::IMAGE;
2556 properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2558 ImageView imageView = ImageView::New();
2559 imageView.SetProperty(ImageView::Property::IMAGE, properties);
2560 imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2562 application.GetScene().Add(imageView);
2564 application.SendNotification();
2565 application.Render();
2566 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2568 Renderer renderer = imageView.GetRendererAt(0);
2569 Shader shader2 = renderer.GetShader();
2570 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
2571 Property::Map* map = value.GetMap();
2572 DALI_TEST_CHECK(map);
2574 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2575 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2577 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2578 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2586 static int gFailCounter = 0;
2587 const int MAX_RETRIES(3);
2589 void ReloadImage(ImageView imageView)
2591 Property::Map imageImmediateLoadingMap;
2592 imageImmediateLoadingMap[ImageVisual::Property::URL] = "Non-existant-image.jpg";
2593 imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
2595 tet_infoline("Immediate load an image");
2596 imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
2599 void ResourceFailedReload(Control control)
2602 if(gFailCounter < MAX_RETRIES)
2604 ReloadImage(ImageView::DownCast(control));
2609 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2611 tet_infoline("Test reloading failed image from within signal handler.");
2613 ToolkitTestApplication application;
2617 ImageView imageView = ImageView::New();
2618 imageView.ResourceReadySignal().Connect(&ResourceFailedReload);
2619 DALI_TEST_EQUALS(gFailCounter, 0, TEST_LOCATION);
2620 ReloadImage(imageView);
2622 // loading started, this waits for the loader thread to complete
2623 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2624 application.SendNotification();
2626 DALI_TEST_EQUALS(gFailCounter, 1, TEST_LOCATION);
2628 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2629 application.SendNotification();
2631 DALI_TEST_EQUALS(gFailCounter, 2, TEST_LOCATION);
2633 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2634 application.SendNotification();
2635 DALI_TEST_EQUALS(gFailCounter, 3, TEST_LOCATION);
2640 int UtcDaliImageViewLoadRemoteSVG(void)
2642 tet_infoline("Test load from a remote server.");
2644 ToolkitTestApplication application;
2645 Toolkit::ImageView imageView;
2646 imageView = Toolkit::ImageView::New();
2647 imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2648 // Victor. Temporary (or permanent?) update as the url above seems not to work from time to time ...
2649 // imageView.SetImage("https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/SVG_logo.svg/64px-SVG_logo.svg.png");
2650 imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2651 imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2652 imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2653 imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2655 application.GetScene().Add(imageView);
2657 DALI_TEST_CHECK(imageView);
2659 DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2661 application.SendNotification();
2663 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2665 application.SendNotification();
2666 application.Render();
2668 DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2673 int UtcDaliImageViewSyncSVGLoading(void)
2675 ToolkitTestApplication application;
2677 tet_infoline("ImageView Testing SVG image sync loading");
2679 // Sync loading, automatic atlasing for small size image
2681 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2683 callStack.Enable(true);
2685 ImageView imageView = ImageView::New();
2687 // Sync loading is used
2688 Property::Map syncLoadingMap;
2689 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2690 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2691 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2692 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2694 application.GetScene().Add(imageView);
2695 DALI_TEST_CHECK(imageView);
2697 application.SendNotification();
2698 application.Render(16);
2699 Vector3 naturalSize = imageView.GetNaturalSize();
2701 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2702 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2707 int UtcDaliImageViewAsyncSVGLoading(void)
2709 ToolkitTestApplication application;
2711 tet_infoline("ImageView Testing SVG image async loading");
2713 // Sync loading, automatic atlasing for small size image
2715 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2717 callStack.Enable(true);
2719 ImageView imageView = ImageView::New();
2721 // Sync loading is used
2722 Property::Map syncLoadingMap;
2723 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2724 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2725 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2726 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2728 application.GetScene().Add(imageView);
2729 DALI_TEST_CHECK(imageView);
2731 application.SendNotification();
2732 application.Render(16);
2733 Vector3 naturalSize = imageView.GetNaturalSize();
2735 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2736 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2741 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2743 ToolkitTestApplication application;
2745 tet_infoline("ImageView Testing SVG image async loading");
2747 // Sync loading, automatic atlasing for small size image
2749 TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2751 callStack.Enable(true);
2753 ImageView imageView = ImageView::New();
2755 // Sync loading is used
2756 Property::Map syncLoadingMap;
2757 syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2758 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2760 // Check to set invalid value
2761 // The SYNCHRONOUS_LOADING property must be set to the bool value.
2762 // Check if error log is outputted when setting other value like string.
2763 // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2764 syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5));
2765 imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2767 application.GetScene().Add(imageView);
2768 DALI_TEST_CHECK(imageView);
2770 application.SendNotification();
2771 application.Render(16);
2772 Vector3 naturalSize = imageView.GetNaturalSize();
2773 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2774 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2776 Property::Value value = imageView.GetProperty(ImageView::Property::IMAGE);
2777 Property::Map* map = value.GetMap();
2778 DALI_TEST_CHECK(map);
2780 Property::Value* sync = map->Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING);
2781 DALI_TEST_CHECK(sync);
2782 DALI_TEST_EQUALS(false, sync->Get<bool>(), TEST_LOCATION);
2787 int UtcDaliImageViewSvgLoadingFailure(void)
2789 ToolkitTestApplication application;
2791 // Local svg file - invalid file path
2793 gResourceReadySignalFired = false;
2795 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2796 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2797 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2799 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2801 application.GetScene().Add(imageView);
2803 application.SendNotification();
2804 application.Render(16);
2806 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2807 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2808 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2811 // Local svg file - invalid file
2813 gResourceReadySignalFired = false;
2815 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.svg");
2816 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2817 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2819 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2821 application.GetScene().Add(imageView);
2823 application.SendNotification();
2824 application.Render(16);
2826 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2827 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2828 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2833 gResourceReadySignalFired = false;
2835 ImageView imageView = ImageView::New("https://bar.org/foobar.svg");
2836 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2837 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2839 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2841 application.GetScene().Add(imageView);
2843 application.SendNotification();
2845 // loading started, this waits for the loader thread
2846 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2848 application.SendNotification();
2849 application.Render(16);
2851 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2852 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2853 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2859 int UtcDaliImageViewSvgRasterizationFailure(void)
2861 ToolkitTestApplication application;
2863 gResourceReadySignalFired = false;
2865 ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/svg1.svg");
2866 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2867 imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2869 DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2871 application.GetScene().Add(imageView);
2873 application.SendNotification();
2875 // loading started, this waits for the loader thread
2876 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2878 application.SendNotification();
2879 application.Render(16);
2881 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2882 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2883 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::READY, TEST_LOCATION);
2886 gResourceReadySignalFired = false;
2889 imageView.SetProperty(Actor::Property::SIZE, Vector2(0.f, 0.f));
2891 application.SendNotification();
2893 // rasterization started, this waits for the rasterize thread
2894 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2896 application.SendNotification();
2897 application.Render(16);
2899 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2900 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2901 // Fail to rasterize because the size is 0.
2902 DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2907 int UtcDaliImageViewTVGLoading(void)
2909 ToolkitTestApplication application;
2911 tet_infoline("ImageView Testing TVG image loading");
2914 ImageView imageView = ImageView::New();
2916 imageView.SetImage(TEST_RESOURCE_DIR "/test.tvg");
2918 application.GetScene().Add(imageView);
2919 DALI_TEST_CHECK(imageView);
2920 Vector3 naturalSize = imageView.GetNaturalSize();
2922 DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2923 DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2927 int UtcDaliImageViewImageLoadFailure01(void)
2929 ToolkitTestApplication application;
2931 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
2932 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
2933 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
2934 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
2936 std::string brokenUrl;
2937 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
2938 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
2940 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
2941 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
2943 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
2944 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
2946 ImageView imageView = ImageView::New("invalidUrl.png");
2947 imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2949 application.GetScene().Add(imageView);
2950 application.SendNotification();
2951 application.Render(16);
2953 // loading started, this waits for the loader thread
2954 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2959 int UtcDaliImageViewImageLoadFailure02(void)
2961 ToolkitTestApplication application;
2963 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
2964 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
2965 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
2966 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
2968 std::string brokenUrl;
2969 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
2970 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
2972 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
2973 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
2975 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
2976 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
2978 ImageView imageView = ImageView::New("invalidUrl.png");
2979 imageView.SetProperty(Actor::Property::SIZE, Vector2(30.f, 30.f));
2980 application.GetScene().Add(imageView);
2981 application.SendNotification();
2982 application.Render(16);
2984 // loading started, this waits for the loader thread
2985 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2990 int UtcDaliImageViewImageLoadFailure03(void)
2992 ToolkitTestApplication application;
2994 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
2995 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
2996 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
2998 std::string brokenUrl;
2999 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3000 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3002 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3003 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3005 ImageView imageView = ImageView::New("invalidUrl.png");
3006 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3007 application.GetScene().Add(imageView);
3008 application.SendNotification();
3009 application.Render(16);
3011 // loading started, this waits for the loader thread
3012 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3017 int UtcDaliImageViewImageLoadFailure04(void)
3019 ToolkitTestApplication application;
3021 ImageView imageView = ImageView::New("invalidUrl.png");
3022 imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3023 application.GetScene().Add(imageView);
3024 application.SendNotification();
3025 application.Render(16);
3027 // loading started, this waits for the loader thread
3028 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3030 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3031 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3032 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3033 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3035 ImageView imageView2 = ImageView::New("invalidUrl.png");
3036 imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3037 application.GetScene().Add(imageView2);
3039 std::string brokenUrl;
3040 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3041 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3043 brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3044 DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3046 application.SendNotification();
3047 application.Render(16);
3049 // loading started, this waits for the loader thread
3050 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3052 DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3054 ImageView imageView3 = ImageView::New("invalidUrl.png");
3055 imageView3.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3056 application.GetScene().Add(imageView3);
3058 application.SendNotification();
3059 application.Render(16);
3061 // loading started, this waits for the loader thread
3062 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3069 static int gResourceReadySignalCounter = 0;
3071 void OnResourceReadySignal01(Control control)
3073 gResourceReadySignalCounter++;
3075 if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3077 if(gResourceReadySignalCounter == 1)
3080 // It makes the first new visual be deleted immediately
3081 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3082 ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3085 else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3087 // Make the resource ready immediately
3088 control[ImageView::Property::IMAGE] = TEST_RESOURCE_DIR "/svg1.svg";
3092 void OnResourceReadySignal02(Control control)
3094 if(++gResourceReadySignalCounter == 1)
3096 // It makes the first new visual be deleted immediately
3097 // The first image will not be loaded.
3098 control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB).Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3099 control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3103 ImageView gImageView1;
3104 ImageView gImageView2;
3105 ImageView gImageView3;
3107 void OnResourceReadySignal03(Control control)
3109 if(gResourceReadySignalCounter == 0)
3112 // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3113 gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3115 // 2. Load a new image
3116 gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3118 // 3. Use the new image again
3119 gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3120 gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3122 else if(gResourceReadySignalCounter == 1)
3124 // This is called from TextureManager::ProcessQueuedTextures().
3125 gImageView1.Unparent();
3126 gImageView1.Reset();
3128 gResourceReadySignalCounter++;
3133 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3135 tet_infoline("Test setting image from within signal handler.");
3137 ToolkitTestApplication application;
3139 gResourceReadySignalCounter = 0;
3141 ImageView imageView = ImageView::New(gImage_34_RGBA);
3142 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal01);
3144 application.GetScene().Add(imageView);
3146 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3148 application.SendNotification();
3149 application.Render();
3151 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3153 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3156 gResourceReadySignalCounter = 0;
3158 imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3160 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3162 application.SendNotification();
3163 application.Render();
3165 // Run idle callback
3166 application.RunIdles();
3168 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3170 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3175 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
3177 tet_infoline("Test setting image from within signal handler.");
3179 ToolkitTestApplication application;
3181 gResourceReadySignalCounter = 0;
3183 ImageView imageView = ImageView::New(gImage_34_RGBA);
3184 imageView.ResourceReadySignal().Connect(&OnResourceReadySignal02);
3186 application.GetScene().Add(imageView);
3188 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3190 application.SendNotification();
3191 application.Render();
3193 // Wait for loading an image
3194 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3196 DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3198 DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3203 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3205 tet_infoline("Test setting image from within signal handler.");
3207 ToolkitTestApplication application;
3209 gResourceReadySignalCounter = 0;
3211 gImageView1 = ImageView::New(gImage_34_RGBA);
3212 application.GetScene().Add(gImageView1);
3215 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3217 gImageView2 = ImageView::New(gImage_600_RGB);
3218 gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3219 application.GetScene().Add(gImageView2);
3221 gImageView3 = ImageView::New();
3222 application.GetScene().Add(gImageView3);
3224 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3226 application.SendNotification();
3227 application.Render();