[dali_2.3.19] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-SyncImageLoader.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <dali-toolkit-test-suite-utils.h>
19 #include <dali-toolkit/dali-toolkit.h>
20 #include <dali/dali.h>
21 #include <stdlib.h>
22 #include <unistd.h>
23
24 using namespace Dali;
25 using namespace Dali::Toolkit;
26
27 namespace
28 {
29 // Resolution: 50*50, pixel format: RGBA8888
30 static const char* gImage_50_RGBA = TEST_RESOURCE_DIR "/icon-delete.png";
31
32 // Resolution: 128*128, pixel format: RGB888
33 static const char* gImage_128_RGB = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
34
35 void VerifyLoad(PixelData pixelData, uint32_t width, uint32_t height)
36 {
37   DALI_TEST_CHECK(pixelData);
38   DALI_TEST_EQUALS<unsigned int>(pixelData.GetWidth(), width, TEST_LOCATION);
39   DALI_TEST_EQUALS<unsigned int>(pixelData.GetHeight(), height, TEST_LOCATION);
40 }
41
42 } // anonymous namespace
43
44 int UtcDaliSyncImageLoaderLoad(void)
45 {
46   PixelData pixelData = Toolkit::SyncImageLoader::Load(gImage_50_RGBA);
47
48   DALI_TEST_CHECK(pixelData);
49
50   END_TEST;
51 }
52
53 int UtcDaliSyncImageLoaderLoadWithDimensions(void)
54 {
55   PixelData pixelData = Toolkit::SyncImageLoader::Load(gImage_50_RGBA, ImageDimensions(25, 25));
56
57   VerifyLoad(pixelData, 25u, 25u);
58
59   END_TEST;
60 }
61
62 int UtcDaliSyncImageLoaderLoadWithAllOptions(void)
63 {
64   PixelData pixelData = Toolkit::SyncImageLoader::Load(gImage_128_RGB, ImageDimensions(100, 100), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, true);
65
66   VerifyLoad(pixelData, 100u, 100u);
67
68   END_TEST;
69 }