• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import { hasComplete } from "./utils"
2
3export function mockBrightness() {
4  global.systemplugin.brightness = {
5    argsV: {
6      value: 80
7    },
8    argsM: {
9      mode: 0
10    },
11    getValue: function (...args) {
12      console.warn("brightness.getValue interface mocked in the Previewer. How this interface works on the Previewer" +
13        " may be different from that on a real device.")
14      args[0].success(this.argsV)
15      hasComplete(args[0].complete)
16    },
17    setValue: function (...args) {
18      console.warn("brightness.setValue interface mocked in the Previewer. How this interface works on the Previewer" +
19        " may be different from that on a real device.")
20      if (args[0].value) {
21        this.argsV.value = args[0].value
22        args[0].success("brightness setValue successfully")
23        hasComplete(args[0].complete)
24      }
25    },
26    getMode: function (...args) {
27      console.warn("brightness.getMode interface mocked in the Previewer. How this interface works on the Previewer" +
28        " may be different from that on a real device.")
29      args[0].success(this.argsM)
30      hasComplete(args[0].complete)
31    },
32    setMode: function (...args) {
33      console.warn("brightness.setMode interface mocked in the Previewer. How this interface works on the Previewer" +
34        " may be different from that on a real device.")
35      this.argsM.mode = args[0].mode
36      args[0].success("brightness setMode successfully")
37      hasComplete(args[0].complete)
38    },
39    setKeepScreenOn: function (...args) {
40      console.warn("brightness.setKeepScreenOn interface mocked in the Previewer. How this interface works on the" +
41        " Previewer may be different from that on a real device.")
42      args[0].success("brightness setKeepScreenOn successfully")
43      hasComplete(args[0].complete)
44    }
45  }
46}