END_TEST;
}
-int UtcDaliNativeImageCreateGlTextureN(void)
+int UtcDaliNativeImageExtensionP(void)
{
TestApplication application;
tet_infoline( "Testing Dali::NativeImage::GenerateGlTexture()" );
- NativeImage image;
- try
- {
- image.CreateGlTexture();
- tet_printf( "Assertion test failed - no Exception\n" );
- tet_result( TET_FAIL );
- }
- catch( Dali::DaliException& e )
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT( e, "image &&", TEST_LOCATION );
- }
+ TestNativeImagePointer testNativeImage = TestNativeImage::New( 16, 16 );
+ DALI_TEST_CHECK( testNativeImage );
+ DALI_TEST_CHECK( NULL != testNativeImage->GetExtension() );
+
+ TestNativeImageNoExtPointer testNativeImage2 = TestNativeImageNoExt::New( 16, 16 );
+ DALI_TEST_CHECK( testNativeImage2 );
+ DALI_TEST_CHECK( NULL == testNativeImage2->GetExtension() );
+
END_TEST;
}
-int UtcDaliNativeImageCreateGlTextureP(void)
+int UtcDaliNativeImageGetCustomFragmentPreFixP(void)
{
TestApplication application;
- tet_infoline( "Testing Dali::NativeImage::GenerateGlTexture()" );
-
- TestNativeImagePointer imageInterface = TestNativeImage::New( 16, 16 );
- NativeImage image = NativeImage::New( *(imageInterface.Get()) );
- DALI_TEST_CHECK( image );
-
- image.CreateGlTexture();
-
- application.SendNotification();
- application.Render(16);
-
- DALI_TEST_EQUALS( imageInterface->mExtensionCreateCalls, 1, TEST_LOCATION );
- DALI_TEST_EQUALS( imageInterface->mTargetTextureCalls, 1, TEST_LOCATION );
+ TestNativeImagePointer nativeImageInterface = TestNativeImage::New( 16, 16 );
+ NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
+ const char* preFix = "#extension GL_OES_EGL_image_external:require\n";
+ DALI_TEST_EQUALS( nativeImage.GetCustomFragmentPreFix(), preFix, TEST_LOCATION );
END_TEST;
}
-int UtcDaliNativeImageContextLoss(void)
+int UtcDaliNativeImageGetCustomSamplerTypenameP(void)
{
TestApplication application;
- tet_infoline( "Testing Dali::NativeImage behaviour through a context lost/regained cycle." );
+ TestNativeImagePointer nativeImageInterface = TestNativeImage::New( 16, 16 );
+ NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
- // Build an image that is expected to have a GL texture created for it and
- // recreated in a GL context recovery:
- TestNativeImagePointer eagerImageInterface = TestNativeImage::New( 16, 16 );
- NativeImage eagerImage = NativeImage::New( *(eagerImageInterface.Get()) );
- DALI_TEST_CHECK( eagerImage );
+ const char* samplerTypename = "samplerExternalOES";
+ DALI_TEST_EQUALS( nativeImage.GetCustomSamplerTypename(), samplerTypename, TEST_LOCATION );
+ END_TEST;
+}
- // Build a regular lazy-allocated image for comparison:
- TestNativeImagePointer lazyImageInterface = TestNativeImage::New( 16, 16 );
- NativeImage lazyImage = NativeImage::New( *(lazyImageInterface.Get()) );
- DALI_TEST_CHECK( lazyImage );
- eagerImage.CreateGlTexture();
- application.SendNotification();
- application.Render(16);
+int UtcDaliNativeImageTestCreationFailure(void)
+{
+ TestApplication application;
+ TestNativeImagePointer nativeImageInterface = TestNativeImage::New( 16, 16 );
+ NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
- // Cycle through a context loss and regain, asserting that the texture is
- // not reallocated if it already existed before the cycle and is never allocated
- // throughout the cycle if of the regular lazy kind:
+ tet_printf("Test what happens when GlExtensionCreate is called, and returns false to indicate an error\n");
- // Call render thread context destroyed / created functions:
- application.ResetContext();
+ nativeImageInterface->SetGlExtensionCreateResult( false );
- // Call event thread function:
- application.GetCore().RecoverFromContextLoss();
+ Actor actor = CreateRenderableActor( nativeImage );
+ actor.SetParentOrigin( ParentOrigin::CENTER );
+ Stage::GetCurrent().Add( actor );
- // Run update/render loop
- application.SendNotification();
- application.Render(16);
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Reset();
+ textureTrace.Enable(true);
- DALI_TEST_EQUALS( eagerImageInterface->mExtensionCreateCalls, 1, TEST_LOCATION );
- DALI_TEST_EQUALS( eagerImageInterface->mTargetTextureCalls, 1, TEST_LOCATION );
+ TraceCallStack& drawTrace = gl.GetDrawTrace();
+ drawTrace.Reset();
+ drawTrace.Enable(true);
- DALI_TEST_EQUALS( lazyImageInterface->mExtensionCreateCalls, 0, TEST_LOCATION );
- DALI_TEST_EQUALS( lazyImageInterface->mTargetTextureCalls, 0, TEST_LOCATION );
+ application.SendNotification();
+ application.Render();
- END_TEST;
-}
+ // Test that nothing was rendered
+ //GlExtensionCreate() called twice, once at initialization and once when trying to bind the texture
+ DALI_TEST_EQUALS( nativeImageInterface->mExtensionCreateCalls, 2, TEST_LOCATION );
+ DALI_TEST_EQUALS( nativeImageInterface->mTargetTextureCalls, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( drawTrace.FindMethod("DrawElements") || drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION );
-int UtcDaliNativeImageExtensionP(void)
-{
- TestApplication application;
- tet_infoline( "Testing Dali::NativeImage::GenerateGlTexture()" );
+ textureTrace.Reset();
+ drawTrace.Reset();
- TestNativeImagePointer testNativeImage = TestNativeImage::New( 16, 16 );
- DALI_TEST_CHECK( testNativeImage );
+ nativeImageInterface->SetGlExtensionCreateResult( true );
+ actor.SetPosition( 0, 0, 1 );
+ application.SendNotification();
+ application.Render();
- DALI_TEST_CHECK( NULL == testNativeImage->GetExtension() );
+ // This time around, the bind and draw should occur following the call to nativeImage->GlExtensionCreate.
+ DALI_TEST_EQUALS( nativeImageInterface->mExtensionCreateCalls, 3, TEST_LOCATION );
+ DALI_TEST_EQUALS( nativeImageInterface->mTargetTextureCalls, 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( drawTrace.FindMethod("DrawElements") || drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION );
END_TEST;
}