d8579317ec4d177df0b78dacfa776235f67442de
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-adaptor-internal / utc-Dali-IcoLoader.cpp
1 /*
2  * Copyright (c) 2016 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 <iostream>
19 #include <stdlib.h>
20 #include <dali-test-suite-utils.h>
21
22 #include "platform-abstractions/tizen/image-loaders/loader-ico.h"
23 #include "image-loaders.h"
24
25 using namespace Dali;
26
27 namespace
28 {
29
30 static const LoadFunctions IcoLoaders( TizenPlatform::LoadIcoHeader, TizenPlatform::LoadBitmapFromIco );
31
32
33 // Golden master image data for each icon type:
34 // Note: The bottom right corner of each image is fully transparent.
35 // Note: The first 4 sets of data *happen* to be the same, but could be different depending on the image converted.
36 //       In this case as the original image contains few colors, they can easily fit inside an 8bit palette, thus
37 //       Causing no image degradation.
38
39 uint32_t ImageCheckData_Ico4x4_32bpp_8alpha[] = {
40     0xff0000ff, 0x00ff00ff, 0x0000ffff, 0xff00ffff,
41     0xc04040ff, 0x40c040ff, 0x4040c0ff, 0xffff00ff,
42     0xa06060ff, 0x60a060ff, 0x6060a0ff, 0x00ffffff,
43     0xffffffff, 0x808080ff, 0x000000ff, 0x00000000
44 };
45
46 uint32_t ImageCheckData_Ico4x4_24bpp[] = {
47     0xff0000ff, 0x00ff00ff, 0x0000ffff, 0xff00ffff,
48     0xc04040ff, 0x40c040ff, 0x4040c0ff, 0xffff00ff,
49     0xa06060ff, 0x60a060ff, 0x6060a0ff, 0x00ffffff,
50     0xffffffff, 0x808080ff, 0x000000ff, 0x00000000
51 };
52
53 uint32_t ImageCheckData_Ico4x4_8bpp[] = {
54     0xff0000ff, 0x00ff00ff, 0x0000ffff, 0xff00ffff,
55     0xc04040ff, 0x40c040ff, 0x4040c0ff, 0xffff00ff,
56     0xa06060ff, 0x60a060ff, 0x6060a0ff, 0x00ffffff,
57     0xffffffff, 0x808080ff, 0x000000ff, 0x00000000
58 };
59
60 uint32_t ImageCheckData_Ico4x4_4bpp[] = {
61     0xff0000ff, 0x00ff00ff, 0x0000ffff, 0xff00ffff,
62     0xc04040ff, 0x40c040ff, 0x4040c0ff, 0xffff00ff,
63     0xa06060ff, 0x60a060ff, 0x6060a0ff, 0x00ffffff,
64     0xffffffff, 0x808080ff, 0x000000ff, 0x00000000
65 };
66
67 uint32_t ImageCheckData_Ico4x4_1bpp[] = {
68     0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA18783ff,
69     0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA18783ff,
70     0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA18783ff,
71     0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA1878300
72 };
73
74
75 } // Unnamed namespace.
76
77
78 int UtcDaliIco32bpp8alpha(void)
79 {
80   ImageDetails image( TEST_IMAGE_DIR "/test-image-4x4-32bpp.ico", 4u, 4u );
81
82   CompareLoadedImageData( image, IcoLoaders, ImageCheckData_Ico4x4_32bpp_8alpha );
83
84   END_TEST;
85 }
86
87
88 int UtcDaliIco24bpp1alpha(void)
89 {
90   ImageDetails image( TEST_IMAGE_DIR "/test-image-4x4-24bpp.ico", 4u, 4u );
91
92   CompareLoadedImageData( image, IcoLoaders, ImageCheckData_Ico4x4_24bpp );
93
94   END_TEST;
95 }
96
97
98 int UtcDaliIco8bpp1alpha(void)
99 {
100   ImageDetails image( TEST_IMAGE_DIR "/test-image-4x4-8bpp.ico", 4u, 4u );
101
102   CompareLoadedImageData( image, IcoLoaders, ImageCheckData_Ico4x4_8bpp );
103
104   END_TEST;
105 }
106
107
108 int UtcDaliIco4bpp1alpha(void)
109 {
110   ImageDetails image( TEST_IMAGE_DIR "/test-image-4x4-4bpp.ico", 4u, 4u );
111
112   CompareLoadedImageData( image, IcoLoaders, ImageCheckData_Ico4x4_4bpp );
113
114   END_TEST;
115 }
116
117
118 int UtcDaliIco1bpp1alpha(void)
119 {
120   ImageDetails image( TEST_IMAGE_DIR "/test-image-4x4-1bpp.ico", 4u, 4u );
121
122   CompareLoadedImageData( image, IcoLoaders, ImageCheckData_Ico4x4_1bpp );
123
124   END_TEST;
125 }
126
127
128