提交 d71f8cfb 编写于 作者: Q quanli

quanli1@huawei.com

Signed-off-by: Nquanli <quanli1@huawei.com>
上级 f8db5871
......@@ -35,6 +35,11 @@ let wifiSecurityType = {
WIFI_SEC_TYPE_WEP: 2,
WIFI_SEC_TYPE_PSK: 3,
WIFI_SEC_TYPE_SAE: 4,
WIFI_SEC_TYPE_EAP: 5,
WIFI_SEC_TYPE_EAP_SUITE_B: 6,
WIFI_SEC_TYPE_OWE:7 ,
WIFI_SEC_TYPE_WAPI_CERT:8 ,
WIFI_SEC_TYPE_WAPI_PSK:9 ,
}
let connState = {
......@@ -444,3 +449,4 @@ export default function actsWifiCandidateNetWorkTest() {
})
}
......@@ -19,6 +19,8 @@ import wifi from '@ohos.wifi'
import wifiext from '@ohos.wifiext'
import wifiManagerExt from '@ohos.wifiManagerExt'
function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay))
}
......@@ -178,11 +180,11 @@ export default function actsWifiEventTest() {
* @tc.type Function
*/
it('SUB_Communication_WiFi_SysCaps_Test_0001', 0, async function (done) {
console.info('testSysCaps01 start');
console.info('SUB_Communication_WiFi_SysCaps_Test_0001 start');
let ret = false;
try {
var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension");
console.info("testSysCaps01 test.syscap.param.001 : " + isAccessToken);
console.info("SUB_Communication_WiFi_SysCaps_Test_0001 test.syscap.param.001 : " + isAccessToken);
if (isAccessToken) {
ret = true;
}
......@@ -191,9 +193,9 @@ export default function actsWifiEventTest() {
done();
} catch (e) {
expect(ret).assertFalse();
console.info("testSysCaps01 canIUse isAccessToken error: " + e);
console.info("SUB_Communication_WiFi_SysCaps_Test_0001 canIUse isAccessToken error: " + e);
}
console.info('testSysCaps01 end');
console.info('SUB_Communication_WiFi_SysCaps_Test_0001 end');
done();
})
......@@ -204,11 +206,11 @@ export default function actsWifiEventTest() {
* @tc.type Function
*/
it('SUB_Communication_WiFi_SysCaps_Test_0002', 0, async function (done) {
console.info('testSysCaps02 start');
console.info('SUB_Communication_WiFi_SysCaps_Test_0002 start');
let ret = false;
try {
var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension");
console.info("testSysCaps01 test.syscap.param.001 : " + isAccessToken);
console.info("SUB_Communication_WiFi_SysCaps_Test_0002 test.syscap.param.001 : " + isAccessToken);
if (isAccessToken) {
ret = true;
}
......@@ -217,9 +219,9 @@ export default function actsWifiEventTest() {
done();
} catch (e) {
expect(ret).assertFalse();
console.info("testSysCaps02 canIUse isAccessToken error: " + e);
console.info("SUB_Communication_WiFi_SysCaps_Test_0002 canIUse isAccessToken error: " + e);
}
console.info('testSysCaps02 end');
console.info('SUB_Communication_WiFi_SysCaps_Test_0002 end');
done();
})
......@@ -230,11 +232,11 @@ export default function actsWifiEventTest() {
* @tc.type Function
*/
it('SUB_Communication_WiFi_SysCaps_Test_0003', 0, async function (done) {
console.info('testSysCaps03 start');
console.info('SUB_Communication_WiFi_SysCaps_Test_0003 start');
let ret = false;
try {
var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension");
console.info("testSysCaps01 test.syscap.param.001 : " + isAccessToken);
console.info("SUB_Communication_WiFi_SysCaps_Test_0003 test.syscap.param.001 : " + isAccessToken);
if (isAccessToken) {
ret = true;
}
......@@ -246,9 +248,9 @@ export default function actsWifiEventTest() {
done();
} catch (e) {
expect(ret).assertFalse();
console.info("testSysCaps03 canIUse isAccessToken error: " + e);
console.info("SUB_Communication_WiFi_SysCaps_Test_0003 canIUse isAccessToken error: " + e);
}
console.info('testSysCaps03 end');
console.info('SUB_Communication_WiFi_SysCaps_Test_0003 end');
done();
})
......@@ -259,11 +261,11 @@ export default function actsWifiEventTest() {
* @tc.type Function
*/
it('SUB_Communication_WiFi_SysCaps_Test_0004', 0, async function (done) {
console.info('testSysCaps04 start');
console.info('SUB_Communication_WiFi_SysCaps_Test_0004 start');
let ret = false;
try {
var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension");
console.info("testSysCaps04 test.syscap.param.001 : " + isAccessToken);
console.info("SUB_Communication_WiFi_SysCaps_Test_0004 test.syscap.param.001 : " + isAccessToken);
if (isAccessToken) {
ret = true;
}
......@@ -285,9 +287,9 @@ export default function actsWifiEventTest() {
done();
} catch (e) {
expect(ret).assertFalse();
console.info("testSysCaps04 canIUse isAccessToken error: " + e);
console.info("SUB_Communication_WiFi_SysCaps_Test_0004 canIUse isAccessToken error: " + e);
}
console.info('testSysCaps04 end');
console.info('SUB_Communication_WiFi_SysCaps_Test_0004 end');
done();
})
......@@ -298,11 +300,11 @@ export default function actsWifiEventTest() {
* @tc.type Function
*/
it('SUB_Communication_WiFi_SysCaps_Test_0005', 0, async function (done) {
console.info('testSysCaps05 start');
console.info('SUB_Communication_WiFi_SysCaps_Test_0005 start');
let ret = false;
try {
var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension");
console.info("testSysCaps01 test.syscap.param.001 : " + isAccessToken);
console.info("SUB_Communication_WiFi_SysCaps_Test_0005 test.syscap.param.001 : " + isAccessToken);
if (isAccessToken) {
ret = true;
}
......@@ -314,9 +316,9 @@ export default function actsWifiEventTest() {
done();
} catch (e) {
expect(ret).assertFalse();
console.info("testSysCaps05 canIUse isAccessToken error: " + e);
console.info("SUB_Communication_WiFi_SysCaps_Test_0005 canIUse isAccessToken error: " + e);
}
console.info('testSysCaps05 end');
console.info('SUB_Communication_WiFi_SysCaps_Test_0005 end');
done();
})
......@@ -327,11 +329,11 @@ export default function actsWifiEventTest() {
* @tc.type Function
*/
it('SUB_Communication_WiFi_SysCaps_Test_0006', 0, async function (done) {
console.info('testSysCaps04 start');
console.info('SUB_Communication_WiFi_SysCaps_Test_0006 start');
let ret = false;
try {
var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension");
console.info("testSysCaps04 test.syscap.param.001 : " + isAccessToken);
console.info("SUB_Communication_WiFi_SysCaps_Test_0006 test.syscap.param.001 : " + isAccessToken);
if (isAccessToken) {
ret = true;
}
......@@ -353,9 +355,9 @@ export default function actsWifiEventTest() {
done();
} catch (e) {
expect(ret).assertFalse();
console.info("testSysCaps06 canIUse isAccessToken error: " + e);
console.info("SUB_Communication_WiFi_SysCaps_Test_0006 canIUse isAccessToken error: " + e);
}
console.info('testSysCaps06 end');
console.info('SUB_Communication_WiFi_SysCaps_Test_0006 end');
done();
})
......@@ -366,11 +368,11 @@ export default function actsWifiEventTest() {
* @tc.type Function
*/
it('SUB_Communication_WiFi_SysCaps_Test_0007', 0, async function (done) {
console.info('testSysCaps01 start');
console.info('SUB_Communication_WiFi_SysCaps_Test_0007 start');
let ret = false;
try {
var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension");
console.info("testSysCaps01 test.syscap.param.001 : " + isAccessToken);
console.info("SUB_Communication_WiFi_SysCaps_Test_0007 test.syscap.param.001 : " + isAccessToken);
if (isAccessToken) {
ret = true;
}
......@@ -379,9 +381,223 @@ export default function actsWifiEventTest() {
done();
} catch (e) {
expect(ret).assertFalse();
console.info("testSysCaps07 canIUse isAccessToken error: " + e);
console.info("SUB_Communication_WiFi_SysCaps_Test_0007 canIUse isAccessToken error: " + e);
}
console.info('SUB_Communication_WiFi_SysCaps_Test_0007 end');
done();
})
/**
* @tc.number SUB_Communication_WiFi_SysCaps_Test_0008
* @tc.name testenableHotspot
* @tc.desc Test enableHotspot api.
* @tc.type Function
*/
it('SUB_Communication_WiFi_SysCaps_Test_0008', 0, async function (done) {
console.info('SUB_Communication_WiFi_SysCaps_Test_0008 start');
let ret = false;
try {
var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension");
console.info("SUB_Communication_WiFi_SysCaps_Test_0008 test.syscap.param.001 : " + isAccessToken);
if (isAccessToken) {
ret = true;
}
console.info("[wifi_test] enableHotspot: " + wifiManagerExt.enableHotspot())
expect(isAccessToken).assertFalse();
done();
} catch (e) {
expect(ret).assertFalse();
console.info("SUB_Communication_WiFi_SysCaps_Test_0008 canIUse isAccessToken error: " + e);
}
console.info('SUB_Communication_WiFi_SysCaps_Test_0008 end');
done();
})
/**
* @tc.number SUB_Communication_WiFi_SysCaps_Test_0009
* @tc.name testdisableHotspot
* @tc.desc Test disableHotspot api.
* @tc.type Function
*/
it('SUB_Communication_WiFi_SysCaps_Test_0009', 0, async function (done) {
console.info('SUB_Communication_WiFi_SysCaps_Test_0009 start');
let ret = false;
try {
var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension");
console.info("SUB_Communication_WiFi_SysCaps_Test_0009 test.syscap.param.001 : " + isAccessToken);
if (isAccessToken) {
ret = true;
}
console.info("[wifi_test] disableHotspot: " + wifiManagerExt.disableHotspot())
expect(isAccessToken).assertFalse();
done();
} catch (e) {
expect(ret).assertFalse();
console.info("SUB_Communication_WiFi_SysCaps_Test_0009 canIUse isAccessToken error: " + e);
}
console.info('SUB_Communication_WiFi_SysCaps_Test_0009 end');
done();
})
/**
* @tc.number SUB_Communication_WiFi_SysCaps_Test_0010
* @tc.name testgetSupportedPowerModel
* @tc.desc Test getSupportedPowerModel api.
* @tc.type Function
*/
it('SUB_Communication_WiFi_SysCaps_Test_0010', 0, async function (done) {
console.info('SUB_Communication_WiFi_SysCaps_Test_0010 start');
let ret = false;
try {
var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension");
console.info("SUB_Communication_WiFi_SysCaps_Test_0010 test.syscap.param.001 : " + isAccessToken);
if (isAccessToken) {
ret = true;
}
await wifiManagerExt.getSupportedPowerModel()
.then(data => {
console.info("[wifi_test]getSupportedPowerModel promise result -> " + JSON.stringify(data));
});
expect(isAccessToken).assertFalse();
done();
} catch (e) {
expect(ret).assertFalse();
console.info("SUB_Communication_WiFi_SysCaps_Test_0010 canIUse isAccessToken error: " + e);
}
console.info('SUB_Communication_WiFi_SysCaps_Test_0010 end');
done();
})
/**
* @tc.number SUB_Communication_WiFi_SysCaps_Test_0011
* @tc.name testgetSupportedPowerModel
* @tc.desc Test getSupportedPowerModel api.
* @tc.type Function
*/
it('SUB_Communication_WiFi_SysCaps_Test_0011', 0, async function (done) {
console.info('SUB_Communication_WiFi_SysCaps_Test_0011 start');
let ret = false;
try {
var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension");
console.info("SUB_Communication_WiFi_SysCaps_Test_0011 test.syscap.param.001 : " + isAccessToken);
if (isAccessToken) {
ret = true;
}
function getSupportedPowerModelResult(){
return new Promise((resolve, reject) => {
wifiManagerExt.getSupportedPowerModel(
(err, result) => {
if(err) {
console.info("[wifi_test]failed to getSupportedPowerModel:" + JSON.stringify(err));
expect(true).assertTrue();
}
console.info("[wifi_test]getSupportedPowerModel callback:" + JSON.stringify(result));
resolve();
});
});
}
await getSupportedPowerModelResult();
expect(isAccessToken).assertFalse();
done();
} catch (e) {
expect(ret).assertFalse();
console.info("SUB_Communication_WiFi_SysCaps_Test_0011 canIUse isAccessToken error: " + e);
}
console.info('SUB_Communication_WiFi_SysCaps_Test_0011 end');
done();
})
/**
* @tc.number SUB_Communication_WiFi_SysCaps_Test_0012
* @tc.name testgetPowerModel
* @tc.desc Test getPowerModel api.
* @tc.type Function
*/
it('SUB_Communication_WiFi_SysCaps_Test_0012', 0, async function (done) {
console.info('SUB_Communication_WiFi_SysCaps_Test_0012 start');
let ret = false;
try {
var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension");
console.info("SUB_Communication_WiFi_SysCaps_Test_0012 test.syscap.param.001 : " + isAccessToken);
if (isAccessToken) {
ret = true;
}
await wifiManagerExt.getPowerModel()
.then(data => {
console.info("[wifi_test]getPowerModel promise result -> " + JSON.stringify(data));
});
expect(isAccessToken).assertFalse();
done();
} catch (e) {
expect(ret).assertFalse();
console.info("SUB_Communication_WiFi_SysCaps_Test_0012 canIUse isAccessToken error: " + e);
}
console.info('SUB_Communication_WiFi_SysCaps_Test_0012 end');
done();
})
/**
* @tc.number SUB_Communication_WiFi_SysCaps_Test_0013
* @tc.name testgetPowerModel
* @tc.desc Test getPowerModel api.
* @tc.type Function
*/
it('SUB_Communication_WiFi_SysCaps_Test_0013', 0, async function (done) {
console.info('SUB_Communication_WiFi_SysCaps_Test_0013 start');
let ret = false;
try {
var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension");
console.info("SUB_Communication_WiFi_SysCaps_Test_0013 test.syscap.param.001 : " + isAccessToken);
if (isAccessToken) {
ret = true;
}
function getPowerModelResult(){
return new Promise((resolve, reject) => {
wifiManagerExt.getPowerModel(
(err, result) => {
if(err) {
console.info("[wifi_test]failed to getPowerModel:" + JSON.stringify(err));
expect(true).assertTrue();
}
console.info("[wifi_test]getPowerModel callback:" + JSON.stringify(result));
resolve();
});
});
}
await getPowerModelResult();
expect(isAccessToken).assertFalse();
done();
} catch (e) {
expect(ret).assertFalse();
console.info("SUB_Communication_WiFi_SysCaps_Test_0013 canIUse isAccessToken error: " + e);
}
console.info('testSysCaps07 end');
console.info('SUB_Communication_WiFi_SysCaps_Test_0013 end');
done();
})
/**
* @tc.number SUB_Communication_WiFi_SysCaps_Test_0007
* @tc.name testsetPowerModel
* @tc.desc Test setPowerModel api.
* @tc.type Function
*/
it('SUB_Communication_WiFi_SysCaps_Test_0014', 0, async function (done) {
console.info('SUB_Communication_WiFi_SysCaps_Test_0014 start');
let ret = false;
try {
var isAccessToken = canIUse("SystemCapability.Communication.WiFi.AP.Extension");
console.info("SUB_Communication_WiFi_SysCaps_Test_0014 test.syscap.param.001 : " + isAccessToken);
if (isAccessToken) {
ret = true;
}
console.info("[wifi_test] setPowerModel: " + wifiManagerExt.setPowerModel(PowerModel))
expect(isAccessToken).assertFalse();
done();
} catch (e) {
expect(ret).assertFalse();
console.info("SUB_Communication_WiFi_SysCaps_Test_0014 canIUse isAccessToken error: " + e);
}
console.info('SUB_Communication_WiFi_SysCaps_Test_0014 end');
done();
})
console.log("*************[wifi_test] start wifi js unit test end*************");
......@@ -389,4 +605,3 @@ export default function actsWifiEventTest() {
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册