2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit-test-suite-utils.h>
20 #include <dali/public-api/rendering/texture.h>
21 #include <dali/public-api/images/pixel-data.h>
22 #include <dali/public-api/rendering/frame-buffer.h>
23 #include <dali/public-api/adaptor-framework/native-image-source.h>
24 #include <dali-toolkit/public-api/image-loader/image.h>
25 #include <dali-toolkit/public-api/image-loader/image-url.h>
28 using namespace Dali::Toolkit;
35 void dali_image_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_image_cleanup(void)
42 test_return_value = TET_PASS;
45 int UtcDaliImageConvertFrameBufferToUrl1(void)
47 ToolkitTestApplication application;
48 tet_infoline( "UtcDaliImageConvertFrameBufferToUrl1" );
50 unsigned int width(64);
51 unsigned int height(64);
52 FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::NONE );
54 DALI_TEST_CHECK( frameBuffer );
55 ImageUrl url = Dali::Toolkit::Image::GenerateUrl( frameBuffer, Pixel::Format::RGBA8888, width, height );
57 DALI_TEST_CHECK( url.GetUrl().size() > 0u );
63 int UtcDaliImageConvertFrameBufferToUrl2(void)
65 ToolkitTestApplication application;
66 tet_infoline( "UtcDaliImageConvertFrameBufferToUrl2" );
68 unsigned int width(64);
69 unsigned int height(64);
70 FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::NONE );
72 Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
73 frameBuffer.AttachColorTexture( texture );
75 DALI_TEST_CHECK( Dali::Toolkit::Image::GenerateUrl( frameBuffer, 0 ).GetUrl().size() > 0u );
81 int UtcDaliImageConvertPixelDataToUrl(void)
83 ToolkitTestApplication application;
84 tet_infoline( "UtcDaliImageConvertPixelDataToUrl" );
86 unsigned int width(64);
87 unsigned int height(64);
88 unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( Pixel::RGB888 );
90 unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
91 PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, Pixel::RGB888, PixelData::FREE );
93 DALI_TEST_CHECK( Dali::Toolkit::Image::GenerateUrl( pixelData ).GetUrl().size() > 0u );
99 int UtcDaliImageConvertNativeImageSourceToUrl(void)
101 ToolkitTestApplication application;
102 tet_infoline( "UtcDaliImageConvertNativeImageSourceToUrl" );
104 unsigned int width(64);
105 unsigned int height(64);
108 NativeImageSourcePtr nativeImageSource = NativeImageSource::New(width, height, NativeImageSource::COLOR_DEPTH_DEFAULT );
110 DALI_TEST_CHECK( Dali::Toolkit::Image::GenerateUrl( nativeImageSource ).GetUrl().size() > 0u );
112 catch(Dali::DaliException& e)
114 DALI_TEST_PRINT_ASSERT( e );
115 DALI_TEST_ASSERT(e, "Adaptor::IsAvailable()", TEST_LOCATION);
119 tet_printf("Assertion test failed - wrong Exception\n" );
120 tet_result(TET_FAIL);
126 int UtcDaliImageConvertEncodedImageBufferToUrl(void)
128 ToolkitTestApplication application;
129 tet_infoline( "UtcDaliImageConvertEncodedImageBufferToUrl" );
131 Dali::Vector<uint8_t> buffer;
132 buffer.PushBack(0x11);
133 buffer.PushBack(0x22);
134 buffer.PushBack(0x33);
136 DALI_TEST_CHECK( Dali::Toolkit::Image::GenerateUrl( EncodedImageBuffer::New(buffer) ).GetUrl().size() > 0u );