diff --git a/runtime/main/extend/systemplugin/napi/ohos_convertxml.js b/runtime/main/extend/systemplugin/napi/ohos_convertxml.js index 89db4709..78c48f43 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_convertxml.js +++ b/runtime/main/extend/systemplugin/napi/ohos_convertxml.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,19 +16,42 @@ import { paramMock } from "../utils" export function mockConvertXml() { - const result = { - ConvertXML: function (...args) { - console.warn("convertXml.ConvertXML interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return ConvertXMLMock; - } - } + const ConvertXMLClass = class ConvertXML { + constructor(...args) { + console.warn("convertXml.ConvertXML.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + this.convert = function (...args) { + console.warn("ConvertXML.convert interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + return paramMock.paramObjectMock; + } + } + }; + const ConvertXMLMock = { - convert: function (...args) { - console.warn("ConvertXML.convert interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramObjectMock; - } - } - return result; + ConvertXML : ConvertXMLClass + }; + + const ConvertOptionsMock = { + trim : '[PC preview] unknow trim', + ignoreDeclaration : '[PC preview] unknow ignoreDeclaration', + ignoreInstruction : '[PC preview] unknow ignoreInstruction', + ignoreAttributes : '[PC preview] unknow ignoreAttributes', + ignoreComment : '[PC preview] unknow ignoreComment', + ignoreCDATA : '[PC preview] unknow ignoreCDATA', + ignoreDoctype : '[PC preview] unknow ignoreDoctype', + ignoreText : '[PC preview] unknow ignoreText', + declarationKey : '[PC preview] unknow declarationKey', + instructionKey : '[PC preview] unknow instructionKey', + attributesKey : '[PC preview] unknow attributesKey', + textKey : '[PC preview] unknow textKey', + cdataKey : '[PC preview] unknow cdataKey', + doctypeKey : '[PC preview] unknow doctypeKey', + commentKey : '[PC preview] unknow commentKey', + parentKey : '[PC preview] unknow parentKey', + typeKey : '[PC preview] unknow typeKey', + nameKey : '[PC preview] unknow nameKey', + elementsKey : '[PC preview] unknow elementsKey' + }; + return ConvertXMLMock; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_process.js b/runtime/main/extend/systemplugin/napi/ohos_process.js index 6438c629..f0bfa030 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_process.js +++ b/runtime/main/extend/systemplugin/napi/ohos_process.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockProcess() { - const result = { + const process = { runCmd: function (...args) { console.warn("process.runCmd interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -155,5 +155,5 @@ export function mockProcess() { " may be different from that on a real device.") } } - return result; + return process; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_uri.js b/runtime/main/extend/systemplugin/napi/ohos_uri.js index a4577161..0af4e601 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_uri.js +++ b/runtime/main/extend/systemplugin/napi/ohos_uri.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockUri() { - const result = { + const uri = { URI: function (...args) { console.warn("uri.URI interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -24,6 +24,10 @@ export function mockUri() { } } const URIMock = { + constructor(...args) { + console.warn("uri.URI.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, toString: function (...args) { console.warn("URI.toString interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -45,7 +49,7 @@ export function mockUri() { return paramMock.paramObjectMock; }, scheme: '[PC preview] unknow scheme', - userinfo: '[PC preview] unknow userinfo', + userInfo: '[PC preview] unknow userInfo', host: '[PC preview] unknow host', port: '[PC preview] unknow port', path: '[PC preview] unknow path', @@ -54,5 +58,5 @@ export function mockUri() { authority: '[PC preview] unknow authority', ssp: '[PC preview] unknow ssp' } - return result; + return uri; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_url.js b/runtime/main/extend/systemplugin/napi/ohos_url.js index a29acc3c..5afb7350 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_url.js +++ b/runtime/main/extend/systemplugin/napi/ohos_url.js @@ -91,28 +91,28 @@ export function mockUrl() { ' may be different from that on a real device.'); return paramMock.paramStringMock; }; - } - [Symbol.iterator]() { - console.warn('url.URLSearchParams.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer' + - ' may be different from that on a real device.'); - let index = 0; - const IteratorTwoStringMock = { - next: () => { - if (index < 1) { - const returnValue = [paramMock.paramStringMock, paramMock.paramStringMock]; - index++; - return { - value: returnValue, - done: false - }; - } else { - return { - done: true - }; + this[Symbol.iterator] = function (...args) { + console.warn('url.URLSearchParams.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + let index = 0; + const IteratorTwoStringMock = { + next: () => { + if (index < 1) { + const returnValue = [paramMock.paramStringMock, paramMock.paramStringMock]; + index++; + return { + value: returnValue, + done: false + }; + } else { + return { + done: true + }; + } } - } - }; - return IteratorTwoStringMock; + }; + return IteratorTwoStringMock; + } } }; const URLClass = class URL { @@ -143,9 +143,9 @@ export function mockUrl() { this.username = '[PC preview] unknow username'; } }; - const result = { + const urlMock = { URLSearchParams: URLSearchParamsClass, URL: URLClass }; - return result; + return urlMock; } diff --git a/runtime/main/extend/systemplugin/napi/ohos_util.js b/runtime/main/extend/systemplugin/napi/ohos_util.js index 1f205b14..a5c451c5 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,7 @@ import { paramMock } from "../utils" export function mockUtil() { - const result = { + const util = { printf: function (...args) { console.warn("util.printf interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -52,9 +52,14 @@ export function mockUtil() { return RationalNumberMock; }, LruBuffer: function (...args) { - console.warn("util.Lrubuffer interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("util.LruBuffer interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return LrubufferMock; + return LruBufferMock; + }, + ScopeComparable: function (...args) { + console.warn("util.Scope interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return ScopeComparableMock; }, Scope: function (...args) { console.warn("util.Scope interface mocked in the Previewer. How this interface works on the Previewer" + @@ -66,16 +71,20 @@ export function mockUtil() { " may be different from that on a real device.") return Base64Mock; }, - Types: function (...args) { - console.warn("util.Types interface mocked in the Previewer. How this interface works on the Previewer" + + types: function (...args) { + console.warn("util.types interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return TypesMock; } } const TextDecoderMock = { - encoding: '[PC preview] unknow encoding', - fatal: '[PC preview] unknow fatal', - ignoreBOM: '[PC preview] unknow ignoreBOM', + encoding: "[PC preview] unknow encoding", + fatal: "[PC preview] unknow fatal", + ignoreBOM: "[PC preview] unknow ignoreBOM", + constructor(...args) { + console.warn("util.TextDecoder.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, decode: function (...args) { console.warn("TextDecoder.decode interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -83,7 +92,11 @@ export function mockUtil() { } } const TextEncoderMock = { - encoding: '[PC preview] unknow encoding', + encoding: "[PC preview] unknow encoding", + constructor(...args) { + console.warn("util.TextEncoder.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, encode: function (...args) { console.warn("TextEncoder.encode interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -97,6 +110,10 @@ export function mockUtil() { } } const RationalNumberMock = { + constructor(...args) { + console.warn("util.RationalNumber.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, createRationalFromString: function (...args) { console.warn("RationalNumber.createRationalFromString​ interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -153,107 +170,122 @@ export function mockUtil() { return paramMock.paramStringMock; } } - const LrubufferMock = { - length: '[PC preview] unknow length', + const LruBufferMock = { + length: "[PC preview] unknow length", + constructor(...args) { + console.warn("util.LruBuffer.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, updateCapacity: function (...args) { - console.warn("Lrubuffer.updateCapacity interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.updateCapacity interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") }, toString: function (...args) { - console.warn("Lrubuffer.toString interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.toString interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramStringMock; }, getCapacity: function (...args) { - console.warn("Lrubuffer.getCapacity interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.getCapacity interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramNumberMock; }, clear: function (...args) { - console.warn("Lrubuffer.clear interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.clear interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") }, getCreateCount: function (...args) { - console.warn("Lrubuffer.getCreateCount interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.getCreateCount interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramNumberMock; }, getMissCount: function (...args) { - console.warn("Lrubuffer.getMissCount interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.getMissCount interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramNumberMock; }, getRemovalCount: function (...args) { - console.warn("Lrubuffer.getRemovalCount interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.getRemovalCount interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramNumberMock; }, getMatchCount: function (...args) { - console.warn("Lrubuffer.getMatchCount interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.getMatchCount interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramNumberMock; }, getPutCount: function (...args) { - console.warn("Lrubuffer.getPutCount interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.getPutCount interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramNumberMock; }, isEmpty: function (...args) { - console.warn("Lrubuffer.isEmpty​ interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.isEmpty​ interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramBooleanMock; }, get: function (...args) { - console.warn("Lrubuffer.get interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.get interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramObjectMock; }, put: function (...args) { - console.warn("Lrubuffer.put interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.put interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramObjectMock; }, values: function (...args) { - console.warn("Lrubuffer.values interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.values interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramObjectMock; }, keys: function (...args) { - console.warn("Lrubuffer.keys​ interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.keys​ interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramObjectMock; }, remove: function (...args) { - console.warn("Lrubuffer.remove interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.remove interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramObjectMock; }, afterRemoval: function (...args) { - console.warn("Lrubuffer.afterRemoval interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.afterRemoval interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") }, contains: function (...args) { - console.warn("Lrubuffer.contains​ interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.contains​ interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramBooleanMock; }, createDefault: function (...args) { - console.warn("Lrubuffer.createDefault​ interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.createDefault​ interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramObjectMock; }, entries: function (...args) { - console.warn("Lrubuffer.entries interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.entries interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramObjectMock; }, [Symbol.iterator]: function (...args) { - console.warn("Lrubuffer.[Symbol.iterator] interface mockecd in the Previewer. How this interface works on the Previewer" + + console.warn("LruBuffer.[Symbol.iterator] interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") return paramMock.paramObjectMock; } } + const ScopeComparableMock = { + compareTo: function(...args) { + console.warn("ScopeComparable.compareTo interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + } + } const ScopeMock = { + constructor(...args) { + console.warn("util.Scope.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, toString: function (...args) { console.warn("Scope.toString interface mockecd in the Previewer. How this interface works on the Previewer" + "may be different from that on a real device.") @@ -311,6 +343,10 @@ export function mockUtil() { } } const Base64Mock = { + constructor(...args) { + console.warn("util.Base64.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, encodeSync: function (...args) { console.warn("Base64.encodeSync interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") @@ -353,201 +389,205 @@ export function mockUtil() { } } const TypesMock = { + constructor(...args) { + console.warn("util.Types.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }, isAnyArrayBuffer: function (...args) { - console.warn("Types.isAnyArrayBuffer interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isAnyArrayBuffer interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isArrayBufferView: function (...args) { - console.warn("Types.isArrayBufferView interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isArrayBufferView interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isArgumentsObject: function (...args) { - console.warn("Types.isArgumentsObject interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isArgumentsObject interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isArrayBuffer: function (...args) { - console.warn("Types.isArrayBuffer interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isArrayBuffer interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isAsyncFunction: function (...args) { - console.warn("Types.isAsyncFunction interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isAsyncFunction interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isBigInt64Array: function (...args) { - console.warn("Types.isBigInt64Array interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isBigInt64Array interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isBigUint64Array: function (...args) { - console.warn("Types.isBigUint64Array interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isBigUint64Array interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isBooleanObject: function (...args) { - console.warn("Types.isBooleanObject interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isBooleanObject interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isBoxedPrimitive: function (...args) { - console.warn("Types.isBoxedPrimitive interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isBoxedPrimitive interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isDataView: function (...args) { - console.warn("Types.isDataView interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isDataView interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isDate: function (...args) { - console.warn("Types.isDate interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isDate interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isExternal: function (...args) { - console.warn("Types.isExternal interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isExternal interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isFloat32Array: function (...args) { - console.warn("Types.isFloat32Array interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isFloat32Array interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isFloat64Array: function (...args) { - console.warn("Types.isFloat64Array interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isFloat64Array interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isGeneratorFunction: function (...args) { - console.warn("Types.isGeneratorFunction interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isGeneratorFunction interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isGeneratorObject: function (...args) { - console.warn("Types.isGeneratorObject interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isGeneratorObject interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isInt8Array: function (...args) { - console.warn("Types.isInt8Array interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isInt8Array interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isInt16Array: function (...args) { - console.warn("Types.isInt16Array interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isInt16Array interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isInt32Array: function (...args) { - console.warn("Types.isInt32Array interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isInt32Array interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isMap: function (...args) { - console.warn("Types.isMap interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isMap interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isMapIterator: function (...args) { - console.warn("Types.isMapIterator interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isMapIterator interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isModuleNamespaceObject: function (...args) { - console.warn("Types.isModuleNamespaceObject interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isModuleNamespaceObject interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isNativeError: function (...args) { - console.warn("Types.isNativeError interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isNativeError interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isNumberObject: function (...args) { - console.warn("Types.isNumberObject interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isNumberObject interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isPromise: function (...args) { - console.warn("Types.isPromise interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isPromise interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isProxy: function (...args) { - console.warn("Types.isProxy interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isProxy interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isRegExp: function (...args) { - console.warn("Types.isRegExp interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isRegExp interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isSet: function (...args) { - console.warn("Types.isSet interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isSet interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isSetIterator: function (...args) { - console.warn("Types.isSetIterator interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isSetIterator interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isSharedArrayBuffer: function (...args) { - console.warn("Types.isSharedArrayBuffer interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isSharedArrayBuffer interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isStringObject: function (...args) { - console.warn("Types.isStringObject interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isStringObject interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isSymbolObject: function (...args) { - console.warn("Types.isSymbolObject interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isSymbolObject interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isTypedArray: function (...args) { - console.warn("Types.isTypedArray interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isTypedArray interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isUint8Array: function (...args) { - console.warn("Types.isUint8Array interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isUint8Array interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isUint8ClampedArray: function (...args) { - console.warn("Types.isUint8ClampedArray interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isUint8ClampedArray interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isUint16Array: function (...args) { - console.warn("Types.isUint16Array interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isUint16Array interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isUint32Array: function (...args) { - console.warn("Types.isUint32Array interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isUint32Array interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isWeakMap: function (...args) { - console.warn("Types.isWeakMap interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isWeakMap interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; }, isWeakSet: function (...args) { - console.warn("Types.isWeakSet interface mocked in the Previewer. How this interface works on the Previewer" + + console.warn("types.isWeakSet interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") return paramMock.paramBooleanMock; } } - return result; + return util; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_worker.js b/runtime/main/extend/systemplugin/napi/ohos_worker.js index c522bd73..f4a06d4e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_worker.js +++ b/runtime/main/extend/systemplugin/napi/ohos_worker.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,71 +16,153 @@ import { paramMock } from "../utils" export function mockWorker() { - const result = { - Worker: function (params) { - console.warn("worker.Worker interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return WorkerMock; + const WorkerOptionsMock = { + type: '[PC preview] unknow type', + name: '[PC preview] unknow name', + shared: '[PC preview] unknow shared' + }; + + const EventMock = { + type: '[PC preview] unknow type', + timeStamp: '[PC preview] unknow timeStamp' + }; + + const ErrorEventMock = { + message: '[PC preview] unknow message', + filename: '[PC preview] unknow filename', + lineno: '[PC preview] unknow lineno', + colno: '[PC preview] unknow colno', + error: '[PC preview] unknow error' + }; + + const MessageEventMock = { + data: '[PC preview] unknow data' + }; + + const PostMessageOptionsMock = { + transfer:'[PC preview] unknow transfer' + }; + + const EventTargetMock = { + addEventListener : function (...args) { + console.warn('PostMessageOptions.addEventListener interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + }, + dispatchEvent : function (...args) { + console.warn('PostMessageOptions.dispatchEvent interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + return paramMock.paramBooleanMock; + }, + removeEventListener : function (...args) { + console.warn("PostMessageOptions.removeEventListener interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }, + removeAllListener : function (...args) { + console.warn("PostMessageOptions.removeAllListener interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); } - } - const WorkerMock = { - postMessage: function (...args) { - console.warn("Worker.postMessage interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - terminate: function (...args) { - console.warn("Worker.terminate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - on: function (...args) { - console.warn("Worker.on interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - once: function (...args) { - console.warn("Worker.once interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - off: function (...args) { - console.warn("Worker.off interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - addEventListener: function (...args) { - console.warn("Worker.addEventListener interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - dispatchEvent: function (...args) { - console.warn("Worker.dispatchEvent interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - removeEventListener: function (...args) { - console.warn("Worker.removeEventListener interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - removeAllListener: function (...args) { - console.warn("Worker.removeAllListener interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - onmessage: function (...args) { - console.warn("Worker.onmessage interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - onmessageerror: function (...agrs) { - console.warn("Worker.onmessageerror interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, + }; + + const WorkerGlobalScopeMock = { + name: '[PC preview] unknow name', onerror: function (...args) { - console.warn("Worker.onerror interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + console.warn("WorkerGlobalScope.onerror interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); }, - onclose: function (...args) { - console.warn("Worker.onclose interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + self: '[PC preview] unknow self' + }; + + const DedicatedWorkerGlobalScopeMock = { + onmessage: function (...args) { + console.warn("DedicatedWorkerGlobalScope.onmessage interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); }, - onexit: function (...args) { - console.warn("Worker.onexit interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + onmessageerror: function (...args) { + console.warn("DedicatedWorkerGlobalScope.onmessageerror interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }, + close : function (...args) { + console.warn("DedicatedWorkerGlobalScope.close interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }, + postMessage : function (...args) { + console.warn("DedicatedWorkerGlobalScope.postMessage interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }, + postMessage : function (...args) { + console.warn("DedicatedWorkerGlobalScope.postMessage interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); } - } - return result; -} \ No newline at end of file + }; + + const WorkerClass = class Worker { + constructor(...args){ + console.warn('Worker.constructor interface mocked in the Previewer. How this interface works on the' + + ' Previewer may be different from that on a real device.'); + this.postMessage = function (...args) { + console.warn("Worker.postMessage interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.terminate = function (...args) { + console.warn("Worker.terminate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.on = function (...args) { + console.warn("Worker.on interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.once = function (...args) { + console.warn("Worker.once interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.off = function (...args) { + console.warn("Worker.off interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.addEventListener = function (...args) { + console.warn("Worker.addEventListener interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + }; + this.dispatchEvent = function (...args) { + console.warn("Worker.dispatchEvent interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + return paramMock.paramBooleanMock; + }; + this.removeEventListener = function (...args) { + console.warn("Worker.removeEventListener interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + }; + this.removeAllListener = function (...args) { + console.warn("Worker.removeAllListener interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + }; + this.onmessage = function (...args) { + console.warn("Worker.onmessage interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.onmessageerror = function (...agrs) { + console.warn("Worker.onmessageerror interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + }; + this.onerror = function (...args) { + console.warn("Worker.onerror interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.onclose = function (...args) { + console.warn("Worker.onclose interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.onexit = function (...args) { + console.warn("Worker.onexit interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + } + } + }; + + const workerMock = { + Worker : WorkerClass, + parentPort : '[PC preview] unknow parentPort' + }; + return workerMock; +} + diff --git a/runtime/main/extend/systemplugin/napi/ohos_xml.js b/runtime/main/extend/systemplugin/napi/ohos_xml.js index 531e9964..84eaec4c 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_xml.js +++ b/runtime/main/extend/systemplugin/napi/ohos_xml.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,67 +14,155 @@ */ import { paramMock } from "../utils" - export function mockXml() { - const result = { - XmlSerializer: function (...args) { - console.warn("xml.XmlSerializer interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return XmlSerializerMock; - }, - XmlPullParser: function (...args) { - console.warn("xml.XmlPullParser interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return XmlPullParserMock; + const XmlSerializerClass = class XmlSerializer { + constructor(...args) { + console.warn("XmlSerializer.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + this.setAttributes = function (...args) { + console.warn("XmlSerializer.setAttributes interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.addEmptyElement = function (...args) { + console.warn("XmlSerializer.addEmptyElement interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.setDeclaration = function (...args) { + console.warn("XmlSerializer.setDeclaration interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.startElement = function (...args) { + console.warn("XmlSerializer.startElement interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.endElement = function (...args) { + console.warn("XmlSerializer.endElement interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.setNamespace = function (...args) { + console.warn("XmlSerializer.setNamespace interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.setComment = function (...args) { + console.warn("XmlSerializer.setCommnet interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.setCData = function (...args) { + console.warn("XmlSerializer.setCData interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.setText = function (...args) { + console.warn("XmlSerializer.setText interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + }; + this.setDocType = function (...args) { + console.warn("XmlSerializer.setDocType interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + } } - } - const XmlSerializerMock = { - setAttributes: function (...args) { - console.warn("XmlSerializer.setAttributes interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - addEmptyElement: function (...args) { - console.warn("XmlSerializer.addEmptyElement interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - setDeclaration: function (...args) { - console.warn("XmlSerializer.setDeclaration interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - startElement: function (...args) { - console.warn("XmlSerializer.startElement interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - endElement: function (...args) { - console.warn("XmlSerializer.endElement interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - setNamespace: function (...args) { - console.warn("XmlSerializer.setNamespace interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - setCommnet: function (...args) { - console.warn("XmlSerializer.setCommnet interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - setCData: function (...args) { - console.warn("XmlSerializer.setCData interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - setText: function (...args) { - console.warn("XmlSerializer.setText interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - setDocType: function (...args) { - console.warn("XmlSerializer.setDocType interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + }; + + const XmlPullParserClass = class XmlPullParser { + constructor(...args) { + console.warn("XmlPullParser.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + this.parse = function (...args) { + console.warn("XmlPullParser.parse interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device."); + } } - } - const XmlPullParserMock = { - parse: function (...args) { - console.warn("XmlPullParser.parse interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") + }; + + const xmlMock = { + XmlSerializer : XmlSerializerClass, + XmlPullParser : XmlPullParserClass, + + EventType : { + START_DOCUMENT: 0, + END_DOCUMENT: 1, + START_TAG: 2, + END_TAG: 3, + TEXT: 4, + CDSECT: 5, + COMMENT: 6, + DOCDECL: 7, + INSTRUCTION: 8, + ENTITY_REFERENCE: 9, + WHITESPACE: 10 } - } - return result; + }; + + const ParseInfoMock = { + getColumnNumber: function () { + console.warn("ParseInfo.getColumnNumber interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getDepth: function () { + console.warn("ParseInfo.getDepth interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getLineNumber: function () { + console.warn("ParseInfo.getLineNumber interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getName: function () { + console.warn("ParseInfo.getName interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + getNamespace: function () { + console.warn("ParseInfo.getNamespace interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + getPrefix: function () { + console.warn("ParseInfo.getPrefix interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + getText: function () { + console.warn("ParseInfo.getText interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + isEmptyElementTag: function () { + console.warn("ParseInfo.isEmptyElementTag interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isWhitespace: function () { + console.warn("ParseInfo.isWhitespace interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + getAttributeCount: function () { + console.warn("ParseInfo.getAttributeCount interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + } + }; + + const ParseOptionsMock = { + supportDoctype: '[PC preview] unknow supportDoctype', + ignoreNameSpace: '[PC preview] unknow ignoreNameSpace', + tagValueCallbackFunction: function(...args) { + console.warn("ParseOptions.tagValueCallbackFunction interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + attributeValueCallbackFunction: function(...args) { + console.warn("ParseOptions.attributeValueCallbackFunction interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + tokenValueCallbackFunction: function(...args) { + console.warn("ParseOptions.tokenValueCallbackFunction interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + } + }; + return xmlMock; }