2 * Copyright (c) 2022 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.
20 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/public-api/image-loader/image-url.h>
23 #include <dali-toolkit/public-api/image-loader/image.h>
24 #include <dali/public-api/adaptor-framework/native-image-source.h>
25 #include <dali/public-api/images/pixel-data.h>
26 #include <dali/public-api/rendering/frame-buffer.h>
27 #include <dali/public-api/rendering/texture.h>
30 using namespace Dali::Toolkit;
36 void dali_image_startup(void)
38 test_return_value = TET_UNDEF;
41 void dali_image_cleanup(void)
43 test_return_value = TET_PASS;
46 int UtcDaliImageConvertFrameBufferToUrl1(void)
48 ToolkitTestApplication application;
49 tet_infoline("UtcDaliImageConvertFrameBufferToUrl1");
51 unsigned int width(64);
52 unsigned int height(64);
53 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
55 DALI_TEST_CHECK(frameBuffer);
56 ImageUrl url = Dali::Toolkit::Image::GenerateUrl(frameBuffer, Pixel::Format::RGBA8888, width, height);
58 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);
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).GetUrl().size() > 0u);
97 int UtcDaliImageConvertNativeImageSourceToUrl(void)
99 ToolkitTestApplication application;
100 tet_infoline("UtcDaliImageConvertNativeImageSourceToUrl");
102 unsigned int width(64);
103 unsigned int height(64);
106 NativeImageSourcePtr nativeImageSource = NativeImageSource::New(width, height, NativeImageSource::COLOR_DEPTH_DEFAULT);
108 DALI_TEST_CHECK(Dali::Toolkit::Image::GenerateUrl(nativeImageSource).GetUrl().size() > 0u);
110 catch(Dali::DaliException& e)
112 DALI_TEST_PRINT_ASSERT(e);
113 DALI_TEST_ASSERT(e, "Adaptor::IsAvailable()", TEST_LOCATION);
117 tet_printf("Assertion test failed - wrong Exception\n");
118 tet_result(TET_FAIL);
124 int UtcDaliImageConvertEncodedImageBufferToUrl(void)
126 ToolkitTestApplication application;
127 tet_infoline("UtcDaliImageConvertEncodedImageBufferToUrl");
129 Dali::Vector<uint8_t> buffer;
130 buffer.PushBack(0x11);
131 buffer.PushBack(0x22);
132 buffer.PushBack(0x33);
134 DALI_TEST_CHECK(Dali::Toolkit::Image::GenerateUrl(EncodedImageBuffer::New(buffer)).GetUrl().size() > 0u);