• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 mockWifi() {
19  const linkedInfoMock = {
20    ssid: '[PC preview] unknow ssid',
21    bssid: '[PC preview] unknow bssid',
22    networkId: '[PC preview] unknow networkId',
23    rssi: '[PC preview] unknow rssi',
24    band: '[PC preview] unknow band',
25    linkSpeed: '[PC preview] unknow linkSpeed',
26    frequency: '[PC preview] unknow frequency',
27    isHidden: '[PC preview] unknow isHidden',
28    isRestricted: '[PC preview] unknow isRestricted',
29    chload: '[PC preview] unknow chload',
30    snr: '[PC preview] unknow snr',
31    macAddress: '[PC preview] unknow macAddress',
32    ipAddress: '[PC preview] unknow ipAddress',
33    suppState: '[PC preview] unknow suppState',
34    connState: '[PC preview] unknow connState'
35  }
36  global.systemplugin.wifi = {
37    getLinkedInfo: function (...args) {
38      console.warn("wifi.getLinkedInfo interface mocked in the Previewer. How this interface works on the Previewer" +
39        " may be different from that on a real device.")
40      const len = args.length
41      if (typeof args[len - 1] === 'function') {
42        args[len - 1].call(this, paramMock.businessErrorMock, linkedInfoMock)
43      } else {
44        return new Promise((resolve) => {
45          resolve(linkedInfoMock)
46        })
47      }
48    }
49  }
50}