From d299454a08eb095700cd3d17b1ea5fc3a3f7af23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=84=E5=A4=A9=E4=BD=91?= <1462027985@qq.com> Date: Wed, 29 Dec 2021 07:11:38 +0000 Subject: [PATCH 1/3] =?UTF-8?q?update=20runtime/main/extend/systemplugin/o?= =?UTF-8?q?hos/systemTime.js.=20IssueNo:=E7=B3=BB=E7=BB=9F=E6=97=B6?= =?UTF-8?q?=E9=97=B4js=20api8=20mock=E5=90=88=E5=85=A5=20Description:add?= =?UTF-8?q?=20systemTime=20js=20api8=20mock=20Sig:jsframework=20Feature=20?= =?UTF-8?q?or=20Bugfix:Feature=20Binary=20Source:No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangdengjia wangdengjia@huawei.com --- .../extend/systemplugin/ohos/systemTime.js | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/runtime/main/extend/systemplugin/ohos/systemTime.js b/runtime/main/extend/systemplugin/ohos/systemTime.js index 0afd3d84..9cc6eb8f 100644 --- a/runtime/main/extend/systemplugin/ohos/systemTime.js +++ b/runtime/main/extend/systemplugin/ohos/systemTime.js @@ -14,6 +14,78 @@ export function mockSystemTime() { }) } }, + getCurrentTime: function (...args) { + console.warn("systemTime.getCurrentTime interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock,paramMock.paramNumberMock) + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + getCurrentTimeNs: function (...args) { + console.warn("systemTime.getCurrentTimeNs interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock,paramMock.paramNumberMock) + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + getRealActiveTime: function (...args) { + console.warn("systemTime.getRealActiveTime interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock,paramMock.paramNumberMock) + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + getRealActiveTimeNs: function (...args) { + console.warn("systemTime.getRealActiveTimeNs interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock,paramMock.paramNumberMock) + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + getRealTime: function (...args) { + console.warn("systemTime.getRealTime interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock,paramMock.paramNumberMock) + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + getRealTimeNs: function (...args) { + console.warn("systemTime.getRealTimeNs interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock,paramMock.paramNumberMock) + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, setDate: function (...args) { console.warn("systemTime.setDate interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") @@ -26,6 +98,18 @@ export function mockSystemTime() { }) } }, + getDate: function (...args) { + console.warn("systemTime.getDate interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock,paramMock.paramObjectMock) + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramObjectMock); + }) + } + }, setTimezone: function (...args) { console.warn("systemTime.setTimezone interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") @@ -37,6 +121,18 @@ export function mockSystemTime() { resolve(); }) } + }, + getTimeZone: function (...args) { + console.warn("systemTime.getTimeZone interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock,paramMock.paramStringMock) + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } } } } \ No newline at end of file -- Gitee From 760ba64d1b5c4f423b6718572dcacf571d91f488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=84=E5=A4=A9=E4=BD=91?= <1462027985@qq.com> Date: Wed, 29 Dec 2021 07:24:22 +0000 Subject: [PATCH 2/3] =?UTF-8?q?update=20runtime/main/extend/systemplugin/o?= =?UTF-8?q?hos/systemTime.js.=20IssueNo:=E7=B3=BB=E7=BB=9F=E6=97=B6?= =?UTF-8?q?=E9=97=B4js=20api8=20mock=E5=90=88=E5=85=A5=20Description:add?= =?UTF-8?q?=20systemTime=20js=20api=20mock=20Sig:jsframework=20Feature=20o?= =?UTF-8?q?r=20Bugfix:Feature=20Binary=20Source:No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhuangtianyou 1462027985@qq.com --- .../main/extend/systemplugin/ohos/systemTime.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/runtime/main/extend/systemplugin/ohos/systemTime.js b/runtime/main/extend/systemplugin/ohos/systemTime.js index 9cc6eb8f..8a0561e1 100644 --- a/runtime/main/extend/systemplugin/ohos/systemTime.js +++ b/runtime/main/extend/systemplugin/ohos/systemTime.js @@ -19,7 +19,7 @@ export function mockSystemTime() { " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock,paramMock.paramNumberMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) } else { return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); @@ -31,7 +31,7 @@ export function mockSystemTime() { " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock,paramMock.paramNumberMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) } else { return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); @@ -43,7 +43,7 @@ export function mockSystemTime() { " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock,paramMock.paramNumberMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) } else { return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); @@ -55,7 +55,7 @@ export function mockSystemTime() { " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock,paramMock.paramNumberMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) } else { return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); @@ -67,7 +67,7 @@ export function mockSystemTime() { " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock,paramMock.paramNumberMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) } else { return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); @@ -79,7 +79,7 @@ export function mockSystemTime() { " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock,paramMock.paramNumberMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) } else { return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); @@ -103,7 +103,7 @@ export function mockSystemTime() { " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock,paramMock.paramObjectMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock) } else { return new Promise((resolve, reject) => { resolve(paramMock.paramObjectMock); @@ -127,7 +127,7 @@ export function mockSystemTime() { " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock,paramMock.paramStringMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock) } else { return new Promise((resolve, reject) => { resolve(paramMock.paramStringMock); -- Gitee From 1c2655d8db3947eac6338ccb44412a9fe9c86dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=84=E5=A4=A9=E4=BD=91?= <1462027985@qq.com> Date: Wed, 29 Dec 2021 08:42:40 +0000 Subject: [PATCH 3/3] update runtime/main/extend/systemplugin/ohos/systemTime.js. Signed-off-by: zhuangtianyou --- .../extend/systemplugin/ohos/systemTime.js | 114 +++++++++--------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/runtime/main/extend/systemplugin/ohos/systemTime.js b/runtime/main/extend/systemplugin/ohos/systemTime.js index 8a0561e1..2af25f00 100644 --- a/runtime/main/extend/systemplugin/ohos/systemTime.js +++ b/runtime/main/extend/systemplugin/ohos/systemTime.js @@ -3,136 +3,136 @@ import {paramMock} from "../utils" export function mockSystemTime() { global.ohosplugin.systemTime = { setTime: function (...args) { - console.warn("systemTime.setTime interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length + console.warn('systemTime.setTime interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.'); + const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock) + args[len - 1].call(this, paramMock.businessErrorMock); } else { return new Promise((resolve, reject) => { resolve(); - }) + }); } }, getCurrentTime: function (...args) { - console.warn("systemTime.getCurrentTime interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length + console.warn('systemTime.getCurrentTime interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.'); + const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); - }) + }); } }, getCurrentTimeNs: function (...args) { - console.warn("systemTime.getCurrentTimeNs interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length + console.warn('systemTime.getCurrentTimeNs interface mocked in the Previewer.' + + 'How this interface works on the Previewer may be different from that on a real device.'); + const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); - }) + }); } }, getRealActiveTime: function (...args) { - console.warn("systemTime.getRealActiveTime interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length + console.warn('systemTime.getRealActiveTime interface mocked in the Previewer.' + + 'How this interface works on the Previewer may be different from that on a real device.'); + const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); - }) + }); } }, getRealActiveTimeNs: function (...args) { - console.warn("systemTime.getRealActiveTimeNs interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length + console.warn('systemTime.getRealActiveTimeNs interface mocked in the Previewer.' + + 'How this interface works on the Previewer may be different from that on a real device.'); + const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); - }) + }); } }, getRealTime: function (...args) { - console.warn("systemTime.getRealTime interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length + console.warn('systemTime.getRealTime interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.'); + const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); - }) + }); } }, getRealTimeNs: function (...args) { - console.warn("systemTime.getRealTimeNs interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length + console.warn('systemTime.getRealTimeNs interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.'); + const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramNumberMock); - }) + }); } }, setDate: function (...args) { - console.warn("systemTime.setDate interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length + console.warn('systemTime.setDate interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.'); + const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock) + args[len - 1].call(this, paramMock.businessErrorMock); } else { return new Promise((resolve, reject) => { resolve(); - }) + }); } }, getDate: function (...args) { - console.warn("systemTime.getDate interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length + console.warn('systemTime.getDate interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.'); + const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramObjectMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramObjectMock); - }) + }); } }, setTimezone: function (...args) { - console.warn("systemTime.setTimezone interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length + console.warn('systemTime.setTimezone interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.'); + const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock) + args[len - 1].call(this, paramMock.businessErrorMock); } else { return new Promise((resolve, reject) => { resolve(); - }) + }); } }, getTimeZone: function (...args) { - console.warn("systemTime.getTimeZone interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length + console.warn('systemTime.getTimeZone interface mocked in the Previewer. How this interface works on the' + + 'Previewer may be different from that on a real device.'); + const len = args.length; if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock) + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); } else { return new Promise((resolve, reject) => { resolve(paramMock.paramStringMock); - }) + }); } - } - } + }, + }; } \ No newline at end of file -- Gitee