X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-SuperBlurView.cpp;h=3c121c067b915da67f67e04b4033c0968f04ace7;hp=5fd205c0218c507f2cb5e6433b984aceb4b63644;hb=c125573992c196f15ece50589ae80efed63c8870;hpb=90b76ea06a1d553df0840f7dde4437ff242320f3 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp index 5fd205c..3c121c0 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp @@ -24,6 +24,7 @@ #include #include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -43,7 +44,7 @@ namespace { const int BLUR_LEVELS = 3; const int RENDER_FRAME_INTERVAL = 16; - +const char* TEST_IMAGE_FILE_NAME("image.png"); static bool gObjectCreatedCallBackCalled; static void TestCallback(BaseHandle handle) { @@ -98,6 +99,43 @@ Image CreateSolidColorImage( ToolkitTestApplication& application, const Vector4& return imageData; } + +void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height) +{ + Integration::ResourceRequest* request = platform.GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height); + + if(request) + { + platform.SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } +} + +class SignalHandler : public Dali::ConnectionTracker +{ +public: + SignalHandler() : + mCalls( 0 ) + { + } + + void Callback( SuperBlurView handle ) + { + mCalls++; + tet_infoline( "Signal called" ); + } + + unsigned int GetCalls() const + { + return mCalls; + } + +private: + unsigned int mCalls; ///< Keeps track of how many times the signal has been called. +}; + }//namespace @@ -138,6 +176,33 @@ int UtcDaliSuperBlurViewNew(void) END_TEST; } +int UtcDaliSuperBlurViewCreate(void) +{ + ToolkitTestApplication application; + + tet_infoline(" UtcDaliSuperBlurViewNew "); + + // Test default constructor. + SuperBlurView blurView; + DALI_TEST_CHECK( !blurView ); + + // Test object creation + TypeInfo type = TypeRegistry::Get().GetTypeInfo("SuperBlurView"); + if( type ) + { + Dali::BaseHandle handle = type.CreateInstance(); + if( handle ) + { + blurView = Dali::Toolkit::SuperBlurView::DownCast( handle ); + } + } + + DALI_TEST_CHECK( blurView ); + + END_TEST; +} + + int UtcDaliSuperBlurViewSetImage(void) { ToolkitTestApplication application; @@ -145,16 +210,100 @@ int UtcDaliSuperBlurViewSetImage(void) tet_infoline(" UtcDaliSuperBlurViewSetImage "); SuperBlurView blurView = SuperBlurView::New( BLUR_LEVELS ); - // create image actors for the original image and each blurred image - DALI_TEST_CHECK( blurView.GetChildCount() == BLUR_LEVELS+1 ); + blurView.SetSize( 100.f, 100.f ); Image inputImage = CreateSolidColorImage( application, Color::GREEN, 50, 50 ); blurView.SetImage( inputImage ); // start multiple guassian blur call, each guassian blur creates two render tasks - DALI_TEST_CHECK( Stage::GetCurrent().GetRenderTaskList().GetTaskCount() == BLUR_LEVELS*2 + 1); + DALI_TEST_CHECK( Stage::GetCurrent().GetRenderTaskList().GetTaskCount() == 1+BLUR_LEVELS*2); + + { + // create image renderers for the original image and each blurred image + Stage::GetCurrent().Add( blurView ); + Wait(application); + DALI_TEST_EQUALS(blurView.GetRendererCount(), BLUR_LEVELS+1, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + Stage::GetCurrent().Remove( blurView ); + } + END_TEST; } +int UtcDaliSuperBlurViewSetProperty(void) +{ + ToolkitTestApplication application; + + tet_infoline(" UtcDaliSuperBlurViewSetProperty "); + + SuperBlurView blurView = SuperBlurView::New( BLUR_LEVELS ); + // create image renderers for the original image and each blurred image + Stage::GetCurrent().Add( blurView ); + blurView.SetSize( 100.f, 100.f ); + + tet_infoline(" Set property map. Set height and width large enough to avoid atlassing"); + int width(512); + int height(513); + LoadBitmapResource( application.GetPlatform(), width, height ); + + Property::Map propertyMap; + propertyMap["filename"] = TEST_IMAGE_FILE_NAME ; + propertyMap["width"] = width; + propertyMap["height"] = height; + + // Will create ResourceImage + blurView.SetProperty(SuperBlurView::Property::IMAGE, propertyMap); + Wait(application); + + // start multiple guassian blur call, each guassian blur creates two render tasks + DALI_TEST_CHECK( Stage::GetCurrent().GetRenderTaskList().GetTaskCount() == 1+BLUR_LEVELS*2); + + Wait(application); + + END_TEST; +} + + +int UtcDaliSuperBlurViewGetProperty(void) +{ + ToolkitTestApplication application; + + tet_infoline(" UtcDaliSuperBlurViewSetProperty "); + + SuperBlurView blurView = SuperBlurView::New( BLUR_LEVELS ); + blurView.SetSize( 100.f, 100.f ); + + tet_infoline(" Set property map."); + int width(512); + int height(513); // Value large enough to avoid future atlassing + LoadBitmapResource( application.GetPlatform(), width, height ); + + Property::Map propertyMap; + propertyMap["filename"] = TEST_IMAGE_FILE_NAME ; + propertyMap["width"] = width; + propertyMap["height"] = height; + + // Will create ResourceImage + blurView.SetProperty(SuperBlurView::Property::IMAGE, propertyMap); + Wait(application); + + // create image renderers for the original image and each blurred image + Stage::GetCurrent().Add( blurView ); + + Property::Value imageProperty = blurView.GetProperty(SuperBlurView::Property::IMAGE); + Property::Map* map = imageProperty.GetMap(); + DALI_TEST_CHECK( map != NULL ); + if( map ) + { + Property::Map& mapRef = *map; + DALI_TEST_EQUALS( mapRef["filename"], TEST_IMAGE_FILE_NAME, TEST_LOCATION ); + } + + END_TEST; +} + + int UtcDaliSuperBlurViewSetGetBlurStrength(void) { ToolkitTestApplication application; @@ -207,11 +356,38 @@ int UtcDaliSuperBlurViewGetBlurredImage(void) DALI_TEST_CHECK( image1 ); Image image2 = blurView.GetBlurredImage( 2 ); - DALI_TEST_CHECK( image2.GetWidth() == 25 ); - DALI_TEST_CHECK( image2.GetHeight() == 25 ); + DALI_TEST_EQUALS( image2.GetWidth(), 25u, TEST_LOCATION ); + DALI_TEST_EQUALS( image2.GetHeight(), 25u, TEST_LOCATION ); Image image3 = blurView.GetBlurredImage( 3 ); - DALI_TEST_CHECK( FrameBufferImage::DownCast( image2 ) ); + DALI_TEST_CHECK( FrameBufferImage::DownCast( image3 ) ); + + END_TEST; +} + +int UtcDaliSuperBlurViewBlurSignal(void) +{ + ToolkitTestApplication application; + + tet_infoline(" UtcDaliSuperBlurViewSignal "); + + SuperBlurView blurView = SuperBlurView::New( BLUR_LEVELS ); + blurView.SetSize( 100.f, 100.f ); + + Image inputImage = CreateSolidColorImage( application, Color::GREEN, 50, 50 ); + blurView.SetImage( inputImage ); + // start multiple guassian blur call, each guassian blur creates two render tasks + DALI_TEST_CHECK( Stage::GetCurrent().GetRenderTaskList().GetTaskCount() == 1+BLUR_LEVELS*2); + + SignalHandler signalHandler; + blurView.BlurFinishedSignal().Connect(&signalHandler, &SignalHandler::Callback); + + // create image renderers for the original image and each blurred image + Stage::GetCurrent().Add( blurView ); + Wait(application, 1000); + + DALI_TEST_EQUALS(blurView.GetRendererCount(), BLUR_LEVELS+1, TEST_LOCATION ); + //DALI_TEST_EQUALS(signalHandler.GetCalls(), 1, TEST_LOCATION); END_TEST; }