Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
bff2fdbd
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bff2fdbd
编写于
7月 23, 2022
作者:
Z
zhijianwen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
10
Signed-off-by:
N
zhijianwen
<
zhijianwen@huawei.com
>
上级
3c0256fc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
247 addition
and
142 deletion
+247
-142
notification/ans_standard/publish_test/wantagent/wantagent1promise/src/main/js/test/WantAgent.test.js
...gent/wantagent1promise/src/main/js/test/WantAgent.test.js
+121
-62
notification/ces_standard/subscribeandpublish/actssubscriberunordertest/src/main/js/test/ActsSubscriber_test_unorder.js
...ordertest/src/main/js/test/ActsSubscriber_test_unorder.js
+2
-0
notification/ces_standard/subscribeandpublish/emittertest/src/main/js/test/EmitterTest.js
...ibeandpublish/emittertest/src/main/js/test/EmitterTest.js
+124
-80
未找到文件。
notification/ans_standard/publish_test/wantagent/wantagent1promise/src/main/js/test/WantAgent.test.js
浏览文件 @
bff2fdbd
...
...
@@ -19,70 +19,129 @@ var time = 1000
var
WantAgent
;
export
default
function
ActsAnsWantAgentOneProTest
()
{
describe
(
'
ActsAnsWantAgentOneProTest
'
,
function
()
{
console
.
info
(
'
----ActsWantAgentTest----
'
);
console
.
info
(
"
----ActsWantAgentTest----
"
);
/*
* @tc.number: ACTS_SetWant_0200
* @tc.name: getWantAgent(OperationType.START_ABILITY)
* @tc.desc: verify the function of getWantAgent(OperationType.START_ABILITY)
*/
it
(
'
ACTS_SetWant_0200
'
,
0
,
async
function
(
done
)
{
var
agentInfo
=
{
wants
:
[
{
bundleName
:
"
com.example.WantAgentTest1
"
,
abilityName
:
"
com.example.WantAgentTest1.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey6
:
true
,
}
},
],
operationType
:
wantAgent
.
OperationType
.
START_ABILITY
,
requestCode
:
0
,
wantAgentFlags
:[
wantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
/*
* @tc.number: ACTS_SetWant_0200
* @tc.name: getWantAgent(OperationType.START_ABILITY)
* @tc.desc: verify the function of getWantAgent(OperationType.START_ABILITY)
*/
it
(
"
ACTS_SetWant_0200
"
,
0
,
async
function
(
done
)
{
var
agentInfo
=
{
wants
:
[
{
bundleName
:
"
com.example.WantAgentTest1
"
,
abilityName
:
"
com.example.WantAgentTest1.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey6
:
true
,
},
},
],
operationType
:
wantAgent
.
OperationType
.
START_ABILITY
,
requestCode
:
0
,
wantAgentFlags
:
[
wantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
],
};
console
.
info
(
"
----getWantAgent before----
"
);
wantAgent
.
getWantAgent
(
agentInfo
).
then
((
data
)
=>
{
WantAgent
=
data
;
console
.
info
(
"
----getWantAgent success!----
"
);
console
.
info
(
JSON
.
stringify
(
data
));
expect
(
typeof
data
).
assertEqual
(
"
object
"
);
var
triggerInfo
=
{
code
:
0
,
};
wantAgent
.
trigger
(
WantAgent
,
triggerInfo
,
(
err
,
data
)
=>
{
if
(
err
.
code
==
0
)
{
console
.
info
(
"
----trigger success!----
"
);
console
.
info
(
"
== trigger data
"
+
JSON
.
stringify
(
data
));
}
else
{
console
.
info
(
"
----trigger failed!----
"
);
console
.
info
(
"
== trigger data
"
+
JSON
.
stringify
(
data
));
}
console
.
info
(
'
----getWantAgent before----
'
);
wantAgent
.
getWantAgent
(
agentInfo
).
then
(
(
data
)
=>
{
WantAgent
=
data
;
console
.
info
(
'
----getWantAgent success!----
'
);
console
.
info
(
JSON
.
stringify
(
data
));
expect
(
typeof
(
data
)).
assertEqual
(
"
object
"
);
var
triggerInfo
=
{
code
:
0
}
wantAgent
.
trigger
(
WantAgent
,
triggerInfo
,
(
err
,
data
)
=>
{
if
(
err
.
code
==
0
)
{
console
.
info
(
'
----trigger success!----
'
);
console
.
info
(
'
== trigger data
'
+
JSON
.
stringify
(
data
)
);
}
else
{
console
.
info
(
'
----trigger failed!----
'
);
console
.
info
(
'
== trigger data
'
+
JSON
.
stringify
(
data
)
);
}
done
();
}
);
done
();
}
);
setTimeout
(
function
(){
console
.
debug
(
"
====>time out ACTS_SetWant_0200====>
"
);
},
time
);
console
.
info
(
'
----getWantAgent after----
'
);
})
done
();
});
done
();
});
setTimeout
(
function
()
{
console
.
debug
(
"
====>time out ACTS_SetWant_0200====>
"
);
},
time
);
console
.
info
(
"
----getWantAgent after----
"
);
});
/*
* @tc.number: ACTS_SetWant_0300
* @tc.name: getWantAgent(OperationType.START_ABILITY)
* @tc.desc: verify the function of getWantAgent(OperationType.START_ABILITY)
*/
it
(
"
ACTS_SetWant_0300
"
,
0
,
async
function
(
done
)
{
var
agentInfo
=
{
wants
:
[
{
bundleName
:
"
com.example.WantAgentTest1
"
,
abilityName
:
"
com.example.WantAgentTest1.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey6
:
true
,
},
},
],
operationType
:
wantAgent
.
OperationType
.
START_ABILITY
,
requestCode
:
0
,
wantAgentFlags
:
[
wantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
],
extraInfo
:
{
key1
:
'
test_extraInfo
'
}
};
console
.
info
(
"
----getWantAgent before----
"
);
wantAgent
.
getWantAgent
(
agentInfo
).
then
((
data
)
=>
{
WantAgent
=
data
;
console
.
info
(
"
----getWantAgent success!----
"
);
console
.
info
(
JSON
.
stringify
(
data
));
expect
(
typeof
data
).
assertEqual
(
"
object
"
);
var
triggerInfo
=
{
code
:
0
,
want
:
WantAgent
,
permission
:
''
,
extraInfo
:
{
key1
:
'
test_triggerInfo
'
}
};
wantAgent
.
trigger
(
WantAgent
,
triggerInfo
,
(
err
,
data
)
=>
{
if
(
err
.
code
==
0
)
{
console
.
info
(
"
----trigger success!----
"
);
console
.
info
(
"
== trigger data
"
+
JSON
.
stringify
(
data
));
}
else
{
console
.
info
(
"
----trigger failed!----
"
);
console
.
info
(
"
== trigger data
"
+
JSON
.
stringify
(
data
));
}
done
();
});
done
();
});
setTimeout
(
function
()
{
console
.
debug
(
"
====>time out ACTS_SetWant_0200====>
"
);
},
time
);
console
.
info
(
"
----getWantAgent after----
"
);
});
})
}
notification/ces_standard/subscribeandpublish/actssubscriberunordertest/src/main/js/test/ActsSubscriber_test_unorder.js
浏览文件 @
bff2fdbd
...
...
@@ -334,6 +334,7 @@ describe("ActsSubscriberTestUnorder", async function (done) {
console
.
info
(
"
===============ActsSubscriberTestUnorder_0700==========================>
"
);
let
commonEventSubscribeInfo
=
{
events
:
[
"
publish_event0700
"
],
userId
:
100
};
let
commonEventPublishData
=
{
...
...
@@ -357,6 +358,7 @@ describe("ActsSubscriberTestUnorder", async function (done) {
Subscriber
.
createSubscriber
(
commonEventSubscribeInfo
).
then
((
data
)
=>
{
console
.
info
(
"
===============ActsSubscriberTestUnorder_0700=========createSubscriber promise
"
);
expect
(
commonEventSubscribeInfo
.
userId
).
assertEqual
(
100
)
commonEventSubscriber007
=
data
;
data
.
getSubscribeInfo
().
then
(()
=>
{
console
.
info
(
"
===============ActsSubscriberTestUnorder_0700=========getSubscribeInfo promise
"
);
...
...
notification/ces_standard/subscribeandpublish/emittertest/src/main/js/test/EmitterTest.js
浏览文件 @
bff2fdbd
...
...
@@ -16,96 +16,140 @@ import emitter from '@ohos.events.emitter'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
EmitterTest
()
{
describe
(
'
EmitterTest
'
,
function
()
{
console
.
info
(
"
===========EmitterTest start====================>
"
);
describe
(
'
EmitterTest
'
,
function
()
{
console
.
info
(
"
===========EmitterTest start====================>
"
);
var
eventData
=
{
data
:
{
"
id
"
:
1
,
"
content
"
:
"
message
"
,
var
eventData
=
{
data
:
{
"
id
"
:
1
,
"
content
"
:
"
message
"
,
}
}
}
var
InnerEventImmediate
=
{
eventId
:
1
,
priority
:
emitter
.
EventPriority
.
IMMEDIATE
}
var
InnerEventImmediate
=
{
eventId
:
1
,
priority
:
emitter
.
EventPriority
.
IMMEDIATE
}
var
InnerEventLow
=
{
eventId
:
2
,
priority
:
emitter
.
EventPriority
.
LOW
}
var
InnerEventLow
=
{
eventId
:
2
,
priority
:
emitter
.
EventPriority
.
LOW
}
function
callback
(
data
){
console
.
info
(
'
callback success
'
);
expect
(
data
.
eventId
).
assertEqual
(
"
message
"
);
}
function
callback
(
data
){
console
.
info
(
'
callback success
'
);
expect
(
data
.
eventId
).
assertEqual
(
"
message
"
);
}
function
callback01
(
data
){
console
.
info
(
'
callback success
'
);
expect
(
data
.
data
.
id
).
assertEqual
(
1
);
expect
(
data
.
data
.
content
).
assertEqual
(
"
message
"
);
}
function
callback01
(
data
){
console
.
info
(
'
callback success
'
);
expect
(
data
.
data
.
id
).
assertEqual
(
1
);
expect
(
data
.
data
.
content
).
assertEqual
(
"
message
"
);
}
/*
* @tc.number : EmitterOnTest
* @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)
*/
it
(
'
EmitterOnTest
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
===========EmitterOnTest====================>
"
);
emitter
.
on
(
InnerEventImmediate
,
callback
);
done
();
})
/*
* @tc.number : EmitterOnTest
* @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)
*/
it
(
'
EmitterOnTest
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
===========EmitterOnTest====================>
"
);
emitter
.
on
(
InnerEventImmediate
,
callback
);
done
();
})
/*
* @tc.number : EmitterOnceTest
* @tc.name : verify once : Check subscribe same once common ordered event
* @tc.desc : Check the subscriber can receive event "EmitterOnceTest" type of the interface (by Promise)
*/
it
(
'
EmitterOnceTest
'
,
0
,
async
function
(
done
){
console
.
info
(
"
===========EmitterOnceTest====================>
"
);
emitter
.
once
(
InnerEventImmediate
,
callback
);
done
();
})
/*
* @tc.number : EmitterOnceTest
* @tc.name : verify once : Check subscribe same once common ordered event
* @tc.desc : Check the subscriber can receive event "EmitterOnceTest" type of the interface (by Promise)
*/
it
(
'
EmitterOnceTest
'
,
0
,
async
function
(
done
){
console
.
info
(
"
===========EmitterOnceTest====================>
"
);
emitter
.
once
(
InnerEventImmediate
,
callback
);
done
();
})
/*
* @tc.number : EmitterEmitTest
* @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)
*/
it
(
'
EmitterEmitTest
'
,
0
,
async
function
(
done
){
console
.
info
(
"
===========EmitterEmitTest====================>
"
);
emitter
.
once
(
InnerEventImmediate
,
callback01
);
emitter
.
emit
(
InnerEventImmediate
,
eventData
);
done
();
})
/*
* @tc.number : EmitterEmitTest
* @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)
*/
it
(
'
EmitterEmitTest
'
,
0
,
async
function
(
done
){
console
.
info
(
"
===========EmitterEmitTest====================>
"
);
emitter
.
once
(
InnerEventImmediate
,
callback01
);
emitter
.
emit
(
InnerEventImmediate
,
eventData
);
done
();
})
/*
* @tc.number : EmitterLowTest
* @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)
*/
it
(
'
EmitterLowTest
'
,
0
,
async
function
(
done
){
console
.
info
(
"
===========EmitterLowTest====================>
"
);
emitter
.
once
(
InnerEventLow
,
callback01
);
emitter
.
emit
(
InnerEventLow
,
eventData
);
done
();
})
/*
* @tc.number : EmitterLowTest
* @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)
*/
it
(
'
EmitterLowTest
'
,
0
,
async
function
(
done
){
console
.
info
(
"
===========EmitterLowTest====================>
"
);
emitter
.
once
(
InnerEventLow
,
callback01
);
emitter
.
emit
(
InnerEventLow
,
eventData
);
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 : 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 : EmitterEmitTest_0100
* @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
(
'
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
();
})
/*
* @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
();
})
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录