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

change freeinstalltest code case

Signed-off-by: Nxinxin13 <xinxin13@huawei.com>
上级 69ee04d7
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import ConnectAbilityTest1 from './ConnectAbilityTest1'
import ConnectAbilityTest from './ConnectAbilityTest'
import connectAbilityTest_PA from './connectAbilityTest_PA' import connectAbilityTest_PA from './connectAbilityTest_PA'
import ConnectAbilityTest from './ConnectAbilityTest'
import ConnectAbilityTest1 from './ConnectAbilityTest1'
export default function testsuite() {
ConnectAbilityTest1();
ConnectAbilityTest();
connectAbilityTest_PA();
} export default function testsuite() {
\ No newline at end of file connectAbilityTest_PA();
ConnectAbilityTest();
ConnectAbilityTest1();
}
...@@ -26,7 +26,7 @@ export default function connectAbilityTest_PA() { ...@@ -26,7 +26,7 @@ export default function connectAbilityTest_PA() {
var subscriber; var subscriber;
var subscribeInfo = { var subscribeInfo = {
events: ["service_event", "service2_event", "service3_event", "service4_event", "service5_event", 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) { function sleep(time) {
...@@ -39,8 +39,8 @@ export default function connectAbilityTest_PA() { ...@@ -39,8 +39,8 @@ export default function connectAbilityTest_PA() {
.then((data) => { .then((data) => {
console.info(msg + ' startService successful. Data: ' + JSON.stringify(data)); console.info(msg + ' startService successful. Data: ' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(msg + ' startService failed. Cause: ' + JSON.stringify(error)); console.error(msg + ' startService failed. Cause: ' + JSON.stringify(error));
}) })
} }
function checkParameters(msg1, data) { function checkParameters(msg1, data) {
...@@ -144,14 +144,14 @@ export default function connectAbilityTest_PA() { ...@@ -144,14 +144,14 @@ export default function connectAbilityTest_PA() {
dataAssert = "" dataAssert = ""
await sleep(1000); await sleep(1000);
if ("FreeInstall_FA_ConnectAbility_PA_1100" === TAG) { if ("FreeInstall_FA_ConnectAbility_PA_1100" === TAG) {
var cmd14 = "bm uninstall -n com.ohos.hag.famanager"; var cmd14 = "bm uninstall -n com.ohos.hag.famanager";
abilityDelegator.executeShellCommand(cmd14, (err: any, d: any) => { abilityDelegator.executeShellCommand(cmd14, (err: any, d: any) => {
console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
} }
await sleep(500); await sleep(500);
done(); done();
}); });
/* /*
* @tc.number FreeInstall_FA_ConnectAbility_PA_0100 * @tc.number FreeInstall_FA_ConnectAbility_PA_0100
...@@ -163,24 +163,23 @@ export default function connectAbilityTest_PA() { ...@@ -163,24 +163,23 @@ export default function connectAbilityTest_PA() {
console.log("------------start FreeInstall_FA_ConnectAbility_PA_0100-------------"); console.log("------------start FreeInstall_FA_ConnectAbility_PA_0100-------------");
TAG = "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/" + 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) => { abilityDelegator.executeShellCommand(cmdmyapp7, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
await sleep(500); setTimeout(async () => {
var str1 = { var str1 = {
"want": { "want": {
"bundleName": "com.example.myapplication.hmservice", "bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility", "abilityName": "com.example.myapplication.ServiceAbility",
} }
}; };
startService(TAG, str1); startService(TAG, str1);
setTimeout(function () {
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onConnect"); expect(dataAssert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0100-------------"); console.log("------------end FreeInstall_FA_ConnectAbility_PA_0100-------------");
done();
}, 4000); }, 4000);
done();
}); });
/* /*
...@@ -196,20 +195,19 @@ export default function connectAbilityTest_PA() { ...@@ -196,20 +195,19 @@ export default function connectAbilityTest_PA() {
abilityDelegator.executeShellCommand(cmdapp9, (err: any, d: any) => { abilityDelegator.executeShellCommand(cmdapp9, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
await sleep(500); setTimeout(async () => {
var str2 = { var str2 = {
"want": { "want": {
"bundleName": "com.example.myapplication.hmservice", "bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility2", "abilityName": "com.example.myapplication.ServiceAbility2",
} }
}; };
startService(TAG, str2); startService(TAG, str2);
setTimeout(function () {
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onConnect"); expect(dataAssert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0200-------------"); console.log("------------end FreeInstall_FA_ConnectAbility_PA_0200-------------");
done();
}, 4000); }, 4000);
done();
}); });
/* /*
...@@ -221,19 +219,19 @@ export default function connectAbilityTest_PA() { ...@@ -221,19 +219,19 @@ export default function connectAbilityTest_PA() {
it("FreeInstall_FA_ConnectAbility_PA_0300", 0, async function (done) { it("FreeInstall_FA_ConnectAbility_PA_0300", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_PA_0300-------------"); console.log("------------start FreeInstall_FA_ConnectAbility_PA_0300-------------");
TAG = "FreeInstall_FA_ConnectAbility_PA_0300"; TAG = "FreeInstall_FA_ConnectAbility_PA_0300";
var str3 = { setTimeout(async () => {
"want": { var str3 = {
"bundleName": "com.example.myapplication.hmservice", "want": {
"abilityName": "com.example.myapplication.ServiceAbility3", "bundleName": "com.example.myapplication.hmservice",
} "abilityName": "com.example.myapplication.ServiceAbility3",
}; }
startService(TAG, str3); };
setTimeout(function () { startService(TAG, str3);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onFailed"); expect(dataAssert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0300-------------"); console.log("------------end FreeInstall_FA_ConnectAbility_PA_0300-------------");
done();
}, 4000); }, 4000);
done();
}); });
/* /*
...@@ -244,20 +242,20 @@ export default function connectAbilityTest_PA() { ...@@ -244,20 +242,20 @@ export default function connectAbilityTest_PA() {
*/ */
it("FreeInstall_FA_ConnectAbility_PA_0400", 0, async function (done) { it("FreeInstall_FA_ConnectAbility_PA_0400", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_PA_0400-------------"); console.log("------------start FreeInstall_FA_ConnectAbility_PA_0400-------------");
TAG = "FreeInstall_FA_ConnectAbility_PA_0400"; setTimeout(async () => {
var str4 = { TAG = "FreeInstall_FA_ConnectAbility_PA_0400";
"want": { var str4 = {
"bundleName": "com.example.myapplication.hmservice", "want": {
"abilityName": "com.example.myapplication.ServiceAbility4", "bundleName": "com.example.myapplication.hmservice",
} "abilityName": "com.example.myapplication.ServiceAbility4",
}; }
startService(TAG, str4); };
setTimeout(function () { startService(TAG, str4);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onFailed"); expect(dataAssert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0400-------------"); console.log("------------end FreeInstall_FA_ConnectAbility_PA_0400-------------");
done();
}, 4000); }, 4000);
done();
}); });
/* /*
...@@ -273,20 +271,19 @@ export default function connectAbilityTest_PA() { ...@@ -273,20 +271,19 @@ export default function connectAbilityTest_PA() {
abilityDelegator.executeShellCommand(cmdin, (err: any, d: any) => { abilityDelegator.executeShellCommand(cmdin, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
await sleep(500); setTimeout(async () => {
var str5 = { var str5 = {
"want": { "want": {
"bundleName": "com.example.myapplication.hmservice", "bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication.ServiceAbility5", "abilityName": "com.example.myapplication.ServiceAbility5",
} }
}; };
startService(TAG, str5); startService(TAG, str5);
setTimeout(function () {
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onConnect"); expect(dataAssert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0500-------------"); console.log("------------end FreeInstall_FA_ConnectAbility_PA_0500-------------");
done();
}, 4000); }, 4000);
done();
}); });
/* /*
...@@ -298,19 +295,19 @@ export default function connectAbilityTest_PA() { ...@@ -298,19 +295,19 @@ export default function connectAbilityTest_PA() {
it("FreeInstall_FA_ConnectAbility_PA_0600", 0, async function (done) { it("FreeInstall_FA_ConnectAbility_PA_0600", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_PA_0600-------------"); console.log("------------start FreeInstall_FA_ConnectAbility_PA_0600-------------");
TAG = "FreeInstall_FA_ConnectAbility_PA_0600"; TAG = "FreeInstall_FA_ConnectAbility_PA_0600";
var str6 = { setTimeout(async () => {
"want": { var str6 = {
"bundleName": "com.example.myapplication.hmservice", "want": {
"abilityName": "com.example.myapplication.ServiceAbility6", "bundleName": "com.example.myapplication.hmservice",
} "abilityName": "com.example.myapplication.ServiceAbility6",
}; }
startService(TAG, str6); };
setTimeout(function () { startService(TAG, str6);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onFailed"); expect(dataAssert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0600-------------"); console.log("------------end FreeInstall_FA_ConnectAbility_PA_0600-------------");
done();
}, 4000); }, 4000);
done();
}); });
/* /*
...@@ -322,19 +319,20 @@ export default function connectAbilityTest_PA() { ...@@ -322,19 +319,20 @@ export default function connectAbilityTest_PA() {
it("FreeInstall_FA_ConnectAbility_PA_0700", 0, async function (done) { it("FreeInstall_FA_ConnectAbility_PA_0700", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_PA_0700-------------"); console.log("------------start FreeInstall_FA_ConnectAbility_PA_0700-------------");
TAG = "FreeInstall_FA_ConnectAbility_PA_0700"; TAG = "FreeInstall_FA_ConnectAbility_PA_0700";
var str7 = {
"want": { setTimeout(async () => {
"bundleName": "com.example.myapplication.hmservice", var str7 = {
"abilityName": "com.example.myapplication.ServiceAbility7", "want": {
} "bundleName": "com.example.myapplication.hmservice",
}; "abilityName": "com.example.myapplication.ServiceAbility7",
startService(TAG, str7); }
setTimeout(function () { };
startService(TAG, str7);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onFailed"); expect(dataAssert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0700-------------"); console.log("------------end FreeInstall_FA_ConnectAbility_PA_0700-------------");
done();
}, 4000); }, 4000);
done();
}); });
/* /*
...@@ -346,19 +344,20 @@ export default function connectAbilityTest_PA() { ...@@ -346,19 +344,20 @@ export default function connectAbilityTest_PA() {
it("FreeInstall_FA_ConnectAbility_PA_0800", 0, async function (done) { it("FreeInstall_FA_ConnectAbility_PA_0800", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_PA_0800-------------"); console.log("------------start FreeInstall_FA_ConnectAbility_PA_0800-------------");
TAG = "FreeInstall_FA_ConnectAbility_PA_0800"; TAG = "FreeInstall_FA_ConnectAbility_PA_0800";
var str8 = {
"want": { setTimeout(async () => {
"bundleName": "com.example.myapplication.hmservice", var str8 = {
"abilityName": "com.example.myapplication.ServiceAbility8", "want": {
} "bundleName": "com.example.myapplication.hmservice",
}; "abilityName": "com.example.myapplication.ServiceAbility8",
startService(TAG, str8); }
setTimeout(function () { };
startService(TAG, str8);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onFailed"); expect(dataAssert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0800-------------"); console.log("------------end FreeInstall_FA_ConnectAbility_PA_0800-------------");
done();
}, 4000); }, 4000);
done();
}); });
/* /*
...@@ -374,20 +373,21 @@ export default function connectAbilityTest_PA() { ...@@ -374,20 +373,21 @@ export default function connectAbilityTest_PA() {
abilityDelegator.executeShellCommand(cmdrm, (err: any, d: any) => { abilityDelegator.executeShellCommand(cmdrm, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
await sleep(500);
var str9 = { setTimeout(async () => {
"want": { await sleep(500);
"bundleName": "com.example.myapplication.hmservice", var str9 = {
"abilityName": "com.example.myapplication.ServiceAbility9", "want": {
} "bundleName": "com.example.myapplication.hmservice",
}; "abilityName": "com.example.myapplication.ServiceAbility9",
startService(TAG, str9); }
setTimeout(function () { };
startService(TAG, str9);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onFailed"); expect(dataAssert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_0900-------------"); console.log("------------end FreeInstall_FA_ConnectAbility_PA_0900-------------");
done();
}, 4000); }, 4000);
done();
}); });
/* /*
...@@ -399,19 +399,20 @@ export default function connectAbilityTest_PA() { ...@@ -399,19 +399,20 @@ export default function connectAbilityTest_PA() {
it("FreeInstall_FA_ConnectAbility_PA_1000", 0, async function (done) { it("FreeInstall_FA_ConnectAbility_PA_1000", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_PA_1000-------------"); console.log("------------start FreeInstall_FA_ConnectAbility_PA_1000-------------");
TAG = "FreeInstall_FA_ConnectAbility_PA_1000"; TAG = "FreeInstall_FA_ConnectAbility_PA_1000";
var str10 = {
"want": { setTimeout(async () => {
"bundleName": "com.example.myapplication.hmservice", var str10 = {
"abilityName": "com.example.myapplication.ServiceAbility10", "want": {
} "bundleName": "com.example.myapplication.hmservice",
}; "abilityName": "com.example.myapplication.ServiceAbility10",
startService(TAG, str10); }
setTimeout(function () { };
startService(TAG, str10);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onFailed"); expect(dataAssert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_1000-------------"); console.log("------------end FreeInstall_FA_ConnectAbility_PA_1000-------------");
done();
}, 4000); }, 4000);
done();
}); });
/* /*
...@@ -424,24 +425,24 @@ export default function connectAbilityTest_PA() { ...@@ -424,24 +425,24 @@ export default function connectAbilityTest_PA() {
console.log("------------start FreeInstall_FA_ConnectAbility_PA_1100-------------"); console.log("------------start FreeInstall_FA_ConnectAbility_PA_1100-------------");
TAG = "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/" + 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) => { abilityDelegator.executeShellCommand(cmdmyapp8, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
await sleep(1000);
var str11 = { setTimeout(async () => {
"want": { var str11 = {
"bundleName": "com.example.myapplication.hmservice", "want": {
"abilityName": "com.example.myapplication.ServiceAbility11", "bundleName": "com.example.myapplication.hmservice",
} "abilityName": "com.example.myapplication.ServiceAbility11",
}; }
startService(TAG, str11); };
setTimeout(function () { startService(TAG, str11);
console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert));
expect(dataAssert).assertEqual("onConnect"); expect(dataAssert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_PA_1100-------------"); console.log("------------end FreeInstall_FA_ConnectAbility_PA_1100-------------");
done();
}, 4000); }, 4000);
done();
}); });
} }
) )
......
...@@ -17,7 +17,7 @@ import featureAbility from '@ohos.ability.featureAbility'; ...@@ -17,7 +17,7 @@ import featureAbility from '@ohos.ability.featureAbility';
export default { export default {
onCreate() { onCreate() {
console.info('Application onCreate') console.info('Application onCreate')
setTimeout(function () { setTimeout(()=> {
featureAbility.terminateSelf() featureAbility.terminateSelf()
.then((data) => { .then((data) => {
console.info('[Demo] MainAbility2 terminateself succeeded: ' + data); console.info('[Demo] MainAbility2 terminateself succeeded: ' + data);
......
...@@ -23,214 +23,211 @@ import commonEvent from '@ohos.commonEvent'; ...@@ -23,214 +23,211 @@ import commonEvent from '@ohos.commonEvent';
export default function startAbilityTest2() { 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) { function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time)) return new Promise((resolve) => setTimeout(resolve, time))
} }
beforeAll(async function (done) { beforeAll(async function (done) {
console.info("StartAbilityForResult before all called"); console.info("StartAbilityForResult before all called");
var cmd = "bm install -p data/test/MockService.hap"; var cmd = "bm install -p data/test/MockService.hap";
console.info("cmd : " + cmd) console.info("cmd : " + cmd)
delegator.executeShellCommand(cmd, (err: any, d: any) => { 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); await sleep(500);
var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
delegator.executeShellCommand(cmd1, (err: any, d: any) => { 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); await sleep(500);
var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
delegator.executeShellCommand(cmd2, (err: any, d: any) => { 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); await sleep(500);
var cmd3 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + var cmd3 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" +
"entry/files"; "entry/files";
delegator.executeShellCommand(cmd3, (err: any, d: any) => { 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(); done();
}) })
}); });
afterEach(async function (done) { afterEach(async function (done) {
console.info("StartAbilityTest after each called"); console.info("StartAbilityTest after each called");
if ("FreeInstall_FA_Local_StartAbility_2000" === TAG) { if ("FreeInstall_FA_Local_StartAbility_2000" === TAG) {
var cmd4 = "bm uninstall -n com.example.qianyiyingyong.hmservice"; var cmd4 = "bm uninstall -n com.example.qianyiyingyong.hmservice";
delegator.executeShellCommand(cmd4, (err: any, d: any) => { delegator.executeShellCommand(cmd4, (err: any, d: any) => {
console.info("executeShellCommand4 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand4 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
await sleep(500); await sleep(500);
} }
if ("FreeInstall_FA_Local_StartAbility_2500" === TAG) { if ("FreeInstall_FA_Local_StartAbility_2500" === TAG) {
var cmd5 = "bm uninstall -n com.ohos.hag.famanager"; var cmd5 = "bm uninstall -n com.ohos.hag.famanager";
delegator.executeShellCommand(cmd5, (err: any, d: any) => { delegator.executeShellCommand(cmd5, (err: any, d: any) => {
console.info("executeShellCommand5 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand5 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
} }
await sleep(500); await sleep(500);
done(); done();
}); });
/* /*
* @tc.number FreeInstall_FA_Local_StartAbility_1900 * @tc.number FreeInstall_FA_Local_StartAbility_1900
* @tc.name The current service is not in the foreground. Page a jumps to page B first. * @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 There are HAP packages that need not be installed under the specified path
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("FreeInstall_FA_Local_StartAbility_1900", 0, async function (done) { it("FreeInstall_FA_Local_StartAbility_1900", 0, async function (done) {
console.info("------------start FreeInstall_FA_Local_StartAbility_1900-------------"); console.info("------------start FreeInstall_FA_Local_StartAbility_1900-------------");
TAG = "FreeInstall_FA_Local_StartAbility_1900"; TAG = "FreeInstall_FA_Local_StartAbility_1900";
let wrong; let wrong;
var str1 = { var str1 = {
'want': { 'want': {
"bundleName": "com.open.harmony.startAbility", "bundleName": "com.open.harmony.startAbility",
"abilityName": "com.open.harmony.startAbility.PageAbility", "abilityName": "com.open.harmony.startAbility.PageAbility",
"moduleName": "entry", "moduleName": "entry",
} }
} }
featureAbility.startAbility(str1) featureAbility.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' StartAbility successful. Promise Data: ' + JSON.stringify(data)) console.info(TAG + ' StartAbility successful. Promise Data: ' + JSON.stringify(data))
}).catch((error) => { }).catch((error) => {
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error)); console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error));
}) })
await sleep(3000); setTimeout(async () => {
var str = { var str = {
'want': { 'want': {
"bundleName": "com.example.qianyiyingyong.hmservice", "bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility", "abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry", "moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND
} }
} }
await featureAbility.startAbility(str).then((data) => { await featureAbility.startAbility(str).then((data) => {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
wrong = error; wrong = error;
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(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();
}); });
expect(wrong.code).assertEqual(13);
}, 2000)
console.info("------------end FreeInstall_FA_Local_StartAbility_1900-------------");
done();
});
/* /*
* @tc.number FreeInstall_FA_Local_StartAbility_2000 * @tc.number FreeInstall_FA_Local_StartAbility_2000
* @tc.name The current service is not in the foreground. Page a jumps to page B first. * @tc.name The current service is not in the foreground. Page a jumps to page B first.
The atomized HAP package has been installed The atomized HAP package has been installed
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("FreeInstall_FA_Local_StartAbility_2000", 0, async function (done) { it("FreeInstall_FA_Local_StartAbility_2000", 0, async function (done) {
console.info("------------start FreeInstall_FA_Local_StartAbility_2000-------------"); console.info("------------start FreeInstall_FA_Local_StartAbility_2000-------------");
TAG = "FreeInstall_FA_Local_StartAbility_2000"; TAG = "FreeInstall_FA_Local_StartAbility_2000";
var cmd2000 = "bm install -p data/test/AtomizationFaEntry.hap"; var cmd2000 = "bm install -p data/test/AtomizationFaEntry.hap";
delegator.executeShellCommand(cmd2000, (err: any, d: any) => { delegator.executeShellCommand(cmd2000, (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); await sleep(500);
let wrong; let wrong;
var str1 = { var str1 = {
'want': { 'want': {
"bundleName": "com.open.harmony.startAbility", "bundleName": "com.open.harmony.startAbility",
"abilityName": "com.open.harmony.startAbility.PageAbility", "abilityName": "com.open.harmony.startAbility.PageAbility",
"moduleName": "entry", "moduleName": "entry",
} }
} }
featureAbility.startAbility(str1) featureAbility.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' StartAbility successful. Promise Data: ' + JSON.stringify(data)) console.info(TAG + ' StartAbility successful. Promise Data: ' + JSON.stringify(data))
}).catch((error) => { }).catch((error) => {
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error)); console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error));
}) })
await sleep(3000); setTimeout(async () => {
var str = { var str = {
'want': { 'want': {
"bundleName": "com.example.qianyiyingyong.hmservice", "bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility", "abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry", "moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND
} }
} }
await featureAbility.startAbility(str).then((data) => { await featureAbility.startAbility(str).then((data) => {
console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
wrong = error; wrong = error;
console.log(TAG + ": startAbility fail. err: " + JSON.stringify(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();
}); });
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.number FreeInstall_FA_Local_StartAbility_2500
* @tc.name FA Service Center installation free timeout * @tc.name FA Service Center installation free timeout
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("FreeInstall_FA_Local_StartAbility_2500", 0, async function (done) { it("FreeInstall_FA_Local_StartAbility_2500", 0, async function (done) {
console.info("------------start FreeInstall_FA_Local_StartAbility_2500-------------"); console.info("------------start FreeInstall_FA_Local_StartAbility_2500-------------");
TAG = "FreeInstall_FA_Local_StartAbility_2500"; TAG = "FreeInstall_FA_Local_StartAbility_2500";
var cmd2500 = "bm uninstall -n com.ohos.hag.famanager"; var cmd2500 = "bm uninstall -n com.ohos.hag.famanager";
delegator.executeShellCommand(cmd2500, (err: any, d: any) => { delegator.executeShellCommand(cmd2500, (err: any, d: any) => {
console.info("executeShellCommand2500 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand2500 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
await sleep(500); var cmd2501 = "bm install -p data/test/MockServiceTimeout.hap";
var cmd2501 = "bm install -p data/test/MockServiceTimeout.hap"; delegator.executeShellCommand(cmd2501, (err: any, d: any) => {
delegator.executeShellCommand(cmd2501, (err: any, d: any) => { console.info("executeShellCommand2501 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
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";
await sleep(500); delegator.executeShellCommand(cmd2502, (err: any, d: any) => {
var cmd2502 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
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) => {
await sleep(500); console.info("executeShellCommand2 : 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) => { var cmd2504 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps" +
console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); "/entry/files";
}) delegator.executeShellCommand(cmd2504, (err: any, d: any) => {
await sleep(500); console.info("executeShellCommand3 : 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"; setTimeout(async () => {
delegator.executeShellCommand(cmd2504, (err: any, d: any) => { let wrong;
console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); var str = {
}) 'want': {
await sleep(500); "bundleName": "com.example.qianyiyingyong.hmservice",
let wrong; "abilityName": "com.example.qianyiyingyong.MainAbility",
var str = { "moduleName": "entry",
'want': { "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
"bundleName": "com.example.qianyiyingyong.hmservice", }
"abilityName": "com.example.qianyiyingyong.MainAbility", }
"moduleName": "entry", featureAbility.startAbility(str).then((data) => {
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, console.log(TAG + ": startAbility success. data: " + JSON.stringify(data));
} }).catch((error) => {
} wrong = error;
featureAbility.startAbility(str).then((data) => { console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error));
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();
}); });
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'; ...@@ -22,189 +22,191 @@ import wantConstant from '@ohos.ability.wantConstant';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
export default function StartAbilityTest() { export default function StartAbilityTest() {
var TAG = ""; var TAG = "";
describe('StartAbilityTest', function () { describe('StartAbilityTest', function () {
var delegator = AbilityDelegatorRegistry.getAbilityDelegator(); var delegator = AbilityDelegatorRegistry.getAbilityDelegator();
beforeAll(async function (done) { beforeAll(async function (done) {
console.info("StartAbilityTest before all called"); console.info("StartAbilityTest before all called");
var cmd = "bm install -p data/test/MockService.hap"; var cmd = "bm install -p data/test/MockService.hap";
console.info("cmd : " + cmd) console.info("cmd : " + cmd)
delegator.executeShellCommand(cmd, (err: any, d: any) => { 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 Utils.sleep(500); await Utils.sleep(500);
var cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; var cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
delegator.executeShellCommand(cmd1, (err: any, d: any) => { 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 Utils.sleep(500); await Utils.sleep(500);
var cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; var cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
delegator.executeShellCommand(cmd2, (err: any, d: any) => { 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 Utils.sleep(500); await Utils.sleep(500);
var cmd3 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + var cmd3 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" +
"entry/files"; "entry/files";
delegator.executeShellCommand(cmd3, (err: any, d: any) => { 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(); done();
}) })
}); });
afterEach(async function (done) { afterEach(async function (done) {
console.info("StartAbilityTest after each called"); console.info("StartAbilityTest after each called");
if ("FreeInstall_FA_StartAbility_2800" === TAG || "FreeInstall_FA_StartAbility_3900") { if ("FreeInstall_FA_StartAbility_2800" === TAG || "FreeInstall_FA_StartAbility_3900") {
var cmd5 = "bm uninstall -n com.example.qianyiyingyong.hmservice"; var cmd5 = "bm uninstall -n com.example.qianyiyingyong.hmservice";
delegator.executeShellCommand(cmd5, (err: any, d: any) => { delegator.executeShellCommand(cmd5, (err: any, d: any) => {
console.info("executeShellCommand5: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand5: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
} }
await Utils.sleep(500); await Utils.sleep(500);
if ("FreeInstall_FA_StartAbility_3900" === TAG) { if ("FreeInstall_FA_StartAbility_3900" === TAG) {
var cmd4 = "bm uninstall -n com.ohos.hag.famanager"; var cmd4 = "bm uninstall -n com.ohos.hag.famanager";
delegator.executeShellCommand(cmd4, (err: any, d: any) => { delegator.executeShellCommand(cmd4, (err: any, d: any) => {
console.info("executeShellCommand4: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand4: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
} }
await Utils.sleep(500); await Utils.sleep(500);
done(); done();
}); });
/* /*
* @tc.number: FreeInstall_FA_StartAbility_2600 * @tc.number: FreeInstall_FA_StartAbility_2600
* @tc.name: startAbility: NoTargetBundleList,free install successfully. * @tc.name: startAbility: NoTargetBundleList,free install successfully.
* @tc.desc: Function test * @tc.desc: Function test
* @tc.level 0 * @tc.level 0
*/ */
it("FreeInstall_FA_StartAbility_2600", 0, async function (done) { it("FreeInstall_FA_StartAbility_2600", 0, async function (done) {
console.log("------------start FreeInstall_FA_StartAbility_2600-------------"); console.log("------------start FreeInstall_FA_StartAbility_2600-------------");
TAG = "FreeInstall_FA_StartAbility_2600"; TAG = "FreeInstall_FA_StartAbility_2600";
let details; setTimeout(async () => {
var str = { let details;
'want': { var str = {
"deviceId": "", 'want': {
"bundleName": "com.example.qianyiyingyong.hmservice", "deviceId": "",
"abilityName": "com.example.qianyiyingyong.MainAbility", "bundleName": "com.example.qianyiyingyong.hmservice",
"moduleName": "entry", "abilityName": "com.example.qianyiyingyong.MainAbility",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, "moduleName": "entry",
} "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
} }
await featureAbility.startAbility(str).then((data) => { }
details = data; await featureAbility.startAbility(str).then((data) => {
console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data)) details = data;
}).catch((error) => { console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data))
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error)); }).catch((error) => {
}) console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error));
await Utils.sleep(2000); })
expect(details).assertEqual(0); expect(details).assertEqual(0);
done(); }, 2000)
}); done();
});
/* /*
* @tc.number: FreeInstall_FA_StartAbility_2700 * @tc.number: FreeInstall_FA_StartAbility_2700
* @tc.name: startAbility: NoTargetBundleList and yuanzihua already installed,startAbility successfully. * @tc.name: startAbility: NoTargetBundleList and yuanzihua already installed,startAbility successfully.
* @tc.desc: Function test * @tc.desc: Function test
* @tc.level 0 * @tc.level 0
*/ */
it("FreeInstall_FA_StartAbility_2700", 0, async function (done) { it("FreeInstall_FA_StartAbility_2700", 0, async function (done) {
console.log("------------start FreeInstall_FA_StartAbility_2700-------------"); console.log("------------start FreeInstall_FA_StartAbility_2700-------------");
TAG = "FreeInstall_FA_StartAbility_2700"; TAG = "FreeInstall_FA_StartAbility_2700";
var cmd6 = "bm install -p data/test/AtomizationFaEntry.hap"; var cmd6 = "bm install -p data/test/AtomizationFaEntry.hap";
delegator.executeShellCommand(cmd6, (err: any, d: any) => { delegator.executeShellCommand(cmd6, (err: any, d: any) => {
console.info("executeShellCommand6: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand6: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
await Utils.sleep(500); setTimeout(async () => {
let details; let details;
var str = { var str = {
'want': { 'want': {
"deviceId": "", "deviceId": "",
"bundleName": "com.example.qianyiyingyong.hmservice", "bundleName": "com.example.qianyiyingyong.hmservice",
"abilityName": "com.example.qianyiyingyong.MainAbility", "abilityName": "com.example.qianyiyingyong.MainAbility",
"moduleName": "entry", "moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
} }
} }
await featureAbility.startAbility(str).then((data) => { await featureAbility.startAbility(str).then((data) => {
details = data; details = data;
console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data)) console.info(TAG + ' StartAbility2700 successful. Data: ' + JSON.stringify(data))
}).catch((error) => { }).catch((error) => {
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error)); console.info(TAG + ' StartAbility2700 failed. error: ' + JSON.stringify(error));
}) })
await Utils.sleep(2000); expect(details).assertEqual(0);
expect(details).assertEqual(0); }, 2000)
done(); done();
}); });
/* /*
* @tc.number: FreeInstall_FA_StartAbility_2800 * @tc.number: FreeInstall_FA_StartAbility_2800
* @tc.name: startAbility: The same application does not need to check targetbundlelist, * @tc.name: startAbility: The same application does not need to check targetbundlelist,
start feature hap successfully. start feature hap successfully.
* @tc.desc: Function test * @tc.desc: Function test
* @tc.level 0 * @tc.level 0
*/ */
it("FreeInstall_FA_StartAbility_2800", 0, async function (done) { it("FreeInstall_FA_StartAbility_2800", 0, async function (done) {
console.log("------------start FreeInstall_FA_StartAbility_2800-------------"); console.log("------------start FreeInstall_FA_StartAbility_2800-------------");
TAG = "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"; var cmd7 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationFaEntry.hap";
delegator.executeShellCommand(cmd7, (err: any, d: any) => { delegator.executeShellCommand(cmd7, (err: any, d: any) => {
console.info("executeShellCommand7 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand7 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
await Utils.sleep(500); await Utils.sleep(500);
var cmd8 = "cp data/test/FaMyApplication1.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + var cmd8 = "cp data/test/FaMyApplication1.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" +
"entry/files"; "entry/files";
delegator.executeShellCommand(cmd8, (err: any, d: any) => { delegator.executeShellCommand(cmd8, (err: any, d: any) => {
console.info("executeShellCommand8 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand8 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
await Utils.sleep(500); setTimeout(async () => {
let details; let details;
var str = { var str = {
'want': { 'want': {
"bundleName": "com.open.harmony.startAbility", "bundleName": "com.open.harmony.startAbility",
"abilityName": "com.example.myapplication1.MainAbility1", "abilityName": "com.example.myapplication1.MainAbility1",
"moduleName": "myapplication1", "moduleName": "myapplication1",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
} }
} }
await featureAbility.startAbility(str).then((data) => { await featureAbility.startAbility(str).then((data) => {
details = data; details = data;
console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data)) console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data))
}).catch((error) => { }).catch((error) => {
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error)); console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error));
}) })
await Utils.sleep(2000); expect(details).assertEqual(0);
expect(details).assertEqual(0); }, 2000)
done(); done();
}); });
/* /*
* @tc.number: FreeInstall_FA_StartAbility_3900 * @tc.number: FreeInstall_FA_StartAbility_3900
* @tc.name: startAbility: The same application does not need to check targetbundlelist,add BACKGROUND flags * @tc.name: startAbility: The same application does not need to check targetbundlelist,add BACKGROUND flags
start feature hap successfully. start feature hap successfully.
* @tc.desc: Function test * @tc.desc: Function test
* @tc.level 0 * @tc.level 0
*/ */
it("FreeInstall_FA_StartAbility_3900", 0, async function (done) { it("FreeInstall_FA_StartAbility_3900", 0, async function (done) {
console.log("------------start FreeInstall_FA_StartAbility_3900-------------"); console.log("------------start FreeInstall_FA_StartAbility_3900-------------");
TAG = "FreeInstall_FA_StartAbility_3900"; TAG = "FreeInstall_FA_StartAbility_3900";
let details; setTimeout(async () => {
var str = { let details;
'want': { var str = {
"bundleName": "com.open.harmony.startAbility", 'want': {
"abilityName": "com.example.myapplication1.MainAbility1", "bundleName": "com.open.harmony.startAbility",
"moduleName": "myapplication1", "abilityName": "com.example.myapplication1.MainAbility1",
"flags": wantConstant.Flags.FLAG_INSTALL_WITH_BACKGROUND_MODE|wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, "moduleName": "myapplication1",
} "flags": wantConstant.Flags.FLAG_INSTALL_WITH_BACKGROUND_MODE | wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
} }
await featureAbility.startAbility(str).then((data) => { }
details = data; await featureAbility.startAbility(str).then((data) => {
console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data)) details = data;
}).catch((error) => { console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data))
console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error)); }).catch((error) => {
}) console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error));
await Utils.sleep(2000); })
expect(details).assertEqual(0); expect(details).assertEqual(0);
done(); }, 2000);
}); done();
}) });
})
} }
\ No newline at end of file
...@@ -46,7 +46,7 @@ export default function StartAbilityForResult2() { ...@@ -46,7 +46,7 @@ export default function StartAbilityForResult2() {
}) })
await Utils.sleep(500); await Utils.sleep(500);
var cmd3 = "cp data/test/AtomizationResultFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + 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) => { 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(); done();
...@@ -92,10 +92,10 @@ export default function StartAbilityForResult2() { ...@@ -92,10 +92,10 @@ export default function StartAbilityForResult2() {
} }
featureAbility.startAbilityForResult(str1) featureAbility.startAbilityForResult(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) console.info(TAG + ' StartAbilityForResultPromise2200 successful. Data: ' + JSON.stringify(data))
}).catch((error) => { }).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); console.info(TAG + ' StartAbilityForResultPromise2200 failed. Cause: ' + JSON.stringify(error));
}) })
await Utils.sleep(3000); await Utils.sleep(3000);
let wrong; let wrong;
var str = { var str = {
...@@ -108,10 +108,10 @@ export default function StartAbilityForResult2() { ...@@ -108,10 +108,10 @@ export default function StartAbilityForResult2() {
} }
await featureAbility.startAbilityForResult(str) await featureAbility.startAbilityForResult(str)
.then((data) => { .then((data) => {
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) console.info(TAG + ' StartAbilityForResultPromise2200 successful. Data: ' + JSON.stringify(data))
}).catch((error) => { }).catch((error) => {
wrong = 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); await Utils.sleep(2000);
expect(wrong.code).assertEqual(13); expect(wrong.code).assertEqual(13);
...@@ -128,7 +128,8 @@ export default function StartAbilityForResult2() { ...@@ -128,7 +128,8 @@ export default function StartAbilityForResult2() {
it("FreeInstall_FA_StartAbilityForResult_2300", 0, async function (done) { it("FreeInstall_FA_StartAbilityForResult_2300", 0, async function (done) {
console.log("------------start FreeInstall_FA_StartAbilityForResult_2300-------------"); console.log("------------start FreeInstall_FA_StartAbilityForResult_2300-------------");
TAG = "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) => { delegator.executeShellCommand(cmd19, (err: any, d: any) => {
console.info("executeShellCommand19: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand19: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
...@@ -142,29 +143,30 @@ export default function StartAbilityForResult2() { ...@@ -142,29 +143,30 @@ export default function StartAbilityForResult2() {
} }
featureAbility.startAbilityForResult(str1) featureAbility.startAbilityForResult(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) console.info(TAG + ' StartAbilityForResultPromise2300 successful. Data1: ' + JSON.stringify(data))
}).catch((error) => { }).catch((error) => {
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); console.info(TAG + ' StartAbilityForResultPromise2300 failed. Cause1: ' + 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));
}) })
await Utils.sleep(2000); await Utils.sleep(1000);
expect(wrong.code).assertEqual(13); 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(); done();
}); });
...@@ -181,47 +183,45 @@ export default function StartAbilityForResult2() { ...@@ -181,47 +183,45 @@ export default function StartAbilityForResult2() {
delegator.executeShellCommand(cmd20, (err: any, d: any) => { delegator.executeShellCommand(cmd20, (err: any, d: any) => {
console.info("executeShellCommand20: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand20: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
await Utils.sleep(500);
var cmd21 = "bm install -p data/test/MockServiceTimeout.hap"; var cmd21 = "bm install -p data/test/MockServiceTimeout.hap";
delegator.executeShellCommand(cmd21, (err: any, d: any) => { delegator.executeShellCommand(cmd21, (err: any, d: any) => {
console.info("executeShellCommand21: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); 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"; var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
delegator.executeShellCommand(cmd1, (err: any, d: any) => { 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"; var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
delegator.executeShellCommand(cmd2, (err: any, d: any) => { 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/" + 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) => { 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; setTimeout(async () => {
var str = { var wrong;
'want': { var str = {
"bundleName": "com.example.qianyiyingyong.hmservice", 'want': {
"abilityName": "com.example.qianyiyingyong.MainAbility", "bundleName": "com.example.qianyiyingyong.hmservice",
"moduleName": "entry", "abilityName": "com.example.qianyiyingyong.MainAbility",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, "moduleName": "entry",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
} }
} await featureAbility.startAbilityForResult(str)
featureAbility.startAbilityForResult(str) .then((data) => {
.then((data) => { console.info(TAG + ' StartAbilityForResultPromise2600 successful. Data: ' + JSON.stringify(data))
console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) }).catch((error) => {
}).catch((error) => { wrong = error;
wrong = error; console.info(TAG + ' StartAbilityForResultPromise2600 failed. Cause: ' + JSON.stringify(error));
console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); })
}) expect(wrong.code).assertEqual(3)
await Utils.sleep(35000); }, 20000)
expect(wrong.code).assertEqual(3);
done(); done();
}); });
}) })
} }
\ No newline at end of file
...@@ -16,19 +16,19 @@ ...@@ -16,19 +16,19 @@
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
export default { export default {
onCreate() { onCreate() {
console.info('Application onCreate') console.info('Applicationfa onCreate')
setTimeout(function () { setTimeout(async () => {
featureAbility.terminateSelf() await featureAbility.terminateSelf()
.then((data) => { .then((data) => {
console.info('PageAbility terminateself succeeded: ' + data); console.info('PageAbilityfa terminateself succeeded: ' + data);
}).catch((error) => { }).catch((error) => {
console.error('PageAbility terminateself failed. Cause: ' + error); console.error('PageAbilityfa terminateself failed. Cause: ' + error);
}) })
}, 8000); }, 8000);
}, },
onDestroy() { onDestroy() {
console.info('Application onDestroy') console.info('Application onDestroy')
}, },
} }
\ No newline at end of file
...@@ -45,7 +45,7 @@ export default function StartAbilityForResult() { ...@@ -45,7 +45,7 @@ export default function StartAbilityForResult() {
}) })
await Utils.sleep(500); await Utils.sleep(500);
var cmd3 = "cp data/test/AtomizationResultFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/" + 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) => { 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(); done();
...@@ -88,16 +88,17 @@ export default function StartAbilityForResult() { ...@@ -88,16 +88,17 @@ export default function StartAbilityForResult() {
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
} }
} }
await featureAbility.startAbilityForResult(str) setTimeout(async () => {
.then((data) => { await featureAbility.startAbilityForResult(str)
details = data; .then((data) => {
console.info(TAG + ' StartAbilityForResult successful. Data: ' + JSON.stringify(data)) details = data;
}).catch((error) => { console.info(TAG + ' StartAbilityForResult successful. Data: ' + JSON.stringify(data))
console.info(TAG + ' StartAbilityForResult failed. error: ' + JSON.stringify(error)); }).catch((error) => {
}) console.info(TAG + ' StartAbilityForResult failed. error: ' + JSON.stringify(error));
await Utils.sleep(1000); })
console.log(TAG + " resultCode: " + details.resultCode); console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1); expect(details.resultCode).assertEqual(1);
},2000);
done(); done();
}); });
...@@ -114,7 +115,6 @@ export default function StartAbilityForResult() { ...@@ -114,7 +115,6 @@ export default function StartAbilityForResult() {
delegator.executeShellCommand(cmd6, (err: any, d: any) => { delegator.executeShellCommand(cmd6, (err: any, d: any) => {
console.info("executeShellCommand6: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand6: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
await Utils.sleep(500);
let details; let details;
var str = { var str = {
'want': { 'want': {
...@@ -125,16 +125,17 @@ export default function StartAbilityForResult() { ...@@ -125,16 +125,17 @@ export default function StartAbilityForResult() {
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
} }
} }
await featureAbility.startAbilityForResult(str) setTimeout(async ()=>{
await featureAbility.startAbilityForResult(str)
.then((data) => { .then((data) => {
details = data; details = data;
console.info(TAG + ' StartAbilityForResult successful. Data: ' + JSON.stringify(data)) console.info(TAG + ' StartAbilityForResult successful. Data: ' + JSON.stringify(data))
}).catch((error) => { }).catch((error) => {
console.info(TAG + ' StartAbilityForResult failed. error: ' + JSON.stringify(error)); console.info(TAG + ' StartAbilityForResult failed. error: ' + JSON.stringify(error));
}) })
await Utils.sleep(1000);
console.log(TAG + " resultCode: " + details.resultCode); console.log(TAG + " resultCode: " + details.resultCode);
expect(details.resultCode).assertEqual(1); expect(details.resultCode).assertEqual(1);
},2000);
done(); done();
}); });
...@@ -154,30 +155,30 @@ export default function StartAbilityForResult() { ...@@ -154,30 +155,30 @@ export default function StartAbilityForResult() {
}) })
await Utils.sleep(500); await Utils.sleep(500);
var cmd8 = "cp data/test/FaResultMyApplication1.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + 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) => { delegator.executeShellCommand(cmd8, (err: any, d: any) => {
console.info("executeShellCommand8: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); console.info("executeShellCommand8: err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
}) })
await Utils.sleep(500); setTimeout(async ()=>{
let details; let details;
var str = { var str = {
'want': { 'want': {
"bundleName": "com.open.harmony.startAbilityForResult", "bundleName": "com.open.harmony.startAbilityForResult",
"abilityName": "com.example.myapplication1.MainAbility1", "abilityName": "com.example.myapplication1.MainAbility1",
"moduleName": "myapplication1", "moduleName": "myapplication1",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
} }
} await featureAbility.startAbilityForResult(str)
await featureAbility.startAbilityForResult(str) .then((data) => {
.then((data) => { details = data;
details = data; console.info(TAG + ' StartAbilityForResult successful. Data: ' + JSON.stringify(data))
console.info(TAG + ' StartAbilityForResult successful. Data: ' + JSON.stringify(data)) }).catch((error) => {
}).catch((error) => { console.info(TAG + ' StartAbilityForResult failed. error: ' + JSON.stringify(error));
console.info(TAG + ' StartAbilityForResult failed. error: ' + JSON.stringify(error)); })
}) console.log(TAG + " resultCode: " + details.resultCode);
await Utils.sleep(2000); expect(details.resultCode).assertEqual(1);
console.log(TAG + " resultCode: " + details.resultCode); },2000);
expect(details.resultCode).assertEqual(1);
done(); done();
}); });
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册