• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "c/drawing_path.h"
19 
20 using namespace testing;
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace Rosen {
25 namespace Drawing {
26 class NativeDrawingPathTest : 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 NativeDrawingPathTest::SetUpTestCase() {}
TearDownTestCase()35 void NativeDrawingPathTest::TearDownTestCase() {}
SetUp()36 void NativeDrawingPathTest::SetUp() {}
TearDown()37 void NativeDrawingPathTest::TearDown() {}
38 
39 /*
40  * @tc.name: NativeDrawingPathTest_path001
41  * @tc.desc: test for create drawing_path.
42  * @tc.type: FUNC
43  * @tc.require: AR000GTO5R
44  */
45 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_path001, TestSize.Level1)
46 {
47     OH_Drawing_Path* path = OH_Drawing_PathCreate();
48     EXPECT_EQ(path == nullptr, false);
49     OH_Drawing_PathDestroy(path);
50 }
51 
52 /*
53  * @tc.name: NativeDrawingPathTest_path002
54  * @tc.desc: test for PathMoveTo func.
55  * @tc.type: FUNC
56  * @tc.require: AR000GTO5R
57  */
58 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_path002, TestSize.Level1)
59 {
60     OH_Drawing_Path* path1 = OH_Drawing_PathCreate();
61     OH_Drawing_PathMoveTo(path1, 20, 20);
62     OH_Drawing_PathMoveTo(path1, -1, 20.6f);
63     OH_Drawing_PathDestroy(path1);
64 }
65 
66 /*
67  * @tc.name: NativeDrawingPathTest_path004
68  * @tc.desc: test for PathLineTo func.
69  * @tc.type: FUNC
70  * @tc.require: AR000GTO5R
71  */
72 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_path003, TestSize.Level1)
73 {
74     OH_Drawing_Path* path2 = OH_Drawing_PathCreate();
75     OH_Drawing_PathLineTo(path2, 50, 40);
76     OH_Drawing_PathLineTo(path2, -50, 10.2f);
77     OH_Drawing_PathDestroy(path2);
78 }
79 
80 /*
81  * @tc.name: NativeDrawingPathTest_path005
82  * @tc.desc: test for PathReset func.
83  * @tc.type: FUNC
84  * @tc.require: AR000GTO5R
85  */
86 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_path004, TestSize.Level1)
87 {
88     OH_Drawing_Path* path3 = OH_Drawing_PathCreate();
89     OH_Drawing_PathMoveTo(path3, 20, 20);
90     OH_Drawing_PathReset(path3);
91     OH_Drawing_PathDestroy(path3);
92 }
93 
94 /*
95  * @tc.name: NativeDrawingPathTest_path006
96  * @tc.desc: test for PathArcTo func.
97  * @tc.type: FUNC
98  * @tc.require: AR000GTO5R
99  */
100 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_path005, TestSize.Level1)
101 {
102     OH_Drawing_Path* path4 = OH_Drawing_PathCreate();
103     OH_Drawing_PathArcTo(path4, 10, 10, 20, 0, 0, 90);
104     OH_Drawing_PathArcTo(path4, -10, 10, 10, -10, 0, 90);
105     OH_Drawing_PathDestroy(path4);
106 }
107 
108 /*
109  * @tc.name: NativeDrawingPathTest_path007
110  * @tc.desc: test for PathQuadTo func.
111  * @tc.type: FUNC
112  * @tc.require: AR000GTO5R
113  */
114 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_path006, TestSize.Level1)
115 {
116     OH_Drawing_Path* path5 = OH_Drawing_PathCreate();
117     OH_Drawing_PathQuadTo(path5, 0, 0, 30, 30);
118     OH_Drawing_PathQuadTo(path5, -20.5f, -20.5f, 30, 0);
119     OH_Drawing_PathDestroy(path5);
120 }
121 
122 /*
123  * @tc.name: NativeDrawingPathTest_path008
124  * @tc.desc: test for PathCubicTo func.
125  * @tc.type: FUNC
126  * @tc.require: AR000GTO5R
127  */
128 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_path007, TestSize.Level1)
129 {
130     OH_Drawing_Path* path6 = OH_Drawing_PathCreate();
131     OH_Drawing_PathCubicTo(path6, 30, 40, 60, 0, 50, 20);
132     OH_Drawing_PathCubicTo(path6, -30, 40, 60, -30.6f, 50, -20);
133     OH_Drawing_PathDestroy(path6);
134 }
135 
136 /*
137  * @tc.name: NativeDrawingPathTest_path009
138  * @tc.desc: test for PathClose func.
139  * @tc.type: FUNC
140  * @tc.require: AR000GTO5R
141  */
142 HWTEST_F(NativeDrawingPathTest, NativeDrawingPathTest_path009, TestSize.Level1)
143 {
144     OH_Drawing_Path* path7 = OH_Drawing_PathCreate();
145     OH_Drawing_PathLineTo(path7, 50, 40);
146     OH_Drawing_PathClose(path7);
147     OH_Drawing_PathDestroy(path7);
148 }
149 } // namespace Drawing
150 } // namespace Rosen
151 } // namespace OHOS