提交 c4cc4186 编写于 作者: O openharmony_ci 提交者: Gitee

!982 添加sleep,延迟同线程的依次调用

Merge pull request !982 from blackleon/master_1025
......@@ -23,6 +23,11 @@ describe('ActsSubscriberTestUnorderSystem', async function (done) {
console.info("==========================>publishCallback");
}
function sleep(delay) {
var start = (new Date()).getTime();
while((new Date()).getTime() - start < delay) {}
}
/*
* @tc.number : ActsSubscriberTestUnorderSystem_0100
* @tc.name : verify subscribe and publish : Check subscribe and publish common event data
......@@ -32,7 +37,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 +57,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 +72,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 (){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册