• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "gtest/gtest.h"
17 
18 #include "drawing_bitmap.h"
19 #include "drawing_brush.h"
20 #include "drawing_canvas.h"
21 #include "drawing_color.h"
22 #include "drawing_color_filter.h"
23 #include "drawing_color_space.h"
24 #include "drawing_error_code.h"
25 #include "drawing_filter.h"
26 #include "drawing_font.h"
27 #include "drawing_image.h"
28 #include "drawing_mask_filter.h"
29 #include "drawing_matrix.h"
30 #include "drawing_path.h"
31 #include "drawing_pen.h"
32 #include "drawing_point.h"
33 #include "drawing_rect.h"
34 #include "drawing_region.h"
35 #include "drawing_round_rect.h"
36 #include "drawing_sampling_options.h"
37 #include "drawing_shader_effect.h"
38 #include "drawing_text_blob.h"
39 #include "drawing_typeface.h"
40 
41 using namespace testing;
42 using namespace testing::ext;
43 
44 namespace OHOS {
45 namespace Rosen {
46 namespace Drawing {
47 class DrawingNativeColorSpaceTest : public testing::Test {
48     protected:
49     // 在每个测试用例执行前调用
SetUp()50     void SetUp() override
51     {
52         // 设置代码
53         std::cout << "DrawingNativeColorSpaceTest Setup code called before each test case." << std::endl;
54         OH_Drawing_ErrorCodeReset();
55         std::cout << "DrawingNativeColorSpaceTest errorCodeReset before each test case." << std::endl;
56     }
TearDown()57     void TearDown() override
58     {
59         std::cout << "DrawingNativeColorSpaceTest Setup code called after each test case." << std::endl;
60         OH_Drawing_ErrorCodeReset();
61         std::cout << "DrawingNativeColorSpaceTest errorCodeReset after each test case." << std::endl;
62     }
63 };
64 
65 /*
66  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_COLOR_SPACE_0100
67  * @tc.name: testColorSpaceCreateSrgbNormal
68  * @tc.desc: Test for creating an sRGB color space with normal parameters.
69  * @tc.size  : SmallTest
70  * @tc.type  : Function
71  * @tc.level : Level 0
72  */
73 HWTEST_F(DrawingNativeColorSpaceTest, testColorSpaceCreateSrgbNormal, Function | SmallTest | Level0) {
74     OH_Drawing_ColorSpace *colorSpace = OH_Drawing_ColorSpaceCreateSrgb();
75     EXPECT_NE(colorSpace, nullptr);
76     OH_Drawing_ColorSpaceDestroy(colorSpace);
77 }
78 
79 /*
80  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_COLOR_SPACE_0101
81  * @tc.name: testColorSpaceDestroyNull
82  * @tc.desc: Test for destroying a color space with a NULL parameter.
83  * @tc.size  : SmallTest
84  * @tc.type  : Function
85  * @tc.level : Level 3
86  */
87 HWTEST_F(DrawingNativeColorSpaceTest, testColorSpaceDestroyNull, Function | SmallTest | Level3) {
88     OH_Drawing_ColorSpaceDestroy(nullptr);
89     // add assert
90     EXPECT_TRUE(true);
91 }
92 
93 /*
94  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_COLOR_SPACE_0102
95  * @tc.name: testColorSpaceCreateSrgbMultipleCalls
96  * @tc.desc: Test for creating an sRGB color space with multiple calls.
97  * @tc.size  : SmallTest
98  * @tc.type  : Function
99  * @tc.level : Level 3
100  */
101 HWTEST_F(DrawingNativeColorSpaceTest, testColorSpaceCreateSrgbMultipleCalls, Function | SmallTest | Level3) {
102     for (int i = 0; i < 10; i++) {
103         OH_Drawing_ColorSpace *colorSpace = OH_Drawing_ColorSpaceCreateSrgb();
104         EXPECT_NE(colorSpace, nullptr);
105         OH_Drawing_ColorSpaceDestroy(colorSpace);
106     }
107 }
108 
109 /*
110  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_COLOR_SPACE_0200
111  * @tc.name: testColorSpaceCreateSrgbLinearNormal
112  * @tc.desc: Test for creating an sRGB linear color space with normal parameters.
113  * @tc.size  : SmallTest
114  * @tc.type  : Function
115  * @tc.level : Level 0
116  */
117 HWTEST_F(DrawingNativeColorSpaceTest, testColorSpaceCreateSrgbLinearNormal, Function | SmallTest | Level0) {
118     OH_Drawing_ColorSpace *colorSpace = OH_Drawing_ColorSpaceCreateSrgbLinear();
119     EXPECT_NE(colorSpace, nullptr);
120     OH_Drawing_ColorSpaceDestroy(colorSpace);
121 }
122 
123 /*
124  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_COLOR_SPACE_0201
125  * @tc.name: testColorSpaceCreateSrgbLinearMultipleCalls
126  * @tc.desc: Test for creating an sRGB linear color space with multiple calls.
127  * @tc.size  : SmallTest
128  * @tc.type  : Function
129  * @tc.level : Level 3
130  */
131 HWTEST_F(DrawingNativeColorSpaceTest, testColorSpaceCreateSrgbLinearMultipleCalls, Function | SmallTest | Level3) {
132     for (int i = 0; i < 10; i++) {
133         OH_Drawing_ColorSpace *colorSpace = OH_Drawing_ColorSpaceCreateSrgbLinear();
134         EXPECT_NE(colorSpace, nullptr);
135         OH_Drawing_ColorSpaceDestroy(colorSpace);
136     }
137 }
138 
139 } // namespace Drawing
140 } // namespace Rosen
141 } // namespace OHOS