未验证 提交 22dbef13 编写于 作者: O openharmony_ci 提交者: Gitee

!9390 增加statistic接口用例

Merge pull request !9390 from 高曦/master
/**
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2021-2023 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
......@@ -19,6 +19,7 @@ import requestMethodJsunit from './RequestMethodJsunit.test';
import httpResponseJsunit from './HttpResponseJsunit.test';
import HttpRequestOptionsJsunit from './HttpRequestOptionsJsunit.test';
import httpRequestJsunit from './HttpRequestJsunit.test';
import StatisticsTest from './StatisticsTest.test';
export default function testsuite() {
httpJsunit();
......@@ -27,4 +28,5 @@ export default function testsuite() {
httpResponseJsunit();
HttpRequestOptionsJsunit();
httpRequestJsunit();
StatisticsTest();
}
\ No newline at end of file
/*
* Copyright (C) 2023 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,it, expect} from '@ohos/hypium';
import statistics from '@ohos.net.statistics';
import sim from '@ohos.telephony.sim';
import radio from '@ohos.telephony.radio';
export default function StatisticsTest() {
describe("StatisticsTest", function () {
let delayTime = 5000;
const DATA_0 = 0;
let code_201 = 201;
let errCode_201 = "201";
/**
* @tc.number Telephony_NetworkManager_getIfaceRxBytes_Async_0100
* @tc.name Test getIfaceRxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getIfaceRxBytes_Async_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getIfaceRxBytes_Async_0100';
let ifaceName = "eth0";
statistics.getIfaceRxBytes(ifaceName, (err, data) => {
if (err) {
console.log(`${caseName} getIfaceRxBytes fail ${JSON.stringify(err)} `);
done();
} else {
console.log(`${caseName} getIfaceRxBytes ${JSON.stringify(data)}`);
expect().assertFail();
done();
}
});
});
/**
* @tc.number Telephony_NetworkManager_getIfaceRxBytes_Async_0200
* @tc.name Test getIfaceRxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getIfaceRxBytes_Async_0200', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getIfaceRxBytes_Async_0200';
let ifaceName = "wlan0";
statistics.getIfaceRxBytes(ifaceName, (err, data) => {
if (err) {
console.log(`${caseName} getIfaceRxBytes fail ${JSON.stringify(err)} `);
expect().assertFail();
done();
} else {
console.log(`${caseName} getIfaceRxBytes success ${JSON.stringify(data)}`);
expect(data >= DATA_0).assertTrue();
done();
}
});
});
/**
* @tc.number Telephony_NetworkManager_getIfaceRxBytes_Async_0300
* @tc.name Test getIfaceRxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getIfaceRxBytes_Async_0300', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getIfaceRxBytes_Async_0300';
let ifaceName = "wlan1";
statistics.getIfaceRxBytes(ifaceName, (err, data) => {
if (err) {
console.log(`${caseName} getIfaceRxBytes fail ${JSON.stringify(err)} `);
done();
} else {
console.log(`${caseName} getIfaceRxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}
});
});
/**
* @tc.number Telephony_NetworkManager_getIfaceRxBytes_Async_0400
* @tc.name Test getIfaceRxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getIfaceRxBytes_Async_0400', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getIfaceRxBytes_Async_0400';
let ifaceName = null;
try {
statistics.getIfaceRxBytes(ifaceName, (err, data) => {
if (err) {
console.log(`${caseName} getIfaceRxBytes fail ${JSON.stringify(err)}`);
expect(err != undefined).assertTrue();
done();
} else {
console.log(`${caseName} getIfaceRxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}
});
} catch (err) {
console.log(`${caseName} getIfaceRxBytes into catch ${JSON.stringify(err)}`);
expect(err.code == 401).assertTrue();
done();
}
});
/**
* @tc.number Telephony_NetworkManager_getIfaceRxBytes_Promise_0100
* @tc.name Test getIfaceRxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getIfaceRxBytes_Promise_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getIfaceRxBytes_Promise_0100';
let ifaceName = "eth0";
statistics.getIfaceRxBytes(ifaceName).then((data) => {
console.log(`${caseName} getIfaceRxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}).catch((err) => {
console.log(`${caseName} getIfaceRxBytes fail ${JSON.stringify(err)} `);
done();
});
});
/**
* @tc.number Telephony_NetworkManager_getIfaceRxBytes_Promise_0200
* @tc.name Test getIfaceRxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getIfaceRxBytes_Promise_0200', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getIfaceRxBytes_Promise_0200';
let ifaceName = "wlan0";
statistics.getIfaceRxBytes(ifaceName).then((data) => {
console.log(`${caseName} getIfaceRxBytes success ${JSON.stringify(data)}`);
expect(data >= DATA_0).assertTrue();
done();
}).catch((err) => {
console.log(`${caseName} getIfaceRxBytes fail ${JSON.stringify(err)} `);
expect().assertFail();
done();
});
});
/**
* @tc.number Telephony_NetworkManager_getIfaceRxBytes_Promise_0300
* @tc.name Test getIfaceRxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getIfaceRxBytes_Promise_0300', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getIfaceRxBytes_Promise_0300';
let ifaceName = "wlan1";
statistics.getIfaceRxBytes(ifaceName).then((data) => {
console.log(`${caseName} getIfaceRxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}).catch((err) => {
console.log(`${caseName} getIfaceRxBytes fail ${JSON.stringify(err)} `);
done();
});
});
/**
* @tc.number Telephony_NetworkManager_getIfaceRxBytes_Promise_0400
* @tc.name Test getIfaceRxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getIfaceRxBytes_Promise_0400', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getIfaceRxBytes_Promise_0400';
let ifaceName = null;
try {
statistics.getIfaceRxBytes(ifaceName).then((data) => {
console.log(`${caseName} getIfaceRxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}).catch((err) => {
console.log(`${caseName} getIfaceRxBytes fail ${JSON.stringify(err)}`);
expect(err != undefined).assertTrue();
done();
});
} catch (err) {
console.log(`${caseName} getIfaceRxBytes into catch ${JSON.stringify(err)}`);
expect(err.code == 401).assertTrue();
done();
}
});
/**
* @tc.number Telephony_NetworkManager_getIfaceTxBytes_Async_0100
* @tc.name Test getIfaceTxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getIfaceTxBytes_Async_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getIfaceTxBytes_Async_0100';
let ifaceName = "eth0";
statistics.getIfaceTxBytes(ifaceName, (err, data) => {
if (err) {
console.log(`${caseName} getIfaceTxBytes fail ${JSON.stringify(err)} `);
done();
} else {
console.log(`${caseName} getIfaceTxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}
});
});
/**
* @tc.number Telephony_NetworkManager_getIfaceTxBytes_Async_0200
* @tc.name Test getIfaceTxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getIfaceTxBytes_Async_0200', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getIfaceTxBytes_Async_0200';
let ifaceName = "wlan0";
statistics.getIfaceTxBytes(ifaceName, (err, data) => {
if (err) {
console.log(`${caseName} getIfaceTxBytes fail ${JSON.stringify(err)} `);
expect().assertFail();
done();
} else {
console.log(`${caseName} getIfaceTxBytes success ${JSON.stringify(data)}`);
expect(data >= DATA_0).assertTrue();
done();
}
});
});
/**
* @tc.number Telephony_NetworkManager_getIfaceTxBytes_Async_0300
* @tc.name Test getIfaceTxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getIfaceTxBytes_Async_0300', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getIfaceTxBytes_Async_0300';
let ifaceName = "wlan1";
statistics.getIfaceTxBytes(ifaceName, (err, data) => {
if (err) {
console.log(`${caseName} getIfaceTxBytes fail ${JSON.stringify(err)} `);
done();
} else {
console.log(`${caseName} getIfaceTxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}
});
});
/**
* @tc.number Telephony_NetworkManager_getIfaceTxBytes_Async_0400
* @tc.name Test getIfaceTxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getIfaceTxBytes_Async_0400', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getIfaceTxBytes_Async_0400';
let ifaceName = null;
try {
statistics.getIfaceTxBytes(ifaceName, (err, data) => {
if (err) {
console.log(`${caseName} getIfaceTxBytes fail ${JSON.stringify(err)}`);
expect(err != undefined).assertTrue();
done();
} else {
console.log(`${caseName} getIfaceTxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}
});
} catch (err) {
console.log(`${caseName} getIfaceTxBytes into catch ${JSON.stringify(err)}`);
expect(err.code == 401).assertTrue();
done();
}
});
/**
* @tc.number Telephony_NetworkManager_getIfaceTxBytes_Promise_0100
* @tc.name Test getIfaceTxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getIfaceTxBytes_Promise_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getIfaceTxBytes_Promise_0100';
let ifaceName = "eth0";
statistics.getIfaceTxBytes(ifaceName).then((data) => {
console.log(`${caseName} getIfaceTxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}).catch((err) => {
console.log(`${caseName} getIfaceTxBytes fail ${JSON.stringify(err)} `);
done();
});
});
/**
* @tc.number Telephony_NetworkManager_getIfaceTxBytes_Promise_0200
* @tc.name Test getIfaceTxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getIfaceTxBytes_Promise_0200', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getIfaceTxBytes_Promise_0200';
let ifaceName = "wlan0";
statistics.getIfaceTxBytes(ifaceName).then((data) => {
console.log(`${caseName} getIfaceTxBytes success ${JSON.stringify(data)}`);
expect(data >= DATA_0).assertTrue();
done();
}).catch((err) => {
console.log(`${caseName} getIfaceTxBytes fail ${JSON.stringify(err)} `);
expect().assertFail();
done();
});
});
/**
* @tc.number Telephony_NetworkManager_getIfaceTxBytes_Promise_0300
* @tc.name Test getIfaceTxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getIfaceTxBytes_Promise_0300', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getIfaceTxBytes_Promise_0300';
let ifaceName = "wlan1";
statistics.getIfaceTxBytes(ifaceName).then((data) => {
console.log(`${caseName} getIfaceTxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}).catch((err) => {
console.log(`${caseName} getIfaceTxBytes fail ${JSON.stringify(err)} `);
done();
});
});
/**
* @tc.number Telephony_NetworkManager_getIfaceTxBytes_Promise_0400
* @tc.name Test getIfaceTxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getIfaceTxBytes_Promise_0400', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getIfaceTxBytes_Promise_0400';
let ifaceName = null;
try {
statistics.getIfaceTxBytes(ifaceName).then((data) => {
console.log(`${caseName} getIfaceTxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}).catch((err) => {
console.log(`${caseName} getIfaceTxBytes fail ${JSON.stringify(err)}`);
expect(err != undefined).assertTrue();
done();
});
} catch (err) {
console.log(`${caseName} getIfaceTxBytes into catch ${JSON.stringify(err)}`);
expect(err.code == 401).assertTrue();
done();
}
});
/**
* @tc.number Telephony_NetworkManager_getAllTxBytes_Async_0100
* @tc.name Test getAllTxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getAllTxBytes_Async_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getAllTxBytes_Async_0100';
statistics.getAllTxBytes((err, data) => {
if (err) {
console.log(`${caseName} getAllTxBytes fail ${JSON.stringify(err)} `);
expect().assertFail();
done();
} else {
console.log(`${caseName} getAllTxBytes success ${JSON.stringify(data)}`);
expect(data >= DATA_0).assertTrue();
done();
}
});
});
/**
* @tc.number Telephony_NetworkManager_getAllTxBytes_Promise_0100
* @tc.name Test getAllTxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getAllTxBytes_Promise_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getAllTxBytes_Promise_0100';
statistics.getAllTxBytes().then((data) => {
console.log(`${caseName} getAllTxBytes success ${JSON.stringify(data)}`);
expect(data >= DATA_0).assertTrue();
done();
}).catch((err) => {
console.log(`${caseName} getAllTxBytes fail ${JSON.stringify(err)} `);
expect().assertFail();
done();
});
});
/**
* @tc.number Telephony_NetworkManager_getAllRxBytes_Async_0100
* @tc.name Test getAllRxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getAllRxBytes_Async_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getAllRxBytes_Async_0100';
statistics.getAllRxBytes((err, data) => {
if (err) {
console.log(`${caseName} getAllRxBytes fail ${JSON.stringify(err)} `);
expect().assertFail();
done();
} else {
console.log(`${caseName} getAllRxBytes success ${JSON.stringify(data)}`);
expect(data >= DATA_0).assertTrue();
done();
}
});
});
/**
* @tc.number Telephony_NetworkManager_getAllRxBytes_Promise_0100
* @tc.name Test getAllRxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getAllRxBytes_Promise_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getAllRxBytes_Promise_0100';
statistics.getAllRxBytes().then((data) => {
console.log(`${caseName} getAllRxBytes success ${JSON.stringify(data)}`);
expect(data >= DATA_0).assertTrue();
done();
}).catch((err) => {
console.log(`${caseName} getAllRxBytes fail ${JSON.stringify(err)} `);
expect().assertFail();
done();
});
});
/**
* @tc.number Telephony_NetworkManager_getUidRxBytes_Async_0100
* @tc.name Test getUidRxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getUidRxBytes_Async_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getUidRxBytes_Async_0100';
let uid = 20010084;
statistics.getUidRxBytes(uid, (err, data) => {
if (err) {
console.log(`${caseName} getUidRxBytes fail ${JSON.stringify(err)} `);
expect(err.code == 2103005).assertTrue();
done();
} else {
console.log(`${caseName} getUidRxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}
});
});
/**
* @tc.number Telephony_NetworkManager_getUidRxBytes_Async_0200
* @tc.name Test getUidRxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getUidRxBytes_Async_0200', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getUidRxBytes_Async_0200';
let uid = 20010084;
statistics.getUidRxBytes(uid, (err, data) => {
if (err) {
console.log(`${caseName} getUidRxBytes fail ${JSON.stringify(err)} `);
expect(err.code == 2103005).assertTrue();
done();
} else {
console.log(`${caseName} getUidRxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}
});
});
/**
* @tc.number Telephony_NetworkManager_getUidRxBytes_Promise_0100
* @tc.name Test getUidRxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getUidRxBytes_Promise_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getUidRxBytes_Promise_0100';
let uid = 20010084;
statistics.getUidRxBytes(uid).then((data) => {
console.log(`${caseName} getUidRxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}).catch((err) => {
console.log(`${caseName} getUidRxBytes fail ${JSON.stringify(err)} `);
expect(err.code == 2103005).assertTrue();
done();
});
});
/**
* @tc.number Telephony_NetworkManager_getUidRxBytes_Promise_0200
* @tc.name Test getUidRxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getUidRxBytes_Promise_0200', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getUidRxBytes_Promise_0200';
let uid = 20010084;
statistics.getUidRxBytes(uid).then((data) => {
console.log(`${caseName} getUidRxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}).catch((err) => {
console.log(`${caseName} getUidRxBytes fail ${JSON.stringify(err)} `);
expect(err.code == 2103005).assertTrue();
done();
});
});
/**
* @tc.number Telephony_NetworkManager_getUidTxBytes_Async_0100
* @tc.name Test getUidTxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getUidTxBytes_Async_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getUidTxBytes_Async_0100';
let uid = 20010084;
statistics.getUidTxBytes(uid, (err, data) => {
if (err) {
console.log(`${caseName} getUidTxBytes fail ${JSON.stringify(err)} `);
expect(err.code == 2103005).assertTrue();
done();
} else {
console.log(`${caseName} getUidTxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}
});
});
/**
* @tc.number Telephony_NetworkManager_getUidTxBytes_Async_0200
* @tc.name Test getUidTxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getUidTxBytes_Async_0200', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getUidTxBytes_Async_0200';
let uid = 20010084;
statistics.getUidTxBytes(uid, (err, data) => {
if (err) {
console.log(`${caseName} getUidTxBytes fail ${JSON.stringify(err)} `);
expect(err.code == 2103005).assertTrue();
done();
} else {
console.log(`${caseName} getUidTxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}
});
});
/**
* @tc.number Telephony_NetworkManager_getUidTxBytes_Promise_0100
* @tc.name Test getUidTxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getUidTxBytes_Promise_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getUidTxBytes_Promise_0100';
let uid = 20010084;
statistics.getUidTxBytes(uid).then((data) => {
console.log(`${caseName} getUidTxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}).catch((err) => {
console.log(`${caseName} getUidTxBytes fail ${JSON.stringify(err)} `);
expect(err.code == 2103005).assertTrue();
done();
});
});
/**
* @tc.number Telephony_NetworkManager_getUidTxBytes_Promise_0200
* @tc.name Test getUidTxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getUidTxBytes_Promise_0200', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getUidTxBytes_Promise_0200';
let uid = 20010084;
statistics.getUidTxBytes(uid).then((data) => {
console.log(`${caseName} getUidTxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}).catch((err) => {
console.log(`${caseName} getUidTxBytes fail ${JSON.stringify(err)} `);
expect(err.code == 2103005).assertTrue();
done();
});
});
/**
* @tc.number Telephony_NetworkManager_getCellularRxBytes_Async_0100
* @tc.name Test getCellularRxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getCellularRxBytes_Async_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getCellularRxBytes_Async_0100';
sim.hasSimCard(0, (err, data) => {
if (data === false) {
console.info(`${caseName} hasSimCard fail ${JSON.stringify(err)} `);
done();
return;
} else {
radio.isRadioOn(0).then((data) => {
console.info(`${caseName} isRadioOn ${JSON.stringify(data)} `);
expect(data == true).assertTrue();
statistics.getCellularRxBytes((err, data) => {
if (err) {
console.log(`${caseName} getCellularRxBytes fail ${JSON.stringify(err)} `);
expect(err.code).assertEqual(2103012);
done();
} else {
console.log(`${caseName} getCellularRxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}
});
}).catch((err) => {
console.error('When the device has no modem, the interface reports an error' + JSON.stringify(err));
expect(err.code).assertEqual(8300003);
done();
return;
});
}
});
});
/**
* @tc.number Telephony_NetworkManager_getCellularRxBytes_Promise_0100
* @tc.name Test getCellularRxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getCellularRxBytes_Promise_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getCellularRxBytes_Promise_0100';
sim.hasSimCard(0, (err, data) => {
if (data === false) {
console.info(`${caseName} hasSimCard fail ${JSON.stringify(err)} `);
done();
return;
} else {
radio.isRadioOn(0).then((data) => {
console.info(`${caseName} isRadioOn ${JSON.stringify(data)} `);
expect(data == true).assertTrue();
statistics.getCellularRxBytes().then((data) => {
console.log(`${caseName} getCellularRxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}).catch((err) => {
console.log(`${caseName} getCellularRxBytes fail ${JSON.stringify(err)} `);
expect(err.code == 2103012).assertTrue();
done();
});
}).catch((err) => {
console.error('When the device has no modem, the interface reports an error' + JSON.stringify(err));
expect(err.code).assertEqual(8300003);
done();
return;
});
}
});
});
/**
* @tc.number Telephony_NetworkManager_getCellularTxBytes_Async_0100
* @tc.name Test getCellularTxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getCellularTxBytes_Async_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getCellularTxBytes_Async_0100';
sim.hasSimCard(0, (err, data) => {
if (data === false) {
console.info(`${caseName} hasSimCard fail ${JSON.stringify(err)} `);
done();
return;
} else {
radio.isRadioOn(0).then((data) => {
console.info(`${caseName} isRadioOn ${JSON.stringify(data)} `);
expect(data == true).assertTrue();
statistics.getCellularTxBytes((err, data) => {
if (err) {
console.log(`${caseName} getCellularTxBytes fail ${JSON.stringify(err)} `);
expect(err.code == 2103012).assertTrue();
done();
} else {
console.log(`${caseName} getCellularTxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}
});
}).catch((err) => {
console.error('When the device has no modem, the interface reports an error' + JSON.stringify(err));
expect(err.code).assertEqual(8300003);
done();
return;
});
}
});
});
/**
* @tc.number Telephony_NetworkManager_getCellularTxBytes_Promise_0100
* @tc.name Test getCellularTxBytes() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getCellularTxBytes_Promise_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_getCellularTxBytes_Promise_0100';
sim.hasSimCard(0, (err, data) => {
if (data === false) {
console.info(`${caseName} hasSimCard fail ${JSON.stringify(err)} `);
done();
return;
} else {
radio.isRadioOn(0).then((data) => {
console.info(`${caseName} isRadioOn ${JSON.stringify(data)} `);
expect(data == true).assertTrue();
statistics.getCellularTxBytes().then((data) => {
console.log(`${caseName} getCellularTxBytes success ${JSON.stringify(data)}`);
expect().assertFail();
done();
}).catch((err) => {
console.log(`${caseName} getCellularTxBytes fail ${JSON.stringify(err)} `);
expect(err.code).assertEqual(2103012);
done();
});
}).catch((err) => {
console.error('When the device has no modem, the interface reports an error' + JSON.stringify(err));
expect(err.code).assertEqual(8300003);
done();
return;
});
}
});
});
});
};
......@@ -235,11 +235,7 @@ describe('ActsNetworkSearchTest', function () {
}
done();
});
/**
* @tc.number Telephony_NetworkSearch_getNetworkState_Promise_0700
* @tc.name SlotId parameter input is -1, test getNetworkState() query function go to the error
......@@ -441,26 +437,6 @@ describe('ActsNetworkSearchTest', function () {
}
});
/**
* @tc.number Telephony_StateRegistry_on_0200
* @tc.name Add a networkStatus change listen and test observer.on({slotId:0}) to view the callback results
* @tc.desc Function test
*/
it('Telephony_StateRegistry_on_0200', 0, async function (done) {
try {
observer.on('networkStateChange', {
slotId: 0
}, NetworkState => {
console.log("on networkStateChange, NetworkState:" + JSON.stringify(NetworkState));
expect(typeof NetworkState === undefined).assertFalse();
});
done();
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number Telephony_StateRegistry_off_0200
* @tc.name Add a networkStatus change listen and test observer.off() to view the callback results
......@@ -483,26 +459,6 @@ describe('ActsNetworkSearchTest', function () {
}
});
/**
* @tc.number Telephony_StateRegistry_on_0300
* @tc.name Add a networkStatus change listen and test observer.on({slotId:0}) to view the callback results
* @tc.desc Function test
*/
it('Telephony_StateRegistry_on_0300', 0, async function (done) {
try {
observer.on('signalInfoChange', {
slotId: 0
}, SignalInformation => {
console.log("on signalInfoChange, SignalInformation:" + JSON.stringify(SignalInformation));
expect(typeof SignalInformation === undefined).assertFalse();
});
done();
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number Telephony_StateRegistry_off_0300
* @tc.name Add a networkStatus change listen and test observer.off() to view the callback results
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册