• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import { paramMock } from "./utils"
2
3export function mockAccessibility() {
4  global.systemplugin.accessibility = {
5    isOpenAccessibility: function (...args) {
6      console.warn("accessibility.isOpenAccessibility interface mocked in the Previewer. How this interface works on the" +
7        " Previewer may be different from that on a real device.")
8      const len = args.length
9      if (typeof args[len - 1] === 'function') {
10        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
11      } else {
12        return new Promise((resolve, reject) => {
13          resolve(paramMock.paramBooleanMock);
14        })
15      }
16     },
17    isOpenTouchExploration: function (...args) {
18      console.warn("accessibility.isOpenTouchExploration interface mocked in the Previewer. How this interface works on the" +
19        " Previewer may be different from that on a real device.")
20        const len = args.length
21        if (typeof args[len - 1] === 'function') {
22          args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock)
23        } else {
24          return new Promise((resolve) => {
25            resolve(paramMock.paramBooleanMock);
26        })
27      }
28    }
29  }
30}