• 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_extension_info.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 PrintExtensionInfoTest : 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 PrintExtensionInfoTest::SetUpTestCase(void) {}
34 
TearDownTestCase(void)35 void PrintExtensionInfoTest::TearDownTestCase(void) {}
36 
SetUp(void)37 void PrintExtensionInfoTest::SetUp(void) {}
38 
TearDown(void)39 void PrintExtensionInfoTest::TearDown(void) {}
40 
41 /**
42  * @tc.name: PrintExtInfoTest_0001
43  * @tc.desc: Dump
44  * @tc.type: FUNC
45  * @tc.require:
46  */
47 HWTEST_F(PrintExtensionInfoTest, PrintExtInfoTest_0001, TestSize.Level1)
48 {
49     OHOS::Print::PrintExtensionInfo info;
50     OHOS::Print::PrintExtensionInfo inf;
51     inf = info;
52     info.Dump();
53     EXPECT_EQ(inf.GetExtensionId(), info.GetExtensionId());
54     EXPECT_EQ(inf.GetVendorId(), info.GetVendorId());
55     EXPECT_EQ(inf.GetVendorName(), info.GetVendorName());
56     EXPECT_EQ(inf.GetVendorIcon(), info.GetVendorIcon());
57     EXPECT_EQ(inf.GetVersion(), info.GetVersion());
58 }
59 
60 /**
61  * @tc.name: PrintExtInfoTest_0002
62  * @tc.desc: SetExtensionId, GetVendorId
63  * @tc.type: FUNC
64  * @tc.require:
65  */
66 HWTEST_F(PrintExtensionInfoTest, PrintExtInfoTest_0002, TestSize.Level1)
67 {
68     OHOS::Print::PrintExtensionInfo info;
69     info.SetExtensionId("id-1234");
70     EXPECT_EQ(info.GetExtensionId(), "id-1234");
71 }
72 
73 /**
74  * @tc.name: PrintExtInfoTest_0003
75  * @tc.desc: SetVendorId, GetVendorId
76  * @tc.type: FUNC
77  * @tc.require:
78  */
79 HWTEST_F(PrintExtensionInfoTest, PrintExtInfoTest_0003, TestSize.Level1)
80 {
81     OHOS::Print::PrintExtensionInfo info;
82     info.SetVendorId("vid-1234");
83     EXPECT_EQ(info.GetVendorId(), "vid-1234");
84 }
85 
86 /**
87  * @tc.name: PrintExtInfoTest_0004
88  * @tc.desc: SetVendorIcon, SetVendorIcon
89  * @tc.type: FUNC
90  * @tc.require:
91  */
92 HWTEST_F(PrintExtensionInfoTest, PrintExtInfoTest_0004, TestSize.Level1)
93 {
94     OHOS::Print::PrintExtensionInfo info;
95     info.SetVendorIcon(1234);
96     EXPECT_EQ(info.GetVendorIcon(), (uint32_t)1234);
97 }
98 
99 /**
100  * @tc.name: PrintExtInfoTest_0005
101  * @tc.desc: SetVendorName, GetVendorName
102  * @tc.type: FUNC
103  * @tc.require:
104  */
105 HWTEST_F(PrintExtensionInfoTest, PrintExtInfoTest_0005, TestSize.Level1)
106 {
107     OHOS::Print::PrintExtensionInfo info;
108     info.SetVendorName("vendorName");
109     EXPECT_EQ(info.GetVendorName(), "vendorName");
110 }
111 
112 /**
113  * @tc.name: PrintExtInfoTest_0006
114  * @tc.desc: SetVersion, GetVersion
115  * @tc.type: FUNC
116  * @tc.require:
117  */
118 HWTEST_F(PrintExtensionInfoTest, PrintExtInfoTest_0006, TestSize.Level1)
119 {
120     OHOS::Print::PrintExtensionInfo info;
121     info.SetVersion("1.0.0");
122     EXPECT_EQ(info.GetVersion(), "1.0.0");
123 }
124 
125 /**
126  * @tc.name: PrintExtInfoTest_0007
127  * @tc.desc: PrintExtensionInfo()
128  * @tc.type: FUNC
129  * @tc.require:
130  */
131 HWTEST_F(PrintExtensionInfoTest, PrintExtInfoTest_0007, TestSize.Level1)
132 {
133     OHOS::Print::PrintExtensionInfo info;
134     info.SetVersion("1.0.0");
135     OHOS::Print::PrintExtensionInfo copyInfo(info);
136     EXPECT_EQ(copyInfo.GetVersion(), info.GetVersion());
137 }
138 
139 /**
140  * @tc.name: PrintExtInfoTest_0008
141  * @tc.desc: operation =
142  * @tc.type: FUNC
143  * @tc.require:
144  */
145 HWTEST_F(PrintExtensionInfoTest, PrintExtInfoTest_0008, TestSize.Level1)
146 {
147     OHOS::Print::PrintExtensionInfo info;
148     info.SetVersion("1.0.0");
149     OHOS::Print::PrintExtensionInfo copyInfo = info;
150     EXPECT_EQ(copyInfo.GetVersion(), info.GetVersion());
151 }
152 
153 /**
154  * @tc.name: PrintExtInfoTest_0009
155  * @tc.desc: Marshalling
156  * @tc.type: FUNC
157  * @tc.require:
158  */
159 HWTEST_F(PrintExtensionInfoTest, PrintExtInfoTest_0009, TestSize.Level1)
160 {
161     OHOS::Print::PrintExtensionInfo info;
162     info.SetVendorName("vendorName");
163     info.SetExtensionId("extensionId:123");
164     info.SetVendorId("vendorId");
165     info.SetVendorIcon(123);
166     info.SetVersion("version");
167     Parcel parcel;
168     EXPECT_EQ(info.Marshalling(parcel), true);
169 }
170 
171 /**
172  * @tc.name: PrintExtInfoTest_0010
173  * @tc.desc: Unmarshalling
174  * @tc.type: FUNC
175  * @tc.require:
176  */
177 HWTEST_F(PrintExtensionInfoTest, PrintExtInfoTest_0010, TestSize.Level1)
178 {
179     OHOS::Print::PrintExtensionInfo info;
180     info.SetVendorName("vendorName");
181     info.SetExtensionId("extensionId:123");
182     info.SetVendorId("vendorId");
183     info.SetVendorIcon(123);
184     info.SetVersion("version");
185     Parcel parcel;
186     info.Marshalling(parcel);
187     auto result = OHOS::Print::PrintExtensionInfo::Unmarshalling(parcel);
188     EXPECT_NE(nullptr, result);
189 }
190 } // namespace Print
191 } // namespace OHOS