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 { FormState } from "./ohos_application_formInfo" 17import { FormExtensionContextClass as FormExtensionContext } from "./application/FormExtensionContext" 18import { FormBindingData } from "./ohos_application_formBindingData" 19 20export function mockFormExtension() { 21 const formExtensionClass = class formExtension { 22 constructor() { 23 console.warn('application.formExtension.constructor interface mocked in the Previewer. How this interface works on' + 24 ' the Previewer may be different from that on a real device.'); 25 this.context = new FormExtensionContext(); 26 this.onCreate = function (...args) { 27 console.warn("application.formExtension.onCreate interface mocked in the Previewer. How this interface works on the Previewer" + 28 " may be different from that on a real device.") 29 return FormBindingData 30 }; 31 this.onCastToNormal = function (...args) { 32 console.warn("application.formExtension.onCastToNormal interface mocked in the Previewer. How this interface works on the Previewer" + 33 " may be different from that on a real device.") 34 }; 35 this.onUpdate = function (...args) { 36 console.warn("application.formExtension.onUpdate interface mocked in the Previewer. How this interface works on the Previewer" + 37 " may be different from that on a real device.") 38 }; 39 this.onVisibilityChange = function (...args) { 40 console.warn("application.formExtension.onVisibilityChange interface mocked in the Previewer. How this interface works on the Previewer" + 41 " may be different from that on a real device.") 42 }; 43 this.onEvent = function (...args) { 44 console.warn("application.formExtension.onEvent interface mocked in the Previewer. How this interface works on the Previewer" + 45 " may be different from that on a real device.") 46 }; 47 this.onDestroy = function (...args) { 48 console.warn("application.formExtension.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" + 49 " may be different from that on a real device.") 50 }; 51 this.onConfigurationUpdated = function (...args) { 52 console.warn("application.formExtension.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" + 53 " may be different from that on a real device.") 54 }; 55 this.onAcquireFormState = function (...args) { 56 console.warn("application.formExtension.onAcquireFormState interface mocked in the Previewer. How this interface works on the Previewer" + 57 " may be different from that on a real device.") 58 return FormState; 59 }; 60 this.onShare = function (...args) { 61 console.warn("application.formExtension.onShare interface mocked in the Previewer. How this interface works on the Previewer" + 62 " may be different from that on a real device.") 63 return {"key": "unknow any"}; 64 }; 65 } 66 } 67 return new formExtensionClass(); 68}