Changed image loaders to use new PixelBuffer class.
[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-event-thread-callback.h>
22
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali/devel-api/scripting/scripting.h>
25 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
26 #include <dali-toolkit/devel-api/controls/control-devel.h>
27 #include <dali/public-api/rendering/renderer.h>
28
29 #include <test-native-image.h>
30 #include <sstream>
31 #include <unistd.h>
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   TestGlAbstraction& gl = application.GetGlAbstraction();
431   const std::vector<GLuint>& textures = gl.GetBoundTextures();
432   size_t numTextures = textures.size();
433
434   // Async loading, no atlasing for big size image
435   ImageView imageView = ImageView::New( gImage_600_RGB );
436
437   // By default, Aysnc loading is used
438   Stage::GetCurrent().Add( imageView );
439   imageView.SetSize(100, 100);
440   imageView.SetParentOrigin( ParentOrigin::CENTER );
441
442   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
443
444   application.SendNotification();
445   application.Render(16);
446   application.SendNotification();
447
448   const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
449   DALI_TEST_GREATER( textures2.size(), numTextures, TEST_LOCATION );
450
451
452
453   END_TEST;
454 }
455
456 int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
457 {
458   ToolkitTestApplication application;
459
460   //Async loading, automatic atlasing for small size image
461   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
462   callStack.Reset();
463   callStack.Enable(true);
464
465   Property::Map imageMap;
466
467   imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
468   imageMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
469   imageMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
470   imageMap[ DevelImageVisual::Property::ATLASING] = true;
471
472   ImageView imageView = ImageView::New();
473   imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
474
475   // By default, Aysnc loading is used
476   // loading is not started if the actor is offStage
477
478   Stage::GetCurrent().Add( imageView );
479   application.SendNotification();
480   application.Render(16);
481   application.Render(16);
482   application.SendNotification();
483
484   // loading started, this waits for the loader thread for max 30 seconds
485   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
486
487   application.SendNotification();
488   application.Render(16);
489
490   callStack.Enable(false);
491
492   TraceCallStack::NamedParams params;
493   params["width"] = ToString(34);
494   params["height"] = ToString(34);
495   DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
496
497   END_TEST;
498 }
499
500 int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
501 {
502   ToolkitTestApplication application;
503
504   //Async loading, automatic atlasing for small size image
505   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
506   callStack.Reset();
507   callStack.Enable(true);
508
509   Property::Map asyncLoadingMap;
510   asyncLoadingMap[ "url" ] = gImage_34_RGBA;
511   asyncLoadingMap[ "desiredHeight" ] = 34;
512   asyncLoadingMap[ "desiredWidth" ] = 34;
513   asyncLoadingMap[ "synchronousLoading" ] = false;
514   asyncLoadingMap[ "atlasing" ] = true;
515
516   ImageView imageView = ImageView::New();
517   imageView.SetProperty( ImageView::Property::IMAGE, asyncLoadingMap );
518
519   Stage::GetCurrent().Add( imageView );
520   application.SendNotification();
521   application.Render(16);
522   application.Render(16);
523   application.SendNotification();
524
525   // loading started, this waits for the loader thread for max 30 seconds
526   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
527
528   application.SendNotification();
529   application.Render(16);
530
531   callStack.Enable(false);
532
533   TraceCallStack::NamedParams params;
534   params["width"] = ToString(34);
535   params["height"] = ToString(34);
536   DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ), true, TEST_LOCATION );
537
538   END_TEST;
539 }
540
541 int UtcDaliImageViewSyncLoading(void)
542 {
543   ToolkitTestApplication application;
544
545   tet_infoline("ImageView Testing sync loading and size using index key property map");
546
547   Property::Map syncLoadingMap;
548   syncLoadingMap[ ImageVisual::Property::SYNCHRONOUS_LOADING ] = true;
549   syncLoadingMap[ DevelImageVisual::Property::ATLASING ] = true;
550
551   // Sync loading, no atlasing for big size image
552   {
553     ImageView imageView = ImageView::New();
554
555     // Sync loading is used
556     syncLoadingMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
557     imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
558   }
559
560   // Sync loading, automatic atlasing for small size image
561   {
562     TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
563     callStack.Reset();
564     callStack.Enable(true);
565
566     ImageView imageView = ImageView::New( );
567
568     // Sync loading is used
569     syncLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
570     syncLoadingMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
571     syncLoadingMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
572     imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
573
574     Stage::GetCurrent().Add( imageView );
575     application.SendNotification();
576     application.Render(16);
577
578     TraceCallStack::NamedParams params;
579     params["width"] = ToString(34);
580     params["height"] = ToString(34);
581     DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
582                       true, TEST_LOCATION );
583   }
584   END_TEST;
585 }
586
587
588 int UtcDaliImageViewSyncLoading02(void)
589 {
590   ToolkitTestApplication application;
591
592   tet_infoline("ImageView Testing sync loading and size using string key property map");
593
594   // Sync loading, automatic atlasing for small size image
595   {
596     TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
597     callStack.Reset();
598     callStack.Enable(true);
599
600     ImageView imageView = ImageView::New( );
601
602     // Sync loading is used
603     Property::Map syncLoadingMap;
604     syncLoadingMap[ "url" ] = gImage_34_RGBA;
605     syncLoadingMap[ "desiredHeight" ] = 34;
606     syncLoadingMap[ "desiredWidth" ] = 34;
607     syncLoadingMap[ "synchronousLoading" ] = true;
608     syncLoadingMap[ "atlasing" ] = true;
609     imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
610
611     Stage::GetCurrent().Add( imageView );
612     application.SendNotification();
613     application.Render(16);
614
615     TraceCallStack::NamedParams params;
616     params["width"] = ToString(34);
617     params["height"] = ToString(34);
618     DALI_TEST_EQUALS( callStack.FindMethodAndParams( "TexSubImage2D", params ),
619                       true, TEST_LOCATION );
620   }
621   END_TEST;
622 }
623
624 int UtcDaliImageViewSizeWithBackground(void)
625 {
626   ToolkitTestApplication application;
627
628   int width = 100;
629   int height = 200;
630   Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
631   ImageView imageView = ImageView::New();
632   imageView.SetBackgroundImage( image );
633
634   Stage::GetCurrent().Add( imageView );
635   application.SendNotification();
636   application.Render();
637
638   DALI_TEST_EQUALS( imageView.GetCurrentSize().width, (float)width, TEST_LOCATION );
639   DALI_TEST_EQUALS( imageView.GetCurrentSize().height, (float)height, TEST_LOCATION );
640
641   END_TEST;
642 }
643
644 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
645 {
646   ToolkitTestApplication application;
647
648   int widthBackground = 100;
649   int heightBackground = 200;
650   int width = 300;
651   int height = 400;
652   Image imageBackground = CreateBufferImage( widthBackground, heightBackground, Vector4(1.f, 1.f, 1.f, 1.f) );
653   Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
654
655   ImageView imageView = ImageView::New();
656   imageView.SetBackgroundImage( imageBackground );
657   imageView.SetImage( image );
658
659   Stage::GetCurrent().Add( imageView );
660   application.SendNotification();
661   application.Render();
662
663   DALI_TEST_EQUALS( imageView.GetCurrentSize().width, (float)width, TEST_LOCATION );
664   DALI_TEST_EQUALS( imageView.GetCurrentSize().height, (float)height, TEST_LOCATION );
665
666   END_TEST;
667 }
668
669 int UtcDaliImageViewHeightForWidthBackground(void)
670 {
671   ToolkitTestApplication application;
672
673   int widthBackground = 100;
674   int heightBackground = 200;
675   Image imageBackground = CreateBufferImage( widthBackground, heightBackground, Vector4(1.f, 1.f, 1.f, 1.f) );
676
677   ImageView imageView = ImageView::New();
678   imageView.SetBackgroundImage( imageBackground );
679
680   Stage::GetCurrent().Add( imageView );
681   application.SendNotification();
682   application.Render();
683
684   Control control = Control::DownCast( imageView );
685   DALI_TEST_CHECK( control );
686   DALI_TEST_EQUALS( imageView.GetHeightForWidth( 123.f ), control.GetHeightForWidth( 123.f ), TEST_LOCATION );
687   DALI_TEST_EQUALS( imageView.GetWidthForHeight( 321.f ), control.GetWidthForHeight( 321.f ), TEST_LOCATION );
688
689   END_TEST;
690 }
691
692 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
693 {
694   ToolkitTestApplication application;
695
696   int widthBackground = 100;
697   int heightBackground = 200;
698   int width = 300;
699   int height = 400;
700   Image imageBackground = CreateBufferImage( widthBackground, heightBackground, Vector4(1.f, 1.f, 1.f, 1.f) );
701   Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
702
703   ImageView imageView = ImageView::New();
704   imageView.SetBackgroundImage( imageBackground );
705   imageView.SetImage( image );
706
707   Stage::GetCurrent().Add( imageView );
708   application.SendNotification();
709   application.Render();
710
711   DALI_TEST_EQUALS( imageView.GetHeightForWidth( width ), (float)height, TEST_LOCATION );
712   DALI_TEST_EQUALS( imageView.GetWidthForHeight( height ), (float)width, TEST_LOCATION );
713
714   END_TEST;
715 }
716
717 int UtcDaliImageViewSetBufferImage(void)
718 {
719   ToolkitTestApplication application;
720
721   int width1 = 300;
722   int height1 = 400;
723   BufferImage image1 = CreateBufferImage( width1, height1, Vector4( 1.f, 1.f, 1.f, 1.f ) );
724   ImageView imageView = ImageView::New();
725   imageView.SetImage( image1 );
726
727   TestImage( imageView, image1 );
728
729   int width2 = 600;
730   int height2 = 500;
731   BufferImage image2 = CreateBufferImage( width2, height2, Vector4( 1.f, 1.f, 1.f, 1.f ) );
732   imageView.SetImage( image2 );
733
734   TestImage( imageView, image2 );
735
736   END_TEST;
737 }
738
739 int UtcDaliImageViewSetImageUrl(void)
740 {
741   ToolkitTestApplication application;
742
743   ImageView imageView = ImageView::New();
744   imageView.SetImage( TEST_IMAGE_FILE_NAME );
745   TestUrl( imageView, TEST_IMAGE_FILE_NAME );
746
747
748   imageView.SetImage( TEST_IMAGE_FILE_NAME2 );
749   TestUrl( imageView, TEST_IMAGE_FILE_NAME2 );
750
751   END_TEST;
752 }
753
754 int UtcDaliImageViewSetImageOnstageP(void)
755 {
756   ToolkitTestApplication application;
757
758   ImageView imageView = ImageView::New();
759
760   Stage::GetCurrent().Add( imageView );
761   application.SendNotification();
762   application.Render();
763
764   ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
765   imageView.SetImage( image1 );
766   TestImage( imageView, image1 );
767
768   int width = 300;
769   int height = 400;
770   BufferImage image2 = CreateBufferImage( width, height, Vector4( 1.f, 1.f, 1.f, 1.f ) );
771   imageView.SetImage( image2 );
772   TestImage( imageView, image2 );
773
774   END_TEST;
775 }
776
777 int UtcDaliImageViewSetImageOnstageN(void)
778 {
779   ToolkitTestApplication application;
780
781   ImageView imageView = ImageView::New();
782
783   Stage::GetCurrent().Add( imageView );
784   application.SendNotification();
785   application.Render();
786
787   ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
788   imageView.SetImage( image1 );
789   TestImage( imageView, image1 );
790
791   Image image2;
792   imageView.SetImage( image2 );
793
794   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
795
796   //the value should be empty
797   std::string url;
798   DALI_TEST_CHECK( !value.Get( url ) );
799
800   Property::Map map;
801   DALI_TEST_CHECK( !value.Get( map ) );
802
803   END_TEST;
804 }
805
806 int UtcDaliImageViewSetImageOffstageP(void)
807 {
808   ToolkitTestApplication application;
809
810   ImageView imageView = ImageView::New();
811
812   Stage::GetCurrent().Add( imageView );
813   application.SendNotification();
814   application.Render();
815   Stage::GetCurrent().Remove( imageView );
816
817   ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
818   imageView.SetImage( image1 );
819   TestImage( imageView, image1 );
820
821   int width = 300;
822   int height = 400;
823   BufferImage image2 = CreateBufferImage( width, height, Vector4( 1.f, 1.f, 1.f, 1.f ) );
824   imageView.SetImage( image2 );
825   TestImage( imageView, image2 );
826
827   END_TEST;
828 }
829
830 bool gResourceReadySignalFired = false;
831
832 void ResourceReadySignal( Control control )
833 {
834   gResourceReadySignalFired = true;
835 }
836
837 int UtcDaliImageViewCheckResourceReady(void)
838 {
839   ToolkitTestApplication application;
840
841   gResourceReadySignalFired = false;
842
843
844   int width = 100;
845   int height = 200;
846   Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
847
848   // Check ImageView with background and main image, to ensure both visuals are marked as loaded
849   ImageView imageView = ImageView::New( TEST_GIF_FILE_NAME );
850
851   imageView.SetBackgroundImage( image );
852
853   DALI_TEST_EQUALS( Toolkit::DevelControl::IsResourceReady( imageView ), false, TEST_LOCATION );
854
855   Toolkit::DevelControl::ResourceReadySignal( imageView ).Connect( &ResourceReadySignal);
856
857   Stage::GetCurrent().Add( imageView );
858
859   application.SendNotification();
860   application.Render(16);
861
862
863   DALI_TEST_EQUALS( Toolkit::DevelControl::IsResourceReady( imageView ), true, TEST_LOCATION );
864
865   DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
866
867   END_TEST;
868 }
869
870 int UtcDaliImageViewSetImageOffstageN(void)
871 {
872   ToolkitTestApplication application;
873
874   ImageView imageView = ImageView::New();
875
876   Stage::GetCurrent().Add( imageView );
877   application.SendNotification();
878   application.Render();
879   Stage::GetCurrent().Remove( imageView );
880
881   ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
882   imageView.SetImage( image1 );
883   TestImage( imageView, image1 );
884
885   Image image2;
886   imageView.SetImage( image2 );
887
888   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
889
890   //the value should be empty
891   std::string url;
892   DALI_TEST_CHECK( !value.Get( url ) );
893
894   Property::Map map;
895   DALI_TEST_CHECK( !value.Get( map ) );
896
897   END_TEST;
898 }
899
900 int UtcDaliImageViewSetImageN(void)
901 {
902   ToolkitTestApplication application;
903
904   Image image1;
905   ImageView imageView = ImageView::New();
906   imageView.SetImage( image1 );
907
908   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
909
910   //the value should be empty
911   std::string url;
912   DALI_TEST_CHECK( !value.Get( url ) );
913
914   Property::Map map;
915   DALI_TEST_CHECK( !value.Get( map ) );
916
917   std::string resource_url;
918   Property::Value val = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
919   DALI_TEST_CHECK( !val.Get( resource_url ) );
920
921   END_TEST;
922 }
923
924 int UtcDaliImageViewSetImageTypeChangesP(void)
925 {
926   ToolkitTestApplication application;
927
928   ImageView imageView = ImageView::New();
929
930
931   std::string url;
932   Property::Map map;
933
934   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
935   DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
936   DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
937
938   // Set a URL
939   imageView.SetImage( "TEST_URL" );
940   value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
941
942   DALI_TEST_CHECK( value.Get( url ) );   // Value should NOT be empty
943   DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
944
945   // Set an empty Image
946   imageView.SetImage( Image() );
947   value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
948
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 an Image
953   ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
954   imageView.SetImage( image1 );
955   value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
956
957   DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
958   DALI_TEST_CHECK( value.Get( map ) );   // Value should NOT be empty
959
960   // Set an empty URL
961   imageView.SetImage( "" );
962   value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
963
964   DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
965   DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
966
967   END_TEST;
968 }
969
970 int UtcDaliImageViewResourceUrlP(void)
971 {
972   ToolkitTestApplication application;
973
974   ImageView imageView = ImageView::New();
975   DALI_TEST_CHECK( imageView.GetProperty( ImageView::Property::RESOURCE_URL ).Get< std::string >().empty() );
976
977   imageView.SetProperty( ImageView::Property::RESOURCE_URL, "TestString" );
978   DALI_TEST_EQUALS( imageView.GetProperty( ImageView::Property::RESOURCE_URL ).Get< std::string >(), "TestString", TEST_LOCATION );
979
980   END_TEST;
981 }
982
983 // Scenarios 1: ImageView from regular image
984 int UtcDaliImageViewSetImageBufferImage(void)
985 {
986   ToolkitTestApplication application;
987
988   ImageView imageView = ImageView::New();
989   Stage::GetCurrent().Add( imageView );
990
991   TestGlAbstraction& gl = application.GetGlAbstraction();
992   gl.EnableTextureCallTrace( true );
993
994   std::vector< GLuint > ids;
995   ids.push_back( 23 );
996   application.GetGlAbstraction().SetNextTextureIds( ids );
997
998   int width = 300;
999   int height = 400;
1000   BufferImage image = CreateBufferImage( width, height, Color::WHITE );
1001
1002   imageView.SetImage( image );
1003
1004   application.SendNotification();
1005   application.Render();
1006
1007   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1008
1009   std::stringstream params;
1010   params << GL_TEXTURE_2D << ", " << 23;
1011   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
1012
1013   END_TEST;
1014 }
1015
1016 // Scenarios 2: ImageView from Native image
1017 int UtcDaliImageViewSetImageNativeImage(void)
1018 {
1019   ToolkitTestApplication application;
1020
1021   ImageView imageView = ImageView::New();
1022   Stage::GetCurrent().Add( imageView );
1023
1024   TestGlAbstraction& gl = application.GetGlAbstraction();
1025   gl.EnableTextureCallTrace( true );
1026
1027   std::vector< GLuint > ids;
1028   ids.push_back( 23 );
1029   application.GetGlAbstraction().SetNextTextureIds( ids );
1030
1031   int width = 200;
1032   int height = 500;
1033   TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
1034   NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
1035
1036   imageView.SetImage( nativeImage );
1037   application.SendNotification();
1038   application.Render();
1039
1040   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1041
1042   std::stringstream params;
1043   params << GL_TEXTURE_EXTERNAL_OES << ", " << 23;
1044   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
1045
1046   END_TEST;
1047 }
1048
1049 // Scenarios 3: ImageView initially from regular image but then SetImage called with Native image
1050 int UtcDaliImageViewSetImageBufferImageToNativeImage(void)
1051 {
1052   ToolkitTestApplication application;
1053
1054   int width = 300;
1055   int height = 400;
1056   BufferImage image = CreateBufferImage( width, height, Color::WHITE );
1057
1058   ImageView imageView = ImageView::New( image );
1059   Stage::GetCurrent().Add( imageView );
1060
1061   TestGlAbstraction& gl = application.GetGlAbstraction();
1062   gl.EnableTextureCallTrace( true );
1063
1064   std::vector< GLuint > ids;
1065   ids.push_back( 23 );
1066   application.GetGlAbstraction().SetNextTextureIds( ids );
1067
1068   application.SendNotification();
1069   application.Render();
1070
1071   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1072
1073   std::stringstream params;
1074   params << GL_TEXTURE_2D << ", " << 23;
1075   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
1076
1077   width = 200;
1078   height = 500;
1079   TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
1080   NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
1081   imageView.SetImage( nativeImage );
1082
1083   ids.clear();
1084   ids.push_back( 24 );
1085   application.GetGlAbstraction().SetNextTextureIds( ids );
1086
1087   application.SendNotification();
1088   application.Render();
1089
1090   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1091
1092   std::stringstream nextTextureParams;
1093   nextTextureParams << GL_TEXTURE_EXTERNAL_OES << ", " << 24;
1094   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", nextTextureParams.str()) );
1095
1096   END_TEST;
1097 }
1098
1099 // Scenarios 4: ImageView initially from Native image but then SetImage called with regular image
1100 int UtcDaliImageViewSetImageNativeImageToBufferImage(void)
1101 {
1102   ToolkitTestApplication application;
1103
1104   int width = 300;
1105   int height = 400;
1106   TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
1107   NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
1108
1109   ImageView imageView = ImageView::New( nativeImage );
1110   Stage::GetCurrent().Add( imageView );
1111
1112   TestGlAbstraction& gl = application.GetGlAbstraction();
1113   gl.EnableTextureCallTrace( true );
1114
1115   std::vector< GLuint > ids;
1116   ids.push_back( 23 );
1117   application.GetGlAbstraction().SetNextTextureIds( ids );
1118
1119   application.SendNotification();
1120   application.Render();
1121
1122   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1123
1124   std::stringstream params;
1125   params << GL_TEXTURE_EXTERNAL_OES << ", " << 23;
1126   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
1127
1128   width = 200;
1129   height = 500;
1130   BufferImage image = CreateBufferImage( width, height, Color::WHITE );
1131   imageView.SetImage( image );
1132
1133   ids.clear();
1134   ids.push_back( 24 );
1135   application.GetGlAbstraction().SetNextTextureIds( ids );
1136
1137   application.SendNotification();
1138   application.Render();
1139
1140   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1141
1142   std::stringstream nextTextureParams;
1143   nextTextureParams << GL_TEXTURE_2D << ", " << 24;
1144   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", nextTextureParams.str()) );
1145
1146   END_TEST;
1147 }
1148
1149 // Scenarios 5: ImageView from Native image with custom shader
1150 int UtcDaliImageViewSetImageNativeImageWithCustomShader(void)
1151 {
1152   ToolkitTestApplication application;
1153
1154   int width = 300;
1155   int height = 400;
1156
1157   Property::Map customShader;
1158   customShader.Insert( "vertexShader", VERTEX_SHADER );
1159   customShader.Insert( "fragmentShader", FRAGMENT_SHADER );
1160
1161   Property::Array shaderHints;
1162   shaderHints.PushBack( "requiresSelfDepthTest" );
1163   shaderHints.PushBack( "outputIsTransparent" );
1164   shaderHints.PushBack( "outputIsOpaque" );
1165   shaderHints.PushBack( "modifiesGeometry" );
1166
1167   customShader.Insert( "hints", shaderHints );
1168
1169   Property::Map map;
1170   map.Insert( "shader", customShader );
1171
1172   TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
1173   NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
1174
1175   ImageView imageView = ImageView::New( nativeImage );
1176   imageView.SetProperty( ImageView::Property::IMAGE, map );
1177   Stage::GetCurrent().Add( imageView );
1178
1179   TestGlAbstraction& gl = application.GetGlAbstraction();
1180   gl.EnableTextureCallTrace( true );
1181
1182   std::vector< GLuint > ids;
1183   ids.push_back( 23 );
1184   application.GetGlAbstraction().SetNextTextureIds( ids );
1185
1186   application.SendNotification();
1187   application.Render();
1188
1189   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1190
1191   std::stringstream params;
1192   params << GL_TEXTURE_EXTERNAL_OES << ", " << 23;
1193   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
1194
1195   END_TEST;
1196 }
1197
1198 // Scenarios 6: ImageView initially from regular image with custom shader but then SetImage called with Native
1199 int UtcDaliImageViewSetImageBufferImageWithCustomShaderToNativeImage(void)
1200 {
1201   ToolkitTestApplication application;
1202
1203   int width = 300;
1204   int height = 400;
1205
1206   Property::Map customShader;
1207   customShader.Insert( "vertexShader", VERTEX_SHADER );
1208   customShader.Insert( "fragmentShader", FRAGMENT_SHADER );
1209
1210   Property::Array shaderHints;
1211   shaderHints.PushBack( "requiresSelfDepthTest" );
1212   shaderHints.PushBack( "outputIsTransparent" );
1213   shaderHints.PushBack( "outputIsOpaque" );
1214   shaderHints.PushBack( "modifiesGeometry" );
1215
1216   customShader.Insert( "hints", shaderHints );
1217
1218   Property::Map map;
1219   map.Insert( "shader", customShader );
1220
1221   BufferImage image = CreateBufferImage( width, height, Color::WHITE );
1222
1223   ImageView imageView = ImageView::New( image );
1224   imageView.SetProperty( ImageView::Property::IMAGE, map );
1225   Stage::GetCurrent().Add( imageView );
1226
1227   TestGlAbstraction& gl = application.GetGlAbstraction();
1228   gl.EnableTextureCallTrace( true );
1229
1230   std::vector< GLuint > ids;
1231   ids.push_back( 23 );
1232   application.GetGlAbstraction().SetNextTextureIds( ids );
1233
1234   application.SendNotification();
1235   application.Render();
1236
1237   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1238
1239   std::stringstream params;
1240   params << GL_TEXTURE_2D << ", " << 23;
1241   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
1242
1243   TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
1244   NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
1245   imageView.SetImage( nativeImage );
1246
1247   ids.clear();
1248   ids.push_back( 24 );
1249   application.GetGlAbstraction().SetNextTextureIds( ids );
1250
1251   application.SendNotification();
1252   application.Render();
1253
1254   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
1255
1256   std::stringstream nativeImageParams;
1257   nativeImageParams << GL_TEXTURE_EXTERNAL_OES << ", " << 24;
1258   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", nativeImageParams.str()) );
1259
1260
1261   END_TEST;
1262 }
1263
1264 int UtcDaliImageViewGetImageP1(void)
1265 {
1266   ToolkitTestApplication application;
1267
1268   ImageView imageView = ImageView::New();
1269   DALI_TEST_CHECK( ! imageView.GetImage() );
1270
1271   Image image = CreateBufferImage();
1272   imageView.SetImage( image );
1273   DALI_TEST_CHECK( imageView.GetImage() == image );
1274
1275   END_TEST;
1276 }
1277
1278 int UtcDaliImageViewGetImageP2(void)
1279 {
1280   ToolkitTestApplication application;
1281
1282   BufferImage image = CreateBufferImage();
1283   ImageView imageView = ImageView::New( image );
1284   DALI_TEST_CHECK( imageView.GetImage() == image );
1285
1286   END_TEST;
1287 }
1288
1289 int UtcDaliImageViewGetImageN(void)
1290 {
1291   ToolkitTestApplication application;
1292
1293   ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
1294   DALI_TEST_CHECK( ! imageView.GetImage() );
1295
1296   Image image = CreateBufferImage();
1297   imageView.SetImage( image );
1298   DALI_TEST_CHECK( imageView.GetImage() == image );
1299
1300   imageView.SetImage( TEST_IMAGE_FILE_NAME );
1301   DALI_TEST_CHECK( ! imageView.GetImage() );
1302
1303   END_TEST;
1304 }