1/* 2 * Copyright (c) 2022 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 16import { paramMock } from "../../utils" 17import { InstallErrorCode } from '../ohos_bundle.js' 18 19export const HashParam = { 20 moduleName: "[PC preview] unknown moduleName", 21 hashValue: "[PC preview] unknown hashValue", 22} 23 24export const InstallParam = { 25 userId: "[PC preview] unknown userId", 26 installFlag: "[PC preview] unknown installFlag", 27 isKeepData: "[PC preview] unknown isKeepData", 28 hashParams: [HashParam], 29 crowdtestDeadline: "[PC preview] unknown crowdtestDeadline", 30} 31 32export const InstallStatus = { 33 status: InstallErrorCode, 34 statusMessage: "[PC preview] unknown statusMessage", 35} 36 37export const BundleInstaller = { 38 moduleName: "[PC preview] unknown moduleName", 39 hashValue: "[PC preview] unknown hashValue", 40} 41 42export function mockBundleInstaller() { 43 const bundleInstaller = { 44 install: function(...args){ 45 console.warn("bundleInstaller.install interface mocked in the Previewer. How this interface works on the" + 46 " Previewer may be different from that on a real device.") 47 const len = args.length; 48 args[len - 1].call(this, paramMock.businessErrorMock, InstallStatus); 49 }, 50 uninstall: function(...args){ 51 console.warn("bundleInstaller.uninstall interface mocked in the Previewer. How this interface works on the" + 52 " Previewer may be different from that on a real device.") 53 const len = args.length; 54 args[len - 1].call(this, paramMock.businessErrorMock, InstallStatus); 55 }, 56 recover: function(...args){ 57 console.warn("bundleInstaller.recover interface mocked in the Previewer. How this interface works on the" + 58 " Previewer may be different from that on a real device.") 59 const len = args.length; 60 args[len - 1].call(this, paramMock.businessErrorMock, InstallStatus); 61 } 62 }; 63 return bundleInstaller; 64}