From 98392fea9ea03e7aa03be7549fdeb0836e9079d2 Mon Sep 17 00:00:00 2001 From: jiangyuan0000 Date: Tue, 18 Oct 2022 15:05:19 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20004feaf=20from=20https://gitee.com/jian?= =?UTF-8?q?gyuan0000/xts=5Facts=5F1/pulls/5944=20hidebug=20getServiceDump?= =?UTF-8?q?=20xts=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jiangyuan0000 --- .../src/main/js/test/Hidebug.test.js | 74 +++++++++++++------ 1 file changed, 51 insertions(+), 23 deletions(-) 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 6f5421a20..8bce18754 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*************'); }); -- GitLab