• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 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 #ifndef FOUNDATION_APPEXECFWK_STANDARD_TOOLS_TEST_MOCK_MOCK_BUNDLE_INSTALLER_HOST_H
17 #define FOUNDATION_APPEXECFWK_STANDARD_TOOLS_TEST_MOCK_MOCK_BUNDLE_INSTALLER_HOST_H
18 
19 #include "gmock/gmock.h"
20 
21 #include "iremote_stub.h"
22 #include "bundle_installer_interface.h"
23 
24 #include "app_log_wrapper.h"
25 
26 namespace OHOS {
27 namespace AppExecFwk {
28 namespace {
29 const std::string MSG_SUCCESS = "[SUCCESS]";
30 const std::string STRING_BUNDLE_PATH = "/data/test/bundle_test/testdemo.hap";
31 const std::string STRING_OTHER_BUNDLE_PATH = "/data/test/bundle_test/othertestdemo.hap";
32 const std::string STRING_BUNDLE_INSTALL_PATH1 = "../../test/bundle_test1/";
33 const std::string STRING_BUNDLE_INSTALL_PATH2 = "../../test/bundle_test2/";
34 const std::string STRING_BUNDLE_NAME = "name";
35 const std::string STRING_MODULE_NAME = "module";
36 const std::string STRING_ABILITY_NAME = "ability";
37 const std::string DEFAULT_USER_ID = "100";
38 const std::string ERR_USER_ID = "-1";
39 const std::string DEFAULT_WAIT_TIME = "200";
40 const std::string MINIMUMT_WAIT_TIME = "1";
41 const std::string MAXIMUM_WAIT_TIME = "700";
42 const std::string DEFAULT_DEVICE_TIME = "0";
43 const std::string STRING_SIGNATURE_FILE_PATH = "/data/test/bundle_test/test.sig";
44 const std::string STRING_TEST_BUNDLE_PATH = "/data/test/";
45 const std::string STRING_DATA_TEST = "/data/test/demoTest/";
46 const std::string STRING_EMPTY = "";
47 }  // namespace
48 
49 class MockBundleInstallerHost : public IRemoteStub<IBundleInstaller> {
50 public:
51     MockBundleInstallerHost();
52     ~MockBundleInstallerHost() override;
53     bool Install(const std::string &bundleFilePath, const InstallParam &installParam,
54         const sptr<IStatusReceiver> &statusReceiver) override;
55     bool Install(const std::vector<std::string> &bundleFilePath, const InstallParam &installParam,
56         const sptr<IStatusReceiver> &statusReceiver) override;
57     bool Uninstall(const std::string &bundleName, const InstallParam &installParam,
58         const sptr<IStatusReceiver> &statusReceiver) override;
59 
60     bool Uninstall(const std::string &bundleName, const std::string &modulePackage, const InstallParam &installParam,
61         const sptr<IStatusReceiver> &statusReceiver) override;
62 
63     bool Uninstall(const UninstallParam &uninstallParam, const sptr<IStatusReceiver> &statusReceiver) override;
64 
65     bool Recover(const std::string &bundleName, const InstallParam &installParam,
66         const sptr<IStatusReceiver> &statusReceiver) override;
67 
68     ErrCode StreamInstall(const std::vector<std::string> &bundleFilePaths, const InstallParam &installParam,
69         const sptr<IStatusReceiver> &statusReceiver) override;
70 
71     ErrCode InstallSandboxApp(
72         const std::string &bundleName, int32_t dplType, int32_t userId, int32_t &appIndex) override;
73 
74     ErrCode UninstallSandboxApp(const std::string &bundleName, int32_t appIndex, int32_t userId) override;
75 
76     sptr<IBundleStreamInstaller> CreateStreamInstaller(const InstallParam &installParam,
77         const sptr<IStatusReceiver> &statusReceiver, const std::vector<std::string> &originHapPaths) override;
78 
79     bool DestoryBundleStreamInstaller(uint32_t streamInstallerId) override;
80 
81 private:
82     DISALLOW_COPY_AND_MOVE(MockBundleInstallerHost);
83 };
84 }  // namespace AppExecFwk
85 }  // namespace OHOS
86 
87 #endif  // FOUNDATION_APPEXECFWK_STANDARD_TOOLS_TEST_MOCK_MOCK_BUNDLE_INSTALLER_HOST_H
88