• 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 
49 /*
50  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_COLOR_SPACE_0100
51  * @tc.name: testColorSpaceCreateSrgbNormal
52  * @tc.desc: Test for creating an sRGB color space with normal parameters.
53  * @tc.size  : SmallTest
54  * @tc.type  : Function
55  * @tc.level : Level 0
56  */
57 HWTEST_F(DrawingNativeColorSpaceTest, testColorSpaceCreateSrgbNormal, TestSize.Level0) {
58     OH_Drawing_ColorSpace *colorSpace = OH_Drawing_ColorSpaceCreateSrgb();
59     EXPECT_NE(colorSpace, nullptr);
60     OH_Drawing_ColorSpaceDestroy(colorSpace);
61 }
62 
63 /*
64  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_COLOR_SPACE_0101
65  * @tc.name: testColorSpaceDestroyNull
66  * @tc.desc: Test for destroying a color space with a NULL parameter.
67  * @tc.size  : SmallTest
68  * @tc.type  : Function
69  * @tc.level : Level 3
70  */
71 HWTEST_F(DrawingNativeColorSpaceTest, testColorSpaceDestroyNull, TestSize.Level3) {
72     OH_Drawing_ColorSpaceDestroy(nullptr);
73 }
74 
75 /*
76  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_COLOR_SPACE_0102
77  * @tc.name: testColorSpaceCreateSrgbMultipleCalls
78  * @tc.desc: Test for creating an sRGB color space with multiple calls.
79  * @tc.size  : SmallTest
80  * @tc.type  : Function
81  * @tc.level : Level 3
82  */
83 HWTEST_F(DrawingNativeColorSpaceTest, testColorSpaceCreateSrgbMultipleCalls, TestSize.Level3) {
84     for (int i = 0; i < 10; i++) {
85         OH_Drawing_ColorSpace *colorSpace = OH_Drawing_ColorSpaceCreateSrgb();
86         EXPECT_NE(colorSpace, nullptr);
87         OH_Drawing_ColorSpaceDestroy(colorSpace);
88     }
89 }
90 
91 /*
92  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_COLOR_SPACE_0200
93  * @tc.name: testColorSpaceCreateSrgbLinearNormal
94  * @tc.desc: Test for creating an sRGB linear color space with normal parameters.
95  * @tc.size  : SmallTest
96  * @tc.type  : Function
97  * @tc.level : Level 0
98  */
99 HWTEST_F(DrawingNativeColorSpaceTest, testColorSpaceCreateSrgbLinearNormal, TestSize.Level0) {
100     OH_Drawing_ColorSpace *colorSpace = OH_Drawing_ColorSpaceCreateSrgbLinear();
101     EXPECT_NE(colorSpace, nullptr);
102     OH_Drawing_ColorSpaceDestroy(colorSpace);
103 }
104 
105 /*
106  * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_COLOR_SPACE_0201
107  * @tc.name: testColorSpaceCreateSrgbLinearMultipleCalls
108  * @tc.desc: Test for creating an sRGB linear color space with multiple calls.
109  * @tc.size  : SmallTest
110  * @tc.type  : Function
111  * @tc.level : Level 3
112  */
113 HWTEST_F(DrawingNativeColorSpaceTest, testColorSpaceCreateSrgbLinearMultipleCalls, TestSize.Level3) {
114     for (int i = 0; i < 10; i++) {
115         OH_Drawing_ColorSpace *colorSpace = OH_Drawing_ColorSpaceCreateSrgbLinear();
116         EXPECT_NE(colorSpace, nullptr);
117         OH_Drawing_ColorSpaceDestroy(colorSpace);
118     }
119 }
120 
121 } // namespace Drawing
122 } // namespace Rosen
123 } // namespace OHOS