Resource ready signal for Controls (for ImageLoading)
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ImageView.cpp
1 /*
2  * Copyright (c) 2017 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 // Need to override adaptor classes for toolkit test harness, so include
19 // test harness headers before dali headers.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <toolkit-bitmap-loader.h>
22 #include <toolkit-event-thread-callback.h>
23
24 #include <dali-toolkit/dali-toolkit.h>
25 #include <dali/devel-api/scripting/scripting.h>
26 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
27 #include <dali-toolkit/devel-api/controls/control-devel.h>
28 #include <dali/public-api/rendering/renderer.h>
29
30 #include <test-native-image.h>
31 #include <sstream>
32
33 using namespace Dali;
34 using namespace Toolkit;
35
36 void utc_dali_toolkit_image_view_startup(void)
37 {
38   test_return_value = TET_UNDEF;
39 }
40
41 void utc_dali_toolkit_image_view_cleanup(void)
42 {
43   test_return_value = TET_PASS;
44 }
45
46 namespace
47 {
48
49 const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
50   attribute mediump vec2 aPosition;\n
51   varying mediump vec2 vTexCoord;\n
52   uniform mediump mat4 uMvpMatrix;\n
53   uniform mediump vec3 uSize;\n
54   \n
55   void main()\n
56   {\n
57     mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
58     vertexPosition.xyz *= uSize;\n
59     vertexPosition = uMvpMatrix * vertexPosition;\n
60     \n
61     vTexCoord = aPosition + vec2(0.5);\n
62     gl_Position = vertexPosition;\n
63   }\n
64 );
65
66 const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
67   varying mediump vec2 vTexCoord;\n
68   uniform sampler2D sTexture;\n
69   uniform lowp vec4 uColor;\n
70   \n
71   void main()\n
72   {\n
73     gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
74   }\n
75 );
76
77 const char* TEST_IMAGE_FILE_NAME =  "gallery_image_01.jpg";
78 const char* TEST_IMAGE_FILE_NAME2 =  "gallery_image_02.jpg";
79
80 // resolution: 34*34, pixel format: RGBA8888
81 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
82 // resolution: 600*600, pixel format: RGB888
83 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
84
85 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
86 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
87
88 void TestImage( ImageView imageView, BufferImage image )
89 {
90   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
91
92   Property::Map map;
93   DALI_TEST_CHECK( value.Get( map ) );
94
95   DALI_TEST_CHECK( map.Find( "width" ) );
96   DALI_TEST_CHECK( map.Find( "height" ) );
97   DALI_TEST_CHECK( map.Find( "type" ) );
98
99   int width = 0;
100   DALI_TEST_CHECK( map[ "width" ].Get( width ) );
101   DALI_TEST_EQUALS( (unsigned int)width, image.GetWidth(), TEST_LOCATION );
102
103   int height = 0;
104   DALI_TEST_CHECK( map[ "height" ].Get( height ) );
105   DALI_TEST_EQUALS( (unsigned int)height, image.GetHeight(), TEST_LOCATION );
106
107   std::string type;
108   DALI_TEST_CHECK( map[ "type" ].Get( type ) );
109   DALI_TEST_EQUALS( type, "BufferImage", TEST_LOCATION );
110 }
111
112 void TestImage( ImageView imageView, ResourceImage image )
113 {
114   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
115
116   Property::Map map;
117   DALI_TEST_CHECK( value.Get( map ) );
118
119   if( map.Find( "width" ) )
120   {
121     int width = 0;
122     DALI_TEST_CHECK( map[ "width" ].Get( width ) );
123     DALI_TEST_EQUALS( (unsigned int)width, image.GetWidth(), TEST_LOCATION );
124   }
125
126   if( map.Find( "height" ) )
127   {
128     int height = 0;
129     DALI_TEST_CHECK( map[ "height" ].Get( height ) );
130     DALI_TEST_EQUALS( (unsigned int)height, image.GetHeight(), TEST_LOCATION );
131   }
132
133   DALI_TEST_CHECK( map.Find( "type" ) );
134
135   std::string type;
136   DALI_TEST_CHECK( map[ "type" ].Get( type ) );
137   DALI_TEST_EQUALS( type, "ResourceImage", TEST_LOCATION );
138
139   std::string filename;
140   DALI_TEST_CHECK( map[ "filename" ].Get( filename ) );
141   DALI_TEST_EQUALS( filename, image.GetUrl(), TEST_LOCATION );
142 }
143
144 void TestUrl( ImageView imageView, const std::string url )
145 {
146   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
147
148   std::string urlActual;
149   DALI_TEST_CHECK( value.Get( urlActual ) );
150   DALI_TEST_EQUALS( urlActual, url, TEST_LOCATION );
151 }
152
153 } // namespace
154
155 int UtcDaliImageViewNewP(void)
156 {
157   TestApplication application;
158
159   ImageView imageView = ImageView::New();
160
161   DALI_TEST_CHECK( imageView );
162
163   END_TEST;
164 }
165
166 int UtcDaliImageViewNewImageP(void)
167 {
168   TestApplication application;
169
170   BufferImage image = CreateBufferImage( 100, 200, Vector4( 1.f, 1.f, 1.f, 1.f ) );
171   ImageView imageView = ImageView::New( image );
172
173   DALI_TEST_CHECK( imageView );
174   TestImage( imageView, image );
175
176   END_TEST;
177 }
178
179 int UtcDaliImageViewNewUrlP(void)
180 {
181   TestApplication application;
182
183   ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
184   DALI_TEST_CHECK( imageView );
185
186   TestUrl( imageView, TEST_IMAGE_FILE_NAME );
187
188   END_TEST;
189 }
190
191 int UtcDaliImageViewConstructorP(void)
192 {
193   TestApplication application;
194
195   ImageView imageView;
196
197   DALI_TEST_CHECK( !imageView );
198
199   END_TEST;
200 }
201
202 int UtcDaliImageViewCopyConstructorP(void)
203 {
204   TestApplication application;
205
206   // Initialize an object, ref count == 1
207   ImageView imageView = ImageView::New();
208
209   ImageView copy( imageView );
210   DALI_TEST_CHECK( copy );
211
212   END_TEST;
213 }
214
215 int UtcDaliImageViewAssignmentOperatorP(void)
216 {
217   TestApplication application;
218
219   ImageView imageView = ImageView::New();
220
221   ImageView copy( imageView );
222   DALI_TEST_CHECK( copy );
223   DALI_TEST_EQUALS( imageView, copy, TEST_LOCATION );
224
225   END_TEST;
226 }
227
228 int UtcDaliImageViewDownCastP(void)
229 {
230   TestApplication application;
231
232   ImageView imageView = ImageView::New();
233
234   BaseHandle object(imageView);
235
236   ImageView imageView2 = ImageView::DownCast( object );
237   DALI_TEST_CHECK(imageView2);
238
239   ImageView imageView3 = DownCast< ImageView >( object );
240   DALI_TEST_CHECK(imageView3);
241
242   END_TEST;
243 }
244
245 int UtcDaliImageViewDownCastN(void)
246 {
247   TestApplication application;
248
249   BaseHandle unInitializedObject;
250
251   ImageView imageView1 = ImageView::DownCast( unInitializedObject );
252   DALI_TEST_CHECK( !imageView1 );
253
254   ImageView imageView2 = DownCast< ImageView >( unInitializedObject );
255   DALI_TEST_CHECK( !imageView2 );
256
257   END_TEST;
258 }
259
260 int UtcDaliImageViewTypeRegistry(void)
261 {
262   ToolkitTestApplication application;
263
264   TypeRegistry typeRegistry = TypeRegistry::Get();
265   DALI_TEST_CHECK( typeRegistry );
266
267   TypeInfo typeInfo = typeRegistry.GetTypeInfo( "ImageView" );
268   DALI_TEST_CHECK( typeInfo );
269
270   BaseHandle handle = typeInfo.CreateInstance();
271   DALI_TEST_CHECK( handle );
272
273   ImageView imageView = ImageView::DownCast( handle );
274   DALI_TEST_CHECK( imageView );
275
276   END_TEST;
277 }
278
279 int UtcDaliImageViewSetGetProperty01(void)
280 {
281   ToolkitTestApplication application;
282
283   ImageView imageView = ImageView::New();
284
285   Property::Index idx = imageView.GetPropertyIndex( "image" );
286   DALI_TEST_EQUALS( idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION );
287
288   imageView.SetProperty( idx, TEST_IMAGE_FILE_NAME );
289   TestUrl( imageView, TEST_IMAGE_FILE_NAME );
290
291   END_TEST;
292 }
293
294 int UtcDaliImageViewSetGetProperty02(void)
295 {
296   ToolkitTestApplication application;
297
298   Image image = CreateBufferImage( 10, 10, Color::WHITE );
299   ImageView imageView = ImageView::New(image);
300   Vector4 fullImageRect( 0.f, 0.f, 1.f, 1.f );
301
302   Stage::GetCurrent().Add( imageView );
303
304   application.SendNotification();
305   application.Render();
306   TestGlAbstraction& gl = application.GetGlAbstraction();
307
308   Vector4 pixelAreaUniform;
309   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
310   DALI_TEST_EQUALS( pixelAreaUniform, fullImageRect, TEST_LOCATION );
311
312   Property::Value value = imageView.GetProperty( ImageView::Property::PIXEL_AREA );
313   Vector4 pixelAreaValue;
314   DALI_TEST_CHECK( value.Get(pixelAreaValue) );
315   DALI_TEST_EQUALS( pixelAreaValue, fullImageRect, TEST_LOCATION );
316
317   Vector4 pixelAreaSet( 0.2f, 0.2f, 0.3f, 0.3f );
318   imageView.SetProperty( ImageView::Property::PIXEL_AREA, pixelAreaSet);
319
320   application.SendNotification();
321   application.Render();
322
323   value = imageView.GetProperty( ImageView::Property::PIXEL_AREA );
324   value.Get(pixelAreaValue);
325   DALI_TEST_EQUALS( pixelAreaValue, pixelAreaSet, TEST_LOCATION );
326
327   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
328   DALI_TEST_EQUALS( pixelAreaUniform, pixelAreaSet, TEST_LOCATION );
329
330   END_TEST;
331 }
332
333 int UtcDaliImageViewSetGetProperty03(void)
334 {
335   ToolkitTestApplication application;
336
337   Image image = CreateBufferImage( 10, 10, Color::WHITE );
338   ImageView imageView = ImageView::New(image);
339   Stage::GetCurrent().Add( imageView );
340   application.SendNotification();
341   application.Render();
342
343   // conventional alpha blending
344   Renderer renderer = imageView.GetRendererAt( 0 );
345   Property::Value value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
346   bool enable;
347   DALI_TEST_CHECK( value.Get( enable ) );
348   DALI_TEST_CHECK( !enable );
349
350   // pre-multiplied alpha blending
351   imageView.SetProperty( Toolkit::ImageView::Property::PRE_MULTIPLIED_ALPHA, true );
352   application.SendNotification();
353   application.Render();
354
355   int srcFactorRgb    = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
356   int destFactorRgb   = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
357   int srcFactorAlpha  = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
358   int destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
359   DALI_TEST_CHECK( srcFactorRgb == BlendFactor::ONE );
360   DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
361   DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
362   DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE );
363
364   value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
365   DALI_TEST_CHECK( value.Get( enable ) );
366   DALI_TEST_CHECK( enable );
367
368   END_TEST;
369 }
370
371 int UtcDaliImageViewPixelArea(void)
372 {
373   // Test pixel area property
374   ToolkitTestApplication application;
375
376   // Gif image, use AnimatedImageVisual internally
377   // Atlasing is applied to pack multiple frames, use custom wrap mode
378   ImageView gifView = ImageView::New();
379   const Vector4 pixelAreaVisual( 0.f, 0.f, 2.f, 2.f );
380   gifView.SetProperty( ImageView::Property::IMAGE,
381                        Property::Map().Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
382                                       .Add( ImageVisual::Property::PIXEL_AREA, pixelAreaVisual ) );
383
384   // Add to stage
385   Stage stage = Stage::GetCurrent();
386   stage.Add( gifView );
387
388   // loading started
389   application.SendNotification();
390   application.Render(16);
391   DALI_TEST_CHECK( gifView.GetRendererCount() == 1u );
392
393   const Vector4 fullTextureRect( 0.f, 0.f, 1.f, 1.f );
394   // test that the pixel area value defined in the visual property map is registered on renderer
395   Renderer renderer = gifView.GetRendererAt(0);
396   Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
397   DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION );
398
399   // test that the shader has the default pixel area value registered.
400   Shader shader = renderer.GetShader();
401   pixelAreaValue = shader.GetProperty( shader.GetPropertyIndex( "pixelArea" ) );
402   DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION );
403
404   // test that the uniform uses the pixelArea property on the renderer.
405   TestGlAbstraction& gl = application.GetGlAbstraction();
406   Vector4 pixelAreaUniform;
407   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
408   DALI_TEST_EQUALS( pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
409
410   // set the pixelArea property on the control
411   const Vector4 pixelAreaControl( -1.f, -1.f, 3.f, 3.f );
412   gifView.SetProperty( ImageView::Property::PIXEL_AREA, pixelAreaControl );
413   application.SendNotification();
414   application.Render(16);
415
416   // check the pixelArea property on the control
417   pixelAreaValue = gifView.GetProperty( gifView.GetPropertyIndex( "pixelArea" ) );
418   DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION );
419   // test that the uniform uses the pixelArea property on the control.
420   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
421   DALI_TEST_EQUALS( pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
422
423
424   END_TEST;
425 }
426
427 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
428 {
429   ToolkitTestApplication application;
430
431   // Async loading, no atlasing for big size image
432   ImageView imageView = ImageView::New( gImage_600_RGB );
433
434   // By default, Aysnc loading is used
435   Stage::GetCurrent().Add( imageView );
436   application.SendNotification();
437   application.Render(16);
438   application.Render(16);
439   application.SendNotification();
440
441   // BitmapLoader is not used
442   BitmapLoader loader = BitmapLoader::GetLatestCreated();
443   DALI_TEST_CHECK( !loader );
444
445   END_TEST;
446 }
447
448 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
449 {
450   ToolkitTestApplication application;
451
452   //Async loading, automatic atlasing for small size image
453   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
454   callStack.Reset();
455   callStack.Enable(true);
456
457   Property::Map imageMap;
458
459   imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
460   imageMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
461   imageMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
462   imageMap[ DevelImageVisual::Property::ATLASING] = true;
463
464   ImageView imageView = ImageView::New();
465   imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
466
467   // By default, Aysnc loading is used
468   // loading is not started if the actor is offStage
469
470   Stage::GetCurrent().Add( imageView );
471   application.SendNotification();
472   application.Render(16);
473   application.Render(16);
474   application.SendNotification();
475
476   // loading started, this waits for the loader thread for max 30 seconds
477   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
478
479   application.SendNotification();
480   application.Render(16);
481
482   callStack.Enable(false);
483
484   TraceCallStack::NamedParams params;
485   params["width"] = ToString(34);
486   params["height"] = ToString(34);
487   DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
488
489   END_TEST;
490 }
491
492 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
493 {
494   ToolkitTestApplication application;
495
496   //Async loading, automatic atlasing for small size image
497   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
498   callStack.Reset();
499   callStack.Enable(true);
500
501   Property::Map asyncLoadingMap;
502   asyncLoadingMap[ "url" ] = gImage_34_RGBA;
503   asyncLoadingMap[ "desiredHeight" ] = 34;
504   asyncLoadingMap[ "desiredWidth" ] = 34;
505   asyncLoadingMap[ "synchronousLoading" ] = false;
506   asyncLoadingMap[ "atlasing" ] = true;
507
508   ImageView imageView = ImageView::New();
509   imageView.SetProperty( ImageView::Property::IMAGE, asyncLoadingMap );
510
511   Stage::GetCurrent().Add( imageView );
512   application.SendNotification();
513   application.Render(16);
514   application.Render(16);
515   application.SendNotification();
516
517   // loading started, this waits for the loader thread for max 30 seconds
518   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
519
520   application.SendNotification();
521   application.Render(16);
522
523   callStack.Enable(false);
524
525   TraceCallStack::NamedParams params;
526   params["width"] = ToString(34);
527   params["height"] = ToString(34);
528   DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
529
530   END_TEST;
531 }
532
533 int UtcDaliImageViewSyncLoading(void)
534 {
535   ToolkitTestApplication application;
536
537   tet_infoline("ImageView Testing sync loading and size using index key property map");
538
539   Property::Map syncLoadingMap;
540   syncLoadingMap[ ImageVisual::Property::SYNCHRONOUS_LOADING ] = true;
541   syncLoadingMap[ DevelImageVisual::Property::ATLASING ] = true;
542
543   // Sync loading, no atlasing for big size image
544   {
545     ImageView imageView = ImageView::New();
546
547     // Sync loading is used
548     syncLoadingMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
549     imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
550
551
552     // BitmapLoader is used, and the loading is started immediately even the actor is not on stage.
553     BitmapLoader loader = BitmapLoader::GetLatestCreated();
554     DALI_TEST_CHECK( loader );
555   }
556
557   // Sync loading, automatic atlasing for small size image
558   {
559     BitmapLoader::ResetLatestCreated();
560     TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
561     callStack.Reset();
562     callStack.Enable(true);
563
564     ImageView imageView = ImageView::New( );
565     // Sync loading is used
566     syncLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
567     syncLoadingMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
568     syncLoadingMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
569     imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
570
571     // loading is started even if the actor is offStage
572     BitmapLoader loader = BitmapLoader::GetLatestCreated();
573     DALI_TEST_CHECK( loader );
574
575     loader.WaitForLoading();
576
577     DALI_TEST_CHECK( loader.IsLoaded() );
578
579     Stage::GetCurrent().Add( imageView );
580     application.SendNotification();
581     application.Render(16);
582
583     TraceCallStack::NamedParams params;
584     params["width"] = ToString(34);
585     params["height"] = ToString(34);
586     DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
587                       true, TEST_LOCATION );
588   }
589   END_TEST;
590 }
591
592
593 int UtcDaliImageViewSyncLoading02(void)
594 {
595   ToolkitTestApplication application;
596
597   tet_infoline("ImageView Testing sync loading and size using string key property map");
598
599   // Sync loading, automatic atlasing for small size image
600   {
601     BitmapLoader::ResetLatestCreated();
602     TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
603     callStack.Reset();
604     callStack.Enable(true);
605
606     ImageView imageView = ImageView::New( );
607
608     // Sync loading is used
609     Property::Map syncLoadingMap;
610     syncLoadingMap[ "url" ] = gImage_34_RGBA;
611     syncLoadingMap[ "desiredHeight" ] = 34;
612     syncLoadingMap[ "desiredWidth" ] = 34;
613     syncLoadingMap[ "synchronousLoading" ] = true;
614     syncLoadingMap[ "atlasing" ] = true;
615     imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
616
617     // loading is started even if the actor is offStage
618     BitmapLoader loader = BitmapLoader::GetLatestCreated();
619     DALI_TEST_CHECK( loader );
620
621     loader.WaitForLoading();
622
623     DALI_TEST_CHECK( loader.IsLoaded() );
624
625     Stage::GetCurrent().Add( imageView );
626     application.SendNotification();
627     application.Render(16);
628
629     TraceCallStack::NamedParams params;
630     params["width"] = ToString(34);
631     params["height"] = ToString(34);
632     DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
633                       true, TEST_LOCATION );
634   }
635   END_TEST;
636 }
637
638 int UtcDaliImageViewSizeWithBackground(void)
639 {
640   ToolkitTestApplication application;
641
642   int width = 100;
643   int height = 200;
644   Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
645   ImageView imageView = ImageView::New();
646   imageView.SetBackgroundImage( image );
647
648   Stage::GetCurrent().Add( imageView );
649   application.SendNotification();
650   application.Render();
651
652   DALI_TEST_EQUALS( imageView.GetCurrentSize().width, (float)width, TEST_LOCATION );
653   DALI_TEST_EQUALS( imageView.GetCurrentSize().height, (float)height, TEST_LOCATION );
654
655   END_TEST;
656 }
657
658 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
659 {
660   ToolkitTestApplication application;
661
662   int widthBackground = 100;
663   int heightBackground = 200;
664   int width = 300;
665   int height = 400;
666   Image imageBackground = CreateBufferImage( widthBackground, heightBackground, Vector4(1.f, 1.f, 1.f, 1.f) );
667   Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
668
669   ImageView imageView = ImageView::New();
670   imageView.SetBackgroundImage( imageBackground );
671   imageView.SetImage( image );
672
673   Stage::GetCurrent().Add( imageView );
674   application.SendNotification();
675   application.Render();
676
677   DALI_TEST_EQUALS( imageView.GetCurrentSize().width, (float)width, TEST_LOCATION );
678   DALI_TEST_EQUALS( imageView.GetCurrentSize().height, (float)height, TEST_LOCATION );
679
680   END_TEST;
681 }
682
683 int UtcDaliImageViewHeightForWidthBackground(void)
684 {
685   ToolkitTestApplication application;
686
687   int widthBackground = 100;
688   int heightBackground = 200;
689   Image imageBackground = CreateBufferImage( widthBackground, heightBackground, Vector4(1.f, 1.f, 1.f, 1.f) );
690
691   ImageView imageView = ImageView::New();
692   imageView.SetBackgroundImage( imageBackground );
693
694   Stage::GetCurrent().Add( imageView );
695   application.SendNotification();
696   application.Render();
697
698   Control control = Control::DownCast( imageView );
699   DALI_TEST_CHECK( control );
700   DALI_TEST_EQUALS( imageView.GetHeightForWidth( 123.f ), control.GetHeightForWidth( 123.f ), TEST_LOCATION );
701   DALI_TEST_EQUALS( imageView.GetWidthForHeight( 321.f ), control.GetWidthForHeight( 321.f ), TEST_LOCATION );
702
703   END_TEST;
704 }
705
706 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
707 {
708   ToolkitTestApplication application;
709
710   int widthBackground = 100;
711   int heightBackground = 200;
712   int width = 300;
713   int height = 400;
714   Image imageBackground = CreateBufferImage( widthBackground, heightBackground, Vector4(1.f, 1.f, 1.f, 1.f) );
715   Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
716
717   ImageView imageView = ImageView::New();
718   imageView.SetBackgroundImage( imageBackground );
719   imageView.SetImage( image );
720
721   Stage::GetCurrent().Add( imageView );
722   application.SendNotification();
723   application.Render();
724
725   DALI_TEST_EQUALS( imageView.GetHeightForWidth( width ), (float)height, TEST_LOCATION );
726   DALI_TEST_EQUALS( imageView.GetWidthForHeight( height ), (float)width, TEST_LOCATION );
727
728   END_TEST;
729 }
730
731 int UtcDaliImageViewSetBufferImage(void)
732 {
733   ToolkitTestApplication application;
734
735   int width1 = 300;
736   int height1 = 400;
737   BufferImage image1 = CreateBufferImage( width1, height1, Vector4( 1.f, 1.f, 1.f, 1.f ) );
738   ImageView imageView = ImageView::New();
739   imageView.SetImage( image1 );
740
741   TestImage( imageView, image1 );
742
743   int width2 = 600;
744   int height2 = 500;
745   BufferImage image2 = CreateBufferImage( width2, height2, Vector4( 1.f, 1.f, 1.f, 1.f ) );
746   imageView.SetImage( image2 );
747
748   TestImage( imageView, image2 );
749
750   END_TEST;
751 }
752
753 int UtcDaliImageViewSetImageUrl(void)
754 {
755   ToolkitTestApplication application;
756
757   ImageView imageView = ImageView::New();
758   imageView.SetImage( TEST_IMAGE_FILE_NAME );
759   TestUrl( imageView, TEST_IMAGE_FILE_NAME );
760
761
762   imageView.SetImage( TEST_IMAGE_FILE_NAME2 );
763   TestUrl( imageView, TEST_IMAGE_FILE_NAME2 );
764
765   END_TEST;
766 }
767
768 int UtcDaliImageViewSetImageOnstageP(void)
769 {
770   ToolkitTestApplication application;
771
772   ImageView imageView = ImageView::New();
773
774   Stage::GetCurrent().Add( imageView );
775   application.SendNotification();
776   application.Render();
777
778   ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
779   imageView.SetImage( image1 );
780   TestImage( imageView, image1 );
781
782   int width = 300;
783   int height = 400;
784   BufferImage image2 = CreateBufferImage( width, height, Vector4( 1.f, 1.f, 1.f, 1.f ) );
785   imageView.SetImage( image2 );
786   TestImage( imageView, image2 );
787
788   END_TEST;
789 }
790
791 int UtcDaliImageViewSetImageOnstageN(void)
792 {
793   ToolkitTestApplication application;
794
795   ImageView imageView = ImageView::New();
796
797   Stage::GetCurrent().Add( imageView );
798   application.SendNotification();
799   application.Render();
800
801   ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
802   imageView.SetImage( image1 );
803   TestImage( imageView, image1 );
804
805   Image image2;
806   imageView.SetImage( image2 );
807
808   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
809
810   //the value should be empty
811   std::string url;
812   DALI_TEST_CHECK( !value.Get( url ) );
813
814   Property::Map map;
815   DALI_TEST_CHECK( !value.Get( map ) );
816
817   END_TEST;
818 }
819
820 int UtcDaliImageViewSetImageOffstageP(void)
821 {
822   ToolkitTestApplication application;
823
824   ImageView imageView = ImageView::New();
825
826   Stage::GetCurrent().Add( imageView );
827   application.SendNotification();
828   application.Render();
829   Stage::GetCurrent().Remove( imageView );
830
831   ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
832   imageView.SetImage( image1 );
833   TestImage( imageView, image1 );
834
835   int width = 300;
836   int height = 400;
837   BufferImage image2 = CreateBufferImage( width, height, Vector4( 1.f, 1.f, 1.f, 1.f ) );
838   imageView.SetImage( image2 );
839   TestImage( imageView, image2 );
840
841   END_TEST;
842 }
843
844 bool gResourceReadySignalFired = false;
845
846 void ResourceReadySignal( Control control )
847 {
848   gResourceReadySignalFired = true;
849 }
850
851 int UtcDaliImageViewCheckResourceReady(void)
852 {
853   ToolkitTestApplication application;
854
855   gResourceReadySignalFired = false;
856
857
858   int width = 100;
859   int height = 200;
860   Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
861
862   // Check ImageView with background and main image, to ensure both visuals are marked as loaded
863   ImageView imageView = ImageView::New( TEST_GIF_FILE_NAME );
864
865   imageView.SetBackgroundImage( image );
866
867   DALI_TEST_EQUALS( Toolkit::DevelControl::IsResourceReady( imageView ), false, TEST_LOCATION );
868
869   Toolkit::DevelControl::ResourceReadySignal( imageView ).Connect( &ResourceReadySignal);
870
871   Stage::GetCurrent().Add( imageView );
872
873   application.SendNotification();
874   application.Render(16);
875
876
877   DALI_TEST_EQUALS( Toolkit::DevelControl::IsResourceReady( imageView ), true, TEST_LOCATION );
878
879   DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
880
881   END_TEST;
882 }
883
884 int UtcDaliImageViewSetImageOffstageN(void)
885 {
886   ToolkitTestApplication application;
887
888   ImageView imageView = ImageView::New();
889
890   Stage::GetCurrent().Add( imageView );
891   application.SendNotification();
892   application.Render();
893   Stage::GetCurrent().Remove( imageView );
894
895   ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
896   imageView.SetImage( image1 );
897   TestImage( imageView, image1 );
898
899   Image image2;
900   imageView.SetImage( image2 );
901
902   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
903
904   //the value should be empty
905   std::string url;
906   DALI_TEST_CHECK( !value.Get( url ) );
907
908   Property::Map map;
909   DALI_TEST_CHECK( !value.Get( map ) );
910
911   END_TEST;
912 }
913
914 int UtcDaliImageViewSetImageN(void)
915 {
916   ToolkitTestApplication application;
917
918   Image image1;
919   ImageView imageView = ImageView::New();
920   imageView.SetImage( image1 );
921
922   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
923
924   //the value should be empty
925   std::string url;
926   DALI_TEST_CHECK( !value.Get( url ) );
927
928   Property::Map map;
929   DALI_TEST_CHECK( !value.Get( map ) );
930
931   std::string resource_url;
932   Property::Value val = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
933   DALI_TEST_CHECK( !val.Get( resource_url ) );
934
935   END_TEST;
936 }
937
938 int UtcDaliImageViewSetImageTypeChangesP(void)
939 {
940   ToolkitTestApplication application;
941
942   ImageView imageView = ImageView::New();
943
944
945   std::string url;
946   Property::Map map;
947
948   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
949   DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
950   DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
951
952   // Set a URL
953   imageView.SetImage( "TEST_URL" );
954   value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
955
956   DALI_TEST_CHECK( value.Get( url ) );   // Value should NOT be empty
957   DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
958
959   // Set an empty Image
960   imageView.SetImage( Image() );
961   value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
962
963   DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
964   DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
965
966   // Set an Image
967   ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
968   imageView.SetImage( image1 );
969   value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
970
971   DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
972   DALI_TEST_CHECK( value.Get( map ) );   // Value should NOT be empty
973
974   // Set an empty URL
975   imageView.SetImage( "" );
976   value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
977
978   DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
979   DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
980
981   END_TEST;
982 }
983
984 int UtcDaliImageViewResourceUrlP(void)
985 {
986   ToolkitTestApplication application;
987
988   ImageView imageView = ImageView::New();
989   DALI_TEST_CHECK( imageView.GetProperty( ImageView::Property::RESOURCE_URL ).Get< std::string >().empty() );
990
991   imageView.SetProperty( ImageView::Property::RESOURCE_URL, "TestString" );
992   DALI_TEST_EQUALS( imageView.GetProperty( ImageView::Property::RESOURCE_URL ).Get< std::string >(), "TestString", TEST_LOCATION );
993
994   END_TEST;
995 }
996
997 // Scenarios 1: ImageView from regular image
998 int UtcDaliImageViewSetImageBufferImage(void)
999 {
1000   ToolkitTestApplication application;
1001
1002   ImageView imageView = ImageView::New();
1003   Stage::GetCurrent().Add( imageView );
1004
1005   TestGlAbstraction& gl = application.GetGlAbstraction();
1006   gl.EnableTextureCallTrace( true );
1007
1008   std::vector< GLuint > ids;
1009   ids.push_back( 23 );
1010   application.GetGlAbstraction().SetNextTextureIds( ids );
1011
1012   int width = 300;
1013   int height = 400;
1014   BufferImage image = CreateBufferImage( width, height, Color::WHITE );
1015
1016   imageView.SetImage( image );
1017
1018   application.SendNotification();
1019   application.Render();
1020
1021   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1022
1023   std::stringstream params;
1024   params << GL_TEXTURE_2D << ", " << 23;
1025   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
1026
1027   END_TEST;
1028 }
1029
1030 // Scenarios 2: ImageView from Native image
1031 int UtcDaliImageViewSetImageNativeImage(void)
1032 {
1033   ToolkitTestApplication application;
1034
1035   ImageView imageView = ImageView::New();
1036   Stage::GetCurrent().Add( imageView );
1037
1038   TestGlAbstraction& gl = application.GetGlAbstraction();
1039   gl.EnableTextureCallTrace( true );
1040
1041   std::vector< GLuint > ids;
1042   ids.push_back( 23 );
1043   application.GetGlAbstraction().SetNextTextureIds( ids );
1044
1045   int width = 200;
1046   int height = 500;
1047   TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
1048   NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
1049
1050   imageView.SetImage( nativeImage );
1051   application.SendNotification();
1052   application.Render();
1053
1054   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1055
1056   std::stringstream params;
1057   params << GL_TEXTURE_EXTERNAL_OES << ", " << 23;
1058   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
1059
1060   END_TEST;
1061 }
1062
1063 // Scenarios 3: ImageView initially from regular image but then SetImage called with Native image
1064 int UtcDaliImageViewSetImageBufferImageToNativeImage(void)
1065 {
1066   ToolkitTestApplication application;
1067
1068   int width = 300;
1069   int height = 400;
1070   BufferImage image = CreateBufferImage( width, height, Color::WHITE );
1071
1072   ImageView imageView = ImageView::New( image );
1073   Stage::GetCurrent().Add( imageView );
1074
1075   TestGlAbstraction& gl = application.GetGlAbstraction();
1076   gl.EnableTextureCallTrace( true );
1077
1078   std::vector< GLuint > ids;
1079   ids.push_back( 23 );
1080   application.GetGlAbstraction().SetNextTextureIds( ids );
1081
1082   application.SendNotification();
1083   application.Render();
1084
1085   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1086
1087   std::stringstream params;
1088   params << GL_TEXTURE_2D << ", " << 23;
1089   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
1090
1091   width = 200;
1092   height = 500;
1093   TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
1094   NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
1095   imageView.SetImage( nativeImage );
1096
1097   ids.clear();
1098   ids.push_back( 24 );
1099   application.GetGlAbstraction().SetNextTextureIds( ids );
1100
1101   application.SendNotification();
1102   application.Render();
1103
1104   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1105
1106   std::stringstream nextTextureParams;
1107   nextTextureParams << GL_TEXTURE_EXTERNAL_OES << ", " << 24;
1108   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", nextTextureParams.str()) );
1109
1110   END_TEST;
1111 }
1112
1113 // Scenarios 4: ImageView initially from Native image but then SetImage called with regular image
1114 int UtcDaliImageViewSetImageNativeImageToBufferImage(void)
1115 {
1116   ToolkitTestApplication application;
1117
1118   int width = 300;
1119   int height = 400;
1120   TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
1121   NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
1122
1123   ImageView imageView = ImageView::New( nativeImage );
1124   Stage::GetCurrent().Add( imageView );
1125
1126   TestGlAbstraction& gl = application.GetGlAbstraction();
1127   gl.EnableTextureCallTrace( true );
1128
1129   std::vector< GLuint > ids;
1130   ids.push_back( 23 );
1131   application.GetGlAbstraction().SetNextTextureIds( ids );
1132
1133   application.SendNotification();
1134   application.Render();
1135
1136   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1137
1138   std::stringstream params;
1139   params << GL_TEXTURE_EXTERNAL_OES << ", " << 23;
1140   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
1141
1142   width = 200;
1143   height = 500;
1144   BufferImage image = CreateBufferImage( width, height, Color::WHITE );
1145   imageView.SetImage( image );
1146
1147   ids.clear();
1148   ids.push_back( 24 );
1149   application.GetGlAbstraction().SetNextTextureIds( ids );
1150
1151   application.SendNotification();
1152   application.Render();
1153
1154   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1155
1156   std::stringstream nextTextureParams;
1157   nextTextureParams << GL_TEXTURE_2D << ", " << 24;
1158   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", nextTextureParams.str()) );
1159
1160   END_TEST;
1161 }
1162
1163 // Scenarios 5: ImageView from Native image with custom shader
1164 int UtcDaliImageViewSetImageNativeImageWithCustomShader(void)
1165 {
1166   ToolkitTestApplication application;
1167
1168   int width = 300;
1169   int height = 400;
1170
1171   Property::Map customShader;
1172   customShader.Insert( "vertexShader", VERTEX_SHADER );
1173   customShader.Insert( "fragmentShader", FRAGMENT_SHADER );
1174
1175   Property::Array shaderHints;
1176   shaderHints.PushBack( "requiresSelfDepthTest" );
1177   shaderHints.PushBack( "outputIsTransparent" );
1178   shaderHints.PushBack( "outputIsOpaque" );
1179   shaderHints.PushBack( "modifiesGeometry" );
1180
1181   customShader.Insert( "hints", shaderHints );
1182
1183   Property::Map map;
1184   map.Insert( "shader", customShader );
1185
1186   TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
1187   NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
1188
1189   ImageView imageView = ImageView::New( nativeImage );
1190   imageView.SetProperty( ImageView::Property::IMAGE, map );
1191   Stage::GetCurrent().Add( imageView );
1192
1193   TestGlAbstraction& gl = application.GetGlAbstraction();
1194   gl.EnableTextureCallTrace( true );
1195
1196   std::vector< GLuint > ids;
1197   ids.push_back( 23 );
1198   application.GetGlAbstraction().SetNextTextureIds( ids );
1199
1200   application.SendNotification();
1201   application.Render();
1202
1203   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1204
1205   std::stringstream params;
1206   params << GL_TEXTURE_EXTERNAL_OES << ", " << 23;
1207   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
1208
1209   END_TEST;
1210 }
1211
1212 // Scenarios 6: ImageView initially from regular image with custom shader but then SetImage called with Native
1213 int UtcDaliImageViewSetImageBufferImageWithCustomShaderToNativeImage(void)
1214 {
1215   ToolkitTestApplication application;
1216
1217   int width = 300;
1218   int height = 400;
1219
1220   Property::Map customShader;
1221   customShader.Insert( "vertexShader", VERTEX_SHADER );
1222   customShader.Insert( "fragmentShader", FRAGMENT_SHADER );
1223
1224   Property::Array shaderHints;
1225   shaderHints.PushBack( "requiresSelfDepthTest" );
1226   shaderHints.PushBack( "outputIsTransparent" );
1227   shaderHints.PushBack( "outputIsOpaque" );
1228   shaderHints.PushBack( "modifiesGeometry" );
1229
1230   customShader.Insert( "hints", shaderHints );
1231
1232   Property::Map map;
1233   map.Insert( "shader", customShader );
1234
1235   BufferImage image = CreateBufferImage( width, height, Color::WHITE );
1236
1237   ImageView imageView = ImageView::New( image );
1238   imageView.SetProperty( ImageView::Property::IMAGE, map );
1239   Stage::GetCurrent().Add( imageView );
1240
1241   TestGlAbstraction& gl = application.GetGlAbstraction();
1242   gl.EnableTextureCallTrace( true );
1243
1244   std::vector< GLuint > ids;
1245   ids.push_back( 23 );
1246   application.GetGlAbstraction().SetNextTextureIds( ids );
1247
1248   application.SendNotification();
1249   application.Render();
1250
1251   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1252
1253   std::stringstream params;
1254   params << GL_TEXTURE_2D << ", " << 23;
1255   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
1256
1257   TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
1258   NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
1259   imageView.SetImage( nativeImage );
1260
1261   ids.clear();
1262   ids.push_back( 24 );
1263   application.GetGlAbstraction().SetNextTextureIds( ids );
1264
1265   application.SendNotification();
1266   application.Render();
1267
1268   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1269
1270   std::stringstream nativeImageParams;
1271   nativeImageParams << GL_TEXTURE_EXTERNAL_OES << ", " << 24;
1272   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", nativeImageParams.str()) );
1273
1274
1275   END_TEST;
1276 }
1277
1278 int UtcDaliImageViewGetImageP1(void)
1279 {
1280   ToolkitTestApplication application;
1281
1282   ImageView imageView = ImageView::New();
1283   DALI_TEST_CHECK( ! imageView.GetImage() );
1284
1285   Image image = CreateBufferImage();
1286   imageView.SetImage( image );
1287   DALI_TEST_CHECK( imageView.GetImage() == image );
1288
1289   END_TEST;
1290 }
1291
1292 int UtcDaliImageViewGetImageP2(void)
1293 {
1294   ToolkitTestApplication application;
1295
1296   BufferImage image = CreateBufferImage();
1297   ImageView imageView = ImageView::New( image );
1298   DALI_TEST_CHECK( imageView.GetImage() == image );
1299
1300   END_TEST;
1301 }
1302
1303 int UtcDaliImageViewGetImageN(void)
1304 {
1305   ToolkitTestApplication application;
1306
1307   ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
1308   DALI_TEST_CHECK( ! imageView.GetImage() );
1309
1310   Image image = CreateBufferImage();
1311   imageView.SetImage( image );
1312   DALI_TEST_CHECK( imageView.GetImage() == image );
1313
1314   imageView.SetImage( TEST_IMAGE_FILE_NAME );
1315   DALI_TEST_CHECK( ! imageView.GetImage() );
1316
1317   END_TEST;
1318 }