Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
cb78cb01
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,发现更多精彩内容 >>
提交
cb78cb01
编写于
7月 17, 2023
作者:
X
xinking129
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify code
Signed-off-by:
N
xinking129
<
xinxin13@huawei.com
>
上级
2afa5db6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
112 addition
and
105 deletion
+112
-105
ability/ability_runtime/getrunningprocessinformation/GetRunningProcessInformationTest/entry/src/main/ets/test/Ability.test.ets
...sInformationTest/entry/src/main/ets/test/Ability.test.ets
+112
-105
未找到文件。
ability/ability_runtime/getrunningprocessinformation/GetRunningProcessInformationTest/entry/src/main/ets/test/Ability.test.ets
浏览文件 @
cb78cb01
...
...
@@ -24,11 +24,7 @@ let ACTS_ProcessState = {
export default function abilityTest() {
describe('GetRunningProcessInformationTest', function () {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(function () {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
})
beforeEach(async function () {
var abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
...
...
@@ -38,6 +34,7 @@ export default function abilityTest() {
});
await abilityDelegator.executeShellCommand("hilog -G 20M", async (err, data) => {})
})
afterEach(async function () {
var abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
...
...
@@ -47,58 +44,59 @@ export default function abilityTest() {
let cmd4 = 'aa force-stop com.example.getrunningprocessinformationonereply'
let cmd5 = 'aa force-stop com.example.getrunningprocessinformationtworeply'
let cmd3 = 'hilog -r'
await abilityDelegator.executeShellCommand(cmd1
, (err : any, data : any
) => {
await abilityDelegator.executeShellCommand(cmd1
).then((
) => {
console.info("executeShellCommand1 callback");
});
await abilityDelegator.executeShellCommand(cmd2
, (err : any, data : any
) => {
await abilityDelegator.executeShellCommand(cmd2
).then((
) => {
console.info("executeShellCommand2 callback");
});
await abilityDelegator.executeShellCommand(cmd3
, (err : any, data : any
) => {
await abilityDelegator.executeShellCommand(cmd3
).then((
) => {
console.info("executeShellCommand3 callback");
});
await abilityDelegator.executeShellCommand(cmd4
, (err : any, data : any
) => {
await abilityDelegator.executeShellCommand(cmd4
).then((
) => {
console.info("executeShellCommand3 callback");
});
await abilityDelegator.executeShellCommand(cmd5
, (err : any, data : any
) => {
await abilityDelegator.executeShellCommand(cmd5
).then((
) => {
console.info("executeShellCommand3 callback");
});
await abilityDelegator.executeShellCommand(cmd6
, (err : any, data : any
) => {
await abilityDelegator.executeShellCommand(cmd6
).then((
) => {
console.info("executeShellCommand3 callback");
});
})
afterAll(function () {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
})
/*
* @tc.number: Acts_ApplicationStateChange_0100
* @tc.name: Register and deregister to monitor the foreground and background changes of this application.
* @tc.desc: In the same application, the on interface is called once, but the off interface is not called, and the
* foreground and background changes can be monitored.
*/
it('Acts_ApplicationStateChange_0100',0, function (done) {
let want = {
"deviceId": "",
"bundleName": "com.example.applicationstatechangeonereply",
"abilityName": "EntryAbility",
"action": "Normal"
}
}
;
let wantAuxiliary = {
"deviceId": "",
"bundleName": "com.example.applicationstatechangetworeply",
"abilityName": "EntryAbility",
"action": "Normal"
}
let subscriber
}
;
let subscriber
;
function unSubscribeCallback() {
console.debug("====>Acts_ApplicationStateChange_0100 unSubscribeCallback");
done();
}
function subscribeCallBack(err, data) {
console.debug("====>Acts_ApplicationStateChange_0100 data: " + JSON.stringify(data));
console.debug("====>Acts_ApplicationStateChange_0100 err: " + JSON.stringify(err));
if(data.event == "processState") {
try{
expect(data.parameters.commonStateArr[0]).assertEqual(1)
expect(data.parameters.commonStateArr[1]).assertEqual(1)
expect(data.parameters.commonStateArr[2]).assertEqual(-1)
expect(data.parameters.commonStateArr[3]).assertEqual(-1)
expect(data.parameters.commonStateArr[0]).assertEqual(1)
;
expect(data.parameters.commonStateArr[1]).assertEqual(1)
;
expect(data.parameters.commonStateArr[2]).assertEqual(-1)
;
expect(data.parameters.commonStateArr[3]).assertEqual(-1)
;
}
catch(error) {
console.log("An error is generated")
...
...
@@ -113,28 +111,27 @@ export default function abilityTest() {
commonEvent.subscribe(subscriber, subscribeCallBack);
globalThis.abilityContext.startAbility(want, (error) => {
console.log("ability error.code = " + error.code)
expect().assertFail();
done();
console.log("ability error.code = " + error.code);
expect(error.code).assertEqual(0);
})
setTimeout(() => {
globalThis.abilityContext.startAbility(wantAuxiliary, (error) => {
console.log("auxiliary ability error.code = " + error.code)
expect().assertFail();
done();
console.log("auxiliary ability error.code = " + error.code);
expect(error.code).assertEqual(0);
})
},3000)
})
},700)
},1500)
setTimeout(()=>{
done();
}, 9500);
});
},700);
})
/*
* @tc.number: Acts_ApplicationStateChange_0200
* @tc.name: Register and deregister to monitor the foreground and background changes of this application.
* @tc.desc: In the same application, the on interface is called once, and the off interface is called, and the
* foreground and background changes can be monitored.
*/
it('Acts_ApplicationStateChange_0200',0, async function (done) {
let want = {
"deviceId": "",
...
...
@@ -151,6 +148,7 @@ export default function abilityTest() {
let subscriber
function unSubscribeCallback() {
console.debug("====>Acts_ApplicationStateChange_0200 unSubscribeCallback");
done();
}
function subscribeCallBack(err, data) {
console.debug("====>Acts_ApplicationStateChange_0200 data: " + JSON.stringify(data));
...
...
@@ -178,26 +176,25 @@ export default function abilityTest() {
globalThis.abilityContext.startAbility(want, (error) => {
console.log("ability error.code = " + error.code)
expect().assertFail();
done();
expect(error.code).assertEqual(0);
})
setTimeout(() => {
globalThis.abilityContext.startAbility(wantAuxiliary, (error) => {
console.log("auxiliary ability error.code = " + error.code)
expect().assertFail();
done();
expect(error.code).assertEqual(0);
})
},3000)
})
},700)
setTimeout(()=>{
done();
}, 9500);
})
/*
* @tc.number: Acts_ApplicationStateChange_0300
* @tc.name: Register and deregister to monitor the foreground and background changes of this application.
* @tc.desc: In the same application, the on interface is called many times, but the off interface is not called,
* and the foreground and background changes can be monitored.
*/
it('Acts_ApplicationStateChange_0300',0, async function (done) {
let want = {
"deviceId": "",
...
...
@@ -215,6 +212,7 @@ export default function abilityTest() {
let subscriber
function unSubscribeCallback() {
console.debug("====>Acts_ApplicationStateChange_0300 unSubscribeCallback");
done();
}
function subscribeCallBack(err, data) {
console.debug("====>Acts_ApplicationStateChange_0300 data: " + JSON.stringify(data));
...
...
@@ -241,26 +239,24 @@ export default function abilityTest() {
globalThis.abilityContext.startAbility(want, (error) => {
console.log("ability error.code = " + error.code)
expect().assertFail();
done();
expect(error.code).assertEqual(0);
})
setTimeout(() => {
globalThis.abilityContext.startAbility(wantAuxiliary, (error) => {
console.log("auxiliary ability error.code = " + error.code)
expect().assertFail();
done();
expect(error.code).assertEqual(0);
})
},3000)
})
},700)
setTimeout(()=>{
done();
}, 9500);
})
/*
* @tc.number: Acts_ApplicationStateChange_0400
* @tc.name: Register and deregister to monitor the foreground and background changes of this application.
* @tc.desc: In the same application, the on interface is called many times, and the off interface is called
* (Callback is specified), and the foreground and background changes can be monitored.
*/
it('Acts_ApplicationStateChange_0400',0, async function (done) {
let abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
...
...
@@ -280,6 +276,7 @@ export default function abilityTest() {
let subscriber
function unSubscribeCallback() {
console.debug("====>Acts_ApplicationStateChange_0400 unSubscribeCallback");
done();
}
function subscribeCallBack(err, data) {
console.debug("====>Acts_ApplicationStateChange_0400 data: " + JSON.stringify(data));
...
...
@@ -306,25 +303,24 @@ export default function abilityTest() {
globalThis.abilityContext.startAbility(want, (error) => {
console.log("ability error.code = " + error.code)
expect().assertFail();
done();
expect(error.code).assertEqual(0);
})
setTimeout(() => {
globalThis.abilityContext.startAbility(wantAuxiliary, (error) => {
console.log("auxiliary ability error.code = " + error.code)
expect().assertFail();
done();
expect(error.code).assertEqual(0);
})
},3000)
})
},700)
setTimeout(()=>{
done();
}, 9500);
})
/*
* @tc.number: Acts_ApplicationStateChange_0500
* @tc.name: Register and deregister to monitor the foreground and background changes of this application.
* @tc.desc: In the different application, the on interface is called many times, and the off interface is called,
* and the foreground and background changes can be monitored.
*/
it('Acts_ApplicationStateChange_0500',0, async function (done) {
let abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
...
...
@@ -344,6 +340,7 @@ export default function abilityTest() {
let subscriber
function unSubscribeCallback() {
console.debug("====>Acts_ApplicationStateChange_0500 unSubscribeCallback");
done();
}
function subscribeCallBack(err, data) {
console.debug("====>Acts_ApplicationStateChange_0500 data: " + JSON.stringify(data));
...
...
@@ -370,24 +367,24 @@ export default function abilityTest() {
globalThis.abilityContext.startAbility(want, (error) => {
console.log("ability error.code = " + error.code)
expect().assertFail();
done();
expect(error.code).assertEqual(0);
})
setTimeout(() => {
globalThis.abilityContext.startAbility(wantAuxiliary, (error) => {
console.log("auxiliary ability error.code = " + error.code)
expect().assertFail();
done();
expect(error.code).assertEqual(0);
})
},3000)
})
},700)
setTimeout(()=>{
done();
}, 9500);
})
/*
* @tc.number: Acts_ApplicationStateChange_0600
* @tc.name: Register and deregister to monitor the foreground and background changes of this application.
* @tc.desc: In the same application, the on interface is called many times, and the off interface is called
* (Callback is not specified), and the foreground and background changes can be monitored.
*/
it('Acts_ApplicationStateChange_0600',0, async function (done) {
let abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
...
...
@@ -407,6 +404,7 @@ export default function abilityTest() {
let subscriber
function unSubscribeCallback() {
console.debug("====>Acts_ApplicationStateChange_0600 unSubscribeCallback");
done();
}
function subscribeCallBack(err, data) {
console.debug("====>Acts_ApplicationStateChange_0600 data: " + JSON.stringify(data));
...
...
@@ -433,26 +431,24 @@ export default function abilityTest() {
globalThis.abilityContext.startAbility(want, (error) => {
console.log("ability error.code = " + error.code)
expect().assertFail();
done();
expect(error.code).assertEqual(0);
})
setTimeout(() => {
globalThis.abilityContext.startAbility(wantAuxiliary, (error) => {
console.log("auxiliary ability error.code = " + error.code)
expect().assertFail();
done();
expect(error.code).assertEqual(0);
})
},3000)
})
},700)
setTimeout(()=>{
done();
}, 9500);
},700);
})
/*
* @tc.number: Acts_ApplicationStateChange_0700
* @tc.name: Register and deregister to monitor the foreground and background changes of this application.
* @tc.desc: In the same application, call on interface, call off interface and then call on again., and the
* foreground and background changes can be monitored.
*/
it('Acts_ApplicationStateChange_0700',0, function (done) {
let want = {
"deviceId": "",
...
...
@@ -469,6 +465,7 @@ export default function abilityTest() {
let subscriber
function unSubscribeCallback() {
console.debug("====>Acts_ApplicationStateChange_0700 unSubscribeCallback");
done();
}
function subscribeCallBack(err, data) {
console.debug("====>Acts_ApplicationStateChange_0700 data: " + JSON.stringify(data));
...
...
@@ -494,27 +491,26 @@ export default function abilityTest() {
globalThis.abilityContext.startAbility(want, (error) => {
console.log("ability error.code = " + error.code)
expect().assertFail();
done();
expect(error.code).assertEqual(0);
})
setTimeout(() => {
globalThis.abilityContext.startAbility(wantAuxiliary, (error) => {
console.log("auxiliary ability error.code = " + error.code)
expect().assertFail();
done();
expect(error.code).assertEqual(0);
})
},3000)
})
},700)
setTimeout(()=>{
done();
}, 9500);
},700);
})
/*
* @tc.number: Acts_ApplicationStateChange_0800
* @tc.name: Register and deregister to monitor the foreground and background changes of this application.
* @tc.desc: In the same application, start multiple abilities, call the on interface, and not all the application
* abilities can't be monitored in the background.
*/
it('Acts_ApplicationStateChange_0800', 0, async function (done) {
let want = {
"deviceId": "",
...
...
@@ -529,11 +525,11 @@ export default function abilityTest() {
"action": "DoubleAbilityTest"
}
let subscriber
let subscriber
;
function unSubscribeCallback() {
console.debug("====>Acts_ApplicationStateChange_0800 unSubscribeCallback");
done()
done()
;
}
function subscribeCallBack(err, data) {
...
...
@@ -559,21 +555,24 @@ export default function abilityTest() {
globalThis.abilityContext.startAbility(want, (error) => {
console.log("ability error.code = " + error.code)
expect().assertFail();
done();
expect(error.code).assertEqual(0);
})
setTimeout(() => {
globalThis.abilityContext.startAbility(wantAuxiliary, (error) => {
console.log("auxiliary ability error.code = " + error.code)
expect().assertFail();
done();
expect(error.code).assertEqual(0);
})
}, 3000)
})
}, 700)
}, 700);
})
/*
* @tc.number: Acts_GetRunningProcessInformation_AsyncCallback_0100
* @tc.name: When getting ProcessInfo, add the state field.
* @tc.desc: When the application obtains and does not obtain the focus, it can get the process information by
* calling the getRunningProcessInformation interface in AsyncCallback mode.
*/
it('Acts_GetRunningProcessInformation_AsyncCallback_0100', 0, async function (done) {
let TAG = 'getRunningProcess'
console.info("=====>Acts_GetRunningProcessInformation_AsyncCallback_0100 start<=====")
...
...
@@ -620,6 +619,7 @@ export default function abilityTest() {
globalThis.abilityContext.startAbility(want, (error) => {
console.log("start normal ability error.code = " + error.code)
expect(error.code).assertEqual(0);
})
setTimeout(async () => {
...
...
@@ -641,8 +641,14 @@ export default function abilityTest() {
}, 3000)
})
}, 1000)
})
})
/*
* @tc.number: Acts_GetRunningProcessInformation_Promise_0100
* @tc.name: When getting ProcessInfo, add the state field.
* @tc.desc: When the application obtains and does not obtain the focus, it can get the process information by
* calling the getRunningProcessInformation interface in promise mode.
*/
it('Acts_GetRunningProcessInformation_Promise_0100', 0, async function (done) {
let TAG = 'getRunningProcess'
console.info("=====>Acts_GetRunningProcessInformation_AsyncCallback_0100 start<=====")
...
...
@@ -656,7 +662,7 @@ export default function abilityTest() {
function unSubscribeCallback() {
console.debug("====>Acts_GetRunningProcessInformation_Promise_0100 unSubscribeCallback");
done()
done()
;
}
function subscribeCallBack(err, data) {
...
...
@@ -689,6 +695,7 @@ export default function abilityTest() {
globalThis.abilityContext.startAbility(want, (error) => {
console.log("start normal ability error.code = " + error.code)
expect(error.code).assertEqual(0);
})
setTimeout(async () => {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录