From 5df324c92cd42c3b8e26f03e838e4dd9c1dd2982 Mon Sep 17 00:00:00 2001 From: zhangchunyan Date: Wed, 29 Dec 2021 15:16:53 +0800 Subject: [PATCH 1/9] add uri Signed-off-by: zhangchunyan On branch master Your branch is up to date with 'origin/master'. --- .../main/extend/systemplugin/napi/index.js | 3 ++ runtime/main/extend/systemplugin/napi/uri.js | 43 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 runtime/main/extend/systemplugin/napi/uri.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 498374d6..9a7d6d58 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -35,6 +35,7 @@ import { mockWifi } from './wifi' import { mockUsb } from './usb' import { mockBundle } from './bundle' import { mockInnerBundle } from './innerBundleManager' +import { mockUri } from './uri' export function mockRequireNapiFun() { global.requireNapi = function (...args) { @@ -113,6 +114,8 @@ export function mockRequireNapiFun() { return mockBundle(); case "bundle.innerBundleManager": return mockInnerBundle(); + case "uri": + return mockUri(); default: return global.requireNapiPreview(...args); } diff --git a/runtime/main/extend/systemplugin/napi/uri.js b/runtime/main/extend/systemplugin/napi/uri.js new file mode 100644 index 00000000..8ac32d3b --- /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; +} -- Gitee From 827748bed9ad4a7d88379dfd5c168f44201221d6 Mon Sep 17 00:00:00 2001 From: zhangchunyan Date: Wed, 29 Dec 2021 15:36:36 +0800 Subject: [PATCH 2/9] add xml Signed-off-by: zhangchunyan On branch master Your branch is up to date with 'origin/master'. --- .../main/extend/systemplugin/napi/index.js | 3 + runtime/main/extend/systemplugin/napi/xml.js | 73 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 runtime/main/extend/systemplugin/napi/xml.js diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 9a7d6d58..2b312cb2 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -36,6 +36,7 @@ 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) { @@ -116,6 +117,8 @@ export function mockRequireNapiFun() { return mockInnerBundle(); case "uri": return mockUri(); + case "xml": + return mockXml(); default: return global.requireNapiPreview(...args); } diff --git a/runtime/main/extend/systemplugin/napi/xml.js b/runtime/main/extend/systemplugin/napi/xml.js new file mode 100644 index 00000000..43b2afa5 --- /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; +} -- Gitee From 67fa3ac162936b66a6188756155b1ecf2411d1db Mon Sep 17 00:00:00 2001 From: zhangchunyan Date: Wed, 29 Dec 2021 16:05:20 +0800 Subject: [PATCH 3/9] edit process Signed-off-by: zhangchunyan On branch master Your branch is up to date with 'origin/master'. --- .../main/extend/systemplugin/napi/process.js | 66 ++++++++++++++++--- 1 file changed, 58 insertions(+), 8 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/process.js b/runtime/main/extend/systemplugin/napi/process.js index e0ad70db..2bcff88f 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', -- Gitee From c63290ae338cac628f6eed4332bd96bf17f47234 Mon Sep 17 00:00:00 2001 From: zhangchunyan Date: Wed, 29 Dec 2021 16:29:34 +0800 Subject: [PATCH 4/9] add util rationalnumber Signed-off-by: zhangchunyan On branch master Your branch is up to date with 'origin/master'. --- runtime/main/extend/systemplugin/napi/util.js | 97 ++++++++++++++----- 1 file changed, 71 insertions(+), 26 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/util.js b/runtime/main/extend/systemplugin/napi/util.js index 22c40ca8..35945aba 100644 --- a/runtime/main/extend/systemplugin/napi/util.js +++ b/runtime/main/extend/systemplugin/napi/util.js @@ -15,28 +15,11 @@ export function mockUtil() { callbackWrapper: function(...args) { console.warn('util.callbackWrapper interface mocked in the Previewer. How this interface works on the Previewer' + ' may be different from that on a real device.'); - return function(...args) { - console.warn('util.callbackWrapper.return function interface mocked in the Previewer. How this interface' + - ' works on the Previewer may be different from that on a real device.'); - }; }, - promiseWrapper: function(func) { + promiseWrapper: function(...args) { console.warn('util.promiseWrapper interface mocked in the Previewer. How this interface works on the Previewer' + ' may be different from that on a real device.'); - if (typeof func === 'function') { - return function(...args) { - return new Promise((resolve, reject) => { - const callback = function(err, ...values) { - if (err) { - reject(err); - } else { - resolve(values); - } - }; - func.apply(null, [...args, callback]); - }); - }; - } + return paramMock.paramObjectMock; }, TextDecoder: function(...args) { console.warn('util.TextDecoder interface mocked in the Previewer. How this interface works on the Previewer' + @@ -47,18 +30,23 @@ 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 = { - encoding: '[PC preview] unknow encoding', - fatal: '[PC preview] unknow fatal', - ignoreBOM: '[PC preview] unknow ignoreBOM', + const TextDecoderMock = { + encoding: '[PC preview] unknow encoding', + fatal: '[PC preview] unknow fatal', + ignoreBOM: '[PC preview] unknow ignoreBOM', 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.'); return paramMock.paramStringMock; - } - }; + } + }; const TextEncoderMock = { encoding: '[PC preview] unknow encoding', encode: function(...args) { @@ -73,5 +61,62 @@ export function mockUtil() { 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; } -- Gitee From c0552487c0fa902157a11b08315be18d8e52df5c Mon Sep 17 00:00:00 2001 From: zhangchunyan Date: Wed, 29 Dec 2021 16:33:29 +0800 Subject: [PATCH 5/9] add util rationalnumber2 Signed-off-by: zhangchunyan On branch master Your branch is up to date with 'origin/master'. --- runtime/main/extend/systemplugin/napi/util.js | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/util.js b/runtime/main/extend/systemplugin/napi/util.js index 35945aba..5115d062 100644 --- a/runtime/main/extend/systemplugin/napi/util.js +++ b/runtime/main/extend/systemplugin/napi/util.js @@ -37,16 +37,17 @@ export function mockUtil() { return RationalNumberMock; } }; - const TextDecoderMock = { - encoding: '[PC preview] unknow encoding', - fatal: '[PC preview] unknow fatal', - ignoreBOM: '[PC preview] unknow ignoreBOM', - 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.'); - return paramMock.paramStringMock; - } - }; + const TextDecoderMock = { + encoding: '[PC preview] unknow encoding', + fatal: '[PC preview] unknow fatal', + ignoreBOM: '[PC preview] unknow ignoreBOM', + 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.'); + return paramMock.paramStringMock; + } + }; + const TextEncoderMock = { encoding: '[PC preview] unknow encoding', encode: function(...args) { -- Gitee From c793dc838066c879345c5fb93d6fb3fd36740f78 Mon Sep 17 00:00:00 2001 From: zhangchunyan Date: Wed, 29 Dec 2021 16:50:03 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E5=A4=8D=E5=8E=9Futil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangchunyan On branch master Your branch is up to date with 'origin/master'. --- runtime/main/extend/systemplugin/napi/util.js | 104 +++++------------- 1 file changed, 29 insertions(+), 75 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/util.js b/runtime/main/extend/systemplugin/napi/util.js index 5115d062..22c40ca8 100644 --- a/runtime/main/extend/systemplugin/napi/util.js +++ b/runtime/main/extend/systemplugin/napi/util.js @@ -15,11 +15,28 @@ export function mockUtil() { callbackWrapper: function(...args) { console.warn('util.callbackWrapper interface mocked in the Previewer. How this interface works on the Previewer' + ' may be different from that on a real device.'); + return function(...args) { + console.warn('util.callbackWrapper.return function interface mocked in the Previewer. How this interface' + + ' works on the Previewer may be different from that on a real device.'); + }; }, - promiseWrapper: function(...args) { + promiseWrapper: function(func) { console.warn('util.promiseWrapper interface mocked in the Previewer. How this interface works on the Previewer' + ' may be different from that on a real device.'); - return paramMock.paramObjectMock; + if (typeof func === 'function') { + return function(...args) { + return new Promise((resolve, reject) => { + const callback = function(err, ...values) { + if (err) { + reject(err); + } else { + resolve(values); + } + }; + func.apply(null, [...args, callback]); + }); + }; + } }, TextDecoder: function(...args) { console.warn('util.TextDecoder interface mocked in the Previewer. How this interface works on the Previewer' + @@ -30,24 +47,18 @@ 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 = { - encoding: '[PC preview] unknow encoding', - fatal: '[PC preview] unknow fatal', - ignoreBOM: '[PC preview] unknow ignoreBOM', - 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.'); - return paramMock.paramStringMock; - } - }; - + encoding: '[PC preview] unknow encoding', + fatal: '[PC preview] unknow fatal', + ignoreBOM: '[PC preview] unknow ignoreBOM', + 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.'); + return paramMock.paramStringMock; + } + }; const TextEncoderMock = { encoding: '[PC preview] unknow encoding', encode: function(...args) { @@ -62,62 +73,5 @@ export function mockUtil() { 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; } -- Gitee From 5450f3fd5b465cb474997809b3e91fc0d0460419 Mon Sep 17 00:00:00 2001 From: zhangchunyan Date: Wed, 29 Dec 2021 16:53:26 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E5=A4=8D=E5=8E=9Futil2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangchunyan On branch master Your branch is up to date with 'origin/master'. --- runtime/main/extend/systemplugin/napi/util.js | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/main/extend/systemplugin/napi/util.js b/runtime/main/extend/systemplugin/napi/util.js index 22c40ca8..25f1f143 100644 --- a/runtime/main/extend/systemplugin/napi/util.js +++ b/runtime/main/extend/systemplugin/napi/util.js @@ -75,3 +75,4 @@ export function mockUtil() { }; return result; } +// util -- Gitee From 65f116097aee5f48a0bad3fc3df0bd7c8bbda4d4 Mon Sep 17 00:00:00 2001 From: zhangchunyan Date: Wed, 29 Dec 2021 17:47:14 +0800 Subject: [PATCH 8/9] add util rational1 Signed-off-by: zhangchunyan On branch master Your branch is up to date with 'origin/master'. --- runtime/main/extend/systemplugin/napi/util.js | 64 ++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/runtime/main/extend/systemplugin/napi/util.js b/runtime/main/extend/systemplugin/napi/util.js index 25f1f143..1fe8dd95 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,8 +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 -- Gitee From bb7eb47aa2e28e28939f245ea1d834ed5072a60c Mon Sep 17 00:00:00 2001 From: zhangchunyan Date: Wed, 29 Dec 2021 18:09:55 +0800 Subject: [PATCH 9/9] add util rational2 Signed-off-by: zhangchunyan On branch master Your branch is up to date with 'origin/master'. --- runtime/main/extend/systemplugin/napi/util.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/util.js b/runtime/main/extend/systemplugin/napi/util.js index 1fe8dd95..11e03884 100644 --- a/runtime/main/extend/systemplugin/napi/util.js +++ b/runtime/main/extend/systemplugin/napi/util.js @@ -49,9 +49,9 @@ export function mockUtil() { 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; + 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 = { @@ -80,17 +80,17 @@ export function mockUtil() { }; const RationalNumberMock = { createRationalFromString: function (...args) { - console.warn("RationalNumber.createRationalFromString? interface mocked in the Previewer. How this interface works on the Previewer" + + 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" + + 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" + + 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; }, @@ -100,32 +100,32 @@ export function mockUtil() { return paramMock.paramNumberMock; }, getCommonDivisor: function (...args) { - console.warn("RationalNumber.getCommonDivisor? interface mocked in the Previewer. How this interface works on the Previewer" + + 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" + + 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" + + 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" + + 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" + + 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" + + 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; }, -- Gitee