• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 <gtest/gtest.h>
17 #include "print_margin.h"
18 #include "printer_capability.h"
19 
20 using namespace testing::ext;
21 
22 namespace OHOS {
23 namespace Print {
24 class PrintMarginTest : public testing::Test {
25 public:
26     static void SetUpTestCase(void);
27     static void TearDownTestCase(void);
28     void SetUp();
29     void TearDown();
30 };
31 
SetUpTestCase(void)32 void PrintMarginTest::SetUpTestCase(void) {}
33 
TearDownTestCase(void)34 void PrintMarginTest::TearDownTestCase(void) {}
35 
SetUp(void)36 void PrintMarginTest::SetUp(void) {}
37 
TearDown(void)38 void PrintMarginTest::TearDown(void) {}
39 
40 /**
41  * @tc.name: PrintMarginTest_002
42  * @tc.desc: Verify the getBottom function.
43  * @tc.type: FUNC
44  * @tc.require:
45  */
46 HWTEST_F(PrintMarginTest, PrintMarginTest_002, TestSize.Level1)
47 {
48     OHOS::Print::PrintMargin margin;
49     OHOS::Print::PrintMargin right;
50     margin.Set(right);
51     EXPECT_EQ((uint32_t)0, margin.GetBottom());
52 }
53 
54 /**
55  * @tc.name: PrintMarginTest_003
56  * @tc.desc: Verify the reset function.
57  * @tc.type: FUNC
58  * @tc.require:
59  */
60 HWTEST_F(PrintMarginTest, PrintMarginTest_003, TestSize.Level1)
61 {
62     OHOS::Print::PrintMargin margin;
63     margin.Reset();
64     EXPECT_EQ((uint32_t)0, margin.GetBottom());
65 }
66 
67 /**
68  * @tc.name: PrintMarginTest_004
69  * @tc.desc: Verify the hasTop function.
70  * @tc.type: FUNC
71  * @tc.require:
72  */
73 HWTEST_F(PrintMarginTest, PrintMarginTest_004, TestSize.Level1)
74 {
75     OHOS::Print::PrintMargin margin;
76     margin.SetTop(6);
77     EXPECT_TRUE(margin.HasTop());
78 }
79 
80 /**
81  * @tc.name: PrintMarginTest_005
82  * @tc.desc: Verify the getTop function.
83  * @tc.type: FUNC
84  * @tc.require:
85  */
86 HWTEST_F(PrintMarginTest, PrintMarginTest_005, TestSize.Level1)
87 {
88     OHOS::Print::PrintMargin margin;
89     margin.SetTop(6);
90     EXPECT_EQ((uint32_t)6, margin.GetTop());
91 }
92 
93 /**
94  * @tc.name: PrintMarginTest_006
95  * @tc.desc: Verify the hasBottom function.
96  * @tc.type: FUNC
97  * @tc.require:
98  */
99 HWTEST_F(PrintMarginTest, PrintMarginTest_006, TestSize.Level1)
100 {
101     OHOS::Print::PrintMargin margin;
102     margin.SetBottom(6);
103     EXPECT_TRUE(margin.HasBottom());
104 }
105 
106 /**
107  * @tc.name: PrintMarginTest_007
108  * @tc.desc: Verify the getBottom function.
109  * @tc.type: FUNC
110  * @tc.require:
111  */
112 HWTEST_F(PrintMarginTest, PrintMarginTest_007, TestSize.Level1)
113 {
114     OHOS::Print::PrintMargin margin;
115     margin.SetBottom(6);
116     EXPECT_EQ((uint32_t)6, margin.GetBottom());
117 }
118 
119 /**
120  * @tc.name: PrintMarginTest_008
121  * @tc.desc: Verify the Reset function.
122  * @tc.type: FUNC
123  * @tc.require:
124  */
125 HWTEST_F(PrintMarginTest, PrintMarginTest_008, TestSize.Level1)
126 {
127     OHOS::Print::PrintMargin margin;
128     margin.SetLeft(6);
129     EXPECT_TRUE(margin.HasLeft());
130 }
131 
132 /**
133  * @tc.name: PrintMarginTest_009
134  * @tc.desc: Verify the Reset function.
135  * @tc.type: FUNC
136  * @tc.require:
137  */
138 HWTEST_F(PrintMarginTest, PrintMarginTest_009, TestSize.Level1)
139 {
140     OHOS::Print::PrintMargin margin;
141     margin.SetLeft(6);
142     EXPECT_EQ((uint32_t)6, margin.GetLeft());
143 }
144 
145 /**
146  * @tc.name: PrintMarginTest_0010
147  * @tc.desc: Verify the hasRight function.
148  * @tc.type: FUNC
149  * @tc.require:
150  */
151 HWTEST_F(PrintMarginTest, PrintMarginTest_0010, TestSize.Level1)
152 {
153     OHOS::Print::PrintMargin margin;
154     margin.SetRight(6);
155     EXPECT_TRUE(margin.HasRight());
156 }
157 
158 /**
159  * @tc.name: PrintMarginTest_0011
160  * @tc.desc: Verify the getRight function.
161  * @tc.type: FUNC
162  * @tc.require:
163  */
164 HWTEST_F(PrintMarginTest, PrintMarginTest_0011, TestSize.Level1)
165 {
166     OHOS::Print::PrintMargin margin;
167     margin.SetRight(6);
168     EXPECT_EQ((uint32_t)6, margin.GetRight());
169 }
170 
171 /**
172  * @tc.name: PrintMarginTest_0012
173  * @tc.desc: Verify the marshalling function.
174  * @tc.type: FUNC
175  * @tc.require:
176  */
177 HWTEST_F(PrintMarginTest, PrintMarginTest_0012, TestSize.Level1)
178 {
179     OHOS::Print::PrintMargin margin;
180     margin.SetTop(6);
181     margin.SetBottom(6);
182     margin.SetLeft(6);
183     margin.SetRight(6);
184     Parcel parcel;
185     EXPECT_TRUE(margin.Marshalling(parcel));
186 }
187 
188 /**
189  * @tc.name: PrintMarginTest_0013
190  * @tc.desc: Verify the marshalling function.
191  * @tc.type: FUNC
192  * @tc.require:
193  */
194 HWTEST_F(PrintMarginTest, PrintMarginTest_0013, TestSize.Level1)
195 {
196     OHOS::Print::PrintMargin margin;
197     margin.SetBottom(6);
198     margin.SetLeft(6);
199     margin.SetRight(6);
200     Parcel parcel;
201     EXPECT_TRUE(margin.Marshalling(parcel));
202 }
203 
204 /**
205  * @tc.name: PrintMarginTest_0014
206  * @tc.desc: Verify the marshalling function.
207  * @tc.type: FUNC
208  * @tc.require:
209  */
210 HWTEST_F(PrintMarginTest, PrintMarginTest_0014, TestSize.Level1)
211 {
212     OHOS::Print::PrintMargin margin;
213     margin.SetTop(6);
214     margin.SetLeft(6);
215     margin.SetRight(6);
216     Parcel parcel;
217     EXPECT_TRUE(margin.Marshalling(parcel));
218 }
219 
220 /**
221  * @tc.name: PrintMarginTest_0015
222  * @tc.desc: Verify the marshalling function.
223  * @tc.type: FUNC
224  * @tc.require:
225  */
226 HWTEST_F(PrintMarginTest, PrintMarginTest_0015, TestSize.Level1)
227 {
228     OHOS::Print::PrintMargin margin;
229     margin.SetTop(6);
230     margin.SetBottom(6);
231     margin.SetRight(6);
232     Parcel parcel;
233     EXPECT_TRUE(margin.Marshalling(parcel));
234 }
235 
236 /**
237  * @tc.name: PrintMarginTest_0016
238  * @tc.desc: Verify the marshalling function.
239  * @tc.type: FUNC
240  * @tc.require:
241  */
242 HWTEST_F(PrintMarginTest, PrintMarginTest_0016, TestSize.Level1)
243 {
244     OHOS::Print::PrintMargin margin;
245     margin.SetTop(6);
246     margin.SetBottom(6);
247     margin.SetLeft(6);
248     Parcel parcel;
249     EXPECT_TRUE(margin.Marshalling(parcel));
250 }
251 
252 /**
253  * @tc.name: PrintMarginTest_0017
254  * @tc.desc: Verify the unmarshalling function.
255  * @tc.type: FUNC
256  * @tc.require:
257  */
258 HWTEST_F(PrintMarginTest, PrintMarginTest_0017, TestSize.Level1)
259 {
260     OHOS::Print::PrintMargin margin;
261     margin.SetTop(6);
262     margin.SetBottom(6);
263     margin.SetLeft(6);
264     margin.SetRight(6);
265     Parcel parcel;
266     margin.Marshalling(parcel);
267     auto result = OHOS::Print::PrintMargin::Unmarshalling(parcel);
268     EXPECT_NE(nullptr, result);
269 }
270 
271 /**
272  * @tc.name: PrintMarginTest_0018
273  * @tc.desc: Verify the unmarshalling function.
274  * @tc.type: FUNC
275  * @tc.require:
276  */
277 HWTEST_F(PrintMarginTest, PrintMarginTest_0018, TestSize.Level1)
278 {
279     OHOS::Print::PrintMargin margin;
280     margin.SetBottom(6);
281     margin.SetLeft(6);
282     margin.SetRight(6);
283     Parcel parcel;
284     margin.Marshalling(parcel);
285     auto result = OHOS::Print::PrintMargin::Unmarshalling(parcel);
286     EXPECT_NE(nullptr, result);
287 }
288 
289 /**
290  * @tc.name: PrintMarginTest_0019
291  * @tc.desc: Verify the unmarshalling function.
292  * @tc.type: FUNC
293  * @tc.require:
294  */
295 HWTEST_F(PrintMarginTest, PrintMarginTest_0019, TestSize.Level1)
296 {
297     OHOS::Print::PrintMargin margin;
298     margin.SetTop(6);
299     margin.SetLeft(6);
300     margin.SetRight(6);
301     Parcel parcel;
302     margin.Marshalling(parcel);
303     auto result = OHOS::Print::PrintMargin::Unmarshalling(parcel);
304     EXPECT_NE(nullptr, result);
305 }
306 
307 /**
308  * @tc.name: PrintMarginTest_0020
309  * @tc.desc: Verify the unmarshalling function.
310  * @tc.type: FUNC
311  * @tc.require:
312  */
313 HWTEST_F(PrintMarginTest, PrintMarginTest_0020, TestSize.Level1)
314 {
315     OHOS::Print::PrintMargin margin;
316     margin.SetTop(6);
317     margin.SetBottom(6);
318     margin.SetRight(6);
319     Parcel parcel;
320     margin.Marshalling(parcel);
321     auto result = OHOS::Print::PrintMargin::Unmarshalling(parcel);
322     EXPECT_NE(nullptr, result);
323 }
324 
325 /**
326  * @tc.name: PrintMarginTest_0021
327  * @tc.desc: Verify the unmarshalling function.
328  * @tc.type: FUNC
329  * @tc.require:
330  */
331 HWTEST_F(PrintMarginTest, PrintMarginTest_0021, TestSize.Level1)
332 {
333     OHOS::Print::PrintMargin margin;
334     margin.SetTop(6);
335     margin.SetBottom(6);
336     margin.SetLeft(6);
337     Parcel parcel;
338     margin.Marshalling(parcel);
339     auto result = OHOS::Print::PrintMargin::Unmarshalling(parcel);
340     EXPECT_NE(nullptr, result);
341 }
342 
343 /**
344  * @tc.name: PrintMarginTest_0022
345  * @tc.desc: Verify the bottom function.
346  * @tc.type: FUNC
347  * @tc.require:
348  */
349 HWTEST_F(PrintMarginTest, PrintMarginTest_0022, TestSize.Level1)
350 {
351     OHOS::Print::PrintMargin margin;
352     margin.SetTop(6);
353     OHOS::Print::PrintMargin copyMargin(margin);
354     EXPECT_EQ(copyMargin.GetTop(), margin.GetTop());
355 }
356 
357 /**
358  * @tc.name: PrintMarginTest_0023
359  * @tc.desc: Verify the bottom function.
360  * @tc.type: FUNC
361  * @tc.require:
362  */
363 HWTEST_F(PrintMarginTest, PrintMarginTest_0023, TestSize.Level1)
364 {
365     OHOS::Print::PrintMargin margin;
366     margin.SetTop(6);
367     OHOS::Print::PrintMargin copyMargin = margin;
368     EXPECT_EQ(copyMargin.GetTop(), margin.GetTop());
369 }
370 } // namespace Print
371 } // namespace OHOS
372