X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-ImageVisual.cpp;h=7b07ffc0403a6a333aa1d41070a6645cd1ee22dd;hb=fac892daf82a0d6b8edc049bf29cca33887d37fa;hp=4b5e54645aeb4cbafe5e0d9ed215033689de862d;hpb=1c1896d3ed691afb6d80f8b20bc66a994d5bc7f8;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp index 4b5e546..7b07ffc 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp @@ -680,6 +680,72 @@ int UtcDaliImageVisualWithPixelDataMasking(void) END_TEST; } +int UtcDaliImageVisualWithPixelDataMasking02(void) +{ + ToolkitTestApplication application; + tet_infoline("Load premultiplied external texture with mask"); + + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + textureTrace.Enable(true); + + uint32_t width(64); + uint32_t height(64); + uint32_t bufferSize = width * height * Pixel::GetBytesPerPixel(Pixel::RGBA8888); + + uint8_t* buffer = reinterpret_cast(malloc(bufferSize)); + PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE); + + DALI_TEST_CHECK(pixelData); + + ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(pixelData, true); + std::string url = imageUrl.GetUrl(); + + VisualFactory factory = VisualFactory::Get(); + DALI_TEST_CHECK(factory); + + Property::Map propertyMap; + propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE); + propertyMap.Insert(ImageVisual::Property::URL, url); + propertyMap.Insert(ImageVisual::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(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION); + + DummyControl actor = DummyControl::New(); + DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual); + + DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION); + + application.GetScene().Add(actor); + application.SendNotification(); + application.Render(16); + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION); + DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION); + + Renderer renderer = actor.GetRendererAt(0); + + //Check visual property + DALI_TEST_EQUALS(*testMap.Find(Visual::Property::PREMULTIPLIED_ALPHA), Property::Value(true), TEST_LOCATION); + + // Check whether preMultipliedAlpha is true. + auto preMultipliedAlpha = renderer.GetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA); + DALI_TEST_EQUALS(preMultipliedAlpha, true, TEST_LOCATION); + + dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1); + DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION); + + END_TEST; +} + int UtcDaliImageVisualWithPixelDataMaskingSynchronously(void) { ToolkitTestApplication application; @@ -3803,7 +3869,6 @@ int UtcDaliImageVisualLoadFastTrackImageReload(void) int UtcDaliImageVisualLoadFastTrackImagePlanes01(void) { -#if 0 //< Do not open this UTC yet. EnvironmentVariable::SetTestEnvironmentVariable(LOAD_IMAGE_YUV_PLANES_ENV, "1"); EnvironmentVariable::SetTestEnvironmentVariable(ENABLE_DECODE_JPEG_TO_YUV_420_ENV, "1"); @@ -3853,19 +3918,65 @@ int UtcDaliImageVisualLoadFastTrackImagePlanes01(void) DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 3, TEST_LOCATION); - // Event thread don't know the result yet. - DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION); + application.SendNotification(); + application.Render(); - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + END_TEST; +} + +int UtcDaliImageVisualLoadFastTrackImagePlanes02(void) +{ + EnvironmentVariable::SetTestEnvironmentVariable(LOAD_IMAGE_YUV_PLANES_ENV, "1"); + EnvironmentVariable::SetTestEnvironmentVariable(ENABLE_DECODE_JPEG_TO_YUV_420_ENV, "1"); + + ToolkitTestApplication application; + + Test::TextureUploadManager::InitalizeGraphicsController(application.GetGraphicsController()); + + VisualFactory factory = VisualFactory::Get(); + DALI_TEST_CHECK(factory); + + Property::Map propertyMap; + propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE); + propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME); + propertyMap.Insert(DevelImageVisual::Property::FAST_TRACK_UPLOADING, true); + + Visual::Base visual = factory.CreateVisual(propertyMap); + DALI_TEST_CHECK(visual); + + DummyControl actor = DummyControl::New(); + DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual); + actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f)); + + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + textureTrace.Enable(true); + + application.GetScene().Add(actor); - // Check resource ready comes after application.SendNotification(); + application.Render(); - DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION); - DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION); + // EventThread without callback + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 30, false), true, TEST_LOCATION); + + DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION); + + { + // TODO : There is no way to flush TextureUploadManager in test-application's Render() now. + // How can we make it? Should it be integration-api? + auto textureUploadManager = Dali::Devel::TextureUploadManager::Get(); + textureUploadManager.ResourceUpload(); + application.Render(); + } + // Render only without SendNotification(). And check whether glTexImage2D called or not. + application.Render(); + + DALI_TEST_GREATER(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION); + + application.SendNotification(); + application.Render(); -#else - DALI_TEST_CHECK(true); -#endif END_TEST; } \ No newline at end of file