• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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_service_helper.h"
18 #include "print_constant.h"
19 #include "ipc_skeleton.h"
20 
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace Print {
25 
26 static const std::string SPOOLER_BUNDLE_NAME = "com.ohos.spooler";
27 static const std::string SPOOLER_PACKAGE_NAME = "com.ohos.spooler";
28 static const std::string SPOOLER_STATUS_BAR_ABILITY_NAME = "PluginPrintIconExtAbility";
29 static const std::string CALLER_PKG_NAME = "caller.pkgName";
30 
31 class PrintServiceHelperTest : public testing::Test {
32 public:
33     static void SetUpTestCase(void);
34     static void TearDownTestCase(void);
35     void SetUp();
36     void TearDown();
37 };
38 
SetUpTestCase(void)39 void PrintServiceHelperTest::SetUpTestCase(void) {}
40 
TearDownTestCase(void)41 void PrintServiceHelperTest::TearDownTestCase(void) {}
42 
SetUp(void)43 void PrintServiceHelperTest::SetUp(void)
44 {
45     static int32_t testNo = 0;
46     PRINT_HILOGI("PrintServiceHelperTest_%{public}d", ++testNo);
47 }
48 
TearDown(void)49 void PrintServiceHelperTest::TearDown(void) {}
50 
51 /**
52 * @tc.name: PrintServiceHelperTest_0001
53 * @tc.desc: reportPrintSuccess
54 * @tc.type: FUNC
55 * @tc.require:
56 */
57 HWTEST_F(PrintServiceHelperTest, PrintServiceHelperTest_0001, TestSize.Level1)
58 {
59     PrintServiceHelper helper;
60     helper.~PrintServiceHelper();
61 }
62 
63 /**
64 * @tc.name: PrintServiceHelperTest_0002
65 * @tc.desc: faultPrint
66 * @tc.type: FUNC
67 * @tc.require:
68 */
69 HWTEST_F(PrintServiceHelperTest, PrintServiceHelperTest_0002, TestSize.Level1)
70 {
71     PrintServiceHelper helper;
72     helper.CheckPermission("");
73 }
74 
75 /**
76 * @tc.name: PrintServiceHelperTest_0003
77 * @tc.desc: faultPrint
78 * @tc.type: FUNC
79 * @tc.require:
80 */
81 HWTEST_F(PrintServiceHelperTest, PrintServiceHelperTest_0003, TestSize.Level1)
82 {
83     PrintServiceHelper helper;
84     helper.GetBundleMgr();
85 }
86 
87 /**
88 * @tc.name: PrintServiceHelperTest_0004
89 * @tc.desc: faultPrint
90 * @tc.type: FUNC
91 * @tc.require:
92 */
93 HWTEST_F(PrintServiceHelperTest, PrintServiceHelperTest_0004, TestSize.Level1)
94 {
95     PrintServiceHelper helper;
96     std::vector<int> accountList;
97     helper.QueryAccounts(accountList);
98 }
99 
100 /**
101 * @tc.name: PrintServiceHelperTest_0005
102 * @tc.desc: faultPrint
103 * @tc.type: FUNC
104 * @tc.require:
105 */
106 HWTEST_F(PrintServiceHelperTest, PrintServiceHelperTest_0005, TestSize.Level1)
107 {
108     PrintServiceHelper helper;
109     std::vector<int> accountList = {};
110     helper.QueryAccounts(accountList);
111 }
112 
113 /**
114 * @tc.name: PrintServiceHelperTest_0006
115 * @tc.desc: faultPrint
116 * @tc.type: FUNC
117 * @tc.require:
118 */
119 HWTEST_F(PrintServiceHelperTest, PrintServiceHelperTest_0006, TestSize.Level1)
120 {
121     PrintServiceHelper helper;
122     sptr<AppExecFwk::IBundleMgr> mgr;
123     int userId = 0;
124     std::vector<AppExecFwk::ExtensionAbilityInfo> extensionInfos;
125     helper.QueryExtension(mgr, userId, extensionInfos);
126 }
127 
128 /**
129 * @tc.name: PrintServiceHelperTest_0007
130 * @tc.desc: faultPrint
131 * @tc.type: FUNC
132 * @tc.require:
133 */
134 HWTEST_F(PrintServiceHelperTest, PrintServiceHelperTest_0007, TestSize.Level1)
135 {
136     PrintServiceHelper helper;
137     sptr<AppExecFwk::IBundleMgr> mgr;
138     int userId = 0;
139     std::string userName;
140     helper.QueryNameForUid(mgr, userId, userName);
141 }
142 
143 /**
144 * @tc.name: PrintServiceHelperTest_0008
145 * @tc.desc: faultPrint
146 * @tc.type: FUNC
147 * @tc.require:
148 */
149 HWTEST_F(PrintServiceHelperTest, PrintServiceHelperTest_0008, TestSize.Level1)
150 {
151     PrintServiceHelper helper;
152     helper.IsSyncMode();
153 }
154 
155 /**
156 * @tc.name: PrintServiceHelperTest_0013
157 * @tc.desc: faultPrint
158 * @tc.type: FUNC
159 * @tc.require:
160 */
161 HWTEST_F(PrintServiceHelperTest, PrintServiceHelperTest_009, TestSize.Level1) {
162     PrintServiceHelper helper;
163     AAFwk::Want want;
164     EXPECT_FALSE(helper.StartAbility(want));
165 }
166 
167 /**
168 * @tc.name: PrintServiceHelperTest_0014
169 * @tc.desc: faultPrint
170 * @tc.type: FUNC
171 * @tc.require:
172 */
173 HWTEST_F(PrintServiceHelperTest, PrintServiceHelperTest_0010, TestSize.Level1)
174 {
175     PrintServiceHelper helper;
176     helper.PrintSubscribeCommonEvent();
177 }
178 
179 } // namespace Print
180 } // namespace OHOS