Call ResourceReady callback even image loading failed.
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ImageView.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <unistd.h>
19 #include <sstream>
20
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
23
24 #include <dali-toolkit-test-suite-utils.h>
25 #include <toolkit-event-thread-callback.h>
26 #include "dummy-control.h"
27
28 #include <test-encoded-image-buffer.h>
29 #include <test-native-image.h>
30
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/animated-image-visual-actions-devel.h>
37 #include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
38 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
39 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
40 #include <dali-toolkit/public-api/image-loader/image-url.h>
41 #include <dali-toolkit/public-api/image-loader/image.h>
42 #include <dali/devel-api/scripting/scripting.h>
43
44 using namespace Dali;
45 using namespace Toolkit;
46
47 void utc_dali_toolkit_image_view_startup(void)
48 {
49   test_return_value = TET_UNDEF;
50 }
51
52 void utc_dali_toolkit_image_view_cleanup(void)
53 {
54   test_return_value = TET_PASS;
55 }
56
57 namespace
58 {
59 const char* TEST_IMAGE_FILE_NAME  = "gallery_image_01.jpg";
60 const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
61
62 const char* TEST_IMAGE_1 = TEST_RESOURCE_DIR "/TB-gloss.png";
63 const char* TEST_IMAGE_2 = TEST_RESOURCE_DIR "/tb-norm.png";
64
65 const char* TEST_BROKEN_IMAGE_DEFAULT = TEST_RESOURCE_DIR "/broken.png";
66 const char* TEST_BROKEN_IMAGE_S       = TEST_RESOURCE_DIR "/broken_s.9.png";
67 const char* TEST_BROKEN_IMAGE_M       = TEST_RESOURCE_DIR "/broken_m.9.png";
68 const char* TEST_BROKEN_IMAGE_L       = TEST_RESOURCE_DIR "/broken_l.9.png";
69 const char* TEST_BROKEN_IMAGE_01      = TEST_RESOURCE_DIR "/button-up.9.png";
70 const char* TEST_BROKEN_IMAGE_02      = TEST_RESOURCE_DIR "/heartsframe.9.png";
71
72 // resolution: 34*34, pixel format: RGBA8888
73 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
74 // resolution: 600*600, pixel format: RGB888
75 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
76
77 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
78 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
79
80 const char* TEST_SVG_FILE_NAME                   = TEST_RESOURCE_DIR "/svg1.svg";
81 const char* TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
82
83 void TestUrl(ImageView imageView, const std::string url)
84 {
85   Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
86
87   std::string urlActual;
88   DALI_TEST_CHECK(value.Get(urlActual));
89   DALI_TEST_EQUALS(urlActual, url, TEST_LOCATION);
90 }
91
92 } // namespace
93
94 int UtcDaliImageViewNewP(void)
95 {
96   ToolkitTestApplication application;
97
98   ImageView imageView = ImageView::New();
99
100   DALI_TEST_CHECK(imageView);
101
102   END_TEST;
103 }
104
105 int UtcDaliImageViewNewUrlP(void)
106 {
107   ToolkitTestApplication application;
108
109   ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
110   DALI_TEST_CHECK(imageView);
111
112   TestUrl(imageView, TEST_IMAGE_FILE_NAME);
113
114   END_TEST;
115 }
116
117 int UtcDaliImageViewConstructorP(void)
118 {
119   ToolkitTestApplication application;
120
121   ImageView imageView;
122
123   DALI_TEST_CHECK(!imageView);
124
125   END_TEST;
126 }
127
128 int UtcDaliImageViewCopyConstructorP(void)
129 {
130   ToolkitTestApplication application;
131
132   // Initialize an object, ref count == 1
133   ImageView imageView = ImageView::New();
134
135   ImageView copy(imageView);
136   DALI_TEST_CHECK(copy);
137
138   END_TEST;
139 }
140
141 int UtcDaliImageViewMoveConstructor(void)
142 {
143   ToolkitTestApplication application;
144
145   ImageView imageView = ImageView::New();
146   DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
147   imageView.SetProperty(Actor::Property::SENSITIVE, false);
148   DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
149
150   ImageView moved = std::move(imageView);
151   DALI_TEST_CHECK(moved);
152   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
153   DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
154   DALI_TEST_CHECK(!imageView);
155
156   END_TEST;
157 }
158
159 int UtcDaliImageViewAssignmentOperatorP(void)
160 {
161   ToolkitTestApplication application;
162
163   ImageView imageView = ImageView::New();
164
165   ImageView copy(imageView);
166   DALI_TEST_CHECK(copy);
167   DALI_TEST_EQUALS(imageView, copy, TEST_LOCATION);
168
169   END_TEST;
170 }
171
172 int UtcDaliImageViewMoveAssignment(void)
173 {
174   ToolkitTestApplication application;
175
176   ImageView imageView = ImageView::New();
177   DALI_TEST_EQUALS(1, imageView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
178   imageView.SetProperty(Actor::Property::SENSITIVE, false);
179   DALI_TEST_CHECK(false == imageView.GetProperty<bool>(Actor::Property::SENSITIVE));
180
181   ImageView moved;
182   moved = std::move(imageView);
183   DALI_TEST_CHECK(moved);
184   DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
185   DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
186   DALI_TEST_CHECK(!imageView);
187
188   END_TEST;
189 }
190
191 int UtcDaliImageViewDownCastP(void)
192 {
193   ToolkitTestApplication application;
194
195   ImageView imageView = ImageView::New();
196
197   BaseHandle object(imageView);
198
199   ImageView imageView2 = ImageView::DownCast(object);
200   DALI_TEST_CHECK(imageView2);
201
202   ImageView imageView3 = DownCast<ImageView>(object);
203   DALI_TEST_CHECK(imageView3);
204
205   END_TEST;
206 }
207
208 int UtcDaliImageViewDownCastN(void)
209 {
210   ToolkitTestApplication application;
211
212   BaseHandle unInitializedObject;
213
214   ImageView imageView1 = ImageView::DownCast(unInitializedObject);
215   DALI_TEST_CHECK(!imageView1);
216
217   ImageView imageView2 = DownCast<ImageView>(unInitializedObject);
218   DALI_TEST_CHECK(!imageView2);
219
220   END_TEST;
221 }
222
223 int UtcDaliImageViewTypeRegistry(void)
224 {
225   ToolkitTestApplication application;
226
227   TypeRegistry typeRegistry = TypeRegistry::Get();
228   DALI_TEST_CHECK(typeRegistry);
229
230   TypeInfo typeInfo = typeRegistry.GetTypeInfo("ImageView");
231   DALI_TEST_CHECK(typeInfo);
232
233   BaseHandle handle = typeInfo.CreateInstance();
234   DALI_TEST_CHECK(handle);
235
236   ImageView imageView = ImageView::DownCast(handle);
237   DALI_TEST_CHECK(imageView);
238
239   END_TEST;
240 }
241
242 int UtcDaliImageViewSetGetProperty01(void)
243 {
244   ToolkitTestApplication application;
245
246   ImageView imageView = ImageView::New();
247
248   Property::Index idx = imageView.GetPropertyIndex("image");
249   DALI_TEST_EQUALS(idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION);
250
251   imageView.SetProperty(idx, TEST_IMAGE_FILE_NAME);
252   TestUrl(imageView, TEST_IMAGE_FILE_NAME);
253
254   END_TEST;
255 }
256
257 int UtcDaliImageViewPreMultipliedAlphaPng(void)
258 {
259   ToolkitTestApplication application;
260
261   // Set up trace debug
262   TestGlAbstraction& gl           = application.GetGlAbstraction();
263   TraceCallStack&    textureTrace = gl.GetTextureTrace();
264   textureTrace.Enable(true);
265
266   Property::Map imageMap;
267   imageMap[ImageVisual::Property::URL]            = gImage_34_RGBA;
268   imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
269
270   ImageView imageView1 = ImageView::New();
271   imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
272
273   application.GetScene().Add(imageView1);
274
275   Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
276   bool            enable;
277   DALI_TEST_CHECK(value.Get(enable));
278   DALI_TEST_CHECK(enable); // Default value is true
279
280   // loading started, this waits for the loader thread for max 30 seconds
281   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
282
283   application.SendNotification();
284   application.Render();
285
286   value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
287   DALI_TEST_CHECK(value.Get(enable));
288   DALI_TEST_CHECK(enable); // Keep true
289
290   // conventional alpha blending
291   Renderer renderer1 = imageView1.GetRendererAt(0);
292   value              = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
293   DALI_TEST_CHECK(value.Get(enable));
294   DALI_TEST_CHECK(enable);
295
296   int srcFactorRgb    = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
297   int destFactorRgb   = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
298   int srcFactorAlpha  = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
299   int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
300   DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
301   DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
302   DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
303   DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
304
305   DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
306   textureTrace.Reset();
307
308   // Disable pre-multiplied alpha blending
309   imageView1.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
310
311   // Reload the image
312   Property::Map attributes;
313   DevelControl::DoAction(imageView1, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
314
315   // loading started, this waits for the loader thread for max 30 seconds
316   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
317
318   application.SendNotification();
319   application.Render();
320
321   value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
322   DALI_TEST_CHECK(value.Get(enable));
323   DALI_TEST_CHECK(!enable);
324
325   // conventional alpha blending
326   value = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
327   DALI_TEST_CHECK(value.Get(enable));
328   DALI_TEST_CHECK(!enable);
329
330   srcFactorRgb    = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
331   destFactorRgb   = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
332   srcFactorAlpha  = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
333   destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
334   DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
335   DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
336   DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
337   DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
338
339   DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
340   textureTrace.Reset();
341
342   // Make a new ImageView using the same image
343   ImageView imageView2 = ImageView::New();
344   imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
345
346   application.GetScene().Add(imageView2);
347
348   application.SendNotification();
349   application.Render();
350
351   Renderer renderer2 = imageView2.GetRendererAt(0);
352   value              = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
353   DALI_TEST_CHECK(value.Get(enable));
354   DALI_TEST_CHECK(enable);
355
356   srcFactorRgb    = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
357   destFactorRgb   = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
358   srcFactorAlpha  = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
359   destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
360   DALI_TEST_CHECK(srcFactorRgb == BlendFactor::ONE);
361   DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
362   DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
363   DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
364
365   DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
366
367   END_TEST;
368 }
369
370 int UtcDaliImageViewPreMultipliedAlphaJpg(void)
371 {
372   ToolkitTestApplication application;
373
374   // Set up trace debug
375   TestGlAbstraction& gl           = application.GetGlAbstraction();
376   TraceCallStack&    textureTrace = gl.GetTextureTrace();
377   textureTrace.Enable(true);
378
379   Property::Map imageMap;
380   imageMap[ImageVisual::Property::URL]            = gImage_600_RGB;
381   imageMap[ImageVisual::Property::RELEASE_POLICY] = ImageVisual::ReleasePolicy::NEVER; // To keep the texture cache
382
383   ImageView imageView1 = ImageView::New();
384   imageView1.SetProperty(ImageView::Property::IMAGE, imageMap);
385
386   application.GetScene().Add(imageView1);
387
388   Property::Value value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
389   bool            enable;
390   DALI_TEST_CHECK(value.Get(enable));
391   DALI_TEST_CHECK(enable); // Default value is true
392
393   // loading started, this waits for the loader thread for max 30 seconds
394   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
395
396   application.SendNotification();
397   application.Render();
398
399   value = imageView1.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
400   DALI_TEST_CHECK(value.Get(enable));
401   DALI_TEST_CHECK(!enable); // Should be false after loading
402
403   // conventional alpha blending
404   Renderer renderer1 = imageView1.GetRendererAt(0);
405   value              = renderer1.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
406   DALI_TEST_CHECK(value.Get(enable));
407   DALI_TEST_CHECK(!enable);
408
409   int srcFactorRgb    = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
410   int destFactorRgb   = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
411   int srcFactorAlpha  = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
412   int destFactorAlpha = renderer1.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
413   DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
414   DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
415   DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
416   DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
417
418   DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION); // A new texture should be generated.
419   textureTrace.Reset();
420
421   ImageView imageView2 = ImageView::New();
422   imageView2.SetProperty(ImageView::Property::IMAGE, imageMap);
423
424   // Disable pre-multiplied alpha blending
425   imageView2.SetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA, false);
426
427   application.GetScene().Add(imageView2);
428
429   application.SendNotification();
430   application.Render();
431
432   value = imageView2.GetProperty(ImageView::Property::PRE_MULTIPLIED_ALPHA);
433   DALI_TEST_CHECK(value.Get(enable));
434   DALI_TEST_CHECK(!enable);
435
436   // conventional alpha blending
437   Renderer renderer2 = imageView2.GetRendererAt(0);
438   value              = renderer2.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
439   DALI_TEST_CHECK(value.Get(enable));
440   DALI_TEST_CHECK(!enable);
441
442   srcFactorRgb    = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
443   destFactorRgb   = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
444   srcFactorAlpha  = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
445   destFactorAlpha = renderer2.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
446   DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
447   DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
448   DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
449   DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
450
451   DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // The cached texture should be used.
452
453   END_TEST;
454 }
455
456 int UtcDaliImageViewPixelArea(void)
457 {
458   // Test pixel area property
459   ToolkitTestApplication application;
460
461   static std::vector<UniformData> customUniforms =
462     {
463       UniformData("pixelArea", Property::Type::VECTOR4),
464     };
465
466   TestGraphicsController& graphics = application.GetGraphicsController();
467   graphics.AddCustomUniforms(customUniforms);
468
469   // Gif image, use AnimatedImageVisual internally
470   // Atlasing is applied to pack multiple frames, use custom wrap mode
471   ImageView     gifView = ImageView::New();
472   const Vector4 pixelAreaVisual(0.f, 0.f, 2.f, 2.f);
473   gifView.SetProperty(ImageView::Property::IMAGE,
474                       Property::Map().Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME).Add(ImageVisual::Property::PIXEL_AREA, pixelAreaVisual));
475
476   // Add to stage
477   Integration::Scene stage = application.GetScene();
478   stage.Add(gifView);
479
480   // loading started
481   application.SendNotification();
482   application.Render(16);
483
484   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
485
486   application.SendNotification();
487   application.Render();
488   DALI_TEST_CHECK(gifView.GetRendererCount() == 1u);
489
490   const Vector4 fullTextureRect(0.f, 0.f, 1.f, 1.f);
491   // test that the pixel area value defined in the visual property map is registered on renderer
492   Renderer        renderer       = gifView.GetRendererAt(0);
493   Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
494   DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION);
495
496   // test that the shader has the default pixel area value registered.
497   Shader shader  = renderer.GetShader();
498   pixelAreaValue = shader.GetProperty(shader.GetPropertyIndex("pixelArea"));
499   DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION);
500
501   // test that the uniform uses the pixelArea property on the renderer.
502   TestGlAbstraction& gl = application.GetGlAbstraction();
503   Vector4            pixelAreaUniform;
504   DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
505   DALI_TEST_EQUALS(pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
506
507   // set the pixelArea property on the control
508   const Vector4 pixelAreaControl(-1.f, -1.f, 3.f, 3.f);
509   gifView.SetProperty(ImageView::Property::PIXEL_AREA, pixelAreaControl);
510   application.SendNotification();
511   application.Render(16);
512
513   // check the pixelArea property on the control
514   pixelAreaValue = gifView.GetProperty(gifView.GetPropertyIndex("pixelArea"));
515   DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION);
516   // test that the uniform uses the pixelArea property on the control.
517   DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
518   DALI_TEST_EQUALS(pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
519
520   END_TEST;
521 }
522
523 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
524 {
525   ToolkitTestApplication     application;
526   TestGlAbstraction&         gl          = application.GetGlAbstraction();
527   const std::vector<GLuint>& textures    = gl.GetBoundTextures();
528   size_t                     numTextures = textures.size();
529
530   // Async loading, no atlasing for big size image
531   ImageView imageView = ImageView::New(gImage_600_RGB);
532
533   // By default, Aysnc loading is used
534   application.GetScene().Add(imageView);
535   imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
536   imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
537
538   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
539
540   application.SendNotification();
541   application.Render(16);
542   application.SendNotification();
543
544   const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
545   DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
546
547   END_TEST;
548 }
549
550 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
551 {
552   ToolkitTestApplication application;
553
554   //Async loading, automatic atlasing for small size image
555   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
556   callStack.Reset();
557   callStack.Enable(true);
558
559   Property::Map imageMap;
560
561   imageMap[ImageVisual::Property::URL]            = gImage_34_RGBA;
562   imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
563   imageMap[ImageVisual::Property::DESIRED_WIDTH]  = 34;
564   imageMap[ImageVisual::Property::ATLASING]       = true;
565
566   ImageView imageView = ImageView::New();
567   imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
568   imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
569
570   // By default, Aysnc loading is used
571   // loading is not started if the actor is offScene
572
573   application.GetScene().Add(imageView);
574   application.SendNotification();
575   application.Render(16);
576   application.Render(16);
577   application.SendNotification();
578
579   imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
580   application.SendNotification();
581   application.Render(16);
582   application.Render(16);
583   application.SendNotification();
584
585   // loading started, this waits for the loader thread for max 30 seconds
586   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
587
588   application.SendNotification();
589   application.Render(16);
590
591   callStack.Enable(false);
592
593   TraceCallStack::NamedParams params;
594   params["width"] << 34;
595   params["height"] << 34;
596   DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
597
598   END_TEST;
599 }
600
601 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
602 {
603   ToolkitTestApplication application;
604
605   //Async loading, automatic atlasing for small size image
606   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
607   callStack.Reset();
608   callStack.Enable(true);
609
610   Property::Map asyncLoadingMap;
611   asyncLoadingMap["url"]                = gImage_34_RGBA;
612   asyncLoadingMap["desiredHeight"]      = 34;
613   asyncLoadingMap["desiredWidth"]       = 34;
614   asyncLoadingMap["synchronousLoading"] = false;
615   asyncLoadingMap["atlasing"]           = true;
616
617   ImageView imageView = ImageView::New();
618   imageView.SetProperty(ImageView::Property::IMAGE, asyncLoadingMap);
619
620   application.GetScene().Add(imageView);
621   application.SendNotification();
622   application.Render(16);
623   application.Render(16);
624   application.SendNotification();
625
626   // loading started, this waits for the loader thread for max 30 seconds
627   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
628
629   application.SendNotification();
630   application.Render(16);
631
632   callStack.Enable(false);
633
634   TraceCallStack::NamedParams params;
635   params["width"] << 34;
636   params["height"] << 34;
637   DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
638
639   END_TEST;
640 }
641
642 int UtcDaliImageViewSyncLoading(void)
643 {
644   ToolkitTestApplication application;
645
646   tet_infoline("ImageView Testing sync loading and size using index key property map");
647
648   Property::Map syncLoadingMap;
649   syncLoadingMap[ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
650   syncLoadingMap[ImageVisual::Property::ATLASING]            = true;
651
652   // Sync loading, no atlasing for big size image
653   {
654     ImageView imageView = ImageView::New();
655
656     // Sync loading is used
657     syncLoadingMap[ImageVisual::Property::URL] = gImage_600_RGB;
658     imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
659   }
660
661   // Sync loading, automatic atlasing for small size image
662   {
663     TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
664     callStack.Reset();
665     callStack.Enable(true);
666
667     ImageView imageView = ImageView::New();
668
669     // Sync loading is used
670     syncLoadingMap[ImageVisual::Property::URL]            = gImage_34_RGBA;
671     syncLoadingMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
672     syncLoadingMap[ImageVisual::Property::DESIRED_WIDTH]  = 34;
673     imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
674
675     application.GetScene().Add(imageView);
676     application.SendNotification();
677     application.Render(16);
678
679     TraceCallStack::NamedParams params;
680     params["width"] << 34;
681     params["height"] << 34;
682     DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
683                      true,
684                      TEST_LOCATION);
685   }
686   END_TEST;
687 }
688
689 int UtcDaliImageViewSyncLoading02(void)
690 {
691   ToolkitTestApplication application;
692
693   tet_infoline("ImageView Testing sync loading and size using string key property map");
694
695   // Sync loading, automatic atlasing for small size image
696   {
697     TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
698     callStack.Reset();
699     callStack.Enable(true);
700
701     ImageView imageView = ImageView::New();
702
703     // Sync loading is used
704     Property::Map syncLoadingMap;
705     syncLoadingMap["url"]                = gImage_34_RGBA;
706     syncLoadingMap["desiredHeight"]      = 34;
707     syncLoadingMap["desiredWidth"]       = 34;
708     syncLoadingMap["synchronousLoading"] = true;
709     syncLoadingMap["atlasing"]           = true;
710     imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
711
712     application.GetScene().Add(imageView);
713     application.SendNotification();
714     application.Render(16);
715
716     TraceCallStack::NamedParams params;
717     params["width"] << 34;
718     params["height"] << 34;
719     DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
720                      true,
721                      TEST_LOCATION);
722   }
723   END_TEST;
724 }
725
726 int UtcDaliImageViewAsyncLoadingEncodedBuffer(void)
727 {
728   ToolkitTestApplication     application;
729   TestGlAbstraction&         gl          = application.GetGlAbstraction();
730   const std::vector<GLuint>& textures    = gl.GetBoundTextures();
731   size_t                     numTextures = textures.size();
732
733   // Get encoded raw-buffer image and generate url
734   EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
735   ImageUrl           url    = Toolkit::Image::GenerateUrl(buffer);
736
737   // Async loading, no atlasing for big size image
738   ImageView imageView = ImageView::New(url.GetUrl());
739
740   // By default, Aysnc loading is used
741   application.GetScene().Add(imageView);
742   imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
743   imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
744
745   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
746
747   application.SendNotification();
748   application.Render(16);
749   application.SendNotification();
750
751   const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
752   DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION);
753
754   END_TEST;
755 }
756
757 int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
758 {
759   ToolkitTestApplication application;
760
761   // Get encoded raw-buffer image and generate url
762   EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
763   ImageUrl           url    = Toolkit::Image::GenerateUrl(buffer);
764   ImageUrl           url2   = Toolkit::Image::GenerateUrl(buffer);
765
766   // Generate url is not equal to url2
767   // NOTE : This behavior may changed when ImageUrl compare operator changed.
768   DALI_TEST_CHECK(url != url2);
769   // Generate url's string is equal to url2's string
770   DALI_TEST_CHECK(url.GetUrl() == url2.GetUrl());
771
772   EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(gImage_600_RGB);
773   url2                       = Toolkit::Image::GenerateUrl(buffer2);
774
775   // Check whethere two url are not equal
776   DALI_TEST_CHECK(url.GetUrl() != url2.GetUrl());
777
778   // Async loading, automatic atlasing for small size image
779   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
780   callStack.Reset();
781   callStack.Enable(true);
782
783   Property::Map imageMap;
784
785   imageMap[ImageVisual::Property::URL]            = url.GetUrl();
786   imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
787   imageMap[ImageVisual::Property::DESIRED_WIDTH]  = 34;
788   imageMap[ImageVisual::Property::ATLASING]       = true;
789
790   ImageView imageView = ImageView::New();
791   imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
792   imageView.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
793
794   // By default, Aysnc loading is used
795   // loading is not started if the actor is offScene
796
797   application.GetScene().Add(imageView);
798   application.SendNotification();
799   application.Render(16);
800   application.Render(16);
801   application.SendNotification();
802
803   // Change url to url2
804   imageMap[ImageVisual::Property::URL] = url2.GetUrl();
805   imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
806
807   imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
808   application.SendNotification();
809   application.Render(16);
810   application.Render(16);
811   application.SendNotification();
812
813   // loading started, this waits for the loader thread for max 30 seconds
814   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
815
816   application.SendNotification();
817   application.Render(16);
818
819   callStack.Enable(false);
820
821   TraceCallStack::NamedParams params;
822   params["width"] << 34;
823   params["height"] << 34;
824   DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params), true, TEST_LOCATION);
825
826   END_TEST;
827 }
828
829 int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
830 {
831   ToolkitTestApplication application;
832
833   tet_infoline("ImageView Testing sync loading from EncodedImageBuffer");
834
835   // Get encoded raw-buffer image and generate url
836   EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA);
837   ImageUrl           url    = Toolkit::Image::GenerateUrl(buffer);
838
839   // Sync loading, automatic atlasing for small size image
840   {
841     TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
842     callStack.Reset();
843     callStack.Enable(true);
844
845     ImageView imageView = ImageView::New();
846
847     // Sync loading is used
848     Property::Map syncLoadingMap;
849     syncLoadingMap["url"]                = url.GetUrl();
850     syncLoadingMap["desiredHeight"]      = 34;
851     syncLoadingMap["desiredWidth"]       = 34;
852     syncLoadingMap["synchronousLoading"] = true;
853     syncLoadingMap["atlasing"]           = true;
854     imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
855
856     application.GetScene().Add(imageView);
857     application.SendNotification();
858     application.Render(16);
859
860     TraceCallStack::NamedParams params;
861     params["width"] << 34;
862     params["height"] << 34;
863     DALI_TEST_EQUALS(callStack.FindMethodAndParams("TexSubImage2D", params),
864                      true,
865                      TEST_LOCATION);
866   }
867
868   END_TEST;
869 }
870
871 int UtcDaliImageViewAddedTexture(void)
872 {
873   ToolkitTestApplication application;
874
875   tet_infoline("ImageView Testing image view with texture provided manager url");
876
877   ImageView imageView = ImageView::New();
878
879   // empty texture is ok, though pointless from app point of view
880   TextureSet  empty;
881   std::string url = TextureManager::AddTexture(empty);
882   DALI_TEST_CHECK(url.size() > 0u);
883
884   Property::Map propertyMap;
885   propertyMap[ImageVisual::Property::URL] = url;
886   imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
887
888   application.GetScene().Add(imageView);
889   application.SendNotification();
890   application.Render();
891
892   END_TEST;
893 }
894
895 int UtcDaliImageViewSizeWithBackground(void)
896 {
897   ToolkitTestApplication application;
898
899   int       width     = 100;
900   int       height    = 200;
901   ImageView imageView = ImageView::New();
902
903   imageView.SetProperty(Control::Property::BACKGROUND,
904                         {
905                           {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
906                           {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
907                           {ImageVisual::Property::DESIRED_WIDTH, width},
908                           {ImageVisual::Property::DESIRED_HEIGHT, height},
909                         });
910
911   application.GetScene().Add(imageView);
912   application.SendNotification();
913   application.Render();
914
915   DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
916   DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
917
918   END_TEST;
919 }
920
921 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
922 {
923   ToolkitTestApplication application;
924
925   int widthBackground  = 100;
926   int heightBackground = 200;
927   int width            = 600;
928   int height           = 600;
929
930   ImageView imageView = ImageView::New();
931
932   imageView.SetProperty(Control::Property::BACKGROUND,
933                         {
934                           {Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
935                           {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
936                           {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
937                           {ImageVisual::Property::DESIRED_HEIGHT, heightBackground},
938                         });
939
940   imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio, 600x600 pixels
941
942   application.GetScene().Add(imageView);
943   application.SendNotification();
944   application.Render();
945
946   DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, (float)width, TEST_LOCATION);
947   DALI_TEST_EQUALS(imageView.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, (float)height, TEST_LOCATION);
948
949   END_TEST;
950 }
951
952 int UtcDaliImageViewHeightForWidthBackground(void)
953 {
954   ToolkitTestApplication application;
955
956   int widthBackground  = 100;
957   int heightBackground = 200;
958
959   ImageView imageView = ImageView::New();
960
961   imageView.SetProperty(Control::Property::BACKGROUND,
962                         {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
963                          {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
964                          {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
965                          {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}});
966
967   application.GetScene().Add(imageView);
968   application.SendNotification();
969   application.Render();
970
971   Control control = Control::DownCast(imageView);
972   DALI_TEST_CHECK(control);
973   DALI_TEST_EQUALS(imageView.GetHeightForWidth(123.f), control.GetHeightForWidth(123.f), TEST_LOCATION);
974   DALI_TEST_EQUALS(imageView.GetWidthForHeight(321.f), control.GetWidthForHeight(321.f), TEST_LOCATION);
975
976   END_TEST;
977 }
978
979 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
980 {
981   ToolkitTestApplication application;
982
983   int widthBackground  = 100;
984   int heightBackground = 200;
985   int width            = 300;
986   int height           = 300;
987
988   ImageView imageView = ImageView::New();
989
990   imageView.SetProperty(Control::Property::BACKGROUND,
991                         {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
992                          {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
993                          {ImageVisual::Property::DESIRED_WIDTH, widthBackground},
994                          {ImageVisual::Property::DESIRED_HEIGHT, heightBackground}}); // 1 to 2 ratio
995
996   imageView.SetImage(gImage_600_RGB); // 1 to 1 ratio
997
998   application.GetScene().Add(imageView);
999   application.SendNotification();
1000   application.Render();
1001
1002   DALI_TEST_EQUALS(imageView.GetHeightForWidth(width), (float)height, TEST_LOCATION);
1003   DALI_TEST_EQUALS(imageView.GetWidthForHeight(height), (float)width, TEST_LOCATION);
1004
1005   END_TEST;
1006 }
1007
1008 int UtcDaliImageViewSetImageUrl(void)
1009 {
1010   ToolkitTestApplication application;
1011
1012   ImageView imageView = ImageView::New();
1013   imageView.SetImage(TEST_IMAGE_FILE_NAME);
1014   TestUrl(imageView, TEST_IMAGE_FILE_NAME);
1015
1016   imageView.SetImage(TEST_IMAGE_FILE_NAME2);
1017   TestUrl(imageView, TEST_IMAGE_FILE_NAME2);
1018
1019   END_TEST;
1020 }
1021
1022 bool    gResourceReadySignalFired = false;
1023 Vector3 gNaturalSize;
1024
1025 void ResourceReadySignal(Control control)
1026 {
1027   gResourceReadySignalFired = true;
1028 }
1029
1030 int UtcDaliImageViewCheckResourceReady(void)
1031 {
1032   ToolkitTestApplication application;
1033
1034   gResourceReadySignalFired = false;
1035
1036   // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1037   ImageView imageView = ImageView::New(TEST_GIF_FILE_NAME);
1038
1039   imageView.SetProperty(Control::Property::BACKGROUND,
1040                         {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
1041                          {Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/gallery-small-1.jpg"},
1042                          {ImageVisual::Property::DESIRED_WIDTH, 100},
1043                          {ImageVisual::Property::DESIRED_HEIGHT, 200}});
1044
1045   DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1046
1047   imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1048
1049   application.GetScene().Add(imageView);
1050
1051   // loading started, this waits for the loader thread
1052   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1053
1054   application.SendNotification();
1055   application.Render(16);
1056
1057   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1058
1059   application.SendNotification();
1060   application.Render();
1061
1062   DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1063
1064   DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1065
1066   END_TEST;
1067 }
1068
1069 int UtcDaliImageViewSetImageTypeChangesP(void)
1070 {
1071   ToolkitTestApplication application;
1072
1073   ImageView                   imageView   = ImageView::New();
1074   Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1075
1076   application.GetScene().Add(imageView);
1077
1078   std::string           url;
1079   Property::Map         map;
1080   Toolkit::Visual::Base visual;
1081
1082   Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1083   visual                = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1084
1085   application.SendNotification();
1086   application.Render(16);
1087
1088   DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1089   value.Get(map);
1090   DALI_TEST_CHECK(map.Empty()); // Value should be empty
1091   DALI_TEST_CHECK(!visual);     // Visual should be invalid
1092
1093   // Set a URL
1094   imageView.SetImage("TEST_URL");
1095
1096   application.SendNotification();
1097   application.Render(16);
1098
1099   value  = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1100   visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1101
1102   DALI_TEST_CHECK(value.Get(url));  // Value should NOT be empty
1103   DALI_TEST_CHECK(!value.Get(map)); // Value should be empty
1104   DALI_TEST_CHECK(visual);          // Visual should be valid
1105
1106   // Set an empty URL
1107   imageView.SetImage("");
1108
1109   application.SendNotification();
1110   application.Render(16);
1111
1112   value  = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1113   visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1114
1115   DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1116   value.Get(map);
1117   DALI_TEST_CHECK(map.Empty()); // Value should be empty
1118   DALI_TEST_CHECK(!visual);     // Visual should be invalid
1119
1120   // Set a URL in property map
1121   Property::Map propertyMap;
1122   propertyMap[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
1123   imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1124
1125   application.SendNotification();
1126   application.Render(16);
1127
1128   value  = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1129   visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1130
1131   DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1132   DALI_TEST_CHECK(value.Get(map));  // Value should NOT be empty
1133   DALI_TEST_CHECK(visual);          // Visual should be valid
1134
1135   // Set a URL in property map again
1136   propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1137   imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1138
1139   application.SendNotification();
1140   application.Render(16);
1141
1142   value  = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1143   visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1144
1145   DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1146   DALI_TEST_CHECK(value.Get(map));  // Value should NOT be empty
1147   DALI_TEST_CHECK(visual);          // Visual should be valid
1148
1149   // Set an empty URL in property map
1150   propertyMap[ImageVisual::Property::URL] = std::string();
1151   imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1152
1153   application.SendNotification();
1154   application.Render(16);
1155
1156   value  = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1157   visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1158
1159   DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1160   DALI_TEST_CHECK(value.Get(map));  // Value should NOT be empty
1161   DALI_TEST_CHECK(!visual);         // Visual should be invalid
1162
1163   // Set a URL in property map again
1164   propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
1165   imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1166
1167   application.SendNotification();
1168   application.Render(16);
1169
1170   value  = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1171   visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1172
1173   DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1174   DALI_TEST_CHECK(value.Get(map));  // Value should NOT be empty
1175   DALI_TEST_CHECK(visual);          // Visual should be valid
1176
1177   // Set an empty property map
1178   propertyMap.Clear();
1179   imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
1180
1181   application.SendNotification();
1182   application.Render(16);
1183
1184   value  = imageView.GetProperty(imageView.GetPropertyIndex("image"));
1185   visual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1186
1187   DALI_TEST_CHECK(!value.Get(url)); // Value should be empty
1188   DALI_TEST_CHECK(value.Get(map));  // Value should NOT be empty
1189   DALI_TEST_CHECK(map.Empty());     // But PropertyMap should be empty
1190   DALI_TEST_CHECK(!visual);         // Visual should be invalid
1191
1192   END_TEST;
1193 }
1194
1195 int UtcDaliImageViewResourceUrlP(void)
1196 {
1197   ToolkitTestApplication application;
1198
1199   ImageView imageView = ImageView::New();
1200   DALI_TEST_CHECK(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>().empty());
1201
1202   imageView.SetProperty(ImageView::Property::IMAGE, "TestString");
1203   DALI_TEST_EQUALS(imageView.GetProperty(ImageView::Property::IMAGE).Get<std::string>(), "TestString", TEST_LOCATION);
1204
1205   END_TEST;
1206 }
1207
1208 int UtcDaliImageViewReplaceImage(void)
1209 {
1210   ToolkitTestApplication application;
1211
1212   gResourceReadySignalFired = false;
1213
1214   // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1215   ImageView imageView = ImageView::New(TEST_IMAGE_1);
1216
1217   DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
1218
1219   imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1220
1221   application.GetScene().Add(imageView);
1222
1223   application.SendNotification();
1224   application.Render(16);
1225
1226   // loading started, this waits for the loader thread for max 30 seconds
1227   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1228
1229   DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1230
1231   DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1232
1233   gResourceReadySignalFired = false;
1234
1235   imageView.SetImage(TEST_IMAGE_2);
1236
1237   application.SendNotification();
1238   application.Render(16);
1239
1240   // loading started, this waits for the loader thread for max 30 seconds
1241   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1242
1243   DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
1244
1245   DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
1246
1247   DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1248
1249   END_TEST;
1250 }
1251
1252 void OnRelayoutOverride(Size size)
1253 {
1254   gNaturalSize = size; // Size Relayout is using
1255 }
1256
1257 int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
1258 {
1259   ToolkitTestApplication application;
1260
1261   // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1262   ImageView imageView = ImageView::New(TEST_IMAGE_1);
1263   imageView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1264
1265   DummyControl        dummyControl = DummyControl::New(true);
1266   Impl::DummyControl& dummyImpl    = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1267   dummyControl.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
1268
1269   dummyControl.Add(imageView);
1270   dummyImpl.SetRelayoutCallback(&OnRelayoutOverride);
1271   application.GetScene().Add(dummyControl);
1272
1273   application.SendNotification();
1274   application.Render();
1275
1276   // loading started, this waits for the loader thread for max 30 seconds
1277   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1278
1279   DALI_TEST_EQUALS(gNaturalSize.width, 1024.0f, TEST_LOCATION);
1280   DALI_TEST_EQUALS(gNaturalSize.height, 1024.0f, TEST_LOCATION);
1281
1282   gNaturalSize = Vector3::ZERO;
1283
1284   imageView.SetImage(gImage_600_RGB);
1285
1286   // Waiting for resourceReady so SendNotifcation not called here.
1287
1288   // loading started, this waits for the loader thread for max 30 seconds
1289   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1290
1291   // Trigger a potential relayout
1292   application.SendNotification();
1293   application.Render();
1294
1295   DALI_TEST_EQUALS(gNaturalSize.width, 600.0f, TEST_LOCATION);
1296   DALI_TEST_EQUALS(gNaturalSize.height, 600.0f, TEST_LOCATION);
1297
1298   END_TEST;
1299 }
1300
1301 int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
1302 {
1303   tet_infoline("Test Setting Image with IMMEDIATE load and receving ResourceReadySignal before staged.");
1304
1305   ToolkitTestApplication application;
1306
1307   gResourceReadySignalFired = false;
1308
1309   Property::Map imageMap;
1310
1311   imageMap[ImageVisual::Property::URL]         = gImage_34_RGBA;
1312   imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1313
1314   tet_infoline("Creating ImageView without URL so image does not start loading");
1315   ImageView imageView = ImageView::New();
1316   tet_infoline("Connect to image loaded signal before setting image");
1317   imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1318   tet_infoline("Setting Image with IMMEDIATE load, signal already connected so will be triggered.");
1319   imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1320
1321   // loading started, this waits for the loader thread
1322   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1323
1324   application.SendNotification();
1325   application.Render(16);
1326
1327   DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1328
1329   END_TEST;
1330 }
1331
1332 int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
1333 {
1334   tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal.");
1335
1336   ToolkitTestApplication application;
1337
1338   gResourceReadySignalFired = false;
1339
1340   Property::Map imageMap;
1341
1342   imageMap[ImageVisual::Property::URL]         = gImage_34_RGBA;
1343   imageMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1344
1345   ImageView imageView = ImageView::New();
1346   imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1347   imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
1348
1349   // loading started, this waits for the loader thread
1350   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1351
1352   application.SendNotification();
1353   application.Render(16);
1354
1355   DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1356   gResourceReadySignalFired = false;
1357
1358   ImageView imageViewWithExistingImage = ImageView::New();
1359   imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1360   imageViewWithExistingImage.SetProperty(ImageView::Property::IMAGE, imageMap);
1361
1362   DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1363
1364   END_TEST;
1365 }
1366
1367 int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
1368 {
1369   tet_infoline("Test Setting Image that was already loaded by another ImageView and still getting ResourceReadySignal when staged.");
1370
1371   ToolkitTestApplication application;
1372
1373   gResourceReadySignalFired = false;
1374
1375   Property::Map imageImmediateLoadingMap;
1376   imageImmediateLoadingMap[ImageVisual::Property::URL]         = gImage_34_RGBA;
1377   imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
1378
1379   tet_infoline("Immediate load an image");
1380   ImageView imageView = ImageView::New();
1381   imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
1382   imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
1383
1384   // loading started, this waits for the loader thread
1385   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1386
1387   application.SendNotification();
1388   application.Render(16);
1389
1390   tet_infoline("Check image loaded");
1391   DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1392   gResourceReadySignalFired = false;
1393
1394   tet_infoline("Create another ImageView with the same URL");
1395   ImageView imageViewWithExistingImage = ImageView::New(gImage_34_RGBA);
1396   tet_infoline("Connect to ResourceReady signal for second ImageView, it should still fire as resource is ready");
1397   imageViewWithExistingImage.ResourceReadySignal().Connect(&ResourceReadySignal);
1398
1399   application.GetScene().Add(imageViewWithExistingImage);
1400
1401   DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
1402
1403   END_TEST;
1404 }
1405
1406 int UtcDaliImageViewPaddingProperty(void)
1407 {
1408   ToolkitTestApplication application;
1409
1410   ImageView     imageView = ImageView::New();
1411   Property::Map imagePropertyMap;
1412   imagePropertyMap[Toolkit::Visual::Property::TYPE]       = Toolkit::Visual::IMAGE;
1413   imagePropertyMap[Toolkit::ImageVisual::Property::URL]   = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
1414   imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH]  = 128;
1415   imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT] = 128;
1416   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1417   imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1418   imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1419   imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1420   application.GetScene().Add(imageView);
1421
1422   application.SendNotification();
1423   application.Render();
1424
1425   DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1426
1427   ImageView childImage = ImageView::New();
1428   childImage.SetBackgroundColor(Color::BLACK);
1429   childImage.SetProperty(Actor::Property::SIZE, Vector2(10.f, 10.f));
1430   imageView.Add(childImage);
1431
1432   application.SendNotification();
1433   application.Render();
1434
1435   // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
1436   DALI_TEST_EQUALS(childImage.GetProperty<Vector3>(Dali::Actor::Property::POSITION), Vector3(15, 5, 0), TEST_LOCATION);
1437
1438   // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1439   Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1440   Toolkit::Visual::Base       imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1441   Property::Map               resultMap;
1442   imageVisual.CreatePropertyMap(resultMap);
1443
1444   Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1445   DALI_TEST_CHECK(transformValue);
1446   Property::Map* retMap = transformValue->GetMap();
1447   DALI_TEST_CHECK(retMap);
1448
1449   // Image Visual should be positioned depending on ImageView's padding
1450   DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1451
1452   END_TEST;
1453 }
1454
1455 int UtcDaliImageViewPaddingProperty02(void)
1456 {
1457   ToolkitTestApplication application;
1458
1459   ImageView     imageView = ImageView::New();
1460   Property::Map imagePropertyMap;
1461   imagePropertyMap[Toolkit::Visual::Property::TYPE]            = Toolkit::Visual::IMAGE;
1462   imagePropertyMap[Toolkit::ImageVisual::Property::URL]        = TEST_RESOURCE_DIR "/Kid1.svg";
1463   imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH]       = 128;
1464   imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT]      = 128;
1465   imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1466   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1467   imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1468   imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1469   imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1470   application.GetScene().Add(imageView);
1471
1472   application.SendNotification();
1473   application.Render();
1474
1475   DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1476
1477   // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1478   Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1479   Toolkit::Visual::Base       imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1480   Property::Map               resultMap;
1481   imageVisual.CreatePropertyMap(resultMap);
1482
1483   Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1484   DALI_TEST_CHECK(transformValue);
1485   Property::Map* retMap = transformValue->GetMap();
1486   DALI_TEST_CHECK(retMap);
1487
1488   // Image Visual should be positioned depending on ImageView's padding
1489   DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(15, 5), TEST_LOCATION);
1490
1491   END_TEST;
1492 }
1493
1494 int UtcDaliImageViewPaddingProperty03(void)
1495 {
1496   tet_infoline("Test Setting Image Padding then removing it.");
1497
1498   ToolkitTestApplication application;
1499
1500   ImageView     imageView = ImageView::New();
1501   Property::Map imagePropertyMap;
1502   imagePropertyMap[Toolkit::Visual::Property::TYPE]            = Toolkit::Visual::IMAGE;
1503   imagePropertyMap[Toolkit::ImageVisual::Property::URL]        = TEST_RESOURCE_DIR "/Kid1.svg";
1504   imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH]       = 128;
1505   imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT]      = 128;
1506   imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
1507   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1508   imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1509   imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1510   imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1511   application.GetScene().Add(imageView);
1512
1513   application.SendNotification();
1514   application.Render();
1515
1516   DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1517
1518   tet_infoline("Remove Padding and test Visual is position correctly");
1519
1520   imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1521
1522   application.SendNotification();
1523   application.Render();
1524
1525   // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1526   Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1527   Toolkit::Visual::Base       imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1528   Property::Map               resultMap;
1529   imageVisual.CreatePropertyMap(resultMap);
1530
1531   Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1532   DALI_TEST_CHECK(transformValue);
1533   Property::Map* retMap = transformValue->GetMap();
1534   DALI_TEST_CHECK(retMap);
1535
1536   // Image Visual should be positioned depending on ImageView's padding
1537   DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1538
1539   END_TEST;
1540 }
1541
1542 int UtcDaliImageViewPaddingProperty04(void)
1543 {
1544   tet_infoline("Test Setting Image Padding then removing it. Visual Fitting Mode as Fill");
1545
1546   ToolkitTestApplication application;
1547
1548   ImageView     imageView = ImageView::New();
1549   Property::Map imagePropertyMap;
1550   imagePropertyMap[Toolkit::Visual::Property::TYPE]            = Toolkit::Visual::IMAGE;
1551   imagePropertyMap[Toolkit::ImageVisual::Property::URL]        = TEST_RESOURCE_DIR "/Kid1.svg";
1552   imagePropertyMap[ImageVisual::Property::DESIRED_WIDTH]       = 128;
1553   imagePropertyMap[ImageVisual::Property::DESIRED_HEIGHT]      = 128;
1554   imagePropertyMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FILL;
1555   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1556   imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1557   imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1558   imageView.SetProperty(Control::Property::PADDING, Extents(15, 10, 5, 10));
1559   application.GetScene().Add(imageView);
1560
1561   application.SendNotification();
1562   application.Render();
1563
1564   DALI_TEST_EQUALS(imageView.GetProperty<Extents>(Control::Property::PADDING), Extents(15, 10, 5, 10), TEST_LOCATION);
1565
1566   tet_infoline("Remove Padding and test Visual is position correctly");
1567
1568   imageView.SetProperty(Control::Property::PADDING, Extents(0, 0, 0, 0));
1569
1570   application.SendNotification();
1571   application.Render();
1572
1573   // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1574   Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1575   Toolkit::Visual::Base       imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1576   Property::Map               resultMap;
1577   imageVisual.CreatePropertyMap(resultMap);
1578
1579   Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1580   DALI_TEST_CHECK(transformValue);
1581   Property::Map* retMap = transformValue->GetMap();
1582   DALI_TEST_CHECK(retMap);
1583
1584   // Image Visual should be positioned depending on ImageView's padding
1585   DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
1586
1587   END_TEST;
1588 }
1589
1590 int UtcDaliImageViewTransformTest01(void)
1591 {
1592   tet_infoline("Test Setting a offset transform on the ImageView");
1593
1594   ToolkitTestApplication application;
1595
1596   ImageView     imageView = ImageView::New();
1597   Property::Map imagePropertyMap;
1598   imagePropertyMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE)
1599     .Add(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/Kid1.svg")
1600     .Add(ImageVisual::Property::DESIRED_WIDTH, 120)
1601     .Add(ImageVisual::Property::DESIRED_HEIGHT, 120)
1602     .Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL)
1603     .Add(Visual::Property::TRANSFORM,
1604          Property::Map().Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
1605                              Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE))
1606            .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(8, 8)));
1607
1608   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
1609   imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1610   imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1611   application.GetScene().Add(imageView);
1612
1613   application.SendNotification();
1614   application.Render();
1615
1616   // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
1617   Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(imageView);
1618   Toolkit::Visual::Base       imageVisual = DevelControl::GetVisual(controlImpl, ImageView::Property::IMAGE);
1619   Property::Map               resultMap;
1620   imageVisual.CreatePropertyMap(resultMap);
1621
1622   Property::Value* transformValue = resultMap.Find(Visual::Property::TRANSFORM);
1623   DALI_TEST_CHECK(transformValue);
1624   Property::Map* retMap = transformValue->GetMap();
1625   DALI_TEST_CHECK(retMap);
1626
1627   // Image Visual should be positioned depending on ImageView's padding
1628   DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::OFFSET)->Get<Vector2>(), Vector2(8, 8), TEST_LOCATION);
1629   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);
1630
1631   END_TEST;
1632 }
1633
1634 int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
1635 {
1636   ToolkitTestApplication application;
1637
1638   // Check ImageView with background and main image, to ensure both visuals are marked as loaded
1639   ImageView     imageView = ImageView::New();
1640   Property::Map imageMap;
1641   imageMap[Toolkit::Visual::Property::TYPE]          = Toolkit::Visual::IMAGE;
1642   imageMap[Toolkit::ImageVisual::Property::URL]      = gImage_34_RGBA;
1643   imageMap[Toolkit::ImageVisual::Property::ATLASING] = true;
1644   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1645   application.GetScene().Add(imageView);
1646
1647   // Trigger a potential relayout
1648   application.SendNotification();
1649   application.Render();
1650
1651   Vector3 naturalSize = imageView.GetNaturalSize();
1652
1653   DALI_TEST_EQUALS(naturalSize.width, 34.0f, TEST_LOCATION);
1654   DALI_TEST_EQUALS(naturalSize.height, 34.0f, TEST_LOCATION);
1655
1656   END_TEST;
1657 }
1658
1659 int UtcDaliImageViewFillMode(void)
1660 {
1661   ToolkitTestApplication application;
1662
1663   tet_infoline("Create an ImageVisual without padding and set the fill-mode to fill");
1664
1665   ImageView     imageView = ImageView::New();
1666   Property::Map imageMap;
1667   imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1668   imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB);
1669   imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FittingMode::FILL);
1670
1671   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1672
1673   application.GetScene().Add(imageView);
1674
1675   // Trigger a potential relayout
1676   application.SendNotification();
1677   application.Render();
1678
1679   Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1680   Property::Map         returnedMap;
1681   visual.CreatePropertyMap(returnedMap);
1682
1683   Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1684   DALI_TEST_CHECK(value);
1685   Property::Map* map = value->GetMap();
1686   DALI_TEST_CHECK(map);
1687
1688   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1689   DALI_TEST_CHECK(value);
1690   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION);
1691
1692   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1693   DALI_TEST_CHECK(value);
1694   DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1695
1696   END_TEST;
1697 }
1698
1699 int UtcDaliImageViewFittingModeFitKeepAspectRatio(void)
1700 {
1701   ToolkitTestApplication application;
1702
1703   tet_infoline("Create an ImageVisual using FitKeepAspectRatio ( image: [600,600], view: [600,700] )");
1704   tet_infoline("  There should be need to change the transform, offset is adjusted to fit inside");
1705
1706   ImageView     imageView = ImageView::New();
1707   Property::Map imageMap;
1708   imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1709   imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1710   imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO);
1711
1712   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1713   imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1714
1715   application.GetScene().Add(imageView);
1716
1717   // Trigger a potential relayout
1718   application.SendNotification();
1719   application.Render();
1720
1721   Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1722   Property::Map         returnedMap;
1723   visual.CreatePropertyMap(returnedMap);
1724
1725   Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1726   DALI_TEST_CHECK(value);
1727   Property::Map* map = value->GetMap();
1728   DALI_TEST_CHECK(map);
1729
1730   // If there's
1731   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1732   DALI_TEST_CHECK(value);
1733   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION);
1734
1735   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1736   DALI_TEST_CHECK(value);
1737   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1738
1739   value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1740   DALI_TEST_CHECK(value);
1741   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
1742
1743   END_TEST;
1744 }
1745
1746 int UtcDaliImageViewFittingModesFill(void)
1747 {
1748   ToolkitTestApplication application;
1749
1750   tet_infoline("Create an ImageVisual using Fill ( image: [600,600], view: [600,700] )");
1751   tet_infoline("  There should be no need to change the transform, only size is changed to fit view");
1752
1753   ImageView     imageView = ImageView::New();
1754   Property::Map imageMap;
1755   imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1756   imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1757   imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL);
1758
1759   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1760   imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1761
1762   application.GetScene().Add(imageView);
1763
1764   // Trigger a potential relayout
1765   application.SendNotification();
1766   application.Render();
1767
1768   Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1769   Property::Map         returnedMap;
1770   visual.CreatePropertyMap(returnedMap);
1771
1772   Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1773   DALI_TEST_CHECK(value);
1774   Property::Map* map = value->GetMap();
1775   DALI_TEST_CHECK(map);
1776
1777   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1778   DALI_TEST_CHECK(value);
1779   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Change the internal size according to the image view size
1780
1781   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1782   DALI_TEST_CHECK(value);
1783   DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
1784
1785   value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1786   DALI_TEST_CHECK(value);
1787   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1788
1789   END_TEST;
1790 }
1791
1792 int UtcDaliImageViewFittingModesOverfitKeepAspectRatio(void)
1793 {
1794   ToolkitTestApplication application;
1795
1796   tet_infoline("Create an ImageVisual using OverFitKeepAspectRatio ( image: [600,600], view: [600,500] )");
1797   tet_infoline("  offset or size is the same as view, but adjust internally using pixelArea ");
1798
1799   ImageView     imageView = ImageView::New();
1800   Property::Map imageMap;
1801   imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1802   imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1803   imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO);
1804
1805   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1806   imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 500));
1807
1808   application.GetScene().Add(imageView);
1809
1810   // Trigger a potential relayout
1811   application.SendNotification();
1812   application.Render();
1813
1814   Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1815   Property::Map         returnedMap;
1816   visual.CreatePropertyMap(returnedMap);
1817
1818   Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1819   DALI_TEST_CHECK(value);
1820   Property::Map* map = value->GetMap();
1821   DALI_TEST_CHECK(map);
1822
1823   // If there's
1824   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1825   DALI_TEST_CHECK(value);
1826   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 500), TEST_LOCATION); // Change the internal size according to the image view size
1827
1828   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1829   DALI_TEST_CHECK(value);
1830   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1831
1832   value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1833   DALI_TEST_CHECK(value);
1834   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1835
1836   END_TEST;
1837 }
1838
1839 int UtcDaliImageViewFittingModesCenter01(void)
1840 {
1841   ToolkitTestApplication application;
1842
1843   tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [700,700] )");
1844   tet_infoline("  There should be need to change the transform, offset is adjusted to fit inside");
1845
1846   ImageView     imageView = ImageView::New();
1847   Property::Map imageMap;
1848   imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1849   imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1850   imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1851
1852   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1853   imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1854
1855   application.GetScene().Add(imageView);
1856
1857   // Trigger a potential relayout
1858   application.SendNotification();
1859   application.Render();
1860
1861   Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1862   Property::Map         returnedMap;
1863   visual.CreatePropertyMap(returnedMap);
1864
1865   Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1866   DALI_TEST_CHECK(value);
1867   Property::Map* map = value->GetMap();
1868   DALI_TEST_CHECK(map);
1869
1870   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1871   DALI_TEST_CHECK(value);
1872   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1873
1874   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1875   DALI_TEST_CHECK(value);
1876   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1877
1878   value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1879   DALI_TEST_CHECK(value);
1880   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1881
1882   END_TEST;
1883 }
1884
1885 int UtcDaliImageViewFittingModesCenter02(void)
1886 {
1887   ToolkitTestApplication application;
1888
1889   tet_infoline("Create an ImageVisual using Center ( image: [600,600], view: [500,500] )");
1890   tet_infoline("  There should be need to change the transform, offset is adjusted to fit inside");
1891
1892   ImageView     imageView = ImageView::New();
1893   Property::Map imageMap;
1894   imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1895   imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1896   imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::CENTER);
1897
1898   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1899   imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 700));
1900
1901   application.GetScene().Add(imageView);
1902
1903   // Trigger a potential relayout
1904   application.SendNotification();
1905   application.Render();
1906
1907   Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1908   Property::Map         returnedMap;
1909   visual.CreatePropertyMap(returnedMap);
1910
1911   Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1912   DALI_TEST_CHECK(value);
1913   Property::Map* map = value->GetMap();
1914   DALI_TEST_CHECK(map);
1915
1916   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1917   DALI_TEST_CHECK(value);
1918   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
1919
1920   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1921   DALI_TEST_CHECK(value);
1922   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1923
1924   value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1925   DALI_TEST_CHECK(value);
1926   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 50), TEST_LOCATION);
1927
1928   END_TEST;
1929 }
1930
1931 int UtcDaliImageViewFittingModesFitHeight01(void)
1932 {
1933   ToolkitTestApplication application;
1934
1935   tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [600,700] )");
1936
1937   ImageView     imageView = ImageView::New();
1938   Property::Map imageMap;
1939   imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1940   imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
1941   imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1942
1943   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1944   imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
1945
1946   application.GetScene().Add(imageView);
1947
1948   // Trigger a potential relayout
1949   application.SendNotification();
1950   application.Render();
1951
1952   Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1953   Property::Map         returnedMap;
1954   visual.CreatePropertyMap(returnedMap);
1955
1956   Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
1957   DALI_TEST_CHECK(value);
1958   Property::Map* map = value->GetMap();
1959   DALI_TEST_CHECK(map);
1960
1961   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
1962   DALI_TEST_CHECK(value);
1963   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 700), TEST_LOCATION); // Change the internal size according to the image view size
1964
1965   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
1966   DALI_TEST_CHECK(value);
1967   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
1968
1969   value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
1970   DALI_TEST_CHECK(value);
1971   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
1972
1973   END_TEST;
1974 }
1975
1976 int UtcDaliImageViewFittingModesFitHeight02(void)
1977 {
1978   ToolkitTestApplication application;
1979
1980   tet_infoline("Create an ImageVisual using FitHeight ( image: [600,600], view: [700,600] )");
1981
1982   ImageView     imageView = ImageView::New();
1983   Property::Map imageMap;
1984   imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
1985   imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
1986   imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_HEIGHT);
1987
1988   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
1989   imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
1990
1991   application.GetScene().Add(imageView);
1992
1993   // Trigger a potential relayout
1994   application.SendNotification();
1995   application.Render();
1996
1997   Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
1998   Property::Map         returnedMap;
1999   visual.CreatePropertyMap(returnedMap);
2000
2001   Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2002   DALI_TEST_CHECK(value);
2003   Property::Map* map = value->GetMap();
2004   DALI_TEST_CHECK(map);
2005
2006   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2007   DALI_TEST_CHECK(value);
2008   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2009
2010   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2011   DALI_TEST_CHECK(value);
2012   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2013
2014   value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2015   DALI_TEST_CHECK(value);
2016   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2017
2018   END_TEST;
2019 }
2020
2021 int UtcDaliImageViewFittingModesFitWidth01(void)
2022 {
2023   ToolkitTestApplication application;
2024
2025   tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view: [600,700] )");
2026
2027   ImageView     imageView = ImageView::New();
2028   Property::Map imageMap;
2029   imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2030   imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 600x600 image
2031   imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2032
2033   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2034   imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 700));
2035
2036   application.GetScene().Add(imageView);
2037
2038   // Trigger a potential relayout
2039   application.SendNotification();
2040   application.Render();
2041
2042   Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2043   Property::Map         returnedMap;
2044   visual.CreatePropertyMap(returnedMap);
2045
2046   Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2047   DALI_TEST_CHECK(value);
2048   Property::Map* map = value->GetMap();
2049   DALI_TEST_CHECK(map);
2050
2051   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2052   DALI_TEST_CHECK(value);
2053   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2054
2055   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2056   DALI_TEST_CHECK(value);
2057   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2058
2059   value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2060   DALI_TEST_CHECK(value);
2061   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
2062
2063   END_TEST;
2064 }
2065
2066 int UtcDaliImageViewFittingModesFitWidth02(void)
2067 {
2068   ToolkitTestApplication application;
2069
2070   tet_infoline("Create an ImageVisual using FitWidth ( image: [600,600], view:[700,600] )");
2071
2072   ImageView     imageView = ImageView::New();
2073   Property::Map imageMap;
2074   imageMap.Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2075   imageMap.Add(Toolkit::ImageVisual::Property::URL, gImage_600_RGB); // 249x169 image
2076   imageMap.Add(DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FIT_WIDTH);
2077
2078   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2079   imageView.SetProperty(Actor::Property::SIZE, Vector2(700, 600));
2080
2081   application.GetScene().Add(imageView);
2082
2083   // Trigger a potential relayout
2084   application.SendNotification();
2085   application.Render();
2086
2087   Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2088   Property::Map         returnedMap;
2089   visual.CreatePropertyMap(returnedMap);
2090
2091   Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2092   DALI_TEST_CHECK(value);
2093   Property::Map* map = value->GetMap();
2094   DALI_TEST_CHECK(map);
2095
2096   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2097   DALI_TEST_CHECK(value);
2098   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 600), TEST_LOCATION); // Change the internal size according to the image view size
2099
2100   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2101   DALI_TEST_CHECK(value);
2102   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2103
2104   value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2105   DALI_TEST_CHECK(value);
2106   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2107
2108   END_TEST;
2109 }
2110
2111 int UtcDaliImageViewFittingModesChangeFittingMode01(void)
2112 {
2113   ToolkitTestApplication application;
2114
2115   tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2116
2117   ImageView imageView = ImageView::New();
2118
2119   // 1. Render using FittingMode::SHRINK_TO_FIT
2120   Property::Map imageMap;
2121   imageMap[Toolkit::Visual::Property::TYPE]            = Toolkit::Visual::IMAGE;
2122   imageMap[Toolkit::ImageVisual::Property::URL]        = gImage_600_RGB;
2123   imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2124
2125   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2126   imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2127
2128   application.GetScene().Add(imageView);
2129
2130   // Trigger a potential relayout
2131   application.SendNotification();
2132   application.Render();
2133
2134   Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2135   Property::Map         returnedMap;
2136   visual.CreatePropertyMap(returnedMap);
2137
2138   Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2139   DALI_TEST_CHECK(value);
2140   Property::Map* map = value->GetMap();
2141   DALI_TEST_CHECK(map);
2142
2143   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2144   DALI_TEST_CHECK(value);
2145   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2146
2147   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2148   DALI_TEST_CHECK(value);
2149   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2150
2151   value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2152   DALI_TEST_CHECK(value);
2153   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2154
2155   // 2. Render again using DevelVisaul::CENTER
2156   Property::Map imageMap2;
2157   imageMap2[Toolkit::Visual::Property::TYPE]            = Toolkit::Visual::IMAGE;
2158   imageMap2[Toolkit::ImageVisual::Property::URL]        = gImage_600_RGB;
2159   imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2160
2161   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2162   imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2163
2164   application.GetScene().Add(imageView);
2165
2166   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2167
2168   // Trigger a potential relayout
2169   application.SendNotification();
2170   application.Render();
2171
2172   returnedMap.Clear();
2173   visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2174
2175   visual.CreatePropertyMap(returnedMap);
2176
2177   value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2178   DALI_TEST_CHECK(value);
2179   map = value->GetMap();
2180   DALI_TEST_CHECK(map);
2181
2182   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2183   DALI_TEST_CHECK(value);
2184   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2185
2186   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2187   DALI_TEST_CHECK(value);
2188   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2189
2190   value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2191   DALI_TEST_CHECK(value);
2192   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2193
2194   // 3. Render again using before fittingMode
2195   Property::Map imageMap3;
2196   imageMap3[Toolkit::Visual::Property::TYPE]            = Toolkit::Visual::IMAGE;
2197   imageMap3[Toolkit::ImageVisual::Property::URL]        = gImage_600_RGB;
2198   imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
2199
2200   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2201   imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2202
2203   application.GetScene().Add(imageView);
2204
2205   // Trigger a potential relayout
2206   application.SendNotification();
2207   application.Render();
2208
2209   returnedMap.Clear();
2210   visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2211   visual.CreatePropertyMap(returnedMap);
2212
2213   value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2214   DALI_TEST_CHECK(value);
2215   map = value->GetMap();
2216   DALI_TEST_CHECK(map);
2217
2218   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2219   DALI_TEST_CHECK(value);
2220   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(700, 700), TEST_LOCATION); // Change the internal size according to the image view size
2221
2222   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2223   DALI_TEST_CHECK(value);
2224   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2225
2226   value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2227   DALI_TEST_CHECK(value);
2228   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(50, 0), TEST_LOCATION);
2229
2230   END_TEST;
2231 }
2232
2233 int UtcDaliImageViewFittingModesChangeFittingMode02(void)
2234 {
2235   ToolkitTestApplication application;
2236
2237   tet_infoline("UtcDaliImageViewFittingModesChangeFittingMode, image: [600,600], view:[800,700]");
2238
2239   ImageView imageView = ImageView::New();
2240
2241   // 1. Render using FittingMode::OVER_FIT_KEEP_ASPECT_RATIO
2242   Property::Map imageMap;
2243   imageMap[Toolkit::Visual::Property::TYPE]            = Toolkit::Visual::IMAGE;
2244   imageMap[Toolkit::ImageVisual::Property::URL]        = gImage_600_RGB;
2245   imageMap[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2246
2247   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2248   imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2249
2250   application.GetScene().Add(imageView);
2251
2252   // Trigger a potential relayout
2253   application.SendNotification();
2254   application.Render();
2255
2256   Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2257   Property::Map         returnedMap;
2258   visual.CreatePropertyMap(returnedMap);
2259
2260   Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2261   DALI_TEST_CHECK(value);
2262   Property::Map* map = value->GetMap();
2263   DALI_TEST_CHECK(map);
2264
2265   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2266   DALI_TEST_CHECK(value);
2267   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2268
2269   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2270   DALI_TEST_CHECK(value);
2271   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2272
2273   value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2274   DALI_TEST_CHECK(value);
2275   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2276
2277   // 2. Render again using DevelVisaul::CENTER
2278   Property::Map imageMap2;
2279   imageMap2[Toolkit::Visual::Property::TYPE]            = Toolkit::Visual::IMAGE;
2280   imageMap2[Toolkit::ImageVisual::Property::URL]        = gImage_600_RGB;
2281   imageMap2[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::CENTER;
2282
2283   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap2);
2284   imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2285
2286   application.GetScene().Add(imageView);
2287
2288   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2289
2290   // Trigger a potential relayout
2291   application.SendNotification();
2292   application.Render();
2293
2294   returnedMap.Clear();
2295   visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2296
2297   visual.CreatePropertyMap(returnedMap);
2298
2299   value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2300   DALI_TEST_CHECK(value);
2301   map = value->GetMap();
2302   DALI_TEST_CHECK(map);
2303
2304   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2305   DALI_TEST_CHECK(value);
2306   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(600, 600), TEST_LOCATION); // Change the internal size according to the image view size
2307
2308   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2309   DALI_TEST_CHECK(value);
2310   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2311
2312   value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2313   DALI_TEST_CHECK(value);
2314   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(100, 50), TEST_LOCATION);
2315
2316   // 3. Render again using before fittingMode
2317   Property::Map imageMap3;
2318   imageMap3[Toolkit::Visual::Property::TYPE]            = Toolkit::Visual::IMAGE;
2319   imageMap3[Toolkit::ImageVisual::Property::URL]        = gImage_600_RGB;
2320   imageMap3[DevelVisual::Property::VISUAL_FITTING_MODE] = Toolkit::DevelVisual::OVER_FIT_KEEP_ASPECT_RATIO;
2321
2322   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap3);
2323   imageView.SetProperty(Actor::Property::SIZE, Vector2(800, 700));
2324
2325   application.GetScene().Add(imageView);
2326
2327   // Trigger a potential relayout
2328   application.SendNotification();
2329   application.Render();
2330
2331   returnedMap.Clear();
2332   visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2333   visual.CreatePropertyMap(returnedMap);
2334
2335   value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2336   DALI_TEST_CHECK(value);
2337   map = value->GetMap();
2338   DALI_TEST_CHECK(map);
2339
2340   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2341   DALI_TEST_CHECK(value);
2342   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(800, 700), TEST_LOCATION); // Change the internal size according to the image view size
2343
2344   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2345   DALI_TEST_CHECK(value);
2346   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE), TEST_LOCATION);
2347
2348   value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2349   DALI_TEST_CHECK(value);
2350   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION);
2351
2352   END_TEST;
2353 }
2354
2355 int UtcDaliImageViewFittingModesWithAnimatedVectorImageVisual(void)
2356 {
2357   ToolkitTestApplication application;
2358
2359   tet_infoline("Create an ImageVisual using SCALE_TO_FILL and animated vector image ( image: [600,600], view:[600,600] )");
2360
2361   ImageView     imageView = ImageView::New();
2362   Property::Map imageMap;
2363   imageMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE);
2364   imageMap.Add(Toolkit::ImageVisual::Property::URL, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME); // 249x169 image
2365
2366   imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
2367   imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
2368
2369   application.GetScene().Add(imageView);
2370
2371   // Trigger a potential relayout
2372   application.SendNotification();
2373   application.Render();
2374
2375   Toolkit::Visual::Base visual = DevelControl::GetVisual(Toolkit::Internal::GetImplementation(imageView), Toolkit::ImageView::Property::IMAGE);
2376   Property::Map         returnedMap;
2377   visual.CreatePropertyMap(returnedMap);
2378
2379   Property::Value* value = returnedMap.Find(Toolkit::Visual::Property::TRANSFORM);
2380   DALI_TEST_CHECK(value);
2381   Property::Map* map = value->GetMap();
2382   DALI_TEST_CHECK(map);
2383
2384   value = map->Find(Toolkit::Visual::Transform::Property::SIZE);
2385   DALI_TEST_CHECK(value);
2386   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2::ONE, TEST_LOCATION); // Relative size so will take up 100%
2387
2388   value = map->Find(Toolkit::Visual::Transform::Property::SIZE_POLICY);
2389   DALI_TEST_CHECK(value);
2390   DALI_TEST_CHECK(value->Get<int>() == Toolkit::Visual::Transform::Policy::RELATIVE);
2391
2392   value = map->Find(Toolkit::Visual::Transform::Property::OFFSET);
2393   DALI_TEST_CHECK(value);
2394   DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
2395
2396   END_TEST;
2397 }
2398
2399 int UtcDaliImageViewCustomShader(void)
2400 {
2401   ToolkitTestApplication application;
2402
2403   // Set a custom shader with an image url
2404   {
2405     Property::Map     properties;
2406     Property::Map     shader;
2407     const std::string vertexShader                    = "Foobar";
2408     const std::string fragmentShader                  = "Foobar";
2409     shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2410     shader[Visual::Shader::Property::VERTEX_SHADER]   = vertexShader;
2411
2412     properties[Visual::Property::TYPE]     = Visual::IMAGE;
2413     properties[Visual::Property::SHADER]   = shader;
2414     properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2415
2416     ImageView imageView = ImageView::New();
2417     imageView.SetProperty(ImageView::Property::IMAGE, properties);
2418
2419     application.GetScene().Add(imageView);
2420
2421     application.SendNotification();
2422     application.Render();
2423
2424     DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2425
2426     Renderer        renderer = imageView.GetRendererAt(0);
2427     Shader          shader2  = renderer.GetShader();
2428     Property::Value value    = shader2.GetProperty(Shader::Property::PROGRAM);
2429     Property::Map*  map      = value.GetMap();
2430     DALI_TEST_CHECK(map);
2431
2432     Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2433     DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2434
2435     Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2436     DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2437   }
2438
2439   // Set a custom shader after setting an image url
2440   {
2441     Property::Map     properties;
2442     Property::Map     shader;
2443     const std::string vertexShader                    = "Foobar";
2444     const std::string fragmentShader                  = "Foobar";
2445     shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2446     shader[Visual::Shader::Property::VERTEX_SHADER]   = vertexShader;
2447
2448     properties[Visual::Property::SHADER] = shader;
2449
2450     ImageView imageView = ImageView::New(TEST_IMAGE_FILE_NAME);
2451     imageView.SetProperty(ImageView::Property::IMAGE, properties);
2452
2453     application.GetScene().Add(imageView);
2454
2455     application.SendNotification();
2456     application.Render();
2457
2458     DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2459
2460     Renderer        renderer = imageView.GetRendererAt(0);
2461     Shader          shader2  = renderer.GetShader();
2462     Property::Value value    = shader2.GetProperty(Shader::Property::PROGRAM);
2463     Property::Map*  map      = value.GetMap();
2464     DALI_TEST_CHECK(map);
2465
2466     Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2467     DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2468
2469     Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2470     DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2471   }
2472
2473   // Set a custom shader before setting an image url
2474   {
2475     Property::Map     properties;
2476     Property::Map     shader;
2477     const std::string vertexShader                    = "Foobar";
2478     const std::string fragmentShader                  = "Foobar";
2479     shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2480     shader[Visual::Shader::Property::VERTEX_SHADER]   = vertexShader;
2481
2482     properties[Visual::Property::SHADER] = shader;
2483
2484     ImageView imageView = ImageView::New();
2485     imageView.SetProperty(ImageView::Property::IMAGE, properties);
2486     imageView.SetProperty(ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME);
2487
2488     application.GetScene().Add(imageView);
2489
2490     application.SendNotification();
2491     application.Render();
2492     DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2493
2494     Renderer        renderer = imageView.GetRendererAt(0);
2495     Shader          shader2  = renderer.GetShader();
2496     Property::Value value    = shader2.GetProperty(Shader::Property::PROGRAM);
2497     Property::Map*  map      = value.GetMap();
2498     DALI_TEST_CHECK(map);
2499
2500     Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2501     DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2502
2503     Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2504     DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2505   }
2506
2507   // Set a custom shader after setting a property map
2508   {
2509     Property::Map     properties;
2510     Property::Map     shader;
2511     const std::string vertexShader                    = "Foobar";
2512     const std::string fragmentShader                  = "Foobar";
2513     shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2514     shader[Visual::Shader::Property::VERTEX_SHADER]   = vertexShader;
2515
2516     properties[Visual::Property::SHADER] = shader;
2517
2518     Property::Map properties1;
2519     properties1[Visual::Property::TYPE]     = Visual::IMAGE;
2520     properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2521
2522     ImageView imageView = ImageView::New();
2523     imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2524     imageView.SetProperty(ImageView::Property::IMAGE, properties);
2525
2526     application.GetScene().Add(imageView);
2527
2528     application.SendNotification();
2529     application.Render();
2530     DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2531
2532     Renderer        renderer = imageView.GetRendererAt(0);
2533     Shader          shader2  = renderer.GetShader();
2534     Property::Value value    = shader2.GetProperty(Shader::Property::PROGRAM);
2535     Property::Map*  map      = value.GetMap();
2536     DALI_TEST_CHECK(map);
2537
2538     Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2539     DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2540
2541     Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2542     DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2543   }
2544
2545   // Set a custom shader before setting a property map
2546   {
2547     Property::Map     properties;
2548     Property::Map     shader;
2549     const std::string vertexShader                    = "Foobar";
2550     const std::string fragmentShader                  = "Foobar";
2551     shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2552     shader[Visual::Shader::Property::VERTEX_SHADER]   = vertexShader;
2553
2554     properties[Visual::Property::SHADER] = shader;
2555
2556     Property::Map properties1;
2557     properties1[Visual::Property::TYPE]     = Visual::IMAGE;
2558     properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2559
2560     ImageView imageView = ImageView::New();
2561     imageView.SetProperty(ImageView::Property::IMAGE, properties);
2562     imageView.SetProperty(ImageView::Property::IMAGE, properties1);
2563
2564     application.GetScene().Add(imageView);
2565
2566     application.SendNotification();
2567     application.Render();
2568     DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2569
2570     Renderer        renderer = imageView.GetRendererAt(0);
2571     Shader          shader2  = renderer.GetShader();
2572     Property::Value value    = shader2.GetProperty(Shader::Property::PROGRAM);
2573     Property::Map*  map      = value.GetMap();
2574     DALI_TEST_CHECK(map);
2575
2576     Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
2577     DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
2578
2579     Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
2580     DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
2581   }
2582
2583   END_TEST;
2584 }
2585
2586 namespace
2587 {
2588 static int gFailCounter = 0;
2589 const int  MAX_RETRIES(3);
2590
2591 void ReloadImage(ImageView imageView)
2592 {
2593   Property::Map imageImmediateLoadingMap;
2594   imageImmediateLoadingMap[ImageVisual::Property::URL]         = "Non-existant-image.jpg";
2595   imageImmediateLoadingMap[ImageVisual::Property::LOAD_POLICY] = ImageVisual::LoadPolicy::IMMEDIATE;
2596
2597   tet_infoline("Immediate load an image");
2598   imageView.SetProperty(ImageView::Property::IMAGE, imageImmediateLoadingMap);
2599 }
2600
2601 void ResourceFailedReload(Control control)
2602 {
2603   gFailCounter++;
2604   if(gFailCounter < MAX_RETRIES)
2605   {
2606     ReloadImage(ImageView::DownCast(control));
2607   }
2608 }
2609 } // namespace
2610
2611 int UtcDaliImageViewReloadFailedOnResourceReadySignal(void)
2612 {
2613   tet_infoline("Test reloading failed image from within signal handler.");
2614
2615   ToolkitTestApplication application;
2616
2617   gFailCounter = 0;
2618
2619   ImageView imageView = ImageView::New();
2620   imageView.ResourceReadySignal().Connect(&ResourceFailedReload);
2621   DALI_TEST_EQUALS(gFailCounter, 0, TEST_LOCATION);
2622   ReloadImage(imageView);
2623
2624   // loading started, this waits for the loader thread to complete
2625   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2626   application.SendNotification();
2627
2628   DALI_TEST_EQUALS(gFailCounter, 1, TEST_LOCATION);
2629
2630   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2631   application.SendNotification();
2632
2633   DALI_TEST_EQUALS(gFailCounter, 2, TEST_LOCATION);
2634
2635   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2636   application.SendNotification();
2637   DALI_TEST_EQUALS(gFailCounter, 3, TEST_LOCATION);
2638
2639   END_TEST;
2640 }
2641
2642 int UtcDaliImageViewLoadRemoteSVG(void)
2643 {
2644   tet_infoline("Test load from a remote server.");
2645
2646   ToolkitTestApplication application;
2647   Toolkit::ImageView     imageView;
2648   imageView = Toolkit::ImageView::New();
2649   imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
2650   // Victor. Temporary (or permanent?) update as the url above seems not to work from time to time ...
2651   //  imageView.SetImage("https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/SVG_logo.svg/64px-SVG_logo.svg.png");
2652   imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2653   imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2654   imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
2655   imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
2656
2657   application.GetScene().Add(imageView);
2658
2659   DALI_TEST_CHECK(imageView);
2660
2661   DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
2662
2663   application.SendNotification();
2664
2665   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2666
2667   application.SendNotification();
2668   application.Render();
2669
2670   DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
2671
2672   END_TEST;
2673 }
2674
2675 int UtcDaliImageViewSyncSVGLoading(void)
2676 {
2677   ToolkitTestApplication application;
2678
2679   tet_infoline("ImageView Testing SVG image sync loading");
2680
2681   // Sync loading, automatic atlasing for small size image
2682   {
2683     TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2684     callStack.Reset();
2685     callStack.Enable(true);
2686
2687     ImageView imageView = ImageView::New();
2688
2689     // Sync loading is used
2690     Property::Map syncLoadingMap;
2691     syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2692     syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2693     syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2694     imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2695
2696     application.GetScene().Add(imageView);
2697     DALI_TEST_CHECK(imageView);
2698
2699     application.SendNotification();
2700     application.Render(16);
2701     Vector3 naturalSize = imageView.GetNaturalSize();
2702
2703     DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2704     DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2705   }
2706   END_TEST;
2707 }
2708
2709 int UtcDaliImageViewAsyncSVGLoading(void)
2710 {
2711   ToolkitTestApplication application;
2712
2713   tet_infoline("ImageView Testing SVG image async loading");
2714
2715   // Sync loading, automatic atlasing for small size image
2716   {
2717     TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2718     callStack.Reset();
2719     callStack.Enable(true);
2720
2721     ImageView imageView = ImageView::New();
2722
2723     // Sync loading is used
2724     Property::Map syncLoadingMap;
2725     syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2726     syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2727     syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, false);
2728     imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2729
2730     application.GetScene().Add(imageView);
2731     DALI_TEST_CHECK(imageView);
2732
2733     application.SendNotification();
2734     application.Render(16);
2735     Vector3 naturalSize = imageView.GetNaturalSize();
2736
2737     DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2738     DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2739   }
2740   END_TEST;
2741 }
2742
2743 int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
2744 {
2745   ToolkitTestApplication application;
2746
2747   tet_infoline("ImageView Testing SVG image async loading");
2748
2749   // Sync loading, automatic atlasing for small size image
2750   {
2751     TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
2752     callStack.Reset();
2753     callStack.Enable(true);
2754
2755     ImageView imageView = ImageView::New();
2756
2757     // Sync loading is used
2758     Property::Map syncLoadingMap;
2759     syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
2760     syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
2761
2762     // Check to set invalid value
2763     // The SYNCHRONOUS_LOADING property must be set to the bool value.
2764     // Check if error log is outputted when setting other value like string.
2765     // Even if the wrong value is set, the image will be shown normally, and the synchronous value should be the default value(false).
2766     syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, std::to_string(5));
2767     imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
2768
2769     application.GetScene().Add(imageView);
2770     DALI_TEST_CHECK(imageView);
2771
2772     application.SendNotification();
2773     application.Render(16);
2774     Vector3 naturalSize = imageView.GetNaturalSize();
2775     DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2776     DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2777
2778     Property::Value value = imageView.GetProperty(ImageView::Property::IMAGE);
2779     Property::Map*  map   = value.GetMap();
2780     DALI_TEST_CHECK(map);
2781
2782     Property::Value* sync = map->Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING);
2783     DALI_TEST_CHECK(sync);
2784     DALI_TEST_EQUALS(false, sync->Get<bool>(), TEST_LOCATION);
2785   }
2786   END_TEST;
2787 }
2788
2789 int UtcDaliImageViewSvgLoadingFailure(void)
2790 {
2791   ToolkitTestApplication application;
2792
2793   // Local svg file - invalid file path
2794   {
2795     gResourceReadySignalFired = false;
2796
2797     ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
2798     imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2799     imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2800
2801     DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2802
2803     application.GetScene().Add(imageView);
2804
2805     application.SendNotification();
2806     application.Render(16);
2807
2808     DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2809     DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2810     DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2811   }
2812
2813   // Local svg file - invalid file
2814   {
2815     gResourceReadySignalFired = false;
2816
2817     ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.svg");
2818     imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2819     imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2820
2821     DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2822
2823     application.GetScene().Add(imageView);
2824
2825     application.SendNotification();
2826     application.Render(16);
2827
2828     DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2829     DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2830     DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2831   }
2832
2833   // Remote svg file
2834   {
2835     gResourceReadySignalFired = false;
2836
2837     ImageView imageView = ImageView::New("https://bar.org/foobar.svg");
2838     imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2839     imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2840
2841     DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2842
2843     application.GetScene().Add(imageView);
2844
2845     application.SendNotification();
2846
2847     // loading started, this waits for the loader thread
2848     DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2849
2850     application.SendNotification();
2851     application.Render(16);
2852
2853     DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2854     DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2855     DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2856   }
2857
2858   END_TEST;
2859 }
2860
2861 int UtcDaliImageViewSvgRasterizationFailure(void)
2862 {
2863   ToolkitTestApplication application;
2864
2865   gResourceReadySignalFired = false;
2866
2867   ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/svg1.svg");
2868   imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2869   imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
2870
2871   DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
2872
2873   application.GetScene().Add(imageView);
2874
2875   application.SendNotification();
2876
2877   // loading started, this waits for the loader thread
2878   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2879
2880   application.SendNotification();
2881   application.Render(16);
2882
2883   DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2884   DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2885   DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::READY, TEST_LOCATION);
2886
2887   // Reset flag
2888   gResourceReadySignalFired = false;
2889
2890   // Change size
2891   imageView.SetProperty(Actor::Property::SIZE, Vector2(0.f, 0.f));
2892
2893   application.SendNotification();
2894
2895   // rasterization started, this waits for the rasterize thread
2896   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2897
2898   application.SendNotification();
2899   application.Render(16);
2900
2901   DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
2902   DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
2903   // Fail to rasterize because the size is 0.
2904   DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
2905
2906   END_TEST;
2907 }
2908
2909 int UtcDaliImageViewTVGLoading(void)
2910 {
2911   ToolkitTestApplication application;
2912
2913   tet_infoline("ImageView Testing TVG image loading");
2914
2915   {
2916     ImageView imageView = ImageView::New();
2917
2918     imageView.SetImage(TEST_RESOURCE_DIR "/test.tvg");
2919
2920     application.GetScene().Add(imageView);
2921     DALI_TEST_CHECK(imageView);
2922     Vector3 naturalSize = imageView.GetNaturalSize();
2923
2924     DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
2925     DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
2926   }
2927   END_TEST;
2928 }
2929 int UtcDaliImageViewImageLoadFailure01(void)
2930 {
2931   ToolkitTestApplication application;
2932
2933   Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
2934   DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
2935   DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
2936   DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
2937
2938   std::string brokenUrl;
2939   brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
2940   DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
2941
2942   brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
2943   DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
2944
2945   brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
2946   DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
2947
2948   ImageView imageView = ImageView::New("invalidUrl.png");
2949   imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2950
2951   application.GetScene().Add(imageView);
2952   application.SendNotification();
2953   application.Render(16);
2954
2955   // loading started, this waits for the loader thread
2956   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2957
2958   END_TEST;
2959 }
2960
2961 int UtcDaliImageViewImageLoadFailure02(void)
2962 {
2963   ToolkitTestApplication application;
2964
2965   Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
2966   DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_DEFAULT);
2967   DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
2968   DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
2969
2970   std::string brokenUrl;
2971   brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
2972   DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_DEFAULT, brokenUrl, TEST_LOCATION);
2973
2974   brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
2975   DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_M, brokenUrl, TEST_LOCATION);
2976
2977   brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
2978   DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
2979
2980   ImageView imageView = ImageView::New("invalidUrl.png");
2981   imageView.SetProperty(Actor::Property::SIZE, Vector2(30.f, 30.f));
2982   application.GetScene().Add(imageView);
2983   application.SendNotification();
2984   application.Render(16);
2985
2986   // loading started, this waits for the loader thread
2987   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2988
2989   END_TEST;
2990 }
2991
2992 int UtcDaliImageViewImageLoadFailure03(void)
2993 {
2994   ToolkitTestApplication application;
2995
2996   Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
2997   DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_01);
2998   DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_02);
2999
3000   std::string brokenUrl;
3001   brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3002   DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_01, brokenUrl, TEST_LOCATION);
3003
3004   brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL);
3005   DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_02, brokenUrl, TEST_LOCATION);
3006
3007   ImageView imageView = ImageView::New("invalidUrl.png");
3008   imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3009   application.GetScene().Add(imageView);
3010   application.SendNotification();
3011   application.Render(16);
3012
3013   // loading started, this waits for the loader thread
3014   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3015
3016   END_TEST;
3017 }
3018
3019 int UtcDaliImageViewImageLoadFailure04(void)
3020 {
3021   ToolkitTestApplication application;
3022
3023   ImageView imageView = ImageView::New("invalidUrl.png");
3024   imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3025   application.GetScene().Add(imageView);
3026   application.SendNotification();
3027   application.Render(16);
3028
3029   // loading started, this waits for the loader thread
3030   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3031
3032   Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
3033   DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
3034   DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
3035   DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
3036
3037   ImageView imageView2 = ImageView::New("invalidUrl.png");
3038   imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3039   application.GetScene().Add(imageView2);
3040
3041   std::string brokenUrl;
3042   brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
3043   DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
3044
3045   brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
3046   DALI_TEST_EQUALS(TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
3047
3048   application.SendNotification();
3049   application.Render(16);
3050
3051   // loading started, this waits for the loader thread
3052   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3053
3054   DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
3055
3056   ImageView imageView3 = ImageView::New("invalidUrl.png");
3057   imageView3.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
3058   application.GetScene().Add(imageView3);
3059
3060   application.SendNotification();
3061   application.Render(16);
3062
3063   // loading started, this waits for the loader thread
3064   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3065
3066   END_TEST;
3067 }
3068
3069 namespace
3070 {
3071 static int gResourceReadySignalCounter = 0;
3072
3073 void OnResourceReadySignal01(Control control)
3074 {
3075   gResourceReadySignalCounter++;
3076
3077   if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::READY)
3078   {
3079     if(gResourceReadySignalCounter == 1)
3080     {
3081       // Set image twice
3082       // It makes the first new visual be deleted immediately
3083       ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3084       ImageView::DownCast(control).SetImage(gImage_34_RGBA);
3085     }
3086   }
3087   else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
3088   {
3089     // Make the resource ready immediately
3090     control[ImageView::Property::IMAGE] = TEST_RESOURCE_DIR "/svg1.svg";
3091   }
3092 }
3093
3094 void OnResourceReadySignal02(Control control)
3095 {
3096   if(++gResourceReadySignalCounter == 1)
3097   {
3098     // It makes the first new visual be deleted immediately
3099     // The first image will not be loaded.
3100     control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB).Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
3101     control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3102   }
3103 }
3104
3105 ImageView gImageView1;
3106 ImageView gImageView2;
3107 ImageView gImageView3;
3108
3109 void OnResourceReadySignal03(Control control)
3110 {
3111   if(gResourceReadySignalCounter == 0)
3112   {
3113     // Queue loading
3114     // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
3115     gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
3116
3117     // 2. Load a new image
3118     gImageView3[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3119
3120     // 3. Use the new image again
3121     gImageView1[ImageView::Property::IMAGE] = TEST_IMAGE_1;
3122     gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3123   }
3124   else if(gResourceReadySignalCounter == 1)
3125   {
3126     // This is called from TextureManager::ProcessQueuedTextures().
3127     gImageView1.Unparent();
3128     gImageView1.Reset();
3129   }
3130   gResourceReadySignalCounter++;
3131 }
3132
3133 void OnSimpleResourceReadySignal(Control control)
3134 {
3135   // simply increate counter
3136   gResourceReadySignalCounter++;
3137 }
3138
3139 } // namespace
3140
3141 int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
3142 {
3143   tet_infoline("Test setting image from within signal handler.");
3144
3145   ToolkitTestApplication application;
3146
3147   gResourceReadySignalCounter = 0;
3148
3149   ImageView imageView = ImageView::New(gImage_34_RGBA);
3150   imageView.ResourceReadySignal().Connect(&OnResourceReadySignal01);
3151
3152   application.GetScene().Add(imageView);
3153
3154   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3155
3156   application.SendNotification();
3157   application.Render();
3158
3159   DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3160
3161   DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3162
3163   // Reset count
3164   gResourceReadySignalCounter = 0;
3165
3166   imageView[ImageView::Property::IMAGE] = "invalid.jpg";
3167
3168   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3169
3170   application.SendNotification();
3171   application.Render();
3172
3173   // Run idle callback
3174   application.RunIdles();
3175
3176   DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3177
3178   DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3179
3180   END_TEST;
3181 }
3182
3183 int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
3184 {
3185   tet_infoline("Test setting image from within signal handler.");
3186
3187   ToolkitTestApplication application;
3188
3189   gResourceReadySignalCounter = 0;
3190
3191   ImageView imageView = ImageView::New(gImage_34_RGBA);
3192   imageView.ResourceReadySignal().Connect(&OnResourceReadySignal02);
3193
3194   application.GetScene().Add(imageView);
3195
3196   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3197
3198   application.SendNotification();
3199   application.Render();
3200
3201   // Wait for loading an image
3202   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3203
3204   DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION);
3205
3206   DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
3207
3208   END_TEST;
3209 }
3210
3211 int UtcDaliImageViewSetImageOnResourceReadySignal03(void)
3212 {
3213   tet_infoline("Test setting image from within signal handler.");
3214
3215   ToolkitTestApplication application;
3216
3217   gResourceReadySignalCounter = 0;
3218
3219   gImageView1 = ImageView::New(gImage_34_RGBA);
3220   application.GetScene().Add(gImageView1);
3221
3222   // Wait for loading
3223   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3224
3225   gImageView2 = ImageView::New(gImage_600_RGB);
3226   gImageView2.ResourceReadySignal().Connect(&OnResourceReadySignal03);
3227   application.GetScene().Add(gImageView2);
3228
3229   gImageView3 = ImageView::New();
3230   application.GetScene().Add(gImageView3);
3231
3232   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
3233
3234   application.SendNotification();
3235   application.Render();
3236
3237   END_TEST;
3238 }
3239
3240 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask01(void)
3241 {
3242   tet_infoline("Test signal handler when image / mask image is broken.");
3243
3244   ToolkitTestApplication application;
3245
3246   auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, const std::string& url, const std::string& mask, const char* location) {
3247     gResourceReadySignalCounter = 0;
3248
3249     Property::Map map;
3250     map[Toolkit::ImageVisual::Property::URL] = url;
3251     if(!mask.empty())
3252     {
3253       map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3254     }
3255     map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3256
3257     ImageView imageView                            = ImageView::New();
3258     imageView[Toolkit::ImageView::Property::IMAGE] = map;
3259     imageView[Actor::Property::SIZE]               = Vector2(100.0f, 200.0f);
3260     imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3261
3262     application.GetScene().Add(imageView);
3263     application.SendNotification();
3264     application.Render();
3265
3266     if(!isSynchronous)
3267     {
3268       // Wait for loading
3269       DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3270     }
3271     tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3272     DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3273
3274     imageView.Unparent();
3275   };
3276
3277   for(int synchronous = 0; synchronous <= 1; synchronous++)
3278   {
3279     tet_printf("Test normal case (sync:%d)\n", synchronous);
3280     TestResourceReadyUrl(1, synchronous, gImage_600_RGB, "", TEST_LOCATION);
3281     TestResourceReadyUrl(3, synchronous, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 3 event trigger required : 2 image load + 1 apply mask
3282
3283     tet_printf("Test broken image case (sync:%d)\n", synchronous);
3284     TestResourceReadyUrl(1, synchronous, "invalid.jpg", "", TEST_LOCATION);
3285     TestResourceReadyUrl(2, synchronous, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3286
3287     tet_printf("Test broken mask image case (sync:%d)\n", synchronous);
3288     TestResourceReadyUrl(2, synchronous, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3289
3290     tet_printf("Test broken both image, mask image case (sync:%d)\n", synchronous);
3291     TestResourceReadyUrl(2, synchronous, "invalid.jpg", "invalid.png", TEST_LOCATION);
3292   }
3293
3294   END_TEST;
3295 }
3296
3297 int UtcDaliImageViewOnResourceReadySignalWithBrokenAlphaMask02(void)
3298 {
3299   tet_infoline("Test signal handler when image try to use cached-and-broken mask image.");
3300
3301   ToolkitTestApplication application;
3302
3303   gResourceReadySignalCounter = 0;
3304
3305   auto TestBrokenMaskResourceReadyUrl = [&application](const std::string& url, const char* location) {
3306     Property::Map map;
3307     map[Toolkit::ImageVisual::Property::URL] = url;
3308     // Use invalid mask url
3309     map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = "invalid.png";
3310
3311     ImageView imageView                            = ImageView::New();
3312     imageView[Toolkit::ImageView::Property::IMAGE] = map;
3313     imageView[Actor::Property::SIZE]               = Vector2(100.0f, 200.0f);
3314     imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3315
3316     application.GetScene().Add(imageView);
3317     application.SendNotification();
3318     application.Render();
3319
3320     // Don't unparent imageView, for keep the cache.
3321   };
3322
3323   // Use more than 4 images (The number of LocalImageLoadThread)
3324   const std::vector<std::string> testUrlList = {gImage_34_RGBA, gImage_600_RGB, "invalid.jpg" /* invalid url */, TEST_IMAGE_1, TEST_IMAGE_2, TEST_BROKEN_IMAGE_DEFAULT};
3325
3326   int expectResourceReadySignalCounter = 0;
3327
3328   for(auto& url : testUrlList)
3329   {
3330     TestBrokenMaskResourceReadyUrl(url, TEST_LOCATION);
3331     expectResourceReadySignalCounter++;
3332   }
3333
3334   // Remain 1 signal due to we use #URL + 1 mask image.
3335   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(expectResourceReadySignalCounter + 1), true, TEST_LOCATION);
3336
3337   DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
3338
3339   END_TEST;
3340 }
3341
3342 int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
3343 {
3344   tet_infoline("Test signal handler various case.");
3345
3346   ToolkitTestApplication application;
3347
3348   auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
3349     gResourceReadySignalCounter = 0;
3350
3351     Property::Map map;
3352     map[Toolkit::ImageVisual::Property::URL] = url;
3353     if(!mask.empty())
3354     {
3355       map[Toolkit::ImageVisual::Property::ALPHA_MASK_URL] = mask;
3356     }
3357     map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = isSynchronous;
3358
3359     ImageView imageView                            = ImageView::New();
3360     imageView[Toolkit::ImageView::Property::IMAGE] = map;
3361     imageView[Actor::Property::SIZE]               = Vector2(100.0f, 200.0f);
3362     imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3363
3364     application.GetScene().Add(imageView);
3365     application.SendNotification();
3366     application.Render();
3367
3368     // Wait for loading
3369     DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(eventTriggerCount), true, location);
3370
3371     tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3372     DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3373     DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3374
3375     imageView.Unparent();
3376   };
3377
3378   auto TestAuxiliaryResourceReadyUrl = [&application](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
3379     gResourceReadySignalCounter = 0;
3380
3381     Property::Map map;
3382     map[Toolkit::ImageVisual::Property::URL]                        = url;
3383     map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE]       = auxiliaryUrl;
3384     map[Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA] = 0.5f;
3385     map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING]        = isSynchronous;
3386
3387     ImageView imageView = ImageView::New();
3388     imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
3389     imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
3390     imageView.ResourceReadySignal().Connect(&OnSimpleResourceReadySignal);
3391     application.GetScene().Add(imageView);
3392
3393     application.SendNotification();
3394     application.Render();
3395
3396     if(!isSynchronous)
3397     {
3398       // Wait for loading
3399       DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, location);
3400     }
3401
3402     tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0);
3403     DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location);
3404     DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3405
3406     imageView.Unparent();
3407   };
3408
3409   // Case 1 : asynchronous loading
3410   tet_printf("Test invalid single simple image Asynchronous\n");
3411
3412   // Test normal case
3413   TestResourceReadyUrl(1, 0, 1, gImage_600_RGB, "", TEST_LOCATION);
3414   TestResourceReadyUrl(1, 0, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // 1 rasterize
3415   TestResourceReadyUrl(1, 0, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
3416
3417   TestResourceReadyUrl(2, 0, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION);                   // 2 image loading - batch size
3418   TestResourceReadyUrl(1, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // 1 rasterize
3419
3420   TestResourceReadyUrl(3, 0, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 2 image loading + 1 applymask
3421
3422   TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
3423
3424   // Test broken case
3425   TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
3426   TestResourceReadyUrl(0, 0, 0, "invalid.svg", "", TEST_LOCATION); // 0 rasterize
3427   TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
3428   TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION);  // 1 image loading
3429   TestResourceReadyUrl(0, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
3430
3431   TestResourceReadyUrl(2, 0, 0, "invalid.jpg", "invalid.png", TEST_LOCATION);  // 2 image loading
3432   TestResourceReadyUrl(2, 0, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); // 2 image loading
3433   TestResourceReadyUrl(2, 0, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION); // 2 image loading
3434
3435   TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
3436   TestAuxiliaryResourceReadyUrl(0, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
3437   TestAuxiliaryResourceReadyUrl(0, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
3438
3439   // Case 2 : Synchronous loading
3440   tet_printf("Test invalid single simple image Synchronous\n");
3441
3442   // Test normal case
3443   TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "", TEST_LOCATION);
3444   TestResourceReadyUrl(0, 1, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
3445   TestResourceReadyUrl(0, 1, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION);
3446
3447   TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION);                   // first frame image loading sync + second frame image loading async
3448   TestResourceReadyUrl(0, 1, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize
3449
3450   TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION);
3451
3452   TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, gImage_34_RGBA, TEST_LOCATION);
3453
3454   // Test broken case
3455   TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
3456   TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION); // 0 rasterize
3457   TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
3458   TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
3459   TestResourceReadyUrl(0, 1, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
3460
3461   TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "invalid.png", TEST_LOCATION);
3462   TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION);
3463   TestResourceReadyUrl(0, 1, 0, "invalid.jpg", gImage_34_RGBA, TEST_LOCATION);
3464
3465   TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", "invalid.png", TEST_LOCATION);
3466   TestAuxiliaryResourceReadyUrl(1, 1, TEST_BROKEN_IMAGE_L, "invalid.png", TEST_LOCATION);
3467   TestAuxiliaryResourceReadyUrl(1, 0, "invalid.9.png", gImage_34_RGBA, TEST_LOCATION);
3468
3469   END_TEST;
3470 }