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

!5639 freeinstalltest change

Merge pull request !5639 from xinking129/master
......@@ -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();
});
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册