提交 98392fea 编写于 作者: J jiangyuan0000

fixed 004feaf4 from https://gitee.com/jiangyuan0000/xts_acts_1/pulls/5944

hidebug getServiceDump xts测试用例同步修改
Signed-off-by: Njiangyuan0000 <jiangyuan29@huawei.com>
上级 be09a18b
......@@ -14,6 +14,7 @@
*/
import hidebug from '@ohos.hidebug'
import fileio from '@ohos.fileio'
import featureAbility from '@ohos.ability.featureAbility'
import {describe, it, expect} from '@ohos/hypium'
export default function HidebugJsTest() {
......@@ -337,47 +338,74 @@ describe('HidebugJsTest', function () {
*/
it('DFX_DFR_Hiprofiler_Interface_1100', 0, function() {
console.log('************* DFX_DFR_Hiprofiler_Interface_1100 Test start*************');
try {
let temp = hidebug.getServiceDump(10);
console.info("ServiceDump is " + temp);
expect(temp.indexOf('Success')!=-1).assertTrue();
} catch (error) {
expect().assertFail();
}
let context = featureAbility.getContext();
context.getFilesDir().then((data) => {
var path = data + "/serviceInfo1.txt"
let fd = fileio.openSync(path, 0o102, 0o666)
var serviceId = 10
var args = new Array("allInfo")
try {
hidebug.getServiceDump(serviceId, fd, args)
expect(true).assertTrue();
} catch (error) {
expect().assertFail();
console.info(error.code)
console.info(error.message)
}
fileio.closeSync(fd);
})
console.log('************* DFX_DFR_Hiprofiler_Interface_1100 Test end*************');
});
/*
* @tc.number : DFX_DFR_Hiprofiler_Interface_0900
* @tc.name : getServiceDump with abnormal parameter
* @tc.name : getServiceDump with parameter error
* @tc.desc : getServiceDump
*/
it('DFX_DFR_Hiprofiler_Interface_0900', 0, function() {
console.log('************* DFX_DFR_Hiprofiler_Interface_0900 Test start*************');
try {
let temp = hidebug.getServiceDump(-1);
console.info("ServiceDump is " + temp);
expect(temp=="Error: no such system ability service.").assertTrue();
} catch (error) {
expect().assertFail();
}
let context = featureAbility.getContext();
context.getFilesDir().then((data) => {
var path = data + "/serviceInfo2.txt"
let fd = fileio.openSync(path, 0o102, 0o666)
var serviceId = 10
var args = new Array("allInfo")
try {
hidebug.getServiceDump(serviceId)
expect().assertFail();
} catch (error) {
console.info(error.code)
console.info(error.message)
expect(error.code == 401).assertTrue();
}
fileio.closeSync(fd);
})
console.log('************* DFX_DFR_Hiprofiler_Interface_0900 Test end*************');
});
/*
* @tc.number : DFX_DFR_Hiprofiler_Interface_1000
* @tc.name : getServiceDump with overlog parameter
* @tc.name : getServiceDump with check system ability failed
* @tc.desc : getServiceDump
*/
it('DFX_DFR_Hiprofiler_Interface_1000', 0, function() {
console.log('************* DFX_DFR_Hiprofiler_Interface_1000 Test start*************');
try {
let temp = hidebug.getServiceDump(9007199254740993);
console.info("ServiceDump is " + temp);
expect(temp=="Error: invalid param").assertTrue();
} catch (error) {
expect().assertFail();
}
let context = featureAbility.getContext();
context.getFilesDir().then((data) => {
var path = data + "/serviceInfo3.txt"
let fd = fileio.openSync(path, 0o102, 0o666)
var serviceId = -10
var args = new Array("allInfo")
try {
hidebug.getServiceDump(serviceId, fd, args)
expect().assertFail();
} catch (error) {
console.info(error.code)
console.info(error.message)
expect(error.code == 11400101).assertTrue();
}
fileio.closeSync(fd);
})
console.log('************* DFX_DFR_Hiprofiler_Interface_1000 Test end*************');
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册