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 #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 #include "bundle_installer_host.h" 26 27 namespace OHOS { 28 namespace AppExecFwk { 29 namespace { 30 const std::string MSG_SUCCESS = "[SUCCESS]"; 31 const std::string STRING_BUNDLE_PATH = "/data/test/bundle_test/testdemo.hap"; 32 const std::string STRING_OTHER_BUNDLE_PATH = "/data/test/bundle_test/othertestdemo.hap"; 33 const std::string STRING_BUNDLE_INSTALL_PATH1 = "../../test/bundle_test1/"; 34 const std::string STRING_BUNDLE_INSTALL_PATH2 = "../../test/bundle_test2/"; 35 const std::string STRING_BUNDLE_NAME = "name"; 36 const std::string STRING_MODULE_NAME = "module"; 37 const std::string STRING_ABILITY_NAME = "ability"; 38 const std::string DEFAULT_USER_ID = "100"; 39 const std::string ERR_USER_ID = "-1"; 40 const std::string DEFAULT_WAIT_TIME = "200"; 41 const std::string MINIMUMT_WAIT_TIME = "1"; 42 const std::string MAXIMUM_WAIT_TIME = "700"; 43 const std::string DEFAULT_DEVICE_TIME = "0"; 44 const std::string STRING_SIGNATURE_FILE_PATH = "/data/test/bundle_test/test.sig"; 45 const std::string STRING_TEST_BUNDLE_PATH = "/data/test/"; 46 const std::string STRING_DATA_TEST = "/data/test/demoTest/"; 47 const std::string STRING_EMPTY = ""; 48 } // namespace 49 50 class MockBundleInstallerHost : public IRemoteStub<IBundleInstaller> { 51 public: 52 MockBundleInstallerHost(); 53 ~MockBundleInstallerHost() override; 54 bool Install(const std::string &bundleFilePath, const InstallParam &installParam, 55 const sptr<IStatusReceiver> &statusReceiver); 56 bool Install(const std::vector<std::string> &bundleFilePath, const InstallParam &installParam, 57 const sptr<IStatusReceiver> &statusReceiver); 58 bool Uninstall( 59 const std::string &bundleName, const InstallParam &installParam, const sptr<IStatusReceiver> &statusReceiver); 60 61 bool Uninstall(const std::string &bundleName, const std::string &modulePackage, const InstallParam &installParam, 62 const sptr<IStatusReceiver> &statusReceiver); 63 64 bool Uninstall(const UninstallParam &uninstallParam, const sptr<IStatusReceiver> &statusReceiver); 65 66 bool Recover(const std::string &bundleName, const InstallParam &installParam, 67 const sptr<IStatusReceiver> &statusReceiver); 68 69 ErrCode StreamInstall(const std::vector<std::string> &bundleFilePaths, const InstallParam &installParam, 70 const sptr<IStatusReceiver> &statusReceiver); 71 72 ErrCode InstallSandboxApp(const std::string &bundleName, int32_t dplType, int32_t userId, 73 int32_t &appIndex); 74 75 ErrCode UninstallSandboxApp(const std::string &bundleName, int32_t appIndex, int32_t userId); 76 77 sptr<IBundleStreamInstaller> CreateStreamInstaller(const InstallParam &installParam, 78 const sptr<IStatusReceiver> &statusReceiver, const std::vector<std::string> &originHapPaths); 79 80 bool DestoryBundleStreamInstaller(uint32_t streamInstallerId); 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