• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 mockWifiExt() {
19  const PowerModel = {
20    SLEEPING : 0,
21    GENERAL : 1,
22    THROUGH_WALL : 2,
23  }
24
25  const wifiext = {
26    enableHotspot: function (...args) {
27      console.warn("wifiext.enableHotspot interface mocked in the Previewer." +
28        " How this interface works on the Previewer may be different from that on a real device.")
29      return paramMock.paramBooleanMock;
30    },
31
32    disableHotspot: function (...args) {
33      console.warn("wifiext.disableHotspot interface mocked in the Previewer." +
34        " How this interface works on the Previewer may be different from that on a real device.")
35      return paramMock.paramBooleanMock;
36    },
37
38    getSupportedPowerModel: function (...args) {
39      console.warn("wifiext.getSupportedPowerModel interface mocked in the Previewer." +
40        " How this interface works on the Previewer may be different from that on a real device.")
41      const len = args.length
42      if (typeof args[len - 1] === 'function') {
43        args[len - 1].call(this, paramMock.businessErrorMock, [PowerModel.GENERAL])
44      } else {
45        return new Promise((resolve) => {
46          resolve([PowerModel.GENERAL])
47        })
48      }
49    },
50
51    getPowerModel: function (...args) {
52      console.warn("wifiext.getPowerModel interface mocked in the Previewer." +
53        " How this interface works on the Previewer may be different from that on a real device.")
54      const len = args.length
55      if (typeof args[len - 1] === 'function') {
56        args[len - 1].call(this, paramMock.businessErrorMock, PowerModel.GENERAL)
57      } else {
58        return new Promise((resolve) => {
59          resolve(PowerModel.GENERAL)
60        })
61      }
62    },
63
64    setPowerModel: function (...args) {
65      console.warn("wifiext.setPowerModel interface mocked in the Previewer. How this interface works on the Previewer" +
66        " may be different from that on a real device.")
67      return paramMock.paramBooleanMock;
68    },
69  }
70  return wifiext;
71}
72