X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-NativeImage.cpp;h=6368762075627768d579724510297e301b7cee62;hb=44a5352ea2a8571b9e12df1b90756953d2678d5e;hp=9a36354af1eb2e56385b40205837353b74e3595e;hpb=3b40105fa98689b9356125ffa3da85c85d07bc71;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-NativeImage.cpp b/automated-tests/src/dali/utc-Dali-NativeImage.cpp index 9a36354..6368762 100644 --- a/automated-tests/src/dali/utc-Dali-NativeImage.cpp +++ b/automated-tests/src/dali/utc-Dali-NativeImage.cpp @@ -21,6 +21,7 @@ #include #include #include +#include using namespace Dali; @@ -34,6 +35,20 @@ void utc_dali_native_image_cleanup(void) test_return_value = TET_PASS; } +IntrusivePtr Creator() +{ + return TestNativeImage::New(10,10); +} + +int UtcDaliIntrusivePtrTestNativeImage(void) +{ + UtcCoverageIntrusivePtr pointer; + + pointer.Check(Creator); + + END_TEST; +} + int UtcDaliNativeImageNew(void) { TestApplication application; @@ -53,6 +68,25 @@ int UtcDaliNativeImageNew(void) END_TEST; } +int UtcDaliNativeImageCopyConstructor(void) +{ + TestApplication application; + + tet_infoline("UtcDaliNativeImageCopyConstructor - NativeImage::NativeImage( const NativeImage& )"); + + NativeImage image1; + DALI_TEST_CHECK( !image1 ); + + TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16); + image1 = NativeImage::New(*(nativeImage.Get())); + NativeImage image2( image1 ); + + DALI_TEST_CHECK( image2 ); + DALI_TEST_EQUALS( image1, image2, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliNativeImageDownCast(void) { TestApplication application; @@ -81,3 +115,87 @@ int UtcDaliNativeImageDownCast(void) DALI_TEST_CHECK(image7); END_TEST; } + +int UtcDaliNativeImageCreateGlTextureN(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 ); + } + END_TEST; +} + +int UtcDaliNativeImageCreateGlTextureP(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 ); + + END_TEST; +} + +int UtcDaliNativeImageContextLoss(void) +{ + TestApplication application; + tet_infoline( "Testing Dali::NativeImage behaviour through a context lost/regained cycle." ); + + // 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 ); + + // 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); + + // 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: + + // Call render thread context destroyed / created functions: + application.ResetContext(); + + // Call event thread function: + application.GetCore().RecoverFromContextLoss(); + + // Run update/render loop + application.SendNotification(); + application.Render(16); + + DALI_TEST_EQUALS( eagerImageInterface->mExtensionCreateCalls, 1, TEST_LOCATION ); + DALI_TEST_EQUALS( eagerImageInterface->mTargetTextureCalls, 1, TEST_LOCATION ); + + DALI_TEST_EQUALS( lazyImageInterface->mExtensionCreateCalls, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( lazyImageInterface->mTargetTextureCalls, 0, TEST_LOCATION ); + + END_TEST; +}