1/* 2 * Copyright (c) 2021-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" 17import { PixelMapMock } from "./ohos_multimedia_image" 18 19export const WindowType = { 20 TYPE_APP: 0, 21 TYPE_SYSTEM_ALERT: 1, 22 TYPE_INPUT_METHOD: 2, 23 TYPE_STATUS_BAR: 3, 24 TYPE_PANEL: 4, 25 TYPE_KEYGUARD: 5, 26 TYPE_VOLUME_OVERLAY: 6, 27 TYPE_NAVIGATION_BAR: 7, 28 TYPE_FLOAT: 8, 29 TYPE_WALLPAPER: 9, 30 TYPE_DESKTOP: 10, 31 TYPE_LAUNCHER_RECENT: 11, 32 TYPE_LAUNCHER_DOCK: 12, 33 TYPE_VOICE_INTERACTION: 13, 34 TYPE_POINTER: 14, 35 TYPE_FLOAT_CAMERA: 15, 36 TYPE_DIALOG: 16, 37 TYPE_SCREENSHOT: 17 38} 39 40export const AvoidAreaType= { 41 TYPE_SYSTEM: 0, 42 TYPE_CUTOUT: 1, 43 TYPE_SYSTEM_GESTURE: 2, 44 TYPE_KEYBOARD: 3 45} 46 47export const Orientation = { 48 UNSPECIFIED: 0, 49 PORTRAIT: 1, 50 LANDSCAPE: 2, 51 PORTRAIT_INVERTED: 3, 52 LANDSCAPE_INVERTED: 4, 53 AUTO_ROTATION: 5, 54 AUTO_ROTATION_PORTRAIT: 6, 55 AUTO_ROTATION_LANDSCAPE: 7, 56 AUTO_ROTATION_RESTRICTED: 8, 57 AUTO_ROTATION_PORTRAIT_RESTRICTED: 9, 58 AUTO_ROTATION_LANDSCAPE_RESTRICTED: 10, 59 LOCKED: 11 60} 61 62 63export const WindowMode= { 64 UNDEFINED: 1, 65 FULLSCREEN: 2, 66 PRIMARY: 3, 67 SECONDARY: 4, 68 FLOATING: 5 69} 70 71export const WindowLayoutMode= { 72 WINDOW_LAYOUT_MODE_CASCADE: 0, 73 WINDOW_LAYOUT_MODE_TILE: 1 74} 75 76export const SystemBarProperties= { 77 statusBarColor: '[PC preview] unknow statusBarColor', 78 isStatusBarLightIcon: '[PC preview] unknow isStatusBarLightIcon', 79 statusBarContentColor: '[PC preview] unknow statusBarContentColor', 80 navigationBarColor: '[PC preview] unknow navigationBarColor', 81 isNavigationBarLightIcon: '[PC preview] unknow isNavigationBarLightIcon', 82 navigationBarContentColor: '[PC preview] unknow navigationBarContentColor' 83} 84 85export const Rect = { 86 left: '[PC preview] unknow Rect.left', 87 top: '[PC preview] unknow Rect.top', 88 width: '[PC preview] unknow Rect.width', 89 height: '[PC preview] unknow Rect.height' 90} 91 92export const SystemBarRegionTint = { 93 type: WindowType, 94 isEnable: '[PC preview] unknow isEnable', 95 region: Rect, 96 backgroundColor: '[PC preview] unknow backgroundColor', 97 contentColor: '[PC preview] unknow contentColor' 98} 99 100export const SystemBarTintState = { 101 displayId: '[PC preview] unknow brightness', 102 regionTint:[SystemBarRegionTint] 103} 104 105export const AvoidArea = { 106 visible: '[PC preview] unknow AvoidArea.visible', 107 leftRect: Rect, 108 topRect: Rect, 109 rightRect: Rect, 110 bottomRect: Rect 111} 112 113export const Size = { 114 width: '[PC preview] unknow width', 115 height: '[PC preview] unknow height' 116} 117 118export const WindowProperties = { 119 windowRect: '[PC preview] unknow windowRect', 120 type: '[PC preview] unknow type', 121 brightness: '[PC preview] unknow brightness', 122 isTransparent: '[PC preview] unknow isTransparent', 123 isFullScreen: '[PC preview] unknow isFullScreen', 124 isKeepScreenOn: '[PC preview] unknow isKeepScreenOn', 125 dimBehindValue: '[PC preview] unknow dimBehindValue', 126 isLayoutFullScreen: '[PC preview] unknow isLayoutFullScreen', 127 focusable: '[PC preview] unknow focusable', 128 touchable: '[PC preview] unknow touchable', 129 isPrivacyMode: '[PC preview] unknow isPrivacyMode', 130 isRoundCorner: '[PC preview] unknow isRoundCorner' 131} 132 133export const ColorSpace = { 134 DEFAULT: 0, 135 WIDE_GAMUT: 1 136} 137 138const TransitionController = { 139 animationForShown : function(...args) { 140 console.warn("TransitionController.animationForShown interface mocked in the Previewer. How this interface works on the" + 141 " Previewer may be different from that on a real device.") 142 }, 143 animationForHidden : function(...args) { 144 console.warn("TransitionController.animationForHidden interface mocked in the Previewer. How this interface works on the" + 145 " Previewer may be different from that on a real device.") 146 } 147} 148 149const TransitionContext = { 150 toWindow: Window, 151 completeTransition : function(...args) { 152 console.warn("TransitionContext.completeTransition interface mocked in the Previewer. How this interface works on the" + 153 " Previewer may be different from that on a real device.") 154 } 155} 156 157export const WindowStageEventType = { 158 FOREGROUND: 1, 159 ACTIVE: 2, 160 INACTIVE: 3, 161 BACKGROUND: 4 162} 163 164export const WindowStage = { 165 getMainWindow: function(...args) { 166 console.warn("WindowStage.getMainWindow interface mocked in the Previewer. How this interface works on the Previewer" + 167 " may be different from that on a real device.") 168 const len = args.length 169 if (typeof args[len - 1] === 'function') { 170 args[len - 1].call(this, paramMock.businessErrorMock, Window) 171 } else { 172 return new Promise((resolve) => { 173 resolve(Window) 174 }) 175 } 176 }, 177 createSubWindow: function(...args) { 178 console.warn("WindowStage.createSubWindow interface mocked in the Previewer. How this interface works on the Previewer" + 179 " may be different from that on a real device.") 180 const len = args.length 181 if (typeof args[len - 1] === 'function') { 182 args[len - 1].call(this, paramMock.businessErrorMock, Window) 183 } else { 184 return new Promise((resolve) => { 185 resolve(Window) 186 }) 187 } 188 }, 189 getSubWindow: function(...args) { 190 console.warn("WindowStage.getSubWindow interface mocked in the Previewer. How this interface works on the Previewer" + 191 " may be different from that on a real device.") 192 const len = args.length 193 if (typeof args[len - 1] === 'function') { 194 args[len - 1].call(this, paramMock.businessErrorMock, [Window]) 195 } else { 196 return new Promise((resolve) => { 197 resolve([Window]) 198 }) 199 } 200 }, 201 loadContent: function(...args) { 202 console.warn("WindowStage.loadContent interface mocked in the Previewer. How this interface works on the Previewer" + 203 " may be different from that on a real device.") 204 const len = args.length 205 if (typeof args[len - 1] === 'function') { 206 args[len - 1].call(this, paramMock.businessErrorMock) 207 } else { 208 return new Promise((resolve) => { 209 resolve() 210 }) 211 } 212 }, 213 on: function(...args) { 214 console.warn("WindowStage.on interface mocked in the Previewer. How this interface works on the Previewer" + 215 " may be different from that on a real device.") 216 const len = args.length 217 if (typeof args[len - 1] === 'function') { 218 if (args[0] === 'windowStageEvent') { 219 console.warn(`WindowStage.on you has registered ${args[0]} event`) 220 } else { 221 console.warn("WindowStage.on:please check first param!") 222 } 223 } else { 224 console.warn("WindowStage.on:please check param!") 225 } 226 }, 227 off: function(...args) { 228 console.warn("WindowStage.off interface mocked in the Previewer. How this interface works on the Previewer" + 229 " may be different from that on a real device.") 230 const len = args.length 231 if (typeof args[len - 1] === 'function') { 232 if (args[0] === 'windowStageEvent') { 233 console.warn(`you has registered ${args[0]} event`) 234 }else { 235 console.warn("WindowStage.off:please check first param!") 236 } 237 }else { 238 console.warn("WindowStage.off:please check param!") 239 } 240 }, 241 disableWindowDecor: function() { 242 console.warn("WindowStage.disableWindowDecor interface mocked in the Previewer. How this interface works on the Previewer" + 243 "may be different from that on a real device.") 244 }, 245 setShowOnLockScreen: function() { 246 console.warn("WindowStage.setShowOnLockScreen interface mocked in the Previewer. How this interface works on the" + 247 " Previewer may be different from that on a real device.") 248 } 249} 250 251export const Window = { 252 setBrightness: function(...args) { 253 console.warn("Window.setBrightness interface mocked in the Previewer. How this interface works on the" + 254 " Previewer may be different from that on a real device.") 255 const len = args.length 256 if (typeof args[len - 1] === 'function') { 257 args[len - 1].call(this, paramMock.businessErrorMock) 258 } else { 259 return new Promise((resolve) => { 260 resolve() 261 }) 262 } 263 }, 264 setBackgroundColor: function(...args) { 265 console.warn("Window.setBackgroundColor interface mocked in the Previewer. How this interface works on the" + 266 " Previewer may be different from that on a real device.") 267 const len = args.length 268 if (typeof args[len - 1] === 'function') { 269 args[len - 1].call(this, paramMock.businessErrorMock) 270 } else { 271 return new Promise((resolve) => { 272 resolve() 273 }) 274 } 275 }, 276 setTransparent: function(...args) { 277 console.warn("Window.setTransparent interface mocked in the Previewer. How this interface works on the" + 278 " Previewer may be different from that on a real device.") 279 const len = args.length 280 if (typeof args[len - 1] === 'function') { 281 args[len - 1].call(this, paramMock.businessErrorMock) 282 } else { 283 return new Promise((resolve) => { 284 resolve() 285 }) 286 } 287 }, 288 setFullScreen: function(...args) { 289 console.warn("Window.setFullScreen interface mocked in the Previewer. How this interface works on the" + 290 " Previewer may be different from that on a real device.") 291 const len = args.length 292 if (typeof args[len - 1] === 'function') { 293 args[len - 1].call(this, paramMock.businessErrorMock) 294 } else { 295 return new Promise((resolve) => { 296 resolve() 297 }) 298 } 299 }, 300 setKeepScreenOn: function(...args) { 301 console.warn("Window.setKeepScreenOn interface mocked in the Previewer. How this interface works on the" + 302 " Previewer may be different from that on a real device.") 303 const len = args.length 304 if (typeof args[len - 1] === 'function') { 305 args[len - 1].call(this, paramMock.businessErrorMock) 306 } else { 307 return new Promise((resolve) => { 308 resolve() 309 }) 310 } 311 }, 312 setWakeUpScreen: function(...args) { 313 console.warn("Window.setWakeUpScreen interface mocked in the Previewer. How this interface works on the" + 314 " Previewer may be different from that on a real device.") 315 }, 316 setDimBehind: function(...args) { 317 console.warn("Window.setDimBehind interface mocked in the Previewer. How this interface works on the" + 318 " Previewer may be different from that on a real device.") 319 const len = args.length 320 if (typeof args[len - 1] === 'function') { 321 args[len - 1].call(this, paramMock.businessErrorMock) 322 } else { 323 return new Promise((resolve) => { 324 resolve() 325 }) 326 } 327 }, 328 setLayoutFullScreen: function(...args) { 329 console.warn("Window.setLayoutFullScreen interface mocked in the Previewer. How this interface works on the" + 330 " Previewer may be different from that on a real device.") 331 const len = args.length 332 if (typeof args[len - 1] === 'function') { 333 args[len - 1].call(this, paramMock.businessErrorMock) 334 } else { 335 return new Promise((resolve) => { 336 resolve() 337 }) 338 } 339 }, 340 setFocusable: function(...args) { 341 console.warn("Window.setFocusable interface mocked in the Previewer. How this interface works on the" + 342 " Previewer may be different from that on a real device.") 343 const len = args.length 344 if (typeof args[len - 1] === 'function') { 345 args[len - 1].call(this, paramMock.businessErrorMock) 346 } else { 347 return new Promise((resolve) => { 348 resolve() 349 }) 350 } 351 }, 352 setTouchable: function(...args) { 353 console.warn("Window.setTouchable interface mocked in the Previewer. How this interface works on the" + 354 " Previewer may be different from that on a real device.") 355 const len = args.length 356 if (typeof args[len - 1] === 'function') { 357 args[len - 1].call(this, paramMock.businessErrorMock) 358 } else { 359 return new Promise((resolve) => { 360 resolve() 361 }) 362 } 363 }, 364 setPrivacyMode: function(...args) { 365 console.warn("Window.setPrivacyMode interface mocked in the Previewer. How this interface works on the" + 366 " Previewer may be different from that on a real device.") 367 const len = args.length 368 if (typeof args[len - 1] === 'function') { 369 args[len - 1].call(this, paramMock.businessErrorMock) 370 } else { 371 return new Promise((resolve) => { 372 resolve() 373 }) 374 } 375 }, 376 setSnapshotSkip: function(...args) { 377 console.warn("Window.setSnapshotSkip interface mocked in the Previewer. How this interface works on the" + 378 " Previewer may be different from that on a real device.") 379 }, 380 setSystemBarEnable: function(...args) { 381 console.warn("Window.setSystemBarEnable interface mocked in the Previewer. How this interface works on the" + 382 " Previewer may be different from that on a real device.") 383 const len = args.length 384 if (typeof args[len - 1] === 'function') { 385 args[len - 1].call(this, paramMock.businessErrorMock) 386 } else { 387 return new Promise((resolve) => { 388 resolve() 389 }) 390 } 391 }, 392 setSystemBarProperties: function(...args) { 393 console.warn("Window.setSystemBarProperties interface mocked in the Previewer. How this interface works on the" + 394 " Previewer may be different from that on a real device.") 395 const len = args.length 396 if (typeof args[len - 1] === 'function') { 397 args[len - 1].call(this, paramMock.businessErrorMock) 398 } else { 399 return new Promise((resolve) => { 400 resolve() 401 }) 402 } 403 }, 404 setPreferredOrientation: function(...args) { 405 console.warn("Window.setPreferredOrientation interface mocked in the Previewer. How this interface works on the" + 406 " Previewer may be different from that on a real device.") 407 const len = args.length 408 if (typeof args[len - 1] === 'function') { 409 args[len - 1].call(this, paramMock.businessErrorMock,Orientation) 410 } else { 411 return new Promise((resolve) => { 412 resolve(Orientation) 413 }) 414 } 415 }, 416 setForbidSplitMove: function(...args) { 417 console.warn("Window.setForbidSplitMove interface mocked in the Previewer. How this interface works on the" + 418 " Previewer may be different from that on a real device.") 419 const len = args.length 420 if (typeof args[len - 1] === 'function') { 421 args[len - 1].call(this, paramMock.businessErrorMock) 422 } else { 423 return new Promise((resolve) => { 424 resolve() 425 }) 426 } 427 }, 428 getProperties: function(...args) { 429 console.warn("Window.getProperties interface mocked in the Previewer. How this interface works on the" + 430 " Previewer may be different from that on a real device.") 431 const len = args.length 432 if (typeof args[len - 1] === 'function') { 433 args[len - 1].call(this, paramMock.businessErrorMock, WindowProperties) 434 } else { 435 return new Promise((resolve) => { 436 resolve(WindowProperties) 437 }) 438 } 439 }, 440 getAvoidArea: function(...args) { 441 console.warn("Window.getAvoidArea interface mocked in the Previewer. How this interface works on the" + 442 " Previewer may be different from that on a real device.") 443 const len = args.length 444 if (typeof args[len - 1] === 'function') { 445 args[len - 1].call(this, paramMock.businessErrorMock, AvoidArea) 446 } else { 447 return new Promise((resolve) => { 448 resolve(AvoidArea) 449 }) 450 } 451 }, 452 moveTo: function(...args) { 453 console.warn("Window.moveTo interface mocked in the Previewer. How this interface works on the" + 454 " Previewer may be different from that on a real device.") 455 const len = args.length 456 if (typeof args[len - 1] === 'function') { 457 args[len - 1].call(this, paramMock.businessErrorMock) 458 } else { 459 return new Promise((resolve) => { 460 resolve() 461 }) 462 } 463 }, 464 resetSize: function(...args) { 465 console.warn("Window.resetSize interface mocked in the Previewer. How this interface works on the" + 466 " Previewer may be different from that on a real device.") 467 const len = args.length 468 if (typeof args[len - 1] === 'function') { 469 args[len - 1].call(this, paramMock.businessErrorMock) 470 } else { 471 return new Promise((resolve) => { 472 resolve() 473 }) 474 } 475 }, 476 setWindowType: function(...args) { 477 console.warn("Window.setWindowType interface mocked in the Previewer. How this interface works on the" + 478 " Previewer may be different from that on a real device.") 479 const len = args.length 480 if (typeof args[len - 1] === 'function') { 481 args[len - 1].call(this, paramMock.businessErrorMock) 482 } else { 483 return new Promise((resolve) => { 484 resolve() 485 }) 486 } 487 }, 488 loadContent: function(...args) { 489 console.warn("Window.loadContent interface mocked in the Previewer. How this interface works on the" + 490 " Previewer may be different from that on a real device.") 491 const len = args.length 492 if (typeof args[len - 1] === 'function') { 493 args[len - 1].call(this, paramMock.businessErrorMock) 494 } else { 495 return new Promise((resolve) => { 496 resolve() 497 }) 498 } 499 }, 500 hide: function(...args) { 501 console.warn("Window.hide interface mocked in the Previewer. How this interface works on the" + 502 " Previewer may be different from that on a real device.") 503 const len = args.length 504 if (typeof args[len - 1] === 'function') { 505 args[len - 1].call(this, paramMock.businessErrorMock) 506 } else { 507 return new Promise((resolve) => { 508 resolve() 509 }) 510 } 511 }, 512 hideWithAnimation: function(...args) { 513 console.warn("Window.hideWithAnimation interface mocked in the Previewer. How this interface works on the" + 514 " Previewer may be different from that on a real device.") 515 const len = args.length 516 if (typeof args[len - 1] === 'function') { 517 args[len - 1].call(this, paramMock.businessErrorMock) 518 } else { 519 return new Promise((resolve) => { 520 resolve() 521 }) 522 } 523 }, 524 show: function(...args) { 525 console.warn("Window.show interface mocked in the Previewer. How this interface works on the" + 526 " Previewer may be different from that on a real device.") 527 const len = args.length 528 if (typeof args[len - 1] === 'function') { 529 args[len - 1].call(this, paramMock.businessErrorMock) 530 } else { 531 return new Promise((resolve) => { 532 resolve() 533 }) 534 } 535 }, 536 showWithAnimation: function(...args) { 537 console.warn("Window.showWithAnimation interface mocked in the Previewer. How this interface works on the" + 538 " Previewer may be different from that on a real device.") 539 const len = args.length 540 if (typeof args[len - 1] === 'function') { 541 args[len - 1].call(this, paramMock.businessErrorMock) 542 } else { 543 return new Promise((resolve) => { 544 resolve() 545 }) 546 } 547 }, 548 isShowing: function(...args) { 549 console.warn("Window.isShowing interface mocked in the Previewer. How this interface works on the" + 550 " Previewer may be different from that on a real device.") 551 const len = args.length 552 if (typeof args[len - 1] === 'function') { 553 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock) 554 } else { 555 return new Promise((resolve) => { 556 resolve(paramMock.paramBooleanMock) 557 }) 558 } 559 }, 560 destroy: function(...args) { 561 console.warn("Window.destroy interface mocked in the Previewer. How this interface works on the" + 562 " Previewer may be different from that on a real device.") 563 const len = args.length 564 if (typeof args[len - 1] === 'function') { 565 args[len - 1].call(this, paramMock.businessErrorMock) 566 } else { 567 return new Promise((resolve) => { 568 resolve() 569 }) 570 } 571 }, 572 setOutsideTouchable: function(...args) { 573 console.warn("Window.setOutsideTouchable interface mocked in the Previewer. How this interface works on the" + 574 " Previewer may be different from that on a real device.") 575 const len = args.length 576 if (typeof args[len - 1] === 'function') { 577 args[len - 1].call(this, paramMock.businessErrorMock) 578 } else { 579 return new Promise((resolve) => { 580 resolve() 581 }) 582 } 583 }, 584 on: function(...args) { 585 console.warn("Window.on interface mocked in the Previewer. How this interface works on the Previewer may be" + 586 " different from that on a real device.") 587 const len = args.length; 588 if (typeof args[len - 1] === 'function') { 589 if (args[0] === 'keyboardHeightChange'|| args[0] === 'systemAvoidAreaChange' 590 || args[0] === 'windowSizeChange'|| args[0] === 'touchOutside'|| args[0] === 'avoidAreaChange' 591 || args[0] === 'screenshot' || args[0] === 'dialogTargetTouch' 592 ){ 593 console.warn(`Window.on you has registered ${args[0]} event`) 594 } else { 595 console.warn("Window.on please check first param!") 596 } 597 } else { 598 console.warn("Window.on please check param!") 599 } 600 }, 601 off: function(...args) { 602 console.warn("Window.off interface mocked in the Previewer. How this interface works on the Previewer may be" + 603 " different from that on a real device.") 604 const len = args.length; 605 if (typeof args[len - 1] === 'function') { 606 if (args[0] === 'keyboardHeightChange'|| args[0] === 'systemAvoidAreaChange' 607 || args[0] === 'windowSizeChange'|| args[0] === 'touchOutside'|| args[0] === 'avoidAreaChange' 608 || args[0] === 'screenshot' || args[0] === 'dialogTargetTouch' 609 ){ 610 console.warn(`Window.off you has registered ${args[0]} event`) 611 } else { 612 console.warn("Window.off please check first param!") 613 } 614 } else { 615 console.warn("Window.off please check param!") 616 } 617 }, 618 setColorSpace: function(...args) { 619 console.warn("Window.setColorSpace interface mocked in the Previewer. How this interface works on the Previewer" + 620 " may be different from that on a real device.") 621 const len = args.length 622 if (typeof args[len - 1] === 'function') { 623 args[len - 1].call(this, paramMock.businessErrorMock) 624 } else { 625 return new Promise((resolve) => { 626 resolve() 627 }) 628 } 629 }, 630 getColorSpace: function(...args) { 631 console.warn("Window.getColorSpace interface mocked in the Previewer. How this interface works on the Previewer" + 632 " may be different from that on a real device.") 633 const len = args.length 634 if (typeof args[len - 1] === 'function') { 635 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock) 636 } else { 637 return new Promise((resolve) => { 638 resolve(paramMock.paramNumberMock) 639 }) 640 } 641 }, 642 isSupportWideGamut: function(...args) { 643 console.warn("Window.isSupportWideGamut interface mocked in the Previewer. How this interface works on the" + 644 " Previewer may be different from that on a real device.") 645 const len = args.length 646 if (typeof args[len - 1] === 'function') { 647 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock) 648 } else { 649 return new Promise((resolve) => { 650 resolve(paramMock.paramBooleanMock) 651 }) 652 } 653 }, 654 snapshot: function (...args) { 655 console.warn("Window.snapshot interface mocked in the Previewer. How this interface works on the Previewer" + 656 " may be different from that on a real device.") 657 const len = args.length 658 if (typeof args[len - 1] === 'function') { 659 args[len - 1].call(this, paramMock.businessErrorMock, PixelMapMock) 660 } else { 661 return new Promise((resolve, reject) => { 662 resolve(PixelMapMock) 663 }) 664 } 665 }, 666 bindDialogTarget: function(...args) { 667 console.warn("Window.bindDialogTarget interface mocked in the Previewer. How this interface works on the Previewer" + 668 " may be different from that on a real device.") 669 const len = args.length 670 /* 参数带有function,需特殊判断,原型如下 */ 671 /* bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>): Promise<void>; */ 672 /* bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>, callback: AsyncCallback<void>); */ 673 if (typeof args[len - 2] === 'function') { 674 args[len - 1].call(this, paramMock.businessErrorMock) 675 } else { 676 return new Promise((resolve) => { 677 resolve() 678 }) 679 } 680 }, 681 setBlur: function() { 682 console.warn("Window.setBlur interface mocked in the Previewer. How this interface works on the" + 683 " Previewer may be different from that on a real device.") 684 }, 685 setBackdropBlur: function() { 686 console.warn("Window.setBackdropBlur interface mocked in the Previewer. How this interface works on the" + 687 " Previewer may be different from that on a real device.") 688 }, 689 setBackdropBlurStyle: function() { 690 console.warn("Window.setBackdropBlurStyle interface mocked in the Previewer. How this interface works on the" + 691 " Previewer may be different from that on a real device.") 692 }, 693 setShadow: function() { 694 console.warn("Window.setShadow interface mocked in the Previewer. How this interface works on the" + 695 " Previewer may be different from that on a real device.") 696 }, 697 setCornerRadius: function() { 698 console.warn("Window.setCornerRadius interface mocked in the Previewer. How this interface works on the" + 699 " Previewer may be different from that on a real device.") 700 }, 701 opacity: function(...args) { 702 console.warn("Window.opacity interface mocked in the Previewer. How this interface works on the" + 703 " Previewer may be different from that on a real device.") 704 }, 705 scale: function(...args) { 706 console.warn("Window.scale interface mocked in the Previewer. How this interface works on the" + 707 " Previewer may be different from that on a real device.") 708 }, 709 rotate: function(...args) { 710 console.warn("Window.rotate interface mocked in the Previewer. How this interface works on the" + 711 " Previewer may be different from that on a real device.") 712 }, 713 translate: function(...args) { 714 console.warn("Window.translate interface mocked in the Previewer. How this interface works on the" + 715 " Previewer may be different from that on a real device.") 716 }, 717 getTransitionController: function() { 718 console.warn("Window.getTransitionController interface mocked in the Previewer. How this interface works on the" + 719 " Previewer may be different from that on a real device.") 720 return TransitionController; 721 } 722} 723 724export const windowMock = Window 725 726export function mockWindow() { 727 const ScaleOptions = { 728 x: '[PC preview] unknow x', 729 y: '[PC preview] unknow y', 730 pivotX: '[PC preview] unknow pivotX', 731 pivotY: '[PC preview] unknow pivotY' 732 } 733 734 const RotateOptions = { 735 x: '[PC preview] unknow x', 736 y: '[PC preview] unknow y', 737 z: '[PC preview] unknow z', 738 pivotX: '[PC preview] unknow pivotX', 739 pivotY: '[PC preview] unknow pivotY' 740 } 741 742 const TranslateOptions = { 743 x: '[PC preview] unknow x', 744 y: '[PC preview] unknow y', 745 z: '[PC preview] unknow z' 746 } 747 748 const window = { 749 BlurStyle: { 750 OFF: 0, 751 THIN: 1, 752 REGULAR: 2, 753 THICK: 3 754 }, 755 getTopWindow: function(...args) { 756 console.warn("Window.getTopWindow interface mocked in the Previewer. How this interface works on the Previewer" + 757 "may be different from that on a real device.") 758 const len = args.length 759 if (typeof args[len - 1] === 'function') { 760 args[len - 1].call(this, paramMock.businessErrorMock, Window) 761 } else { 762 return new Promise((resolve) => { 763 resolve(Window) 764 }) 765 } 766 }, 767 create: function(...args) { 768 console.warn("Window.create interface mocked in the Previewer. How this interface works on the Previewer may" + 769 " be different from that on a real device.") 770 const len = args.length 771 if (typeof args[len - 1] === 'function') { 772 args[len - 1].call(this, paramMock.businessErrorMock, Window) 773 } else { 774 return new Promise((resolve) => { 775 resolve(Window) 776 }) 777 } 778 }, 779 find: function(...args) { 780 console.warn("Window.find interface mocked in the Previewer. How this interface works on the Previewer may be" + 781 " different from that on a real device.") 782 const len = args.length 783 if (typeof args[len - 1] === 'function') { 784 args[len - 1].call(this, paramMock.businessErrorMock, Window) 785 } else { 786 return new Promise((resolve) => { 787 resolve(Window) 788 }) 789 } 790 }, 791 isFloatingAbilityWindowVisible: function(...args) { 792 console.warn("Window.isFloatingAbilityWindowVisible interface mocked in the Previewer. How this interface" + 793 " works on the Previewer may be different from that on a real device.") 794 const len = args.length 795 if (typeof args[len - 1] === 'function') { 796 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock) 797 } else { 798 return new Promise((resolve) => { 799 resolve(paramMock.paramBooleanMock) 800 }) 801 } 802 }, 803 setSplitBarVisibility: function(...args) { 804 console.warn("Window.setSplitBarVisibility interface mocked in the Previewer. How this interface works on the Previewer" + 805 "may be different from that on a real device.") 806 const len = args.length 807 if (typeof args[len - 1] === 'function') { 808 args[len - 1].call(this, paramMock.businessErrorMock) 809 } else { 810 return new Promise((resolve) => { 811 resolve() 812 }) 813 } 814 }, 815 minimizeAll: function(...args) { 816 console.warn("Window.minimizeAll interface mocked in the Previewer. How this interface works on the Previewer" + 817 " may be different from that on a real device.") 818 const len = args.length 819 if (typeof args[len - 1] === 'function') { 820 args[len - 1].call(this, paramMock.businessErrorMock) 821 } else { 822 return new Promise((resolve) => { 823 resolve() 824 }) 825 } 826 }, 827 toggleShownStateForAllAppWindows: function(...args) { 828 console.warn("Window.toggleShownStateForAllAppWindows interface mocked in the Previewer. How this interface" + 829 " works on the Previewer may be different from that on a real device.") 830 const len = args.length 831 if (typeof args[len - 1] === 'function') { 832 args[len - 1].call(this, paramMock.businessErrorMock) 833 } else { 834 return new Promise((resolve) => { 835 resolve() 836 }) 837 } 838 }, 839 setWindowLayoutMode: function(...args) { 840 console.warn("Window.setWindowLayoutMode interface mocked in the Previewer. How this interface works on the" + 841 " Previewer may be different from that on a real device.") 842 const len = args.length 843 if (typeof args[len - 1] === 'function') { 844 args[len - 1].call(this, paramMock.businessErrorMock) 845 } else { 846 return new Promise((resolve) => { 847 resolve() 848 }) 849 } 850 }, 851 on: function(...args) { 852 console.warn("Window.on interface mocked in the Previewer. How this interface works on the Previewer may be" + 853 " different from that on a real device.") 854 const len = args.length 855 if (typeof args[len - 1] === 'function') { 856 if (args[0] === 'systemBarTintChange') { 857 console.warn(`Window.on you has registered ${args[0]} event`) 858 } else { 859 console.warn("Window.on please check first param!") 860 } 861 } else { 862 console.warn("Window.on please check param!") 863 } 864 }, 865 off: function(...args) { 866 console.warn("Window.off interface mocked in the Previewer. How this interface works on the Previewer may be" + 867 " different from that on a real device.") 868 const len = args.length 869 if (typeof args[len - 1] === 'function') { 870 if (args[0] === 'systemBarTintChange') { 871 console.warn(`Window.off you has registered ${args[0]} event`) 872 } else { 873 console.warn("Window.off please check first param!") 874 } 875 } else { 876 console.warn("Window.off please check param!") 877 } 878 }, 879 WindowType, 880 AvoidAreaType, 881 WindowMode, 882 WindowLayoutMode, 883 SystemBarProperties, 884 SystemBarRegionTint, 885 SystemBarTintState, 886 Rect, 887 AvoidArea, 888 Size, 889 WindowProperties, 890 ColorSpace, 891 ScaleOptions, 892 RotateOptions, 893 TranslateOptions, 894 TransitionContext, 895 TransitionController, 896 WindowStageEventType, 897 WindowStage 898 } 899 return window 900} 901