1 /*
2 * Copyright (c) 2024 Huawei Device 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, Hardware
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 #include "drawing_color_space.h"
18
19 #ifdef RS_ENABLE_VK
20 #include "platform/ohos/backend/rs_vulkan_context.h"
21 #endif
22
23 using namespace testing;
24 using namespace testing::ext;
25
26 namespace OHOS {
27 namespace Rosen {
28 namespace Drawing {
29 class NativeDrawingColorSpaceTest : public testing::Test {
30 public:
31 static void SetUpTestCase();
32 static void TearDownTestCase();
33 void SetUp() override;
34 void TearDown() override;
35 };
36
SetUpTestCase()37 void NativeDrawingColorSpaceTest::SetUpTestCase()
38 {
39 #ifdef RS_ENABLE_VK
40 RsVulkanContext::SetRecyclable(false);
41 #endif
42 }
TearDownTestCase()43 void NativeDrawingColorSpaceTest::TearDownTestCase() {}
SetUp()44 void NativeDrawingColorSpaceTest::SetUp() {}
TearDown()45 void NativeDrawingColorSpaceTest::TearDown() {}
46
47 /*
48 * @tc.name: NativeDrawingColorSpaceTest_ColorSpace001
49 * @tc.desc: test for ColorSpace.
50 * @tc.type: FUNC
51 * @tc.require: AR000GTO5R
52 */
53 HWTEST_F(NativeDrawingColorSpaceTest, NativeDrawingColorSpaceTest_ColorSpace001, TestSize.Level1)
54 {
55 OH_Drawing_ColorSpace* colorSpace = OH_Drawing_ColorSpaceCreateSrgb();
56 EXPECT_NE(colorSpace, nullptr);
57 OH_Drawing_ColorSpaceDestroy(colorSpace);
58 }
59
60 /*
61 * @tc.name: NativeDrawingColorSpaceTest_ColorSpace002
62 * @tc.desc: test for ColorSpace.
63 * @tc.type: FUNC
64 * @tc.require: AR000GTO5R
65 */
66 HWTEST_F(NativeDrawingColorSpaceTest, NativeDrawingColorSpaceTest_ColorSpace002, TestSize.Level1)
67 {
68 OH_Drawing_ColorSpace* colorSpace = OH_Drawing_ColorSpaceCreateSrgbLinear();
69 EXPECT_NE(colorSpace, nullptr);
70 OH_Drawing_ColorSpaceDestroy(colorSpace);
71 colorSpace = nullptr;
72 OH_Drawing_ColorSpaceDestroy(colorSpace);
73 EXPECT_EQ(colorSpace, nullptr);
74 }
75 } // namespace Drawing
76 } // namespace Rosen
77 } // namespace OHOS