Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
846da039
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看板
未验证
提交
846da039
编写于
7月 30, 2022
作者:
O
openharmony_ci
提交者:
Gitee
7月 30, 2022
浏览文件
操作
浏览文件
下载
差异文件
!4709 XTS元能力用例优化
Merge pull request !4709 from chengxingzhen/master
上级
2d89fafd
abbb616d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
112 addition
and
107 deletion
+112
-107
ability/ability_runtime/newwant/actsnewwantarelyhap/entry/src/main/ets/MainAbility/MainAbility.ts
...antarelyhap/entry/src/main/ets/MainAbility/MainAbility.ts
+0
-5
ability/ability_runtime/newwant/actsnewwantbrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts
...antbrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts
+7
-0
ability/ability_runtime/newwant/actsnewwantrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts
...wantrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts
+25
-1
ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/ets/test/Ability.test.ets
.../actsnewwanttest/entry/src/main/ets/test/Ability.test.ets
+80
-101
未找到文件。
ability/ability_runtime/newwant/actsnewwantarelyhap/entry/src/main/ets/MainAbility/MainAbility.ts
浏览文件 @
846da039
...
...
@@ -89,11 +89,6 @@ export default class MainAbility extends Ability {
console
.
log
(
"
ACTS_NewWant Publish CallBack onNewWantMain_To_Test_CommonEvent
"
)
});
switch
(
want
.
action
)
{
case
'
restartHapB
'
:
commonEvent
.
publish
(
"
onNewWantMain1_To_Test_CommonEvent
"
,
publishData
,
()
=>
{
console
.
log
(
"
ACTS_NewWant Publish CallBack onNewWantMain1_To_Test_CommonEvent
"
)
});
break
;
case
'
restartHapC
'
:
commonEvent
.
publish
(
"
onNewWantMain2_To_Test_CommonEvent
"
,
publishData
,
()
=>
{
console
.
log
(
"
ACTS_NewWant Publish CallBack onNewWantMain2_To_Test_CommonEvent
"
)
...
...
ability/ability_runtime/newwant/actsnewwantbrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts
浏览文件 @
846da039
...
...
@@ -88,5 +88,12 @@ export default class MainAbility extends Ability {
commonEvent
.
publish
(
"
onNewWantMain_To_Test_CommonEvent
"
,
publishData
,
()
=>
{
console
.
log
(
"
ACTS_NewWant Publish CallBack onNewWantMain_To_Test_CommonEvent
"
)
});
switch
(
want
.
action
)
{
case
'
restartHapB
'
:
commonEvent
.
publish
(
"
onNewWantMain1_To_Test_CommonEvent
"
,
publishData
,
()
=>
{
console
.
log
(
"
ACTS_NewWant Publish CallBack onNewWantMain1_To_Test_CommonEvent
"
)
});
break
;
}
}
};
ability/ability_runtime/newwant/actsnewwantrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts
浏览文件 @
846da039
...
...
@@ -80,6 +80,16 @@ export default class MainAbility extends Ability {
+
JSON
.
stringify
(
error
)
+
"
,
"
+
JSON
.
stringify
(
data
))
})
}
if
(
globalThis
.
abilityWant
.
action
==
'
startMainAbility0800
'
)
{
globalThis
.
abilityContext
.
startAbility
({
bundleName
:
"
com.example.newwanthap
"
,
abilityName
:
"
com.example.newwanthapa.SecondAbility
"
,
action
:
"
startSecondAbility0800
"
},
(
error
,
data
)
=>
{
console
.
log
(
'
ACTS_NewWant MainAbility onForeground - startAbility startServiceAbility:
'
+
JSON
.
stringify
(
error
)
+
"
,
"
+
JSON
.
stringify
(
data
))
})
}
commonEvent
.
publish
(
"
onForegroundMain_To_Test_CommonEvent
"
,
()
=>
{
console
.
log
(
"
ACTS_NewWant MainAbility Publish CallBack onForegroundMain_To_Test_CommonEvent
"
)
});
...
...
@@ -102,9 +112,23 @@ export default class MainAbility extends Ability {
console
.
log
(
"
ACTS_NewWant MainAbility onNewWant type :
"
+
want
.
type
)
console
.
log
(
"
ACTS_NewWant MainAbility onNewWant flags :
"
+
want
.
flags
)
console
.
log
(
"
ACTS_NewWant MainAbility onNewWant action :
"
+
want
.
action
)
var
publishData
=
{
data
:
want
.
action
}
commonEvent
.
publish
(
"
onNewWantMain_To_Test_CommonEvent
"
,
()
=>
{
console
.
log
(
"
ACTS_NewWant MainAbility Publish CallBack onNewWantMain_To_Test_CommonEvent
"
)
});
switch
(
want
.
action
)
{
case
'
restartHapB
'
:
commonEvent
.
publish
(
"
onNewWantSecond1_To_Test_CommonEvent
"
,
publishData
,()
=>
{
console
.
log
(
"
ACTS_NewWant SecondAbility Publish CallBack onNewWantSecond1_To_Test_CommonEvent
"
)
});
break
;
case
'
restartSecondAbility0700
'
:
commonEvent
.
publish
(
"
onNewWantSecond2_To_Test_CommonEvent
"
,
publishData
,()
=>
{
console
.
log
(
"
ACTS_NewWant SecondAbility Publish CallBack onNewWantSecond2_To_Test_CommonEvent
"
)
});
break
;
}
}
};
ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/ets/test/Ability.test.ets
浏览文件 @
846da039
...
...
@@ -16,7 +16,7 @@
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"
import commonEvent from '@ohos.commonEvent'
var
subscriberInfo = {
let
subscriberInfo = {
events: ['onCreateMain_To_Test_CommonEvent',
'onWindowStageCreateMain_To_Test_CommonEvent',
'onForegroundMain_To_Test_CommonEvent',
...
...
@@ -33,6 +33,8 @@ var subscriberInfo = {
],
};
let flagNewWant = false;
export default function abilityTest(abilityContext) {
describe('ActsNewWantTest', function () {
...
...
@@ -43,13 +45,13 @@ export default function abilityTest(abilityContext) {
*/
it('ACTS_NewWant_Test_0100', 0, async function (done) {
console.log("ACTS_NewWant_Test_0100 --- start")
var
Subscriber;
var
flagOnCreate = 0;
var
flagOnWindowStageCreate = 0;
var
flagOnForeground = 0;
var
flagOnNewWant = 0;
let
Subscriber;
let
flagOnCreate = 0;
let
flagOnWindowStageCreate = 0;
let
flagOnForeground = 0;
let
flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
await
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0100====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
...
...
@@ -94,17 +96,14 @@ export default function abilityTest(abilityContext) {
+ flagOnNewWant)
if (flagOnCreate == 1 && flagOnWindowStageCreate == 1
&& flagOnForeground == 1 && flagOnNewWant == 0) {
expect(flagOnCreate).assertEqual(1);
expect(flagOnWindowStageCreate).assertEqual(1);
expect(flagOnForeground).assertEqual(1);
expect(flagOnNewWant).assertEqual(0);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
flagNewWant = true;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
done()
}
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0100====>UnSubscribe CallBack====>");
expect(flagNewWant).assertTrue();
done();
}
})
...
...
@@ -116,13 +115,13 @@ export default function abilityTest(abilityContext) {
*/
it('ACTS_NewWant_Test_0200', 0, async function (done) {
console.log("ACTS_NewWant_Test_0200 --- start")
var
Subscriber;
var
flagOnCreate = 0;
var
flagOnWindowStageCreate = 0;
var
flagOnForeground = 0;
var
flagOnNewWant = 0;
let
Subscriber;
let
flagOnCreate = 0;
let
flagOnWindowStageCreate = 0;
let
flagOnForeground = 0;
let
flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
await
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0200====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
...
...
@@ -166,17 +165,14 @@ export default function abilityTest(abilityContext) {
+ flagOnNewWant)
if (flagOnCreate == 1 && flagOnWindowStageCreate == 1
&& flagOnForeground == 1 && flagOnNewWant == 0) {
expect(flagOnCreate).assertEqual(1);
expect(flagOnWindowStageCreate).assertEqual(1);
expect(flagOnForeground).assertEqual(1);
expect(flagOnNewWant).assertEqual(0);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
flagNewWant = true;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
done()
}
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0200====>UnSubscribe CallBack====>");
expect(flagNewWant).assertTrue();
done();
}
})
...
...
@@ -188,13 +184,13 @@ export default function abilityTest(abilityContext) {
*/
it('ACTS_NewWant_Test_0300', 0, async function (done) {
console.log("ACTS_NewWant_Test_0300 --- start")
var
Subscriber;
var
flagOnCreate = 0;
var
flagOnWindowStageCreate = 0;
var
flagOnForeground = 0;
var
flagOnNewWant = 0;
let
Subscriber;
let
flagOnCreate = 0;
let
flagOnWindowStageCreate = 0;
let
flagOnForeground = 0;
let
flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
await
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0300====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
...
...
@@ -240,15 +236,13 @@ export default function abilityTest(abilityContext) {
if (flagOnCreate == 2 && flagOnWindowStageCreate == 2
&& flagOnForeground == 2 && flagOnNewWant == 0) {
expect(flagOnCreate).assertEqual(2);
expect(flagOnWindowStageCreate).assertEqual(2);
expect(flagOnForeground).assertEqual(2);
expect(flagOnNewWant).assertEqual(0);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
flagNewWant = true;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0300====>UnSubscribe CallBack====>");
expect(flagNewWant).assertTrue();
done();
}
})
...
...
@@ -260,13 +254,13 @@ export default function abilityTest(abilityContext) {
*/
it('ACTS_NewWant_Test_0400', 0, async function (done) {
console.log("ACTS_NewWant_Test_0400 --- start")
var
Subscriber;
var
flagOnCreate = 0;
var
flagOnWindowStageCreate = 0;
var
flagOnForeground = 0;
var
flagOnNewWant = 0;
let
Subscriber;
let
flagOnCreate = 0;
let
flagOnWindowStageCreate = 0;
let
flagOnForeground = 0;
let
flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
await
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0400====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
...
...
@@ -311,19 +305,16 @@ export default function abilityTest(abilityContext) {
console.debug("ACTS_NewWant_Test_0400====>flagOnNewWant:====>"
+ flagOnNewWant)
if (flagOnCreate ==
1 && flagOnWindowStageCreate == 1
if (flagOnCreate ==
0 && flagOnWindowStageCreate == 0
&& flagOnForeground == 2 && flagOnNewWant == 1) {
expect(flagOnCreate).assertEqual(1);
expect(flagOnWindowStageCreate).assertEqual(1);
expect(flagOnForeground).assertEqual(2);
expect(flagOnNewWant).assertEqual(1);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
flagNewWant = true;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
done()
}
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0400====>UnSubscribe CallBack====>");
expect(flagNewWant).assertTrue();
done();
}
})
...
...
@@ -335,13 +326,13 @@ export default function abilityTest(abilityContext) {
*/
it('ACTS_NewWant_Test_0500', 0, async function (done) {
console.log("ACTS_NewWant_Test_0500 --- start")
var
Subscriber;
var
flagOnCreate = 0;
var
flagOnWindowStageCreate = 0;
var
flagOnForeground = 0;
var
flagOnNewWant = 0;
let
Subscriber;
let
flagOnCreate = 0;
let
flagOnWindowStageCreate = 0;
let
flagOnForeground = 0;
let
flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
await
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0500====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
...
...
@@ -388,17 +379,14 @@ export default function abilityTest(abilityContext) {
if (flagOnCreate == 1 && flagOnWindowStageCreate == 1
&& flagOnForeground == 2 && flagOnNewWant == 1) {
expect(flagOnCreate).assertEqual(1);
expect(flagOnWindowStageCreate).assertEqual(1);
expect(flagOnForeground).assertEqual(2);
expect(flagOnNewWant).assertEqual(1);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
flagNewWant = true;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
done()
}
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0500====>UnSubscribe CallBack====>");
expect(flagNewWant).assertTrue();
done();
}
})
...
...
@@ -410,13 +398,13 @@ export default function abilityTest(abilityContext) {
*/
it('ACTS_NewWant_Test_0600', 0, async function (done) {
console.log("ACTS_NewWant_Test_0600 --- start")
var
Subscriber;
var
flagOnCreate = 0;
var
flagOnWindowStageCreate = 0;
var
flagOnForeground = 0;
var
flagOnNewWant = 0;
let
Subscriber;
let
flagOnCreate = 0;
let
flagOnWindowStageCreate = 0;
let
flagOnForeground = 0;
let
flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
await
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0600====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
...
...
@@ -463,17 +451,14 @@ export default function abilityTest(abilityContext) {
if (flagOnCreate == 1 && flagOnWindowStageCreate == 1
&& flagOnForeground == 2 && flagOnNewWant == 1) {
expect(flagOnCreate).assertEqual(1);
expect(flagOnWindowStageCreate).assertEqual(1);
expect(flagOnForeground).assertEqual(2);
expect(flagOnNewWant).assertEqual(1);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
flagNewWant = true;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
done()
}
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0600====>UnSubscribe CallBack====>");
expect(flagNewWant).assertTrue();
done();
}
})
...
...
@@ -485,13 +470,13 @@ export default function abilityTest(abilityContext) {
*/
it('ACTS_NewWant_Test_0700', 0, async function (done) {
console.log("ACTS_NewWant_Test_0700 --- start")
var
Subscriber;
var
flagOnCreate = 0;
var
flagOnWindowStageCreate = 0;
var
flagOnForeground = 0;
var
flagOnNewWant = 0;
let
Subscriber;
let
flagOnCreate = 0;
let
flagOnWindowStageCreate = 0;
let
flagOnForeground = 0;
let
flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
await
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0700====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
...
...
@@ -536,18 +521,15 @@ export default function abilityTest(abilityContext) {
console.debug("ACTS_NewWant_Test_0700====>flagOnNewWant:====>"
+ flagOnNewWant)
if (flagOnCreate ==
1 && flagOnWindowStageCreate == 1
if (flagOnCreate ==
0 && flagOnWindowStageCreate == 0
&& flagOnForeground == 2 && flagOnNewWant == 1) {
expect(flagOnCreate).assertEqual(1);
expect(flagOnWindowStageCreate).assertEqual(1);
expect(flagOnForeground).assertEqual(2);
expect(flagOnNewWant).assertEqual(1);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
flagNewWant = true;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
done()
}
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0700====>UnSubscribe CallBack====>");
expect(flagNewWant).assertTrue();
done();
}
})
...
...
@@ -559,13 +541,13 @@ export default function abilityTest(abilityContext) {
*/
it('ACTS_NewWant_Test_0800', 0, async function (done) {
console.log("ACTS_NewWant_Test_0800 --- start")
var
Subscriber;
var
flagOnCreate = 0;
var
flagOnWindowStageCreate = 0;
var
flagOnForeground = 0;
var
flagOnNewWant = 0;
let
Subscriber;
let
flagOnCreate = 0;
let
flagOnWindowStageCreate = 0;
let
flagOnForeground = 0;
let
flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
await
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0800====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
...
...
@@ -573,8 +555,8 @@ export default function abilityTest(abilityContext) {
abilityContext.startAbility({
bundleName: "com.example.newwanthap",
abilityName: "com.example.newwanthapa.
Second
Ability",
action: "start
Second
Ability0800"
abilityName: "com.example.newwanthapa.
Main
Ability",
action: "start
Main
Ability0800"
}, (error, data) => {
console.log('ACTS_NewWant_Test_0800 - startAbility start SecondAbility: '
+ JSON.stringify(error) + ", " + JSON.stringify(data))
...
...
@@ -611,18 +593,15 @@ export default function abilityTest(abilityContext) {
console.debug("ACTS_NewWant_Test_0800====>flagOnNewWant:====>"
+ flagOnNewWant)
if (flagOnCreate ==
1 && flagOnWindowStageCreate == 1
if (flagOnCreate ==
0 && flagOnWindowStageCreate == 0
&& flagOnForeground == 2 && flagOnNewWant == 1) {
expect(flagOnCreate).assertEqual(1);
expect(flagOnWindowStageCreate).assertEqual(1);
expect(flagOnForeground).assertEqual(2);
expect(flagOnNewWant).assertEqual(1);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
flagNewWant = true;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
done()
}
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0800====>UnSubscribe CallBack====>");
expect(flagNewWant).assertTrue();
done();
}
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录