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

!3359 【OpenHarmony开源贡献者计划2022】NAPI接口用例补充

Merge pull request !3359 from bayanxing/master
......@@ -19,162 +19,234 @@ import abilityFeatureAbility from '@ohos.ability.featureAbility'
var timeSleep = 3000;
describe('DistributedTest', function(){
describe('DistributedTest', function () {
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0300
* @tc.name testContinueAbility0300
* @tc.desc T
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0200
* @tc.name testContinueAbility0200
* @tc.desc T (by callback)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility0300', 0, async function (done) {
console.log('testContinueAbility0300 run start');
it('testContinueAbility0200', 0, async function (done) {
console.log('testContinueAbility0200 run start');
abilityFeatureAbility.continueAbility(undefined, (err, data) => {
console.log('testContinueAbility0300 err is :' + JSON.stringify(err) + ', value is :'
+ JSON.stringify(data));
console.log('testContinueAbility0200 err is :' + JSON.stringify(error));
console.log('testContinueAbility0200 value is :' + JSON.stringify(data));
})
await sleep(timeSleep);
console.log('testContinueAbility0300 run end');
console.log('testContinueAbility0200 run end');
done();
})
})
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0400
* @tc.name testContinueAbility0200
* @tc.desc T
* @tc.name testContinueAbility0400
* @tc.desc T (by callback)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility0400', 0, async function (done) {
it('testContinueAbility0400', 0, async function (done) {
console.log('testContinueAbility0400 run start');
abilityFeatureAbility.continueAbility("", (err, data) => {
console.log('testContinueAbility0400 err is :' + JSON.stringify(err) + ', value is :'
+ JSON.stringify(data));
console.log('testContinueAbility0400 err is :' + JSON.stringify(err));
console.log('testContinueAbility0400 value is :' + JSON.stringify(data));
})
await sleep(timeSleep);
console.log('testContinueAbility0400 run end');
done();
})
})
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0500
* @tc.name testContinueAbility0500
* @tc.desc T
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0600
* @tc.name testContinueAbility0600
* @tc.desc T (by callback)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility0500', 0, async function (done) {
it('testContinueAbility0600', 0, async function (done) {
let options = {
deviceId : undefined,
reversible : false,
deviceId: undefined,
reversible: false,
}
console.log('testContinueAbility0500 run start');
console.log('testContinueAbility0600 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => {
console.log('testContinueAbility0500 err is :' + JSON.stringify(err) + ', value is :'
+ JSON.stringify(data));
console.log('testContinueAbility0600 err is :' + JSON.stringify(err));
console.log('testContinueAbility0600 value is :' + JSON.stringify(data));
})
await sleep(timeSleep);
console.log('testContinueAbility0500 run end');
console.log('testContinueAbility0600 run end');
done();
})
})
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0600
* @tc.name testContinueAbility0600
* @tc.desc T
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0700
* @tc.name testContinueAbility0700
* @tc.desc T (by promise)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility0600', 0, async function (done) {
it('testContinueAbility0700', 0, async function (done) {
let options = {
deviceId : "",
reversible : false,
deviceId: "",
reversible: false,
}
console.log('testContinueAbility0600 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => {
console.log('testContinueAbility0600 err is :' + JSON.stringify(err) + ', value is :'
+ JSON.stringify(data));
console.log('testContinueAbility0700 run start');
abilityFeatureAbility.continueAbility(options).then((data) => {
console.log('testContinueAbility0700 value is :' + JSON.stringify(data));
}).catch((error) => {
console.log('testContinueAbility0700 err is :' + JSON.stringify(error));
})
await sleep(timeSleep);
console.log('testContinueAbility0600 run end');
console.log('testContinueAbility0700 run end');
done();
})
})
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0700
* @tc.name testContinueAbility0700
* @tc.desc T
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0800
* @tc.name testContinueAbility0800
* @tc.desc T (by callback)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility0700', 0, async function (done) {
it('testContinueAbility0800', 0, async function (done) {
let options = {
reversible : false,
deviceId: "",
reversible: false,
}
console.log('testContinueAbility0700 run start');
console.log('testContinueAbility0800 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => {
console.log('testContinueAbility0700 err is :' + JSON.stringify(err) + ', value is :'
+ JSON.stringify(data));
console.log('testContinueAbility0800 err is :' + JSON.stringify(err));
console.log('testContinueAbility0800 value is :' + JSON.stringify(data));
})
await sleep(timeSleep);
console.log('testContinueAbility0700 run end');
console.log('testContinueAbility0800 run end');
done();
})
})
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0900
* @tc.name testContinueAbility0900
* @tc.desc T
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_1000
* @tc.name testContinueAbility1000
* @tc.desc T (by callback)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility0900', 0, async function (done) {
it('testContinueAbility1000', 0, async function (done) {
let options = {
deviceId : "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26",
reversible : false,
reversible: false,
}
console.log('testContinueAbility0900 run start');
console.log('testContinueAbility1000 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => {
console.log('testContinueAbility0900 err is :' + JSON.stringify(err) + ', value is :'
+ JSON.stringify(data));
console.log('testContinueAbility1000 err is :' + JSON.stringify(err));
console.log('testContinueAbility1000 value is :' + JSON.stringify(data));
})
await sleep(timeSleep);
console.log('testContinueAbility0900 run end');
console.log('testContinueAbility1000 run end');
done();
})
})
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_1000
* @tc.name testContinueAbility0900
* @tc.desc T
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_1100
* @tc.name testContinueAbility1100
* @tc.desc T (by promise)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility1100', 0, async function (done) {
let options = {
deviceId: "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26",
reversible: false,
}
console.log('testContinueAbility1100 run start');
abilityFeatureAbility.continueAbility(options).then((data) => {
console.log('testContinueAbility1100 value is :' + JSON.stringify(data));
}).catch((error) => {
console.log('testContinueAbility1100 err is :' + JSON.stringify(error));
})
await sleep(timeSleep);
console.log('testContinueAbility1100 run end');
done();
})
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_1200
* @tc.name testContinueAbility1200
* @tc.desc T (by callback)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility1000', 0, async function (done) {
it('testContinueAbility1200', 0, async function (done) {
let options = {
deviceId: "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26",
reversible: false,
}
console.log('testContinueAbility1200 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => {
console.log('testContinueAbility1200 err is :' + JSON.stringify(err));
console.log('testContinueAbility1200 value is :' + JSON.stringify(data));
})
await sleep(timeSleep);
console.log('testContinueAbility1200 run end');
done();
})
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_1300
* @tc.name testContinueAbility1300
* @tc.desc T (by promise)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility1300', 0, async function (done) {
let options = {
deviceId : "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26",
reversible : false,
deviceId: "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26",
reversible: false,
}
for(var i = 0; i < 10; i++) {
for (var i = 0; i < 10; i++) {
abilityFeatureAbility.continueAbility(options).then((data) => {
console.log('testContinueAbility1300 value is :' + JSON.stringify(data));
}).catch((error) => {
console.log('testContinueAbility1300 err is :' + JSON.stringify(error));
})
}
await sleep(timeSleep);
console.log('testContinueAbility1300 run end');
done();
})
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_1400
* @tc.name testContinueAbility1400
* @tc.desc T (by callback)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility1400', 0, async function (done) {
let options = {
deviceId: "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26",
reversible: false,
}
for (var i = 0; i < 10; i++) {
abilityFeatureAbility.continueAbility(options, (err, data) => {
console.log('testContinueAbility1000 err is :' + JSON.stringify(err) + ', value is :'
console.log('testContinueAbility1400 err is :' + JSON.stringify(err) + ', value is :'
+ JSON.stringify(data));
})
}
await sleep(timeSleep);
console.log('testContinueAbility1000 run end');
console.log('testContinueAbility1400 run end');
done();
})
})
})
\ No newline at end of file
......@@ -62,7 +62,7 @@ afterAll((done) => {
done();
}, gSetTimeout);
})
/*
* @tc.number: ACTS_AfeatureAbilityEnum_0100
* @tc.name: Enum the client resource of the Data ability.
......@@ -74,7 +74,7 @@ it('ACTS_AfeatureAbilityEnum_0100', 0, async function (done) {
expect(featureAbility.ContinuationState.LOCAL_RUNNING).assertEqual(0);
expect(featureAbility.ContinuationState.REMOTE_RUNNING).assertEqual(1);
expect(featureAbility.ContinuationState.REPLICA_RUNNING).assertEqual(2);
expect(abilityManager.ProcessErrCode.NO_ERROR).assertEqual(0);
expect(abilityManager.ProcessErrCode.CRASHED).assertEqual(1);
expect(abilityManager.ProcessErrCode.NO_RESPONSE).assertEqual(2);
......@@ -750,11 +750,10 @@ it("ACTS_Call_0100", 0, async function (done) {
console.log('ACTS_Call_0100 end......');
})
/*
* @tc.number: ACTS_Call_0200
* @tc.name: call : Queries data in the database.
* @tc.desc: Check the return value of the interface
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("ACTS_Call_0200", 0, async function (done) {
......@@ -768,13 +767,12 @@ it("ACTS_Call_0200", 0, async function (done) {
try {
rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper));
rDAHelper.call(dataAbilityUri, 'query', arg, pacMap, (err, data) => {
if (err) {
console.error('ACTS_Call_0200 error: ' + JSON.stringify(err));
} else {
console.info('ACTS_Call_0200 succeeded: ' + JSON.stringify(data));
}
rDAHelper.call(dataAbilityUri, 'query', arg, pacMap).then((data) => {
console.info('ACTS_Call_0200 succeeded data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('ACTS_Call_0200 error: ' + JSON.stringify(error));
});
done();
} catch (err) {
console.error('ACTS_Call_0200 catch(err)====>:' + err);
console.log('ACTS_Call_0200====<end catch(err)');
......@@ -786,7 +784,7 @@ it("ACTS_Call_0200", 0, async function (done) {
/*
* @tc.number: ACTS_Call_0300
* @tc.name: call : Updates data records in the database.
* @tc.desc: Check the return value of the interface
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("ACTS_Call_0300", 0, async function (done) {
......@@ -800,13 +798,12 @@ it("ACTS_Call_0300", 0, async function (done) {
try {
rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper));
rDAHelper.call(dataAbilityUri, 'update', arg, pacMap, (err, data) => {
if (err) {
console.error('ACTS_Call_0300 error: ' + JSON.stringify(err));
} else {
console.info('ACTS_Call_0300 succeeded: ' + JSON.stringify(data));
}
rDAHelper.call(dataAbilityUri, 'update', arg, pacMap).then((data) => {
console.info('ACTS_Call_0300 succeeded data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('ACTS_Call_0300 error: ' + JSON.stringify(error));
});
done();
} catch (err) {
console.error('ACTS_Call_0300 catch(err)====>:' + err);
console.log('ACTS_Call_0300====<end catch(err)');
......@@ -818,7 +815,7 @@ it("ACTS_Call_0300", 0, async function (done) {
/*
* @tc.number: ACTS_Call_0400
* @tc.name: call : Deletes one or more data records from the database.
* @tc.desc: Check the return value of the interface
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("ACTS_Call_0400", 0, async function (done) {
......@@ -828,23 +825,153 @@ it("ACTS_Call_0400", 0, async function (done) {
'ringtone_modify_time': 32,
};
var rDAHelper
try {
rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper));
rDAHelper.call(dataAbilityUri, 'delete', arg, pacMap).then((data) => {
console.info('ACTS_Call_0400 succeeded data: ' + JSON.stringify(data));
}).catch((error) => {
console.error('ACTS_Call_0400 error: ' + JSON.stringify(error));
});
done();
} catch (err) {
console.error('ACTS_Call_0400 catch(err)====>:' + err);
console.log('ACTS_Call_0400====<end catch(err)');
done();
}
console.log('ACTS_Call_0400 end......');
})
/*
* @tc.number: ACTS_Call_0500
* @tc.name: call : Inserts a single data record into the database.
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it("ACTS_Call_0500", 0, async function (done) {
console.log('ACTS_Call_0500 start......');
var pacMap = {
'groupName': 'test1',
'ringtone_modify_time': 28
};
var rDAHelper
try {
rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper));
expect(typeof (rDAHelper)).assertEqual("object");
pacMap.groupName = 'test2';
rDAHelper.call(dataAbilityUri, 'insert', '', pacMap, (err, data) => {
if (err) {
console.error('ACTS_Call_0500 error: ' + JSON.stringify(err));
} else {
console.info('ACTS_Call_0500 succeeded: ' + JSON.stringify(data));
}
});
done();
} catch (err) {
console.error('ACTS_Call_0500 catch(err)====>:' + err);
console.log('ACTS_Call_0500====<end catch(err)');
done();
}
console.log('ACTS_Call_0500 end......');
})
/*
* @tc.number: ACTS_Call_0600
* @tc.name: call : Queries data in the database.
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it("ACTS_Call_0600", 0, async function (done) {
console.log('ACTS_Call_0600 start......');
var arg = "{\"equalTo\": \"groupName\"}";
var pacMap = {
"groupName": "test1",
"columns": "groupName,ringtone_modify_time"
};
var rDAHelper
try {
rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper));
rDAHelper.call(dataAbilityUri, 'query', arg, pacMap, (err, data) => {
if (err) {
console.error('ACTS_Call_0600 error: ' + JSON.stringify(err));
} else {
console.info('ACTS_Call_0600 succeeded: ' + JSON.stringify(data));
}
});
done();
} catch (err) {
console.error('ACTS_Call_0600 catch(err)====>:' + err);
console.log('ACTS_Call_0600====<end catch(err)');
done();
}
console.log('ACTS_Call_0600 end......');
})
/*
* @tc.number: ACTS_Call_0700
* @tc.name: call : Updates data records in the database.
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it("ACTS_Call_0700", 0, async function (done) {
console.log('ACTS_Call_0700 start......');
var arg = "{\"equalTo\": \"ringtone_modify_time\"}";
var pacMap = {
'ringtone_modify_time': 28,
'groupName': 'testupdata1'
};
var rDAHelper
try {
rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper));
rDAHelper.call(dataAbilityUri, 'update', arg, pacMap, (err, data) => {
if (err) {
console.error('ACTS_Call_0700 error: ' + JSON.stringify(err));
} else {
console.info('ACTS_Call_0700 succeeded: ' + JSON.stringify(data));
}
});
done();
} catch (err) {
console.error('ACTS_Call_0700 catch(err)====>:' + err);
console.log('ACTS_Call_0700====<end catch(err)');
done();
}
console.log('ACTS_Call_0700 end......');
})
/*
* @tc.number: ACTS_Call_0800
* @tc.name: call : Deletes one or more data records from the database.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("ACTS_Call_0800", 0, async function (done) {
console.log('ACTS_Call_0800 start......');
var arg = "{\"lessThan\": \"ringtone_modify_time\"}";
var pacMap = {
'ringtone_modify_time': 32,
};
var rDAHelper
try {
rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper));
rDAHelper.call(dataAbilityUri, 'delete', arg, pacMap, (err, data) => {
if (err) {
console.error('ACTS_Call_0400 error: ' + JSON.stringify(err));
console.error('ACTS_Call_0800 error: ' + JSON.stringify(err));
} else {
console.info('ACTS_Call_0400 succeeded: ' + JSON.stringify(data));
console.info('ACTS_Call_0800 succeeded: ' + JSON.stringify(data));
}
});
done();
} catch (err) {
console.error('ACTS_Call_0400 catch(err)====>:' + err);
console.log('ACTS_Call_0400====<end catch(err)');
console.error('ACTS_Call_0800 catch(err)====>:' + err);
console.log('ACTS_Call_0800====<end catch(err)');
done();
}
console.log('ACTS_Call_0400 end......');
console.log('ACTS_Call_0800 end......');
})
})
\ No newline at end of file
......@@ -229,15 +229,39 @@ describe('ActsContextTest', function () {
it('ACTS_RequestPermissionForUser_0100', 0, async function (done) {
var ret = false
var context = await featureAbility.getContext();
console.log("RequestPermissionForUser ----------1");
console.log("ACTS_RequestPermissionForUser_0100 ----------1");
context.requestPermissionsFromUser([], 1,
(err, data)=>{
console.log("====>requestdata====>" + JSON.stringify(data));
console.log("====>requesterrcode====>" + JSON.stringify(err.code));
console.log("====>ACTS_RequestPermissionForUser_0100 data====>" + JSON.stringify(data));
console.log("====>ACTS_RequestPermissionForUser_0100 err====>" + JSON.stringify(err.code));
expect(err.code).assertEqual(-104)
});
console.log("RequestPermissionForUser ----------2");
console.log("ACTS_RequestPermissionForUser_0100 ----------2");
ret = true
done();
setTimeout(function(){
expect(ret).assertEqual(true)
},1000)
})
// @tc.number: ACTS_RequestPermissionForUser_0200
// @tc.name: requestPermissionsFromUser : Requests certain permissions from the system.
// permission: The list of permissions to be requested.
// @tc.desc: Requests certain permissions from the system.
// process is the current process. (by promise)
it('ACTS_RequestPermissionForUser_0200', 0, async function (done) {
var ret = false
var context = await featureAbility.getContext();
console.log("ACTS_RequestPermissionForUser_0200 ----------1");
context.requestPermissionsFromUser([], 1).then((data) => {
console.log("====>ACTS_RequestPermissionForUser_0200 data====>" + JSON.stringify(data));
}).catch((err) => {
console.log("====>ACTS_RequestPermissionForUser_0200 err====>" + JSON.stringify(err.code));
expect(err.code).assertEqual(-104)
})
console.log("ACTS_RequestPermissionForUser_0200 ----------2");
ret = true
done();
setTimeout(function(){
......
......@@ -27,7 +27,7 @@ describe('ConnectAbilityTest', function () {
/*
* @tc.number: SUB_AA_JsApi_StartAbility_0100
* @tc.name: testAbility0100.
* @tc.desc: StartAbility fail with want nothing.
* @tc.desc: StartAbility fail with want nothing.(by promise)
*/
it("SUB_AA_JsApi_StartAbility_0100", 0, async function (done) {
let parameter = {
......@@ -44,19 +44,57 @@ describe('ConnectAbilityTest', function () {
})
/*
* @tc.number: SUB_AA_JsApi_StartAbility_0200
* @tc.name: testAbility0200.
* @tc.desc: StartAbility fail with error parameter.
* @tc.number: SUB_AA_JsApi_Ability_0200
* @tc.name: testAblity0200.
* @tc.desc: StartAbility fail with want nothing.(by callback)
*/
it("SUB_AA_JsApi_Ability_0200", 0, async function (done) {
let parameter = {
'want': {}
}
featureAbility.startAbility(parameter, (error, data) => {
console.log('testAbility0200 data: ' + JSON.stringify(data))
console.log('testAbility0200 error: ' + JSON.stringify(error))
expect(errCode1).assertEqual(error.code)
done();
})
})
/*
* @tc.number: SUB_AA_JsApi_StartAbility_0300
* @tc.name: testAbility0300.
* @tc.desc: StartAbility fail with error parameter.(by promise)
*/
it("SUB_AA_JsApi_StartAbility_0300", 0, async function (done) {
let parameter = {
'StartAbilityParameter': {
'want': {}
}
}
await featureAbility.startAbility(parameter).then((data) => {
console.log('testAbility0300 data: ' + JSON.stringify(data))
expect().assertFail()
}).catch((error) => {
console.log('testAbility0300 error: ' + JSON.stringify(error))
expect(errCode).assertEqual(error.code)
})
done()
})
/*
* @tc.number: SUB_AA_JsApi_StartAbility_0400
* @tc.name: testAbility0400.
* @tc.desc: StartAbility fail with error parameter.(by callback)
*/
it("SUB_AA_JsApi_StartAbility_0200", 0, async function (done) {
it("SUB_AA_JsApi_StartAbility_0400", 0, async function (done) {
let parameter = {
'StartAbilityParameter': {
'want': {}
}
}
featureAbility.startAbility((parameter), (error, data) => {
console.log('testAbility0200 data: ' + JSON.stringify(data))
console.log('testAbility0200 error: ' + JSON.stringify(error))
console.log('testAbility0400 data: ' + JSON.stringify(data))
console.log('testAbility0400 error: ' + JSON.stringify(error))
expect(errCode).assertEqual(error.code)
done()
})
......@@ -65,7 +103,7 @@ describe('ConnectAbilityTest', function () {
/*
* @tc.number: SUB_AA_JsApi_Ability_0500
* @tc.name: testAblity0500.
* @tc.desc: startAbility-want configure action+entities- there is no Ability corresponding to entities.
* @tc.desc: startAbility-want configure action+entities- there is no Ability corresponding to entities.(by promise)
*/
it("SUB_AA_JsApi_Ability_0500", 0, async function (done) {
let parameter = {
......@@ -89,38 +127,35 @@ describe('ConnectAbilityTest', function () {
/*
* @tc.number: SUB_AA_JsApi_Ability_0600
* @tc.name: testAblity0600.
* @tc.desc: startAbility-want-configuration action+entities-entities is configured as a string.
* @tc.desc: startAbility-want configure action+entities- there is no Ability corresponding to entities.(by callback)
*/
it("SUB_AA_JsApi_Ability_0600", 0, async function (done) {
let parameter = {
'want': {
'action': 'action.ohos.acts.aafwk.jsapi.MainAbility',
'entities': 'abc123'
'entities': [
'entity.com.example.mytestw.ENITIES22'
]
}
}
await featureAbility.startAbility(parameter).then((data) => {
console.log('testAblity0600 data: ' + JSON.stringify(data))
expect().assertFail()
}).catch((error) => {
console.log('testAblity0600 error: ' + JSON.stringify(error))
featureAbility.startAbility((parameter), (error, data) => {
console.log('testAbility0600 data: ' + JSON.stringify(data))
console.log('testAbility0600 error: ' + JSON.stringify(error))
expect(errCode1).assertEqual(error.code)
done()
})
done()
})
/*
* @tc.number: SUB_AA_JsApi_Ability_0700
* @tc.name: testAblity0700.
* @tc.desc: startAbility-want configure action+entities- entities is configurd as a string.
* @tc.desc: startAbility-want-configuration action+entities-entities is configured as a string.(by promise)
*/
it("SUB_AA_JsApi_Ability_0700", 0, async function (done) {
let parameter = {
'startAbilityParameter': {
'want': {
'bundleName': bundleName,
'abilityName': mainAbilityName
}
'want': {
'action': 'action.ohos.acts.aafwk.jsapi.MainAbility',
'entities': 'abc123'
}
}
await featureAbility.startAbility(parameter).then((data) => {
......@@ -128,7 +163,7 @@ describe('ConnectAbilityTest', function () {
expect().assertFail()
}).catch((error) => {
console.log('testAblity0700 error: ' + JSON.stringify(error))
expect(errCode).assertEqual(error.code)
expect(errCode1).assertEqual(error.code)
})
done()
})
......@@ -136,86 +171,200 @@ describe('ConnectAbilityTest', function () {
/*
* @tc.number: SUB_AA_JsApi_Ability_0800
* @tc.name: testAblity0800.
* @tc.desc: startAbility-want configure action+entities- entities is configurd as a string.
* @tc.desc: startAbility-want-configuration action+entities-entities is configured as a string.(by callback)
*/
it("SUB_AA_JsApi_Ability_0800", 0, async function (done) {
let parameter = {
'want': {}
'want': {
'action': 'action.ohos.acts.aafwk.jsapi.MainAbility',
'entities': 'abc123'
}
}
featureAbility.startAbility(parameter, (err, data) => {
console.log('testAblity0800 data: ' + JSON.stringify(data) + ',err: ' + JSON.stringify(err))
expect(errCode1).assertEqual(err.code)
done();
featureAbility.startAbility((parameter), (error, data) => {
console.log('testAblity0800 data: ' + JSON.stringify(data))
console.log('testAblity0800 error: ' + JSON.stringify(error))
expect(errCode1).assertEqual(error.code)
done()
})
})
/*
* @tc.number: SUB_AA_JsApi_Ability_0900
* @tc.name: testAblity0900.
* @tc.desc: startAbility: The input parameter want is not configured (the value is {}).
* @tc.desc: startAbility-want configure action+entities- entities is configurd as a string.(by promise)
*/
it("SUB_AA_JsApi_Ability_0900", 0, async function (done) {
let parameter = {}
featureAbility.startAbility(parameter, (err, data) => {
console.log('testAblity0900 data: ' + JSON.stringify(data) + ',err: ' + JSON.stringify(err))
expect(errCode).assertEqual(err.code)
done();
let parameter = {
'startAbilityParameter': {
'want': {
'bundleName': bundleName,
'abilityName': mainAbilityName
}
}
}
await featureAbility.startAbility(parameter).then((data) => {
console.log('testAblity0900 data: ' + JSON.stringify(data))
expect().assertFail()
}).catch((error) => {
console.log('testAblity0900 error: ' + JSON.stringify(error))
expect(errCode).assertEqual(error.code)
})
done()
})
/*
* @tc.number: SUB_AA_JsApi_Ability_1000
* @tc.name: testAblity1000.
* @tc.desc: startAbility: The input parameter is uddefined.
* @tc.desc: startAbility-want configure action+entities- entities is configurd as a string.(by callback)
*/
it("SUB_AA_JsApi_Ability_1000", 0, async function (done) {
await featureAbility.startAbility(undefined).then((data) => {
let parameter = {
'startAbilityParameter': {
'want': {
'bundleName': bundleName,
'abilityName': mainAbilityName
}
}
}
featureAbility.startAbility((parameter), (error, data) => {
console.log('testAblity1000 data: ' + JSON.stringify(data))
console.log('testAblity1000 error: ' + JSON.stringify(error))
expect(errCode).assertEqual(error.code)
done()
})
})
/*
* @tc.number: SUB_AA_JsApi_Ability_1100
* @tc.name: testAblity1100.
* @tc.desc: startAbility: The input parameter want is not configured (the value is {}).(by promise)
*/
it("SUB_AA_JsApi_Ability_1100", 0, async function (done) {
let parameter = {}
await featureAbility.startAbility(parameter).then((data) => {
console.log('testAblity1100 data: ' + JSON.stringify(data))
expect().assertFail()
}).catch((error) => {
console.log('testAblity1000 error: ' + JSON.stringify(error))
console.log('testAblity1100 error: ' + JSON.stringify(error))
expect(errCode).assertEqual(error.code)
})
done()
})
/*
* @tc.number: SUB_AA_JsApi_Ability_1200
* @tc.name: testAblity1200.
* @tc.desc: startAbilityForResult: The input parameter want is not configured (the value is {}).
* @tc.desc: startAbility: The input parameter want is not configured (the value is {}).(by callback)
*/
it("SUB_AA_JsApi_Ability_1200", 0, async function (done) {
let parameter = {}
await featureAbility.startAbilityForResult(parameter).then((data) => {
console.log('testAblity2900 data: ' + JSON.stringify(data) + ',err: ' + JSON.stringify(err))
expect.assertFail()
}).catch((err) => {
console.log('testAblity1200' + JSON.stringify(err));
expect().assertEqual(err.code)
featureAbility.startAbility(parameter, (error, data) => {
console.log('testAblity1200 data: ' + JSON.stringify(data))
console.log('testAblity1200 error: ' + JSON.stringify(error))
expect(errCode).assertEqual(error.code)
done();
})
done()
})
/*
* @tc.number: SUB_AA_JsApi_Ability_1300
* @tc.name: testAblity1300.
* @tc.desc: startAbilityForResult: The input parameter optParam is undefined.
* @tc.desc: startAbility: The input parameter is uddefined.(by promise)
*/
it("SUB_AA_JsApi_Ability_1300", 0, async function (done) {
featureAbility.startAbilityForResult(undefined, (err) => {
console.log('testAblity1300' + JSON.stringify(err));
expect(errCode1).assertEqual(err.code)
done()
await featureAbility.startAbility(undefined).then((data) => {
console.log('testAblity1300 data: ' + JSON.stringify(data))
expect().assertFail()
}).catch((error) => {
console.log('testAblity1300 error: ' + JSON.stringify(error))
expect(errCode).assertEqual(error.code)
})
done()
})
/*
* @tc.number: SUB_AA_JsApi_Ability_1400
* @tc.name: testAblity1400.
* @tc.desc: startAbilityForResult-wrong input parameter format want a layer outside.
* @tc.desc: startAbility: The input parameter is uddefined.(by callback)
*/
it("SUB_AA_JsApi_Ability_1400", 0, async function (done) {
featureAbility.startAbility(undefined, (error, data) => {
console.log('testAblity1400 data: ' + JSON.stringify(data))
console.log('testAblity1400 error: ' + JSON.stringify(error))
expect(errCode).assertEqual(error.code)
done();
})
})
/*
* @tc.number: SUB_AA_JsApi_Ability_1500
* @tc.name: testAblity1500.
* @tc.desc: startAbilityForResult: The input parameter want is not configured (the value is {}).(by promise)
*/
it("SUB_AA_JsApi_Ability_1500", 0, async function (done) {
let parameter = {}
await featureAbility.startAbilityForResult(parameter).then((data) => {
console.log('testAblity1500 data: ' + JSON.stringify(data))
expect.assertFail()
}).catch((error) => {
console.log('testAblity1500' + JSON.stringify(error));
expect().assertEqual(error.code)
})
done()
})
/*
* @tc.number: SUB_AA_JsApi_Ability_1600
* @tc.name: testAblity1600.
* @tc.desc: startAbilityForResult: The input parameter want is not configured (the value is {}).(by callback)
*/
it("SUB_AA_JsApi_Ability_1600", 0, async function (done) {
let parameter = {}
featureAbility.startAbilityForResult(parameter, (error, data) => {
console.log('testAblity1600 data: ' + JSON.stringify(data))
console.log('testAblity1600 error: ' + JSON.stringify(error))
expect().assertEqual(error.code)
done();
})
})
/*
* @tc.number: SUB_AA_JsApi_Ability_1700
* @tc.name: testAblity1700.
* @tc.desc: startAbilityForResult: The input parameter optParam is undefined.(by promise)
*/
it("SUB_AA_JsApi_Ability_1700", 0, async function (done) {
await featureAbility.startAbilityForResult(undefined).then((data) => {
console.log('testAblity1700 data: ' + JSON.stringify(data))
expect.assertFail()
}).catch((error) => {
console.log('testAblity1700' + JSON.stringify(error));
expect(errCode1).assertEqual(error.code)
})
done()
})
/*
* @tc.number: SUB_AA_JsApi_Ability_1800
* @tc.name: testAblity1800.
* @tc.desc: startAbilityForResult: The input parameter optParam is undefined.(by callback)
*/
it("SUB_AA_JsApi_Ability_1800", 0, async function (done) {
featureAbility.startAbilityForResult(undefined, (error) => {
console.log('testAblity1800' + JSON.stringify(error));
expect(errCode1).assertEqual(error.code)
done()
})
})
/*
* @tc.number: SUB_AA_JsApi_Ability_1900
* @tc.name: testAblity1900.
* @tc.desc: startAbilityForResult-wrong input parameter format want a layer outside.(by promise)
*/
it("SUB_AA_JsApi_Ability_1900", 0, async function (done) {
let parameter = {
'StartAbilityParameter': {
'want': {
......@@ -228,17 +377,45 @@ describe('ConnectAbilityTest', function () {
}
}
}
featureAbility.startAbilityForResult(parameter, (err, data) => {
console.log('testAblity1400' + JSON.stringify(err));
expect(errCode1).assertEqual(err.code)
await featureAbility.startAbilityForResult(parameter).then((data) => {
console.log('testAblity1900 data: ' + JSON.stringify(data))
expect.assertFail()
}).catch((error) => {
console.log('testAblity1900 err:' + JSON.stringify(error));
expect(errCode1).assertEqual(error.code)
})
done()
})
/*
* @tc.number: SUB_AA_JsApi_Ability_2000
* @tc.name: testAblity2000.
* @tc.desc: startAbilityForResult-wrong input parameter format want a layer outside.(by callback)
*/
it("SUB_AA_JsApi_Ability_2000", 0, async function (done) {
let parameter = {
'StartAbilityParameter': {
'want': {
'bundleName': bundleName,
'abilityName': mainAbilityName,
'parameters': {
'key': resultCode,
'terminate': true
}
}
}
}
featureAbility.startAbilityForResult(parameter, (error, data) => {
console.log('testAblity2000' + JSON.stringify(error));
expect(errCode1).assertEqual(error.code)
done()
})
})
})
/*
* @tc.number: SUB_AA_JsApi_Ability_2100
* @tc.name: testAblity2100.
* @tc.desc: startAbilityForResult-want-Set bundleName and abilityName+flag-flag to character strings.
* @tc.desc: startAbilityForResult-want-Set bundleName and abilityName+flag-flag to character strings.(by promise)
*/
it("SUB_AA_JsApi_Ability_2100", 0, async function (done) {
let parameter = {
......@@ -255,10 +432,34 @@ describe('ConnectAbilityTest', function () {
await featureAbility.startAbilityForResult(parameter).then((data) => {
console.log('testAblity2100 data: ' + JSON.stringify(data))
expect.assertFail()
}).catch((err) => {
console.log('testAblity2100' + JSON.stringify(err));
expect(undefined).assertEqual(err.code)
}).catch((error) => {
console.log('testAblity2100' + JSON.stringify(error));
expect(undefined).assertEqual(error.code)
})
done()
})
/*
* @tc.number: SUB_AA_JsApi_Ability_2200
* @tc.name: testAblity2200.
* @tc.desc: startAbilityForResult-want-Set bundleName and abilityName+flag-flag to character strings.(by callback)
*/
it("SUB_AA_JsApi_Ability_2200", 0, async function (done) {
let parameter = {
'want': {
'bundleName': bundleName,
'abilityName': mainAbilityName,
'flages': 'abc',
'parameters': {
'key': resultCode,
'terminate': true
}
}
}
featureAbility.startAbilityForResult(parameter, (error, data) => {
console.log('testAblity2200' + JSON.stringify(error));
expect(undefined).assertEqual(error.code)
done()
})
})
})
......@@ -80,9 +80,9 @@ describe('storageTest', function () {
})
/**
* @tc.name removeStorageFromCache interface test
* @tc.name removeStorageFromCache promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_Helper_0040
* @tc.desc removeStorageFromCache interface test
* @tc.desc removeStorageFromCache promise interface test
*/
it('testRemoveStorageFromCache002', 0, async function (done) {
let perf = storage.getStorageSync('/data/test_storage2');
......@@ -96,6 +96,27 @@ describe('storageTest', function () {
done();
})
/**
* @tc.name removeStorageFromCache callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_Helper_0041
* @tc.desc removeStorageFromCache callback interface test
*/
// it('testRemoveStorageFromCache003', 0, function (done) {
// let perf = storage.getStorageSync('/data/test_storage3');
// storage.removeStorageFromCache(perf, function (err) {
// if (err) {
// console.info("removeStorageFromCache callback interface test failed" + err);
// expect(null).assertFail();
// done();
// return
// }
// console.info("removeStorageFromCache callback interface test successfully.");
// expect(true).assertTrue();
// done();
// })
//
// })
/**
* @tc.name deleteStorageSync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_Helper_0050
......
......@@ -15,6 +15,7 @@
import wantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
var WantAgenta;
......
......@@ -511,4 +511,5 @@ describe('SimManagerTest', function () {
}
done();
});
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册