Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
18970b1e
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
18970b1e
编写于
8月 04, 2022
作者:
O
openharmony_ci
提交者:
Gitee
8月 04, 2022
浏览文件
操作
浏览文件
下载
差异文件
!4799 【XTS】【事件通知子系统】EmitterTest 整改_master
Merge pull request !4799 from 郅建文/master
上级
ca35e93c
0e1c427b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
116 addition
and
117 deletion
+116
-117
notification/ces_standard/subscribeandpublish/emittertest/src/main/js/test/EmitterTest.js
...ibeandpublish/emittertest/src/main/js/test/EmitterTest.js
+116
-117
未找到文件。
notification/ces_standard/subscribeandpublish/emittertest/src/main/js/test/EmitterTest.js
浏览文件 @
18970b1e
...
...
@@ -17,139 +17,138 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
export
default
function
EmitterTest
()
{
describe
(
'
EmitterTest
'
,
function
()
{
console
.
info
(
"
===========EmitterTest start====================>
"
);
var
eventData
=
{
data
:
{
"
id
"
:
1
,
"
content
"
:
"
message
"
,
}
}
var
InnerEventImmediate
=
{
eventId
:
1
,
priority
:
emitter
.
EventPriority
.
IMMEDIATE
const
TAG
=
'
EmitterTest ===>
'
console
.
info
(
TAG
+
'
EmitterTest START
'
)
let
innerEvent
=
{
eventId
:
undefined
,
priority
:
undefined
}
var
InnerEventLow
=
{
eventId
:
2
,
priority
:
emitter
.
EventPriority
.
LOW
let
eventData
=
{
data
:
{
'
id
'
:
undefined
,
'
content
'
:
undefined
}
}
function
callback
(
data
){
console
.
info
(
'
callback success
'
);
expect
(
data
.
eventId
).
assertEqual
(
"
message
"
);
function
EmitterCallback
(
eventData
)
{
console
.
info
(
TAG
+
'
eventData.id:
'
+
JSON
.
stringify
(
eventData
.
data
.
id
));
console
.
info
(
TAG
+
'
eventData.content:
'
+
JSON
.
stringify
(
eventData
.
data
.
content
));
if
(
eventData
.
data
.
id
==
0
)
{
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_0
'
);
}
else
if
(
eventData
.
data
.
id
==
1
)
{
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_1
'
);
}
else
if
(
eventData
.
data
.
id
==
2
)
{
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_2
'
);
}
else
if
(
eventData
.
data
.
id
==
3
)
{
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_3
'
);
}
else
if
(
eventData
.
data
.
id
==
4
)
{
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_4
'
);
}
else
if
(
eventData
.
data
.
id
==
5
)
{
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_5
'
);
}
}
function
callback01
(
data
){
console
.
info
(
'
callback success
'
);
expect
(
data
.
data
.
id
).
assertEqual
(
1
);
expect
(
data
.
data
.
content
).
assertEqual
(
"
message
"
);
}
/*
* @tc.number : Emitter
OnTest
* @tc.name : verify on :
Check subscribe same on common ordered event
* @tc.desc :
Check the subscriber can receive event "EmitterOnTest" type of the interface (by Promise)
* @tc.number : Emitter
Test_0100
* @tc.name : verify on :
on(event: InnerEvent, callback: Callback<EventData>): void
* @tc.desc :
emitter.EventPriority.IDLE
*/
it
(
'
EmitterOnTest
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
===========EmitterOnTest====================>
"
);
emitter
.
on
(
InnerEventImmediate
,
callback
);
done
();
it
(
'
EmitterTest_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
EmitterTest_0100 START
'
)
innerEvent
.
eventId
=
1
innerEvent
.
priority
=
emitter
.
EventPriority
.
IDLE
eventData
.
data
.
id
=
0
eventData
.
data
.
content
=
'
message_0
'
emitter
.
on
(
innerEvent
,
EmitterCallback
)
emitter
.
emit
(
innerEvent
,
eventData
)
eventData
.
data
.
id
=
1
eventData
.
data
.
content
=
'
message_1
'
emitter
.
emit
(
innerEvent
,
eventData
)
console
.
info
(
TAG
+
'
EmitterTest_0100 END
'
)
done
()
})
/*
* @tc.number : Emitter
OnceTest
* @tc.name : verify on
ce : Check subscribe same once common ordered event
* @tc.desc :
Check the subscriber can receive event "EmitterOnceTest" type of the interface (by Promise)
* @tc.number : Emitter
Test_0200
* @tc.name : verify on
: once(event: InnerEvent, callback: Callback<EventData>): void
* @tc.desc :
emitter.EventPriority.LOW
*/
it
(
'
EmitterOnceTest
'
,
0
,
async
function
(
done
){
console
.
info
(
"
===========EmitterOnceTest====================>
"
);
emitter
.
once
(
InnerEventImmediate
,
callback
);
done
();
it
(
'
EmitterTest_0200
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
EmitterTest_0200 START
'
)
innerEvent
.
eventId
=
2
innerEvent
.
priority
=
emitter
.
EventPriority
.
LOW
eventData
.
data
.
id
=
2
eventData
.
data
.
content
=
'
message_2
'
emitter
.
once
(
innerEvent
,
EmitterCallback
)
emitter
.
emit
(
innerEvent
,
eventData
)
console
.
info
(
TAG
+
'
EmitterTest_0200 END
'
)
done
()
})
/*
* @tc.number : Emitter
EmitTest
* @tc.name : verify
emit : Check subscribe same emit common ordered event
* @tc.desc :
Check the subscriber can receive event "EmitterEmitTest" type of the interface (by Promise)
* @tc.number : Emitter
Test_0300
* @tc.name : verify
on : emit(event: InnerEvent, data?: EventData): void
* @tc.desc :
emitter.EventPriority.HIGH
*/
it
(
'
EmitterEmitTest
'
,
0
,
async
function
(
done
){
console
.
info
(
"
===========EmitterEmitTest====================>
"
);
emitter
.
once
(
InnerEventImmediate
,
callback01
);
emitter
.
emit
(
InnerEventImmediate
,
eventData
);
done
();
it
(
'
EmitterTest_0300
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
EmitterTest_0300 START
'
)
innerEvent
.
eventId
=
3
innerEvent
.
priority
=
emitter
.
EventPriority
.
HIGH
eventData
.
data
.
id
=
3
eventData
.
data
.
content
=
'
message_3
'
emitter
.
once
(
innerEvent
,
EmitterCallback
)
emitter
.
emit
(
innerEvent
,
eventData
)
console
.
info
(
TAG
+
'
EmitterTest_0300 END
'
)
done
()
})
/*
* @tc.number : Emitter
LowTest
* @tc.name : verify
low : Check subscribe same low common ordered event
* @tc.desc :
Check the subscriber can receive event "EmitterLowTest" type of the interface (by Promise)
* @tc.number : Emitter
Test_0400
* @tc.name : verify
on : emit(event: InnerEvent, data?: EventData): void
* @tc.desc :
emitter.EventPriority.IMMEDIATE
*/
it
(
'
EmitterLowTest
'
,
0
,
async
function
(
done
){
console
.
info
(
"
===========EmitterLowTest====================>
"
);
emitter
.
once
(
InnerEventLow
,
callback01
);
emitter
.
emit
(
InnerEventLow
,
eventData
);
done
();
it
(
'
EmitterTest_0400
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
EmitterTest_0400 START
'
)
innerEvent
.
eventId
=
4
innerEvent
.
priority
=
emitter
.
EventPriority
.
IMMEDIATE
eventData
.
data
.
id
=
4
eventData
.
data
.
content
=
'
message_4
'
emitter
.
once
(
innerEvent
,
EmitterCallback
)
emitter
.
emit
(
innerEvent
,
eventData
)
console
.
info
(
TAG
+
'
EmitterTest_0400 END
'
)
done
()
})
/*
* @tc.number : EmitterOffTest
* @tc.name : verify off : Check subscribe same off common ordered event
* @tc.desc : Check the subscriber can receive event "EmitterOffTest" type of the interface (by Promise)
*/
it
(
'
EmitterOffTest
'
,
0
,
async
function
(
done
){
console
.
info
(
"
===========EmitterOffTest111====================>
"
);
emitter
.
once
(
InnerEventLow
,
callback01
);
emitter
.
emit
(
InnerEventImmediate
,
eventData
);
emitter
.
off
(
1
);
done
();
})
/*
* @tc.number : Emitter
EmitTest_01
00
* @tc.name : verify o
ff : Check subscribe same off common ordered event
* @tc.desc :
Check the subscriber can receive event "EmitterOffTest" type of the interface (by Promise)
* @tc.number : Emitter
Test_05
00
* @tc.name : verify o
n : off(eventId: number): void
* @tc.desc :
emitter.EventPriority.IMMEDIATE
*/
it
(
'
EmitterEmitTest_0100
'
,
0
,
async
function
(
done
){
console
.
info
(
"
===========EmitterEmitTest_0100====================>
"
);
var
eventData2
=
{
data
:
{
"
content
"
:
"
c
"
,
"
id
"
:
2
,
}};
var
innerEventHigh
=
{
eventId
:
3
,
priority
:
emitter
.
EventPriority
.
HIGH
};
emitter
.
once
(
InnerEventLow
,
callback01
);
emitter
.
emit
(
innerEventHigh
,
eventData2
);
expect
(
emitter
.
EventPriority
.
HIGH
).
assertEqual
(
1
)
done
();
it
(
'
EmitterTest_0500
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
EmitterTest_0500 START
'
)
innerEvent
.
eventId
=
5
innerEvent
.
priority
=
emitter
.
EventPriority
.
IMMEDIATE
eventData
.
data
.
id
=
5
eventData
.
data
.
content
=
'
message_5
'
emitter
.
once
(
innerEvent
,
EmitterCallback
)
emitter
.
emit
(
innerEvent
,
eventData
)
emitter
.
off
(
5
)
console
.
info
(
TAG
+
'
EmitterTest_0500 END
'
)
done
()
})
/*
* @tc.number : EmitterEmitTest_0200
* @tc.name : verify off : emitter.EventPriority.IDLE
* @tc.desc : emitter.EventPriority.IDLE
*/
it
(
'
EmitterEmitTest_0200
'
,
0
,
async
function
(
done
){
console
.
info
(
"
===========EmitterEmitTest_0100====================>
"
);
var
eventData3
=
{
data
:
{
"
content
"
:
"
d
"
,
"
id
"
:
3
,
}};
var
innerEventIdle
=
{
eventId
:
4
,
priority
:
emitter
.
EventPriority
.
IDLE
};
emitter
.
once
(
innerEventIdle
,
callback01
);
emitter
.
emit
(
InnerEventImmediate
,
eventData3
);
expect
(
emitter
.
EventPriority
.
IDLE
).
assertEqual
(
3
)
done
();
})
})
console
.
info
(
TAG
+
'
EmitterTest END
'
)
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录