From 812fed0b9fcc0ecff0c7669b70335ed2d11f49a2 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Tue, 19 Jul 2022 17:22:20 +0800 Subject: [PATCH 1/5] Signed-off-by: lovechinamo Changes to be committed: --- .../systemplugin/napi/ohos_pasteboard.js | 195 ++++++++++++- .../extend/systemplugin/ohos/pasteboard.js | 257 ------------------ 2 files changed, 194 insertions(+), 258 deletions(-) delete mode 100644 runtime/main/extend/systemplugin/ohos/pasteboard.js diff --git a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js index efedd4d0..93649029 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js +++ b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js @@ -21,9 +21,162 @@ export function mockPasteBoard() { console.warn("PasteData.getPrimaryText interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return "[PC Preview] unknow primarytext" + }, + addHtmlRecord: function () { + console.warn("PasteData.addHtmlRecord interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + addWantRecord: function () { + console.warn("PasteData.addWantRecord interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + addRecord: function () { + console.warn("PasteData.addRecord interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + addTextRecord: function () { + console.warn("PasteData.addTextRecord interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + addUriRecord: function () { + console.warn("PasteData.addUriRecord interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + getMimeTypes: function () { + console.warn("PasteData.getMimeTypes interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device."); + let mimeTypes = new Array(); + mimeTypes.push('[PC preview] unknow MIMETYPE_TEXT_HTML'); + mimeTypes.push('[PC preview] unknow MIMETYPE_TEXT_PLAIN'); + return mimeTypes; + }, + getPrimaryHtml: function () { + console.warn("PasteData.getPrimaryHtml interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return "[PC Preview] unknow getPrimaryHtml" + }, + getPrimaryWant: function () { + console.warn("PasteData.getPrimaryWant interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return "[PC Preview] unknow getPrimaryWant" + }, + getPrimaryMimeType: function () { + console.warn("PasteData.getPrimaryMimeType interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return "[PC Preview] unknow getPrimaryMimeType" + }, + getPrimaryUri: function () { + console.warn("PasteData.getPrimaryUri interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return "[PC Preview] unknow getPrimaryUri" + }, + getProperty: function () { + console.warn("PasteData.getProperty interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return PasteDataPropertyMock; + }, + getRecordAt: function () { + console.warn("PasteData.getRecordAt interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return PasteDataRecordMock; + }, + getRecordCount: function () { + console.warn("PasteData.getRecordCount interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return "[PC Preview] unknow getRecordCount" + }, + getTag: function () { + console.warn("PasteData.getTag interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return "[PC Preview] unknow getTag" + }, + hasMimeType: function () { + console.warn("PasteData.hasMimeType interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return "[PC Preview] unknow hasMimeType" + }, + removeRecordAt: function () { + console.warn("PasteData.removeRecordAt interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return "[PC Preview] unknow removeRecordAt" + }, + replaceRecordAt: function () { + console.warn("PasteData.replaceRecordAt interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return "[PC Preview] unknow replaceRecordAt" } } + const PasteDataRecordMock = { + htmlText: '[PC preview] unknow htmlText', + want: '[PC preview] unknow want', + mimeType: '[PC preview] unknow mimeType', + plainText: '[PC preview] unknow plainText', + uri: '[PC preview] unknow uri', + convertToText: function (...args) { + console.warn("PasteDataRecord.convertToText 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); + }) + } + } + } + const PasteDataPropertyMock = { + additions: '[PC preview] unknow additions', + mimeTypes: new Array('[PC preview] unknow MIMETYPE_TEXT_PLAIN'), + tag: '[PC preview] unknow tag', + timestamp: '[PC preview] unknow timestamp', + localOnly: '[PC preview] unknow localOnly', + } const SystemPasteboardMock = { + on: function (...args) { + console.warn("SystemPasteboard.on 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') { + if (args[0] == 'update') { + args[len - 1].call(this); + } + } + }, + off: function (...args) { + console.warn("SystemPasteboard.off 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') { + if (args[0] == 'update') { + args[len - 1].call(this); + } + } + }, + clear: function (...args) { + console.warn("SystemPasteboard.clear 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, reject) => { + resolve(); + }) + } + }, + hasPasteData: function (...args) { + console.warn("SystemPasteboard.hasPasteData 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.paramBooleanMock) + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, getPasteData: function (...args) { console.warn("SystemPasteboard.getPasteData interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") @@ -49,12 +202,52 @@ export function mockPasteBoard() { } } } - const pasteboard = { + global.ohosplugin.pasteboard = { + MAX_RECORD_NUM: '[PC preview] unknow MAX_RECORD_NUM', + MIMETYPE_TEXT_HTML: '[PC preview] unknow MIMETYPE_TEXT_HTML', + MIMETYPE_TEXT_WANT: '[PC preview] unknow MIMETYPE_TEXT_WANT', + MIMETYPE_TEXT_PLAIN: '[PC preview] unknow MIMETYPE_TEXT_PLAIN', + MIMETYPE_TEXT_URI: '[PC preview] unknow MIMETYPE_TEXT_URI', createPlainTextData: function () { console.warn("pasteboard.createPlainTextData interface mocked in the Previewer. How this interface works on" + " the Previewer may be different from that on a real device.") return PasteDataMock; }, + createHtmlData: function () { + console.warn("pasteboard.createHtmlData interface mocked in the Previewer. How this interface works on" + + " the Previewer may be different from that on a real device.") + return PasteDataMock; + }, + createUriData: function () { + console.warn("pasteboard.createUriData interface mocked in the Previewer. How this interface works on" + + " the Previewer may be different from that on a real device.") + return PasteDataMock; + }, + createWantData: function () { + console.warn("pasteboard.createWantData interface mocked in the Previewer. How this interface works on" + + " the Previewer may be different from that on a real device.") + return PasteDataMock; + }, + createHtmlTextRecord: function () { + console.warn("pasteboard.createHtmlTextRecord interface mocked in the Previewer. How this interface works on" + + " the Previewer may be different from that on a real device.") + return PasteDataRecordMock; + }, + createWantRecord: function () { + console.warn("pasteboard.createWantRecord interface mocked in the Previewer. How this interface works on" + + " the Previewer may be different from that on a real device.") + return PasteDataRecordMock; + }, + createUriRecord: function () { + console.warn("pasteboard.createUriRecord interface mocked in the Previewer. How this interface works on" + + " the Previewer may be different from that on a real device.") + return PasteDataRecordMock; + }, + createPlainTextRecord: function () { + console.warn("pasteboard.createPlainTextRecord interface mocked in the Previewer. How this interface works on" + + " the Previewer may be different from that on a real device.") + return PasteDataRecordMock; + }, getSystemPasteboard: function () { console.warn("pasteboard.getSystemPasteboard interface mocked in the Previewer. How this interface works on" + " the Previewer may be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/ohos/pasteboard.js b/runtime/main/extend/systemplugin/ohos/pasteboard.js deleted file mode 100644 index 92111e88..00000000 --- a/runtime/main/extend/systemplugin/ohos/pasteboard.js +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (c) 2021 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { paramMock } from "../utils"; - -export function mockPasteBoard() { - const PasteDataMock = { - getPrimaryText: function () { - console.warn("PasteData.getPrimaryText interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow primarytext" - }, - addHtmlRecord: function () { - console.warn("PasteData.addHtmlRecord interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - addWantRecord: function () { - console.warn("PasteData.addWantRecord interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - addRecord: function () { - console.warn("PasteData.addRecord interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - addTextRecord: function () { - console.warn("PasteData.addTextRecord interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - addUriRecord: function () { - console.warn("PasteData.addUriRecord interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - }, - getMimeTypes: function () { - console.warn("PasteData.getMimeTypes interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device."); - let mimeTypes = new Array(); - mimeTypes.push('[PC preview] unknow MIMETYPE_TEXT_HTML'); - mimeTypes.push('[PC preview] unknow MIMETYPE_TEXT_PLAIN'); - return mimeTypes; - }, - getPrimaryHtml: function () { - console.warn("PasteData.getPrimaryHtml interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getPrimaryHtml" - }, - getPrimaryWant: function () { - console.warn("PasteData.getPrimaryWant interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getPrimaryWant" - }, - getPrimaryMimeType: function () { - console.warn("PasteData.getPrimaryMimeType interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getPrimaryMimeType" - }, - getPrimaryUri: function () { - console.warn("PasteData.getPrimaryUri interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getPrimaryUri" - }, - getProperty: function () { - console.warn("PasteData.getProperty interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return PasteDataPropertyMock; - }, - getRecordAt: function () { - console.warn("PasteData.getRecordAt interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return PasteDataRecordMock; - }, - getRecordCount: function () { - console.warn("PasteData.getRecordCount interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getRecordCount" - }, - getTag: function () { - console.warn("PasteData.getTag interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getTag" - }, - hasMimeType: function () { - console.warn("PasteData.hasMimeType interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow hasMimeType" - }, - removeRecordAt: function () { - console.warn("PasteData.removeRecordAt interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow removeRecordAt" - }, - replaceRecordAt: function () { - console.warn("PasteData.replaceRecordAt interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - return "[PC Preview] unknow replaceRecordAt" - } - } - const PasteDataRecordMock = { - htmlText: '[PC preview] unknow htmlText', - want: '[PC preview] unknow want', - mimeType: '[PC preview] unknow mimeType', - plainText: '[PC preview] unknow plainText', - uri: '[PC preview] unknow uri', - convertToText: function (...args) { - console.warn("PasteDataRecord.convertToText 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); - }) - } - } - } - const PasteDataPropertyMock = { - additions: '[PC preview] unknow additions', - mimeTypes: new Array('[PC preview] unknow MIMETYPE_TEXT_PLAIN'), - tag: '[PC preview] unknow tag', - timestamp: '[PC preview] unknow timestamp', - localOnly: '[PC preview] unknow localOnly', - } - const SystemPasteboardMock = { - on: function (...args) { - console.warn("SystemPasteboard.on 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') { - if (args[0] == 'update') { - args[len - 1].call(this); - } - } - }, - off: function (...args) { - console.warn("SystemPasteboard.off 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') { - if (args[0] == 'update') { - args[len - 1].call(this); - } - } - }, - clear: function (...args) { - console.warn("SystemPasteboard.clear 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, reject) => { - resolve(); - }) - } - }, - hasPasteData: function (...args) { - console.warn("SystemPasteboard.hasPasteData 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.paramBooleanMock) - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - getPasteData: function (...args) { - console.warn("SystemPasteboard.getPasteData 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, PasteDataMock) - } else { - return new Promise((resolve, reject) => { - resolve(PasteDataMock); - }) - } - }, - setPasteData: function (...args) { - console.warn("SystemPasteboard.setPasteData 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, reject) => { - resolve(); - }) - } - } - } - global.ohosplugin.pasteboard = { - MAX_RECORD_NUM: '[PC preview] unknow MAX_RECORD_NUM', - MIMETYPE_TEXT_HTML: '[PC preview] unknow MIMETYPE_TEXT_HTML', - MIMETYPE_TEXT_WANT: '[PC preview] unknow MIMETYPE_TEXT_WANT', - MIMETYPE_TEXT_PLAIN: '[PC preview] unknow MIMETYPE_TEXT_PLAIN', - MIMETYPE_TEXT_URI: '[PC preview] unknow MIMETYPE_TEXT_URI', - createPlainTextData: function () { - console.warn("pasteboard.createPlainTextData interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return PasteDataMock; - }, - createHtmlData: function () { - console.warn("pasteboard.createHtmlData interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return PasteDataMock; - }, - createUriData: function () { - console.warn("pasteboard.createUriData interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return PasteDataMock; - }, - createWantData: function () { - console.warn("pasteboard.createWantData interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return PasteDataMock; - }, - createHtmlTextRecord: function () { - console.warn("pasteboard.createHtmlTextRecord interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return PasteDataRecordMock; - }, - createWantRecord: function () { - console.warn("pasteboard.createWantRecord interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return PasteDataRecordMock; - }, - createUriRecord: function () { - console.warn("pasteboard.createUriRecord interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return PasteDataRecordMock; - }, - createPlainTextRecord: function () { - console.warn("pasteboard.createPlainTextRecord interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return PasteDataRecordMock; - }, - getSystemPasteboard: function () { - console.warn("pasteboard.getSystemPasteboard interface mocked in the Previewer. How this interface works on" + - " the Previewer may be different from that on a real device.") - return SystemPasteboardMock; - } - } -} From 9aa39d14768643f9889a2936efe64e7d8420d2bb Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Wed, 20 Jul 2022 09:56:17 +0800 Subject: [PATCH 2/5] Signed-off-by: lovechinamo Changes to be committed: --- runtime/main/extend/systemplugin/napi/ohos_pasteboard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js index 93649029..bb66e601 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js +++ b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -202,7 +202,7 @@ export function mockPasteBoard() { } } } - global.ohosplugin.pasteboard = { + const pasteboard = { MAX_RECORD_NUM: '[PC preview] unknow MAX_RECORD_NUM', MIMETYPE_TEXT_HTML: '[PC preview] unknow MIMETYPE_TEXT_HTML', MIMETYPE_TEXT_WANT: '[PC preview] unknow MIMETYPE_TEXT_WANT', From 079970ca6d35d7701bda39dd7d31eaa68951c327 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Wed, 20 Jul 2022 16:33:26 +0800 Subject: [PATCH 3/5] Signed-off-by: lovechinamo Changes to be committed: --- .../systemplugin/napi/ohos_pasteboard.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js index bb66e601..ad840fcb 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js +++ b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js @@ -20,7 +20,7 @@ export function mockPasteBoard() { getPrimaryText: function () { console.warn("PasteData.getPrimaryText interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") - return "[PC Preview] unknow primarytext" + return paramMock.paramStringMock }, addHtmlRecord: function () { console.warn("PasteData.addHtmlRecord interface mocked in the Previewer. How this interface works on the" + @@ -48,12 +48,12 @@ export function mockPasteBoard() { let mimeTypes = new Array(); mimeTypes.push('[PC preview] unknow MIMETYPE_TEXT_HTML'); mimeTypes.push('[PC preview] unknow MIMETYPE_TEXT_PLAIN'); - return mimeTypes; + return new Array(paramMock.paramStringMock); }, getPrimaryHtml: function () { console.warn("PasteData.getPrimaryHtml interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getPrimaryHtml" + return paramMock.paramStringMock }, getPrimaryWant: function () { console.warn("PasteData.getPrimaryWant interface mocked in the Previewer. How this interface works on the" + @@ -63,12 +63,12 @@ export function mockPasteBoard() { getPrimaryMimeType: function () { console.warn("PasteData.getPrimaryMimeType interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getPrimaryMimeType" + return paramMock.paramStringMock }, getPrimaryUri: function () { console.warn("PasteData.getPrimaryUri interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getPrimaryUri" + return paramMock.paramStringMock }, getProperty: function () { console.warn("PasteData.getProperty interface mocked in the Previewer. How this interface works on the" + @@ -83,27 +83,27 @@ export function mockPasteBoard() { getRecordCount: function () { console.warn("PasteData.getRecordCount interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getRecordCount" + return paramMock.paramNumberMock }, getTag: function () { console.warn("PasteData.getTag interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") - return "[PC Preview] unknow getTag" + return paramMock.paramStringMock }, hasMimeType: function () { console.warn("PasteData.hasMimeType interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") - return "[PC Preview] unknow hasMimeType" + return paramMock.paramBooleanMock }, removeRecordAt: function () { console.warn("PasteData.removeRecordAt interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") - return "[PC Preview] unknow removeRecordAt" + return paramMock.paramBooleanMock }, replaceRecordAt: function () { console.warn("PasteData.replaceRecordAt interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") - return "[PC Preview] unknow replaceRecordAt" + return paramMock.paramBooleanMock } } const PasteDataRecordMock = { From 4b576b554b5328ac04114ac663879de71e4dd965 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Wed, 20 Jul 2022 19:58:52 +0800 Subject: [PATCH 4/5] Signed-off-by: lovechinamo Changes to be committed: --- .../systemplugin/napi/ohos_pasteboard.js | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js index ad840fcb..391d9df1 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js +++ b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js @@ -22,23 +22,23 @@ export function mockPasteBoard() { " Previewer may be different from that on a real device.") return paramMock.paramStringMock }, - addHtmlRecord: function () { + addHtmlRecord: function (...args) { console.warn("PasteData.addHtmlRecord interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, - addWantRecord: function () { + addWantRecord: function (...args) { console.warn("PasteData.addWantRecord interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, - addRecord: function () { + addRecord: function (...args) { console.warn("PasteData.addRecord interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, - addTextRecord: function () { + addTextRecord: function (...args) { console.warn("PasteData.addTextRecord interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, - addUriRecord: function () { + addUriRecord: function (...args) { console.warn("PasteData.addUriRecord interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") }, @@ -75,7 +75,7 @@ export function mockPasteBoard() { " Previewer may be different from that on a real device.") return PasteDataPropertyMock; }, - getRecordAt: function () { + getRecordAt: function (...args) { console.warn("PasteData.getRecordAt interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return PasteDataRecordMock; @@ -90,17 +90,17 @@ export function mockPasteBoard() { " Previewer may be different from that on a real device.") return paramMock.paramStringMock }, - hasMimeType: function () { + hasMimeType: function (...args) { console.warn("PasteData.hasMimeType interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock }, - removeRecordAt: function () { + removeRecordAt: function (...args) { console.warn("PasteData.removeRecordAt interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock }, - replaceRecordAt: function () { + replaceRecordAt: function (...args) { console.warn("PasteData.replaceRecordAt interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") return paramMock.paramBooleanMock @@ -208,42 +208,42 @@ export function mockPasteBoard() { MIMETYPE_TEXT_WANT: '[PC preview] unknow MIMETYPE_TEXT_WANT', MIMETYPE_TEXT_PLAIN: '[PC preview] unknow MIMETYPE_TEXT_PLAIN', MIMETYPE_TEXT_URI: '[PC preview] unknow MIMETYPE_TEXT_URI', - createPlainTextData: function () { + createPlainTextData: function (...args) { console.warn("pasteboard.createPlainTextData interface mocked in the Previewer. How this interface works on" + " the Previewer may be different from that on a real device.") return PasteDataMock; }, - createHtmlData: function () { + createHtmlData: function (...args) { console.warn("pasteboard.createHtmlData interface mocked in the Previewer. How this interface works on" + " the Previewer may be different from that on a real device.") return PasteDataMock; }, - createUriData: function () { + createUriData: function (...args) { console.warn("pasteboard.createUriData interface mocked in the Previewer. How this interface works on" + " the Previewer may be different from that on a real device.") return PasteDataMock; }, - createWantData: function () { + createWantData: function (...args) { console.warn("pasteboard.createWantData interface mocked in the Previewer. How this interface works on" + " the Previewer may be different from that on a real device.") return PasteDataMock; }, - createHtmlTextRecord: function () { + createHtmlTextRecord: function (...args) { console.warn("pasteboard.createHtmlTextRecord interface mocked in the Previewer. How this interface works on" + " the Previewer may be different from that on a real device.") return PasteDataRecordMock; }, - createWantRecord: function () { + createWantRecord: function (...args) { console.warn("pasteboard.createWantRecord interface mocked in the Previewer. How this interface works on" + " the Previewer may be different from that on a real device.") return PasteDataRecordMock; }, - createUriRecord: function () { + createUriRecord: function (...args) { console.warn("pasteboard.createUriRecord interface mocked in the Previewer. How this interface works on" + " the Previewer may be different from that on a real device.") return PasteDataRecordMock; }, - createPlainTextRecord: function () { + createPlainTextRecord: function (...args) { console.warn("pasteboard.createPlainTextRecord interface mocked in the Previewer. How this interface works on" + " the Previewer may be different from that on a real device.") return PasteDataRecordMock; From 253c0686122eb9639bfd5c0976597e4e792ca724 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Thu, 21 Jul 2022 14:40:25 +0800 Subject: [PATCH 5/5] Signed-off-by: lovechinamo Changes to be committed: --- runtime/main/extend/systemplugin/napi/ohos_pasteboard.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js index 391d9df1..bda091b4 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js +++ b/runtime/main/extend/systemplugin/napi/ohos_pasteboard.js @@ -45,9 +45,6 @@ export function mockPasteBoard() { getMimeTypes: function () { console.warn("PasteData.getMimeTypes interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device."); - let mimeTypes = new Array(); - mimeTypes.push('[PC preview] unknow MIMETYPE_TEXT_HTML'); - mimeTypes.push('[PC preview] unknow MIMETYPE_TEXT_PLAIN'); return new Array(paramMock.paramStringMock); }, getPrimaryHtml: function () {