From 871bbc8d5f4cfffaf9f8fcd8361b020580ed0300 Mon Sep 17 00:00:00 2001 From: du-zhihai Date: Mon, 26 Sep 2022 12:48:59 +0800 Subject: [PATCH] =?UTF-8?q?DMS=E9=94=99=E8=AF=AF=E7=A0=81=E6=95=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: du-zhihai Change-Id: I31e8bd1edc8f35826a4a9894b42edb8a6722a7cc --- .../ohos_continuation_continuationManager.js | 64 +++++++++++++++++-- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_continuation_continuationManager.js b/runtime/main/extend/systemplugin/napi/ohos_continuation_continuationManager.js index dd0925a6..d7b5acfe 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_continuation_continuationManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_continuation_continuationManager.js @@ -16,12 +16,16 @@ import { paramMock } from "../utils" export function mockContinationManager() { + const ContinuationMode = { + COLLABORATION_SINGLE: 0, + COLLABORATION_MULTIPLE: 1 + } const ContinuationExtraParams = { deviceType: [paramMock.paramStringMock], targetBundle: '[PC preview] unknown targetBundle', description: '[PC preview] unknown description', filter: '[PC preview] unknown filter', - continuationMode: continuationManager.ContinuationMode, + continuationMode: ContinuationMode, authInfo: '[PC preview] unknown authInfo' } @@ -32,6 +36,7 @@ export function mockContinationManager() { } const continuationManager = { + ContinuationMode, DeviceConnectState: { IDLE: 0, CONNECTING: 1, @@ -39,11 +44,6 @@ export function mockContinationManager() { DISCONNECTING: 3 }, - ContinuationMode: { - COLLABORATION_SINGLE: 0, - COLLABORATION_MULTIPLE: 1 - }, - on: function (...args) { console.warn("continuationManager.on interface mocked in the Previewer. How this interface works on the Previewer may" + " be different from that on a real device.") @@ -113,6 +113,58 @@ export function mockContinationManager() { }); } }, + + registerContinuation: function (...args) { + console.warn("continuationManager.registerContinuation 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) => { + resolve(paramMock.paramNumberMock); + }); + } + }, + + unregisterContinuation: function (...args) { + console.warn("continuationManager.unregisterContinuation 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); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + + updateContinuationState: function (...args) { + console.warn("continuationManager.updateContinuationState 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); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, + + startContinuationDeviceManager: function (...args) { + console.warn("continuationManager.startContinuationDeviceManager 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); + } else { + return new Promise((resolve) => { + resolve(); + }); + } + }, } return continuationManager } \ No newline at end of file