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-ImageVisual.cpp;h=25779d574feeda9b8121a0dbcef3744f20db4d21;hp=a56df484f864c1f43213524c94b279341a7418fa;hb=de0c0ef70719409ce6accc801ff664612a96495e;hpb=611b9daaa96e45eb728f8e02fe10c3319bd405c0 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp index a56df48..25779d5 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -30,6 +29,7 @@ #include #include #include +#include #include #include "dummy-control.h" @@ -48,12 +48,13 @@ void dali_image_visual_cleanup(void) namespace { -const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery_small-1.jpg"; +const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg"; const char* TEST_LARGE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/tbcol.png"; const char* TEST_SMALL_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/icon-edit.png"; const char* TEST_REMOTE_IMAGE_FILE_NAME = "https://www.tizen.org/sites/all/themes/tizen_theme/logo.png"; const char* TEST_INVALID_FILE_NAME = TEST_RESOURCE_DIR "/invalid.jpg"; const char* TEST_REMOTE_INVALID_FILE_NAME = "https://www.tizen.org/invalid.png"; +const char* TEST_MASK_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/mask.png"; } @@ -343,7 +344,12 @@ int UtcDaliImageVisualTextureReuse2(void) DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); DALI_TEST_EQUALS( drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION ); - DALI_TEST_EQUALS( textureTrace.CountMethod("BindTexture"), 2, TEST_LOCATION ); + TraceCallStack::NamedParams tex1; + tex1["texture"] = "1"; + TraceCallStack::NamedParams tex2; + tex1["texture"] = "2"; + DALI_TEST_EQUALS( textureTrace.FindMethodAndParams("BindTexture", tex1), true, TEST_LOCATION ); + DALI_TEST_EQUALS( textureTrace.FindMethodAndParams("BindTexture", tex2), true, TEST_LOCATION ); tet_infoline("Test that removing 1 actor deletes it's texture\n"); @@ -444,11 +450,6 @@ int UtcDaliImageVisualCustomWrapModePixelArea(void) application.SendNotification(); application.Render(); - BitmapLoader loader = BitmapLoader::GetLatestCreated(); - DALI_TEST_CHECK( loader ); - loader.WaitForLoading();// waiting until the image to be loaded - DALI_TEST_CHECK( loader.IsLoaded() ); - DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION ); @@ -527,11 +528,6 @@ int UtcDaliImageVisualCustomWrapModeNoAtlas(void) application.SendNotification(); application.Render(); - BitmapLoader loader = BitmapLoader::GetLatestCreated(); - DALI_TEST_CHECK( loader ); - loader.WaitForLoading();// waiting until the image to be loaded - DALI_TEST_CHECK( loader.IsLoaded() ); - DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION ); @@ -846,6 +842,58 @@ int UtcDaliImageVisualTextureCancelRemoteLoad(void) END_TEST; } +int UtcDaliImageVisualTextureCancelAsyncLoad(void) +{ + ToolkitTestApplication application; + tet_infoline( "Load image asynchronosly, cancel loading, then load again" ); + + VisualFactory factory = VisualFactory::Get(); + DALI_TEST_CHECK( factory ); + + Property::Map propertyMap; + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + + Visual::Base visual = factory.CreateVisual( propertyMap ); + DALI_TEST_CHECK( visual ); + + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + textureTrace.Enable( true ); + TraceCallStack& drawTrace = gl.GetDrawTrace(); + drawTrace.Enable( true ); + + DummyControl actor = DummyControl::New(); + DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() ); + dummyImpl.RegisterVisual( Control::Property::BACKGROUND, visual ); + + Stage::GetCurrent().Add( actor ); + + // Cancel loading + Stage::GetCurrent().Remove( actor ); + + Stage::GetCurrent().Add( actor ); + + // Create another visual with the same image + visual = factory.CreateVisual( propertyMap ); + DALI_TEST_CHECK( visual ); + + dummyImpl.RegisterVisual( Control::Property::BACKGROUND, visual ); + + application.SendNotification(); + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); + DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION ); + DALI_TEST_EQUALS( drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliImageVisualSetInvalidAsyncImage(void) { ToolkitTestApplication application; @@ -973,3 +1021,107 @@ int UtcDaliImageVisualSetInvalidRemoteImage(void) END_TEST; } + +int UtcDaliImageVisualAlphaMask(void) +{ + ToolkitTestApplication application; + tet_infoline( "Request image visual with a Property::Map containing an Alpha mask" ); + + VisualFactory factory = VisualFactory::Get(); + DALI_TEST_CHECK( factory ); + + Property::Map propertyMap; + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME ); + propertyMap.Insert( DevelImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME ); + + Visual::Base visual = factory.CreateVisual( propertyMap ); + DALI_TEST_CHECK( visual ); + + Property::Map testMap; + visual.CreatePropertyMap(testMap); + DALI_TEST_EQUALS(*testMap.Find(DevelImageVisual::Property::ALPHA_MASK_URL),Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION ); + + // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied. + // Image with a size smaller than 512*512 will be uploaded as a part of the atlas. + + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + textureTrace.Enable(true); + + DummyControl actor = DummyControl::New(); + DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual ); + + actor.SetSize( 200.f, 200.f ); + DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), false, TEST_LOCATION ); + + Stage::GetCurrent().Add( actor ); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), true, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliImageVisualRemoteAlphaMask(void) +{ + ToolkitTestApplication application; + tet_infoline( "Request image visual with a Property::Map containing an Alpha mask" ); + + VisualFactory factory = VisualFactory::Get(); + DALI_TEST_CHECK( factory ); + + const std::string MASK_IMAGE = TEST_REMOTE_IMAGE_FILE_NAME; + + Property::Map propertyMap; + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMap.Insert( "alphaMaskUrl", MASK_IMAGE ); + + Visual::Base visual = factory.CreateVisual( propertyMap ); + DALI_TEST_CHECK( visual ); + + Property::Map testMap; + visual.CreatePropertyMap(testMap); + DALI_TEST_EQUALS(*testMap.Find(DevelImageVisual::Property::ALPHA_MASK_URL),Property::Value(MASK_IMAGE), TEST_LOCATION ); + + // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied. + // Image with a size smaller than 512*512 will be uploaded as a part of the atlas. + + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + textureTrace.Enable(true); + + DummyControl actor = DummyControl::New(); + DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual ); + DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), false, TEST_LOCATION ); + + actor.SetSize( 200.f, 200.f ); + DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); + + Stage::GetCurrent().Add( actor ); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), true, TEST_LOCATION ); + + END_TEST; +}