提交 0b3dbb53 编写于 作者: X xinking129

modify runningprocess done

Signed-off-by: Nxinking129 <xinxin13@huawei.com>
上级 074a8805
......@@ -41,8 +41,7 @@ let ApplicationStateChangeCallbackFir = {
console.log(TAG, 'ApplicationStateChangeCallbackFir onApplicationBackground')
commonEventData.parameters.commonStateArr[1] = 1
if (globalThis.want.action == 'NeedBackGroundOff' || globalThis.want.action == 'MultiAppRegister'
|| globalThis.want.action == 'DoubleRegisterOff') {
if (globalThis.want.action == 'NeedBackGroundOff' || globalThis.want.action == 'MultiAppRegister') {
console.info('entered needbackgroundoff!')
globalThis.applicationContext.off('applicationStateChange', ApplicationStateChangeCallbackFir)
}
......
......@@ -24,12 +24,20 @@
{
"type": "ShellKit",
"run-command": [
"param set persist.sys.suspend_manager_enabled false",
"reboot",
"power-shell wakeup",
"uinput -T -d 300 600 -m 300 600 300 100 -u 300 100",
"power-shell setmode 602",
"hilog -Q pidoff",
"hilog -Q domainoff",
"hilog -b D",
"setenforce 0"
],
"teardown-command": [
"param set persist.sys.suspend_manager_enabled true",
"power-shell setmode 601",
"reboot"
]
}
]
......
......@@ -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,24 +111,27 @@ export default function abilityTest() {
commonEvent.subscribe(subscriber, subscribeCallBack);
globalThis.abilityContext.startAbility(want, (error) => {
console.log("ability error.code = " + error.code)
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)
console.log("auxiliary ability error.code = " + error.code);
expect(error.code).assertEqual(0);
})
},3000)
})
},700)
},3000)
setTimeout(()=>{
done();
}, 18000);
});
},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": "",
......@@ -147,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));
......@@ -174,22 +176,25 @@ export default function abilityTest() {
globalThis.abilityContext.startAbility(want, (error) => {
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(error.code).assertEqual(0);
})
},3000)
})
},700)
setTimeout(()=>{
done();
}, 18000);
})
/*
* @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": "",
......@@ -207,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));
......@@ -233,22 +239,24 @@ export default function abilityTest() {
globalThis.abilityContext.startAbility(want, (error) => {
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(error.code).assertEqual(0);
})
},3000)
})
},700)
setTimeout(()=>{
done();
}, 18000);
})
/*
* @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();
......@@ -268,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));
......@@ -294,21 +303,24 @@ export default function abilityTest() {
globalThis.abilityContext.startAbility(want, (error) => {
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(error.code).assertEqual(0);
})
},3000)
})
},700)
setTimeout(()=>{
done();
}, 18000);
})
/*
* @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();
......@@ -328,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));
......@@ -354,20 +367,24 @@ export default function abilityTest() {
globalThis.abilityContext.startAbility(want, (error) => {
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(error.code).assertEqual(0);
})
},3000)
})
},700)
setTimeout(()=>{
done();
}, 18000);
})
/*
* @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();
......@@ -387,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));
......@@ -413,22 +431,24 @@ export default function abilityTest() {
globalThis.abilityContext.startAbility(want, (error) => {
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(error.code).assertEqual(0);
})
},3000)
})
},700)
setTimeout(()=>{
done();
}, 18000);
},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": "",
......@@ -445,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));
......@@ -470,23 +491,26 @@ export default function abilityTest() {
globalThis.abilityContext.startAbility(want, (error) => {
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(error.code).assertEqual(0);
})
},3000)
})
},700)
setTimeout(()=>{
done();
}, 18000);
},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": "",
......@@ -501,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) {
......@@ -531,17 +555,24 @@ export default function abilityTest() {
globalThis.abilityContext.startAbility(want, (error) => {
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(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<=====")
......@@ -588,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 () => {
......@@ -609,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<=====")
......@@ -624,7 +662,7 @@ export default function abilityTest() {
function unSubscribeCallback() {
console.debug("====>Acts_GetRunningProcessInformation_Promise_0100 unSubscribeCallback");
done()
done();
}
function subscribeCallBack(err, data) {
......@@ -657,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.
先完成此消息的编辑!
想要评论请 注册