未验证 提交 1832dbdb 编写于 作者: O openharmony_ci 提交者: Gitee

!5960 hidebug napi接口调整

Merge pull request !5960 from jiangyuan0000/cherry-pick-1666098189
......@@ -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.
先完成此消息的编辑!
想要评论请 注册