1/* 2 * Copyright (c) 2021-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 { AbilityContextClass } from "./application/AbilityContext" 18import { WantClass } from "./ohos_application_Want" 19import { OnContinueResult } from "./ohos_application_AbilityConstant" 20import { MessageParcelClass } from "./ohos_rpc" 21 22export const Caller = { 23 call: function (...args) { 24 console.warn("Caller.call interface mocked in the Previewer." + 25 " How this interface works on the Previewer may be different from that on a real device.") 26 return new Promise((resolve, reject) => { 27 resolve(); 28 }) 29 }, 30 callWithResult: function (...args) { 31 console.warn("Caller.callWithResult interface mocked in the Previewer." + 32 " How this interface works on the Previewer may be different from that on a real device.") 33 return new Promise((resolve, reject) => { 34 resolve(new MessageParcelClass()); 35 }) 36 }, 37 release: function () { 38 console.warn("Caller.release interface mocked in the Previewer. How this interface works on the Previewer" + 39 " may be different from that on a real device.") 40 }, 41 onRelease: function (...args) { 42 console.warn("Caller.onRelease interface mocked in the Previewer. How this interface works on the Previewer" + 43 " may be different from that on a real device.") 44 }, 45} 46export const Callee = { 47 on: function (...args) { 48 console.warn("Ability.calleeClass.on interface mocked in the Previewer. How this interface works on the Previewer" + 49 " may be different from that on a real device.") 50 }, 51 off: function (...args) { 52 console.warn("Ability.calleeClass.off interface mocked in the Previewer. How this interface works on the Previewer" + 53 " may be different from that on a real device.") 54 }, 55} 56export const AbilityClass = class Ability { 57 constructor() { 58 console.warn('application.Ability.constructor interface mocked in the Previewer. How this interface works on' + 59 ' the Previewer may be different from that on a real device.'); 60 this.context = new AbilityContextClass(); 61 this.launchWant = new WantClass(); 62 this.lastRequestWant = new WantClass(); 63 this.callee = Callee; 64 this.onCreate = function (...args) { 65 console.warn("application.Ability.onCreate interface mocked in the Previewer. How this interface works on the Previewer" + 66 " may be different from that on a real device.") 67 }; 68 this.onWindowStageCreate = function (...args) { 69 console.warn("application.Ability.onWindowStageCreate interface mocked in the Previewer. How this interface works on the Previewer" + 70 " may be different from that on a real device.") 71 }; 72 this.onWindowStageDestroy = function () { 73 console.warn("application.Ability.onWindowStageDestroy interface mocked in the Previewer. How this interface works on the Previewer" + 74 " may be different from that on a real device.") 75 }; 76 this.onWindowStageRestore = function (...args) { 77 console.warn("application.Ability.onWindowStageRestore interface mocked in the Previewer. How this interface works on the Previewer" + 78 " may be different from that on a real device.") 79 }; 80 this.onDestroy = function () { 81 console.warn("application.Ability.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" + 82 " may be different from that on a real device.") 83 }; 84 this.onForeground = function () { 85 console.warn("application.Ability.onForeground interface mocked in the Previewer. How this interface works on the Previewer" + 86 " may be different from that on a real device.") 87 }; 88 this.onBackground = function () { 89 console.warn("application.Ability.onBackground interface mocked in the Previewer. How this interface works on the Previewer" + 90 " may be different from that on a real device.") 91 }; 92 this.onContinue = function (...args) { 93 console.warn("application.Ability.onContinue interface mocked in the Previewer. How this interface works on the Previewer" + 94 " may be different from that on a real device.") 95 return OnContinueResult; 96 }; 97 this.onNewWant = function (...args) { 98 console.warn("application.Ability.onNewWant interface mocked in the Previewer. How this interface works on the Previewer" + 99 " may be different from that on a real device.") 100 }; 101 this.onConfigurationUpdated = function (...args) { 102 console.warn("application.Ability.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" + 103 " may be different from that on a real device.") 104 }; 105 this.dump = function (...args) { 106 console.warn("application.Ability.dump interface mocked in the Previewer. How this interface works on the Previewer" + 107 " may be different from that on a real device.") 108 return [paramMock.paramStringMock]; 109 }; 110 this.onMemoryLevel = function (...args) { 111 console.warn("application.Ability.onMemoryLevel interface mocked in the Previewer. How this interface works on the Previewer" + 112 " may be different from that on a real device.") 113 }; 114 } 115} 116export function mockAbility() { 117 return new AbilityClass(); 118} 119