1/* 2 * Copyright (c) 2021 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 mockUtil() { 19 const result = { 20 printf: function (...args) { 21 console.warn("util.printf interface mocked in the Previewer. How this interface works on the Previewer" + 22 " may be different from that on a real device.") 23 return paramMock.paramStringMock; 24 }, 25 getErrorString: function (...args) { 26 console.warn("util.getErrorString interface mocked in the Previewer. How this interface works on the Previewer" + 27 " may be different from that on a real device.") 28 return paramMock.paramStringMock; 29 }, 30 callbackWrapper: function (...args) { 31 console.warn("util.callbackWrapper interface mocked in the Previewer. How this interface works on the Previewer" + 32 " may be different from that on a real device.") 33 }, 34 promiseWrapper: function (...args) { 35 console.warn("util.promiseWrapper interface mocked in the Previewer. How this interface works on the Previewer" + 36 " may be different from that on a real device.") 37 return paramMock.paramObjectMock; 38 }, 39 TextDecoder: function (...args) { 40 console.warn("util.TextDecoder interface mocked in the Previewer. How this interface works on the Previewer" + 41 " may be different from that on a real device.") 42 return TextDecoderMock; 43 }, 44 TextEncoder: function (...args) { 45 console.warn("util.TextEncoder interface mocked in the Previewer. How this interface works on the Previewer" + 46 " may be different from that on a real device.") 47 return TextEncoderMock; 48 }, 49 RationalNumber: function (...args) { 50 console.warn("util.RationalNumber interface mocked in the Previewer. How this interface works on the Previewer" + 51 " may be different from that on a real device.") 52 return RationalNumberMock; 53 }, 54 LruBuffer: function (...args) { 55 console.warn("util.Lrubuffer interface mocked in the Previewer. How this interface works on the Previewer" + 56 " may be different from that on a real device.") 57 return LrubufferMock; 58 }, 59 Scope: function (...args) { 60 console.warn("util.Scope interface mocked in the Previewer. How this interface works on the Previewer" + 61 " may be different from that on a real device.") 62 return ScopeMock; 63 }, 64 Base64: function (...args) { 65 console.warn("util.Base64 interface mocked in the Previewer. How this interface works on the Previewer" + 66 " may be different from that on a real device.") 67 return Base64Mock; 68 }, 69 Types: function (...args) { 70 console.warn("util.Types interface mocked in the Previewer. How this interface works on the Previewer" + 71 " may be different from that on a real device.") 72 return TypesMock; 73 } 74 } 75 const TextDecoderMock = { 76 encoding: '[PC preview] unknow encoding', 77 fatal: '[PC preview] unknow fatal', 78 ignoreBOM: '[PC preview] unknow ignoreBOM', 79 decode: function (...args) { 80 console.warn("TextDecoder.decode interface mocked in the Previewer. How this interface works on the Previewer" + 81 " may be different from that on a real device.") 82 return paramMock.paramStringMock; 83 } 84 } 85 const TextEncoderMock = { 86 encoding: '[PC preview] unknow encoding', 87 encode: function (...args) { 88 console.warn("TextEncoder.encode interface mocked in the Previewer. How this interface works on the Previewer" + 89 " may be different from that on a real device.") 90 const arr = new Uint8Array() 91 return arr; 92 }, 93 encodeInto: function (...args) { 94 console.warn("TextEncoder.encodeInto interface mocked in the Previewer. How this interface works on the Previewer" + 95 " may be different from that on a real device.") 96 return paramMock.paramObjectMock; 97 } 98 } 99 const RationalNumberMock = { 100 createRationalFromString: function (...args) { 101 console.warn("RationalNumber.createRationalFromString interface mocked in the Previewer. How this interface works on the Previewer" + 102 " may be different from that on a real device.") 103 return paramMock.paramObjectMock; 104 }, 105 compareTo: function (...args) { 106 console.warn("RationalNumber.compareTo interface mocked in the Previewer. How this interface works on the Previewer" + 107 " may be different from that on a real device.") 108 return paramMock.paramNumberMock; 109 }, 110 equals: function (...args) { 111 console.warn("RationalNumber.equals interface mocked in the Previewer. How this interface works on the Previewer" + 112 " may be different from that on a real device.") 113 return paramMock.paramBooleanMock; 114 }, 115 valueOf: function (...args) { 116 console.warn("RationalNumber.valueOf 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.paramNumberMock; 119 }, 120 getCommonDivisor: function (...args) { 121 console.warn("RationalNumber.getCommonDivisor interface mocked in the Previewer. How this interface works on the Previewer" + 122 " may be different from that on a real device.") 123 return paramMock.paramNumberMock; 124 }, 125 getDenominator: function (...args) { 126 console.warn("RationalNumber.getDenominator interface mocked in the Previewer. How this interface works on the Previewer" + 127 " may be different from that on a real device.") 128 return paramMock.paramNumberMock; 129 }, 130 getNumerator: function (...args) { 131 console.warn("RationalNumber.getNumerator interface mocked in the Previewer. How this interface works on the Previewer" + 132 " may be different from that on a real device.") 133 return paramMock.paramNumberMock; 134 }, 135 isFinite: function (...args) { 136 console.warn("RationalNumber.isFinite interface mocked in the Previewer. How this interface works on the Previewer" + 137 " may be different from that on a real device.") 138 return paramMock.paramBooleanMock; 139 }, 140 isNaN: function (...args) { 141 console.warn("RationalNumber.isNaN interface mocked in the Previewer. How this interface works on the Previewer" + 142 " may be different from that on a real device.") 143 return paramMock.paramBooleanMock; 144 }, 145 isZero: function (...args) { 146 console.warn("RationalNumber.isZero interface mocked in the Previewer. How this interface works on the Previewer" + 147 " may be different from that on a real device.") 148 return paramMock.paramBooleanMock; 149 }, 150 toString: function (...args) { 151 console.warn("RationalNumber.toString interface mocked in the Previewer. How this interface works on the Previewer" + 152 "may be different from that on a real device.") 153 return paramMock.paramStringMock; 154 } 155 } 156 const LrubufferMock = { 157 length: '[PC preview] unknow length', 158 updateCapacity: function (...args) { 159 console.warn("Lrubuffer.updateCapacity interface mockecd in the Previewer. How this interface works on the Previewer" + 160 "may be different from that on a real device.") 161 }, 162 toString: function (...args) { 163 console.warn("Lrubuffer.toString interface mockecd in the Previewer. How this interface works on the Previewer" + 164 "may be different from that on a real device.") 165 return paramMock.paramStringMock; 166 }, 167 getCapacity: function (...args) { 168 console.warn("Lrubuffer.getCapacity interface mockecd in the Previewer. How this interface works on the Previewer" + 169 "may be different from that on a real device.") 170 return paramMock.paramNumberMock; 171 }, 172 clear: function (...args) { 173 console.warn("Lrubuffer.clear interface mockecd in the Previewer. How this interface works on the Previewer" + 174 "may be different from that on a real device.") 175 }, 176 getCreateCount: function (...args) { 177 console.warn("Lrubuffer.getCreateCount interface mockecd in the Previewer. How this interface works on the Previewer" + 178 "may be different from that on a real device.") 179 return paramMock.paramNumberMock; 180 }, 181 getMissCount: function (...args) { 182 console.warn("Lrubuffer.getMissCount interface mockecd in the Previewer. How this interface works on the Previewer" + 183 "may be different from that on a real device.") 184 return paramMock.paramNumberMock; 185 }, 186 getRemovalCount: function (...args) { 187 console.warn("Lrubuffer.getRemovalCount interface mockecd in the Previewer. How this interface works on the Previewer" + 188 "may be different from that on a real device.") 189 return paramMock.paramNumberMock; 190 }, 191 getMatchCount: function (...args) { 192 console.warn("Lrubuffer.getMatchCount interface mockecd in the Previewer. How this interface works on the Previewer" + 193 "may be different from that on a real device.") 194 return paramMock.paramNumberMock; 195 }, 196 getPutCount: function (...args) { 197 console.warn("Lrubuffer.getPutCount interface mockecd in the Previewer. How this interface works on the Previewer" + 198 "may be different from that on a real device.") 199 return paramMock.paramNumberMock; 200 }, 201 isEmpty: function (...args) { 202 console.warn("Lrubuffer.isEmpty interface mockecd in the Previewer. How this interface works on the Previewer" + 203 "may be different from that on a real device.") 204 return paramMock.paramBooleanMock; 205 }, 206 get: function (...args) { 207 console.warn("Lrubuffer.get interface mockecd in the Previewer. How this interface works on the Previewer" + 208 "may be different from that on a real device.") 209 return paramMock.paramObjectMock; 210 }, 211 put: function (...args) { 212 console.warn("Lrubuffer.put interface mockecd in the Previewer. How this interface works on the Previewer" + 213 "may be different from that on a real device.") 214 return paramMock.paramObjectMock; 215 }, 216 values: function (...args) { 217 console.warn("Lrubuffer.values interface mockecd in the Previewer. How this interface works on the Previewer" + 218 "may be different from that on a real device.") 219 return paramMock.paramObjectMock; 220 }, 221 keys: function (...args) { 222 console.warn("Lrubuffer.keys interface mockecd in the Previewer. How this interface works on the Previewer" + 223 "may be different from that on a real device.") 224 return paramMock.paramObjectMock; 225 }, 226 remove: function (...args) { 227 console.warn("Lrubuffer.remove interface mockecd in the Previewer. How this interface works on the Previewer" + 228 "may be different from that on a real device.") 229 return paramMock.paramObjectMock; 230 }, 231 afterRemoval: function (...args) { 232 console.warn("Lrubuffer.afterRemoval interface mockecd in the Previewer. How this interface works on the Previewer" + 233 "may be different from that on a real device.") 234 }, 235 contains: function (...args) { 236 console.warn("Lrubuffer.contains interface mockecd in the Previewer. How this interface works on the Previewer" + 237 "may be different from that on a real device.") 238 return paramMock.paramBooleanMock; 239 }, 240 createDefault: function (...args) { 241 console.warn("Lrubuffer.createDefault interface mockecd in the Previewer. How this interface works on the Previewer" + 242 "may be different from that on a real device.") 243 return paramMock.paramObjectMock; 244 }, 245 entries: function (...args) { 246 console.warn("Lrubuffer.entries interface mockecd in the Previewer. How this interface works on the Previewer" + 247 "may be different from that on a real device.") 248 return paramMock.paramObjectMock; 249 }, 250 [Symbol.iterator]: function (...args) { 251 console.warn("Lrubuffer.[Symbol.iterator] interface mockecd in the Previewer. How this interface works on the Previewer" + 252 "may be different from that on a real device.") 253 return paramMock.paramObjectMock; 254 } 255 } 256 const ScopeMock = { 257 toString: function (...args) { 258 console.warn("Scope.toString interface mockecd in the Previewer. How this interface works on the Previewer" + 259 "may be different from that on a real device.") 260 return paramMock.paramStringMock; 261 }, 262 intersect: function (...args) { 263 console.warn("Scope.intersect interface mockecd in the Previewer. How this interface works on the Previewer" + 264 "may be different from that on a real device.") 265 return paramMock.paramScopeMock; 266 }, 267 intersect: function (...args) { 268 console.warn("Scope.intersect interface mockecd in the Previewer. How this interface works on the Previewer" + 269 "may be different from that on a real device.") 270 return paramMock.paramScopeMock; 271 }, 272 getUpper: function (...args) { 273 console.warn("Scope.getUpper interface mockecd in the Previewer. How this interface works on the Previewer" + 274 "may be different from that on a real device.") 275 return paramMock.paramScopeTypeMock; 276 }, 277 getLower: function (...args) { 278 console.warn("Scope.getLower interface mockecd in the Previewer. How this interface works on the Previewer" + 279 "may be different from that on a real device.") 280 return paramMock.paramScopeTypeMock; 281 }, 282 expand: function (...args) { 283 console.warn("Scope.expand interface mockecd in the Previewer. How this interface works on the Previewer" + 284 "may be different from that on a real device.") 285 return paramMock.paramScopeMock; 286 }, 287 expand: function (...args) { 288 console.warn("Scope.expand interface mockecd in the Previewer. How this interface works on the Previewer" + 289 "may be different from that on a real device.") 290 return paramMock.paramScopeMock; 291 }, 292 expand: function (...args) { 293 console.warn("Scope.expand interface mockecd in the Previewer. How this interface works on the Previewer" + 294 "may be different from that on a real device.") 295 return paramMock.paramScopeMock; 296 }, 297 contains: function (...args) { 298 console.warn("Scope.contains interface mockecd in the Previewer. How this interface works on the Previewer" + 299 "may be different from that on a real device.") 300 return paramMock.paramBooleanMock; 301 }, 302 contains: function (...args) { 303 console.warn("Scope.contains interface mockecd in the Previewer. How this interface works on the Previewer" + 304 "may be different from that on a real device.") 305 return paramMock.paramBooleanMock; 306 }, 307 clamp: function (...args) { 308 console.warn("Scope.clamp interface mockecd in the Previewer. How this interface works on the Previewer" + 309 "may be different from that on a real device.") 310 return paramMock.paramScopeTypeMock; 311 } 312 } 313 const Base64Mock = { 314 encodeSync: function (...args) { 315 console.warn("Base64.encodeSync interface mocked in the Previewer. How this interface works on the Previewer" + 316 " may be different from that on a real device.") 317 const arr = new Uint8Array() 318 return arr; 319 }, 320 encodeToStringSync: function (...args) { 321 console.warn("Base64.encodeToStringSync interface mocked in the Previewer. How this interface works on the Previewer" + 322 " may be different from that on a real device.") 323 return paramMock.paramStringMock; 324 }, 325 decodeSync: function (...args) { 326 console.warn("Base64.decodeSync interface mocked in the Previewer. How this interface works on the Previewer" + 327 " may be different from that on a real device.") 328 const arr = new Uint8Array() 329 return arr; 330 }, 331 encode: function (...args) { 332 console.warn("Base64.encode interface mocked in the Previewer. How this interface works on the Previewer" + 333 " may be different from that on a real device.") 334 const arr = new Uint8Array() 335 return new Promise((resolve, reject) => { 336 resolve(arr); 337 }) 338 }, 339 encodeToString: function (...args) { 340 console.warn("Base64.encodeToString interface mocked in the Previewer. How this interface works on the Previewer" + 341 " may be different from that on a real device.") 342 return new Promise((resolve, reject) => { 343 resolve(paramMock.paramStringMock); 344 }) 345 }, 346 decode: function (...args) { 347 console.warn("Base64.decode interface mocked in the Previewer. How this interface works on the Previewer" + 348 " may be different from that on a real device.") 349 const arr = new Uint8Array() 350 return new Promise((resolve, reject) => { 351 resolve(arr); 352 }) 353 } 354 } 355 const TypesMock = { 356 isAnyArrayBuffer: function (...args) { 357 console.warn("Types.isAnyArrayBuffer interface mocked in the Previewer. How this interface works on the Previewer" + 358 " may be different from that on a real device.") 359 return paramMock.paramBooleanMock; 360 }, 361 isArrayBufferView: function (...args) { 362 console.warn("Types.isArrayBufferView interface mocked in the Previewer. How this interface works on the Previewer" + 363 " may be different from that on a real device.") 364 return paramMock.paramBooleanMock; 365 }, 366 isArgumentsObject: function (...args) { 367 console.warn("Types.isArgumentsObject interface mocked in the Previewer. How this interface works on the Previewer" + 368 " may be different from that on a real device.") 369 return paramMock.paramBooleanMock; 370 }, 371 isArrayBuffer: function (...args) { 372 console.warn("Types.isArrayBuffer interface mocked in the Previewer. How this interface works on the Previewer" + 373 " may be different from that on a real device.") 374 return paramMock.paramBooleanMock; 375 }, 376 isAsyncFunction: function (...args) { 377 console.warn("Types.isAsyncFunction interface mocked in the Previewer. How this interface works on the Previewer" + 378 " may be different from that on a real device.") 379 return paramMock.paramBooleanMock; 380 }, 381 isBigInt64Array: function (...args) { 382 console.warn("Types.isBigInt64Array interface mocked in the Previewer. How this interface works on the Previewer" + 383 " may be different from that on a real device.") 384 return paramMock.paramBooleanMock; 385 }, 386 isBigUint64Array: function (...args) { 387 console.warn("Types.isBigUint64Array interface mocked in the Previewer. How this interface works on the Previewer" + 388 " may be different from that on a real device.") 389 return paramMock.paramBooleanMock; 390 }, 391 isBooleanObject: function (...args) { 392 console.warn("Types.isBooleanObject interface mocked in the Previewer. How this interface works on the Previewer" + 393 " may be different from that on a real device.") 394 return paramMock.paramBooleanMock; 395 }, 396 isBoxedPrimitive: function (...args) { 397 console.warn("Types.isBoxedPrimitive interface mocked in the Previewer. How this interface works on the Previewer" + 398 " may be different from that on a real device.") 399 return paramMock.paramBooleanMock; 400 }, 401 isDataView: function (...args) { 402 console.warn("Types.isDataView interface mocked in the Previewer. How this interface works on the Previewer" + 403 " may be different from that on a real device.") 404 return paramMock.paramBooleanMock; 405 }, 406 isDate: function (...args) { 407 console.warn("Types.isDate interface mocked in the Previewer. How this interface works on the Previewer" + 408 " may be different from that on a real device.") 409 return paramMock.paramBooleanMock; 410 }, 411 isExternal: function (...args) { 412 console.warn("Types.isExternal interface mocked in the Previewer. How this interface works on the Previewer" + 413 " may be different from that on a real device.") 414 return paramMock.paramBooleanMock; 415 }, 416 isFloat32Array: function (...args) { 417 console.warn("Types.isFloat32Array interface mocked in the Previewer. How this interface works on the Previewer" + 418 " may be different from that on a real device.") 419 return paramMock.paramBooleanMock; 420 }, 421 isFloat64Array: function (...args) { 422 console.warn("Types.isFloat64Array interface mocked in the Previewer. How this interface works on the Previewer" + 423 " may be different from that on a real device.") 424 return paramMock.paramBooleanMock; 425 }, 426 isGeneratorFunction: function (...args) { 427 console.warn("Types.isGeneratorFunction interface mocked in the Previewer. How this interface works on the Previewer" + 428 " may be different from that on a real device.") 429 return paramMock.paramBooleanMock; 430 }, 431 isGeneratorObject: function (...args) { 432 console.warn("Types.isGeneratorObject interface mocked in the Previewer. How this interface works on the Previewer" + 433 " may be different from that on a real device.") 434 return paramMock.paramBooleanMock; 435 }, 436 isInt8Array: function (...args) { 437 console.warn("Types.isInt8Array interface mocked in the Previewer. How this interface works on the Previewer" + 438 " may be different from that on a real device.") 439 return paramMock.paramBooleanMock; 440 }, 441 isInt16Array: function (...args) { 442 console.warn("Types.isInt16Array interface mocked in the Previewer. How this interface works on the Previewer" + 443 " may be different from that on a real device.") 444 return paramMock.paramBooleanMock; 445 }, 446 isInt32Array: function (...args) { 447 console.warn("Types.isInt32Array interface mocked in the Previewer. How this interface works on the Previewer" + 448 " may be different from that on a real device.") 449 return paramMock.paramBooleanMock; 450 }, 451 isMap: function (...args) { 452 console.warn("Types.isMap interface mocked in the Previewer. How this interface works on the Previewer" + 453 " may be different from that on a real device.") 454 return paramMock.paramBooleanMock; 455 }, 456 isMapIterator: function (...args) { 457 console.warn("Types.isMapIterator interface mocked in the Previewer. How this interface works on the Previewer" + 458 " may be different from that on a real device.") 459 return paramMock.paramBooleanMock; 460 }, 461 isModuleNamespaceObject: function (...args) { 462 console.warn("Types.isModuleNamespaceObject interface mocked in the Previewer. How this interface works on the Previewer" + 463 " may be different from that on a real device.") 464 return paramMock.paramBooleanMock; 465 }, 466 isNativeError: function (...args) { 467 console.warn("Types.isNativeError interface mocked in the Previewer. How this interface works on the Previewer" + 468 " may be different from that on a real device.") 469 return paramMock.paramBooleanMock; 470 }, 471 isNumberObject: function (...args) { 472 console.warn("Types.isNumberObject interface mocked in the Previewer. How this interface works on the Previewer" + 473 " may be different from that on a real device.") 474 return paramMock.paramBooleanMock; 475 }, 476 isPromise: function (...args) { 477 console.warn("Types.isPromise interface mocked in the Previewer. How this interface works on the Previewer" + 478 " may be different from that on a real device.") 479 return paramMock.paramBooleanMock; 480 }, 481 isProxy: function (...args) { 482 console.warn("Types.isProxy interface mocked in the Previewer. How this interface works on the Previewer" + 483 " may be different from that on a real device.") 484 return paramMock.paramBooleanMock; 485 }, 486 isRegExp: function (...args) { 487 console.warn("Types.isRegExp interface mocked in the Previewer. How this interface works on the Previewer" + 488 " may be different from that on a real device.") 489 return paramMock.paramBooleanMock; 490 }, 491 isSet: function (...args) { 492 console.warn("Types.isSet interface mocked in the Previewer. How this interface works on the Previewer" + 493 " may be different from that on a real device.") 494 return paramMock.paramBooleanMock; 495 }, 496 isSetIterator: function (...args) { 497 console.warn("Types.isSetIterator interface mocked in the Previewer. How this interface works on the Previewer" + 498 " may be different from that on a real device.") 499 return paramMock.paramBooleanMock; 500 }, 501 isSharedArrayBuffer: function (...args) { 502 console.warn("Types.isSharedArrayBuffer interface mocked in the Previewer. How this interface works on the Previewer" + 503 " may be different from that on a real device.") 504 return paramMock.paramBooleanMock; 505 }, 506 isStringObject: function (...args) { 507 console.warn("Types.isStringObject interface mocked in the Previewer. How this interface works on the Previewer" + 508 " may be different from that on a real device.") 509 return paramMock.paramBooleanMock; 510 }, 511 isSymbolObject: function (...args) { 512 console.warn("Types.isSymbolObject interface mocked in the Previewer. How this interface works on the Previewer" + 513 " may be different from that on a real device.") 514 return paramMock.paramBooleanMock; 515 }, 516 isTypedArray: function (...args) { 517 console.warn("Types.isTypedArray interface mocked in the Previewer. How this interface works on the Previewer" + 518 " may be different from that on a real device.") 519 return paramMock.paramBooleanMock; 520 }, 521 isUint8Array: function (...args) { 522 console.warn("Types.isUint8Array interface mocked in the Previewer. How this interface works on the Previewer" + 523 " may be different from that on a real device.") 524 return paramMock.paramBooleanMock; 525 }, 526 isUint8ClampedArray: function (...args) { 527 console.warn("Types.isUint8ClampedArray interface mocked in the Previewer. How this interface works on the Previewer" + 528 " may be different from that on a real device.") 529 return paramMock.paramBooleanMock; 530 }, 531 isUint16Array: function (...args) { 532 console.warn("Types.isUint16Array interface mocked in the Previewer. How this interface works on the Previewer" + 533 " may be different from that on a real device.") 534 return paramMock.paramBooleanMock; 535 }, 536 isUint32Array: function (...args) { 537 console.warn("Types.isUint32Array interface mocked in the Previewer. How this interface works on the Previewer" + 538 " may be different from that on a real device.") 539 return paramMock.paramBooleanMock; 540 }, 541 isWeakMap: function (...args) { 542 console.warn("Types.isWeakMap interface mocked in the Previewer. How this interface works on the Previewer" + 543 " may be different from that on a real device.") 544 return paramMock.paramBooleanMock; 545 }, 546 isWeakSet: function (...args) { 547 console.warn("Types.isWeakSet interface mocked in the Previewer. How this interface works on the Previewer" + 548 " may be different from that on a real device.") 549 return paramMock.paramBooleanMock; 550 } 551 } 552 return result; 553}