提交 51eeabd0 编写于 作者: J jiyong

change startability and want

Signed-off-by: Njiyong <jiyong@huawei.com>
上级 3113a4d9
......@@ -167,6 +167,65 @@ describe('ActsFeatureAbilityTest', function () {
}, TIMEOUT)
})
/*
* @tc.number ACTS_StartAbility_1000
* @tc.name The configured URI is started and the page is not configured
* @tc.desc Function test
* @tc.level 0
*/
it("ACTS_StartAbility_1000",0, async function(done){
console.info("------------------logMessage ACTS_StartAbility_1000-------------------");
try{
var Subscriber;
let id;
function SubscribeCallBack(err, data) {
clearTimeout(id);
expect(data.event).assertEqual("ACTS_StartAbility_1000_CommonEvent");
console.debug("====>Subscribe CallBack data:====>" + JSON.stringify(data));
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
done();
}
commonEvent.createSubscriber(subscriberInfoStartAbilityTen).then(async (data) => {
console.debug("====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.debug("====>UnSubscribe CallBack====>");
done();
}
function timeout() {
expect().assertFail();
console.debug('ACTS_StartAbility_1000=====timeout======');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
done();
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
let Want = {
bundleName: "com.example.startability",
abilityName: "com.example.startability.MainAbility",
uri: "xxxxx",
}
var StartAbilityParameter = {
want:Want
}
featureAbility.startAbility(StartAbilityParameter,(err,data)=>{
console.log('ACTS_StartAbility_1000 asyncCallback errCode : ' + JSON.stringify(err)
+ " data: " + JSON.stringify(data));
expect(err.code == 0).assertTrue();
done();
});
}catch(error){
console.log("ACTS_StartAbility_1000 : error = " + error);
}
})
/**
* @tc.number: ACTS_StartAbility_0100
* @tc.name: StartAbility : A Page or Service ability uses this method to start a specific ability.
......@@ -1099,7 +1158,7 @@ describe('ActsFeatureAbilityTest', function () {
(error, data) => {
console.log("ACTS_HasWindowFocus_0400 asyncCallback code: " + error.code + " data: " + data)
expect(error.code).assertEqual(0);
expect(data).assertEqual(true);
expect(data).assertEqual(false);
done();
}
);
......@@ -1228,7 +1287,7 @@ describe('ActsFeatureAbilityTest', function () {
}
}
commonEvent.createSubscriber(subscriberInfoTerminateAbilityTwo).then(async (data) => {
commonEvent.createSubscriber(subscriberInfo_ACTS_TerminateAbility_0200).then(async (data) => {
console.debug("====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
......@@ -1525,13 +1584,13 @@ describe('ActsFeatureAbilityTest', function () {
// expect(info.iconId).assertEqual(0); //create by DevEco when building HAP.
expect(info.process).assertEqual("processTest");
expect(info.supportedModes).assertEqual(0);
expect(info.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/" +
expect(info.moduleSourceDirs[0]).assertEqual("/data/accounts/account_0/applications/" +
"com.example.actsfeatureabilitytest/com.example.actsfeatureabilitytest");
expect(info.permissions[0]).assertEqual("ohos.permission.CAMERA");
expect(info.moduleInfos[0].moduleName).assertEqual("entry");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/accounts/account_0/applications/" +
"com.example.actsfeatureabilitytest/com.example.actsfeatureabilitytest");
expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/" +
expect(info.entryDir).assertEqual("/data/accounts/account_0/applications/" +
"com.example.actsfeatureabilitytest/com.example.actsfeatureabilitytest");
}
......@@ -1806,14 +1865,17 @@ describe('ActsFeatureAbilityTest', function () {
expect(data.type).assertEqual(1);
expect(data.subType).assertEqual(0);
expect(data.orientation).assertEqual(0);
expect(data.launchMode).assertEqual(0);
expect(data.launchMode).assertEqual(1);
expect(data.permissions[0]).assertEqual("ohos.permission.ACCELEROMETER");
expect(data.permissions[1]).assertEqual("ohos.permission.ANSWER_CALL");
expect(data.deviceTypes[0]).assertEqual("phone");
expect(data.deviceCapabilities[0]).assertEqual("screen_support");
expect(data.deviceCapabilities[1]).assertEqual("audio_support");
expect(data.readPermission).assertEqual("");
expect(data.writePermission).assertEqual("");
checkApplicationInfo(data.applicationInfo);
expect(data.formEntity).assertEqual(0);
expect(data.minFormHeight).assertEqual(0);
expect(data.defaultFormHeight).assertEqual(0);
......@@ -2179,65 +2241,6 @@ describe('ActsFeatureAbilityTest', function () {
}
});
/*
* @tc.number ACTS_StartAbility_1000
* @tc.name The configured URI is started and the page is not configured
* @tc.desc Function test
* @tc.level 0
*/
it("ACTS_StartAbility_1000",0, async function(done){
console.info("------------------logMessage ACTS_StartAbility_1000-------------------");
try{
var Subscriber;
let id;
function SubscribeCallBack(err, data) {
clearTimeout(id);
expect(data.event).assertEqual("ACTS_StartAbility_1000_CommonEvent");
console.debug("====>Subscribe CallBack data:====>" + JSON.stringify(data));
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
done();
}
commonEvent.createSubscriber(subscriberInfoStartAbilityTen).then(async (data) => {
console.debug("====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.debug("====>UnSubscribe CallBack====>");
done();
}
function timeout() {
expect().assertFail();
console.debug('ACTS_StartAbility_1000=====timeout======');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
done();
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
let Want = {
bundleName: "com.example.startability",
abilityName: "com.example.startability.MainAbility",
uri: "xxxxx",
}
var StartAbilityParameter = {
want:Want
}
featureAbility.startAbility(StartAbilityParameter,(err,data)=>{
console.log('ACTS_StartAbility_1000 asyncCallback errCode : ' + JSON.stringify(err)
+ " data: " + JSON.stringify(data));
expect(err.code == 0).assertTrue();
done();
});
}catch(error){
console.log("ACTS_StartAbility_1000 : error = " + error);
}
})
/*
* @tc.number ACTS_StartAbility_1100
* @tc.name Verify the ability of implicitly starting through action without configuring action
......@@ -2257,7 +2260,7 @@ describe('ActsFeatureAbilityTest', function () {
featureAbility.startAbility(StartAbilityParameter,(err,data)=>{
console.log('ACTS_StartAbility_1100 asyncCallback errCode : ' + JSON.stringify(err)
+ " data: " + JSON.stringify(data));
expect(err.code != 0).assertTrue();
expect(err.code == 2097155).assertTrue();
done();
});
}catch(error){
......@@ -2285,7 +2288,7 @@ describe('ActsFeatureAbilityTest', function () {
featureAbility.startAbility(StartAbilityParameter,(err,data)=>{
console.log('ACTS_StartAbility_1200 asyncCallback errCode : ' + JSON.stringify(err)
+ " data: " + JSON.stringify(data));
expect(err.code != 0).assertTrue();
expect(err.code == 2097155).assertTrue();
done();
});
}catch(error){
......@@ -2392,11 +2395,12 @@ describe('ActsFeatureAbilityTest', function () {
want:Want
}
featureAbility.startAbility(StartAbilityParameter).then((data) => {
console.log("ACTS_StartAbility_1600 asyncCallbackdata: " + JSON.stringify(data));
}).catch((error) => {
console.log("ACTS_StartAbility_1600 : error = " + JSON.stringify(error));
await featureAbility.startAbility(StartAbilityParameter).then((data) => {
console.log('ACTS_StartAbility_1600 errCode : ' + " data: " + JSON.stringify(data));
expect().assertFail();
done();
}).catch((err)=>{
expect(err.code == 2097155).assertTrue();
});
});
......@@ -2408,14 +2412,14 @@ describe('ActsFeatureAbilityTest', function () {
*/
it("ACTS_StartAbility_1700",0, async function(){
console.info("------------------logMessage ACTS_StartAbility_1700-------------------");
try{
var StartAbilityParameter = {}
var promise = await featureAbility.startAbility(StartAbilityParameter);
console.log('ACTS_StartAbility_1700 promise is : ' + JSON.stringify(promise));
await featureAbility.startAbility(StartAbilityParameter).then((data) => {
console.log('ACTS_StartAbility_1700 data: ' + JSON.stringify(data));
expect().assertFail();
done();
}catch(error){
console.log("ACTS_StartAbility_1700 : error = " + JSON.stringify(error));
}
}).catch((err)=>{
expect(err.code == -104).assertTrue();
});
});
/*
......@@ -2426,11 +2430,13 @@ describe('ActsFeatureAbilityTest', function () {
*/
it("ACTS_StartAbility_1800",0, async function(done){
console.info("------------------logMessage ACTS_StartAbility_1800-------------------");
featureAbility.startAbility(undefined).then((data) => {
console.log("ACTS_StartAbility_1800 asyncCallbackdata: " + JSON.stringify(data));;
}).catch((error) => {
console.log("ACTS_StartAbility_1800 : error = " + JSON.stringify(error));
await featureAbility.startAbility(undefined).then((data) => {
console.log('ACTS_StartAbility_1800 asyncCallback data: ' + JSON.stringify(data));
expect().assertFail();
done();
}).catch((err)=>{
expect(err.code == -104).assertTrue();
});
});
})
......@@ -323,7 +323,6 @@ describe('ActsGetWantTest', function () {
},
(err, data) => {
console.info('====> ACTS_StartAbilityForResult_0700 start ability=====>' + JSON.stringify(data))
console.info('====> ACTS_StartAbilityForResult_0700 Ret:' + JSON.stringify(err))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
......@@ -377,8 +376,26 @@ describe('ActsGetWantTest', function () {
},
(err, data) => {
console.info('====> ACTS_StartAbilityForResult_0800 start ability=====>' + JSON.stringify(data))
console.info('====> ACTS_StartAbilityForResult_0800 Ret:' + JSON.stringify(err))
expect(err.code == 0).assertFalse(); // StartAbility with continuation flags is not allowed.
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITY_CONTINUATION );
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> before done=====>')
done();
})
......@@ -994,7 +1011,7 @@ describe('ActsGetWantTest', function () {
mykey2: "[1, 2, 3]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "!@#$%", "helloopenharmony"],
mykey5: ["str", "test123", "helloopenharmony"],
},
},
},
......@@ -1028,7 +1045,7 @@ describe('ActsGetWantTest', function () {
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("!@#$%");
expect(data.want.parameters.mykey5[1]).assertEqual("test123");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmony");
console.info('====> before done=====>')
}
......
......@@ -30,8 +30,12 @@ export default {
(err, data) => {
globalWant = data;
console.debug("==========data=" + JSON.stringify(globalWant));
if (globalWant.parameters.mykey5[1] == 'test123'){
featureAbility.getWant().then((data) =>{
globalWant = data
setTimeout(function(){
console.debug("==========data1 bundleName is===========" + JSON.stringify(globalWant.bundleName));
console.debug("==========data2 bundleName is==========="
+ JSON.stringify(globalWant.bundleName));
var promise = featureAbility.terminateSelfWithResult(
{
resultCode: 1,
......@@ -39,6 +43,19 @@ export default {
}
);
},1000);
})
}else{
setTimeout(function(){
console.debug("==========data1 bundleName is==========="
+ JSON.stringify(globalWant.bundleName));
var promise = featureAbility.terminateSelfWithResult(
{
resultCode: 1,
want: globalWant
}
);
},1000);
}
}
)
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册