From c720b028c2cf11ad146624bf06b70dea6b8468c3 Mon Sep 17 00:00:00 2001 From: liu-ganlin Date: Fri, 18 Mar 2022 16:58:43 +0800 Subject: [PATCH] add container mock Signed-off-by: liu-ganlin --- .../extend/systemplugin/napi/arraylist.js | 148 ++++++++++++++ .../main/extend/systemplugin/napi/deque.js | 92 +++++++++ .../main/extend/systemplugin/napi/hashmap.js | 135 +++++++++++++ .../main/extend/systemplugin/napi/hashset.js | 103 ++++++++++ .../main/extend/systemplugin/napi/index.js | 42 ++++ .../systemplugin/napi/lightweightmap.js | 172 ++++++++++++++++ .../systemplugin/napi/lightweightset.js | 153 ++++++++++++++ .../extend/systemplugin/napi/linkedlist.js | 152 ++++++++++++++ runtime/main/extend/systemplugin/napi/list.js | 152 ++++++++++++++ .../extend/systemplugin/napi/plainarray.js | 134 ++++++++++++ .../main/extend/systemplugin/napi/queue.js | 74 +++++++ .../main/extend/systemplugin/napi/stack.js | 84 ++++++++ .../main/extend/systemplugin/napi/treemap.js | 153 ++++++++++++++ .../main/extend/systemplugin/napi/treeset.js | 134 ++++++++++++ .../main/extend/systemplugin/napi/vector.js | 190 ++++++++++++++++++ 15 files changed, 1918 insertions(+) create mode 100644 runtime/main/extend/systemplugin/napi/arraylist.js create mode 100644 runtime/main/extend/systemplugin/napi/deque.js create mode 100644 runtime/main/extend/systemplugin/napi/hashmap.js create mode 100644 runtime/main/extend/systemplugin/napi/hashset.js create mode 100644 runtime/main/extend/systemplugin/napi/lightweightmap.js create mode 100644 runtime/main/extend/systemplugin/napi/lightweightset.js create mode 100644 runtime/main/extend/systemplugin/napi/linkedlist.js create mode 100644 runtime/main/extend/systemplugin/napi/list.js create mode 100644 runtime/main/extend/systemplugin/napi/plainarray.js create mode 100644 runtime/main/extend/systemplugin/napi/queue.js create mode 100644 runtime/main/extend/systemplugin/napi/stack.js create mode 100644 runtime/main/extend/systemplugin/napi/treemap.js create mode 100644 runtime/main/extend/systemplugin/napi/treeset.js create mode 100644 runtime/main/extend/systemplugin/napi/vector.js diff --git a/runtime/main/extend/systemplugin/napi/arraylist.js b/runtime/main/extend/systemplugin/napi/arraylist.js new file mode 100644 index 00000000..2aa9eccc --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/arraylist.js @@ -0,0 +1,148 @@ +/* + * Copyright (c) 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 + * + * 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 mockArrayList() { + const paramArrayList = { + paramAnyMock : '[PC Preview] unknow any', + paramArrayListMock : '[PC Preview] unknow ArrayList' + } + const ArrayListClass = class ArrayList { + constructor(...args) { + console.warn('util.ArrayList interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + this.length = '[PC preview] unknow length'; + this.add = function (...args) { + console.warn("ArrayList.add interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.insert = function (...args) { + console.warn("ArrayList.insert interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.has = function (...args) { + console.warn("ArrayList.has interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.getIndexOf = function (...args) { + console.warn("ArrayList.getIndexOf interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.removeByIndex = function (...args) { + console.warn("ArrayList.removeByIndex interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramArrayList.paramAnyMock; + }; + this.remove = function (...args) { + console.warn("ArrayList.remove interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.getLastIndexOf = function (...args) { + console.warn("ArrayList.getLastIndexOf interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.removeByRange = function (...args) { + console.warn("ArrayList.removeByRange interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.replaceAllElements = function (...args) { + console.warn("ArrayList.replaceAllElements interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (typeof args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock, paramArrayList.paramAnyMock) + } + }; + this.forEach = function (...args) { + console.warn("ArrayList.forEach interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (typeof args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock) + } + }; + this.sort = function (...args) { + console.warn("ArrayList.sort interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (typeof args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) + } + }; + this.subArrayList = function (...args) { + console.warn("ArrayList.subArrayList interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramArrayList.paramArrayListMock; + }; + this.clear = function (...args) { + console.warn("ArrayList.clear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.clone = function (...args) { + console.warn("ArrayList.clone interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramArrayList.paramArrayListMock; + }; + this.getCapacity = function (...args) { + console.warn("ArrayList.getCapacity interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.convertToArray = function (...args) { + console.warn("ArrayList.convertToArray interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramArrayMock; + }; + this.isEmpty = function (...args) { + console.warn("ArrayList.isEmpty interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.increaseCapacityTo = function (...args) { + console.warn("ArrayList.clear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.trimToCurrentLength = function (...args) { + console.warn("ArrayList.trimToCurrentLength interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + } + [Symbol.iterator](){ + console.warn("ArrayList.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + index++; + return { + value: paramArrayList.paramAnyMock, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; + } + } + return ArrayListClass; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/deque.js b/runtime/main/extend/systemplugin/napi/deque.js new file mode 100644 index 00000000..716cf890 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/deque.js @@ -0,0 +1,92 @@ +/* + * Copyright (c) 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 + * + * 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 mockDeque() { + const paramDeque = { + paramAnyMock: '[PC Preview] unknow any', + paramIterMock: '[PC Preview] unknow IterableIterator' + } + const DequeClass = class Deque { + constructor(...args) { + console.warn('util.Deque interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + this.length = '[PC preview] unknow length'; + this.insertFront = function (...args) { + console.warn("Deque.insertFront interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.insertEnd = function (...args) { + console.warn("Deque.insertEnd interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.has = function (...args) { + console.warn("Deque.has interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.getFirst = function (...args) { + console.warn("Deque.getFirst interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramDeque.paramAnyMock; + }; + this.getLast = function (...args) { + console.warn("Deque.getLast interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramDeque.paramAnyMock; + }; + this.popFirst = function (...args) { + console.warn("Deque.popFirst interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramDeque.paramAnyMock; + }; + this.popLast = function (...args) { + console.warn("Deque.popLast interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramDeque.paramAnyMock; + }; + this.forEach = function (...args) { + console.warn("Deque.forEach interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (typeof args[0] === 'function') { + args[0].call(this, paramDeque.businessErrorMock) + } + }; + } + [Symbol.iterator]() { + console.warn("Deque.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + index++; + return { + value: paramDeque.paramAnyMock, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; + } + } + return DequeClass; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/hashmap.js b/runtime/main/extend/systemplugin/napi/hashmap.js new file mode 100644 index 00000000..4b8e75f9 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/hashmap.js @@ -0,0 +1,135 @@ +/* + * Copyright (c) 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 + * + * 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 mockHashMap() { + const paramHashMap = { + paramAnyMock : '[PC Preview] unknow any', + paramHashMap : '[PC Preview] unknow hashmap', + paramIterMock_K : '[PC Preview] unknow iterableiterator_k', + paramIterMock_V : '[PC Preview] unknow iterableiterator_v' + } + const HashMapClass = class HashMap { + constructor(...args) { + console.warn('util.HashMap interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + this.length = '[PC preview] unknow length'; + this.isEmpty = function (...args) { + console.warn("HashMap.isEmpty interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.hasKey = function (...args) { + console.warn("HashMap.hasKey interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.hasValue = function (...args) { + console.warn("HashMap.hasValue interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.get = function (...args) { + console.warn("HashMap.get interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramHashMap.paramAnyMock; + }; + this.setAll = function (...args) { + console.warn("HashMap.setAll interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.set = function (...args) { + console.warn("HashMap.set interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramObjectMock; + }; + this.remove = function (...args) { + console.warn("HashMap.remove interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramHashMap.paramAnyMock; + }; + this.clear = function (...args) { + console.warn("HashMap.clear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.keys = function (...args) { + console.warn('HashMap.keys interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + const IteratorKMock = { + *[Symbol.iterator]() { + yield paramHashMap.paramIterMock_K; + } + }; + return IteratorKMock; + }; + this.values = function (...args) { + console.warn('HashMap.values interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + const IteratorVMock = { + *[Symbol.iterator]() { + yield paramHashMap.paramIterMock_V; + } + }; + return IteratorVMock; + }; + this.replace = function (...args) { + console.warn("HashMap.replace interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.forEach = function (...args) { + console.warn("HashMap.forEach interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (typeof args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock); + } + }; + this.entries = function (...args) { + console.warn('HashMap.entries interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + const IteratorEntriesMock = { + *[Symbol.iterator]() { + yield [paramHashMap.paramIterMock_K, paramHashMap.paramIterMock_V]; + } + }; + return IteratorEntriesMock; + }; + } + [Symbol.iterator]() { + console.warn("HashMap.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + const returnValue = [paramHashMap.paramIterMock_K, paramHashMap.paramIterMock_V]; + index++; + return { + value: returnValue, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; + } + } + return HashMapClass; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/hashset.js b/runtime/main/extend/systemplugin/napi/hashset.js new file mode 100644 index 00000000..8d9d4ff1 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/hashset.js @@ -0,0 +1,103 @@ +/* + * Copyright (c) 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 + * + * 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 mockHashSet() { + const paramHashSet = { + paramAnyMock : '[PC Preview] unknow any' + } + const HashSetClass = class HashSet { + constructor(...args) { + console.warn('util.HashSet interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + this.length = '[PC preview] unknow length'; + this.isEmpty = function (...args) { + console.warn("HashSet.isEmpty interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.has = function (...args) { + console.warn("HashSet.has interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.add = function (...args) { + console.warn("HashSet.add interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.remove = function (...args) { + console.warn("HashSet.remove interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.clear = function (...args) { + console.warn("HashSet.clear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.forEach = function (...args) { + console.warn("HashSet.forEach interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (this.args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock); + } + }; + this.values = function (...args) { + console.warn('HashSet.values interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + const IteratorVMock = { + *[Symbol.iterator]() { + yield paramHashSet.paramAnyMock; + } + }; + return IteratorVMock; + }; + this.entries = function (...args) { + console.warn('HashSet.entries interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + const IteratorEntriesMock = { + *[Symbol.iterator]() { + yield [paramHashSet.paramAnyMock, paramHashSet.paramAnyMock]; + } + }; + return IteratorEntriesMock; + } + } + [Symbol.iterator]() { + console.warn("HashSet.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + const returnValue = [paramHashSet.paramAnyMock, paramHashSet.paramAnyMock]; + index++; + return { + value: returnValue, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; + } + } + return HashSetClass; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 3ec496ac..03cd233f 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -76,6 +76,20 @@ import { mockSecurityLabel } from './securitylabel' import { mockWorkScheduler } from './workScheduler' import { mockWorkSchedulerExtensionAbility } from './WorkSchedulerExtensionAbility' import { mockUserAuth } from './userAuth' +import { mockArrayList } from './arraylist' +import { mockDeque } from './deque' +import { mockHashMap } from './hashmap' +import { mockHashSet } from './hashset' +import { mockLightWeightMap } from './lightweightmap' +import { mockLightWeightSet } from './lightweightset' +import { mockLinkedList } from './linkedlist' +import { mockList } from './list' +import { mockPlainArray } from './plainarray' +import { mockQueue } from './queue' +import { mockStack } from './stack' +import { mockTreeMap } from './treemap' +import { mockTreeSet } from './treeset' +import { mockVector } from './vector' export function mockRequireNapiFun() { global.requireNapi = function (...args) { @@ -206,6 +220,34 @@ export function mockRequireNapiFun() { return mockWorkSchedulerExtensionAbility(); case "userIAM.userAuth": return mockUserAuth(); + case "util.ArrayList": + return mockArrayList(); + case "util.Deque": + return mockDeque(); + case "util.HashMap": + return mockHashMap(); + case "util.HashSet": + return mockHashSet(); + case "util.LightWeightMap": + return mockLightWeightMap(); + case "util.LightWeightSet": + return mockLightWeightSet(); + case "util.LinkedList": + return mockLinkedList(); + case "util.List": + return mockList(); + case "util.PlainArray": + return mockPlainArray(); + case "util.Queue": + return mockQueue(); + case "util.Stack": + return mockStack(); + case "util.TreeMap": + return mockTreeMap(); + case "util.TreeSet": + return mockTreeSet(); + case "util.Vector": + return mockVector(); default: return global.requireNapiPreview(...args); } diff --git a/runtime/main/extend/systemplugin/napi/lightweightmap.js b/runtime/main/extend/systemplugin/napi/lightweightmap.js new file mode 100644 index 00000000..b62ed140 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/lightweightmap.js @@ -0,0 +1,172 @@ +/* + * Copyright (c) 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 + * + * 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 mockLightWeightMap() { + const paramLightWeightMap = { + paramAnyMock_K : '[PC Preview] unknow any_k', + paramAnyMock_V : '[PC Preview] unknow any_v' + } + const LightWeightMapClass = class LightWeightMap { + constructor(...args) { + console.warn('util.LightWeightMap interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + this.length = '[PC preview] unknow length'; + this.hasAll = function (...args) { + console.warn("LightWeightMap.hasAll interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.hasKey = function (...args) { + console.warn("LightWeightMap.hasKey interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.hasValue = function (...args) { + console.warn("LightWeightMap.hasValue interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.increaseCapacityTo = function (...args) { + console.warn("LightWeightMap.increaseCapacityTo interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.entries = function (...args) { + console.warn('LightWeightMap.entries interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + const IteratorEntriesMock = { + *[Symbol.iterator]() { + yield [paramLightWeightMap.paramAnyMock_K, paramHashMap.paramAnyMock_V]; + } + }; + return IteratorEntriesMock; + } + this.get = function (...args) { + console.warn("LightWeightMap.get interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramLightWeightMap.paramAnyMock_V; + }; + this.getIndexOfKey = function (...args) { + console.warn("LightWeightMap.getIndexOfKey interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.getIndexOfValue = function (...args) { + console.warn("LightWeightMap.getIndexOfValue interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.isEmpty = function (...args) { + console.warn("LightWeightMap.isEmpty interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.getKeyAt = function (...args) { + console.warn("LightWeightMap.getKeyAt interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramLightWeightMap.paramAnyMock_K; + }; + this.keys = function (...args) { + console.warn('LightWeightMap.keys interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + const IteratorKMock = { + *[Symbol.iterator]() { + yield paramLightWeightMap.paramAnyMock_K; + } + }; + return IteratorKMock; + }; + this.setAll = function (...args) { + console.warn("LightWeightMap.setAll interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.set = function (...args) { + console.warn("LightWeightMap.set interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramObjectMock; + }; + this.remove = function (...args) { + console.warn("LightWeightMap.remove interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramLightWeightMap.paramAnyMock_V; + }; + this.removeAt = function (...args) { + console.warn("LightWeightMap.removeAt interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.clear = function (...args) { + console.warn("LightWeightMap.clear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.setValueAt = function (...args) { + console.warn("LightWeightMap.setValueAt interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.forEach = function (...args) { + console.warn("LightWeightMap.forEach interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (this.args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock) + } + }; + this.toString = function (...args) { + console.warn("LightWeightMap.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; + }; + this.getValueAt = function (...args) { + console.warn("LightWeightMap.getValueAt interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramLightWeightMap.paramAnyMock_V; + }; + this.values = function (...args) { + console.warn('LightWeightMap.values interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + const IteratorVMock = { + *[Symbol.iterator]() { + yield paramLightWeightMap.paramAnyMock_V; + } + }; + return IteratorVMock; + }; + } + [Symbol.iterator]() { + console.warn("LightWeightMap.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + const returnValue = [paramLightWeightMap.paramAnyMock_K, paramLightWeightMap.paramAnyMock_V]; + index++; + return { + value: returnValue, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; + } + } + return LightWeightMapClass; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/lightweightset.js b/runtime/main/extend/systemplugin/napi/lightweightset.js new file mode 100644 index 00000000..8108592c --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/lightweightset.js @@ -0,0 +1,153 @@ +/* + * Copyright (c) 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 + * + * 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 mockLightWeightSet() { + const paramLightWeightSet = { + paramAnyMock : '[PC Preview] unknow any', + paramIterMock_T : '[PC Preview] unknow IterableIterator_t' + } + const LightWeightSetClass = class LightWeightSet { + constructor(...args) { + console.warn('util.LightWeightSet interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + this.length = '[PC preview] unknow length'; + this.add = function (...args) { + console.warn("LightWeightSet.add interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.addAll = function (...args) { + console.warn("LightWeightSet.addAll interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.hasAll = function (...args) { + console.warn("LightWeightSet.hasAll interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.has = function (...args) { + console.warn("LightWeightSet.has interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.equal = function (...args) { + console.warn("LightWeightSet.equal interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.increaseCapacityTo = function (...args) { + console.warn("LightWeightSet.increaseCapacityTo interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.getIndexOf = function (...args) { + console.warn("LightWeightSet.getIndexOf interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.remove = function (...args) { + console.warn("LightWeightSet.remove interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramLightWeightSet.paramAnyMock; + }; + this.removeAt = function (...args) { + console.warn("LightWeightSet.removeAt interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.clear = function (...args) { + console.warn("LightWeightSet.clear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.forEach = function (...args) { + console.warn("LightWeightSet.forEach interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (this.args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock); + } + }; + this.toString = function (...args) { + console.warn("LightWeightSet.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; + }; + this.toString = function (...args) { + console.warn("LightWeightSet.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; + }; + this.toArray = function (...args) { + console.warn("LightWeightSet.toArray interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramArrayMock; + }; + this.getValueAt = function (...args) { + console.warn("LightWeightSet.getValueAt interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramLightWeightSet.paramAnyMock; + }; + this.values = function (...args) { + console.warn('LightWeightSet.values interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + const IteratorVMock = { + *[Symbol.iterator]() { + yield paramLightWeightSet.paramIterMock_T; + } + }; + return IteratorVMock; + }; + this.entries = function (...args) { + console.warn('LightWeightSet.entries interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + const IteratorEntriesMock = { + *[Symbol.iterator]() { + yield [paramLightWeightSet.paramIterMock_T, paramLightWeightSet.paramIterMock_T]; + } + }; + return IteratorEntriesMock; + } + this.isEmpty = function (...args) { + console.warn("LightWeightSet.isEmpty interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + } + } + [Symbol.iterator]() { + console.warn("LightWeightSet.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + const returnValue = [paramLightWeightSet.paramIterMock_T, paramLightWeightSet.paramIterMock_T]; + index++; + return { + value: returnValue, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; + } + } + return LightWeightSetClass; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/linkedlist.js b/runtime/main/extend/systemplugin/napi/linkedlist.js new file mode 100644 index 00000000..0addf9ff --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/linkedlist.js @@ -0,0 +1,152 @@ +/* + * Copyright (c) 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 + * + * 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 mockLinkedList() { + const paramLinkedList = { + paramAnyMock: '[PC Preview] unknow any', + paramLinkedListMock: '[PC Preview] unknow LinkedList', + paramIterMock: '[PC Preview] unknow IterableIterator' + } + const LinkedListClass = class LinkedList { + constructor(...args) { + console.warn('util.LinkedList interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + this.length = '[PC preview] unknow length'; + this.add = function (...args) { + console.warn("LinkedList.add interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.insert = function (...args) { + console.warn("LinkedList.insert interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.get = function (...args) { + console.warn("LinkedList.get interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramLinkedList.paramAnyMock; + }; + this.addFirst = function (...args) { + console.warn("LinkedList.addFirst interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.removeFirst = function (...args) { + console.warn("LinkedList.removeFirst interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramLinkedList.paramAnyMock; + }; + this.removeLast = function (...args) { + console.warn("LinkedList.removeLast interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramLinkedList.paramAnyMock; + }; + this.has = function (...args) { + console.warn("LinkedList.has interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.getIndexOf = function (...args) { + console.warn("LinkedList.getIndexOf interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.removeByIndex = function (...args) { + console.warn("LinkedList.removeByIndex interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramLinkedList.paramAnyMock; + }; + this.remove = function (...args) { + console.warn("LinkedList.remove interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.removeFirstFound = function (...args) { + console.warn("LinkedList.removeFirstFound interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.removeLastFound = function (...args) { + console.warn("LinkedList.removeLastFound interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.getLastIndexOf = function (...args) { + console.warn("LinkedList.getLastIndexOf interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.getFirst = function (...args) { + console.warn("LinkedList.getFirst interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramLinkedList.paramAnyMock; + }; + this.getLast = function (...args) { + console.warn("LinkedList.getLast interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramLinkedList.paramAnyMock; + }; + this.set = function (...args) { + console.warn("LinkedList.set interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramLinkedList.paramAnyMock; + }; + this.forEach = function (...args) { + console.warn("LinkedList.forEach interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (typeof args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock) + } + }; + this.clear = function (...args) { + console.warn("LinkedList.clear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.clone = function (...args) { + console.warn("LinkedList.clone interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramLinkedList.paramLinkedListMock; + }; + this.convertToArray = function (...args) { + console.warn("LinkedList.convertToArray interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramArrayMock; + }; + } + [Symbol.iterator]() { + console.warn("LinkedList.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + index++; + return { + value: paramLinkedList.paramAnyMock, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; + } + } + return LinkedListClass; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/list.js b/runtime/main/extend/systemplugin/napi/list.js new file mode 100644 index 00000000..38d5cd69 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/list.js @@ -0,0 +1,152 @@ +/* + * Copyright (c) 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 + * + * 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 mockList() { + const paramList = { + paramAnyMock: '[PC Preview] unknow any', + paramListMock: '[PC Preview] unknow List', + paramIterMock: '[PC Preview] unknow IterableIterator' + } + const ListClass = class List { + constructor(...args) { + console.warn('util.List interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + this.length = '[PC preview] unknow length'; + this.add = function (...args) { + console.warn("List.add interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.insert = function (...args) { + console.warn("List.insert interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.get = function (...args) { + console.warn("List.get interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramList.paramAnyMock; + }; + this.has = function (...args) { + console.warn("List.has interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.getIndexOf = function (...args) { + console.warn("List.getIndexOf interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.removeByIndex = function (...args) { + console.warn("List.removeByIndex interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramList.paramAnyMock; + }; + this.remove = function (...args) { + console.warn("List.remove interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.getLastIndexOf = function (...args) { + console.warn("List.getLastIndexOf interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.getFirst = function (...args) { + console.warn("List.getFirst interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramList.paramAnyMock; + }; + this.getLast = function (...args) { + console.warn("List.getLast interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramList.paramAnyMock; + }; + this.set = function (...args) { + console.warn("List.set interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramList.paramAnyMock; + }; + this.equal = function (...args) { + console.warn("List.equal interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.forEach = function (...args) { + console.warn("List.forEach interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (typeof args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock) + } + }; + this.sort = function (...args) { + console.warn("List.sort interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (typeof args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock) + } + }; + this.clear = function (...args) { + console.warn("List.clear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.getSubList = function (...args) { + console.warn("List.getSubList interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramList.paramListMock; + }; + this.replaceAllElements = function (...args) { + console.warn("List.replaceAllElements interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (typeof args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock, paramLinkedList.paramAnyMock) + } + }; + this.convertToArray = function (...args) { + console.warn("List.convertToArray interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramArrayMock; + }; + this.isEmpty = function (...args) { + console.warn("LinkedList.isEmpty interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + } + [Symbol.iterator]() { + console.warn("List.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + index++; + return { + value: paramList.paramAnyMock, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; + } + } + return ListClass; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/plainarray.js b/runtime/main/extend/systemplugin/napi/plainarray.js new file mode 100644 index 00000000..c945a5aa --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/plainarray.js @@ -0,0 +1,134 @@ +/* + * Copyright (c) 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 + * + * 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 mockPlainArray() { + const paramPlainArray = { + paramAnyMock : '[PC Preview] unknow any', + paramPlainArray : '[PC Preview] unknow PlainArray', + paramIterMock_K : '[PC Preview] unknow iterableiterator_k', + paramIterMock_V : '[PC Preview] unknow iterableiterator_v' + } + const PlainArrayClass = class PlainArray { + constructor(...args) { + console.warn('util.PlainArray interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + this.length = '[PC preview] unknow length'; + this.add = function (...args) { + console.warn("PlainArray.add interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.clear = function (...args) { + console.warn("PlainArray.clear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.clone = function (...args) { + console.warn("PlainArray.clone interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramPlainArray.paramPlainArray; + }; + this.has = function (...args) { + console.warn("PlainArray.has interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.get = function (...args) { + console.warn("PlainArray.get interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramPlainArray.paramAnyMock; + }; + this.getIndexOfKey = function (...args) { + console.warn("PlainArray.getIndexOfKey interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.getIndexOfValue = function (...args) { + console.warn("PlainArray.getIndexOfValue interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.isEmpty = function (...args) { + console.warn("PlainArray.isEmpty interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.getKeyAt = function (...args) { + console.warn("PlainArray.getKeyAt interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.remove = function (...args) { + console.warn("PlainArray.remove interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramPlainArray.paramAnyMock; + }; + this.removeAt = function (...args) { + console.warn("PlainArray.removeAt interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramPlainArray.paramAnyMock; + }; + this.removeRangeFrom = function (...args) { + console.warn("PlainArray.removeRangeFrom interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.setValueAt = function (...args) { + console.warn("PlainArray.setValueAt interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.toString = function (...args) { + console.warn("PlainArray.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; + }; + this.getValueAt = function (...args) { + console.warn("PlainArray.getValueAt interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramPlainArray.paramAnyMock; + }; + this.forEach = function (...args) { + console.warn("PlainArray.forEach interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (this.args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock) + } + }; + } + [Symbol.iterator]() { + console.warn("PlainArray.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + const returnValue = [paramPlainArray.paramIterMock_K, paramPlainArray.paramIterMock_V]; + index++; + return { + value: returnValue, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; + } + } + return PlainArrayClass; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/queue.js b/runtime/main/extend/systemplugin/napi/queue.js new file mode 100644 index 00000000..89eeae03 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/queue.js @@ -0,0 +1,74 @@ +/* + * Copyright (c) 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 + * + * 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 mockQueue() { + const paramQueue = { + paramAnyMock: '[PC Preview] unknow any', + paramIterMock: '[PC Preview] unknow IterableIterator' + } + const QueueClass = class Queue { + constructor(...args) { + console.warn('util.Queue interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + this.length = '[PC preview] unknow length'; + this.add = function (...args) { + console.warn("Queue.add interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.getFirst = function (...args) { + console.warn("Queue.getFirst interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramQueue.paramAnyMock; + }; + this.pop = function (...args) { + console.warn("Queue.pop interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramQueue.paramAnyMock; + }; + this.forEach = function (...args) { + console.warn("Queue.forEach interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (typeof args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock) + } + }; + } + [Symbol.iterator]() { + console.warn("Queue.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + index++; + return { + value: paramQueue.paramAnyMock, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; + } + } + return QueueClass; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/stack.js b/runtime/main/extend/systemplugin/napi/stack.js new file mode 100644 index 00000000..25d07f23 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/stack.js @@ -0,0 +1,84 @@ +/* + * Copyright (c) 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 + * + * 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 mockStack() { + const paramStack = { + paramAnyMock: '[PC Preview] unknow any', + paramIterMock: '[PC Preview] unknow IterableIterator' + } + const StackClass = class Stack { + constructor(...args) { + console.warn('util.Stack interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + this.length = '[PC preview] unknow length'; + this.isEmpty = function (...args) { + console.warn("Stack.isEmpty interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.peek = function (...args) { + console.warn("Stack.peek interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramStack.paramAnyMock; + }; + this.pop = function (...args) { + console.warn("Stack.pop interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramStack.paramAnyMock; + }; + this.push = function (...args) { + console.warn("Stack.push interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramStack.paramAnyMock; + }; + this.locate = function (...args) { + console.warn("Stack.locate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.forEach = function (...args) { + console.warn("Stack.forEach interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (typeof args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock) + } + }; + } + [Symbol.iterator]() { + console.warn("Stack.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + index++; + return { + value: paramStack.paramAnyMock, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; + } + } + return StackClass; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/treemap.js b/runtime/main/extend/systemplugin/napi/treemap.js new file mode 100644 index 00000000..93d7fa5c --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/treemap.js @@ -0,0 +1,153 @@ +/* + * Copyright (c) 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 + * + * 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 mockTreeMap() { + const paramTreeMap = { + paramIterMock_K : '[PC Preview] unknow iterableiterator_k', + paramIterMock_V : '[PC Preview] unknow iterableiterator_v' + } + const TreeMapClass = class TreeMap { + constructor(...args) { + console.warn('util.TreeMap interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + this.length = '[PC preview] unknow length'; + this.isEmpty = function (...args) { + console.warn("TreeMap.isEmpty interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.hasKey = function (...args) { + console.warn("TreeMap.hasKey interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.hasValue = function (...args) { + console.warn("TreeMap.hasValue interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.get = function (...args) { + console.warn("TreeMap.get interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramTreeMap.paramIterMock_V; + }; + this.getFirstKey = function (...args) { + console.warn("TreeMap.getFirstKey interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramTreeMap.paramIterMock_K; + }; + this.getLastKey = function (...args) { + console.warn("TreeMap.getLastKey interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramTreeMap.paramIterMock_K; + }; + this.setAll = function (...args) { + console.warn("TreeMap.setAll interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.set = function (...args) { + console.warn("TreeMap.set interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramObjectMock; + }; + this.remove = function (...args) { + console.warn("TreeMap.remove interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramTreeMap.paramIterMock_V; + }; + this.clear = function (...args) { + console.warn("TreeMap.clear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.getLowerKey = function (...args) { + console.warn("TreeMap.getLowerKey interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramTreeMap.paramIterMock_K; + }; + this.getHigherKey = function (...args) { + console.warn("TreeMap.getHigherKey interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramTreeMap.paramIterMock_K; + }; + this.keys = function (...args) { + console.warn('TreeMap.keys interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + const IteratorKMock = { + *[Symbol.iterator]() { + yield paramTreeMap.paramIterMock_K; + } + }; + return IteratorKMock; + }; + this.values = function (...args) { + console.warn('TreeMap.values interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + const IteratorVMock = { + *[Symbol.iterator]() { + yield paramTreeMap.paramIterMock_V; + } + }; + return IteratorVMock; + }; + this.replace = function (...args) { + console.warn("TreeMap.replace interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.forEach = function (...args) { + console.warn("TreeMap.forEach interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (this.args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock) + } + }; + this.entries = function (...args) { + console.warn('TreeMap.entries interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + const IteratorEntriesMock = { + *[Symbol.iterator]() { + yield [paramTreeMap.paramIterMock_K, paramTreeMap.paramIterMock_V]; + } + }; + return IteratorEntriesMock; + }; + } + [Symbol.iterator]() { + console.warn("TreeMap.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + const returnValue = [paramTreeMap.paramIterMock_K, paramTreeMap.paramIterMock_V]; + index++; + return { + value: returnValue, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; + } + } + return TreeMapClass; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/treeset.js b/runtime/main/extend/systemplugin/napi/treeset.js new file mode 100644 index 00000000..f76b23ec --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/treeset.js @@ -0,0 +1,134 @@ +/* + * Copyright (c) 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 + * + * 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 mockTreeSet() { + const paramTreeSet = { + paramAnyMock : '[PC Preview] unknow any', + paramIterMock_TT : '[PC Preview] unknow IterableIterator_tt', + paramIterMock : '[PC Preview] unknow IterableIterator' + } + const TreeSetClass = class TreeSet { + constructor(...args) { + console.warn('util.TreeSet interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + this.length = '[PC preview] unknow length'; + this.isEmpty = function (...args) { + console.warn("TreeSet.isEmpty interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.has = function (...args) { + console.warn("TreeSet.has interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.add = function (...args) { + console.warn("TreeSet.add interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.remove = function (...args) { + console.warn("TreeSet.remove interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.clear = function (...args) { + console.warn("TreeSet.clear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.getFirstValue = function (...args) { + console.warn("TreeSet.getFirstValue interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramTreeSet.paramAnyMock; + }; + this.getLastValue = function (...args) { + console.warn("TreeSet.getLastValue interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramTreeSet.paramAnyMock; + }; + this.getLowerValue = function (...args) { + console.warn("TreeSet.getLowerValue interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramTreeSet.paramAnyMock; + }; + this.getHigherValue = function (...args) { + console.warn("TreeSet.getHigherValue interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramTreeSet.paramAnyMock; + }; + this.popFirst = function (...args) { + console.warn("TreeSet.popFirst interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramTreeSet.paramAnyMock; + }; + this.popLast = function (...args) { + console.warn("TreeSet.popLast interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramTreeSet.paramAnyMock; + }; + this.forEach = function (...args) { + console.warn("TreeSet.forEach interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (typeof args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock) + } + }; + this.values = function (...args) { + console.warn("TreeSet.values interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const IteratorVMock = { + *[Symbol.iterator]() { + yield paramTreeSet.paramIterMock_TT; + } + }; + return IteratorVMock; + }; + this.entries = function (...args) { + console.warn("TreeSet.entries interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + const IteratorVMock = { + *[Symbol.iterator]() { + yield paramTreeSet.paramIterMock; + } + }; + return IteratorVMock; + }; + } + [Symbol.iterator]() { + console.warn("TreeSet.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + index++; + return { + value: paramTreeSet.paramAnyMock, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; + } + } + return TreeSetClass; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/vector.js b/runtime/main/extend/systemplugin/napi/vector.js new file mode 100644 index 00000000..99ee215c --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/vector.js @@ -0,0 +1,190 @@ +/* + * Copyright (c) 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 + * + * 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 mockVector() { + const paramVector = { + paramAnyMock : '[PC Preview] unknow any', + paramVectorMock : '[PC Preview] unknow Vector', + paramIterMock : '[PC Preview] unknow IterableIterator' + } + + const VectorClass = class Vector { + constructor(...args) { + console.warn('util.Vector interface mocked in the Previewer. How this interface works on the Previewer' + + ' may be different from that on a real device.'); + this.length = '[PC preview] unknow length'; + this.add = function (...args) { + console.warn("Vector.add interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.insert = function (...args) { + console.warn("Vector.insert interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.has = function (...args) { + console.warn("Vector.has interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.get = function (...args) { + console.warn("Vector.get interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramVector.paramAnyMock; + }; + this.getIndexOf = function (...args) { + console.warn("Vector.getIndexOf interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.getFirstElement = function (...args) { + console.warn("Vector.getFirstElement interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramVector.paramAnyMock; + }; + this.getLastElement = function (...args) { + console.warn("Vector.getLastElement interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramVector.paramAnyMock; + }; + this.removeByIndex = function (...args) { + console.warn("Vector.removeByIndex interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramVector.paramAnyMock; + }; + this.remove = function (...args) { + console.warn("Vector.remove interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.set = function (...args) { + console.warn("Vector.set interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramVector.paramAnyMock; + }; + this.getLastIndexOf = function (...args) { + console.warn("Vector.getLastIndexOf interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.getLastIndexFrom = function (...args) { + console.warn("Vector.getLastIndexFrom interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.getIndexFrom = function (...args) { + console.warn("Vector.getIndexFrom interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.removeByRange = function (...args) { + console.warn("Vector.removeByRange interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.replaceAllElements = function (...args) { + console.warn("Vector.replaceAllElements interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (typeof args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock, paramVector.paramAnyMock) + } + }; + this.forEach = function (...args) { + console.warn("Vector.forEach interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + if (typeof args[0] === 'function') { + args[0].call(this, paramMock.businessErrorMock) + } + }; + this.sort = function (...args) { + console.warn("Vector.sort interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.subVector = function (...args) { + console.warn("Vector.subVector interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramVector.paramVectorMock; + }; + this.clear = function (...args) { + console.warn("Vector.clear interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.clone = function (...args) { + console.warn("Vector.clone interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramVector.paramVectorMock; + }; + this.setLength = function (...args) { + console.warn("Vector.setLength interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.getCapacity = function (...args) { + console.warn("Vector.getCapacity interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }; + this.convertToArray = function (...args) { + console.warn("Vector.convertToArray interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramArrayMock; + }; + this.isEmpty = function (...args) { + console.warn("Vector.isEmpty interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.increaseCapacityTo = function (...args) { + console.warn("Vector.increaseCapacityTo interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.toString = function (...args) { + console.warn("Vector.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; + }; + this.trimToCurrentLength = function (...args) { + console.warn("Vector.trimToCurrentLength interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.copyToArray = function (...args) { + console.warn("Vector.copyToArray interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + } + [Symbol.iterator]() { + console.warn("Vector.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + let index = 0; + const IteratorMock = { + next: () => { + if (index < 1) { + index++; + return { + value: paramVector.paramAnyMock, + done: false + }; + } else { + return { + done: true + }; + } + } + }; + return IteratorMock; + } + } + return VectorClass; +} \ No newline at end of file