diff --git a/hiviewdfx/hidebugtest/hidebugtestjstest/src/main/js/test/Hidebug.test.js b/hiviewdfx/hidebugtest/hidebugtestjstest/src/main/js/test/Hidebug.test.js index 6f5421a20fa94eb382c3e86889dede6982241091..8bce187544b4b8966cc04495a149d2bcab0d9e12 100644 --- a/hiviewdfx/hidebugtest/hidebugtestjstest/src/main/js/test/Hidebug.test.js +++ b/hiviewdfx/hidebugtest/hidebugtestjstest/src/main/js/test/Hidebug.test.js @@ -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*************'); });