diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 498374d68087008224c6ae9a3ad4d20c624262b3..2b312cb2708f678656b9a020819648f3baee21a5 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -35,6 +35,8 @@ import { mockWifi } from './wifi' import { mockUsb } from './usb' import { mockBundle } from './bundle' import { mockInnerBundle } from './innerBundleManager' +import { mockUri } from './uri' +import { mockXml } from './xml' export function mockRequireNapiFun() { global.requireNapi = function (...args) { @@ -113,6 +115,10 @@ export function mockRequireNapiFun() { return mockBundle(); case "bundle.innerBundleManager": return mockInnerBundle(); + case "uri": + return mockUri(); + case "xml": + return mockXml(); default: return global.requireNapiPreview(...args); } diff --git a/runtime/main/extend/systemplugin/napi/process.js b/runtime/main/extend/systemplugin/napi/process.js index e0ad70db06eef35bb7ccada69c6a19419222bba1..2bcff88fe5b859032224d639c4baeeed03d0e4ef 100644 --- a/runtime/main/extend/systemplugin/napi/process.js +++ b/runtime/main/extend/systemplugin/napi/process.js @@ -43,14 +43,64 @@ export function mockProcess() { " may be different from that on a real device.") return paramMock.paramBooleanMock; }, - getEgid: '[PC preview] unknow getEgid', - getEuid: '[PC preview] unknow getEuid', - getGid: '[PC preview] unknow getGid', - getUid: '[PC preview] unknow getUid', - getGroups: '[PC preview] unknow getGroups', - getPid: '[PC preview] unknow getPid', - getPpid: '[PC preview] unknow getPpid', - + getStartRealtime: function(...args) { + console.warn("process.getStartRealtime interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getPastCputime: function(...args) { + console.warn("process.getPastCputime interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getAvailableCores: function(...args) { + console.warn("process.getAvailableCores interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramArrayMock; + }, + isIsolatedProcess: function(...args) { + console.warn("process.isIsolatedProcess interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + is64Bit: function(...args) { + console.warn("process.is64Bit interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isAppUid: function(...args) { + console.warn("process.isAppUid interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + getUidForName: function(...args) { + console.warn("process.getUidForName interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getThreadPriority: function(...args) { + console.warn("process.getThreadPriority interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getSystemConfig: function(...args) { + console.warn("process.getSystemConfig interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getEnvironmentVar: function(...args) { + console.warn("process.getEnvironmentVar interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + egid: '[PC preview] unknow egid', + euid: '[PC preview] unknow euid', + gid: '[PC preview] unknow gid', + uid: '[PC preview] unknow uid', + groups: '[PC preview] unknow groups', + pid: '[PC preview] unknow pid', + ppid: '[PC preview] unknow ppid', + tid: '[PC preview] unknow tid', } const ChildProcessMock = { pid: '[PC preview] unknow pid', diff --git a/runtime/main/extend/systemplugin/napi/uri.js b/runtime/main/extend/systemplugin/napi/uri.js new file mode 100644 index 0000000000000000000000000000000000000000..8ac32d3b1e929520dceb99e3e80d45b3fe4c1b8e --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/uri.js @@ -0,0 +1,43 @@ +import { paramMock } from "../utils" + +export function mockUri() { + const result = { + 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.") + return URIMock; + } + } + const URIMock = { + 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.") + return paramMock.paramStringMock; + }, + equals: function(...args) { + console.warn("URI.equals interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + checkIsAbsolute: function(...args) { + console.warn("URI.checkIsAbsolute interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + normalize: function(...args) { + console.warn("URI.normalize interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramObjectMock; + }, + scheme: '[PC preview] unknow scheme', + userinfo: '[PC preview] unknow userinfo', + host: '[PC preview] unknow host', + port: '[PC preview] unknow port', + path: '[PC preview] unknow path', + query: '[PC preview] unknow query', + fragment: '[PC preview] unknow fragment', + authority: '[PC preview] unknow authority', + ssp: '[PC preview] unknow ssp' + } + return result; +} diff --git a/runtime/main/extend/systemplugin/napi/util.js b/runtime/main/extend/systemplugin/napi/util.js index 22c40ca8cacb3b020bf257cbd961b553b221a110..11e038844728bc26ebf04a30810fb6c693404e0c 100644 --- a/runtime/main/extend/systemplugin/napi/util.js +++ b/runtime/main/extend/systemplugin/napi/util.js @@ -47,6 +47,11 @@ export function mockUtil() { console.warn('util.TextEncoder interface mocked in the Previewer. How this interface works on the Previewer' + ' may be different from that on a real device.'); return TextEncoderMock; + }, + RationalNumber: function (...args) { + console.warn('util.RationalNumber interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.') + return RationalNumberMock; } }; const TextDecoderMock = { @@ -71,7 +76,65 @@ export function mockUtil() { console.warn('TextEncoder.encodeInto 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 RationalNumberMock = { + 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.") + return paramMock.paramObjectMock; + }, + compareTo: function (...args) { + console.warn("RationalNumber.compareTo interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + equals: function (...args) { + console.warn("RationalNumber.equals interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + valueOf: function (...args) { + console.warn("RationalNumber.valueOf interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getCommonDivisor: function (...args) { + console.warn("RationalNumber.getCommonDivisor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getDenominator: function (...args) { + console.warn("RationalNumber.getDenominator interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getNumerator: function (...args) { + console.warn("RationalNumber.getNumerator interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + isFinite: function (...args) { + console.warn("RationalNumber.isFinite interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isNaN: function (...args) { + console.warn("RationalNumber.isNaN interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isZero: function (...args) { + console.warn("RationalNumber.isZero interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + toString: function (...args) { + console.warn("RationalNumber.toString interface mocked in the Previewer. How this interface works on the Previewer" + + "may be different from that on a real device.") + return paramMock.paramStringMock; + } +}, return result; } +// util diff --git a/runtime/main/extend/systemplugin/napi/xml.js b/runtime/main/extend/systemplugin/napi/xml.js new file mode 100644 index 0000000000000000000000000000000000000000..43b2afa5c33bc17ac4c24389edbfe336d18b76db --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/xml.js @@ -0,0 +1,73 @@ +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; + }, + ConvertXML: function(...args) { + console.warn("converxml.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 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.") + }, + 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 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 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; +}