• 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_page_size.h"
18 #include "printer_capability.h"
19 #include "print_log.h"
20 
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace Print {
25 class PrintPageSizeTest : public testing::Test {
26 public:
27     static void SetUpTestCase(void);
28     static void TearDownTestCase(void);
29     void SetUp();
30     void TearDown();
31 };
32 
SetUpTestCase(void)33 void PrintPageSizeTest::SetUpTestCase(void) {}
34 
TearDownTestCase(void)35 void PrintPageSizeTest::TearDownTestCase(void) {}
36 
SetUp(void)37 void PrintPageSizeTest::SetUp(void) {}
38 
TearDown(void)39 void PrintPageSizeTest::TearDown(void) {}
40 
41 /**
42  * @tc.name: PrintPageSizeTest_0001
43  * @tc.desc: Verify the constructor function.
44  * @tc.type: FUNC
45  * @tc.require:
46  */
47 HWTEST_F(PrintPageSizeTest, PrintPageSizeTest_0001, TestSize.Level1)
48 {
49     OHOS::Print::PrintPageSize printpageSize;
50     OHOS::Print::PrintPageSize::BuildPageSizeMap();
51     printpageSize.Dump();
52 }
53 
54 /**
55  * @tc.name: PrintPageSizeTest_0002
56  * @tc.desc: Verify the getPageSize function.
57  * @tc.type: FUNC
58  * @tc.require:
59  */
60 HWTEST_F(PrintPageSizeTest, PrintPageSizeTest_0002, TestSize.Level1)
61 {
62     auto pageSize = OHOS::Print::PrintPageSize::GetPageSize(ISO_A3);
63     EXPECT_EQ((uint32_t)0, pageSize.GetWidth());
64 }
65 
66 /**
67  * @tc.name: PrintPageSizeTest_0003
68  * @tc.desc: Verify the reset function.
69  * @tc.type: FUNC
70  * @tc.require:
71  */
72 HWTEST_F(PrintPageSizeTest, PrintPageSizeTest_0003, TestSize.Level1)
73 {
74     OHOS::Print::PrintPageSize printpageSize;
75     printpageSize.Reset();
76     EXPECT_EQ("", printpageSize.GetId());
77 }
78 
79 /**
80  * @tc.name: PrintPageSizeTest_0004
81  * @tc.desc: Verify the getId function.
82  * @tc.type: FUNC
83  * @tc.require:
84  */
85 HWTEST_F(PrintPageSizeTest, PrintPageSizeTest_0004, TestSize.Level1)
86 {
87     OHOS::Print::PrintPageSize printpageSize;
88     printpageSize.SetId("Test");
89     EXPECT_EQ("Test", printpageSize.GetId());
90 }
91 
92 /**
93  * @tc.name: PrintPageSizeTest_0005
94  * @tc.desc: Verify the getName function.
95  * @tc.type: FUNC
96  * @tc.require:
97  */
98 HWTEST_F(PrintPageSizeTest, PrintPageSizeTest_0005, TestSize.Level1)
99 {
100     OHOS::Print::PrintPageSize printpageSize;
101     printpageSize.SetName("Test");
102     EXPECT_EQ("Test", printpageSize.GetName());
103 }
104 
105 /**
106  * @tc.name: PrintPageSizeTest_0006
107  * @tc.desc: Verify the getWidth function.
108  * @tc.type: FUNC
109  * @tc.require:
110  */
111 HWTEST_F(PrintPageSizeTest, PrintPageSizeTest_0006, TestSize.Level1)
112 {
113     OHOS::Print::PrintPageSize printpageSize;
114     printpageSize.SetWidth(6);
115     EXPECT_EQ((uint32_t)6, printpageSize.GetWidth());
116 }
117 
118 /**
119  * @tc.name: PrintPageSizeTest_0007
120  * @tc.desc: Verify the getHeight function.
121  * @tc.type: FUNC
122  * @tc.require:
123  */
124 HWTEST_F(PrintPageSizeTest, PrintPageSizeTest_0007, TestSize.Level1)
125 {
126     OHOS::Print::PrintPageSize printpageSize;
127     printpageSize.SetHeight(6);
128     EXPECT_EQ((uint32_t)6, printpageSize.GetHeight());
129 }
130 
131 /**
132  * @tc.name: PrintPageSizeTest_0008
133  * @tc.desc: Verify the marshalling function.
134  * @tc.type: FUNC
135  * @tc.require:
136  */
137 HWTEST_F(PrintPageSizeTest, PrintPageSizeTest_0008, TestSize.Level1)
138 {
139     OHOS::Print::PrintPageSize printpageSize;
140     printpageSize.SetId("id-1234");
141     printpageSize.SetName("Test");
142     printpageSize.SetWidth(6);
143     printpageSize.SetHeight(6);
144     Parcel parcel;
145     EXPECT_EQ(printpageSize.Marshalling(parcel), true);
146 }
147 
148 /**
149  * @tc.name: PrintPageSizeTest_0009
150  * @tc.desc: Verify the unmarshalling function.
151  * @tc.type: FUNC
152  * @tc.require:
153  */
154 HWTEST_F(PrintPageSizeTest, PrintPageSizeTest_0009, TestSize.Level1)
155 {
156     OHOS::Print::PrintPageSize printpageSize;
157     printpageSize.SetId("id-1234");
158     Parcel parcel;
159     printpageSize.Marshalling(parcel);
160     auto result = OHOS::Print::PrintPageSize::Unmarshalling(parcel);
161     EXPECT_NE(nullptr, result);
162 }
163 
164 /**
165  * @tc.name: PrintPageSizeTest_0010
166  * @tc.desc: Verify the constructor function.
167  * @tc.type: FUNC
168  * @tc.require:
169  */
170 HWTEST_F(PrintPageSizeTest, PrintPageSizeTest_0010, TestSize.Level1)
171 {
172     OHOS::Print::PrintPageSize printpageSize("Test", "Test", 6, 6);
173     EXPECT_EQ((uint32_t)6, printpageSize.GetWidth());
174 }
175 
176 /**
177  * @tc.name: PrintPageSizeTest_0011
178  * @tc.desc: Verify the copy constructor function.
179  * @tc.type: FUNC
180  * @tc.require:
181  */
182 HWTEST_F(PrintPageSizeTest, PrintPageSizeTest_0011, TestSize.Level1)
183 {
184     OHOS::Print::PrintPageSize printpageSize;
185     printpageSize.SetWidth(6);
186     OHOS::Print::PrintPageSize copyPageSize(printpageSize);
187     EXPECT_EQ(copyPageSize.GetWidth(), printpageSize.GetWidth());
188 }
189 
190 /**
191  * @tc.name: PrintPageSizeTest_0012
192  * @tc.desc: Verify the copy constructor function.
193  * @tc.type: FUNC
194  * @tc.require:
195  */
196 HWTEST_F(PrintPageSizeTest, PrintPageSizeTest_0012, TestSize.Level1)
197 {
198     OHOS::Print::PrintPageSize printpageSize;
199     printpageSize.SetWidth(6);
200     OHOS::Print::PrintPageSize copyPageSize = printpageSize;
201     EXPECT_EQ(copyPageSize.GetWidth(), printpageSize.GetWidth());
202 }
203 } // namespace Print
204 } // namespace OHOS