未验证 提交 95dfa80a 编写于 作者: O openharmony_ci 提交者: Gitee

!6642 适配nowifi测试用例

Merge pull request !6642 from zhangfuzhi/monthly_20221018
......@@ -14,53 +14,42 @@
*/
import network from '@system.network';
import { describe, it, expect } from '@ohos/hypium';
import { describe, expect, it } from '@ohos/hypium';
import connection from '@ohos.net.connection';
export default function Telephony_NetManager_NetWorkTest() {
describe("Telephony_NetManager_NetWorkTest", function () {
let networkAvailable = () => {
connection.getDefaultNet(function (error, netHandle) {
if (error || netHandle.netId >= 100) {
console.info("Network available or Network error:" + error);
return true;
}
return false;
})
}
/**
* @tc.number Telephony_NetManager_NetWorkTest_GetType_None_0100
* @tc.name Whether the GetType method is called successfully without WiFi
* @tc.desc Function test
*/
it("Telephony_NetManager_NetWorkTest_GetType_None_0100", 0, function (done) {
if (networkAvailable) {
console.warn("No network environment required");
done();
return;
}
network.getType({
success: function (data) {
console.info("NetManager getType " + JSON.stringify(data));
expect(data.type === "none").assertTrue();
expect(data.metered === false).assertTrue();
network.unsubscribe();
done();
},
fail: function (data, code) {
console.log("data:" + JSON.stringify(data) + " code:" + JSON.stringify(code));
expect().assertFail();
done();
},
complete: function () {
expect().assertTrue();
connection.getDefaultNet(function (error, netHandle) {
if (error || netHandle.netId >= 100) {
console.info("Network available or Network error:" + error);
done();
return;
}
network.getType({
success: function (data) {
console.info("NetManager getType " + JSON.stringify(data));
expect(data.type == "none").assertTrue();
expect(data.metered == false).assertTrue();
network.unsubscribe();
done();
},
fail: function (data, code) {
console.log("data:" + JSON.stringify(data) + " code:" + JSON.stringify(code));
expect().assertFail();
done();
},
complete: function () {
}
})
})
done();
});
/**
......@@ -69,31 +58,30 @@ export default function Telephony_NetManager_NetWorkTest() {
* @tc.desc Function test
*/
it("Telephony_NetManager_NetWorkTest_GetType_None_0200", 0, function (done) {
if (networkAvailable) {
console.warn("No network environment required");
done();
return;
}
network.getType({
success: function (data) {
console.info("NetManager getType 1 " + JSON.stringify(data));
expect(data.type === "none").assertTrue();
expect(data.metered === false).assertTrue();
network.unsubscribe();
done();
console.info("NetManager Telephony_NetManager_NetWorkTest_GetType_none_1 end");
},
fail: function (data, code) {
console.log("data:" + JSON.stringify(data) + " code:" + JSON.stringify(code));
expect().assertFail();
done();
},
complete: function () {
expect().assertTrue();
connection.getDefaultNet(function (error, netHandle) {
if (error || netHandle.netId >= 100) {
console.info("Network available or Network error:" + error);
done();
return;
}
network.getType({
success: function (data) {
console.info("NetManager getType 1 " + JSON.stringify(data));
expect(data.type == "none").assertTrue();
expect(data.metered == false).assertTrue();
network.unsubscribe();
done();
console.info("NetManager Telephony_NetManager_NetWorkTest_GetType_none_1 end");
},
fail: function (data, code) {
console.log("data:" + JSON.stringify(data) + " code:" + JSON.stringify(code));
expect().assertFail();
done();
},
complete: function () {
}
})
})
done();
});
/**
......@@ -102,26 +90,27 @@ export default function Telephony_NetManager_NetWorkTest() {
* @tc.desc Function test
*/
it("Telephony_NetManager_NetWorkTest_Subscribe_None_0100", 0, function (done) {
if (networkAvailable) {
console.warn("No network environment required");
done();
return;
}
network.subscribe({
success: function (data) {
console.info("NetManager subscribe " + JSON.stringify(data));
expect(data.type === "none").assertTrue();
expect(data.metered === false).assertTrue();
network.unsubscribe();
done();
},
fail: function (data, code) {
console.log("data:" + JSON.stringify(data) + " code:" + JSON.stringify(code));
expect().assertFail();
connection.getDefaultNet(function (error, netHandle) {
if (error || netHandle.netId >= 100) {
console.info("Network available or Network error:" + error);
done();
return;
}
network.subscribe({
success: function (data) {
console.info("NetManager subscribe " + JSON.stringify(data));
expect(data.type == "none").assertTrue();
expect(data.metered == false).assertTrue();
network.unsubscribe();
done();
},
fail: function (data, code) {
console.log("data:" + JSON.stringify(data) + " code:" + JSON.stringify(code));
expect().assertFail();
done();
}
})
})
done();
});
/**
......@@ -130,27 +119,27 @@ export default function Telephony_NetManager_NetWorkTest() {
* @tc.desc Function test
*/
it("Telephony_NetManager_NetWorkTest_Subscribe_None_0200", 0, function (done) {
if (networkAvailable) {
console.warn("No network environment required");
done();
return;
}
network.subscribe({
success: function (data) {
console.info("NetManager subscribe " + JSON.stringify(data));
expect(data.type === "none").assertTrue();
expect(data.metered === false).assertTrue();
network.unsubscribe();
done();
},
fail: function (data, code) {
console.log("data:" + JSON.stringify(data) + " code:" + JSON.stringify(code));
expect().assertFail();
connection.getDefaultNet(function (error, netHandle) {
if (error || netHandle.netId >= 100) {
console.info("Network available or Network error:" + error);
done();
return;
}
network.subscribe({
success: function (data) {
console.info("NetManager subscribe " + JSON.stringify(data));
expect(data.type == "none").assertTrue();
expect(data.metered == false).assertTrue();
network.unsubscribe();
done();
},
fail: function (data, code) {
console.log("data:" + JSON.stringify(data) + " code:" + JSON.stringify(code));
expect().assertFail();
done();
}
})
})
done();
});
});
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册