X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-Image.cpp;h=dd211945086ce2fbc7158cc2a4a32ea9927142bf;hb=9931aa907c307c6cf79923e4b52462996c475dfa;hp=37e3b5e0302d7ecd6918c78b291707b8507f8e71;hpb=543143c6669520f97120a4d7308c5a18648886e6;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Image.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Image.cpp index 37e3b5e..dd21194 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Image.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Image.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,15 +14,18 @@ * limitations under the License. */ -#include #include +#include + #include -#include + +#include +#include +#include +#include #include #include -#include -#include -#include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -31,7 +34,6 @@ namespace { } // namespace - void dali_image_startup(void) { test_return_value = TET_UNDEF; @@ -45,80 +47,207 @@ void dali_image_cleanup(void) int UtcDaliImageConvertFrameBufferToUrl1(void) { ToolkitTestApplication application; - tet_infoline( "UtcDaliImageConvertFrameBufferToUrl1" ); + tet_infoline("UtcDaliImageConvertFrameBufferToUrl1"); unsigned int width(64); unsigned int height(64); - FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::NONE ); + FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE); - DALI_TEST_CHECK( frameBuffer ); - ImageUrl url = Dali::Toolkit::Image::GenerateUrl( frameBuffer, Pixel::Format::RGBA8888, width, height ); + DALI_TEST_CHECK(frameBuffer); + ImageUrl url = Dali::Toolkit::Image::GenerateUrl(frameBuffer, Pixel::Format::RGBA8888, width, height); - DALI_TEST_CHECK( url.GetUrl().size() > 0u ); + DALI_TEST_CHECK(url.GetUrl().size() > 0u); END_TEST; } - int UtcDaliImageConvertFrameBufferToUrl2(void) { ToolkitTestApplication application; - tet_infoline( "UtcDaliImageConvertFrameBufferToUrl2" ); + tet_infoline("UtcDaliImageConvertFrameBufferToUrl2"); unsigned int width(64); unsigned int height(64); - FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::NONE ); + FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE); - Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height ); - frameBuffer.AttachColorTexture( texture ); + Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height); + frameBuffer.AttachColorTexture(texture); - DALI_TEST_CHECK( Dali::Toolkit::Image::GenerateUrl( frameBuffer, 0 ).GetUrl().size() > 0u ); + DALI_TEST_CHECK(Dali::Toolkit::Image::GenerateUrl(frameBuffer, 0).GetUrl().size() > 0u); END_TEST; } +int UtcDaliImageConvertDepthTextureFrameBufferToUrl(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliImageConvertDepthTextureFrameBufferToUrl"); + + unsigned int width(64); + unsigned int height(64); + FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE); + + Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::DEPTH_UNSIGNED_INT, width, height); + DevelFrameBuffer::AttachDepthTexture(frameBuffer, texture); + + DALI_TEST_CHECK(Dali::Toolkit::Image::GenerateDepthUrl(frameBuffer).GetUrl().size() > 0u); -int UtcDaliImageConvertPixelDataToUrl(void) + END_TEST; +} + +int UtcDaliImageConvertPixelDataToUrl01(void) { ToolkitTestApplication application; - tet_infoline( "UtcDaliImageConvertPixelDataToUrl" ); + tet_infoline("UtcDaliImageConvertPixelDataToUrl01"); unsigned int width(64); unsigned int height(64); - unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( Pixel::RGB888 ); + unsigned int bufferSize = width * height * Pixel::GetBytesPerPixel(Pixel::RGB888); - unsigned char* buffer= reinterpret_cast( malloc( bufferSize ) ); - PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, Pixel::RGB888, PixelData::FREE ); + unsigned char* buffer = reinterpret_cast(malloc(bufferSize)); + PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGB888, PixelData::FREE); - DALI_TEST_CHECK( Dali::Toolkit::Image::GenerateUrl( pixelData ).GetUrl().size() > 0u ); + DALI_TEST_CHECK(Dali::Toolkit::Image::GenerateUrl(pixelData).GetUrl().size() > 0u); END_TEST; } +int UtcDaliImageConvertPixelDataToUrl02(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliImageConvertPixelDataToUrl02"); -int UtcDaliImageConvertNativeImageSourceToUrl(void) + unsigned int width(64); + unsigned int height(64); + unsigned int bufferSize = width * height * Pixel::GetBytesPerPixel(Pixel::RGBA8888); + + unsigned char* buffer = reinterpret_cast(malloc(bufferSize)); + PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE); + + DALI_TEST_CHECK(Dali::Toolkit::Image::GenerateUrl(pixelData, true).GetUrl().size() > 0u); + + END_TEST; +} + +int UtcDaliImageConvertNativeImageSourceToUrl01(void) { ToolkitTestApplication application; - tet_infoline( "UtcDaliImageConvertNativeImageSourceToUrl" ); + tet_infoline("UtcDaliImageConvertNativeImageSourceToUrl01"); unsigned int width(64); unsigned int height(64); try { - NativeImageSourcePtr nativeImageSource = NativeImageSource::New(width, height, NativeImageSource::COLOR_DEPTH_DEFAULT ); + NativeImageSourcePtr nativeImageSource = NativeImageSource::New(width, height, NativeImageSource::COLOR_DEPTH_DEFAULT); - DALI_TEST_CHECK( Dali::Toolkit::Image::GenerateUrl( nativeImageSource ).GetUrl().size() > 0u ); + DALI_TEST_CHECK(Dali::Toolkit::Image::GenerateUrl(nativeImageSource).GetUrl().size() > 0u); } catch(Dali::DaliException& e) { - DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_PRINT_ASSERT(e); DALI_TEST_ASSERT(e, "Adaptor::IsAvailable()", TEST_LOCATION); } catch(...) { - tet_printf("Assertion test failed - wrong Exception\n" ); + tet_printf("Assertion test failed - wrong Exception\n"); tet_result(TET_FAIL); } END_TEST; } + +int UtcDaliImageConvertNativeImageSourceToUrl02(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliImageConvertNativeImageSourceToUrl02"); + + unsigned int width(64); + unsigned int height(64); + try + { + NativeImageSourcePtr nativeImageSource = NativeImageSource::New(width, height, NativeImageSource::COLOR_DEPTH_DEFAULT); + + DALI_TEST_CHECK(Dali::Toolkit::Image::GenerateUrl(nativeImageSource, true).GetUrl().size() > 0u); + } + catch(Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT(e); + DALI_TEST_ASSERT(e, "Adaptor::IsAvailable()", TEST_LOCATION); + } + catch(...) + { + tet_printf("Assertion test failed - wrong Exception\n"); + tet_result(TET_FAIL); + } + + END_TEST; +} + +int UtcDaliImageConvertNativeImageInterfaceToUrl01(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliImageConvertNativeImageInterfaceToUrl01"); + + unsigned int width(64); + unsigned int height(64); + try + { + NativeImageSourceQueuePtr nativeImageQueue = NativeImageSourceQueue::New(width, height, (Dali::NativeImageSourceQueue::ColorFormat::BGR888)); + + DALI_TEST_CHECK(Dali::Toolkit::Image::GenerateUrl(nativeImageQueue).GetUrl().size() > 0u); + } + catch(Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT(e); + DALI_TEST_ASSERT(e, "Adaptor::IsAvailable()", TEST_LOCATION); + } + catch(...) + { + tet_printf("Assertion test failed - wrong Exception\n"); + tet_result(TET_FAIL); + } + + END_TEST; +} + +int UtcDaliImageConvertNativeImageInterfaceToUrl02(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliImageConvertNativeImageInterfaceToUrl02"); + + unsigned int width(64); + unsigned int height(64); + try + { + NativeImageSourceQueuePtr nativeImageQueue = NativeImageSourceQueue::New(width, height, (Dali::NativeImageSourceQueue::ColorFormat::BGR888)); + + DALI_TEST_CHECK(Dali::Toolkit::Image::GenerateUrl(nativeImageQueue, true).GetUrl().size() > 0u); + } + catch(Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT(e); + DALI_TEST_ASSERT(e, "Adaptor::IsAvailable()", TEST_LOCATION); + } + catch(...) + { + tet_printf("Assertion test failed - wrong Exception\n"); + tet_result(TET_FAIL); + } + + END_TEST; +} + +int UtcDaliImageConvertEncodedImageBufferToUrl(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliImageConvertEncodedImageBufferToUrl"); + + Dali::Vector buffer; + buffer.PushBack(0x11); + buffer.PushBack(0x22); + buffer.PushBack(0x33); + + DALI_TEST_CHECK(Dali::Toolkit::Image::GenerateUrl(EncodedImageBuffer::New(buffer)).GetUrl().size() > 0u); + + END_TEST; +}