From 6f2c6e1d6b9572ace0956cbbd7115c1cb0f45d5e Mon Sep 17 00:00:00 2001 From: chenxuihui Date: Fri, 26 Aug 2022 11:52:17 +0800 Subject: [PATCH] hiappeventsubjscommit Signed-off-by: chenxuihui --- .../src/main/js/test/HiAppEventSub.test.js | 88 +++++++++---------- 1 file changed, 43 insertions(+), 45 deletions(-) diff --git a/hiviewdfx/hiappeventtest/hiappeventsubjstest/src/main/js/test/HiAppEventSub.test.js b/hiviewdfx/hiappeventtest/hiappeventsubjstest/src/main/js/test/HiAppEventSub.test.js index 48c657999..850e556db 100755 --- a/hiviewdfx/hiappeventtest/hiappeventsubjstest/src/main/js/test/HiAppEventSub.test.js +++ b/hiviewdfx/hiappeventtest/hiappeventsubjstest/src/main/js/test/HiAppEventSub.test.js @@ -120,13 +120,13 @@ describe('HiAppEventSubTest', function () { */ it('HiAppEventSub02', 3, async function (done) { console.info('testHiAppEventSub02 start') - function sleep(numberMillis){ + function sleep(numberMillis) { var now = new Date(); - var exitTime = now.getTime() +numberMillis; - while (true){ + var exitTime = now.getTime() + numberMillis; + while (true) { now = new Date(); - if(now.getTime() > exitTime) - return; + if (now.getTime() > exitTime) + return; } } let holder = HiAppEvent.addWatcher({ @@ -593,7 +593,7 @@ describe('HiAppEventSubTest', function () { console.info('HiAppEventSub07 end') }, 1000) }) - + /** * @tc.number DFX_DFT_HiAppEvent_Sub_0800 * @tc.name 验证调用hiAppEvent.addWatcher,domain为无效,事件订阅失败 @@ -647,7 +647,7 @@ describe('HiAppEventSubTest', function () { console.info('HiAppEventSub08 end') }, 1000) }) - + /** * @tc.number DFX_DFT_HiAppEvent_Sub_0900 * @tc.name 验证调用hiAppEvent.addWatcher,设置domain,eventType为FAULT,事件订阅成功 @@ -1004,7 +1004,7 @@ describe('HiAppEventSubTest', function () { { domain: "default", eventTypes: [HiAppEvent.EventType.FAULT,HiAppEvent.EventType.STATISTIC, - HiAppEvent.EventType.SECURITY,HiAppEvent.EventType.BEHAVIOR] + HiAppEvent.EventType.SECURITY,HiAppEvent.EventType.BEHAVIOR] } ], triggerCondition: { @@ -1091,7 +1091,7 @@ describe('HiAppEventSubTest', function () { appEventFilters: [ { eventTypes: [HiAppEvent.EventType.FAULT,HiAppEvent.EventType.STATISTIC, - HiAppEvent.EventType.SECURITY,HiAppEvent.EventType.BEHAVIOR] + HiAppEvent.EventType.SECURITY,HiAppEvent.EventType.BEHAVIOR] } ], triggerCondition: { @@ -1258,13 +1258,13 @@ describe('HiAppEventSubTest', function () { */ it('HiAppEventSub16', 3, async function (done) { console.info('testHiAppEventSub16 start') - function sleep(numberMillis){ + function sleep(numberMillis) { var now = new Date(); - var exitTime = now.getTime() +numberMillis; - while (true){ + var exitTime = now.getTime() + numberMillis; + while (true) { now = new Date(); - if(now.getTime() > exitTime) - return; + if (now.getTime() > exitTime) + return; } } let result = HiAppEvent.addWatcher({ @@ -1341,13 +1341,13 @@ describe('HiAppEventSubTest', function () { */ it('HiAppEventSub17', 3, async function (done) { console.info('testHiAppEventSub17 start') - function sleep(numberMillis){ + function sleep(numberMillis) { var now = new Date(); - var exitTime = now.getTime() +numberMillis; - while (true){ + var exitTime = now.getTime() + numberMillis; + while (true) { now = new Date(); - if(now.getTime() > exitTime) - return; + if (now.getTime() > exitTime) + return; } } let result = HiAppEvent.addWatcher({ @@ -1627,7 +1627,7 @@ describe('HiAppEventSubTest', function () { console.info('HiAppEventSub21 end') }, 1000) }) - + /** * @tc.number DFX_DFT_HiAppEvent_Sub_2200 * @tc.name 验证调用hiAppEvent.addWatcher,timeout=1,事件订阅成功 @@ -1635,13 +1635,13 @@ describe('HiAppEventSubTest', function () { */ it('HiAppEventSub22', 3, async function (done) { console.info('testHiAppEventSub22 start') - function sleep(numberMillis){ + function sleep(numberMillis) { var now = new Date(); - var exitTime = now.getTime() +numberMillis; - while (true){ + var exitTime = now.getTime() + numberMillis; + while (true) { now = new Date(); - if(now.getTime() > exitTime) - return; + if (now.getTime() > exitTime) + return; } } let result = HiAppEvent.addWatcher({ @@ -1689,7 +1689,6 @@ describe('HiAppEventSubTest', function () { }, 1000) }) - /** * @tc.number DFX_DFT_HiAppEvent_Sub_2300 * @tc.name 验证调用hiAppEvent.addWatcher,timeout=0,事件订阅失败 @@ -1697,13 +1696,13 @@ describe('HiAppEventSubTest', function () { */ it('HiAppEventSub23', 3, async function (done) { console.info('testHiAppEventSub23 start') - function sleep(numberMillis){ + function sleep(numberMillis) { var now = new Date(); - var exitTime = now.getTime() +numberMillis; - while (true){ + var exitTime = now.getTime() + numberMillis; + while (true) { now = new Date(); - if(now.getTime() > exitTime) - return; + if (now.getTime() > exitTime) + return; } } let result = HiAppEvent.addWatcher({ @@ -1751,7 +1750,6 @@ describe('HiAppEventSubTest', function () { }, 1000) }) - /** * @tc.number DFX_DFT_HiAppEvent_Sub_2400 * @tc.name 验证调用hiAppEvent.addWatcher,未设置触发条件,事件订阅失败 @@ -1759,13 +1757,13 @@ describe('HiAppEventSubTest', function () { */ it('HiAppEventSub24', 3, async function (done) { console.info('testHiAppEventSub24 start') - function sleep(numberMillis){ + function sleep(numberMillis) { var now = new Date(); - var exitTime = now.getTime() +numberMillis; - while (true){ + var exitTime = now.getTime() + numberMillis; + while (true) { now = new Date(); - if(now.getTime() > exitTime) - return; + if (now.getTime() > exitTime) + return; } } let result = HiAppEvent.addWatcher({ @@ -1815,13 +1813,15 @@ describe('HiAppEventSubTest', function () { * @tc.name 验证调用hiAppEvent.addWatcher,触发条件仅timeout有效,事件订阅成功 * @tc.desc HiAppEvent write interface test. */ - function sleep(numberMillis){ + it('HiAppEventSub28', 3, async function (done) { + console.info('testHiAppEventSub28 start') + function sleep(numberMillis) { var now = new Date(); - var exitTime = now.getTime() +numberMillis; - while (true){ + var exitTime = now.getTime() + numberMillis; + while (true) { now = new Date(); - if(now.getTime() > exitTime) - return; + if (now.getTime() > exitTime) + return; } } let result = HiAppEvent.addWatcher({ @@ -1923,7 +1923,6 @@ describe('HiAppEventSubTest', function () { }, 1000) }) - /** * @tc.number DFX_DFT_HiAppEvent_Sub_2500 * @tc.name 验证调用removeWatcher,watcher为已有watcher,订阅者、相关订阅事件删除成功 @@ -1962,7 +1961,6 @@ describe('HiAppEventSubTest', function () { }) - /** * @tc.number DFX_DFT_HiAppEvent_Sub_2600 * @tc.name 验证调用removeWatcher,watcher无效,订阅者、相关订阅事件删除失败 @@ -1999,7 +1997,7 @@ describe('HiAppEventSubTest', function () { console.info('HiAppEventSub26 end') }, 2000) }) - + /** * @tc.number DFX_DFT_HiAppEvent_Sub_2700 * @tc.name 验证清理接口功能 -- GitLab