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 #define private public
18 #include "print_security_guard_manager.h"
19 #undef private
20 #include "print_constant.h"
21 #include "print_log.h"
22
23 using namespace testing::ext;
24
25 namespace OHOS {
26 namespace Print {
27 class PrintSecurityGuardManagerTest : public testing::Test {
28 public:
29 static void SetUpTestCase(void);
30 static void TearDownTestCase(void);
31 void SetUp();
32 void TearDown();
33 };
34
SetUpTestCase(void)35 void PrintSecurityGuardManagerTest::SetUpTestCase(void) {}
36
TearDownTestCase(void)37 void PrintSecurityGuardManagerTest::TearDownTestCase(void) {}
38
SetUp(void)39 void PrintSecurityGuardManagerTest::SetUp(void) {}
40
TearDown(void)41 void PrintSecurityGuardManagerTest::TearDown(void) {}
42
43 /**
44 * @tc.name: PrintSecurityGuardManagerTest_0001
45 * @tc.desc: receiveBaseInfo
46 * @tc.type: FUNC
47 * @tc.require:
48 */
49 HWTEST_F(PrintSecurityGuardManagerTest, PrintSecurityGuardManagerTest_0001_NeedRename, TestSize.Level1)
50 {
51 PrintSecurityGuardManager printSerPrintSecurityGuardManager;
52 std::vector<std::string> fileList;
53 PrinterInfo printerInfo;
54 PrintJob printJob;
55 int num = printSerPrintSecurityGuardManager.securityMap_.size();
56 printSerPrintSecurityGuardManager.receiveBaseInfo("jobId-1", "callerPkg-1", fileList);
57 EXPECT_EQ(printSerPrintSecurityGuardManager.securityMap_.size(), num+1);
58 printSerPrintSecurityGuardManager.receiveJobStateUpdate("jobId-2", printerInfo, printJob);
59 }
60
61 /**
62 * @tc.name: PrintSecurityGuardManagerTest_0002
63 * @tc.desc: receiveBaseInfo
64 * @tc.type: FUNC
65 * @tc.require:
66 */
67 HWTEST_F(PrintSecurityGuardManagerTest, PrintSecurityGuardManagerTest_0002_NeedRename, TestSize.Level1)
68 {
69 PrintSecurityGuardManager printSerPrintSecurityGuardManager;
70 std::vector<std::string> fileList;
71 PrinterInfo printerInfo;
72 PrintJob printJob;
73 int num = printSerPrintSecurityGuardManager.securityMap_.size();
74 printSerPrintSecurityGuardManager.receiveBaseInfo("jobId-1", "callerPkg-1", fileList);
75 EXPECT_EQ(printSerPrintSecurityGuardManager.securityMap_.size(), num+1);
76 printSerPrintSecurityGuardManager.receiveJobStateUpdate("jobId-1", printerInfo, printJob);
77 }
78 } // namespace Print
79 } // namespace OHOS
80