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" 17 18export const HapModuleQuickFixInfo = { 19 moduleName: '[PC preview] unknow moduleName', 20 originHapHash: '[PC preview] unknow originHapHash', 21 quickFixFilePath: '[PC preview] unknow quickFixFilePath', 22} 23export const ApplicationQuickFixInfo = { 24 bundleName: '[PC preview] unknow bundleName', 25 bundleVersionCode: '[PC preview] unknow bundleVersionCode', 26 bundleVersionName: '[PC preview] unknow bundleVersionName', 27 quickFixVersionCode: '[PC preview] unknow quickFixVersionCode', 28 quickFixVersionName: '[PC preview] unknow quickFixVersionName', 29 hapModuleQuickFixInfo: [HapModuleQuickFixInfo], 30} 31export function mockQuickFixManager() { 32 const quickFixManager = { 33 HapModuleQuickFixInfo, 34 ApplicationQuickFixInfo, 35 applyQuickFix: function (...args) { 36 console.warn('quickFixManager.applyQuickFix interface mocked in the Previewer. How this interface works on the' + 37 ' Previewer may be different from that on a real device.'); 38 const len = args.length; 39 if (typeof args[len - 1] === 'function') { 40 args[len - 1].call(this, paramMock.businessErrorMock); 41 } else { 42 return new Promise((resolve) => { 43 resolve(); 44 }); 45 } 46 }, 47 getApplicationQuickFixInfo: function (...args) { 48 console.warn('quickFixManager.getApplicationQuickFixInfo interface mocked in the Previewer. How this interface works on the' + 49 ' Previewer may be different from that on a real device.'); 50 const len = args.length; 51 if (typeof args[len - 1] === 'function') { 52 args[len - 1].call(this, paramMock.businessErrorMock, ApplicationQuickFixInfo); 53 } else { 54 return new Promise((resolve) => { 55 resolve(ApplicationQuickFixInfo); 56 }); 57 } 58 }, 59 } 60 return quickFixManager 61}