1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { paramMock } from "../utils" 17 18export function mockLightWeightMap() { 19 const paramLightWeightMap = { 20 paramAnyMock_K : '[PC Preview] unknow any_k', 21 paramAnyMock_V : '[PC Preview] unknow any_v' 22 } 23 const LightWeightMapClass = class LightWeightMap { 24 constructor(...args) { 25 console.warn('util.LightWeightMap interface mocked in the Previewer. How this interface works on the Previewer' + 26 ' may be different from that on a real device.'); 27 this.length = '[PC preview] unknow length'; 28 this.hasAll = function (...args) { 29 console.warn("LightWeightMap.hasAll interface mocked in the Previewer. How this interface works on the Previewer" + 30 " may be different from that on a real device.") 31 return paramMock.paramBooleanMock; 32 }; 33 this.hasKey = function (...args) { 34 console.warn("LightWeightMap.hasKey interface mocked in the Previewer. How this interface works on the Previewer" + 35 " may be different from that on a real device.") 36 return paramMock.paramBooleanMock; 37 }; 38 this.hasValue = function (...args) { 39 console.warn("LightWeightMap.hasValue interface mocked in the Previewer. How this interface works on the Previewer" + 40 " may be different from that on a real device.") 41 return paramMock.paramBooleanMock; 42 }; 43 this.increaseCapacityTo = function (...args) { 44 console.warn("LightWeightMap.increaseCapacityTo interface mocked in the Previewer. How this interface works on the Previewer" + 45 " may be different from that on a real device.") 46 }; 47 this.entries = function (...args) { 48 console.warn('LightWeightMap.entries interface mocked in the Previewer. How this interface works on the Previewer' + 49 ' may be different from that on a real device.'); 50 const IteratorEntriesMock = { 51 *[Symbol.iterator]() { 52 yield [paramLightWeightMap.paramAnyMock_K, paramHashMap.paramAnyMock_V]; 53 } 54 }; 55 return IteratorEntriesMock; 56 } 57 this.get = function (...args) { 58 console.warn("LightWeightMap.get interface mocked in the Previewer. How this interface works on the Previewer" + 59 " may be different from that on a real device.") 60 return paramLightWeightMap.paramAnyMock_V; 61 }; 62 this.getIndexOfKey = function (...args) { 63 console.warn("LightWeightMap.getIndexOfKey interface mocked in the Previewer. How this interface works on the Previewer" + 64 " may be different from that on a real device.") 65 return paramMock.paramNumberMock; 66 }; 67 this.getIndexOfValue = function (...args) { 68 console.warn("LightWeightMap.getIndexOfValue interface mocked in the Previewer. How this interface works on the Previewer" + 69 " may be different from that on a real device.") 70 return paramMock.paramNumberMock; 71 }; 72 this.isEmpty = function (...args) { 73 console.warn("LightWeightMap.isEmpty interface mocked in the Previewer. How this interface works on the Previewer" + 74 " may be different from that on a real device.") 75 return paramMock.paramBooleanMock; 76 }; 77 this.getKeyAt = function (...args) { 78 console.warn("LightWeightMap.getKeyAt interface mocked in the Previewer. How this interface works on the Previewer" + 79 " may be different from that on a real device.") 80 return paramLightWeightMap.paramAnyMock_K; 81 }; 82 this.keys = function (...args) { 83 console.warn('LightWeightMap.keys interface mocked in the Previewer. How this interface works on the Previewer' + 84 ' may be different from that on a real device.'); 85 const IteratorKMock = { 86 *[Symbol.iterator]() { 87 yield paramLightWeightMap.paramAnyMock_K; 88 } 89 }; 90 return IteratorKMock; 91 }; 92 this.setAll = function (...args) { 93 console.warn("LightWeightMap.setAll interface mocked in the Previewer. How this interface works on the Previewer" + 94 " may be different from that on a real device.") 95 }; 96 this.set = function (...args) { 97 console.warn("LightWeightMap.set interface mocked in the Previewer. How this interface works on the Previewer" + 98 " may be different from that on a real device.") 99 return paramMock.paramObjectMock; 100 }; 101 this.remove = function (...args) { 102 console.warn("LightWeightMap.remove interface mocked in the Previewer. How this interface works on the Previewer" + 103 " may be different from that on a real device.") 104 return paramLightWeightMap.paramAnyMock_V; 105 }; 106 this.removeAt = function (...args) { 107 console.warn("LightWeightMap.removeAt interface mocked in the Previewer. How this interface works on the Previewer" + 108 " may be different from that on a real device.") 109 return paramMock.paramBooleanMock; 110 }; 111 this.clear = function (...args) { 112 console.warn("LightWeightMap.clear interface mocked in the Previewer. How this interface works on the Previewer" + 113 " may be different from that on a real device.") 114 }; 115 this.setValueAt = function (...args) { 116 console.warn("LightWeightMap.setValueAt interface mocked in the Previewer. How this interface works on the Previewer" + 117 " may be different from that on a real device.") 118 return paramMock.paramBooleanMock; 119 }; 120 this.forEach = function (...args) { 121 console.warn("LightWeightMap.forEach interface mocked in the Previewer. How this interface works on the Previewer" + 122 " may be different from that on a real device.") 123 if (this.args[0] === 'function') { 124 args[0].call(this, paramMock.businessErrorMock) 125 } 126 }; 127 this.toString = function (...args) { 128 console.warn("LightWeightMap.toString interface mocked in the Previewer. How this interface works on the Previewer" + 129 " may be different from that on a real device.") 130 return paramMock.paramStringMock; 131 }; 132 this.getValueAt = function (...args) { 133 console.warn("LightWeightMap.getValueAt interface mocked in the Previewer. How this interface works on the Previewer" + 134 " may be different from that on a real device.") 135 return paramLightWeightMap.paramAnyMock_V; 136 }; 137 this.values = function (...args) { 138 console.warn('LightWeightMap.values interface mocked in the Previewer. How this interface works on the Previewer' + 139 ' may be different from that on a real device.'); 140 const IteratorVMock = { 141 *[Symbol.iterator]() { 142 yield paramLightWeightMap.paramAnyMock_V; 143 } 144 }; 145 return IteratorVMock; 146 }; 147 this[Symbol.iterator] = function (...args) { 148 console.warn("LightWeightMap.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + 149 " may be different from that on a real device.") 150 let index = 0; 151 const IteratorMock = { 152 next: () => { 153 if (index < 1) { 154 const returnValue = [paramLightWeightMap.paramAnyMock_K, paramLightWeightMap.paramAnyMock_V]; 155 index++; 156 return { 157 value: returnValue, 158 done: false 159 }; 160 } else { 161 return { 162 done: true 163 }; 164 } 165 } 166 }; 167 return IteratorMock; 168 } 169 } 170 } 171 return LightWeightMapClass; 172}