• 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, 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 <cstddef>
17 #include "gtest/gtest.h"
18 #include "skia_adapter/skia_data.h"
19 
20 using namespace testing;
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace Rosen {
25 namespace Drawing {
26 class SkiaDataTest : public testing::Test {
27 public:
28     static void SetUpTestCase();
29     static void TearDownTestCase();
30     void SetUp() override;
31     void TearDown() override;
32 };
33 
SetUpTestCase()34 void SkiaDataTest::SetUpTestCase() {}
TearDownTestCase()35 void SkiaDataTest::TearDownTestCase() {}
SetUp()36 void SkiaDataTest::SetUp() {}
TearDown()37 void SkiaDataTest::TearDown() {}
38 
39 /**
40  * @tc.name: SkiaData001
41  * @tc.desc: Test functions for SkiaData
42  * @tc.type: FUNC
43  * @tc.require: I91F9L
44  */
45 HWTEST_F(SkiaDataTest, SkiaData001, TestSize.Level1)
46 {
47     SkiaData skiaData;
48     ASSERT_TRUE(skiaData.WritableData() == nullptr);
49     ASSERT_TRUE(skiaData.GetSize() >= 0);
50     ASSERT_TRUE(skiaData.GetData() == nullptr);
51     ASSERT_TRUE(skiaData.GetSkData() == nullptr);
52 }
53 
54 /**
55  * @tc.name: BuildFromMalloc001
56  * @tc.desc: Test BuildFromMalloc
57  * @tc.type: FUNC
58  * @tc.require: I91F9L
59  */
60 HWTEST_F(SkiaDataTest, BuildFromMalloc001, TestSize.Level1)
61 {
62     SkiaData skiaData;
63     auto intData = new int();
64     EXPECT_TRUE(skiaData.BuildFromMalloc(intData, sizeof(intData)));
65 }
66 
67 /**
68  * @tc.name: BuildWithCopy001
69  * @tc.desc: Test BuildWithCopy
70  * @tc.type: FUNC
71  * @tc.require: I91F9L
72  */
73 HWTEST_F(SkiaDataTest, BuildWithCopy001, TestSize.Level1)
74 {
75     SkiaData skiaData;
76     auto intData = std::make_unique<int>();
77     EXPECT_TRUE(skiaData.BuildWithCopy(intData.get(), sizeof(*intData.get())));
78 }
79 
80 /**
81  * @tc.name: BuildWithoutCopy001
82  * @tc.desc: Test BuildWithoutCopy
83  * @tc.type: FUNC
84  * @tc.require: I91F9L
85  */
86 HWTEST_F(SkiaDataTest, BuildWithoutCopy001, TestSize.Level1)
87 {
88     SkiaData skiaData;
89     auto intData = std::make_unique<int>();
90     EXPECT_TRUE(skiaData.BuildWithoutCopy(intData.get(), sizeof(*intData.get())));
91 }
92 
93 /**
94  * @tc.name: BuildUninitialized001
95  * @tc.desc: Test BuildUninitialized
96  * @tc.type: FUNC
97  * @tc.require: I91F9L
98  */
99 HWTEST_F(SkiaDataTest, BuildUninitialized001, TestSize.Level1)
100 {
101     SkiaData skiaData;
102     auto intData = std::make_unique<int>();
103     EXPECT_TRUE(skiaData.BuildUninitialized(sizeof(*intData.get())));
104 }
105 
106 /**
107  * @tc.name: BuildEmpty001
108  * @tc.desc: Test BuildEmpty
109  * @tc.type: FUNC
110  * @tc.require: I91F9L
111  */
112 HWTEST_F(SkiaDataTest, BuildEmpty001, TestSize.Level1)
113 {
114     SkiaData skiaData;
115     EXPECT_TRUE(skiaData.BuildEmpty());
116 }
117 } // namespace Drawing
118 } // namespace Rosen
119 } // namespace OHOS