From 9a4f3692a30a9459d5704b13a9066324f06ba962 Mon Sep 17 00:00:00 2001 From: zhaoyuan17 Date: Mon, 25 Oct 2021 14:17:21 +0800 Subject: [PATCH] Add sleep to delay major thread next do Signed-off-by: zhaoyuan17 --- .../main/js/test/ActsSubscriber_test_unorder.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/notification/ces_standard/subscribeandpublish/actssubscriberunordersystemtest/entry/src/main/js/test/ActsSubscriber_test_unorder.js b/notification/ces_standard/subscribeandpublish/actssubscriberunordersystemtest/entry/src/main/js/test/ActsSubscriber_test_unorder.js index 2cc402d37..53588a007 100755 --- a/notification/ces_standard/subscribeandpublish/actssubscriberunordersystemtest/entry/src/main/js/test/ActsSubscriber_test_unorder.js +++ b/notification/ces_standard/subscribeandpublish/actssubscriberunordersystemtest/entry/src/main/js/test/ActsSubscriber_test_unorder.js @@ -23,6 +23,13 @@ describe('ActsSubscriberTestUnorderSystem', async function (done) { console.info("==========================>publishCallback"); } + function sleep(delay) { + var start = (new Date()).getTime(); + while((new Date()).getTime() - start < delay) { + continue; + } + } + /* * @tc.number : ActsSubscriberTestUnorderSystem_0100 * @tc.name : verify subscribe and publish : Check subscribe and publish common event data @@ -32,7 +39,7 @@ describe('ActsSubscriberTestUnorderSystem', async function (done) { it('ActsSubscriberTestUnorderSystem_0100', 0, async function (done) { console.info("===============ActsSubscriberTestUnorderSystem_0100==========================>"); var commonEventSubscribeInfo = { - events: ["publish_event0100"], + events: ["Subscriber.Support.COMMON_EVENT_BATTERY_CHANGED"], publisherDeviceId: "PublishDeviceId0100", priority: 10, }; @@ -52,7 +59,7 @@ describe('ActsSubscriberTestUnorderSystem', async function (done) { function subscriberCallBack001(err, data) { console.info("==========================>subscriberCallBack001"); - expect(data.event).assertEqual("publish_event0100"); + expect(data.event).assertEqual("Subscriber.Support.COMMON_EVENT_BATTERY_CHANGED"); expect(data.bundleName).assertEqual("PublishBundleName0100"); expect(data.code).assertEqual(55); expect(data.data).assertEqual("PublishData0100"); @@ -67,7 +74,10 @@ describe('ActsSubscriberTestUnorderSystem', async function (done) { data.getSubscribeInfo().then(function (data) { console.info("===============ActsSubscriberTestUnorderSystem_0100=========getSubscribeInfo promise"); Subscriber.subscribe(commonEventSubscriber, subscriberCallBack001); - Subscriber.publish("publish_event0100", commonEventPublishData, publishCallback); + sleep(10); + Subscriber.publish("Subscriber.Support.COMMON_EVENT_BATTERY_CHANGED", + commonEventPublishData, + publishCallback); }); }) setTimeout(function (){ -- GitLab