WifiP2P.test2.js 2.9 KB
Newer Older
Q
quanli 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
/*
 * Copyright (C) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
import wifi from '@ohos.wifi'

function sleep(delay) {
    return new Promise(resovle => setTimeout(resovle, delay))
}

function checkWifiPowerOn(){
    console.info("wifi_test/wifi status:" + wifi.isWifiActive());
}

export default function actsWifiTestNew() {
    describe('actsWifiTestNew', function () {
        beforeEach(function () {
            checkWifiPowerOn();
        })
        afterEach(function () {
        })

        /**
        * @tc.number     P2P_0009
        * @tc.name       SUB_Communication_WiFi_XTS_P2P_0009
        * @since 8
        * @tc.desc       Test p2pCancelConnect Group  API functionality.
        * @syscap SystemCapability.Communication.WiFi.P2P
        * @permission ohos.permission.GET_WIFI_INFO
        */
        it('SUB_Communication_WiFi_XTS_P2P_0009', 0, async function (done) {
            let WifiP2PConfig = {
                deviceAddress : "00:00:00:00:00:00",
                netId : -1,
                passphrase : "12345678",
                groupName : "AAAZZZ123",
                goBand : 0
            };
            let addConfig = wifi.createGroup(WifiP2PConfig);
            console.info("[wifi_test] test p2pConnect result." + addConfig);
            let disConn = wifi.p2pCancelConnect();
            sleep(2000);
            console.info("[wifi_test] test p2pCancelConnect result." + disConn);
            expect(disConn).assertTrue();
            let removeConfig = wifi.removeGroup();
            console.info("[wifi_test] test start removeGroup" + removeConfig);
            expect(removeConfig).assertTrue();
            done();
        })

        /**
        * @tc.number     P2P_0011
        * @tc.name       SUB_Communication_WiFi_XTS_P2P_0011
        * @since 8
        * @tc.desc       Test remove error Group functionality.
        * @syscap SystemCapability.Communication.WiFi.P2P
        * @permission ohos.permission.GET_WIFI_INFO
        */
        it('SUB_Communication_WiFi_XTS_P2P_0011', 0, async function (done) {
            let isRemoved = wifi.removeGroup(10000);
            console.info("[wifi_test]removeGroup(10000) result : " + JSON.stringify(isRemoved));
            expect(isRemoved).assertTrue();
            done();
        })

    })
}