2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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>
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali/devel-api/scripting/scripting.h>
24 #include <dali/devel-api/rendering/renderer.h>
26 #include <test-native-image.h>
30 using namespace Toolkit;
32 void utc_dali_toolkit_image_view_startup(void)
34 test_return_value = TET_UNDEF;
37 void utc_dali_toolkit_image_view_cleanup(void)
39 test_return_value = TET_PASS;
45 const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
46 attribute mediump vec2 aPosition;\n
47 varying mediump vec2 vTexCoord;\n
48 uniform mediump mat4 uMvpMatrix;\n
49 uniform mediump vec3 uSize;\n
53 mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
54 vertexPosition.xyz *= uSize;\n
55 vertexPosition = uMvpMatrix * vertexPosition;\n
57 vTexCoord = aPosition + vec2(0.5);\n
58 gl_Position = vertexPosition;\n
62 const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
63 varying mediump vec2 vTexCoord;\n
64 uniform sampler2D sTexture;\n
65 uniform lowp vec4 uColor;\n
69 gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
73 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
74 const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
76 void TestImage( ImageView imageView, BufferImage image )
78 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
81 DALI_TEST_CHECK( value.Get( map ) );
83 DALI_TEST_CHECK( map.Find( "width" ) );
84 DALI_TEST_CHECK( map.Find( "height" ) );
85 DALI_TEST_CHECK( map.Find( "type" ) );
88 DALI_TEST_CHECK( map[ "width" ].Get( width ) );
89 DALI_TEST_EQUALS( (unsigned int)width, image.GetWidth(), TEST_LOCATION );
92 DALI_TEST_CHECK( map[ "height" ].Get( height ) );
93 DALI_TEST_EQUALS( (unsigned int)height, image.GetHeight(), TEST_LOCATION );
96 DALI_TEST_CHECK( map[ "type" ].Get( type ) );
97 DALI_TEST_EQUALS( type, "BufferImage", TEST_LOCATION );
100 void TestImage( ImageView imageView, ResourceImage image )
102 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
105 DALI_TEST_CHECK( value.Get( map ) );
107 if( map.Find( "width" ) )
110 DALI_TEST_CHECK( map[ "width" ].Get( width ) );
111 DALI_TEST_EQUALS( (unsigned int)width, image.GetWidth(), TEST_LOCATION );
114 if( map.Find( "height" ) )
117 DALI_TEST_CHECK( map[ "height" ].Get( height ) );
118 DALI_TEST_EQUALS( (unsigned int)height, image.GetHeight(), TEST_LOCATION );
121 DALI_TEST_CHECK( map.Find( "type" ) );
124 DALI_TEST_CHECK( map[ "type" ].Get( type ) );
125 DALI_TEST_EQUALS( type, "ResourceImage", TEST_LOCATION );
127 std::string filename;
128 DALI_TEST_CHECK( map[ "filename" ].Get( filename ) );
129 DALI_TEST_EQUALS( filename, image.GetUrl(), TEST_LOCATION );
132 void TestUrl( ImageView imageView, const std::string url )
134 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
136 std::string urlActual;
137 DALI_TEST_CHECK( value.Get( urlActual ) );
138 DALI_TEST_EQUALS( urlActual, url, TEST_LOCATION );
143 int UtcDaliImageViewNewP(void)
145 TestApplication application;
147 ImageView imageView = ImageView::New();
149 DALI_TEST_CHECK( imageView );
154 int UtcDaliImageViewNewImageP(void)
156 TestApplication application;
158 BufferImage image = CreateBufferImage( 100, 200, Vector4( 1.f, 1.f, 1.f, 1.f ) );
159 ImageView imageView = ImageView::New( image );
161 DALI_TEST_CHECK( imageView );
162 TestImage( imageView, image );
167 int UtcDaliImageViewNewUrlP(void)
169 TestApplication application;
171 ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
172 DALI_TEST_CHECK( imageView );
174 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
179 int UtcDaliImageViewConstructorP(void)
181 TestApplication application;
185 DALI_TEST_CHECK( !imageView );
190 int UtcDaliImageViewCopyConstructorP(void)
192 TestApplication application;
194 // Initialize an object, ref count == 1
195 ImageView imageView = ImageView::New();
197 ImageView copy( imageView );
198 DALI_TEST_CHECK( copy );
203 int UtcDaliImageViewAssignmentOperatorP(void)
205 TestApplication application;
207 ImageView imageView = ImageView::New();
209 ImageView copy( imageView );
210 DALI_TEST_CHECK( copy );
211 DALI_TEST_EQUALS( imageView, copy, TEST_LOCATION );
216 int UtcDaliImageViewDownCastP(void)
218 TestApplication application;
220 ImageView imageView = ImageView::New();
222 BaseHandle object(imageView);
224 ImageView imageView2 = ImageView::DownCast( object );
225 DALI_TEST_CHECK(imageView2);
227 ImageView imageView3 = DownCast< ImageView >( object );
228 DALI_TEST_CHECK(imageView3);
233 int UtcDaliImageViewDownCastN(void)
235 TestApplication application;
237 BaseHandle unInitializedObject;
239 ImageView imageView1 = ImageView::DownCast( unInitializedObject );
240 DALI_TEST_CHECK( !imageView1 );
242 ImageView imageView2 = DownCast< ImageView >( unInitializedObject );
243 DALI_TEST_CHECK( !imageView2 );
248 int UtcDaliImageViewTypeRegistry(void)
250 ToolkitTestApplication application;
252 TypeRegistry typeRegistry = TypeRegistry::Get();
253 DALI_TEST_CHECK( typeRegistry );
255 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "ImageView" );
256 DALI_TEST_CHECK( typeInfo );
258 BaseHandle handle = typeInfo.CreateInstance();
259 DALI_TEST_CHECK( handle );
261 ImageView imageView = ImageView::DownCast( handle );
262 DALI_TEST_CHECK( imageView );
267 int UtcDaliImageViewSetGetProperty01(void)
269 ToolkitTestApplication application;
271 ImageView imageView = ImageView::New();
273 Property::Index idx = imageView.GetPropertyIndex( "image" );
274 DALI_TEST_EQUALS( idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION );
276 imageView.SetProperty( idx, TEST_IMAGE_FILE_NAME );
277 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
282 int UtcDaliImageViewSetGetProperty02(void)
284 ToolkitTestApplication application;
286 Image image = CreateBufferImage( 10, 10, Color::WHITE );
287 ImageView imageView = ImageView::New(image);
288 Vector4 fullImageRect( 0.f, 0.f, 1.f, 1.f );
290 Stage::GetCurrent().Add( imageView );
292 application.SendNotification();
293 application.Render();
294 TestGlAbstraction& gl = application.GetGlAbstraction();
296 Vector4 pixelAreaUniform;
297 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
298 DALI_TEST_EQUALS( pixelAreaUniform, fullImageRect, TEST_LOCATION );
300 Property::Value value = imageView.GetProperty( ImageView::Property::PIXEL_AREA );
301 Vector4 pixelAreaValue;
302 DALI_TEST_CHECK( value.Get(pixelAreaValue) );
303 DALI_TEST_EQUALS( pixelAreaValue, fullImageRect, TEST_LOCATION );
305 Vector4 pixelAreaSet( 0.2f, 0.2f, 0.3f, 0.3f );
306 imageView.SetProperty( ImageView::Property::PIXEL_AREA, pixelAreaSet);
308 application.SendNotification();
309 application.Render();
311 value = imageView.GetProperty( ImageView::Property::PIXEL_AREA );
312 value.Get(pixelAreaValue);
313 DALI_TEST_EQUALS( pixelAreaValue, pixelAreaSet, TEST_LOCATION );
315 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
316 DALI_TEST_EQUALS( pixelAreaUniform, pixelAreaSet, TEST_LOCATION );
321 int UtcDaliImageViewSetGetProperty03(void)
323 ToolkitTestApplication application;
325 Image image = CreateBufferImage( 10, 10, Color::WHITE );
326 ImageView imageView = ImageView::New(image);
327 Stage::GetCurrent().Add( imageView );
328 application.SendNotification();
329 application.Render();
331 // conventional alpha blending
332 Renderer renderer = imageView.GetRendererAt( 0 );
333 BlendingFactor::Type srcFactorRgb;
334 BlendingFactor::Type destFactorRgb;
335 BlendingFactor::Type srcFactorAlpha;
336 BlendingFactor::Type destFactorAlpha;
337 renderer.GetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
338 DALI_TEST_CHECK( srcFactorRgb == BlendingFactor::SRC_ALPHA );
339 DALI_TEST_CHECK( destFactorRgb == BlendingFactor::ONE_MINUS_SRC_ALPHA );
340 DALI_TEST_CHECK( srcFactorAlpha == BlendingFactor::ONE );
341 DALI_TEST_CHECK( destFactorAlpha == BlendingFactor::ONE_MINUS_SRC_ALPHA );
343 Property::Value value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
345 DALI_TEST_CHECK( value.Get( enable ) );
346 DALI_TEST_CHECK( !enable );
348 // pre-multiplied alpha blending
349 imageView.SetProperty( Toolkit::ImageView::Property::PRE_MULTIPLIED_ALPHA, true );
350 application.SendNotification();
351 application.Render();
353 renderer.GetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
354 DALI_TEST_CHECK( srcFactorRgb == BlendingFactor::ONE );
355 DALI_TEST_CHECK( destFactorRgb == BlendingFactor::ONE_MINUS_SRC_ALPHA );
356 DALI_TEST_CHECK( srcFactorAlpha == BlendingFactor::ONE );
357 DALI_TEST_CHECK( destFactorAlpha == BlendingFactor::ONE );
359 value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
360 DALI_TEST_CHECK( value.Get( enable ) );
361 DALI_TEST_CHECK( enable );
366 int UtcDaliImageViewSizeWithBackground(void)
368 ToolkitTestApplication application;
372 Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
373 ImageView imageView = ImageView::New();
374 imageView.SetBackgroundImage( image );
376 Stage::GetCurrent().Add( imageView );
377 application.SendNotification();
378 application.Render();
380 DALI_TEST_EQUALS( imageView.GetCurrentSize().width, (float)width, TEST_LOCATION );
381 DALI_TEST_EQUALS( imageView.GetCurrentSize().height, (float)height, TEST_LOCATION );
386 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
388 ToolkitTestApplication application;
390 int widthBackground = 100;
391 int heightBackground = 200;
394 Image imageBackground = CreateBufferImage( widthBackground, heightBackground, Vector4(1.f, 1.f, 1.f, 1.f) );
395 Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
397 ImageView imageView = ImageView::New();
398 imageView.SetBackgroundImage( imageBackground );
399 imageView.SetImage( image );
401 Stage::GetCurrent().Add( imageView );
402 application.SendNotification();
403 application.Render();
405 DALI_TEST_EQUALS( imageView.GetCurrentSize().width, (float)width, TEST_LOCATION );
406 DALI_TEST_EQUALS( imageView.GetCurrentSize().height, (float)height, TEST_LOCATION );
411 int UtcDaliImageViewHeightForWidthBackground(void)
413 ToolkitTestApplication application;
415 int widthBackground = 100;
416 int heightBackground = 200;
417 Image imageBackground = CreateBufferImage( widthBackground, heightBackground, Vector4(1.f, 1.f, 1.f, 1.f) );
419 ImageView imageView = ImageView::New();
420 imageView.SetBackgroundImage( imageBackground );
422 Stage::GetCurrent().Add( imageView );
423 application.SendNotification();
424 application.Render();
426 Control control = Control::DownCast( imageView );
427 DALI_TEST_CHECK( control );
428 DALI_TEST_EQUALS( imageView.GetHeightForWidth( 123.f ), control.GetHeightForWidth( 123.f ), TEST_LOCATION );
429 DALI_TEST_EQUALS( imageView.GetWidthForHeight( 321.f ), control.GetWidthForHeight( 321.f ), TEST_LOCATION );
434 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
436 ToolkitTestApplication application;
438 int widthBackground = 100;
439 int heightBackground = 200;
442 Image imageBackground = CreateBufferImage( widthBackground, heightBackground, Vector4(1.f, 1.f, 1.f, 1.f) );
443 Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
445 ImageView imageView = ImageView::New();
446 imageView.SetBackgroundImage( imageBackground );
447 imageView.SetImage( image );
449 Stage::GetCurrent().Add( imageView );
450 application.SendNotification();
451 application.Render();
453 DALI_TEST_EQUALS( imageView.GetHeightForWidth( width ), (float)height, TEST_LOCATION );
454 DALI_TEST_EQUALS( imageView.GetWidthForHeight( height ), (float)width, TEST_LOCATION );
459 int UtcDaliImageViewSetBufferImage(void)
461 ToolkitTestApplication application;
465 BufferImage image1 = CreateBufferImage( width1, height1, Vector4( 1.f, 1.f, 1.f, 1.f ) );
466 ImageView imageView = ImageView::New();
467 imageView.SetImage( image1 );
469 TestImage( imageView, image1 );
473 BufferImage image2 = CreateBufferImage( width2, height2, Vector4( 1.f, 1.f, 1.f, 1.f ) );
474 imageView.SetImage( image2 );
476 TestImage( imageView, image2 );
481 int UtcDaliImageViewSetImageUrl(void)
483 ToolkitTestApplication application;
485 ImageView imageView = ImageView::New();
486 imageView.SetImage( TEST_IMAGE_FILE_NAME );
487 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
490 imageView.SetImage( TEST_IMAGE_FILE_NAME2 );
491 TestUrl( imageView, TEST_IMAGE_FILE_NAME2 );
496 int UtcDaliImageViewSetImageOnstageP(void)
498 ToolkitTestApplication application;
500 ImageView imageView = ImageView::New();
502 Stage::GetCurrent().Add( imageView );
503 application.SendNotification();
504 application.Render();
506 ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
507 imageView.SetImage( image1 );
508 TestImage( imageView, image1 );
512 BufferImage image2 = CreateBufferImage( width, height, Vector4( 1.f, 1.f, 1.f, 1.f ) );
513 imageView.SetImage( image2 );
514 TestImage( imageView, image2 );
519 int UtcDaliImageViewSetImageOnstageN(void)
521 ToolkitTestApplication application;
523 ImageView imageView = ImageView::New();
525 Stage::GetCurrent().Add( imageView );
526 application.SendNotification();
527 application.Render();
529 ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
530 imageView.SetImage( image1 );
531 TestImage( imageView, image1 );
534 imageView.SetImage( image2 );
536 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
538 //the value should be empty
540 DALI_TEST_CHECK( !value.Get( url ) );
543 DALI_TEST_CHECK( !value.Get( map ) );
548 int UtcDaliImageViewSetImageOffstageP(void)
550 ToolkitTestApplication application;
552 ImageView imageView = ImageView::New();
554 Stage::GetCurrent().Add( imageView );
555 application.SendNotification();
556 application.Render();
557 Stage::GetCurrent().Remove( imageView );
559 ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
560 imageView.SetImage( image1 );
561 TestImage( imageView, image1 );
565 BufferImage image2 = CreateBufferImage( width, height, Vector4( 1.f, 1.f, 1.f, 1.f ) );
566 imageView.SetImage( image2 );
567 TestImage( imageView, image2 );
572 int UtcDaliImageViewSetImageOffstageN(void)
574 ToolkitTestApplication application;
576 ImageView imageView = ImageView::New();
578 Stage::GetCurrent().Add( imageView );
579 application.SendNotification();
580 application.Render();
581 Stage::GetCurrent().Remove( imageView );
583 ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
584 imageView.SetImage( image1 );
585 TestImage( imageView, image1 );
588 imageView.SetImage( image2 );
590 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
592 //the value should be empty
594 DALI_TEST_CHECK( !value.Get( url ) );
597 DALI_TEST_CHECK( !value.Get( map ) );
602 int UtcDaliImageViewSetImageN(void)
604 ToolkitTestApplication application;
607 ImageView imageView = ImageView::New();
608 imageView.SetImage( image1 );
610 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
612 //the value should be empty
614 DALI_TEST_CHECK( !value.Get( url ) );
617 DALI_TEST_CHECK( !value.Get( map ) );
619 std::string resource_url;
620 Property::Value val = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
621 DALI_TEST_CHECK( !val.Get( resource_url ) );
626 int UtcDaliImageViewSetImageTypeChangesP(void)
628 ToolkitTestApplication application;
630 ImageView imageView = ImageView::New();
636 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
637 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
638 DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
641 imageView.SetImage( "TEST_URL" );
642 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
644 DALI_TEST_CHECK( value.Get( url ) ); // Value should NOT be empty
645 DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
647 // Set an empty Image
648 imageView.SetImage( Image() );
649 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
651 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
652 DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
655 ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
656 imageView.SetImage( image1 );
657 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
659 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
660 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
663 imageView.SetImage( "" );
664 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
666 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
667 DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
672 int UtcDaliImageViewResourceUrlP(void)
674 ToolkitTestApplication application;
676 ImageView imageView = ImageView::New();
677 DALI_TEST_CHECK( imageView.GetProperty( ImageView::Property::RESOURCE_URL ).Get< std::string >().empty() );
679 imageView.SetProperty( ImageView::Property::RESOURCE_URL, "TestString" );
680 DALI_TEST_EQUALS( imageView.GetProperty( ImageView::Property::RESOURCE_URL ).Get< std::string >(), "TestString", TEST_LOCATION );
685 // Scenarios 1: ImageView from regular image
686 int UtcDaliImageViewSetImageBufferImage(void)
688 ToolkitTestApplication application;
690 ImageView imageView = ImageView::New();
691 Stage::GetCurrent().Add( imageView );
693 TestGlAbstraction& gl = application.GetGlAbstraction();
694 gl.EnableTextureCallTrace( true );
696 std::vector< GLuint > ids;
698 application.GetGlAbstraction().SetNextTextureIds( ids );
702 BufferImage image = CreateBufferImage( width, height, Color::WHITE );
704 imageView.SetImage( image );
706 application.SendNotification();
707 application.Render();
709 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
711 std::stringstream params;
712 params << GL_TEXTURE_2D << ", " << 23;
713 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
718 // Scenarios 2: ImageView from Native image
719 int UtcDaliImageViewSetImageNativeImage(void)
721 ToolkitTestApplication application;
723 ImageView imageView = ImageView::New();
724 Stage::GetCurrent().Add( imageView );
726 TestGlAbstraction& gl = application.GetGlAbstraction();
727 gl.EnableTextureCallTrace( true );
729 std::vector< GLuint > ids;
731 application.GetGlAbstraction().SetNextTextureIds( ids );
735 TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
736 NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
738 imageView.SetImage( nativeImage );
739 application.SendNotification();
740 application.Render();
742 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
744 std::stringstream params;
745 params << GL_TEXTURE_2D << ", " << 23;
746 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
751 // Scenarios 3: ImageView initially from regular image but then SetImage called with Native image
752 int UtcDaliImageViewSetImageBufferImageToNativeImage(void)
754 ToolkitTestApplication application;
758 BufferImage image = CreateBufferImage( width, height, Color::WHITE );
760 ImageView imageView = ImageView::New( image );
761 Stage::GetCurrent().Add( imageView );
763 TestGlAbstraction& gl = application.GetGlAbstraction();
764 gl.EnableTextureCallTrace( true );
766 std::vector< GLuint > ids;
768 application.GetGlAbstraction().SetNextTextureIds( ids );
770 application.SendNotification();
771 application.Render();
773 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
775 std::stringstream params;
776 params << GL_TEXTURE_2D << ", " << 23;
777 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
781 TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
782 NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
783 imageView.SetImage( nativeImage );
787 application.GetGlAbstraction().SetNextTextureIds( ids );
789 application.SendNotification();
790 application.Render();
792 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
794 std::stringstream nextTextureParams;
795 nextTextureParams << GL_TEXTURE_2D << ", " << 24;
796 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", nextTextureParams.str()) );
801 // Scenarios 4: ImageView initially from Native image but then SetImage called with regular image
802 int UtcDaliImageViewSetImageNativeImageToBufferImage(void)
804 ToolkitTestApplication application;
808 TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
809 NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
811 ImageView imageView = ImageView::New( nativeImage );
812 Stage::GetCurrent().Add( imageView );
814 TestGlAbstraction& gl = application.GetGlAbstraction();
815 gl.EnableTextureCallTrace( true );
817 std::vector< GLuint > ids;
819 application.GetGlAbstraction().SetNextTextureIds( ids );
821 application.SendNotification();
822 application.Render();
824 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
826 std::stringstream params;
827 params << GL_TEXTURE_2D << ", " << 23;
828 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
832 BufferImage image = CreateBufferImage( width, height, Color::WHITE );
833 imageView.SetImage( image );
837 application.GetGlAbstraction().SetNextTextureIds( ids );
839 application.SendNotification();
840 application.Render();
842 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
844 std::stringstream nextTextureParams;
845 nextTextureParams << GL_TEXTURE_2D << ", " << 24;
846 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", nextTextureParams.str()) );
851 // Scenarios 5: ImageView from Native image with custom shader
852 int UtcDaliImageViewSetImageNativeImageWithCustomShader(void)
854 ToolkitTestApplication application;
859 Property::Map customShader;
860 customShader.Insert( "vertexShader", VERTEX_SHADER );
861 customShader.Insert( "fragmentShader", FRAGMENT_SHADER );
863 Property::Array shaderHints;
864 shaderHints.PushBack( "requiresSelfDepthTest" );
865 shaderHints.PushBack( "outputIsTransparent" );
866 shaderHints.PushBack( "outputIsOpaque" );
867 shaderHints.PushBack( "modifiesGeometry" );
869 customShader.Insert( "hints", shaderHints );
872 map.Insert( "rendererType", "image" );
873 map.Insert( "shader", customShader );
875 TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
876 NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
878 ImageView imageView = ImageView::New( nativeImage );
879 imageView.SetProperty( ImageView::Property::IMAGE, map );
880 Stage::GetCurrent().Add( imageView );
882 imageView.SetProperty( ImageView::Property::IMAGE, map );
884 TestGlAbstraction& gl = application.GetGlAbstraction();
885 gl.EnableTextureCallTrace( true );
887 std::vector< GLuint > ids;
889 application.GetGlAbstraction().SetNextTextureIds( ids );
891 application.SendNotification();
892 application.Render();
894 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
896 std::stringstream params;
897 params << GL_TEXTURE_2D << ", " << 23;
898 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
903 // Scenarios 6: ImageView initially from regular image with custom shader but then SetImage called with Native
904 int UtcDaliImageViewSetImageBufferImageWithCustomShaderToNativeImage(void)
906 ToolkitTestApplication application;
911 Property::Map customShader;
912 customShader.Insert( "vertexShader", VERTEX_SHADER );
913 customShader.Insert( "fragmentShader", FRAGMENT_SHADER );
915 Property::Array shaderHints;
916 shaderHints.PushBack( "requiresSelfDepthTest" );
917 shaderHints.PushBack( "outputIsTransparent" );
918 shaderHints.PushBack( "outputIsOpaque" );
919 shaderHints.PushBack( "modifiesGeometry" );
921 customShader.Insert( "hints", shaderHints );
924 map.Insert( "rendererType", "image" );
925 map.Insert( "shader", customShader );
927 BufferImage image = CreateBufferImage( width, height, Color::WHITE );
929 ImageView imageView = ImageView::New( image );
930 imageView.SetProperty( ImageView::Property::IMAGE, map );
931 Stage::GetCurrent().Add( imageView );
933 imageView.SetProperty( ImageView::Property::IMAGE, map );
935 TestGlAbstraction& gl = application.GetGlAbstraction();
936 gl.EnableTextureCallTrace( true );
938 std::vector< GLuint > ids;
940 application.GetGlAbstraction().SetNextTextureIds( ids );
942 application.SendNotification();
943 application.Render();
945 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
947 std::stringstream params;
948 params << GL_TEXTURE_2D << ", " << 23;
949 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
951 TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
952 NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
953 imageView.SetImage( nativeImage );
957 application.GetGlAbstraction().SetNextTextureIds( ids );
959 application.SendNotification();
960 application.Render();
962 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
964 std::stringstream nativeImageParams;
965 nativeImageParams << GL_TEXTURE_2D << ", " << 24;
966 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", nativeImageParams.str()) );