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/material.h>
25 #include <dali/devel-api/rendering/renderer.h>
27 #include <test-native-image.h>
31 using namespace Toolkit;
33 void utc_dali_toolkit_image_view_startup(void)
35 test_return_value = TET_UNDEF;
38 void utc_dali_toolkit_image_view_cleanup(void)
40 test_return_value = TET_PASS;
46 const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
47 attribute mediump vec2 aPosition;\n
48 varying mediump vec2 vTexCoord;\n
49 uniform mediump mat4 uMvpMatrix;\n
50 uniform mediump vec3 uSize;\n
54 mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
55 vertexPosition.xyz *= uSize;\n
56 vertexPosition = uMvpMatrix * vertexPosition;\n
58 vTexCoord = aPosition + vec2(0.5);\n
59 gl_Position = vertexPosition;\n
63 const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
64 varying mediump vec2 vTexCoord;\n
65 uniform sampler2D sTexture;\n
66 uniform lowp vec4 uColor;\n
70 gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
74 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
75 const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
77 void TestImage( ImageView imageView, BufferImage image )
79 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
82 DALI_TEST_CHECK( value.Get( map ) );
84 DALI_TEST_CHECK( map.Find( "width" ) );
85 DALI_TEST_CHECK( map.Find( "height" ) );
86 DALI_TEST_CHECK( map.Find( "type" ) );
89 DALI_TEST_CHECK( map[ "width" ].Get( width ) );
90 DALI_TEST_EQUALS( (unsigned int)width, image.GetWidth(), TEST_LOCATION );
93 DALI_TEST_CHECK( map[ "height" ].Get( height ) );
94 DALI_TEST_EQUALS( (unsigned int)height, image.GetHeight(), TEST_LOCATION );
97 DALI_TEST_CHECK( map[ "type" ].Get( type ) );
98 DALI_TEST_EQUALS( type, "BufferImage", TEST_LOCATION );
101 void TestImage( ImageView imageView, ResourceImage image )
103 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
106 DALI_TEST_CHECK( value.Get( map ) );
108 if( map.Find( "width" ) )
111 DALI_TEST_CHECK( map[ "width" ].Get( width ) );
112 DALI_TEST_EQUALS( (unsigned int)width, image.GetWidth(), TEST_LOCATION );
115 if( map.Find( "height" ) )
118 DALI_TEST_CHECK( map[ "height" ].Get( height ) );
119 DALI_TEST_EQUALS( (unsigned int)height, image.GetHeight(), TEST_LOCATION );
122 DALI_TEST_CHECK( map.Find( "type" ) );
125 DALI_TEST_CHECK( map[ "type" ].Get( type ) );
126 DALI_TEST_EQUALS( type, "ResourceImage", TEST_LOCATION );
128 std::string filename;
129 DALI_TEST_CHECK( map[ "filename" ].Get( filename ) );
130 DALI_TEST_EQUALS( filename, image.GetUrl(), TEST_LOCATION );
133 void TestUrl( ImageView imageView, const std::string url )
135 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
137 std::string urlActual;
138 DALI_TEST_CHECK( value.Get( urlActual ) );
139 DALI_TEST_EQUALS( urlActual, url, TEST_LOCATION );
144 int UtcDaliImageViewNewP(void)
146 TestApplication application;
148 ImageView imageView = ImageView::New();
150 DALI_TEST_CHECK( imageView );
155 int UtcDaliImageViewNewImageP(void)
157 TestApplication application;
159 BufferImage image = CreateBufferImage( 100, 200, Vector4( 1.f, 1.f, 1.f, 1.f ) );
160 ImageView imageView = ImageView::New( image );
162 DALI_TEST_CHECK( imageView );
163 TestImage( imageView, image );
168 int UtcDaliImageViewNewUrlP(void)
170 TestApplication application;
172 ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
173 DALI_TEST_CHECK( imageView );
175 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
180 int UtcDaliImageViewConstructorP(void)
182 TestApplication application;
186 DALI_TEST_CHECK( !imageView );
191 int UtcDaliImageViewCopyConstructorP(void)
193 TestApplication application;
195 // Initialize an object, ref count == 1
196 ImageView imageView = ImageView::New();
198 ImageView copy( imageView );
199 DALI_TEST_CHECK( copy );
204 int UtcDaliImageViewAssignmentOperatorP(void)
206 TestApplication application;
208 ImageView imageView = ImageView::New();
210 ImageView copy( imageView );
211 DALI_TEST_CHECK( copy );
212 DALI_TEST_EQUALS( imageView, copy, TEST_LOCATION );
217 int UtcDaliImageViewDownCastP(void)
219 TestApplication application;
221 ImageView imageView = ImageView::New();
223 BaseHandle object(imageView);
225 ImageView imageView2 = ImageView::DownCast( object );
226 DALI_TEST_CHECK(imageView2);
228 ImageView imageView3 = DownCast< ImageView >( object );
229 DALI_TEST_CHECK(imageView3);
234 int UtcDaliImageViewDownCastN(void)
236 TestApplication application;
238 BaseHandle unInitializedObject;
240 ImageView imageView1 = ImageView::DownCast( unInitializedObject );
241 DALI_TEST_CHECK( !imageView1 );
243 ImageView imageView2 = DownCast< ImageView >( unInitializedObject );
244 DALI_TEST_CHECK( !imageView2 );
249 int UtcDaliImageViewTypeRegistry(void)
251 ToolkitTestApplication application;
253 TypeRegistry typeRegistry = TypeRegistry::Get();
254 DALI_TEST_CHECK( typeRegistry );
256 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "ImageView" );
257 DALI_TEST_CHECK( typeInfo );
259 BaseHandle handle = typeInfo.CreateInstance();
260 DALI_TEST_CHECK( handle );
262 ImageView imageView = ImageView::DownCast( handle );
263 DALI_TEST_CHECK( imageView );
268 int UtcDaliImageViewSetGetProperty01(void)
270 ToolkitTestApplication application;
272 ImageView imageView = ImageView::New();
274 Property::Index idx = imageView.GetPropertyIndex( "image" );
275 DALI_TEST_EQUALS( idx, (Property::Index)ImageView::Property::IMAGE, TEST_LOCATION );
277 imageView.SetProperty( idx, TEST_IMAGE_FILE_NAME );
278 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
283 int UtcDaliImageViewSetGetProperty02(void)
285 ToolkitTestApplication application;
287 Image image = CreateBufferImage( 10, 10, Color::WHITE );
288 ImageView imageView = ImageView::New(image);
289 Vector4 fullImageRect( 0.f, 0.f, 1.f, 1.f );
291 Stage::GetCurrent().Add( imageView );
293 application.SendNotification();
294 application.Render();
295 TestGlAbstraction& gl = application.GetGlAbstraction();
297 Vector4 pixelAreaUniform;
298 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
299 DALI_TEST_EQUALS( pixelAreaUniform, fullImageRect, TEST_LOCATION );
301 Property::Value value = imageView.GetProperty( ImageView::Property::PIXEL_AREA );
302 Vector4 pixelAreaValue;
303 DALI_TEST_CHECK( value.Get(pixelAreaValue) );
304 DALI_TEST_EQUALS( pixelAreaValue, fullImageRect, TEST_LOCATION );
306 Vector4 pixelAreaSet( 0.2f, 0.2f, 0.3f, 0.3f );
307 imageView.SetProperty( ImageView::Property::PIXEL_AREA, pixelAreaSet);
309 application.SendNotification();
310 application.Render();
312 value = imageView.GetProperty( ImageView::Property::PIXEL_AREA );
313 value.Get(pixelAreaValue);
314 DALI_TEST_EQUALS( pixelAreaValue, pixelAreaSet, TEST_LOCATION );
316 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
317 DALI_TEST_EQUALS( pixelAreaUniform, pixelAreaSet, TEST_LOCATION );
322 int UtcDaliImageViewSetGetProperty03(void)
324 ToolkitTestApplication application;
326 Image image = CreateBufferImage( 10, 10, Color::WHITE );
327 ImageView imageView = ImageView::New(image);
328 Stage::GetCurrent().Add( imageView );
329 application.SendNotification();
330 application.Render();
332 // conventional alpha blending
333 Material material = imageView.GetRendererAt( 0 ).GetMaterial();
334 BlendingFactor::Type srcFactorRgb;
335 BlendingFactor::Type destFactorRgb;
336 BlendingFactor::Type srcFactorAlpha;
337 BlendingFactor::Type destFactorAlpha;
338 material.GetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
339 DALI_TEST_CHECK( srcFactorRgb == BlendingFactor::SRC_ALPHA );
340 DALI_TEST_CHECK( destFactorRgb == BlendingFactor::ONE_MINUS_SRC_ALPHA );
341 DALI_TEST_CHECK( srcFactorAlpha == BlendingFactor::ONE );
342 DALI_TEST_CHECK( destFactorAlpha == BlendingFactor::ONE_MINUS_SRC_ALPHA );
344 TestGlAbstraction& gl = application.GetGlAbstraction();
346 float alphaBlendingUniform;
347 DALI_TEST_CHECK( gl.GetUniformValue<float>( "uAlphaBlending", alphaBlendingUniform ) );
348 DALI_TEST_EQUALS( alphaBlendingUniform, 1.f, TEST_LOCATION );
350 // pre-multiplied alpha blending
351 imageView.SetProperty( Toolkit::ImageView::Property::PRE_MULTIPLIED_ALPHA, true );
352 application.SendNotification();
353 application.Render();
355 material.GetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
356 DALI_TEST_CHECK( srcFactorRgb == BlendingFactor::ONE );
357 DALI_TEST_CHECK( destFactorRgb == BlendingFactor::ONE_MINUS_SRC_ALPHA );
358 DALI_TEST_CHECK( srcFactorAlpha == BlendingFactor::ONE );
359 DALI_TEST_CHECK( destFactorAlpha == BlendingFactor::ONE );
361 DALI_TEST_CHECK( gl.GetUniformValue<float>( "uAlphaBlending", alphaBlendingUniform ) );
362 DALI_TEST_EQUALS( alphaBlendingUniform, 0.f, TEST_LOCATION );
367 int UtcDaliImageViewSizeWithBackground(void)
369 ToolkitTestApplication application;
373 Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
374 ImageView imageView = ImageView::New();
375 imageView.SetBackgroundImage( image );
377 Stage::GetCurrent().Add( imageView );
378 application.SendNotification();
379 application.Render();
381 DALI_TEST_EQUALS( imageView.GetCurrentSize().width, (float)width, TEST_LOCATION );
382 DALI_TEST_EQUALS( imageView.GetCurrentSize().height, (float)height, TEST_LOCATION );
387 int UtcDaliImageViewSizeWithBackgroundAndImage(void)
389 ToolkitTestApplication application;
391 int widthBackground = 100;
392 int heightBackground = 200;
395 Image imageBackground = CreateBufferImage( widthBackground, heightBackground, Vector4(1.f, 1.f, 1.f, 1.f) );
396 Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
398 ImageView imageView = ImageView::New();
399 imageView.SetBackgroundImage( imageBackground );
400 imageView.SetImage( image );
402 Stage::GetCurrent().Add( imageView );
403 application.SendNotification();
404 application.Render();
406 DALI_TEST_EQUALS( imageView.GetCurrentSize().width, (float)width, TEST_LOCATION );
407 DALI_TEST_EQUALS( imageView.GetCurrentSize().height, (float)height, TEST_LOCATION );
412 int UtcDaliImageViewHeightForWidthBackground(void)
414 ToolkitTestApplication application;
416 int widthBackground = 100;
417 int heightBackground = 200;
418 Image imageBackground = CreateBufferImage( widthBackground, heightBackground, Vector4(1.f, 1.f, 1.f, 1.f) );
420 ImageView imageView = ImageView::New();
421 imageView.SetBackgroundImage( imageBackground );
423 Stage::GetCurrent().Add( imageView );
424 application.SendNotification();
425 application.Render();
427 Control control = Control::DownCast( imageView );
428 DALI_TEST_CHECK( control );
429 DALI_TEST_EQUALS( imageView.GetHeightForWidth( 123.f ), control.GetHeightForWidth( 123.f ), TEST_LOCATION );
430 DALI_TEST_EQUALS( imageView.GetWidthForHeight( 321.f ), control.GetWidthForHeight( 321.f ), TEST_LOCATION );
435 int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
437 ToolkitTestApplication application;
439 int widthBackground = 100;
440 int heightBackground = 200;
443 Image imageBackground = CreateBufferImage( widthBackground, heightBackground, Vector4(1.f, 1.f, 1.f, 1.f) );
444 Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
446 ImageView imageView = ImageView::New();
447 imageView.SetBackgroundImage( imageBackground );
448 imageView.SetImage( image );
450 Stage::GetCurrent().Add( imageView );
451 application.SendNotification();
452 application.Render();
454 DALI_TEST_EQUALS( imageView.GetHeightForWidth( width ), (float)height, TEST_LOCATION );
455 DALI_TEST_EQUALS( imageView.GetWidthForHeight( height ), (float)width, TEST_LOCATION );
460 int UtcDaliImageViewSetBufferImage(void)
462 ToolkitTestApplication application;
466 BufferImage image1 = CreateBufferImage( width1, height1, Vector4( 1.f, 1.f, 1.f, 1.f ) );
467 ImageView imageView = ImageView::New();
468 imageView.SetImage( image1 );
470 TestImage( imageView, image1 );
474 BufferImage image2 = CreateBufferImage( width2, height2, Vector4( 1.f, 1.f, 1.f, 1.f ) );
475 imageView.SetImage( image2 );
477 TestImage( imageView, image2 );
482 int UtcDaliImageViewSetImageUrl(void)
484 ToolkitTestApplication application;
486 ImageView imageView = ImageView::New();
487 imageView.SetImage( TEST_IMAGE_FILE_NAME );
488 TestUrl( imageView, TEST_IMAGE_FILE_NAME );
491 imageView.SetImage( TEST_IMAGE_FILE_NAME2 );
492 TestUrl( imageView, TEST_IMAGE_FILE_NAME2 );
497 int UtcDaliImageViewSetImageOnstageP(void)
499 ToolkitTestApplication application;
501 ImageView imageView = ImageView::New();
503 Stage::GetCurrent().Add( imageView );
504 application.SendNotification();
505 application.Render();
507 ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
508 imageView.SetImage( image1 );
509 TestImage( imageView, image1 );
513 BufferImage image2 = CreateBufferImage( width, height, Vector4( 1.f, 1.f, 1.f, 1.f ) );
514 imageView.SetImage( image2 );
515 TestImage( imageView, image2 );
520 int UtcDaliImageViewSetImageOnstageN(void)
522 ToolkitTestApplication application;
524 ImageView imageView = ImageView::New();
526 Stage::GetCurrent().Add( imageView );
527 application.SendNotification();
528 application.Render();
530 ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
531 imageView.SetImage( image1 );
532 TestImage( imageView, image1 );
535 imageView.SetImage( image2 );
537 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
539 //the value should be empty
541 DALI_TEST_CHECK( !value.Get( url ) );
544 DALI_TEST_CHECK( !value.Get( map ) );
549 int UtcDaliImageViewSetImageOffstageP(void)
551 ToolkitTestApplication application;
553 ImageView imageView = ImageView::New();
555 Stage::GetCurrent().Add( imageView );
556 application.SendNotification();
557 application.Render();
558 Stage::GetCurrent().Remove( imageView );
560 ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
561 imageView.SetImage( image1 );
562 TestImage( imageView, image1 );
566 BufferImage image2 = CreateBufferImage( width, height, Vector4( 1.f, 1.f, 1.f, 1.f ) );
567 imageView.SetImage( image2 );
568 TestImage( imageView, image2 );
573 int UtcDaliImageViewSetImageOffstageN(void)
575 ToolkitTestApplication application;
577 ImageView imageView = ImageView::New();
579 Stage::GetCurrent().Add( imageView );
580 application.SendNotification();
581 application.Render();
582 Stage::GetCurrent().Remove( imageView );
584 ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
585 imageView.SetImage( image1 );
586 TestImage( imageView, image1 );
589 imageView.SetImage( image2 );
591 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
593 //the value should be empty
595 DALI_TEST_CHECK( !value.Get( url ) );
598 DALI_TEST_CHECK( !value.Get( map ) );
603 int UtcDaliImageViewSetImageN(void)
605 ToolkitTestApplication application;
608 ImageView imageView = ImageView::New();
609 imageView.SetImage( image1 );
611 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
613 //the value should be empty
615 DALI_TEST_CHECK( !value.Get( url ) );
618 DALI_TEST_CHECK( !value.Get( map ) );
620 std::string resource_url;
621 Property::Value val = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
622 DALI_TEST_CHECK( !val.Get( resource_url ) );
627 int UtcDaliImageViewSetImageTypeChangesP(void)
629 ToolkitTestApplication application;
631 ImageView imageView = ImageView::New();
637 Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
638 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
639 DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
642 imageView.SetImage( "TEST_URL" );
643 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
645 DALI_TEST_CHECK( value.Get( url ) ); // Value should NOT be empty
646 DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
648 // Set an empty Image
649 imageView.SetImage( Image() );
650 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
652 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
653 DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
656 ResourceImage image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
657 imageView.SetImage( image1 );
658 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
660 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
661 DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
664 imageView.SetImage( "" );
665 value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
667 DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
668 DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
673 int UtcDaliImageViewResourceUrlP(void)
675 ToolkitTestApplication application;
677 ImageView imageView = ImageView::New();
678 DALI_TEST_CHECK( imageView.GetProperty( ImageView::Property::RESOURCE_URL ).Get< std::string >().empty() );
680 imageView.SetProperty( ImageView::Property::RESOURCE_URL, "TestString" );
681 DALI_TEST_EQUALS( imageView.GetProperty( ImageView::Property::RESOURCE_URL ).Get< std::string >(), "TestString", TEST_LOCATION );
686 // Scenarios 1: ImageView from regular image
687 int UtcDaliImageViewSetImageBufferImage(void)
689 ToolkitTestApplication application;
691 ImageView imageView = ImageView::New();
692 Stage::GetCurrent().Add( imageView );
694 TestGlAbstraction& gl = application.GetGlAbstraction();
695 gl.EnableTextureCallTrace( true );
697 std::vector< GLuint > ids;
699 application.GetGlAbstraction().SetNextTextureIds( ids );
703 BufferImage image = CreateBufferImage( width, height, Color::WHITE );
705 imageView.SetImage( image );
707 application.SendNotification();
708 application.Render();
710 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
712 std::stringstream params;
713 params << GL_TEXTURE_2D << ", " << 23;
714 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
719 // Scenarios 2: ImageView from Native image
720 int UtcDaliImageViewSetImageNativeImage(void)
722 ToolkitTestApplication application;
724 ImageView imageView = ImageView::New();
725 Stage::GetCurrent().Add( imageView );
727 TestGlAbstraction& gl = application.GetGlAbstraction();
728 gl.EnableTextureCallTrace( true );
730 std::vector< GLuint > ids;
732 application.GetGlAbstraction().SetNextTextureIds( ids );
736 TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
737 NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
739 imageView.SetImage( nativeImage );
740 application.SendNotification();
741 application.Render();
743 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
745 std::stringstream params;
746 params << GL_TEXTURE_2D << ", " << 23;
747 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
752 // Scenarios 3: ImageView initially from regular image but then SetImage called with Native image
753 int UtcDaliImageViewSetImageBufferImageToNativeImage(void)
755 ToolkitTestApplication application;
759 BufferImage image = CreateBufferImage( width, height, Color::WHITE );
761 ImageView imageView = ImageView::New( image );
762 Stage::GetCurrent().Add( imageView );
764 TestGlAbstraction& gl = application.GetGlAbstraction();
765 gl.EnableTextureCallTrace( true );
767 std::vector< GLuint > ids;
769 application.GetGlAbstraction().SetNextTextureIds( ids );
771 application.SendNotification();
772 application.Render();
774 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
776 std::stringstream params;
777 params << GL_TEXTURE_2D << ", " << 23;
778 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
782 TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
783 NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
784 imageView.SetImage( nativeImage );
788 application.GetGlAbstraction().SetNextTextureIds( ids );
790 application.SendNotification();
791 application.Render();
793 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
795 std::stringstream nextTextureParams;
796 nextTextureParams << GL_TEXTURE_2D << ", " << 24;
797 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", nextTextureParams.str()) );
802 // Scenarios 4: ImageView initially from Native image but then SetImage called with regular image
803 int UtcDaliImageViewSetImageNativeImageToBufferImage(void)
805 ToolkitTestApplication application;
809 TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
810 NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
812 ImageView imageView = ImageView::New( nativeImage );
813 Stage::GetCurrent().Add( imageView );
815 TestGlAbstraction& gl = application.GetGlAbstraction();
816 gl.EnableTextureCallTrace( true );
818 std::vector< GLuint > ids;
820 application.GetGlAbstraction().SetNextTextureIds( ids );
822 application.SendNotification();
823 application.Render();
825 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
827 std::stringstream params;
828 params << GL_TEXTURE_2D << ", " << 23;
829 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
833 BufferImage image = CreateBufferImage( width, height, Color::WHITE );
834 imageView.SetImage( image );
838 application.GetGlAbstraction().SetNextTextureIds( ids );
840 application.SendNotification();
841 application.Render();
843 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
845 std::stringstream nextTextureParams;
846 nextTextureParams << GL_TEXTURE_2D << ", " << 24;
847 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", nextTextureParams.str()) );
852 // Scenarios 5: ImageView from Native image with custom shader
853 int UtcDaliImageViewSetImageNativeImageWithCustomShader(void)
855 ToolkitTestApplication application;
860 Property::Map customShader;
861 customShader.Insert( "vertexShader", VERTEX_SHADER );
862 customShader.Insert( "fragmentShader", FRAGMENT_SHADER );
864 Property::Array shaderHints;
865 shaderHints.PushBack( "requiresSelfDepthTest" );
866 shaderHints.PushBack( "outputIsTransparent" );
867 shaderHints.PushBack( "outputIsOpaque" );
868 shaderHints.PushBack( "modifiesGeometry" );
870 customShader.Insert( "hints", shaderHints );
873 map.Insert( "rendererType", "imageRenderer" );
874 map.Insert( "shader", customShader );
876 TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
877 NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
879 ImageView imageView = ImageView::New( nativeImage );
880 imageView.SetProperty( ImageView::Property::IMAGE, map );
881 Stage::GetCurrent().Add( imageView );
883 imageView.SetProperty( ImageView::Property::IMAGE, map );
885 TestGlAbstraction& gl = application.GetGlAbstraction();
886 gl.EnableTextureCallTrace( true );
888 std::vector< GLuint > ids;
890 application.GetGlAbstraction().SetNextTextureIds( ids );
892 application.SendNotification();
893 application.Render();
895 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
897 std::stringstream params;
898 params << GL_TEXTURE_2D << ", " << 23;
899 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
904 // Scenarios 6: ImageView initially from regular image with custom shader but then SetImage called with Native
905 int UtcDaliImageViewSetImageBufferImageWithCustomShaderToNativeImage(void)
907 ToolkitTestApplication application;
912 Property::Map customShader;
913 customShader.Insert( "vertexShader", VERTEX_SHADER );
914 customShader.Insert( "fragmentShader", FRAGMENT_SHADER );
916 Property::Array shaderHints;
917 shaderHints.PushBack( "requiresSelfDepthTest" );
918 shaderHints.PushBack( "outputIsTransparent" );
919 shaderHints.PushBack( "outputIsOpaque" );
920 shaderHints.PushBack( "modifiesGeometry" );
922 customShader.Insert( "hints", shaderHints );
925 map.Insert( "rendererType", "imageRenderer" );
926 map.Insert( "shader", customShader );
928 BufferImage image = CreateBufferImage( width, height, Color::WHITE );
930 ImageView imageView = ImageView::New( image );
931 imageView.SetProperty( ImageView::Property::IMAGE, map );
932 Stage::GetCurrent().Add( imageView );
934 imageView.SetProperty( ImageView::Property::IMAGE, map );
936 TestGlAbstraction& gl = application.GetGlAbstraction();
937 gl.EnableTextureCallTrace( true );
939 std::vector< GLuint > ids;
941 application.GetGlAbstraction().SetNextTextureIds( ids );
943 application.SendNotification();
944 application.Render();
946 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
948 std::stringstream params;
949 params << GL_TEXTURE_2D << ", " << 23;
950 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
952 TestNativeImagePointer nativeImageInterface = TestNativeImage::New( width, height );
953 NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
954 imageView.SetImage( nativeImage );
958 application.GetGlAbstraction().SetNextTextureIds( ids );
960 application.SendNotification();
961 application.Render();
963 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
965 std::stringstream nativeImageParams;
966 nativeImageParams << GL_TEXTURE_2D << ", " << 24;
967 DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", nativeImageParams.str()) );