diff --git a/hiviewdfx/BUILD.gn b/hiviewdfx/BUILD.gn index 0406a0344c2cb66550fb7eb25224e59d43a04c65..973407c193f4a1cb11e12368e70ee50c52c79d42 100755 --- a/hiviewdfx/BUILD.gn +++ b/hiviewdfx/BUILD.gn @@ -17,6 +17,8 @@ group("hiviewdfxtestacts") { deps = [ "hiappeventtest/hiappeventjstest:ActsHiAppeventTest", "hicheckertest/hicheckerjstest:hicheckerjstest", + "hilogjstest:ActsHilogJsTest", + "hitracechainjstest:ActsHiTraceChainJsTest", "hiview/faultlogger/faultloggerjs:faultloggerjs_test", ] } diff --git a/hiviewdfx/hilogjstest/BUILD.gn b/hiviewdfx/hilogjstest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..f8f9ec226f3561e89af4ced8f64c5ea3df485b02 --- /dev/null +++ b/hiviewdfx/hilogjstest/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (C) 2021 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("//test/xts/tools/build/suite.gni") +ohos_js_hap_suite("ActsHilogJsTest") { + hap_profile = "./src/main/config.json" + deps = [ + ":hilog_js_assets", + ":hilog_resources", + ] + + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsHilogJsTest" +} +ohos_js_assets("hilog_js_assets") { + source_dir = "./src/main/js/default" +} +ohos_resources("hilog_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/hiviewdfx/hilogjstest/Test.json b/hiviewdfx/hilogjstest/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..4b66c039a5f1b6841c3552add3fabcc5537c351a --- /dev/null +++ b/hiviewdfx/hilogjstest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "270000", + "package": "ohos.acts.hiviewdfx.hilog.function", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHilogJsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/hiviewdfx/hilogjstest/signature/openharmony_sx.p7b b/hiviewdfx/hilogjstest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/hiviewdfx/hilogjstest/signature/openharmony_sx.p7b differ diff --git a/hiviewdfx/hilogjstest/src/main/config.json b/hiviewdfx/hilogjstest/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..2aa4396bb28f2e75b849e8b8db0a1ca94a5d1ada --- /dev/null +++ b/hiviewdfx/hilogjstest/src/main/config.json @@ -0,0 +1,60 @@ +{ + "app": { + "bundleName": "ohos.acts.hiviewdfx.hilog.function", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.acts.hiviewdfx.hilog.function", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "ohos.acts.hiviewdfx.hilog.function.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "MyApplication", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} diff --git a/hiviewdfx/hilogjstest/src/main/js/default/app.js b/hiviewdfx/hilogjstest/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..3ee099f58926b1a7c42f02bb88ebb4998f9e4ac4 --- /dev/null +++ b/hiviewdfx/hilogjstest/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2021 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. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/hiviewdfx/hilogjstest/src/main/js/default/i18n/en-US.json b/hiviewdfx/hilogjstest/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/hiviewdfx/hilogjstest/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/hiviewdfx/hilogjstest/src/main/js/default/i18n/zh-CN.json b/hiviewdfx/hilogjstest/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/hiviewdfx/hilogjstest/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/hiviewdfx/hilogjstest/src/main/js/default/pages/index/index.css b/hiviewdfx/hilogjstest/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/hiviewdfx/hilogjstest/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/hiviewdfx/hilogjstest/src/main/js/default/pages/index/index.hml b/hiviewdfx/hilogjstest/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/hiviewdfx/hilogjstest/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/hiviewdfx/hilogjstest/src/main/js/default/pages/index/index.js b/hiviewdfx/hilogjstest/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..d1af64d7509673fdd0d9026e70938277765862f4 --- /dev/null +++ b/hiviewdfx/hilogjstest/src/main/js/default/pages/index/index.js @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2021 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 app from '@system.app' +import device from '@system.device' +import router from '@system.router' +import {Core, ExpectExtend, Constant} from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../test/List.test') + core.execute() + }, + onReady() { + }, +} \ No newline at end of file diff --git a/hiviewdfx/hilogjstest/src/main/js/default/test/HilogJsTest.js b/hiviewdfx/hilogjstest/src/main/js/default/test/HilogJsTest.js new file mode 100755 index 0000000000000000000000000000000000000000..c2fbbfb957078b036f8066de5f6cd8c7d9672d42 --- /dev/null +++ b/hiviewdfx/hilogjstest/src/main/js/default/test/HilogJsTest.js @@ -0,0 +1,417 @@ +/* + * Copyright (C) 2021 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, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import hilog from '@ohos.hilog' + +describe('HilogJsTest', function () { + + /** + * run before testClass + */ + beforeAll(function () { + console.info('beforeAll called'); + }) + + /** + * run after testClass + */ + afterAll(function () { + console.info('afterAll called'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_0100 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi01', 2, function () { + console.info('testHilogJsApi01 start'); + try{ + hilog.debug(0xD001400, "HILOGTEST", "%{public}s", ['hilogJs0100']) + } catch (error){ + console.log(`testHilogJsApi01 got an error: ${JSON.stringify(error)}`) + expect().assertFail() + } + console.info('testHilogJsApi01 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_0200 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi02', 2, function () { + console.info('testHilogJsApi02 start'); + try{ + hilog.error(0xD001400, "HILOGTEST", "%{public}s", ['hilogJs0200']) + } catch (error){ + console.log(`testHilogJsApi02 got an error: ${JSON.stringify(error)}`) + expect().assertFail() + } + console.info('testHilogJsApi02 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_0300 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi03', 2, function () { + console.info('testHilogJsApi03 start'); + try{ + hilog.fatal(0xD001400, "HILOGTEST", "%{public}s", ['hilogJs0300']) + } catch (error){ + console.log(`testHilogJsApi03 got an error: ${JSON.stringify(error)}`) + expect().assertFail() + } + console.info('testHilogJsApi03 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_0400 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi04', 2, function () { + console.info('testHilogJsApi04 start'); + try{ + hilog.info(0xD001400, "HILOGTEST", "%{public}s", ['hilogJs0400']) + } catch (error){ + console.log(`testHilogJsApi04 got an error: ${JSON.stringify(error)}`) + expect().assertFail() + } + console.info('testHilogJsApi04 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_0500 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi05', 2, function () { + console.info('testHilogJsApi04 start'); + try{ + hilog.warn(0xD001400, "HILOGTEST", "%{public}s", ['hilogJs0500']) + } catch (error){ + console.log(`testHilogJsApi05 got an error: ${JSON.stringify(error)}`) + expect().assertFail() + } + console.info('testHilogJsApi05 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_0600 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi06', 2, function () { + console.info('testHilogJsApi06 start'); + const res = hilog.isLoggable(0xD001400, "HILOGTEST", 3); + expect(res).assertEqual(true); + console.info('testHilogJsApi06 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_0700 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi07', 2, function () { + console.info('testHilogJsApi07 start'); + const res = hilog.isLoggable(0xD001400, "HILOGTEST", 3); + var tag = ""; + for (var i = 0; i < 1000; i++){ + tag += "HILOGTEST" + } + expect(res).assertEqual(true); + console.info('testHilogJsApi07 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_0800 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi08', 2, function () { + console.info('testHilogJsApi08 start'); + const res = hilog.isLoggable(0xD001400, "", 3); + expect(res).assertEqual(true); + console.info('testHilogJsApi08 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_1100 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi09', 2, function () { + console.info('testHilogJsApi09 start'); + const res = hilog.isLoggable(0xD001400, "HILOGTEST", 6); + expect(res).assertEqual(true); + console.info('testHilogJsApi09 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_1200 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi10', 2, function () { + console.info('testHilogJsApi10 start'); + const res = hilog.isLoggable(0xD001400, "HILOGTEST", 7); + expect(res).assertEqual(true); + console.info('testHilogJsApi10 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_1300 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi11', 2, function () { + console.info('testHilogJsApi11 start'); + const res = hilog.isLoggable(0xD001400, "HILOGTEST", 4); + expect(res).assertEqual(true); + console.info('testHilogJsApi11 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_1400 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi12', 2, function () { + console.info('testHilogJsApi12 start'); + const res = hilog.isLoggable(0xD001400, "HILOGTEST", 5); + expect(res).assertEqual(true); + console.info('testHilogJsApi12 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_1500 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi13', 2, function () { + console.info('testHilogJsApi13 start'); + const res = hilog.isLoggable(0xD001400, "HILOGTEST", 100); + expect(res).assertEqual(false); + console.info('testHilogJsApi13 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_1600 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi14', 2, function () { + console.info('testHilogJsApi14 start'); + const res = hilog.isLoggable(0, "HILOGTEST", 5); + expect(res).assertEqual(true); + console.info('testHilogJsApi14 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_01700 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi15', 2, function () { + console.info('testHilogJsApi15 start'); + const res = hilog.isLoggable(0xFFFFFFF, "HILOGTEST", 5); + expect(res).assertEqual(true); + console.info('testHilogJsApi15 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_1800 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi16', 2, function () { + console.info('testHilogJsApi16 start'); + try{ + hilog.debug(0xD001400, "HILOGTEST", "%{public}s", ['hilogJs1800']) + }catch(error){ + console.log(`testHilogJsApi16 got an error: ${JSON.stringify(error)}`) + expect().assertFail(); + } + console.info('testHilogJsApi16 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_2100 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi17', 2, function () { + console.info('testHilogJsApi17 start'); + try{ + hilog.debug(0xD001400, "HILOGTEST", "%{public}f", [2.1]) + }catch(error){ + console.log(`testHilogJsApi17 got an error: ${JSON.stringify(error)}`) + expect().assertFail(); + } + console.info('testHilogJsApi17 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_2500 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi18', 2, function () { + console.info('testHilogJsApi18 start'); + try{ + hilog.debug(0xD001400, "HILOGTEST", "%{public}d", [65535]) + }catch(error){ + console.log(`testHilogJsApi18 got an error: ${JSON.stringify(error)}`) + expect().assertFail(); + } + console.info('testHilogJsApi18 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_2600 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi19', 2, function () { + console.info('testHilogJsApi19 start'); + try{ + hilog.debug(0xD001400, "HILOGTEST", "%{public}s", ["hilog info"]) + }catch(error){ + console.log(`testHilogJsApi19 got an error: ${JSON.stringify(error)}`) + expect().assertFail(); + } + console.info('testHilogJsApi19 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_2900 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi20', 2, function () { + console.info('testHilogJsApi20 start'); + try{ + hilog.debug(0xD001400, "HILOGTEST", "%{public}d", [2147483647]) + }catch(error){ + console.log(`testHilogJsApi20 got an error: ${JSON.stringify(error)}`) + expect().assertFail(); + } + console.info('testHilogJsApi20 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_3000 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi21', 2, function () { + console.info('testHilogJsApi21 start'); + try{ + hilog.debug(0xD001400, "HILOGTEST", "%{public}s", ["100%s%d%x%f"]) + }catch(error){ + console.log(`testHilogJsApi21 got an error: ${JSON.stringify(error)}`) + expect().assertFail(); + } + console.info('testHilogJsApi21 end'); + }) + + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_3200 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi22', 2, function () { + console.info('testHilogJsApi22 start'); + try{ + hilog.debug(0xD001400, "HILOGTEST", "%{public}s", ["65536"]) + }catch(error){ + console.log(`testHilogJsApi22 got an error: ${JSON.stringify(error)}`) + expect().assertFail(); + } + console.info('testHilogJsApi22 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_3300 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi23', 2, function () { + console.info('testHilogJsApi23 start'); + try{ + hilog.debug(0xD001400, "HILOGTEST", "username:%{public}s, password:%{private}s.", ["username", "password"]) + hilog.debug(0xD001400, "HILOGTEST", "username:%{public}s, password:%s.", ["username123", "password"]) + }catch(error){ + console.log(`testHilogJsApi23 got an error: ${JSON.stringify(error)}`) + expect().assertFail(); + } + console.info('testHilogJsApi23 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_3400 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi24', 2, function () { + console.info('testHilogJsApi24 start'); + try{ + hilog.debug(0xD001400, "HILOGTEST", "%{public}s", ["hilog public"]) + }catch(error){ + console.log(`testHilogJsApi24 got an error: ${JSON.stringify(error)}`) + expect().assertFail(); + } + console.info('testHilogJsApi24 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_3500 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi25', 2, function () { + console.info('testHilogJsApi25 start'); + try{ + hilog.debug(0xD001400, "HILOGTEST", "%{nopublic}s", ["Hilogtest"]) + }catch(error){ + console.log(`testHilogJsApi25 got an error: ${JSON.stringify(error)}`) + expect().assertFail(); + } + console.info('testHilogJsApi25 end'); + }) + + /** + * @tc.number DFX_DFT_Hiview_Libhilog_Hilog_JS_3800 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHilogJsApi26', 2, function () { + console.info('testHilogJsApi26 start'); + try{ + hilog.info(0xD001400, "HILOGTEST", "username:%{public}s, password:%{private}s.", ["username", "password"]) + hilog.info(0xD001400, "HILOGTEST", "username:%{public}s, password:%s.", ["username123", "password"]) + }catch(error){ + console.log(`testHilogJsApi26 got an error: ${JSON.stringify(error)}`) + expect().assertFail(); + } + console.info('testHilogJsApi26 end'); + }) + +}) diff --git a/hiviewdfx/hilogjstest/src/main/js/default/test/List.test.js b/hiviewdfx/hilogjstest/src/main/js/default/test/List.test.js new file mode 100755 index 0000000000000000000000000000000000000000..f9061e13ffdcabcb5083c5f8da8eec8c5c468c29 --- /dev/null +++ b/hiviewdfx/hilogjstest/src/main/js/default/test/List.test.js @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2021 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. + */ +require('./HilogJsTest.js') diff --git a/hiviewdfx/hilogjstest/src/main/resources/base/element/string.json b/hiviewdfx/hilogjstest/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ab025e765292c86abf35e594e18f4e4549ed2f06 --- /dev/null +++ b/hiviewdfx/hilogjstest/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "test2demo" + }, + { + "name": "mainability_description", + "value": "hap sample empty page" + } + ] +} diff --git a/hiviewdfx/hilogjstest/src/main/resources/base/media/icon.png b/hiviewdfx/hilogjstest/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/hiviewdfx/hilogjstest/src/main/resources/base/media/icon.png differ diff --git a/hiviewdfx/hitracechainjstest/BUILD.gn b/hiviewdfx/hitracechainjstest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..be4f0d76a09bb7e93467b68390fc2a328b5b5763 --- /dev/null +++ b/hiviewdfx/hitracechainjstest/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (C) 2021 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("//test/xts/tools/build/suite.gni") +ohos_js_hap_suite("ActsHiTraceChainJsTest") { + hap_profile = "./src/main/config.json" + deps = [ + ":hitrace_js_assets", + ":hitrace_resources", + ] + + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsHiTraceChainJsTest" +} +ohos_js_assets("hitrace_js_assets") { + source_dir = "./src/main/js/default" +} +ohos_resources("hitrace_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/hiviewdfx/hitracechainjstest/Test.json b/hiviewdfx/hitracechainjstest/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..450fa2fc2d0badf230e7fe6caa34f63b00a00b46 --- /dev/null +++ b/hiviewdfx/hitracechainjstest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "270000", + "package": "ohos.acts.hiviewdfx.hitracechain.function", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHiTraceChainJsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/hiviewdfx/hitracechainjstest/signature/openharmony_sx.p7b b/hiviewdfx/hitracechainjstest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/hiviewdfx/hitracechainjstest/signature/openharmony_sx.p7b differ diff --git a/hiviewdfx/hitracechainjstest/src/main/config.json b/hiviewdfx/hitracechainjstest/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..8037135725ee0acabb81a941d16712b85654dc28 --- /dev/null +++ b/hiviewdfx/hitracechainjstest/src/main/config.json @@ -0,0 +1,60 @@ +{ + "app": { + "bundleName": "ohos.acts.hiviewdfx.hitracechain.function", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.acts.hiviewdfx.hitracechain.function", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "ohos.acts.hiviewdfx.hilog.hitracechain.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "MyApplication", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} diff --git a/hiviewdfx/hitracechainjstest/src/main/js/default/app.js b/hiviewdfx/hitracechainjstest/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..3ee099f58926b1a7c42f02bb88ebb4998f9e4ac4 --- /dev/null +++ b/hiviewdfx/hitracechainjstest/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2021 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. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/hiviewdfx/hitracechainjstest/src/main/js/default/i18n/en-US.json b/hiviewdfx/hitracechainjstest/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/hiviewdfx/hitracechainjstest/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/hiviewdfx/hitracechainjstest/src/main/js/default/i18n/zh-CN.json b/hiviewdfx/hitracechainjstest/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/hiviewdfx/hitracechainjstest/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/hiviewdfx/hitracechainjstest/src/main/js/default/pages/index/index.css b/hiviewdfx/hitracechainjstest/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/hiviewdfx/hitracechainjstest/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/hiviewdfx/hitracechainjstest/src/main/js/default/pages/index/index.hml b/hiviewdfx/hitracechainjstest/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/hiviewdfx/hitracechainjstest/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/hiviewdfx/hitracechainjstest/src/main/js/default/pages/index/index.js b/hiviewdfx/hitracechainjstest/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..d1af64d7509673fdd0d9026e70938277765862f4 --- /dev/null +++ b/hiviewdfx/hitracechainjstest/src/main/js/default/pages/index/index.js @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2021 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 app from '@system.app' +import device from '@system.device' +import router from '@system.router' +import {Core, ExpectExtend, Constant} from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../test/List.test') + core.execute() + }, + onReady() { + }, +} \ No newline at end of file diff --git a/hiviewdfx/hitracechainjstest/src/main/js/default/test/HiTraceChainJs.test.js b/hiviewdfx/hitracechainjstest/src/main/js/default/test/HiTraceChainJs.test.js new file mode 100755 index 0000000000000000000000000000000000000000..ecfdb65abb30016cc31f4fd24ed681c94921a808 --- /dev/null +++ b/hiviewdfx/hitracechainjstest/src/main/js/default/test/HiTraceChainJs.test.js @@ -0,0 +1,355 @@ +/* + * Copyright (C) 2021 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 hiTraceChain from '@ohos.hiTraceChain' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import hilog from '@ohos.hilog' + +describe('HiTraceJsTest', function () { + + /** + * run before testClass + */ + beforeAll(function () { + console.info('beforeAll called'); + }) + + /** + * run after testClass + */ + afterAll(function () { + console.info('afterAll called'); + }) + + /** + * @tc.number DFX_DFT_Hitrace_JS_001 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHitraceApi01', 1, async function (done) { + console.info('testHitraceApi01 start'); + try{ + let traceId = hiTraceChain.begin("hitrace01"); + let traceIdIsvalid = hiTraceChain.isValid(traceId); + if(!traceIdIsvalid){ + expect().assertFail(); + console.log(`testHitraceApi01 got an error: ${JSON.stringify(error)}`); + } + hiTraceChain.end(traceId); + } catch (error){ + console.log(`testHitraceApi01 got an error: ${JSON.stringify(error)}`); + expect().assertFail(); + done(); + } + console.info('testHitraceApi01 end'); + done(); + }) + + /** + * @tc.number DFX_DFT_Hitrace_JS_002 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHitraceApi02', 1, async function (done) { + console.info('testHitraceApi02 start'); + try{ + let traceId = hiTraceChain.begin("hitrace02", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC | + hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); + let traceIdIsvalid = hiTraceChain.isValid(traceId); + if(!traceIdIsvalid){ + expect().assertFail(); + console.log(`testHitraceApi02 got an error: ${JSON.stringify(error)}`); + } + hiTraceChain.end(traceId); + } catch (error){ + console.log(`testHitraceApi02 got an error: ${JSON.stringify(error)}`); + expect().assertFail(); + done(); + } + console.info('testHitraceApi02 end'); + done(); + }) + + /** + * @tc.number DFX_DFT_Hitrace_JS_003 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHitraceApi03', 1, async function (done) { + console.info('testHitraceApi03 start'); + try{ + let traceId = hiTraceChain.begin("hitrace03", hiTraceChain.HiTraceFlag.TP_INFO); + let curTraceId = hiTraceChain.getId(); + if(traceId.chainId != curTraceId.chainId){ + expect().assertFail(); + console.log(`testHitraceApi03 got an error: ${JSON.stringify(error)}`); + } + hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.THREAD, + hiTraceChain.HiTraceTracepointType.SS, traceId, "hitrace api test."); + hiTraceChain.end(traceId); + } catch (error){ + console.log(`testHitraceApi03 got an error: ${JSON.stringify(error)}`); + expect().assertFail(); + done(); + } + console.info('testHitraceApi03 end'); + done(); + }) + + /** + * @tc.number DFX_DFT_Hitrace_JS_004 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHitraceApi04', 1, async function (done) { + console.info('testHitraceApi04 start'); + try{ + let traceId = hiTraceChain.begin("hitrace04", hiTraceChain.HiTraceFlag.NO_BE_INFO); + let spanTraceId = hiTraceChain.createSpan(); + let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(traceId, hiTraceChain.HiTraceFlag.NO_BE_INFO); + if(!enabledDoNotCreateSpanFlag){ + expect().assertFail(); + console.log(`testHitraceApi04 got an error: ${JSON.stringify(error)}`); + } + hiTraceChain.end(traceId); + } catch (error){ + console.log(`testHitraceApi04 got an error: ${JSON.stringify(error)}`); + expect().assertFail(); + done(); + } + console.info('testHitraceApi04 end'); + done(); + }) + + /** + * @tc.number DFX_DFT_Hitrace_JS_005 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHitraceApi05', 1, async function (done) { + console.info('testHitraceApi05 start'); + try{ + let traceId = hiTraceChain.begin("hitrace05"); + hiTraceChain.enableFlag(traceId, hiTraceChain.HiTraceFlag.DISABLE_LOG); + let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(traceId, hiTraceChain.HiTraceFlag.DISABLE_LOG); + if(!enabledDoNotCreateSpanFlag){ + expect().assertFail(); + console.log(`testHitraceApi05 got an error: ${JSON.stringify(error)}`); + } + hiTraceChain.end(traceId); + } catch (error){ + console.log(`testHitraceApi05 got an error: ${JSON.stringify(error)}`); + expect().assertFail(); + done(); + } + console.info('testHitraceApi05 end'); + done(); + }) + + /** + * @tc.number DFX_DFT_Hitrace_JS_006 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHitraceApi06', 1, async function (done) { + console.info('testHitraceApi06 start'); + try{ + let traceId = hiTraceChain.begin("hitrace06"); + hiTraceChain.enableFlag(traceId, hiTraceChain.HiTraceFlag.FAILURE_TRIGGER); + let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(traceId, + hiTraceChain.HiTraceFlag.FAILURE_TRIGGER); + if(!enabledDoNotCreateSpanFlag){ + expect().assertFail(); + console.log(`testHitraceApi06 got an error: ${JSON.stringify(error)}`); + } + hiTraceChain.end(traceId); + } catch (error){ + console.log(`testHitraceApi06 got an error: ${JSON.stringify(error)}`); + expect().assertFail(); + done(); + } + console.info('testHitraceApi06 end'); + done(); + }) + + /** + * @tc.number DFX_DFT_Hitrace_JS_007 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHitraceApi07', 1, async function (done) { + console.info('testHitraceApi07 start'); + try{ + let traceId = hiTraceChain.begin("hitrace07", hiTraceChain.HiTraceFlag.D2D_TP_INFO); + let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(traceId, hiTraceChain.HiTraceFlag.D2D_TP_INFO) + if(!enabledDoNotCreateSpanFlag){ + expect().assertFail(); + console.log(`testHitraceApi07 got an error: ${JSON.stringify(error)}`); + } + hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.PROCESS, + hiTraceChain.HiTraceTracepointType.CS, traceId, "hitrace test"); + hiTraceChain.end(traceId); + } catch (error){ + console.log(`testHitraceApi07 got an error: ${JSON.stringify(error)}`); + expect().assertFail(); + done(); + } + console.info('testHitraceApi07 end'); + done(); + }) + + /** + * @tc.number DFX_DFT_Hitrace_JS_008 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHitraceApi08', 1, async function (done) { + console.info('testHitraceApi08 start'); + hiTraceChain.clearId(); + let traceId = hiTraceChain.begin("testHitraceApi08", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); + let curChainId = traceId.chainId; + new Promise(function(resolve, reject){ + resolve() + }).then(() => { + console.info('in testHitraceApi08 then callback') + console.info(`testHitraceApi08 ${hiTraceChain.getId().chainId} <> ${curChainId}`) + expect(hiTraceChain.getId().chainId == curChainId).assertTrue() + done() + }) + hiTraceChain.end(traceId); + done() + console.info('testHitraceApi08 end'); + + }) + + /** + * @tc.number DFX_DFT_Hitrace_JS_009 + * @tc.name hitrace interface test + * @tc.desc hitrace begin interface test. + */ + it('testHitraceApi09', 1, async function (done) { + console.info('testHitraceApi09 start'); + hiTraceChain.clearId(); + let traceId = hiTraceChain.begin("hitrace09", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); + let curChainId = traceId.chainId; + async function asyncTask() { + } + asyncTask().then(() => { + console.info('in testhiTraceApi09 then callback') + console.info(`testHitraceApi09 ${hiTraceChain.getId().chainId} <> ${curChainId}`) + expect(hiTraceChain.getId().chainId == curChainId).assertTrue() + done() + }) + hiTraceChain.end(traceId); + done() + console.info('testHitraceApi09 end'); + }) + + /** + * @tc.name: 接口测试-hitrace接口支持跨设备跟踪 + * @tc.number DFX_DFT_Hitrace_JS_010 + * @tc.function A01010 + * @tc.feature DFX_DFT_Hitrace + * @tc.level Level3 + * @tc.type FUNC + * @tc.author chenxuhui + */ + it('testHitraceApi10', 0, async function (done) { + console.info('testHitraceApi10 start') + hiTraceChain.clearId(); + try { + let traceId = hiTraceChain.begin("hitrace10", hiTraceChain.HiTraceFlag.D2D_TP_INFO); + let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(traceId, hiTraceChain.HiTraceFlag.D2D_TP_INFO); + if(!enabledDoNotCreateSpanFlag){ + expect().assertFail(); + console.log(`testHitraceApi10 got an error: ${JSON.stringify(error)}`); + } + hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.DEVICE, + hiTraceChain.HiTraceTracepointType.CR,traceId, "hitrace test"); + hiTraceChain.end(traceId); + } catch (error) { + console.log(`testHitraceApi10 got an error: ${JSON.stringify(error)}`); + expect().assertFail(); + done() + } + console.info('testHitraceApi10 end') + done() + }); + + /** + * @tc.name: 接口测试-hitrace接口支持跨设备跟踪 + * @tc.number DFX_DFT_Hitrace_JS_011 + * @tc.function A01011 + * @tc.feature DFX_DFT_Hitrace + * @tc.level Level3 + * @tc.type FUNC + * @tc.author chenxuhui + */ + it('testHitraceApi11', 0, async function (done) { + console.info('testHitraceApi11 start') + hiTraceChain.setId(12345678); + hiTraceChain.clearId(); + try { + let traceId = hiTraceChain.begin("hitrace11", hiTraceChain.HiTraceFlag.D2D_TP_INFO); + let flags = traceId.flags + let parentSpanId = traceId.parentSpanId + let spanId = traceId.spanId + let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(traceId, hiTraceChain.HiTraceFlag.D2D_TP_INFO); + if(!enabledDoNotCreateSpanFlag){ + expect().assertFail(); + console.log(`testHitraceApi11 got an error: ${JSON.stringify(error)}`); + } + hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.DEFAULT, + hiTraceChain.HiTraceTracepointType.SR, traceId, "hitrace test"); + hiTraceChain.end(traceId); + } catch (error) { + console.log(`testHitraceApi11 got an error: ${JSON.stringify(error)}`); + expect().assertFail(); + done() + } + console.info('testHitraceApi11 end') + done() + }); + + /** + * @tc.name: 接口测试-hitrace接口支持跨设备跟踪 + * @tc.number DFX_DFT_Hitrace_JS_012 + * @tc.function A01010 + * @tc.feature DFX_DFT_Hitrace + * @tc.level Level3 + * @tc.type FUNC + * @tc.author chenxuhui + */ + it('testHitraceApi12', 0, async function (done) { + console.info('testHitraceApi12 start') + try { + let traceId = hiTraceChain.begin("hitrace12", hiTraceChain.HiTraceFlag.D2D_TP_INFO); + let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(traceId, hiTraceChain.HiTraceFlag.D2D_TP_INFO); + if(!enabledDoNotCreateSpanFlag){ + expect().assertFail(); + console.log(`testHitraceApi12 got an error: ${JSON.stringify(error)}`); + } + hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.DEVICE, + hiTraceChain.HiTraceTracepointType.GENERAL, traceId, "hitrace test"); + hiTraceChain.end(traceId); + } catch (error) { + console.log(`testHitraceApi12 got an error: ${JSON.stringify(error)}`); + expect().assertFail(); + done() + } + console.info('testHitraceApi12 end') + done() + }); + +}) diff --git a/hiviewdfx/hitracechainjstest/src/main/js/default/test/List.test.js b/hiviewdfx/hitracechainjstest/src/main/js/default/test/List.test.js new file mode 100755 index 0000000000000000000000000000000000000000..20476b721d5edf862786ce733ac5ee5d108c0f0d --- /dev/null +++ b/hiviewdfx/hitracechainjstest/src/main/js/default/test/List.test.js @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2021 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. + */ +require('./HiTraceChainJs.test.js') diff --git a/hiviewdfx/hitracechainjstest/src/main/resources/base/element/string.json b/hiviewdfx/hitracechainjstest/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ab025e765292c86abf35e594e18f4e4549ed2f06 --- /dev/null +++ b/hiviewdfx/hitracechainjstest/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "test2demo" + }, + { + "name": "mainability_description", + "value": "hap sample empty page" + } + ] +} diff --git a/hiviewdfx/hitracechainjstest/src/main/resources/base/media/icon.png b/hiviewdfx/hitracechainjstest/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/hiviewdfx/hitracechainjstest/src/main/resources/base/media/icon.png differ