未验证 提交 5645cce5 编写于 作者: O openharmony_ci 提交者: Gitee

!6468 XTS--FreeInstallTest用例优化

Merge pull request !6468 from chengxingzhen/master
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" import { describe, beforeAll, afterEach, it, expect } from "@ohos/hypium"
import rpc from '@ohos.rpc'; import rpc from '@ohos.rpc';
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant' import wantConstant from '@ohos.ability.wantConstant'
...@@ -22,9 +22,9 @@ import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry ...@@ -22,9 +22,9 @@ import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry
export default function ConnectAbilityTest1() { export default function ConnectAbilityTest1() {
var TAG = ""; let TAG = "";
var Tempassert = ""; let Tempassert = "";
var abilityDelegator = undefined let abilityDelegator = undefined
function sleep(time) { function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time)) return new Promise((resolve) => setTimeout(resolve, time))
...@@ -34,17 +34,19 @@ export default function ConnectAbilityTest1() { ...@@ -34,17 +34,19 @@ export default function ConnectAbilityTest1() {
beforeAll(async function (done) { beforeAll(async function (done) {
console.info("FreeInstall_FA_ConnectAbility before all called"); console.info("FreeInstall_FA_ConnectAbility before all called");
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var cmd = "bm install -p data/test/MockService.hap"; let cmd = "bm install -p data/test/MockService.hap";
console.info("cmd : " + cmd) console.info("cmd : " + cmd)
console.info(TAG + " abilityDelegator : " + JSON.stringify(abilityDelegator)); console.info(TAG + " abilityDelegator : " + JSON.stringify(abilityDelegator));
abilityDelegator.executeShellCommand(cmd, (err: any, d: any) => { abilityDelegator.executeShellCommand(cmd, (err: any, d: any) => {
console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
var cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; await sleep(500);
let cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
abilityDelegator.executeShellCommand(cmd1, (err: any, d: any) => { abilityDelegator.executeShellCommand(cmd1, (err: any, d: any) => {
console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
var cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; await sleep(500);
let cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
abilityDelegator.executeShellCommand(cmd2, (err: any, d: any) => { abilityDelegator.executeShellCommand(cmd2, (err: any, d: any) => {
console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
done(); done();
...@@ -54,11 +56,12 @@ export default function ConnectAbilityTest1() { ...@@ -54,11 +56,12 @@ export default function ConnectAbilityTest1() {
afterEach(async function (done) { afterEach(async function (done) {
console.info("FreeInstall_FA_ConnectAbility after each called"); console.info("FreeInstall_FA_ConnectAbility after each called");
Tempassert = "" Tempassert = ""
if ("FreeInstall_FA_ConnectAbility_1600" === TAG) { if ("FreeInstall_FA_ConnectAbility_2000" === TAG) {
var cmd14 = "bm uninstall -n com.ohos.hag.famanager"; let cmd14 = "bm uninstall -n com.ohos.hag.famanager";
abilityDelegator.executeShellCommand(cmd14, (err: any, d: any) => { abilityDelegator.executeShellCommand(cmd14, (err: any, d: any) => {
console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
await sleep(2000)
} }
done(); done();
}); });
...@@ -113,8 +116,6 @@ export default function ConnectAbilityTest1() { ...@@ -113,8 +116,6 @@ export default function ConnectAbilityTest1() {
console.info(msg + "END"); console.info(msg + "END");
} }
/* /*
* @tc.number FreeInstall_FA_ConnectAbility_1500 * @tc.number FreeInstall_FA_ConnectAbility_1500
* @tc.name The application is not in the foreground, * @tc.name The application is not in the foreground,
...@@ -125,11 +126,12 @@ export default function ConnectAbilityTest1() { ...@@ -125,11 +126,12 @@ export default function ConnectAbilityTest1() {
it("FreeInstall_FA_ConnectAbility_1500", 0, async function (done) { it("FreeInstall_FA_ConnectAbility_1500", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1500-------------"); console.log("------------start FreeInstall_FA_ConnectAbility_1500-------------");
TAG = "FreeInstall_FA_ConnectAbility_1500"; TAG = "FreeInstall_FA_ConnectAbility_1500";
var cmddif = "bm install -p data/test/ConnectDifferentApplication.hap"; let cmddif = "bm install -p data/test/ConnectDifferentApplication.hap";
abilityDelegator.executeShellCommand(cmddif, (err: any, d: any) => { abilityDelegator.executeShellCommand(cmddif, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
var str = { await sleep(2000)
let str = {
"want": { "want": {
"bundleName": "com.example.different.hmservice", "bundleName": "com.example.different.hmservice",
"abilityName": "MainAbility", "abilityName": "MainAbility",
...@@ -141,20 +143,18 @@ export default function ConnectAbilityTest1() { ...@@ -141,20 +143,18 @@ export default function ConnectAbilityTest1() {
}).catch((error) => { }).catch((error) => {
console.error(TAG + " startother failed. Cause: " + JSON.stringify(error)); console.error(TAG + " startother failed. Cause: " + JSON.stringify(error));
}) })
setTimeout(async () => { let request15 = {
var request15 = { "bundleName": "com.example.myapplication.hmservice",
"bundleName": "com.example.myapplication.hmservice", "abilityName": "com.example.myapplication5.ServiceAbility5",
"abilityName": "com.example.myapplication5.ServiceAbility5", "moduleName": "myapplication5",
"moduleName": "myapplication5", "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, }
} connectabillity(TAG, request15);
connectabillity(TAG, request15); setTimeout(() => {
setTimeout(() => { expect(Tempassert).assertEqual("onFailed");
expect(Tempassert).assertEqual("onFailed"); console.log("------------end FreeInstall_FA_ConnectAbility_1500-------------");
}, 500) done();
}, 2000); }, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_1500-------------");
done();
}); });
/* /*
...@@ -167,11 +167,12 @@ export default function ConnectAbilityTest1() { ...@@ -167,11 +167,12 @@ export default function ConnectAbilityTest1() {
it("FreeInstall_FA_ConnectAbility_1600", 0, async function (done) { it("FreeInstall_FA_ConnectAbility_1600", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1600-------------"); console.log("------------start FreeInstall_FA_ConnectAbility_1600-------------");
TAG = "FreeInstall_FA_ConnectAbility_1600"; TAG = "FreeInstall_FA_ConnectAbility_1600";
var cmdmyapp4 = "bm install -p data/test/ConnectFaMyApplication4.hap"; let cmdmyapp4 = "bm install -p data/test/ConnectFaMyApplication4.hap";
abilityDelegator.executeShellCommand(cmdmyapp4, (err: any, d: any) => { abilityDelegator.executeShellCommand(cmdmyapp4, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
var str = { await sleep(2000)
let str = {
"want": { "want": {
"bundleName": "com.example.different.hmservice", "bundleName": "com.example.different.hmservice",
"abilityName": "MainAbility", "abilityName": "MainAbility",
...@@ -184,20 +185,18 @@ export default function ConnectAbilityTest1() { ...@@ -184,20 +185,18 @@ export default function ConnectAbilityTest1() {
console.error(TAG + " startother failed. Cause: " + JSON.stringify(error)); console.error(TAG + " startother failed. Cause: " + JSON.stringify(error));
}) })
setTimeout(function () { let request16 = {
var request16 = { "bundleName": "com.example.myapplication.hmservice",
"bundleName": "com.example.myapplication.hmservice", "abilityName": "com.example.myapplication4.ServiceAbility4",
"abilityName": "com.example.myapplication4.ServiceAbility4", "moduleName": "myapplication4",
"moduleName": "myapplication4", "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, }
} connectabillity(TAG, request16);
connectabillity(TAG, request16); setTimeout(() => {
setTimeout(() => { expect(Tempassert).assertEqual("onConnect");
expect(Tempassert).assertEqual("onConnect"); console.log("------------end FreeInstall_FA_ConnectAbility_1600-------------");
}, 500) done();
}, 2000); }, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_1600-------------");
done();
}); });
/* /*
...@@ -209,7 +208,7 @@ export default function ConnectAbilityTest1() { ...@@ -209,7 +208,7 @@ export default function ConnectAbilityTest1() {
it("FreeInstall_FA_ConnectAbility_1400", 0, async function (done) { it("FreeInstall_FA_ConnectAbility_1400", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1400-------------"); console.log("------------start FreeInstall_FA_ConnectAbility_1400-------------");
TAG = "FreeInstall_FA_ConnectAbility_1400"; TAG = "FreeInstall_FA_ConnectAbility_1400";
var str = { let str = {
"want": { "want": {
"bundleName": "com.example.myapplication.hmservice", "bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication2.MainAbility", "abilityName": "com.example.myapplication2.MainAbility",
...@@ -222,20 +221,18 @@ export default function ConnectAbilityTest1() { ...@@ -222,20 +221,18 @@ export default function ConnectAbilityTest1() {
}).catch((error) => { }).catch((error) => {
console.error(TAG + " startmyapp2 failed. Cause: " + JSON.stringify(error)); console.error(TAG + " startmyapp2 failed. Cause: " + JSON.stringify(error));
}) })
let request14 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "myapplication3",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request14);
setTimeout(() => { setTimeout(() => {
var request14 = { expect(Tempassert).assertEqual("onFailed");
"bundleName": "com.example.myapplication.hmservice", console.log("------------end FreeInstall_FA_ConnectAbility_1400-------------");
"abilityName": "com.example.myapplication1.ServiceAbility_feature", done()
"moduleName": "myapplication3",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request14);
setTimeout(async () => {
expect(Tempassert).assertEqual("onFailed");
}, 500);
}, 2000) }, 2000)
done();
console.log("------------end FreeInstall_FA_ConnectAbility_1400-------------");
}); });
/* /*
...@@ -247,23 +244,22 @@ export default function ConnectAbilityTest1() { ...@@ -247,23 +244,22 @@ export default function ConnectAbilityTest1() {
it("FreeInstall_FA_ConnectAbility_1700", 0, async function (done) { it("FreeInstall_FA_ConnectAbility_1700", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1700-------------"); console.log("------------start FreeInstall_FA_ConnectAbility_1700-------------");
TAG = "FreeInstall_FA_ConnectAbility_1700"; TAG = "FreeInstall_FA_ConnectAbility_1700";
var cmddif = "bm install -p data/test/ConnectDifferentApplication.hap"; let cmddif = "bm install -p data/test/ConnectDifferentApplication.hap";
await abilityDelegator.executeShellCommand(cmddif, (err: any, d: any) => { await abilityDelegator.executeShellCommand(cmddif, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
await sleep(2000)
let request17 = {
"bundleName": "com.example.different.hmservice",
"abilityName": "com.example.different.ServiceAbility",
"moduleName": "entry",
}
connectabillity(TAG, request17);
setTimeout(() => { setTimeout(() => {
var request17 = { expect(Tempassert).assertEqual("onConnect");
"bundleName": "com.example.different.hmservice", console.log("------------end FreeInstall_FA_ConnectAbility_1700-------------");
"abilityName": "com.example.different.ServiceAbility", done();
"moduleName": "entry",
}
connectabillity(TAG, request17);
setTimeout(() => {
expect(Tempassert).assertEqual("onConnect");
}, 500);
}, 2000) }, 2000)
console.log("------------end FreeInstall_FA_ConnectAbility_1700-------------");
done();
}); });
/* /*
...@@ -275,21 +271,18 @@ export default function ConnectAbilityTest1() { ...@@ -275,21 +271,18 @@ export default function ConnectAbilityTest1() {
it("FreeInstall_FA_ConnectAbility_1800", 0, async function (done) { it("FreeInstall_FA_ConnectAbility_1800", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1800-------------"); console.log("------------start FreeInstall_FA_ConnectAbility_1800-------------");
TAG = "FreeInstall_FA_ConnectAbility_1800"; TAG = "FreeInstall_FA_ConnectAbility_1800";
let request18 = {
setTimeout(async () => { "bundleName": "com.example.myapplication.hmservice",
var request18 = { "abilityName": "com.example.myapplication1.ServiceAbility_feature",
"bundleName": "com.example.myapplication.hmservice", "moduleName": "xxxxx",
"abilityName": "com.example.myapplication1.ServiceAbility_feature", "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
"moduleName": "xxxxx", }
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, connectabillity(TAG, request18);
} setTimeout(() => {
connectabillity(TAG, request18); expect(Tempassert).assertEqual("onFailed");
setTimeout(() => { console.log("------------end FreeInstall_FA_ConnectAbility_1800-------------");
expect(Tempassert).assertEqual("onFailed"); done();
}, 500)
}, 2000); }, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_1800-------------");
done();
}); });
/* /*
...@@ -301,25 +294,23 @@ export default function ConnectAbilityTest1() { ...@@ -301,25 +294,23 @@ export default function ConnectAbilityTest1() {
it("FreeInstall_FA_ConnectAbility_1900", 0, async function (done) { it("FreeInstall_FA_ConnectAbility_1900", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1900-------------"); console.log("------------start FreeInstall_FA_ConnectAbility_1900-------------");
TAG = "FreeInstall_FA_ConnectAbility_1900"; TAG = "FreeInstall_FA_ConnectAbility_1900";
var cmdmyapp5 = "cp data/test/ConnectFaMyApplication5.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + let cmdmyapp5 = "cp data/test/ConnectFaMyApplication5.hap /data/app/el2/100/base/com.ohos.hag.famanager/" +
"haps/entry/files"; "haps/entry/files";
await abilityDelegator.executeShellCommand(cmdmyapp5, (err: any, d: any) => { await abilityDelegator.executeShellCommand(cmdmyapp5, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
setTimeout(async () => { let request19 = {
var request19 = { "bundleName": "com.example.myapplication.hmservice",
"bundleName": "com.example.myapplication.hmservice", "abilityName": "com.example.myapplication1.ServiceAbility_feature",
"abilityName": "com.example.myapplication1.ServiceAbility_feature", "moduleName": "myapplication3",
"moduleName": "myapplication3", "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, }
} connectabillity(TAG, request19);
connectabillity(TAG, request19); setTimeout(() => {
setTimeout(() => { expect(Tempassert).assertEqual("onFailed");
expect(Tempassert).assertEqual("onFailed"); console.log("------------end FreeInstall_FA_ConnectAbility_1900-------------");
}, 500) done();
}, 2000); }, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_1900-------------");
done();
}); });
/* /*
...@@ -331,28 +322,27 @@ export default function ConnectAbilityTest1() { ...@@ -331,28 +322,27 @@ export default function ConnectAbilityTest1() {
it("FreeInstall_FA_ConnectAbility_2000", 0, async function (done) { it("FreeInstall_FA_ConnectAbility_2000", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_2000-------------"); console.log("------------start FreeInstall_FA_ConnectAbility_2000-------------");
TAG = "FreeInstall_FA_ConnectAbility_2000"; TAG = "FreeInstall_FA_ConnectAbility_2000";
var cmdmyapp5 = "cp data/test/ConnectFaMyApplication5.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + let cmdmyapp5 = "cp data/test/ConnectFaMyApplication5.hap /data/app/el2/100/base/com.ohos.hag.famanager/" +
"haps/entry/files"; "haps/entry/files";
abilityDelegator.executeShellCommand(cmdmyapp5, (err: any, d: any) => { abilityDelegator.executeShellCommand(cmdmyapp5, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
setTimeout(async () => { await sleep(1000)
var request20 = { let request20 = {
"bundleName": "com.example.myapplication.hmservice", "bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication5.ServiceAbility5", "abilityName": "com.example.myapplication5.ServiceAbility5",
"moduleName": "myapplication5", "moduleName": "myapplication5",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
"parameters": { "parameters": {
"name": 1111, "key1": "value1", "site": "nice to meet you!" "name": 1111, "key1": "value1", "site": "nice to meet you!"
}, },
} }
connectabillity(TAG, request20); connectabillity(TAG, request20);
setTimeout(() => { setTimeout(() => {
expect(Tempassert).assertEqual("onConnect"); expect(Tempassert).assertEqual("onConnect");
}, 500) console.log("------------end FreeInstall_FA_ConnectAbility_2000-------------");
done()
}, 4000) }, 4000)
done();
console.log("------------end FreeInstall_FA_ConnectAbility_2000-------------");
}); });
} }
) )
......
...@@ -146,8 +146,8 @@ ...@@ -146,8 +146,8 @@
abilityDelegator.executeShellCommand(cmd14, (err: any, d: any) => { abilityDelegator.executeShellCommand(cmd14, (err: any, d: any) => {
console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
await sleep(2000)
} }
await sleep(1500);
done(); done();
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册