• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
18 #include "drawing_pixel_map.h"
19 
20 #ifdef RS_ENABLE_VK
21 #include "platform/ohos/backend/rs_vulkan_context.h"
22 #endif
23 
24 using namespace testing;
25 using namespace testing::ext;
26 
27 namespace OHOS {
28 namespace Rosen {
29 namespace Drawing {
30 class NativeDrawingPixelMapTest : public testing::Test {
31 public:
32     static void SetUpTestCase();
33     static void TearDownTestCase();
34     void SetUp() override;
35     void TearDown() override;
36 };
37 
SetUpTestCase()38 void NativeDrawingPixelMapTest::SetUpTestCase()
39 {
40 #ifdef RS_ENABLE_VK
41     RsVulkanContext::SetRecyclable(false);
42 #endif
43 }
TearDownTestCase()44 void NativeDrawingPixelMapTest::TearDownTestCase() {}
SetUp()45 void NativeDrawingPixelMapTest::SetUp() {}
TearDown()46 void NativeDrawingPixelMapTest::TearDown() {}
47 
48 /*
49  * @tc.name: NativeDrawingPixelMapTest_PixelMapGetFromOhPixelMapNative001
50  * @tc.desc: test for gets an <b>OH_Drawing_PixelMap</b> object.
51  * @tc.type: FUNC
52  * @tc.require: AR000GTO5R
53  */
54 HWTEST_F(NativeDrawingPixelMapTest, NativeDrawingPixelMapTest_PixelMapGetFromOhPixelMapNative001, TestSize.Level1)
55 {
56     OH_PixelmapNative *native = nullptr;
57     OH_Drawing_PixelMap* pixelMap = OH_Drawing_PixelMapGetFromOhPixelMapNative(native);
58     EXPECT_EQ(pixelMap, nullptr);
59 }
60 
61 /*
62  * @tc.name: NativeDrawingPixelMapTest_PixelMapDissolve002
63  * @tc.desc: test for dissolves the relationship between <b>OH_Drawing_PixelMap</b> object and <b>NativePixelMap_</b>
64  * or <b>OH_PixelmapNative</b> which is build by 'GetFrom' function.
65  * @tc.type: FUNC
66  * @tc.require: AR000GTO5R
67  */
68 HWTEST_F(NativeDrawingPixelMapTest, NativeDrawingPixelMapTest_PixelMapDissolve002, TestSize.Level1)
69 {
70     OH_PixelmapNative *native = nullptr;
71     OH_Drawing_PixelMap* pixelMap = OH_Drawing_PixelMapGetFromOhPixelMapNative(native);
72     OH_Drawing_PixelMapDissolve(pixelMap);
73     EXPECT_EQ(pixelMap, nullptr);
74 }
75 } // namespace Drawing
76 } // namespace Rosen
77 } // namespace OHOS