提交 459a517a 编写于 作者: X xinxin13

change freeinstalltest code case

Signed-off-by: Nxinxin13 <xinxin13@huawei.com>
上级 69ee04d7
......@@ -25,611 +25,488 @@ import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry
export default function ConnectAbilityTest() {
var TAG = "";
var Tempassert = "";
var abilityDelegator = undefined
var TAG = "";
var Tempassert = "";
var abilityDelegator = undefined
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
describe('FreeInstall_FA_ConnectAbility', function () {
beforeAll(async function (done) {
console.info("FreeInstall_FA_ConnectAbility before all called");
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var cmd = "bm install -p data/test/MockService.hap";
console.info("cmd : " + cmd)
console.info(TAG + " abilityDelegator : " + JSON.stringify(abilityDelegator));
abilityDelegator.executeShellCommand(cmd, (err: any, d: any) => {
console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
abilityDelegator.executeShellCommand(cmd1, (err: any, d: any) => {
console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
abilityDelegator.executeShellCommand(cmd2, (err: any, d: any) => {
console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
done();
})
});
afterEach(async (done) => {
console.info("FreeInstall_FA_ConnectAbility after each called");
Tempassert = ""
if ("FreeInstall_FA_ConnectAbility_2000" === TAG) {
var cmd14 = "bm uninstall -n com.ohos.hag.famanager";
abilityDelegator.executeShellCommand(cmd14, (err: any, d: any) => {
console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
}
done();
});
function tips(msg) {
Prompt.showToast({
message: msg,
duration: 2000,
bottom: '150px'
});
}
async function connectabillity(msg, request) {
console.info(msg + "START");
let options = {
onConnect: function (element, proxy) {
console.info("FreeInstall_FA_ConnectAbility onConnect success!!!")
console.info(msg + " onConnect success!!! ");
console.info(msg + " onConnect: " + JSON.stringify(element));
console.info(msg + " onConnect: " + JSON.stringify(proxy));
if (proxy == null) {
console.error("FreeInstall_FA_ConnectAbility proxy null");
return;
}
let option = new rpc.MessageOption();
let data = new rpc.MessageParcel();
let reply = new rpc.MessageParcel();
data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver");
proxy.sendRequest(0, data, reply, option);
Tempassert = "onConnect";
tips("连接成功");
},
onDisconnect: function (element) {
console.info("FreeInstall_FA_ConnectAbility onDisconnect success!!!")
console.info(msg + " onDisconnect success!!!");
console.info(msg + " onDisconnect: " + JSON.stringify(element));
Tempassert = "onDisconnect";
tips("连接断开");
},
onFailed: function (code) {
console.info("FreeInstall_FA_ConnectAbility onFailed!!!")
console.info(msg + " onFailed!!! ");
console.info(msg + " onFailed: " + JSON.stringify(code));
Tempassert = "onFailed";
tips("连接失败");
}
}
let connection = await featureAbility.connectAbility(request, options);
console.info(msg + "request:" + JSON.stringify(request));
console.info(msg + "options:" + JSON.stringify(options));
console.info(msg + "connection=" + JSON.stringify(connection));
console.info(msg + "END");
}
describe('FreeInstall_FA_ConnectAbility', function () {
beforeAll(async function (done) {
console.info("FreeInstall_FA_ConnectAbility before all called");
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var cmd = "bm install -p data/test/MockService.hap";
console.info("cmd : " + cmd)
console.info(TAG + " abilityDelegator : " + JSON.stringify(abilityDelegator));
abilityDelegator.executeShellCommand(cmd, (err: any, d: any) => {
console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
abilityDelegator.executeShellCommand(cmd1, (err: any, d: any) => {
console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
abilityDelegator.executeShellCommand(cmd2, (err: any, d: any) => {
console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
done();
})
});
afterEach(async function (done) {
console.info("FreeInstall_FA_ConnectAbility after each called");
Tempassert = ""
await sleep(1000);
if ("FreeInstall_FA_ConnectAbility_2000" === TAG) {
var cmd14 = "bm uninstall -n com.ohos.hag.famanager";
abilityDelegator.executeShellCommand(cmd14, (err: any, d: any) => {
console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
}
await sleep(500);
done();
});
function tips(msg) {
Prompt.showToast({
message: msg,
duration: 2000,
bottom: '150px'
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_0100
* @tc.name Pass in the local deviceid,atomic service does not exist locally
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_ConnectAbility_0100", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0100-------------");
TAG = "FreeInstall_FA_ConnectAbility_0100";
var cmd4 = "cp data/test/ConnectFaMyApplication6.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps" +
"/entry/files";
abilityDelegator.executeShellCommand(cmd4, (err: any, d: any) => {
console.info(TAG + " executeShellCommand4 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
setTimeout(async () => {
var deviceid = "0";
await abilityManager.getTopAbility((err, data) => {
console.log(TAG + 'getTopAbility result: ' + JSON.stringify(data) + " , err: " + JSON.stringify(err));
console.log(TAG + 'getTopAbility result deviceid:' + JSON.stringify(data.deviceId));
deviceid = data.deviceId;
})
var request1 = {
"deviceId": deviceid,
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication6.ServiceAbility",
"moduleName": "myapplication6",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request1);
setTimeout(() => {
expect(Tempassert).assertEqual("onConnect");
}, 500)
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_0100-------------");
done();
});
async function connectabillity(msg, request) {
console.info(msg + "START");
let options = {
onConnect: function (element, proxy) {
console.info("FreeInstall_FA_ConnectAbility onConnect success!!!")
console.info(msg + " onConnect success!!! ");
console.info(msg + " onConnect: " + JSON.stringify(element));
console.info(msg + " onConnect: " + JSON.stringify(proxy));
if (proxy == null) {
console.error("FreeInstall_FA_ConnectAbility proxy null");
return;
}
let option = new rpc.MessageOption();
let data = new rpc.MessageParcel();
let reply = new rpc.MessageParcel();
data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver");
proxy.sendRequest(0, data, reply, option);
Tempassert = "onConnect";
tips("连接成功");
},
onDisconnect: function (element) {
console.info("FreeInstall_FA_ConnectAbility onDisconnect success!!!")
console.info(msg + " onDisconnect success!!!");
console.info(msg + " onDisconnect: " + JSON.stringify(element));
Tempassert = "onDisconnect";
tips("连接断开");
},
onFailed: function (code) {
console.info("FreeInstall_FA_ConnectAbility onFailed!!!")
console.info(msg + " onFailed!!! ");
console.info(msg + " onFailed: " + JSON.stringify(code));
Tempassert = "onFailed";
tips("连接失败");
}
}
let connection = await featureAbility.connectAbility(request, options);
console.info(msg + "request:" + JSON.stringify(request));
console.info(msg + "options:" + JSON.stringify(options));
console.info(msg + "connection=" + JSON.stringify(connection));
console.info(msg + "END");
/*
* @tc.number FreeInstall_FA_ConnectAbility_0200
* @tc.name Pass in the local deviceid,atomic service exists locally
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_ConnectAbility_0200", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0200-------------");
TAG = "FreeInstall_FA_ConnectAbility_0200";
var cmdapp10 = "bm install -p data/test/ConnectFaMyApplication10.hap";
abilityDelegator.executeShellCommand(cmdapp10, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
setTimeout(async () => {
var deviceid = "0";
await abilityManager.getTopAbility((err, data) => {
console.log(TAG + 'getTopAbility result: ' + JSON.stringify(data) + " , err: " + JSON.stringify(err));
console.log(TAG + 'getTopAbility result deviceid:' + JSON.stringify(data.deviceId));
deviceid = data.deviceId;
})
var request2 = {
"deviceId": deviceid,
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication10.ServiceAbility",
"moduleName": "myapplication10",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request2);
setTimeout(() => {
expect(Tempassert).assertEqual("onConnect");
}, 500)
}, 2500);
console.log("------------end FreeInstall_FA_ConnectAbility_0200-------------");
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_0100
* @tc.name Pass in the local deviceid,atomic service does not exist locally
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_ConnectAbility_0100", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0100-------------");
TAG = "FreeInstall_FA_ConnectAbility_0100";
var cmd4 = "cp data/test/ConnectFaMyApplication6.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps" +
"/entry/files";
abilityDelegator.executeShellCommand(cmd4, (err: any, d: any) => {
console.info(TAG + " executeShellCommand4 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var deviceid = "0";
abilityManager.getTopAbility((err, data) => {
console.log(TAG + 'getTopAbility result: ' + JSON.stringify(data) + " , err: " + JSON.stringify(err));
console.log(TAG + 'getTopAbility result deviceid:' + JSON.stringify(data.deviceId));
deviceid = data.deviceId;
})
await sleep(500);
var request1 = {
"deviceId": deviceid,
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication6.ServiceAbility",
"moduleName": "myapplication6",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request1);
setTimeout(function () {
expect(Tempassert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_0100-------------");
done();
}, 3000);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_0200
* @tc.name Pass in the local deviceid,atomic service exists locally
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_ConnectAbility_0200", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0200-------------");
TAG = "FreeInstall_FA_ConnectAbility_0200";
var cmdapp10 = "bm install -p data/test/ConnectFaMyApplication10.hap";
abilityDelegator.executeShellCommand(cmdapp10, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var deviceid = "0";
abilityManager.getTopAbility((err, data) => {
console.log(TAG + 'getTopAbility result: ' + JSON.stringify(data) + " , err: " + JSON.stringify(err));
console.log(TAG + 'getTopAbility result deviceid:' + JSON.stringify(data.deviceId));
deviceid = data.deviceId;
})
await sleep(500);
var request2 = {
"deviceId": deviceid,
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication10.ServiceAbility",
"moduleName": "myapplication10",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request2);
setTimeout(function () {
expect(Tempassert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_0200-------------");
done();
}, 3000);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_0300
* @tc.name Deviceid is empty,atomic service does not exist locally
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_ConnectAbility_0300", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0300-------------");
TAG = "FreeInstall_FA_ConnectAbility_0300";
var cmd3 = "cp data/test/ConnectFaMyApplication1.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
abilityDelegator.executeShellCommand(cmd3, (err: any, d: any) => {
console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var request3 = {
"deviceId": "",
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "myapplication1",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request3);
setTimeout(function () {
expect(Tempassert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_0300-------------");
done();
}, 3000);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_0400
* @tc.name Deviceid is empty,atomic service exists locally
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_ConnectAbility_0400", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0400-------------");
TAG = "FreeInstall_FA_ConnectAbility_0400";
var cmdapp11 = "bm install -p data/test/ConnectFaMyApplication11.hap";
abilityDelegator.executeShellCommand(cmdapp11, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var request4 = {
"deviceId": "",
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication11.ServiceAbility",
"moduleName": "myapplication11",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request4);
setTimeout(function () {
expect(Tempassert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_0400-------------");
done();
}, 3000);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_0500
* @tc.name The bundleName passed in is different from the local
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_0500", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0500-------------");
TAG = "FreeInstall_FA_ConnectAbility_0500";
var request5 = {
"bundleName": "com.example.different.hmservice",
"abilityName": "com.example.different.ServiceAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request5);
setTimeout(function () {
expect(Tempassert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_0500-------------");
done();
}, 2000);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_0600
* @tc.name Pass in an empty bundleName
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_0600", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0600-------------");
TAG = "FreeInstall_FA_ConnectAbility_0600";
var request6 = {
"bundleName": "",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "myapplication1",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request6);
setTimeout(function () {
expect(Tempassert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_0600-------------");
done();
}, 2000);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_0700
* @tc.name Pass in an empty abilityName
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_0700", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0700-------------");
TAG = "FreeInstall_FA_ConnectAbility_0700";
var request7 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "",
"moduleName": "myapplication1",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request7);
setTimeout(function () {
expect(Tempassert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_0700-------------");
done();
}, 2000);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_0800
* @tc.name Incorrect deviceid passed in
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_0800", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0800-------------");
TAG = "FreeInstall_FA_ConnectAbility_0800";
var request8 = {
"deviceId": "xxxxxx",
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication2.ServiceAbility",
"moduleName": "myapplication2",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request8);
setTimeout(function () {
expect(Tempassert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_0800-------------");
done();
}, 2000);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_0900
* @tc.name Incorrect bundleName passed in
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_0900", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0900-------------");
TAG = "FreeInstall_FA_ConnectAbility_0900";
var request9 = {
"bundleName": "com.example.xxx.hmservice",
"abilityName": "com.example.myapplication2.ServiceAbility",
"moduleName": "myapplication2",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request9);
setTimeout(function () {
expect(Tempassert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_0900-------------");
done();
}, 2000);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1000
* @tc.name Incorrect flags passed in,atomic service does not exist locally
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_1000", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1000-------------");
TAG = "FreeInstall_FA_ConnectAbility_1000";
var request10 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication2.ServiceAbility",
"moduleName": "myapplication2",
"flags": 1111111,
}
connectabillity(TAG, request10);
setTimeout(function () {
expect(Tempassert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_1000-------------");
done();
}, 2000);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1100
* @tc.name Incorrect flags passed in,atomic service exists locally
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_ConnectAbility_1100", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1100-------------");
TAG = "FreeInstall_FA_ConnectAbility_1100";
var cmdapp2 = "bm install -p data/test/ConnectFaMyApplication2.hap";
abilityDelegator.executeShellCommand(cmdapp2, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(1000);
var request11 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication2.ServiceAbility",
"moduleName": "myapplication2",
"flags": "11",
}
connectabillity(TAG, request11);
setTimeout(function () {
expect(Tempassert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_1000-------------");
done();
}, 3000);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1200
* @tc.name No atomic service under path
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_1200", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1200-------------");
TAG = "FreeInstall_FA_ConnectAbility_1200";
var cmdrm = "rm -r /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/*";
abilityDelegator.executeShellCommand(cmdrm, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var request12 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "myapplication3",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request12);
setTimeout(function () {
expect(Tempassert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_1200-------------");
done();
}, 2000);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1300
* @tc.name The application is not in the foreground [start MainAbility2 first, then connect]
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_1300", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1300-------------");
TAG = "FreeInstall_FA_ConnectAbility_1300";
var str = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.MainAbility2",
}
}
console.info(TAG + " startmainability2 str: " + JSON.stringify(str));
featureAbility.startAbility(str)
.then((data) => {
console.info(TAG + " startmainability2 successful. Data: " + JSON.stringify(data))
}).catch((error) => {
console.error(TAG + " startmainability2 failed. Cause: " + JSON.stringify(error));
})
await sleep(1500);
var request13 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "myapplication3",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request13);
setTimeout(function () {
expect(Tempassert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_1300-------------");
done();
}, 1500);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1400
* @tc.name The application is not in the foreground [start myapp2 first, then connect]
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_1400", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1400-------------");
TAG = "FreeInstall_FA_ConnectAbility_1400";
var str = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication2.MainAbility",
}
}
console.info(TAG + " startmyapp2 str: " + JSON.stringify(str));
featureAbility.startAbility(str)
.then((data) => {
console.info(TAG + " startmyapp2 successful. Data: " + JSON.stringify(data))
}).catch((error) => {
console.error(TAG + " startmyapp2 failed. Cause: " + JSON.stringify(error));
})
await sleep(1500);
var 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(function () {
expect(Tempassert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_1400-------------");
done();
}, 1500);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1700
* @tc.name Do not pass flags, connect to the service of another project
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_ConnectAbility_1700", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1700-------------");
TAG = "FreeInstall_FA_ConnectAbility_1700";
var cmddif = "bm install -p data/test/ConnectDifferentApplication.hap";
abilityDelegator.executeShellCommand(cmddif, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(1000);
var request17 = {
"bundleName": "com.example.different.hmservice",
"abilityName": "com.example.different.ServiceAbility",
"moduleName": "entry",
}
connectabillity(TAG, request17);
setTimeout(function () {
expect(Tempassert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_1700-------------");
done();
}, 2000);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1800
* @tc.name Incorrect moduleName passed in
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_1800", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1800-------------");
TAG = "FreeInstall_FA_ConnectAbility_1800";
var request18 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "xxxxx",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request18);
setTimeout(function () {
expect(Tempassert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_1800-------------");
done();
}, 2000);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1900
* @tc.name The target is atomized as hapA, and hapB is placed under the path
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_1900", 0, async function (done) {
console.log("------------start 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/" +
"haps/entry/files";
abilityDelegator.executeShellCommand(cmdmyapp5, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(1000);
var request19 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "myapplication3",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request19);
setTimeout(function () {
expect(Tempassert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_1900-------------");
done();
}, 2000);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_2000
* @tc.name Pass in parameters
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_ConnectAbility_2000", 0, async function (done) {
console.log("------------start 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/" +
"haps/entry/files";
abilityDelegator.executeShellCommand(cmdmyapp5, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(1000);
var request20 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication5.ServiceAbility5",
"moduleName": "myapplication5",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
"parameters": {
"name": 1111, "key1": "value1", "site": "nice to meet you!"
},
}
connectabillity(TAG, request20);
setTimeout(function () {
expect(Tempassert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_2000-------------");
done();
}, 2000);
});
}
)
/*
* @tc.number FreeInstall_FA_ConnectAbility_0300
* @tc.name Deviceid is empty,atomic service does not exist locally
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_ConnectAbility_0300", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0300-------------");
TAG = "FreeInstall_FA_ConnectAbility_0300";
var cmd3 = "cp data/test/ConnectFaMyApplication1.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
abilityDelegator.executeShellCommand(cmd3, (err: any, d: any) => {
console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
setTimeout(async () => {
var request3 = {
"deviceId": "",
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "myapplication1",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request3);
setTimeout(() => {
expect(Tempassert).assertEqual("onConnect");
}, 500)
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_0300-------------");
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_0400
* @tc.name Deviceid is empty,atomic service exists locally
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_ConnectAbility_0400", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0400-------------");
TAG = "FreeInstall_FA_ConnectAbility_0400";
var cmdapp11 = "bm install -p data/test/ConnectFaMyApplication11.hap";
abilityDelegator.executeShellCommand(cmdapp11, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
setTimeout(async () => {
var request4 = {
"deviceId": "",
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication11.ServiceAbility",
"moduleName": "myapplication11",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request4);
setTimeout(() => {
expect(Tempassert).assertEqual("onConnect");
}, 500)
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_0400-------------");
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_0500
* @tc.name The bundleName passed in is different from the local
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_0500", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0500-------------");
TAG = "FreeInstall_FA_ConnectAbility_0500";
setTimeout(async () => {
var request5 = {
"bundleName": "com.example.different.hmservice",
"abilityName": "com.example.different.ServiceAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request5);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
}, 500)
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_0500-------------");
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_0600
* @tc.name Pass in an empty bundleName
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_0600", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0600-------------");
TAG = "FreeInstall_FA_ConnectAbility_0600";
setTimeout(async () => {
var request6 = {
"bundleName": "",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "myapplication1",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request6);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
}, 500)
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_0600-------------");
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_0700
* @tc.name Pass in an empty abilityName
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_0700", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0700-------------");
TAG = "FreeInstall_FA_ConnectAbility_0700";
setTimeout(async () => {
var request7 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "",
"moduleName": "myapplication1",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request7);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
}, 500)
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_0700-------------");
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_0800
* @tc.name Incorrect deviceid passed in
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_0800", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0800-------------");
TAG = "FreeInstall_FA_ConnectAbility_0800";
setTimeout(async () => {
var request8 = {
"deviceId": "xxxxxx",
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication2.ServiceAbility",
"moduleName": "myapplication2",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request8);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
}, 500)
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_0800-------------");
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_0900
* @tc.name Incorrect bundleName passed in
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_0900", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_0900-------------");
TAG = "FreeInstall_FA_ConnectAbility_0900";
setTimeout(async () => {
var request9 = {
"bundleName": "com.example.xxx.hmservice",
"abilityName": "com.example.myapplication2.ServiceAbility",
"moduleName": "myapplication2",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request9);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
}, 500)
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_0900-------------");
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1000
* @tc.name Incorrect flags passed in,atomic service does not exist locally
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_1000", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1000-------------");
TAG = "FreeInstall_FA_ConnectAbility_1000";
setTimeout(async () => {
var request10 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication2.ServiceAbility",
"moduleName": "myapplication2",
"flags": 1111111,
}
connectabillity(TAG, request10);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
}, 500)
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_1000-------------");
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1100
* @tc.name Incorrect flags passed in,atomic service exists locally
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_ConnectAbility_1100", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1100-------------");
TAG = "FreeInstall_FA_ConnectAbility_1100";
var cmdapp2 = "bm install -p data/test/ConnectFaMyApplication2.hap";
abilityDelegator.executeShellCommand(cmdapp2, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
setTimeout(async () => {
var request11 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication2.ServiceAbility",
"moduleName": "myapplication2",
"flags": "11",
}
connectabillity(TAG, request11);
setTimeout(() => {
expect(Tempassert).assertEqual("onConnect");
}, 500)
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_1000-------------");
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1200
* @tc.name No atomic service under path
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_1200", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1200-------------");
TAG = "FreeInstall_FA_ConnectAbility_1200";
var cmdrm = "rm -r /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/*";
abilityDelegator.executeShellCommand(cmdrm, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
setTimeout(async () => {
var request12 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "myapplication3",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request12);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
}, 500)
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_1200-------------");
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1300
* @tc.name The application is not in the foreground [start MainAbility2 first, then connect]
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_1300", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1300-------------");
TAG = "FreeInstall_FA_ConnectAbility_1300";
var str = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.MainAbility2",
}
}
console.info(TAG + " startmainability2 str: " + JSON.stringify(str));
featureAbility.startAbility(str)
.then((data) => {
console.info(TAG + " startmainability2 successful. Data: " + JSON.stringify(data))
}).catch((error) => {
console.error(TAG + " startmainability2 failed. Cause: " + JSON.stringify(error));
})
setTimeout(async () => {
var request13 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "myapplication3",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request13);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
}, 500)
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_1300-------------");
done();
});
})
}
\ No newline at end of file
......@@ -24,186 +24,338 @@ import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry
export default function ConnectAbilityTest1() {
var TAG = "";
var Tempassert = "";
var abilityDelegator = undefined
var TAG = "";
var Tempassert = "";
var abilityDelegator = undefined
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
describe('FreeInstall_FA_ConnectAbilityOne', function () {
beforeAll(async function (done) {
console.info("FreeInstall_FA_ConnectAbility before all called");
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var cmd = "bm install -p data/test/MockService.hap";
console.info("cmd : " + cmd)
console.info(TAG + " abilityDelegator : " + JSON.stringify(abilityDelegator));
abilityDelegator.executeShellCommand(cmd, (err: any, d: any) => {
console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
abilityDelegator.executeShellCommand(cmd1, (err: any, d: any) => {
console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
abilityDelegator.executeShellCommand(cmd2, (err: any, d: any) => {
console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
done();
})
});
afterEach(async function (done) {
console.info("FreeInstall_FA_ConnectAbility after each called");
Tempassert = ""
await sleep(1000);
if ("FreeInstall_FA_ConnectAbility_1600" === TAG) {
var cmd14 = "bm uninstall -n com.ohos.hag.famanager";
abilityDelegator.executeShellCommand(cmd14, (err: any, d: any) => {
console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
}
await sleep(500);
describe('FreeInstall_FA_ConnectAbilityOne', function () {
beforeAll(async function (done) {
console.info("FreeInstall_FA_ConnectAbility before all called");
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var cmd = "bm install -p data/test/MockService.hap";
console.info("cmd : " + cmd)
console.info(TAG + " abilityDelegator : " + JSON.stringify(abilityDelegator));
abilityDelegator.executeShellCommand(cmd, (err: any, d: any) => {
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";
abilityDelegator.executeShellCommand(cmd1, (err: any, d: any) => {
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";
abilityDelegator.executeShellCommand(cmd2, (err: any, d: any) => {
console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
done();
});
function tips(msg) {
Prompt.showToast({
message: msg,
duration: 2000,
bottom: '150px'
});
})
});
afterEach(async function (done) {
console.info("FreeInstall_FA_ConnectAbility after each called");
Tempassert = ""
if ("FreeInstall_FA_ConnectAbility_1600" === TAG) {
var cmd14 = "bm uninstall -n com.ohos.hag.famanager";
abilityDelegator.executeShellCommand(cmd14, (err: any, d: any) => {
console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
}
done();
});
function tips(msg) {
Prompt.showToast({
message: msg,
duration: 2000,
bottom: '150px'
});
}
async function connectabillity(msg, request) {
console.info(msg + "START");
let options = {
onConnect: function (element, proxy) {
console.info("FreeInstall_FA_ConnectAbility onConnect success!!!")
console.info(msg + " onConnect success!!! ");
console.info(msg + " onConnect: " + JSON.stringify(element));
console.info(msg + " onConnect: " + JSON.stringify(proxy));
if (proxy == null) {
console.error("FreeInstall_FA_ConnectAbility proxy null");
return;
}
let option = new rpc.MessageOption();
let data = new rpc.MessageParcel();
let reply = new rpc.MessageParcel();
data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver");
proxy.sendRequest(0, data, reply, option);
Tempassert = "onConnect";
tips("连接成功");
},
onDisconnect: function (element) {
console.info("FreeInstall_FA_ConnectAbility onDisconnect success!!!")
console.info(msg + " onDisconnect success!!!");
console.info(msg + " onDisconnect: " + JSON.stringify(element));
Tempassert = "onDisconnect";
tips("连接断开");
},
onFailed: function (code) {
console.info("FreeInstall_FA_ConnectAbility onFailed!!!")
console.info(msg + " onFailed!!! ");
console.info(msg + " onFailed: " + JSON.stringify(code));
Tempassert = "onFailed";
tips("连接失败");
}
}
let connection = await featureAbility.connectAbility(request, options);
console.info(msg + "request:" + JSON.stringify(request));
console.info(msg + "options:" + JSON.stringify(options));
console.info(msg + "connection=" + JSON.stringify(connection));
console.info(msg + "END");
}
async function connectabillity(msg, request) {
console.info(msg + "START");
let options = {
onConnect: function (element, proxy) {
console.info("FreeInstall_FA_ConnectAbility onConnect success!!!")
console.info(msg + " onConnect success!!! ");
console.info(msg + " onConnect: " + JSON.stringify(element));
console.info(msg + " onConnect: " + JSON.stringify(proxy));
if (proxy == null) {
console.error("FreeInstall_FA_ConnectAbility proxy null");
return;
}
let option = new rpc.MessageOption();
let data = new rpc.MessageParcel();
let reply = new rpc.MessageParcel();
data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver");
proxy.sendRequest(0, data, reply, option);
Tempassert = "onConnect";
tips("连接成功");
},
onDisconnect: function (element) {
console.info("FreeInstall_FA_ConnectAbility onDisconnect success!!!")
console.info(msg + " onDisconnect success!!!");
console.info(msg + " onDisconnect: " + JSON.stringify(element));
Tempassert = "onDisconnect";
tips("连接断开");
},
onFailed: function (code) {
console.info("FreeInstall_FA_ConnectAbility onFailed!!!")
console.info(msg + " onFailed!!! ");
console.info(msg + " onFailed: " + JSON.stringify(code));
Tempassert = "onFailed";
tips("连接失败");
}
}
let connection = await featureAbility.connectAbility(request, options);
console.info(msg + "request:" + JSON.stringify(request));
console.info(msg + "options:" + JSON.stringify(options));
console.info(msg + "connection=" + JSON.stringify(connection));
console.info(msg + "END");
/*
* @tc.number FreeInstall_FA_ConnectAbility_1500
* @tc.name The application is not in the foreground,
[start another project first, then connect,atomic service does not exist locally]
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_1500", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1500-------------");
TAG = "FreeInstall_FA_ConnectAbility_1500";
var cmddif = "bm install -p data/test/ConnectDifferentApplication.hap";
abilityDelegator.executeShellCommand(cmddif, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
var str = {
"want": {
"bundleName": "com.example.different.hmservice",
"abilityName": "MainAbility",
}
};
featureAbility.startAbility(str)
.then((data) => {
console.info(TAG + " startother successful. Data: " + JSON.stringify(data))
}).catch((error) => {
console.error(TAG + " startother failed. Cause: " + JSON.stringify(error));
})
setTimeout(async () => {
var request15 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication5.ServiceAbility5",
"moduleName": "myapplication5",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request15);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
}, 500)
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_1500-------------");
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1600
* @tc.name The application is not in the foreground,
[start another project first, then connect,atomic service exists locally]
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_1600", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1600-------------");
TAG = "FreeInstall_FA_ConnectAbility_1600";
var cmdmyapp4 = "bm install -p data/test/ConnectFaMyApplication4.hap";
abilityDelegator.executeShellCommand(cmdmyapp4, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
var str = {
"want": {
"bundleName": "com.example.different.hmservice",
"abilityName": "MainAbility",
}
};
featureAbility.startAbility(str)
.then((data) => {
console.info(TAG + " startother successful. Data: " + JSON.stringify(data))
}).catch((error) => {
console.error(TAG + " startother failed. Cause: " + JSON.stringify(error));
})
setTimeout(function () {
var request16 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication4.ServiceAbility4",
"moduleName": "myapplication4",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request16);
setTimeout(() => {
expect(Tempassert).assertEqual("onConnect");
}, 500)
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_1600-------------");
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1500
* @tc.name The application is not in the foreground,
[start another project first, then connect,atomic service does not exist locally]
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_1500", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1500-------------");
TAG = "FreeInstall_FA_ConnectAbility_1500";
var cmddif = "bm install -p data/test/ConnectDifferentApplication.hap";
abilityDelegator.executeShellCommand(cmddif, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(1000);
var str = {
"want": {
"bundleName": "com.example.different.hmservice",
"abilityName": "MainAbility",
}
};
featureAbility.startAbility(str)
.then((data) => {
console.info(TAG + " startother successful. Data: " + JSON.stringify(data))
}).catch((error) => {
console.error(TAG + " startother failed. Cause: " + JSON.stringify(error));
})
await sleep(1500);
var request15 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication5.ServiceAbility5",
"moduleName": "myapplication5",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request15);
setTimeout(function () {
expect(Tempassert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_1500-------------");
done();
}, 1500);
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1600
* @tc.name The application is not in the foreground,
[start another project first, then connect,atomic service exists locally]
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_1600", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1600-------------");
TAG = "FreeInstall_FA_ConnectAbility_1600";
var cmdmyapp4 = "bm install -p data/test/ConnectFaMyApplication4.hap";
abilityDelegator.executeShellCommand(cmdmyapp4, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(1000);
var str = {
"want": {
"bundleName": "com.example.different.hmservice",
"abilityName": "MainAbility",
}
};
featureAbility.startAbility(str)
.then((data) => {
console.info(TAG + " startother successful. Data: " + JSON.stringify(data))
}).catch((error) => {
console.error(TAG + " startother failed. Cause: " + JSON.stringify(error));
})
await sleep(1500);
var request16 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication4.ServiceAbility4",
"moduleName": "myapplication4",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request16);
setTimeout(function () {
expect(Tempassert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_1600-------------");
done();
}, 1500);
});
}
)
/*
* @tc.number FreeInstall_FA_ConnectAbility_1400
* @tc.name The application is not in the foreground [start myapp2 first, then connect]
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_1400", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1400-------------");
TAG = "FreeInstall_FA_ConnectAbility_1400";
var str = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication2.MainAbility",
}
}
console.info(TAG + " startmyapp2 str: " + JSON.stringify(str));
featureAbility.startAbility(str)
.then((data) => {
console.info(TAG + " startmyapp2 successful. Data: " + JSON.stringify(data))
}).catch((error) => {
console.error(TAG + " startmyapp2 failed. Cause: " + JSON.stringify(error));
})
setTimeout(() => {
var 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(async () => {
expect(Tempassert).assertEqual("onFailed");
}, 500);
}, 2000)
done();
console.log("------------end FreeInstall_FA_ConnectAbility_1400-------------");
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1700
* @tc.name Do not pass flags, connect to the service of another project
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_ConnectAbility_1700", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1700-------------");
TAG = "FreeInstall_FA_ConnectAbility_1700";
var cmddif = "bm install -p data/test/ConnectDifferentApplication.hap";
await abilityDelegator.executeShellCommand(cmddif, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
setTimeout(() => {
var request17 = {
"bundleName": "com.example.different.hmservice",
"abilityName": "com.example.different.ServiceAbility",
"moduleName": "entry",
}
connectabillity(TAG, request17);
setTimeout(() => {
expect(Tempassert).assertEqual("onConnect");
}, 500);
}, 2000)
console.log("------------end FreeInstall_FA_ConnectAbility_1700-------------");
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1800
* @tc.name Incorrect moduleName passed in
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_1800", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1800-------------");
TAG = "FreeInstall_FA_ConnectAbility_1800";
setTimeout(async () => {
var request18 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "xxxxx",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request18);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
}, 500)
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_1800-------------");
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_1900
* @tc.name The target is atomized as hapA, and hapB is placed under the path
* @tc.desc Function test
* @tc.level 1
*/
it("FreeInstall_FA_ConnectAbility_1900", 0, async function (done) {
console.log("------------start 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/" +
"haps/entry/files";
await abilityDelegator.executeShellCommand(cmdmyapp5, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
setTimeout(async () => {
var request19 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "myapplication3",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request19);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
}, 500)
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_1900-------------");
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_2000
* @tc.name Pass in parameters
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_ConnectAbility_2000", 0, async function (done) {
console.log("------------start 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/" +
"haps/entry/files";
abilityDelegator.executeShellCommand(cmdmyapp5, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
setTimeout(async () => {
var request20 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication5.ServiceAbility5",
"moduleName": "myapplication5",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
"parameters": {
"name": 1111, "key1": "value1", "site": "nice to meet you!"
},
}
connectabillity(TAG, request20);
setTimeout(() => {
expect(Tempassert).assertEqual("onConnect");
}, 500)
}, 4000)
done();
console.log("------------end FreeInstall_FA_ConnectAbility_2000-------------");
});
}
)
}
\ No newline at end of file
......@@ -12,13 +12,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import ConnectAbilityTest1 from './ConnectAbilityTest1'
import ConnectAbilityTest from './ConnectAbilityTest'
import connectAbilityTest_PA from './connectAbilityTest_PA'
import ConnectAbilityTest from './ConnectAbilityTest'
import ConnectAbilityTest1 from './ConnectAbilityTest1'
export default function testsuite() {
ConnectAbilityTest1();
ConnectAbilityTest();
connectAbilityTest_PA();
}
\ No newline at end of file
export default function testsuite() {
connectAbilityTest_PA();
ConnectAbilityTest();
ConnectAbilityTest1();
}
......@@ -26,7 +26,7 @@ export default function connectAbilityTest_PA() {
var subscriber;
var subscribeInfo = {
events: ["service_event", "service2_event", "service3_event", "service4_event", "service5_event",
"service6_event", "service7_event", "service8_event", "service9_event", "service10_event", "service11_event"]
"service6_event", "service7_event", "service8_event", "service9_event", "service10_event", "service11_event"]
};
function sleep(time) {
......@@ -39,8 +39,8 @@ export default function connectAbilityTest_PA() {
.then((data) => {
console.info(msg + ' startService successful. Data: ' + JSON.stringify(data));
}).catch((error) => {
console.error(msg + ' startService failed. Cause: ' + JSON.stringify(error));
})
console.error(msg + ' startService failed. Cause: ' + JSON.stringify(error));
})
}
function checkParameters(msg1, data) {
......@@ -144,14 +144,14 @@ export default function connectAbilityTest_PA() {
dataAssert = ""
await sleep(1000);
if ("FreeInstall_FA_ConnectAbility_PA_1100" === TAG) {
var cmd14 = "bm uninstall -n com.ohos.hag.famanager";
abilityDelegator.executeShellCommand(cmd14, (err: any, d: any) => {
console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
}
await sleep(500);
done();
});
var cmd14 = "bm uninstall -n com.ohos.hag.famanager";
abilityDelegator.executeShellCommand(cmd14, (err: any, d: any) => {
console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
}
await sleep(500);
done();
});
/*
* @tc.number FreeInstall_FA_ConnectAbility_PA_0100
......@@ -163,24 +163,23 @@ export default function connectAbilityTest_PA() {
console.log("------------start FreeInstall_FA_ConnectAbility_PA_0100-------------");
TAG = "FreeInstall_FA_ConnectAbility_PA_0100";
var cmdmyapp7 = "cp data/test/ConnectFaMyApplication7.hap /data/app/el2/100/base/com.ohos.hag.famanager/" +
"haps/entry/files";
"haps/entry/files";
abilityDelegator.executeShellCommand(cmdmyapp7, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var str1 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility",
}
};
startService(TAG, str1);
setTimeout(function () {
setTimeout(async () => {
var str1 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility",
}
};
startService(TAG, str1);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0100-------------");
done();
}, 4000);
done();
});
/*
......@@ -196,20 +195,19 @@ export default function connectAbilityTest_PA() {
abilityDelegator.executeShellCommand(cmdapp9, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var str2 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility2",
}
};
startService(TAG, str2);
setTimeout(function () {
setTimeout(async () => {
var str2 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility2",
}
};
startService(TAG, str2);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0200-------------");
done();
}, 4000);
done();
});
/*
......@@ -221,19 +219,19 @@ export default function connectAbilityTest_PA() {
it("FreeInstall_FA_ConnectAbility_PA_0300", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_PA_0300-------------");
TAG = "FreeInstall_FA_ConnectAbility_PA_0300";
var str3 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility3",
}
};
startService(TAG, str3);
setTimeout(function () {
setTimeout(async () => {
var str3 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility3",
}
};
startService(TAG, str3);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0300-------------");
done();
}, 4000);
done();
});
/*
......@@ -244,20 +242,20 @@ export default function connectAbilityTest_PA() {
*/
it("FreeInstall_FA_ConnectAbility_PA_0400", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_PA_0400-------------");
TAG = "FreeInstall_FA_ConnectAbility_PA_0400";
var str4 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility4",
}
};
startService(TAG, str4);
setTimeout(function () {
setTimeout(async () => {
TAG = "FreeInstall_FA_ConnectAbility_PA_0400";
var str4 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility4",
}
};
startService(TAG, str4);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0400-------------");
done();
}, 4000);
done();
});
/*
......@@ -273,20 +271,19 @@ export default function connectAbilityTest_PA() {
abilityDelegator.executeShellCommand(cmdin, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var str5 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility5",
}
};
startService(TAG, str5);
setTimeout(function () {
setTimeout(async () => {
var str5 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility5",
}
};
startService(TAG, str5);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0500-------------");
done();
}, 4000);
done();
});
/*
......@@ -298,19 +295,19 @@ export default function connectAbilityTest_PA() {
it("FreeInstall_FA_ConnectAbility_PA_0600", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_PA_0600-------------");
TAG = "FreeInstall_FA_ConnectAbility_PA_0600";
var str6 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility6",
}
};
startService(TAG, str6);
setTimeout(function () {
setTimeout(async () => {
var str6 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility6",
}
};
startService(TAG, str6);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0600-------------");
done();
}, 4000);
done();
});
/*
......@@ -322,19 +319,20 @@ export default function connectAbilityTest_PA() {
it("FreeInstall_FA_ConnectAbility_PA_0700", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_PA_0700-------------");
TAG = "FreeInstall_FA_ConnectAbility_PA_0700";
var str7 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility7",
}
};
startService(TAG, str7);
setTimeout(function () {
setTimeout(async () => {
var str7 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility7",
}
};
startService(TAG, str7);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0700-------------");
done();
}, 4000);
done();
});
/*
......@@ -346,19 +344,20 @@ export default function connectAbilityTest_PA() {
it("FreeInstall_FA_ConnectAbility_PA_0800", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_PA_0800-------------");
TAG = "FreeInstall_FA_ConnectAbility_PA_0800";
var str8 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility8",
}
};
startService(TAG, str8);
setTimeout(function () {
setTimeout(async () => {
var str8 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility8",
}
};
startService(TAG, str8);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0800-------------");
done();
}, 4000);
done();
});
/*
......@@ -374,20 +373,21 @@ export default function connectAbilityTest_PA() {
abilityDelegator.executeShellCommand(cmdrm, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var str9 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility9",
}
};
startService(TAG, str9);
setTimeout(function () {
setTimeout(async () => {
await sleep(500);
var str9 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility9",
}
};
startService(TAG, str9);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0900-------------");
done();
}, 4000);
done();
});
/*
......@@ -399,19 +399,20 @@ export default function connectAbilityTest_PA() {
it("FreeInstall_FA_ConnectAbility_PA_1000", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_PA_1000-------------");
TAG = "FreeInstall_FA_ConnectAbility_PA_1000";
var str10 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility10",
}
};
startService(TAG, str10);
setTimeout(function () {
setTimeout(async () => {
var str10 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility10",
}
};
startService(TAG, str10);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_1000-------------");
done();
}, 4000);
done();
});
/*
......@@ -424,24 +425,24 @@ export default function connectAbilityTest_PA() {
console.log("------------start FreeInstall_FA_ConnectAbility_PA_1100-------------");
TAG = "FreeInstall_FA_ConnectAbility_PA_1100";
var cmdmyapp8 = "cp data/test/ConnectFaMyApplication8.hap /data/app/el2/100/base/com.ohos.hag.famanager/" +
"haps/entry/files";
"haps/entry/files";
abilityDelegator.executeShellCommand(cmdmyapp8, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(1000);
var str11 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility11",
}
};
startService(TAG, str11);
setTimeout(function () {
setTimeout(async () => {
var str11 = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility11",
}
};
startService(TAG, str11);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_1100-------------");
done();
}, 4000);
done();
});
}
)
......
......@@ -17,7 +17,7 @@ import featureAbility from '@ohos.ability.featureAbility';
export default {
onCreate() {
console.info('Application onCreate')
setTimeout(function () {
setTimeout(()=> {
featureAbility.terminateSelf()
.then((data) => {
console.info('[Demo] MainAbility2 terminateself succeeded: ' + data);
......
......@@ -23,214 +23,211 @@ import commonEvent from '@ohos.commonEvent';
export default function startAbilityTest2() {
describe('startAbilityTest2', function () {
describe('startAbilityTest2', function () {
var TAG = "";
var TAG = "";
var delegator = AbilityDelegatorRegistry.getAbilityDelegator();
var delegator = AbilityDelegatorRegistry.getAbilityDelegator();
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
beforeAll(async function (done) {
console.info("StartAbilityForResult before all called");
var cmd = "bm install -p data/test/MockService.hap";
console.info("cmd : " + cmd)
delegator.executeShellCommand(cmd, (err: any, d: any) => {
console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
delegator.executeShellCommand(cmd1, (err: any, d: any) => {
console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
delegator.executeShellCommand(cmd2, (err: any, d: any) => {
console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var cmd3 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" +
"entry/files";
delegator.executeShellCommand(cmd3, (err: any, d: any) => {
console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
done();
})
});
beforeAll(async function (done) {
console.info("StartAbilityForResult before all called");
var cmd = "bm install -p data/test/MockService.hap";
console.info("cmd : " + cmd)
delegator.executeShellCommand(cmd, (err: any, d: any) => {
console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
delegator.executeShellCommand(cmd1, (err: any, d: any) => {
console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
delegator.executeShellCommand(cmd2, (err: any, d: any) => {
console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var cmd3 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" +
"entry/files";
delegator.executeShellCommand(cmd3, (err: any, d: any) => {
console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
done();
})
});
afterEach(async function (done) {
console.info("StartAbilityTest after each called");
if ("FreeInstall_FA_Local_StartAbility_2000" === TAG) {
var cmd4 = "bm uninstall -n com.example.qianyiyingyong.hmservice";
delegator.executeShellCommand(cmd4, (err: any, d: any) => {
console.info("executeShellCommand4 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
}
afterEach(async function (done) {
console.info("StartAbilityTest after each called");
if ("FreeInstall_FA_Local_StartAbility_2000" === TAG) {
var cmd4 = "bm uninstall -n com.example.qianyiyingyong.hmservice";
delegator.executeShellCommand(cmd4, (err: any, d: any) => {
console.info("executeShellCommand4 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
}
if ("FreeInstall_FA_Local_StartAbility_2500" === TAG) {
var cmd5 = "bm uninstall -n com.ohos.hag.famanager";
delegator.executeShellCommand(cmd5, (err: any, d: any) => {
console.info("executeShellCommand5 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
}
await sleep(500);
done();
});
if ("FreeInstall_FA_Local_StartAbility_2500" === TAG) {
var cmd5 = "bm uninstall -n com.ohos.hag.famanager";
delegator.executeShellCommand(cmd5, (err: any, d: any) => {
console.info("executeShellCommand5 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
}
await sleep(500);
done();
});
/*
* @tc.number FreeInstall_FA_Local_StartAbility_1900
* @tc.name The current service is not in the foreground. Page a jumps to page B first.
There are HAP packages that need not be installed under the specified path
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_Local_StartAbility_1900", 0, async function (done) {
console.info("------------start FreeInstall_FA_Local_StartAbility_1900-------------");
TAG = "FreeInstall_FA_Local_StartAbility_1900";
let wrong;
var str1 = {
'want': {
"bundleName": "com.open.harmony.startAbility",
"abilityName": "com.open.harmony.startAbility.PageAbility",
"moduleName": "entry",
}
}
featureAbility.startAbility(str1)
.then((data) => {
console.info(TAG + ' StartAbility successful. Promise Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error));
})
await sleep(3000);
var str = {
'want': {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND
}
}
await featureAbility.startAbility(str).then((data) => {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
wrong = error;
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
});
await sleep(2000);
expect(wrong.code).assertEqual(13);
console.info("------------end FreeInstall_FA_Local_StartAbility_1900-------------");
done();
/*
* @tc.number FreeInstall_FA_Local_StartAbility_1900
* @tc.name The current service is not in the foreground. Page a jumps to page B first.
There are HAP packages that need not be installed under the specified path
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_Local_StartAbility_1900", 0, async function (done) {
console.info("------------start FreeInstall_FA_Local_StartAbility_1900-------------");
TAG = "FreeInstall_FA_Local_StartAbility_1900";
let wrong;
var str1 = {
'want': {
"bundleName": "com.open.harmony.startAbility",
"abilityName": "com.open.harmony.startAbility.PageAbility",
"moduleName": "entry",
}
}
featureAbility.startAbility(str1)
.then((data) => {
console.info(TAG + ' StartAbility successful. Promise Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error));
})
setTimeout(async () => {
var str = {
'want': {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND
}
}
await featureAbility.startAbility(str).then((data) => {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
wrong = error;
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
});
expect(wrong.code).assertEqual(13);
}, 2000)
console.info("------------end FreeInstall_FA_Local_StartAbility_1900-------------");
done();
});
/*
* @tc.number FreeInstall_FA_Local_StartAbility_2000
* @tc.name The current service is not in the foreground. Page a jumps to page B first.
The atomized HAP package has been installed
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_Local_StartAbility_2000", 0, async function (done) {
console.info("------------start FreeInstall_FA_Local_StartAbility_2000-------------");
TAG = "FreeInstall_FA_Local_StartAbility_2000";
var cmd2000 = "bm install -p data/test/AtomizationFaEntry.hap";
delegator.executeShellCommand(cmd2000, (err: any, d: any) => {
console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
let wrong;
var str1 = {
'want': {
"bundleName": "com.open.harmony.startAbility",
"abilityName": "com.open.harmony.startAbility.PageAbility",
"moduleName": "entry",
}
}
featureAbility.startAbility(str1)
.then((data) => {
console.info(TAG + ' StartAbility successful. Promise Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error));
})
await sleep(3000);
var str = {
'want': {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND
}
}
await featureAbility.startAbility(str).then((data) => {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
wrong = error;
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
});
await sleep(2000);
expect(wrong.code).assertEqual(13);
console.info("------------end FreeInstall_FA_Local_StartAbility_2000-------------");
await sleep(2000);
done();
/*
* @tc.number FreeInstall_FA_Local_StartAbility_2000
* @tc.name The current service is not in the foreground. Page a jumps to page B first.
The atomized HAP package has been installed
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_Local_StartAbility_2000", 0, async function (done) {
console.info("------------start FreeInstall_FA_Local_StartAbility_2000-------------");
TAG = "FreeInstall_FA_Local_StartAbility_2000";
var cmd2000 = "bm install -p data/test/AtomizationFaEntry.hap";
delegator.executeShellCommand(cmd2000, (err: any, d: any) => {
console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
let wrong;
var str1 = {
'want': {
"bundleName": "com.open.harmony.startAbility",
"abilityName": "com.open.harmony.startAbility.PageAbility",
"moduleName": "entry",
}
}
featureAbility.startAbility(str1)
.then((data) => {
console.info(TAG + ' StartAbility successful. Promise Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error));
})
setTimeout(async () => {
var str = {
'want': {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND
}
}
await featureAbility.startAbility(str).then((data) => {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
wrong = error;
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
});
await sleep(2000);
expect(wrong.code).assertEqual(13);
}, 2000)
console.info("------------end FreeInstall_FA_Local_StartAbility_2000-------------");
done();
});
/*
* @tc.number FreeInstall_FA_Local_StartAbility_2500
* @tc.name FA Service Center installation free timeout
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_Local_StartAbility_2500", 0, async function (done) {
console.info("------------start FreeInstall_FA_Local_StartAbility_2500-------------");
TAG = "FreeInstall_FA_Local_StartAbility_2500";
var cmd2500 = "bm uninstall -n com.ohos.hag.famanager";
delegator.executeShellCommand(cmd2500, (err: any, d: any) => {
console.info("executeShellCommand2500 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var cmd2501 = "bm install -p data/test/MockServiceTimeout.hap";
delegator.executeShellCommand(cmd2501, (err: any, d: any) => {
console.info("executeShellCommand2501 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var cmd2502 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
delegator.executeShellCommand(cmd2502, (err: any, d: any) => {
console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var cmd2503 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
delegator.executeShellCommand(cmd2503, (err: any, d: any) => {
console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
var cmd2504 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps" +
"/entry/files";
delegator.executeShellCommand(cmd2504, (err: any, d: any) => {
console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
let wrong;
var str = {
'want': {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
}
featureAbility.startAbility(str).then((data) => {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
wrong = error;
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
});
await sleep(35000);
expect(wrong.code).assertEqual(3);
console.info("------------end FreeInstall_FA_Local_StartAbility_2500-------------");
done();
/*
* @tc.number FreeInstall_FA_Local_StartAbility_2500
* @tc.name FA Service Center installation free timeout
* @tc.desc Function test
* @tc.level 0
*/
it("FreeInstall_FA_Local_StartAbility_2500", 0, async function (done) {
console.info("------------start FreeInstall_FA_Local_StartAbility_2500-------------");
TAG = "FreeInstall_FA_Local_StartAbility_2500";
var cmd2500 = "bm uninstall -n com.ohos.hag.famanager";
delegator.executeShellCommand(cmd2500, (err: any, d: any) => {
console.info("executeShellCommand2500 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
var cmd2501 = "bm install -p data/test/MockServiceTimeout.hap";
delegator.executeShellCommand(cmd2501, (err: any, d: any) => {
console.info("executeShellCommand2501 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
var cmd2502 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
delegator.executeShellCommand(cmd2502, (err: any, d: any) => {
console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
var cmd2503 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
delegator.executeShellCommand(cmd2503, (err: any, d: any) => {
console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
var cmd2504 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps" +
"/entry/files";
delegator.executeShellCommand(cmd2504, (err: any, d: any) => {
console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
setTimeout(async () => {
let wrong;
var str = {
'want': {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
}
featureAbility.startAbility(str).then((data) => {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => {
wrong = error;
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
});
await sleep(35000);
expect(wrong.code).assertEqual(3);
}, 2000)
console.info("------------end FreeInstall_FA_Local_StartAbility_2500-------------");
done();
});
console.info("-------------FA model--> startAbilityXTS Test end----------------")
})
console.info("-------------FA model--> startAbilityXTS Test end----------------")
})
}
\ No newline at end of file
......@@ -22,189 +22,191 @@ import wantConstant from '@ohos.ability.wantConstant';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
export default function StartAbilityTest() {
var TAG = "";
var TAG = "";
describe('StartAbilityTest', function () {
var delegator = AbilityDelegatorRegistry.getAbilityDelegator();
beforeAll(async function (done) {
console.info("StartAbilityTest before all called");
var cmd = "bm install -p data/test/MockService.hap";
console.info("cmd : " + cmd)
delegator.executeShellCommand(cmd, (err: any, d: any) => {
console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
var cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
delegator.executeShellCommand(cmd1, (err: any, d: any) => {
console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
var cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
delegator.executeShellCommand(cmd2, (err: any, d: any) => {
console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
var cmd3 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" +
"entry/files";
delegator.executeShellCommand(cmd3, (err: any, d: any) => {
console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
done();
})
});
describe('StartAbilityTest', function () {
var delegator = AbilityDelegatorRegistry.getAbilityDelegator();
beforeAll(async function (done) {
console.info("StartAbilityTest before all called");
var cmd = "bm install -p data/test/MockService.hap";
console.info("cmd : " + cmd)
delegator.executeShellCommand(cmd, (err: any, d: any) => {
console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
var cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
delegator.executeShellCommand(cmd1, (err: any, d: any) => {
console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
var cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
delegator.executeShellCommand(cmd2, (err: any, d: any) => {
console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
var cmd3 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" +
"entry/files";
delegator.executeShellCommand(cmd3, (err: any, d: any) => {
console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
done();
})
});
afterEach(async function (done) {
console.info("StartAbilityTest after each called");
if ("FreeInstall_FA_StartAbility_2800" === TAG || "FreeInstall_FA_StartAbility_3900") {
var cmd5 = "bm uninstall -n com.example.qianyiyingyong.hmservice";
delegator.executeShellCommand(cmd5, (err: any, d: any) => {
console.info("executeShellCommand5: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
}
await Utils.sleep(500);
if ("FreeInstall_FA_StartAbility_3900" === TAG) {
var cmd4 = "bm uninstall -n com.ohos.hag.famanager";
delegator.executeShellCommand(cmd4, (err: any, d: any) => {
console.info("executeShellCommand4: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
}
await Utils.sleep(500);
done();
});
afterEach(async function (done) {
console.info("StartAbilityTest after each called");
if ("FreeInstall_FA_StartAbility_2800" === TAG || "FreeInstall_FA_StartAbility_3900") {
var cmd5 = "bm uninstall -n com.example.qianyiyingyong.hmservice";
delegator.executeShellCommand(cmd5, (err: any, d: any) => {
console.info("executeShellCommand5: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
}
await Utils.sleep(500);
if ("FreeInstall_FA_StartAbility_3900" === TAG) {
var cmd4 = "bm uninstall -n com.ohos.hag.famanager";
delegator.executeShellCommand(cmd4, (err: any, d: any) => {
console.info("executeShellCommand4: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
}
await Utils.sleep(500);
done();
});
/*
* @tc.number: FreeInstall_FA_StartAbility_2600
* @tc.name: startAbility: NoTargetBundleList,free install successfully.
* @tc.desc: Function test
* @tc.level 0
*/
it("FreeInstall_FA_StartAbility_2600", 0, async function (done) {
console.log("------------start FreeInstall_FA_StartAbility_2600-------------");
TAG = "FreeInstall_FA_StartAbility_2600";
let details;
var str = {
'want': {
"deviceId": "",
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
}
await featureAbility.startAbility(str).then((data) => {
details = data;
console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error));
})
await Utils.sleep(2000);
expect(details).assertEqual(0);
done();
});
/*
* @tc.number: FreeInstall_FA_StartAbility_2600
* @tc.name: startAbility: NoTargetBundleList,free install successfully.
* @tc.desc: Function test
* @tc.level 0
*/
it("FreeInstall_FA_StartAbility_2600", 0, async function (done) {
console.log("------------start FreeInstall_FA_StartAbility_2600-------------");
TAG = "FreeInstall_FA_StartAbility_2600";
setTimeout(async () => {
let details;
var str = {
'want': {
"deviceId": "",
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
}
await featureAbility.startAbility(str).then((data) => {
details = data;
console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error));
})
expect(details).assertEqual(0);
}, 2000)
done();
});
/*
* @tc.number: FreeInstall_FA_StartAbility_2700
* @tc.name: startAbility: NoTargetBundleList and yuanzihua already installed,startAbility successfully.
* @tc.desc: Function test
* @tc.level 0
*/
it("FreeInstall_FA_StartAbility_2700", 0, async function (done) {
console.log("------------start FreeInstall_FA_StartAbility_2700-------------");
TAG = "FreeInstall_FA_StartAbility_2700";
var cmd6 = "bm install -p data/test/AtomizationFaEntry.hap";
delegator.executeShellCommand(cmd6, (err: any, d: any) => {
console.info("executeShellCommand6: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
let details;
var str = {
'want': {
"deviceId": "",
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
}
await featureAbility.startAbility(str).then((data) => {
details = data;
console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error));
})
await Utils.sleep(2000);
expect(details).assertEqual(0);
done();
});
/*
* @tc.number: FreeInstall_FA_StartAbility_2700
* @tc.name: startAbility: NoTargetBundleList and yuanzihua already installed,startAbility successfully.
* @tc.desc: Function test
* @tc.level 0
*/
it("FreeInstall_FA_StartAbility_2700", 0, async function (done) {
console.log("------------start FreeInstall_FA_StartAbility_2700-------------");
TAG = "FreeInstall_FA_StartAbility_2700";
var cmd6 = "bm install -p data/test/AtomizationFaEntry.hap";
delegator.executeShellCommand(cmd6, (err: any, d: any) => {
console.info("executeShellCommand6: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
setTimeout(async () => {
let details;
var str = {
'want': {
"deviceId": "",
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
}
await featureAbility.startAbility(str).then((data) => {
details = data;
console.info(TAG + ' StartAbility2700 successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbility2700 failed. error: ' + JSON.stringify(error));
})
expect(details).assertEqual(0);
}, 2000)
done();
});
/*
* @tc.number: FreeInstall_FA_StartAbility_2800
* @tc.name: startAbility: The same application does not need to check targetbundlelist,
start feature hap successfully.
* @tc.desc: Function test
* @tc.level 0
*/
it("FreeInstall_FA_StartAbility_2800", 0, async function (done) {
console.log("------------start FreeInstall_FA_StartAbility_2800-------------");
TAG = "FreeInstall_FA_StartAbility_2800";
var cmd7 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationFaEntry.hap";
delegator.executeShellCommand(cmd7, (err: any, d: any) => {
console.info("executeShellCommand7 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
var cmd8 = "cp data/test/FaMyApplication1.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" +
"entry/files";
delegator.executeShellCommand(cmd8, (err: any, d: any) => {
console.info("executeShellCommand8 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
let details;
var str = {
'want': {
"bundleName": "com.open.harmony.startAbility",
"abilityName": "com.example.myapplication1.MainAbility1",
"moduleName": "myapplication1",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
}
await featureAbility.startAbility(str).then((data) => {
details = data;
console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error));
})
await Utils.sleep(2000);
expect(details).assertEqual(0);
done();
});
/*
* @tc.number: FreeInstall_FA_StartAbility_2800
* @tc.name: startAbility: The same application does not need to check targetbundlelist,
start feature hap successfully.
* @tc.desc: Function test
* @tc.level 0
*/
it("FreeInstall_FA_StartAbility_2800", 0, async function (done) {
console.log("------------start FreeInstall_FA_StartAbility_2800-------------");
TAG = "FreeInstall_FA_StartAbility_2800";
var cmd7 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationFaEntry.hap";
delegator.executeShellCommand(cmd7, (err: any, d: any) => {
console.info("executeShellCommand7 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
var cmd8 = "cp data/test/FaMyApplication1.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" +
"entry/files";
delegator.executeShellCommand(cmd8, (err: any, d: any) => {
console.info("executeShellCommand8 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
setTimeout(async () => {
let details;
var str = {
'want': {
"bundleName": "com.open.harmony.startAbility",
"abilityName": "com.example.myapplication1.MainAbility1",
"moduleName": "myapplication1",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
}
await featureAbility.startAbility(str).then((data) => {
details = data;
console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error));
})
expect(details).assertEqual(0);
}, 2000)
done();
});
/*
* @tc.number: FreeInstall_FA_StartAbility_3900
* @tc.name: startAbility: The same application does not need to check targetbundlelist,add BACKGROUND flags
start feature hap successfully.
* @tc.desc: Function test
* @tc.level 0
*/
it("FreeInstall_FA_StartAbility_3900", 0, async function (done) {
console.log("------------start FreeInstall_FA_StartAbility_3900-------------");
TAG = "FreeInstall_FA_StartAbility_3900";
let details;
var str = {
'want': {
"bundleName": "com.open.harmony.startAbility",
"abilityName": "com.example.myapplication1.MainAbility1",
"moduleName": "myapplication1",
"flags": wantConstant.Flags.FLAG_INSTALL_WITH_BACKGROUND_MODE|wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
}
await featureAbility.startAbility(str).then((data) => {
details = data;
console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error));
})
await Utils.sleep(2000);
expect(details).assertEqual(0);
done();
});
})
/*
* @tc.number: FreeInstall_FA_StartAbility_3900
* @tc.name: startAbility: The same application does not need to check targetbundlelist,add BACKGROUND flags
start feature hap successfully.
* @tc.desc: Function test
* @tc.level 0
*/
it("FreeInstall_FA_StartAbility_3900", 0, async function (done) {
console.log("------------start FreeInstall_FA_StartAbility_3900-------------");
TAG = "FreeInstall_FA_StartAbility_3900";
setTimeout(async () => {
let details;
var str = {
'want': {
"bundleName": "com.open.harmony.startAbility",
"abilityName": "com.example.myapplication1.MainAbility1",
"moduleName": "myapplication1",
"flags": wantConstant.Flags.FLAG_INSTALL_WITH_BACKGROUND_MODE | wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
}
await featureAbility.startAbility(str).then((data) => {
details = data;
console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error));
})
expect(details).assertEqual(0);
}, 2000);
done();
});
})
}
\ No newline at end of file
......@@ -46,7 +46,7 @@ export default function StartAbilityForResult2() {
})
await Utils.sleep(500);
var cmd3 = "cp data/test/AtomizationResultFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" +
"entry/files";
"entry/files";
delegator.executeShellCommand(cmd3, (err: any, d: any) => {
console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
done();
......@@ -92,10 +92,10 @@ export default function StartAbilityForResult2() {
}
featureAbility.startAbilityForResult(str1)
.then((data) => {
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
console.info(TAG + ' StartAbilityForResultPromise2200 successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
console.info(TAG + ' StartAbilityForResultPromise2200 failed. Cause: ' + JSON.stringify(error));
})
await Utils.sleep(3000);
let wrong;
var str = {
......@@ -108,10 +108,10 @@ export default function StartAbilityForResult2() {
}
await featureAbility.startAbilityForResult(str)
.then((data) => {
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
console.info(TAG + ' StartAbilityForResultPromise2200 successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
wrong = error;
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
console.info(TAG + ' StartAbilityForResultPromise2200 failed. Cause: ' + JSON.stringify(error));
})
await Utils.sleep(2000);
expect(wrong.code).assertEqual(13);
......@@ -128,7 +128,8 @@ export default function StartAbilityForResult2() {
it("FreeInstall_FA_StartAbilityForResult_2300", 0, async function (done) {
console.log("------------start FreeInstall_FA_StartAbilityForResult_2300-------------");
TAG = "FreeInstall_FA_StartAbilityForResult_2300";
var cmd19 = "bm install -p data/test/AtomizationResultFaEntry.hap";
var cmd19 = "bm install -rp /data/test/AtomizationResultFaEntry.hap";
console.log("------------start FreeInstall_FA_StartAbilityForResult_2300------install-------");
delegator.executeShellCommand(cmd19, (err: any, d: any) => {
console.info("executeShellCommand19: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
......@@ -142,29 +143,30 @@ export default function StartAbilityForResult2() {
}
featureAbility.startAbilityForResult(str1)
.then((data) => {
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
console.info(TAG + ' StartAbilityForResultPromise2300 successful. Data1: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await Utils.sleep(3000);
let wrong;
var str = {
'want': {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
}
await featureAbility.startAbilityForResult(str)
.then((data) => {
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
wrong = error;
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
console.info(TAG + ' StartAbilityForResultPromise2300 failed. Cause1: ' + JSON.stringify(error));
})
await Utils.sleep(2000);
expect(wrong.code).assertEqual(13);
await Utils.sleep(1000);
setTimeout(async () => {
var wrong;
var str = {
'want': {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
}
await featureAbility.startAbilityForResult(str)
.then((data) => {
console.info(TAG + ' StartAbilityForResultPromise2300 successful. 1Data: ' + JSON.stringify(data))
}).catch((error) => {
wrong = error;
console.info(TAG + ' StartAbilityForResultPromise2300 failed. 1Cause: ' + JSON.stringify(error));
})
expect(wrong.code).assertEqual(13);
}, 2000)
done();
});
......@@ -181,47 +183,45 @@ export default function StartAbilityForResult2() {
delegator.executeShellCommand(cmd20, (err: any, d: any) => {
console.info("executeShellCommand20: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
var cmd21 = "bm install -p data/test/MockServiceTimeout.hap";
delegator.executeShellCommand(cmd21, (err: any, d: any) => {
console.info("executeShellCommand21: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
delegator.executeShellCommand(cmd1, (err: any, d: any) => {
console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
console.info("executeShellCommand11 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
delegator.executeShellCommand(cmd2, (err: any, d: any) => {
console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
console.info("executeShellCommand21 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
var cmd3 = "cp data/test/AtomizationResultFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" +
"entry/files";
"entry/files";
delegator.executeShellCommand(cmd3, (err: any, d: any) => {
console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
console.info("executeShellCommand31 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
let wrong;
var str = {
'want': {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
setTimeout(async () => {
var wrong;
var str = {
'want': {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
}
}
featureAbility.startAbilityForResult(str)
.then((data) => {
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
wrong = error;
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await Utils.sleep(35000);
expect(wrong.code).assertEqual(3);
await featureAbility.startAbilityForResult(str)
.then((data) => {
console.info(TAG + ' StartAbilityForResultPromise2600 successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
wrong = error;
console.info(TAG + ' StartAbilityForResultPromise2600 failed. Cause: ' + JSON.stringify(error));
})
expect(wrong.code).assertEqual(3)
}, 20000)
done();
});
})
}
\ No newline at end of file
}
......@@ -16,19 +16,19 @@
import featureAbility from '@ohos.ability.featureAbility';
export default {
onCreate() {
console.info('Application onCreate')
setTimeout(function () {
featureAbility.terminateSelf()
.then((data) => {
console.info('PageAbility terminateself succeeded: ' + data);
}).catch((error) => {
console.error('PageAbility terminateself failed. Cause: ' + error);
})
}, 8000);
},
onCreate() {
console.info('Applicationfa onCreate')
setTimeout(async () => {
await featureAbility.terminateSelf()
.then((data) => {
console.info('PageAbilityfa terminateself succeeded: ' + data);
}).catch((error) => {
console.error('PageAbilityfa terminateself failed. Cause: ' + error);
})
}, 8000);
},
onDestroy() {
console.info('Application onDestroy')
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ No newline at end of file
......@@ -45,7 +45,7 @@ export default function StartAbilityForResult() {
})
await Utils.sleep(500);
var cmd3 = "cp data/test/AtomizationResultFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/" +
"files";
"files";
delegator.executeShellCommand(cmd3, (err: any, d: any) => {
console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
done();
......@@ -88,16 +88,17 @@ export default function StartAbilityForResult() {
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
}
await featureAbility.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResult successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResult failed. error: ' + JSON.stringify(error));
})
await Utils.sleep(1000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
setTimeout(async () => {
await featureAbility.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResult successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResult failed. error: ' + JSON.stringify(error));
})
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
},2000);
done();
});
......@@ -114,7 +115,6 @@ export default function StartAbilityForResult() {
delegator.executeShellCommand(cmd6, (err: any, d: any) => {
console.info("executeShellCommand6: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
let details;
var str = {
'want': {
......@@ -125,16 +125,17 @@ export default function StartAbilityForResult() {
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
}
await featureAbility.startAbilityForResult(str)
setTimeout(async ()=>{
await featureAbility.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResult successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResult failed. error: ' + JSON.stringify(error));
})
await Utils.sleep(1000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
},2000);
done();
});
......@@ -154,30 +155,30 @@ export default function StartAbilityForResult() {
})
await Utils.sleep(500);
var cmd8 = "cp data/test/FaResultMyApplication1.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" +
"entry/files";
"entry/files";
delegator.executeShellCommand(cmd8, (err: any, d: any) => {
console.info("executeShellCommand8: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await Utils.sleep(500);
let details;
var str = {
'want': {
"bundleName": "com.open.harmony.startAbilityForResult",
"abilityName": "com.example.myapplication1.MainAbility1",
"moduleName": "myapplication1",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
setTimeout(async ()=>{
let details;
var str = {
'want': {
"bundleName": "com.open.harmony.startAbilityForResult",
"abilityName": "com.example.myapplication1.MainAbility1",
"moduleName": "myapplication1",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
}
}
await featureAbility.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResult successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResult failed. error: ' + JSON.stringify(error));
})
await Utils.sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
await featureAbility.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResult successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResult failed. error: ' + JSON.stringify(error));
})
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
},2000);
done();
});
})
......
......@@ -34,21 +34,24 @@ export default function StartAbilityForResult(abilityContext) {
beforeAll(async function (done) {
console.info("StartAbilityForResult before all called");
var cmd = "bm install -p data/test/MockService.hap";
console.info("cmd : "+cmd)
console.info("cmd : " + cmd)
globalThis.delegator.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));
})
await sleep(500);
var cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
globalThis.delegator.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));
})
await sleep(500);
var cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
globalThis.delegator.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));
})
await sleep(500);
var cmd3 ="cp data/test/AtomizationResultStageEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
var cmd3 = "cp data/test/AtomizationResultStageEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
globalThis.delegator.executeShellCommand(cmd3, (err: any, d: any) => {
console.info("executeShellCommand3 : err : " + JSON.stringify(err)," data : " + JSON.stringify(d));
console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
done();
})
});
......@@ -56,8 +59,8 @@ export default function StartAbilityForResult(abilityContext) {
afterEach(async function (done) {
console.info("StartAbilityForResult after each called");
if ("FreeInstall_Stage_StartAbilityForResult_0100" === TAG ||
"FreeInstall_Stage_StartAbilityForResult_0500" === TAG ||
"FreeInstall_Stage_StartAbilityForResult_2800" === TAG) {
"FreeInstall_Stage_StartAbilityForResult_0500" === TAG ||
"FreeInstall_Stage_StartAbilityForResult_2800" === TAG) {
var cmd4 = "bm uninstall -n com.example.qianyiyingyong.hmservice";
globalThis.delegator.executeShellCommand(cmd4, (err: any, d: any) => {
console.info("executeShellCommand4 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
......@@ -71,18 +74,18 @@ export default function StartAbilityForResult(abilityContext) {
})
await sleep(500);
var cmd6 = "cp data/test/AtomizationResultStageEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" +
"entry/files";
"entry/files";
globalThis.delegator.executeShellCommand(cmd6, (err: any, d: any) => {
console.info("executeShellCommand6 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
}
if ("FreeInstall_Stage_StartAbilityForResult_2600" === TAG) {
var cmd14 = "bm uninstall -n com.ohos.hag.famanager";
globalThis.delegator.executeShellCommand(cmd14, (err: any, d: any) => {
console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
}
if ("FreeInstall_Stage_StartAbilityForResult_2600" === TAG) {
var cmd14 = "bm uninstall -n com.ohos.hag.famanager";
globalThis.delegator.executeShellCommand(cmd14, (err: any, d: any) => {
console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
}
await sleep(500);
done();
});
......@@ -96,24 +99,25 @@ export default function StartAbilityForResult(abilityContext) {
it("FreeInstall_Stage_StartAbilityForResult_0100", 0, async function (done) {
console.log("------------start FreeInstall_Stage_StartAbilityForResult_0100-------------");
TAG = "FreeInstall_Stage_StartAbilityForResult_0100";
let details;
var str = {
"deviceId": "",
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
setTimeout(async () => {
let details;
var str = {
"deviceId": "",
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
}, 2000)
done();
});
......@@ -126,26 +130,27 @@ export default function StartAbilityForResult(abilityContext) {
it("FreeInstall_Stage_StartAbilityForResult_0400", 0, async function (done) {
console.log("------------start FreeInstall_Stage_StartAbilityForResult_0400-------------");
TAG = "FreeInstall_Stage_StartAbilityForResult_0400";
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
var options = {
"windowMode": 0, "displayId": 2
}
await globalThis.abilityContext.startAbilityForResult(str, options)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
setTimeout(async () => {
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
var options = {
"windowMode": 0, "displayId": 2
}
await globalThis.abilityContext.startAbilityForResult(str, options)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
}, 2000)
done();
});
......@@ -158,23 +163,24 @@ export default function StartAbilityForResult(abilityContext) {
it("FreeInstall_Stage_StartAbilityForResult_0500", 0, async function (done) {
console.log("------------start FreeInstall_Stage_StartAbilityForResult_0500-------------");
TAG = "FreeInstall_Stage_StartAbilityForResult_0500";
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
setTimeout(async () => {
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
}, 2000)
done();
});
......@@ -197,24 +203,25 @@ export default function StartAbilityForResult(abilityContext) {
});
console.log(" checkAbilityInfo deviceId : " + details1.ability.deviceId);
DeviceId = details1.ability.deviceId;
await sleep(500);
var str = {
"deviceId": DeviceId,
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details2 = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details2.resultCode);
expect(details2.resultCode).assertEqual(1);
setTimeout(async () => {
var str = {
"deviceId": DeviceId,
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details2 = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details2.resultCode);
expect(details2.resultCode).assertEqual(1);
}, 2000)
done();
});
......@@ -236,24 +243,25 @@ export default function StartAbilityForResult(abilityContext) {
globalThis.delegator.executeShellCommand(cmd8, (err: any, d: any) => {
console.info("executeShellCommand8: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.hm2.MainAbility",
"moduleName": "hnm2",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
setTimeout(async () => {
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.hm2.MainAbility",
"moduleName": "hnm2",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
}, 2000)
done();
});
......@@ -266,24 +274,25 @@ export default function StartAbilityForResult(abilityContext) {
it("FreeInstall_Stage_StartAbilityForResult_0800", 0, async function (done) {
console.log("------------start FreeInstall_Stage_StartAbilityForResult_0800-------------");
TAG = "FreeInstall_Stage_StartAbilityForResult_0800";
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
var options = {
"windowMode": 0, "displayId": 2
}
await globalThis.abilityContext.startAbilityForResult(str, options, (err, data) => {
console.log(TAG + ": StartAbilityForResultCallBack success, err: " + JSON.stringify(err) +
",data: " + JSON.stringify(data));
details = data;
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
setTimeout(async () => {
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
var options = {
"windowMode": 0, "displayId": 2
}
await globalThis.abilityContext.startAbilityForResult(str, options, (err, data) => {
console.log(TAG + ": StartAbilityForResultCallBack success, err: " + JSON.stringify(err) +
",data: " + JSON.stringify(data));
details = data;
})
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
}, 2000)
done();
});
......@@ -296,23 +305,24 @@ export default function StartAbilityForResult(abilityContext) {
it("FreeInstall_Stage_StartAbilityForResult_1200", 0, async function (done) {
console.log("------------start FreeInstall_Stage_StartAbilityForResult_1200-------------");
TAG = "FreeInstall_Stage_StartAbilityForResult_1200";
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
'flags': '11'
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
setTimeout(async () => {
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
'flags': '11'
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
}, 2000)
done();
});
......@@ -325,26 +335,28 @@ export default function StartAbilityForResult(abilityContext) {
it("FreeInstall_Stage_StartAbilityForResult_1400", 0, async function (done) {
console.log("------------start FreeInstall_Stage_StartAbilityForResult_1400-------------");
TAG = "FreeInstall_Stage_StartAbilityForResult_1400";
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
'flags': '11'
}
var options = {
"windowMode": 0, "displayId": 2
}
await globalThis.abilityContext.startAbilityForResult(str, options)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
setTimeout(async () => {
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
'flags': '11'
}
var options = {
"windowMode": 0, "displayId": 2
}
await globalThis.abilityContext.startAbilityForResult(str, options)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
}, 2000)
done();
});
......@@ -357,23 +369,24 @@ export default function StartAbilityForResult(abilityContext) {
it("FreeInstall_Stage_StartAbilityForResult_1600", 0, async function (done) {
console.log("------------start FreeInstall_Stage_StartAbilityForResult_1600-------------");
TAG = "FreeInstall_Stage_StartAbilityForResult_1600";
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
'flags': ''
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
setTimeout(async () => {
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
'flags': ''
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
}, 2000)
done();
});
......@@ -386,26 +399,27 @@ export default function StartAbilityForResult(abilityContext) {
it("FreeInstall_Stage_StartAbilityForResult_1800", 0, async function (done) {
console.log("------------start FreeInstall_Stage_StartAbilityForResult_1800-------------");
TAG = "FreeInstall_Stage_StartAbilityForResult_1800";
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
'flags': ''
}
var options = {
"windowMode": 0, "displayId": 2
}
await globalThis.abilityContext.startAbilityForResult(str, options)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
setTimeout(async () => {
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
'flags': ''
}
var options = {
"windowMode": 0, "displayId": 2
}
await globalThis.abilityContext.startAbilityForResult(str, options)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
}, 2000)
done();
});
......@@ -422,24 +436,25 @@ export default function StartAbilityForResult(abilityContext) {
globalThis.delegator.executeShellCommand(cmd9, (err: any, d: any) => {
console.info("executeShellCommand9: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "hnm2",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
setTimeout(async () => {
let details;
var str = {
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "hnm2",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
}, 2000)
done();
});
......@@ -458,30 +473,31 @@ export default function StartAbilityForResult(abilityContext) {
})
await sleep(500);
var cmd11 = "cp data/test/AtomizationResultStageEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/" +
"haps/entry/files";
"haps/entry/files";
globalThis.delegator.executeShellCommand(cmd11, (err: any, d: any) => {
console.info("executeShellCommand11 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
let details;
var str = {
'deviceId': '',
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
'parameters': {"name": "1111", "Ext2": "ExtValue2","site":"很开心看到你!"}
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
setTimeout(async () => {
let details;
var str = {
'deviceId': '',
"bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
'parameters': { "name": "1111", "Ext2": "ExtValue2", "site": "很开心看到你!" }
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
}, 2000)
done();
});
......@@ -500,29 +516,30 @@ export default function StartAbilityForResult(abilityContext) {
})
await sleep(500);
var cmd13 = "cp data/test/StageResultMyApplication1.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" +
"entry/files";
"entry/files";
globalThis.delegator.executeShellCommand(cmd13, (err: any, d: any) => {
console.info("executeShellCommand13 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(500);
let details;
var str = {
"deviceId": "",
"bundleName": "com.example.startAbilityForResult.hmservice",
"abilityName": "MainAbility1",
"moduleName": "myapplication1",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
setTimeout(async () => {
let details;
var str = {
"deviceId": "",
"bundleName": "com.example.startAbilityForResult.hmservice",
"abilityName": "MainAbility1",
"moduleName": "myapplication1",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
await globalThis.abilityContext.startAbilityForResult(str)
.then((data) => {
details = data;
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data))
}).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error));
})
await sleep(2000);
console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1);
}, 2000)
done();
});
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册