提交 cb78cb01 编写于 作者: X xinking129

modify code

Signed-off-by: Nxinking129 <xinxin13@huawei.com>
上级 2afa5db6
......@@ -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.
先完成此消息的编辑!
想要评论请 注册