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>
27 using namespace Dali::Toolkit;
34 void dali_image_startup(void)
36 test_return_value = TET_UNDEF;
39 void dali_image_cleanup(void)
41 test_return_value = TET_PASS;
44 int UtcDaliImageConvertFrameBufferToUrl1(void)
46 ToolkitTestApplication application;
47 tet_infoline( "UtcDaliImageConvertFrameBufferToUrl1" );
49 unsigned int width(64);
50 unsigned int height(64);
51 FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::NONE );
53 DALI_TEST_CHECK( frameBuffer );
54 std::string url = Dali::Toolkit::Image::GenerateUrl( frameBuffer, Pixel::Format::RGBA8888, width, height );
56 DALI_TEST_CHECK( url.size() > 0u );
62 int UtcDaliImageConvertFrameBufferToUrl2(void)
64 ToolkitTestApplication application;
65 tet_infoline( "UtcDaliImageConvertFrameBufferToUrl2" );
67 unsigned int width(64);
68 unsigned int height(64);
69 FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::NONE );
71 Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
72 frameBuffer.AttachColorTexture( texture );
74 DALI_TEST_CHECK( Dali::Toolkit::Image::GenerateUrl( frameBuffer, 0 ).size() > 0u );
80 int UtcDaliImageConvertPixelDataToUrl(void)
82 ToolkitTestApplication application;
83 tet_infoline( "UtcDaliImageConvertPixelDataToUrl" );
85 unsigned int width(64);
86 unsigned int height(64);
87 unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( Pixel::RGB888 );
89 unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
90 PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, Pixel::RGB888, PixelData::FREE );
92 DALI_TEST_CHECK( Dali::Toolkit::Image::GenerateUrl( pixelData ).size() > 0u );
98 int UtcDaliImageConvertNativeImageSourceToUrl(void)
100 ToolkitTestApplication application;
101 tet_infoline( "UtcDaliImageConvertNativeImageSourceToUrl" );
103 unsigned int width(64);
104 unsigned int height(64);
107 NativeImageSourcePtr nativeImageSource = NativeImageSource::New(width, height, NativeImageSource::COLOR_DEPTH_DEFAULT );
109 DALI_TEST_CHECK( Dali::Toolkit::Image::GenerateUrl( nativeImageSource ).size() > 0u );
111 catch(Dali::DaliException& e)
113 DALI_TEST_PRINT_ASSERT( e );
114 DALI_TEST_ASSERT(e, "Adaptor::IsAvailable()", TEST_LOCATION);
118 tet_printf("Assertion test failed - wrong Exception\n" );
119 tet_result(TET_FAIL);