From c53481b5b8e2352997462500431167bebb503f93 Mon Sep 17 00:00:00 2001 From: linhaoran Date: Fri, 22 Jul 2022 14:42:39 +0800 Subject: [PATCH] Modify container Mock Signed-off-by: linhaoran --- .../systemplugin/napi/ohos_util_Arraylist.js | 44 +++++++------- .../systemplugin/napi/ohos_util_Deque.js | 40 ++++++------- .../systemplugin/napi/ohos_util_HashMap.js | 42 +++++++------- .../systemplugin/napi/ohos_util_HashSet.js | 44 +++++++------- .../napi/ohos_util_LightWeightMap.js | 42 +++++++------- .../napi/ohos_util_LightWeightSet.js | 52 ++++++++--------- .../systemplugin/napi/ohos_util_LinkedList.js | 40 ++++++------- .../systemplugin/napi/ohos_util_List.js | 8 +-- .../systemplugin/napi/ohos_util_PlainArray.js | 42 +++++++------- .../systemplugin/napi/ohos_util_Queue.js | 40 ++++++------- .../systemplugin/napi/ohos_util_Stack.js | 40 ++++++------- .../systemplugin/napi/ohos_util_TreeMap.js | 46 +++++++-------- .../systemplugin/napi/ohos_util_TreeSet.js | 58 +++++++++---------- .../systemplugin/napi/ohos_util_Vector.js | 46 +++++++-------- 14 files changed, 292 insertions(+), 292 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_Arraylist.js b/runtime/main/extend/systemplugin/napi/ohos_util_Arraylist.js index 2aa9eccc..793e7f38 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_Arraylist.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_Arraylist.js @@ -17,8 +17,8 @@ import { paramMock } from "../utils" export function mockArrayList() { const paramArrayList = { - paramAnyMock : '[PC Preview] unknow any', - paramArrayListMock : '[PC Preview] unknow ArrayList' + paramAnyMock: '[PC Preview] unknow any', + paramArrayListMock: '[PC Preview] unknow ArrayList' } const ArrayListClass = class ArrayList { constructor(...args) { @@ -121,27 +121,27 @@ export function mockArrayList() { 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 - }; + this[Symbol.iterator] = function (...args) { + 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 IteratorMock; + } } } return ArrayListClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_Deque.js b/runtime/main/extend/systemplugin/napi/ohos_util_Deque.js index 716cf890..807a3021 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_Deque.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_Deque.js @@ -65,27 +65,27 @@ export function mockDeque() { 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 - }; + this[Symbol.iterator] = function (...args) { + 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 IteratorMock; + } } } return DequeClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_HashMap.js b/runtime/main/extend/systemplugin/napi/ohos_util_HashMap.js index 4b8e75f9..4ffffdf0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_HashMap.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_HashMap.js @@ -107,28 +107,28 @@ export function mockHashMap() { }; 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 - }; + this[Symbol.iterator] = function (...args) { + 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 IteratorMock; + } } } return HashMapClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_HashSet.js b/runtime/main/extend/systemplugin/napi/ohos_util_HashSet.js index 8d9d4ff1..9475eae4 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_HashSet.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_HashSet.js @@ -74,29 +74,29 @@ export function mockHashSet() { } }; 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; + this[Symbol.iterator] = function (...args) { + 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; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_LightWeightMap.js b/runtime/main/extend/systemplugin/napi/ohos_util_LightWeightMap.js index b62ed140..9a869876 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_LightWeightMap.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_LightWeightMap.js @@ -144,28 +144,28 @@ export function mockLightWeightMap() { }; 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 - }; + this[Symbol.iterator] = function (...args) { + 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 IteratorMock; + } } } return LightWeightMapClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_LightWeightSet.js b/runtime/main/extend/systemplugin/napi/ohos_util_LightWeightSet.js index 8108592c..afdb1c42 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_LightWeightSet.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_LightWeightSet.js @@ -17,8 +17,8 @@ import { paramMock } from "../utils" export function mockLightWeightSet() { const paramLightWeightSet = { - paramAnyMock : '[PC Preview] unknow any', - paramIterMock_T : '[PC Preview] unknow IterableIterator_t' + paramAnyMock: '[PC Preview] unknow any', + paramIterMock_T: '[PC Preview] unknow IterableIterator_t' } const LightWeightSetClass = class LightWeightSet { constructor(...args) { @@ -119,35 +119,35 @@ export function mockLightWeightSet() { } }; 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; + }; + this[Symbol.iterator] = function (...args) { + 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; } } - [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; + return LightWeightSetClass; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_LinkedList.js b/runtime/main/extend/systemplugin/napi/ohos_util_LinkedList.js index 0addf9ff..f3a419f7 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_LinkedList.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_LinkedList.js @@ -125,27 +125,27 @@ export function mockLinkedList() { " 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 - }; + this[Symbol.iterator] = function (...args) { + 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 IteratorMock; + } } } return LinkedListClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_List.js b/runtime/main/extend/systemplugin/napi/ohos_util_List.js index 38d5cd69..a2587ceb 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_List.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_List.js @@ -125,10 +125,9 @@ export function mockList() { " 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.") + this[Symbol.iterator] = function (...args) { + 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: () => { @@ -146,6 +145,7 @@ export function mockList() { } }; return IteratorMock; + } } } return ListClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_PlainArray.js b/runtime/main/extend/systemplugin/napi/ohos_util_PlainArray.js index c945a5aa..e8c9a551 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_PlainArray.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_PlainArray.js @@ -106,28 +106,28 @@ export function mockPlainArray() { 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 - }; + this[Symbol.iterator] = function (...args) { + 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 IteratorMock; + } } } return PlainArrayClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_Queue.js b/runtime/main/extend/systemplugin/napi/ohos_util_Queue.js index 89eeae03..4edce0f9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_Queue.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_Queue.js @@ -47,27 +47,27 @@ export function mockQueue() { 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 - }; + this[Symbol.iterator] = function (...args) { + 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 IteratorMock; + } } } return QueueClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_Stack.js b/runtime/main/extend/systemplugin/napi/ohos_util_Stack.js index 25d07f23..23e52e69 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_Stack.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_Stack.js @@ -57,27 +57,27 @@ export function mockStack() { 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 - }; + this[Symbol.iterator] = function (...args) { + 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 IteratorMock; + } } } return StackClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_TreeMap.js b/runtime/main/extend/systemplugin/napi/ohos_util_TreeMap.js index 93d7fa5c..4798cbd2 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_TreeMap.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_TreeMap.js @@ -17,8 +17,8 @@ import { paramMock } from "../utils" export function mockTreeMap() { const paramTreeMap = { - paramIterMock_K : '[PC Preview] unknow iterableiterator_k', - paramIterMock_V : '[PC Preview] unknow iterableiterator_v' + paramIterMock_K: '[PC Preview] unknow iterableiterator_k', + paramIterMock_V: '[PC Preview] unknow iterableiterator_v' } const TreeMapClass = class TreeMap { constructor(...args) { @@ -125,28 +125,28 @@ export function mockTreeMap() { }; 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 - }; + this[Symbol.iterator] = function (...args) { + 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 IteratorMock; + } } } return TreeMapClass; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_TreeSet.js b/runtime/main/extend/systemplugin/napi/ohos_util_TreeSet.js index f76b23ec..ee44c088 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_TreeSet.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_TreeSet.js @@ -17,9 +17,9 @@ 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' + paramAnyMock: '[PC Preview] unknow any', + paramIterMock_TT: '[PC Preview] unknow IterableIterator_tt', + paramIterMock: '[PC Preview] unknow IterableIterator' } const TreeSetClass = class TreeSet { constructor(...args) { @@ -100,34 +100,34 @@ export function mockTreeSet() { 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 - }; + const IteratorVMock = { + *[Symbol.iterator]() { + yield paramTreeSet.paramIterMock; } - } + }; + return IteratorVMock; }; - return IteratorMock; + this[Symbol.iterator] = function (...args) { + 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; diff --git a/runtime/main/extend/systemplugin/napi/ohos_util_Vector.js b/runtime/main/extend/systemplugin/napi/ohos_util_Vector.js index 99ee215c..83fcad63 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_util_Vector.js +++ b/runtime/main/extend/systemplugin/napi/ohos_util_Vector.js @@ -17,9 +17,9 @@ import { paramMock } from "../utils" export function mockVector() { const paramVector = { - paramAnyMock : '[PC Preview] unknow any', - paramVectorMock : '[PC Preview] unknow Vector', - paramIterMock : '[PC Preview] unknow IterableIterator' + paramAnyMock: '[PC Preview] unknow any', + paramVectorMock: '[PC Preview] unknow Vector', + paramIterMock: '[PC Preview] unknow IterableIterator' } const VectorClass = class Vector { @@ -163,27 +163,27 @@ export function mockVector() { 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 - }; + this[Symbol.iterator] = function (...args) { + 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 IteratorMock; + } } } return VectorClass;