提交 5b751775 编写于 作者: B bayanxing

Merge branch 'feature/20220530' of...

Merge branch 'feature/20220530' of https://gitee.com/bayanxing/xts_acts_20220530 into feature/20220530
...@@ -19,14 +19,52 @@ import abilityFeatureAbility from '@ohos.ability.featureAbility' ...@@ -19,14 +19,52 @@ import abilityFeatureAbility from '@ohos.ability.featureAbility'
var timeSleep = 3000; var timeSleep = 3000;
describe('DistributedTest', function(){ describe('DistributedTest', function () {
function sleep(time) { function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time)); return new Promise((resolve) => setTimeout(resolve, time));
} }
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0100(by promise)
* @tc.name testContinueAbility0100
* @tc.desc T
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility0100', 0, async function (done) {
console.log('testContinueAbility0100 run start');
abilityFeatureAbility.continueAbility(undefined).then((data) => {
console.log('testContinueAbility0100 value is :' + JSON.stringify(data));
}).catch((error) => {
console.log('testContinueAbility0100 err is :' + JSON.stringify(error));
})
await sleep(timeSleep);
console.log('testContinueAbility0100 run end');
done();
})
/** /**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0300 * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0200(by callback)
* @tc.name testContinueAbility0200
* @tc.desc T
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility0200', 0, async function (done) {
console.log('testContinueAbility0200 run start');
abilityFeatureAbility.continueAbility(undefined, (err, data) => {
console.log('testContinueAbility0200 err is :' + JSON.stringify(error));
console.log('testContinueAbility0200 value is :' + JSON.stringify(data));
})
await sleep(timeSleep);
console.log('testContinueAbility0200 run end');
done();
})
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0300(by promise)
* @tc.name testContinueAbility0300 * @tc.name testContinueAbility0300
* @tc.desc T * @tc.desc T
* @tc.size : MEDIUM * @tc.size : MEDIUM
...@@ -35,9 +73,10 @@ describe('DistributedTest', function(){ ...@@ -35,9 +73,10 @@ describe('DistributedTest', function(){
*/ */
it('testContinueAbility0300', 0, async function (done) { it('testContinueAbility0300', 0, async function (done) {
console.log('testContinueAbility0300 run start'); console.log('testContinueAbility0300 run start');
abilityFeatureAbility.continueAbility(undefined, (err, data) => { abilityFeatureAbility.continueAbility("").then((data) => {
console.log('testContinueAbility0300 err is :' + JSON.stringify(err) + ', value is :' console.log('testContinueAbility0300 value is :' + JSON.stringify(data));
+ JSON.stringify(data)); }).catch((error) => {
console.log('testContinueAbility0300 err is :' + JSON.stringify(error));
}) })
await sleep(timeSleep); await sleep(timeSleep);
console.log('testContinueAbility0300 run end'); console.log('testContinueAbility0300 run end');
...@@ -45,8 +84,8 @@ describe('DistributedTest', function(){ ...@@ -45,8 +84,8 @@ describe('DistributedTest', function(){
}) })
/** /**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0400 * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0400(by callback)
* @tc.name testContinueAbility0200 * @tc.name testContinueAbility0400
* @tc.desc T * @tc.desc T
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
...@@ -55,8 +94,8 @@ describe('DistributedTest', function(){ ...@@ -55,8 +94,8 @@ describe('DistributedTest', function(){
it('testContinueAbility0400', 0, async function (done) { it('testContinueAbility0400', 0, async function (done) {
console.log('testContinueAbility0400 run start'); console.log('testContinueAbility0400 run start');
abilityFeatureAbility.continueAbility("", (err, data) => { abilityFeatureAbility.continueAbility("", (err, data) => {
console.log('testContinueAbility0400 err is :' + JSON.stringify(err) + ', value is :' console.log('testContinueAbility0400 err is :' + JSON.stringify(err));
+ JSON.stringify(data)); console.log('testContinueAbility0400 value is :' + JSON.stringify(data));
}) })
await sleep(timeSleep); await sleep(timeSleep);
console.log('testContinueAbility0400 run end'); console.log('testContinueAbility0400 run end');
...@@ -64,7 +103,7 @@ describe('DistributedTest', function(){ ...@@ -64,7 +103,7 @@ describe('DistributedTest', function(){
}) })
/** /**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0500 * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0500(by promise)
* @tc.name testContinueAbility0500 * @tc.name testContinueAbility0500
* @tc.desc T * @tc.desc T
* @tc.size : MEDIUM * @tc.size : MEDIUM
...@@ -73,13 +112,14 @@ describe('DistributedTest', function(){ ...@@ -73,13 +112,14 @@ describe('DistributedTest', function(){
*/ */
it('testContinueAbility0500', 0, async function (done) { it('testContinueAbility0500', 0, async function (done) {
let options = { let options = {
deviceId : undefined, deviceId: undefined,
reversible : false, reversible: false,
} }
console.log('testContinueAbility0500 run start'); console.log('testContinueAbility0500 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => { abilityFeatureAbility.continueAbility(options).then((data) => {
console.log('testContinueAbility0500 err is :' + JSON.stringify(err) + ', value is :' console.log('testContinueAbility0500 value is :' + JSON.stringify(data));
+ JSON.stringify(data)); }).catch((error) => {
console.log('testContinueAbility0500 err is :' + JSON.stringify(error));
}) })
await sleep(timeSleep); await sleep(timeSleep);
console.log('testContinueAbility0500 run end'); console.log('testContinueAbility0500 run end');
...@@ -87,7 +127,7 @@ describe('DistributedTest', function(){ ...@@ -87,7 +127,7 @@ describe('DistributedTest', function(){
}) })
/** /**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0600 * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0600(by callback)
* @tc.name testContinueAbility0600 * @tc.name testContinueAbility0600
* @tc.desc T * @tc.desc T
* @tc.size : MEDIUM * @tc.size : MEDIUM
...@@ -96,13 +136,13 @@ describe('DistributedTest', function(){ ...@@ -96,13 +136,13 @@ describe('DistributedTest', function(){
*/ */
it('testContinueAbility0600', 0, async function (done) { it('testContinueAbility0600', 0, async function (done) {
let options = { let options = {
deviceId : "", deviceId: undefined,
reversible : false, reversible: false,
} }
console.log('testContinueAbility0600 run start'); console.log('testContinueAbility0600 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => { abilityFeatureAbility.continueAbility(options, (err, data) => {
console.log('testContinueAbility0600 err is :' + JSON.stringify(err) + ', value is :' console.log('testContinueAbility0600 err is :' + JSON.stringify(err));
+ JSON.stringify(data)); console.log('testContinueAbility0600 value is :' + JSON.stringify(data));
}) })
await sleep(timeSleep); await sleep(timeSleep);
console.log('testContinueAbility0600 run end'); console.log('testContinueAbility0600 run end');
...@@ -110,7 +150,7 @@ describe('DistributedTest', function(){ ...@@ -110,7 +150,7 @@ describe('DistributedTest', function(){
}) })
/** /**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0700 * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0700(by promise)
* @tc.name testContinueAbility0700 * @tc.name testContinueAbility0700
* @tc.desc T * @tc.desc T
* @tc.size : MEDIUM * @tc.size : MEDIUM
...@@ -119,12 +159,14 @@ describe('DistributedTest', function(){ ...@@ -119,12 +159,14 @@ describe('DistributedTest', function(){
*/ */
it('testContinueAbility0700', 0, async function (done) { it('testContinueAbility0700', 0, async function (done) {
let options = { let options = {
reversible : false, deviceId: "",
reversible: false,
} }
console.log('testContinueAbility0700 run start'); console.log('testContinueAbility0700 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => { abilityFeatureAbility.continueAbility(options).then((data) => {
console.log('testContinueAbility0700 err is :' + JSON.stringify(err) + ', value is :' console.log('testContinueAbility0700 value is :' + JSON.stringify(data));
+ JSON.stringify(data)); }).catch((error) => {
console.log('testContinueAbility0700 err is :' + JSON.stringify(error));
}) })
await sleep(timeSleep); await sleep(timeSleep);
console.log('testContinueAbility0700 run end'); console.log('testContinueAbility0700 run end');
...@@ -132,7 +174,30 @@ describe('DistributedTest', function(){ ...@@ -132,7 +174,30 @@ describe('DistributedTest', function(){
}) })
/** /**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0900 * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0800(by callback)
* @tc.name testContinueAbility0800
* @tc.desc T
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility0800', 0, async function (done) {
let options = {
deviceId: "",
reversible: false,
}
console.log('testContinueAbility0800 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => {
console.log('testContinueAbility0800 err is :' + JSON.stringify(err));
console.log('testContinueAbility0800 value is :' + JSON.stringify(data));
})
await sleep(timeSleep);
console.log('testContinueAbility0800 run end');
done();
})
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0900(by promise)
* @tc.name testContinueAbility0900 * @tc.name testContinueAbility0900
* @tc.desc T * @tc.desc T
* @tc.size : MEDIUM * @tc.size : MEDIUM
...@@ -141,13 +206,13 @@ describe('DistributedTest', function(){ ...@@ -141,13 +206,13 @@ describe('DistributedTest', function(){
*/ */
it('testContinueAbility0900', 0, async function (done) { it('testContinueAbility0900', 0, async function (done) {
let options = { let options = {
deviceId : "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26", reversible: false,
reversible : false,
} }
console.log('testContinueAbility0900 run start'); console.log('testContinueAbility0900 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => { abilityFeatureAbility.continueAbility(options).then((data) => {
console.log('testContinueAbility0900 err is :' + JSON.stringify(err) + ', value is :' console.log('testContinueAbility0900 value is :' + JSON.stringify(data));
+ JSON.stringify(data)); }).catch((error) => {
console.log('testContinueAbility0900 err is :' + JSON.stringify(error));
}) })
await sleep(timeSleep); await sleep(timeSleep);
console.log('testContinueAbility0900 run end'); console.log('testContinueAbility0900 run end');
...@@ -155,8 +220,8 @@ describe('DistributedTest', function(){ ...@@ -155,8 +220,8 @@ describe('DistributedTest', function(){
}) })
/** /**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_1000 * @tc.number SUB_AA_OpenHarmony_ContinueAbility_1000(by callback)
* @tc.name testContinueAbility0900 * @tc.name testContinueAbility1000
* @tc.desc T * @tc.desc T
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
...@@ -164,17 +229,111 @@ describe('DistributedTest', function(){ ...@@ -164,17 +229,111 @@ describe('DistributedTest', function(){
*/ */
it('testContinueAbility1000', 0, async function (done) { it('testContinueAbility1000', 0, async function (done) {
let options = { let options = {
deviceId : "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26", reversible: false,
reversible : false, }
console.log('testContinueAbility1000 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => {
console.log('testContinueAbility1000 err is :' + JSON.stringify(err));
console.log('testContinueAbility1000 value is :' + JSON.stringify(data));
})
await sleep(timeSleep);
console.log('testContinueAbility1000 run end');
done();
})
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_1100(by promise)
* @tc.name testContinueAbility1100
* @tc.desc T
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility1100', 0, async function (done) {
let options = {
deviceId: "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26",
reversible: false,
} }
for(var i = 0; i < 10; i++) { 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(by callback)
* @tc.name testContinueAbility1200
* @tc.desc T
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility1200', 0, async function (done) {
let options = {
deviceId: "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26",
reversible: false,
}
console.log('testContinueAbility1200 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => { abilityFeatureAbility.continueAbility(options, (err, data) => {
console.log('testContinueAbility1000 err is :' + JSON.stringify(err) + ', value is :' 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(by promise)
* @tc.name testContinueAbility1300
* @tc.desc T
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility1300', 0, async function (done) {
let options = {
deviceId: "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26",
reversible: false,
}
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(by callback)
* @tc.name testContinueAbility1400
* @tc.desc T
* @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('testContinueAbility1400 err is :' + JSON.stringify(err) + ', value is :'
+ JSON.stringify(data)); + JSON.stringify(data));
}) })
} }
await sleep(timeSleep); await sleep(timeSleep);
console.log('testContinueAbility1000 run end'); console.log('testContinueAbility1400 run end');
done(); done();
}) })
}) })
\ No newline at end of file
...@@ -750,11 +750,10 @@ it("ACTS_Call_0100", 0, async function (done) { ...@@ -750,11 +750,10 @@ it("ACTS_Call_0100", 0, async function (done) {
console.log('ACTS_Call_0100 end......'); console.log('ACTS_Call_0100 end......');
}) })
/* /*
* @tc.number: ACTS_Call_0200 * @tc.number: ACTS_Call_0200
* @tc.name: call : Queries data in the database. * @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 * @tc.level 0
*/ */
it("ACTS_Call_0200", 0, async function (done) { it("ACTS_Call_0200", 0, async function (done) {
...@@ -768,13 +767,12 @@ it("ACTS_Call_0200", 0, async function (done) { ...@@ -768,13 +767,12 @@ it("ACTS_Call_0200", 0, async function (done) {
try { try {
rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri); rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper)); console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper));
rDAHelper.call(dataAbilityUri, 'query', arg, pacMap, (err, data) => { rDAHelper.call(dataAbilityUri, 'query', arg, pacMap).then((data) => {
if (err) { console.info('ACTS_Call_0200 succeeded data: ' + JSON.stringify(data));
console.error('ACTS_Call_0200 error: ' + JSON.stringify(err)); }).catch((error) => {
} else { console.error('ACTS_Call_0200 error: ' + JSON.stringify(error));
console.info('ACTS_Call_0200 succeeded: ' + JSON.stringify(data));
}
}); });
done();
} catch (err) { } catch (err) {
console.error('ACTS_Call_0200 catch(err)====>:' + err); console.error('ACTS_Call_0200 catch(err)====>:' + err);
console.log('ACTS_Call_0200====<end catch(err)'); console.log('ACTS_Call_0200====<end catch(err)');
...@@ -786,7 +784,7 @@ it("ACTS_Call_0200", 0, async function (done) { ...@@ -786,7 +784,7 @@ it("ACTS_Call_0200", 0, async function (done) {
/* /*
* @tc.number: ACTS_Call_0300 * @tc.number: ACTS_Call_0300
* @tc.name: call : Updates data records in the database. * @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 * @tc.level 0
*/ */
it("ACTS_Call_0300", 0, async function (done) { it("ACTS_Call_0300", 0, async function (done) {
...@@ -800,13 +798,12 @@ it("ACTS_Call_0300", 0, async function (done) { ...@@ -800,13 +798,12 @@ it("ACTS_Call_0300", 0, async function (done) {
try { try {
rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri); rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper)); console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper));
rDAHelper.call(dataAbilityUri, 'update', arg, pacMap, (err, data) => { rDAHelper.call(dataAbilityUri, 'update', arg, pacMap).then((data) => {
if (err) { console.info('ACTS_Call_0300 succeeded data: ' + JSON.stringify(data));
console.error('ACTS_Call_0300 error: ' + JSON.stringify(err)); }).catch((error) => {
} else { console.error('ACTS_Call_0300 error: ' + JSON.stringify(error));
console.info('ACTS_Call_0300 succeeded: ' + JSON.stringify(data));
}
}); });
done();
} catch (err) { } catch (err) {
console.error('ACTS_Call_0300 catch(err)====>:' + err); console.error('ACTS_Call_0300 catch(err)====>:' + err);
console.log('ACTS_Call_0300====<end catch(err)'); console.log('ACTS_Call_0300====<end catch(err)');
...@@ -818,7 +815,7 @@ it("ACTS_Call_0300", 0, async function (done) { ...@@ -818,7 +815,7 @@ it("ACTS_Call_0300", 0, async function (done) {
/* /*
* @tc.number: ACTS_Call_0400 * @tc.number: ACTS_Call_0400
* @tc.name: call : Deletes one or more data records from the database. * @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 * @tc.level 0
*/ */
it("ACTS_Call_0400", 0, async function (done) { it("ACTS_Call_0400", 0, async function (done) {
...@@ -828,23 +825,153 @@ it("ACTS_Call_0400", 0, async function (done) { ...@@ -828,23 +825,153 @@ it("ACTS_Call_0400", 0, async function (done) {
'ringtone_modify_time': 32, 'ringtone_modify_time': 32,
}; };
var rDAHelper 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 { try {
rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri); rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper)); console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper));
rDAHelper.call(dataAbilityUri, 'delete', arg, pacMap, (err, data) => { rDAHelper.call(dataAbilityUri, 'delete', arg, pacMap, (err, data) => {
if (err) { if (err) {
console.error('ACTS_Call_0400 error: ' + JSON.stringify(err)); console.error('ACTS_Call_0800 error: ' + JSON.stringify(err));
} else { } else {
console.info('ACTS_Call_0400 succeeded: ' + JSON.stringify(data)); console.info('ACTS_Call_0800 succeeded: ' + JSON.stringify(data));
} }
}); });
done(); done();
} catch (err) { } catch (err) {
console.error('ACTS_Call_0400 catch(err)====>:' + err); console.error('ACTS_Call_0800 catch(err)====>:' + err);
console.log('ACTS_Call_0400====<end catch(err)'); console.log('ACTS_Call_0800====<end catch(err)');
done(); done();
} }
console.log('ACTS_Call_0400 end......'); console.log('ACTS_Call_0800 end......');
}) })
}) })
\ No newline at end of file
...@@ -27,7 +27,7 @@ describe('ConnectAbilityTest', function () { ...@@ -27,7 +27,7 @@ describe('ConnectAbilityTest', function () {
/* /*
* @tc.number: SUB_AA_JsApi_StartAbility_0100 * @tc.number: SUB_AA_JsApi_StartAbility_0100
* @tc.name: testAbility0100. * @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) { it("SUB_AA_JsApi_StartAbility_0100", 0, async function (done) {
let parameter = { let parameter = {
...@@ -44,19 +44,57 @@ describe('ConnectAbilityTest', function () { ...@@ -44,19 +44,57 @@ describe('ConnectAbilityTest', function () {
}) })
/* /*
* @tc.number: SUB_AA_JsApi_StartAbility_0200 * @tc.number: SUB_AA_JsApi_Ability_0200
* @tc.name: testAbility0200. * @tc.name: testAblity0200.
* @tc.desc: StartAbility fail with error parameter. * @tc.desc: StartAbility fail with want nothing.(by callback)
*/ */
it("SUB_AA_JsApi_StartAbility_0200", 0, async function (done) { 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_0400", 0, async function (done) {
let parameter = { let parameter = {
'StartAbilityParameter': { 'StartAbilityParameter': {
'want': {} 'want': {}
} }
} }
featureAbility.startAbility((parameter), (error, data) => { featureAbility.startAbility((parameter), (error, data) => {
console.log('testAbility0200 data: ' + JSON.stringify(data)) console.log('testAbility0400 data: ' + JSON.stringify(data))
console.log('testAbility0200 error: ' + JSON.stringify(error)) console.log('testAbility0400 error: ' + JSON.stringify(error))
expect(errCode).assertEqual(error.code) expect(errCode).assertEqual(error.code)
done() done()
}) })
...@@ -65,7 +103,7 @@ describe('ConnectAbilityTest', function () { ...@@ -65,7 +103,7 @@ describe('ConnectAbilityTest', function () {
/* /*
* @tc.number: SUB_AA_JsApi_Ability_0500 * @tc.number: SUB_AA_JsApi_Ability_0500
* @tc.name: testAblity0500. * @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) { it("SUB_AA_JsApi_Ability_0500", 0, async function (done) {
let parameter = { let parameter = {
...@@ -89,38 +127,35 @@ describe('ConnectAbilityTest', function () { ...@@ -89,38 +127,35 @@ describe('ConnectAbilityTest', function () {
/* /*
* @tc.number: SUB_AA_JsApi_Ability_0600 * @tc.number: SUB_AA_JsApi_Ability_0600
* @tc.name: testAblity0600. * @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) { it("SUB_AA_JsApi_Ability_0600", 0, async function (done) {
let parameter = { let parameter = {
'want': { 'want': {
'action': 'action.ohos.acts.aafwk.jsapi.MainAbility', 'action': 'action.ohos.acts.aafwk.jsapi.MainAbility',
'entities': 'abc123' 'entities': [
'entity.com.example.mytestw.ENITIES22'
]
} }
} }
await featureAbility.startAbility(parameter).then((data) => { featureAbility.startAbility((parameter), (error, data) => {
console.log('testAblity0600 data: ' + JSON.stringify(data)) console.log('testAbility0600 data: ' + JSON.stringify(data))
expect().assertFail() console.log('testAbility0600 error: ' + JSON.stringify(error))
}).catch((error) => {
console.log('testAblity0600 error: ' + JSON.stringify(error))
expect(errCode1).assertEqual(error.code) expect(errCode1).assertEqual(error.code)
})
done() done()
}) })
})
/* /*
* @tc.number: SUB_AA_JsApi_Ability_0700 * @tc.number: SUB_AA_JsApi_Ability_0700
* @tc.name: testAblity0700. * @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) { it("SUB_AA_JsApi_Ability_0700", 0, async function (done) {
let parameter = { let parameter = {
'startAbilityParameter': {
'want': { 'want': {
'bundleName': bundleName, 'action': 'action.ohos.acts.aafwk.jsapi.MainAbility',
'abilityName': mainAbilityName 'entities': 'abc123'
}
} }
} }
await featureAbility.startAbility(parameter).then((data) => { await featureAbility.startAbility(parameter).then((data) => {
...@@ -128,7 +163,7 @@ describe('ConnectAbilityTest', function () { ...@@ -128,7 +163,7 @@ describe('ConnectAbilityTest', function () {
expect().assertFail() expect().assertFail()
}).catch((error) => { }).catch((error) => {
console.log('testAblity0700 error: ' + JSON.stringify(error)) console.log('testAblity0700 error: ' + JSON.stringify(error))
expect(errCode).assertEqual(error.code) expect(errCode1).assertEqual(error.code)
}) })
done() done()
}) })
...@@ -136,86 +171,200 @@ describe('ConnectAbilityTest', function () { ...@@ -136,86 +171,200 @@ describe('ConnectAbilityTest', function () {
/* /*
* @tc.number: SUB_AA_JsApi_Ability_0800 * @tc.number: SUB_AA_JsApi_Ability_0800
* @tc.name: testAblity0800. * @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) { it("SUB_AA_JsApi_Ability_0800", 0, async function (done) {
let parameter = { 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)) featureAbility.startAbility((parameter), (error, data) => {
expect(errCode1).assertEqual(err.code) console.log('testAblity0800 data: ' + JSON.stringify(data))
done(); console.log('testAblity0800 error: ' + JSON.stringify(error))
expect(errCode1).assertEqual(error.code)
done()
}) })
}) })
/* /*
* @tc.number: SUB_AA_JsApi_Ability_0900 * @tc.number: SUB_AA_JsApi_Ability_0900
* @tc.name: testAblity0900. * @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) { it("SUB_AA_JsApi_Ability_0900", 0, async function (done) {
let parameter = {} let parameter = {
featureAbility.startAbility(parameter, (err, data) => { 'startAbilityParameter': {
console.log('testAblity0900 data: ' + JSON.stringify(data) + ',err: ' + JSON.stringify(err)) 'want': {
expect(errCode).assertEqual(err.code) 'bundleName': bundleName,
done(); '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.number: SUB_AA_JsApi_Ability_1000
* @tc.name: testAblity1000. * @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) { 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 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() expect().assertFail()
}).catch((error) => { }).catch((error) => {
console.log('testAblity1000 error: ' + JSON.stringify(error)) console.log('testAblity1100 error: ' + JSON.stringify(error))
expect(errCode).assertEqual(error.code) expect(errCode).assertEqual(error.code)
}) })
done() done()
}) })
/* /*
* @tc.number: SUB_AA_JsApi_Ability_1200 * @tc.number: SUB_AA_JsApi_Ability_1200
* @tc.name: testAblity1200. * @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) { it("SUB_AA_JsApi_Ability_1200", 0, async function (done) {
let parameter = {} let parameter = {}
await featureAbility.startAbilityForResult(parameter).then((data) => { featureAbility.startAbility(parameter, (error, data) => {
console.log('testAblity2900 data: ' + JSON.stringify(data) + ',err: ' + JSON.stringify(err)) console.log('testAblity1200 data: ' + JSON.stringify(data))
expect.assertFail() console.log('testAblity1200 error: ' + JSON.stringify(error))
}).catch((err) => { expect(errCode).assertEqual(error.code)
console.log('testAblity1200' + JSON.stringify(err)); done();
expect().assertEqual(err.code)
}) })
done()
}) })
/* /*
* @tc.number: SUB_AA_JsApi_Ability_1300 * @tc.number: SUB_AA_JsApi_Ability_1300
* @tc.name: testAblity1300. * @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) { it("SUB_AA_JsApi_Ability_1300", 0, async function (done) {
featureAbility.startAbilityForResult(undefined, (err) => { await featureAbility.startAbility(undefined).then((data) => {
console.log('testAblity1300' + JSON.stringify(err)); console.log('testAblity1300 data: ' + JSON.stringify(data))
expect(errCode1).assertEqual(err.code) expect().assertFail()
done() }).catch((error) => {
console.log('testAblity1300 error: ' + JSON.stringify(error))
expect(errCode).assertEqual(error.code)
}) })
done()
}) })
/* /*
* @tc.number: SUB_AA_JsApi_Ability_1400 * @tc.number: SUB_AA_JsApi_Ability_1400
* @tc.name: testAblity1400. * @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) { 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 callback)
*/
it("SUB_AA_JsApi_Ability_1900", 0, async function (done) {
let parameter = { let parameter = {
'StartAbilityParameter': { 'StartAbilityParameter': {
'want': { 'want': {
...@@ -228,19 +377,19 @@ describe('ConnectAbilityTest', function () { ...@@ -228,19 +377,19 @@ describe('ConnectAbilityTest', function () {
} }
} }
} }
featureAbility.startAbilityForResult(parameter, (err, data) => { featureAbility.startAbilityForResult(parameter, (error, data) => {
console.log('testAblity1400' + JSON.stringify(err)); console.log('testAblity1900' + JSON.stringify(error));
expect(errCode1).assertEqual(err.code) expect(errCode1).assertEqual(error.code)
done() done()
}) })
}) })
/* /*
* @tc.number: SUB_AA_JsApi_Ability_2100 * @tc.number: SUB_AA_JsApi_Ability_2000
* @tc.name: testAblity2100. * @tc.name: testAblity2000.
* @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) { it("SUB_AA_JsApi_Ability_2000", 0, async function (done) {
let parameter = { let parameter = {
'want': { 'want': {
'bundleName': bundleName, 'bundleName': bundleName,
...@@ -253,11 +402,11 @@ describe('ConnectAbilityTest', function () { ...@@ -253,11 +402,11 @@ describe('ConnectAbilityTest', function () {
} }
} }
await featureAbility.startAbilityForResult(parameter).then((data) => { await featureAbility.startAbilityForResult(parameter).then((data) => {
console.log('testAblity2100 data: ' + JSON.stringify(data)) console.log('testAblity2000 data: ' + JSON.stringify(data))
expect.assertFail() expect.assertFail()
}).catch((err) => { }).catch((error) => {
console.log('testAblity2100' + JSON.stringify(err)); console.log('testAblity2000' + JSON.stringify(error));
expect(undefined).assertEqual(err.code) expect(undefined).assertEqual(error.code)
}) })
done() done()
}) })
......
...@@ -36,7 +36,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -36,7 +36,7 @@ describe('ActsBundleManagerTest', function () {
/** /**
* @tc.number getBundleInfo_0100 * @tc.number getBundleInfo_0100
* @tc.name BUNDLEMGR::getBundleInfo * @tc.name BUNDLEMGR::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with one hap. * @tc.desc Test getBundleInfo interfaces with one hap.(by promise)
*/ */
it('getBundleInfo_0100', 0, async function (done) { it('getBundleInfo_0100', 0, async function (done) {
let datainfo = await demo.getBundleInfo(NAME1, let datainfo = await demo.getBundleInfo(NAME1,
...@@ -88,10 +88,160 @@ describe('ActsBundleManagerTest', function () { ...@@ -88,10 +88,160 @@ describe('ActsBundleManagerTest', function () {
done(); done();
}) })
/**
* @tc.number getBundleInfo_0200
* @tc.name BUNDLEMGR::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with one hap.(by callback)
*/
it('getBundleInfo_0200', 0, async function (done) {
await demo.getBundleInfo(NAME1,
demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES | demo.BundleFlag.GET_BUNDLE_WITH_REQUESTED_PERMISSION, OnReceiveEvent);
function OnReceiveEvent(err, datainfo) {
console.info("getBundleInfo_0200 dataInfo ====" + datainfo);
expect(datainfo.name).assertEqual(NAME1);
expect(datainfo.vendor).assertEqual("example");
expect(datainfo.versionCode).assertEqual(VERSIONCODE1);
expect(datainfo.versionName).assertEqual("1.0");
expect(datainfo.entryModuleName).assertEqual("entry");
expect(datainfo.compatibleVersion).assertEqual(5);
expect(datainfo.targetVersion).assertEqual(5);
expect(datainfo.uid).assertLarger(0);
expect(datainfo.appId).assertContain(NAME1);
expect(datainfo.type).assertEqual("");
expect(datainfo.cpuAbi).assertEqual("");
expect(datainfo.appInfo.name).assertEqual(NAME1);
expect(datainfo.appInfo.description).assertEqual(DESCRIPTION);
expect(datainfo.appInfo.descriptionId >= 0).assertTrue();
expect(datainfo.appInfo.icon).assertEqual("$media:icon");
expect(datainfo.appInfo.iconId >= 0).assertTrue();
expect(datainfo.appInfo.label).assertEqual("$string:app_name");
expect(datainfo.appInfo.labelId >= 0).assertTrue();
expect(datainfo.appInfo.systemApp).assertEqual(true);
expect(datainfo.appInfo.supportedModes).assertEqual(0);
expect(datainfo.installTime).assertLarger(0);
expect(datainfo.updateTime).assertLarger(0);
expect(datainfo.reqPermissions[0]).assertEqual("com.permission.PERMISSION_A");
expect(datainfo.reqPermissionDetails[0].name).assertEqual("com.permission.PERMISSION_A");
expect(datainfo.reqPermissionDetails[0].reason).assertEqual("Need PERMISSION_A");
expect(datainfo.reqPermissionDetails[0].usedScene.abilities[0]).assertEqual(NAME1 + ".MainAbility");
expect(datainfo.reqPermissionDetails[0].usedScene.when).assertEqual("always");
expect(datainfo.compatibleVersion).assertEqual(5);
expect(datainfo.targetVersion).assertEqual(5);
expect(datainfo.isCompressNativeLibs).assertEqual(false);
for (let s = 0; s < datainfo.hapModuleInfos; s++) {
expect(datainfo.moduleInfos[s].name).assertEqual("com.example.myapplication1");
expect(datainfo.moduleInfos[s].moduleName).assertEqual("entry");
}
expect(datainfo.entryModuleName).assertEqual("entry");
expect(datainfo.isSilentInstallation.length).assertEqual(0);
expect(datainfo.minCompatibleVersionCode).assertEqual(0);
expect(datainfo.entryInstallationFree).assertEqual(false);
for (let j = 0; j < datainfo.appInfo.moduleInfos; j++) {
expect(datainfo.appInfo.moduleInfos[j].moduleName).assertEqual("entry");
expect(datainfo.appInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1);
}
expect(datainfo.appInfo.enabled).assertEqual(true);
done();
}
})
/**
* @tc.number getBundleInfo_0300
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with two haps.(by promise)
*/
it('getBundleInfo_0300', 0, async function (done) {
let datainfo = await demo.getBundleInfo(NAME2, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES);
console.info("getBundleInfo_0300 dataInfo ====" + datainfo);
expect(datainfo.name).assertEqual(NAME2);
expect(datainfo.vendor).assertEqual("example");
expect(datainfo.versionCode).assertEqual(1);
expect(datainfo.versionName).assertLarger(0);
expect(datainfo.entryModuleName).assertEqual("entry");
expect(datainfo.appInfo.name).assertEqual(NAME2);
expect(datainfo.appInfo.description).assertEqual(DESCRIPTION);
expect(datainfo.appInfo.descriptionId >= 0).assertTrue();
expect(datainfo.appInfo.icon).assertEqual("$media:icon");
expect(datainfo.appInfo.iconId >= 0).assertTrue();
expect(datainfo.appInfo.label).assertEqual("$string:app_name");
expect(datainfo.appInfo.labelId >= 0).assertTrue();
expect(datainfo.appInfo.systemApp).assertEqual(true);
done();
})
/**
* @tc.number getBundleInfo_0400
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with two haps.(by callback)
*/
it('getBundleInfo_0400', 0, async function (done) {
await demo.getBundleInfo(NAME2, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent);
function OnReceiveEvent(err, datainfo) {
console.info("getBundleInfo_0400 dataInfo ====" + datainfo);
expect(datainfo.name).assertEqual(NAME2);
expect(datainfo.vendor).assertEqual("example");
expect(datainfo.versionCode).assertEqual(1);
expect(datainfo.versionName).assertLarger(0);
expect(datainfo.entryModuleName).assertEqual("entry");
expect(datainfo.appInfo.name).assertEqual(NAME2);
expect(datainfo.appInfo.description).assertEqual(DESCRIPTION);
expect(datainfo.appInfo.descriptionId >= 0).assertTrue();
expect(datainfo.appInfo.icon).assertEqual("$media:icon");
expect(datainfo.appInfo.iconId >= 0).assertTrue();
expect(datainfo.appInfo.label).assertEqual("$string:app_name");
expect(datainfo.appInfo.labelId >= 0).assertTrue();
expect(datainfo.appInfo.systemApp).assertEqual(true);
done();
}
})
/**
* @tc.number getBundleInfo_0500
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with one hap. (by promise)
*/
it('getBundleInfo_0500', 0, async function (done) {
let datainfo = await demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES);
console.info("getBundleInfo_0500 dataInfo ====" + datainfo);
expect(datainfo.name).assertEqual(NAME1);
expect(datainfo.vendor).assertEqual("example");
expect(datainfo.versionCode).assertEqual(VERSIONCODE1);
expect(datainfo.versionName).assertEqual("1.0");
expect(datainfo.type).assertEqual("");
expect(datainfo.cpuAbi).assertEqual("");
expect(datainfo.compatibleVersion).assertEqual(5);
expect(datainfo.targetVersion).assertEqual(5);
expect(datainfo.installTime).assertLarger(0);
expect(datainfo.updateTime).assertLarger(0);
expect(datainfo.uid).assertLarger(0);
expect(datainfo.entryModuleName).assertEqual("entry");
expect(datainfo.minCompatibleVersionCode).assertEqual(0);
expect(datainfo.entryInstallationFree).assertEqual(false);
expect(datainfo.reqPermissions.length).assertEqual(0);
expect(datainfo.reqPermissionStates.length).assertEqual(0);
expect(datainfo.reqPermissionDetails.length).assertEqual(0);
expect(datainfo.extensionAbilityInfo.length).assertEqual(0);
expect(datainfo.appInfo.name).assertEqual(NAME1);
expect(datainfo.appInfo.description).assertEqual(DESCRIPTION);
expect(datainfo.appInfo.descriptionId >= 0).assertTrue();
expect(datainfo.appInfo.icon).assertEqual("$media:icon");
expect(datainfo.appInfo.iconId >= 0).assertTrue();
expect(datainfo.appInfo.label).assertEqual("$string:app_name");
expect(datainfo.appInfo.labelId >= 0).assertTrue();
expect(datainfo.appInfo.systemApp).assertEqual(true);
expect(datainfo.appInfo.supportedModes).assertEqual(0);
for (let j = 0; j < datainfo.appInfo.moduleInfos; j++) {
expect(datainfo.appInfo.moduleInfos[j].moduleName).assertEqual("entry");
expect(datainfo.appInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1);
}
expect(datainfo.appInfo.enabled).assertEqual(true);
done();
})
/** /**
* @tc.number getBundleInfo_0600 * @tc.number getBundleInfo_0600
* @tc.name BUNDLE::getBundleInfo * @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with one hap. * @tc.desc Test getBundleInfo interfaces with one hap. (by callback)
*/ */
it('getBundleInfo_0600', 0, async function (done) { it('getBundleInfo_0600', 0, async function (done) {
await demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent); await demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent);
...@@ -131,7 +281,80 @@ describe('ActsBundleManagerTest', function () { ...@@ -131,7 +281,80 @@ describe('ActsBundleManagerTest', function () {
expect(datainfo.appInfo.enabled).assertEqual(true); expect(datainfo.appInfo.enabled).assertEqual(true);
done(); done();
} }
})
/**
* @tc.number getBundleInfo_0700
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with error hap. (by promise)
*/
it('getBundleInfo_0700', 0, async function (done) {
await demo.getBundleInfo('error', demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES).then(datainfo => {
console.info("getBundleInfo_0700 success:" + JSON.stringify(datainfo));
expect(datainfo).assertFail();
done();
}).catch(err => {
console.info("getBundleInfo_0700 err:" + JSON.stringify(err));
expect(err).assertEqual(1);
done();
});
})
/**
* @tc.number getBundleInfo_0800
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with error hap. (by callback)
*/
it('getBundleInfo_0800', 0, async function (done) {
await demo.getBundleInfo('error', demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent);
function OnReceiveEvent(err, datainfo) {
if (err) {
console.info("getBundleInfo_0800 err" + JSON.stringify(err));
expect(err).assertEqual(1);
done();
return;
}
console.info("getBundleInfo_0800 success" + JSON.stringify(datainfo));
expect(datainfo).assertFail();
done();
}
})
/**
* @tc.number getBundleInfo_0900
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with none hap.
*/
it('getBundleInfo_0900', 0, async function (done) {
demo.getBundleInfo(' ', demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES).then(datainfo => {
console.info("getBundleInfo_0900 success" + JSON.stringify(datainfo));
expect(datainfo).assertFail();
done();
}).catch(err => {
console.info("getBundleInfo_0900 fail" + JSON.stringify(err));
expect(err).assertEqual(1);
done();
});
})
/**
* @tc.number getBundleInfo_1000
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with none hap.
*/
it('getBundleInfo_1000', 0, async function (done) {
await demo.getBundleInfo(' ', demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent);
function OnReceiveEvent(err, datainfo) {
if (err) {
console.info("getBundleInfo_1000 err" + JSON.stringify(err));
expect(err).assertEqual(1);
done();
return;
}
console.info("getBundleInfo_1000 success" + JSON.stringify(datainfo));
expect(datainfo).assertFail();
done();
}
}) })
/** /**
...@@ -192,6 +415,198 @@ describe('ActsBundleManagerTest', function () { ...@@ -192,6 +415,198 @@ describe('ActsBundleManagerTest', function () {
} }
}) })
/**
* @tc.number getBundleInfo_1300
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with LAUNCHER hap. (by promise)
*/
it('getBundleInfo_1300', 0, async function (done) {
demo.getBundleInfo(LAUNCHER, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES).then(datainfo => {
console.info("getBundleInfo_1300 success:" + JSON.stringify(datainfo));
expect(datainfo.name).assertEqual(LAUNCHER);
expect(datainfo.vendor).assertEqual("ohos");
expect(datainfo.versionCode).assertEqual(1000000);
expect(datainfo.versionName.length).assertLarger(0);
expect(datainfo.uid).assertLarger(2099);
expect(datainfo.appInfo.name).assertEqual(LAUNCHER);
expect(datainfo.appInfo.systemApp).assertEqual(true);
expect(datainfo.appInfo.supportedModes).assertEqual(0);
expect(datainfo.appInfo.moduleInfos.length).assertLarger(0);
expect(datainfo.appInfo.enabled).assertEqual(true);
done();
}).catch(err => {
console.info("getBundleInfo_1300 fail:" + JSON.stringify(err));
expect(err).assertFail();
done();
})
})
/**
* @tc.number getBundleInfo_1400
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with LAUNCHER hap.(by callback)
*/
it('getBundleInfo_1400', 0, async function (done) {
demo.getBundleInfo(LAUNCHER, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, bundleOptions, (err, dataInfo) => {
if (err) {
console.info("getBundleInfo_1400 fail:" + JSON.stringify(err));
expect(err).assertFail();
done();
return;
}
console.info("getBundleInfo_1400 success:" + JSON.stringify(datainfo));
expect(datainfo.name).assertEqual(LAUNCHER);
expect(datainfo.vendor).assertEqual("ohos");
expect(datainfo.versionCode).assertEqual(1000000);
expect(datainfo.versionName.length).assertLarger(0);
expect(datainfo.uid).assertLarger(2099);
expect(datainfo.appInfo.name).assertEqual(LAUNCHER);
expect(datainfo.appInfo.systemApp).assertEqual(true);
expect(datainfo.appInfo.supportedModes).assertEqual(0);
expect(datainfo.appInfo.moduleInfos.length).assertLarger(0);
expect(datainfo.appInfo.enabled).assertEqual(true);
done();
})
})
/**
* @tc.number getBundleInfo_1500
* @tc.name BUNDLEMGR::getBundleInfo
* @tc.desc Test getBundleInfo interface with current userId(by promise).
*/
it('getBundleInfo_1500', 0, async function (done) {
let bundleOptions = {
userId: USERID
};
let dataInfo = await demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, bundleOptions);
console.info("getBundleInfo_1500 start --------");
console.info("getBundleInfo_1500 dataInfo ====" + datainfo);
expect(dataInfo.name).assertEqual(NAME1);
expect(dataInfo.vendor).assertEqual("example");
expect(dataInfo.versionCode).assertEqual(VERSIONCODE1);
expect(dataInfo.versionName).assertLarger(0);
expect(dataInfo.entryModuleName).assertEqual("entry");
expect(dataInfo.appInfo.name).assertEqual(NAME1);
expect(dataInfo.appInfo.description).assertEqual(DESCRIPTION);
expect(dataInfo.appInfo.descriptionId >= 0).assertTrue();
expect(dataInfo.appInfo.icon).assertEqual("$media:icon");
expect(dataInfo.appInfo.iconId >= 0).assertTrue();
expect(dataInfo.appInfo.label).assertEqual("$string:app_name");
expect(dataInfo.appInfo.labelId >= 0).assertTrue();
expect(dataInfo.appInfo.systemApp).assertEqual(true);
expect(dataInfo.appInfo.supportedModes).assertEqual(0);
expect(dataInfo.updateTime).assertLarger(0);
expect(dataInfo.reqPermissions.length).assertEqual(0);
expect(dataInfo.reqPermissionDetails.length).assertEqual(0);
expect(dataInfo.compatibleVersion).assertEqual(5);
expect(dataInfo.targetVersion).assertEqual(5);
expect(dataInfo.isCompressNativeLibs).assertEqual(false);
for (let s = 0; s < dataInfo.hapModuleInfos; s++) {
expect(dataInfo.moduleInfos[s].name).assertEqual("com.example.myapplication1");
expect(dataInfo.moduleInfos[s].moduleName).assertEqual("entry");
}
expect(dataInfo.entryModuleName).assertEqual("entry");
expect(dataInfo.isSilentInstallation.length).assertEqual(0);
expect(dataInfo.minCompatibleVersionCode).assertEqual(0);
expect(dataInfo.entryInstallationFree).assertEqual(false);
for (let j = 0; j < dataInfo.appInfo.moduleInfos; j++) {
expect(dataInfo.appInfo.moduleInfos[j].moduleName).assertEqual("entry");
expect(dataInfo.appInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1);
}
expect(dataInfo.appInfo.enabled).assertEqual(true);
console.info("getBundleInfo_1500 end --------");
done();
})
/**
* @tc.number getBundleInfo_1600
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interface with current userId(by callback).
*/
it('getBundleInfo_1600', 0, async function (done) {
let bundleOptions = {
userId: USERID
};
demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, bundleOptions, (err, dataInfo) => {
console.info("getBundleInfo_1600 start --------");
console.info("getBundleInfo_1600 dataInfo ====" + datainfo);
expect(dataInfo.name).assertEqual(NAME1);
expect(dataInfo.vendor).assertEqual("example");
expect(dataInfo.versionCode).assertEqual(VERSIONCODE1);
expect(dataInfo.versionName).assertLarger(0);
expect(dataInfo.entryModuleName).assertEqual("entry");
expect(dataInfo.appInfo.name).assertEqual(NAME1);
expect(dataInfo.appInfo.description).assertEqual(DESCRIPTION);
expect(dataInfo.appInfo.descriptionId >= 0).assertTrue();
expect(dataInfo.appInfo.icon).assertEqual("$media:icon");
expect(dataInfo.appInfo.iconId >= 0).assertTrue();
expect(dataInfo.appInfo.label).assertEqual("$string:app_name");
expect(dataInfo.appInfo.labelId >= 0).assertTrue();
expect(dataInfo.appInfo.systemApp).assertEqual(true);
expect(dataInfo.appInfo.supportedModes).assertEqual(0);
expect(dataInfo.updateTime).assertLarger(0);
expect(dataInfo.reqPermissions.length).assertEqual(0);
expect(dataInfo.reqPermissionDetails.length).assertEqual(0);
expect(dataInfo.compatibleVersion).assertEqual(5);
expect(dataInfo.targetVersion).assertEqual(5);
expect(dataInfo.isCompressNativeLibs).assertEqual(false);
for (let s = 0; s < dataInfo.hapModuleInfos; s++) {
expect(dataInfo.moduleInfos[s].name).assertEqual("com.example.myapplication1");
expect(dataInfo.moduleInfos[s].moduleName).assertEqual("entry");
}
expect(dataInfo.entryModuleName).assertEqual("entry");
expect(dataInfo.isSilentInstallation.length).assertEqual(0);
expect(dataInfo.minCompatibleVersionCode).assertEqual(0);
expect(dataInfo.entryInstallationFree).assertEqual(false);
for (let j = 0; j < dataInfo.appInfo.moduleInfos; j++) {
expect(dataInfo.appInfo.moduleInfos[j].moduleName).assertEqual("entry");
expect(dataInfo.appInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1);
}
console.info("getBundleInfo_1600 end --------");
done();
});
})
/**
* @tc.number getBundleInfo_1700
* @tc.name BUNDLEMGR::getBundleInfo
* @tc.desc Test getBundleInfo interface with other userId(by promise).
*/
it('getBundleInfo_1700', 0, async function (done) {
demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, {
userId: 1
}).then(data => {
console.info("getBundleInfo_1700 success" + JSON.stringify(data));
expect(data).assertFail();
done();
}).catch(err => {
console.info("getBundleInfo_1700 err" + JSON.stringify(err));
expect(err).assertEqual(1);
done();
});
})
/**
* @tc.number getBundleInfo_1800
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interface with other userId(by callback).
*/
it('getBundleInfo_1800', 0, async function (done) {
demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, {
userId: 1
}, (err, dataInfo) => {
if (err) {
console.info("getBundleInfo_1800 err" + JSON.stringify(err));
expect(err).assertEqual(1);
done();
return;
}
console.info("getBundleInfo_1800 success" + JSON.stringify(datainfo));
expect(dataInfo).assertFail();
done();
});
})
/** /**
* @tc.number getApplicationInfos_0100 * @tc.number getApplicationInfos_0100
* @tc.name BUNDLE::getApplicationInfos * @tc.name BUNDLE::getApplicationInfos
...@@ -421,54 +836,6 @@ describe('ActsBundleManagerTest', function () { ...@@ -421,54 +836,6 @@ describe('ActsBundleManagerTest', function () {
}) })
}) })
/**
* @tc.number getBundleInfo_0200
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with two haps.
*/
it('getBundleInfo_0200', 0, async function (done) {
let datainfo = await demo.getBundleInfo(NAME2, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES);
expect(datainfo.name).assertEqual(NAME2);
expect(datainfo.vendor).assertEqual("example");
expect(datainfo.versionCode).assertEqual(1);
expect(datainfo.versionName).assertLarger(0);
expect(datainfo.entryModuleName).assertEqual("entry");
expect(datainfo.appInfo.name).assertEqual(NAME2);
expect(datainfo.appInfo.description).assertEqual(DESCRIPTION);
expect(datainfo.appInfo.descriptionId >= 0).assertTrue();
expect(datainfo.appInfo.icon).assertEqual("$media:icon");
expect(datainfo.appInfo.iconId >= 0).assertTrue();
expect(datainfo.appInfo.label).assertEqual("$string:app_name");
expect(datainfo.appInfo.labelId >= 0).assertTrue();
expect(datainfo.appInfo.systemApp).assertEqual(true);
done();
})
/**
* @tc.number getBundleInfo_0700
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with two haps.
*/
it('getBundleInfo_0700', 0, async function (done) {
await demo.getBundleInfo(NAME2, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent);
function OnReceiveEvent(err, datainfo) {
expect(datainfo.name).assertEqual(NAME2);
expect(datainfo.vendor).assertEqual("example");
expect(datainfo.versionCode).assertEqual(1);
expect(datainfo.versionName).assertLarger(0);
expect(datainfo.entryModuleName).assertEqual("entry");
expect(datainfo.appInfo.name).assertEqual(NAME2);
expect(datainfo.appInfo.description).assertEqual(DESCRIPTION);
expect(datainfo.appInfo.descriptionId >= 0).assertTrue();
expect(datainfo.appInfo.icon).assertEqual("$media:icon");
expect(datainfo.appInfo.iconId >= 0).assertTrue();
expect(datainfo.appInfo.label).assertEqual("$string:app_name");
expect(datainfo.appInfo.labelId >= 0).assertTrue();
expect(datainfo.appInfo.systemApp).assertEqual(true);
done();
}
})
/** /**
* @tc.number getApplicationInfos_0200 * @tc.number getApplicationInfos_0200
* @tc.name BUNDLE::getApplicationInfos * @tc.name BUNDLE::getApplicationInfos
...@@ -833,43 +1200,6 @@ describe('ActsBundleManagerTest', function () { ...@@ -833,43 +1200,6 @@ describe('ActsBundleManagerTest', function () {
done(); done();
}) })
/**
* @tc.number getBundleInfo_0400
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with error hap.
*/
it('getBundleInfo_0400', 0, async function (done) {
await demo.getBundleInfo('error', demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES).then(datainfo => {
console.info("getBundleInfo success:" + JSON.stringify(datainfo));
expect(datainfo).assertFail();
done();
}).catch(err => {
console.info("getBundleInfo err:" + JSON.stringify(err));
expect(err).assertEqual(1);
done();
});
})
/**
* @tc.number getBundleInfo_0900
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with error hap.
*/
it('getBundleInfo_0900', 0, async function (done) {
await demo.getBundleInfo('error', demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent);
function OnReceiveEvent(err, datainfo) {
if (err) {
console.info("getBundleInfo err" + JSON.stringify(err));
expect(err).assertEqual(1);
done();
return;
}
console.info("getBundleInfo success" + JSON.stringify(datainfo));
expect(datainfo).assertFail();
done();
}
})
/** /**
* @tc.number getApplicationInfo_0400 * @tc.number getApplicationInfo_0400
* @tc.name BUNDLE::getApplicationInfo * @tc.name BUNDLE::getApplicationInfo
...@@ -911,26 +1241,6 @@ describe('ActsBundleManagerTest', function () { ...@@ -911,26 +1241,6 @@ describe('ActsBundleManagerTest', function () {
}) })
}) })
/**
* @tc.number getBundleInfo_1000
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with none hap.
*/
it('getBundleInfo_1000', 0, async function (done) {
await demo.getBundleInfo(' ', demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent);
function OnReceiveEvent(err, datainfo) {
if (err) {
console.info("getBundleInfo err" + JSON.stringify(err));
expect(err).assertEqual(1);
done();
return;
}
console.info("getBundleInfo success" + JSON.stringify(datainfo));
expect(datainfo).assertFail();
done();
}
})
/** /**
* @tc.number getApplicationInfo_0500 * @tc.number getApplicationInfo_0500
* @tc.name BUNDLE::getApplicationInfo * @tc.name BUNDLE::getApplicationInfo
...@@ -951,23 +1261,6 @@ describe('ActsBundleManagerTest', function () { ...@@ -951,23 +1261,6 @@ describe('ActsBundleManagerTest', function () {
}) })
}) })
/**
* @tc.number getBundleInfo_0500
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with none hap.
*/
it('getBundleInfo_0500', 0, async function (done) {
demo.getBundleInfo(' ', demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES).then(datainfo => {
console.info("getBundleInfo success" + JSON.stringify(datainfo));
expect(datainfo).assertFail();
done();
}).catch(err => {
console.info("getBundleInfo fail" + JSON.stringify(err));
expect(err).assertEqual(1);
done();
});
})
/** /**
* @tc.number getApplicationInfo_1000 * @tc.number getApplicationInfo_1000
* @tc.name BUNDLE::getApplicationInfo * @tc.name BUNDLE::getApplicationInfo
...@@ -1155,159 +1448,6 @@ describe('ActsBundleManagerTest', function () { ...@@ -1155,159 +1448,6 @@ describe('ActsBundleManagerTest', function () {
}) })
}) })
/**
* @tc.number getBundleInfo_1300
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with LAUNCHER hap.
*/
it('getBundleInfo_1300', 0, async function (done) {
demo.getBundleInfo(LAUNCHER, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES).then(datainfo => {
console.info("getBundleInfo success:" + JSON.stringify(datainfo));
expect(datainfo.name).assertEqual(LAUNCHER);
expect(datainfo.vendor).assertEqual("ohos");
expect(datainfo.versionCode).assertEqual(1000000);
expect(datainfo.versionName.length).assertLarger(0);
expect(datainfo.uid).assertLarger(2099);
expect(datainfo.appInfo.name).assertEqual(LAUNCHER);
expect(datainfo.appInfo.systemApp).assertEqual(true);
expect(datainfo.appInfo.supportedModes).assertEqual(0);
expect(datainfo.appInfo.moduleInfos.length).assertLarger(0);
expect(datainfo.appInfo.enabled).assertEqual(true);
done();
}).catch(err => {
console.info("getBundleInfo fail:" + JSON.stringify(err));
expect(err).assertFail();
done();
})
})
/**
* @tc.number getBundleInfo_1400
* @tc.name BUNDLEMGR::getBundleInfo
* @tc.desc Test getBundleInfo interface with current userId(by promise).
*/
it('getBundleInfo_1400', 0, async function (done) {
let bundleOptions = {
userId: USERID
};
let dataInfo = await demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, bundleOptions);
console.info("getBundleInfo_1400 start --------");
expect(dataInfo.name).assertEqual(NAME1);
expect(dataInfo.vendor).assertEqual("example");
expect(dataInfo.versionCode).assertEqual(VERSIONCODE1);
expect(dataInfo.versionName).assertLarger(0);
expect(dataInfo.entryModuleName).assertEqual("entry");
expect(dataInfo.appInfo.name).assertEqual(NAME1);
expect(dataInfo.appInfo.description).assertEqual(DESCRIPTION);
expect(dataInfo.appInfo.descriptionId >= 0).assertTrue();
expect(dataInfo.appInfo.icon).assertEqual("$media:icon");
expect(dataInfo.appInfo.iconId >= 0).assertTrue();
expect(dataInfo.appInfo.label).assertEqual("$string:app_name");
expect(dataInfo.appInfo.labelId >= 0).assertTrue();
expect(dataInfo.appInfo.systemApp).assertEqual(true);
expect(dataInfo.appInfo.supportedModes).assertEqual(0);
expect(dataInfo.updateTime).assertLarger(0);
expect(dataInfo.reqPermissions.length).assertEqual(0);
expect(dataInfo.reqPermissionDetails.length).assertEqual(0);
expect(dataInfo.compatibleVersion).assertEqual(5);
expect(dataInfo.targetVersion).assertEqual(5);
expect(dataInfo.isCompressNativeLibs).assertEqual(false);
for (let s = 0; s < dataInfo.hapModuleInfos; s++) {
expect(dataInfo.moduleInfos[s].name).assertEqual("com.example.myapplication1");
expect(dataInfo.moduleInfos[s].moduleName).assertEqual("entry");
}
expect(dataInfo.entryModuleName).assertEqual("entry");
expect(dataInfo.isSilentInstallation.length).assertEqual(0);
expect(dataInfo.minCompatibleVersionCode).assertEqual(0);
expect(dataInfo.entryInstallationFree).assertEqual(false);
for (let j = 0; j < dataInfo.appInfo.moduleInfos; j++) {
expect(dataInfo.appInfo.moduleInfos[j].moduleName).assertEqual("entry");
expect(dataInfo.appInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1);
}
expect(dataInfo.appInfo.enabled).assertEqual(true);
console.info("getBundleInfo_1400 end --------");
done();
})
/**
* @tc.number getBundleInfo_1500
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interface with current userId(by callback).
*/
it('getBundleInfo_1500', 0, async function (done) {
let bundleOptions = {
userId: USERID
};
demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, bundleOptions, (err, dataInfo) => {
expect(dataInfo.name).assertEqual(NAME1);
expect(dataInfo.vendor).assertEqual("example");
expect(dataInfo.versionCode).assertEqual(VERSIONCODE1);
expect(dataInfo.versionName).assertLarger(0);
expect(dataInfo.entryModuleName).assertEqual("entry");
expect(dataInfo.appInfo.name).assertEqual(NAME1);
expect(dataInfo.appInfo.description).assertEqual(DESCRIPTION);
expect(dataInfo.appInfo.descriptionId >= 0).assertTrue();
expect(dataInfo.appInfo.icon).assertEqual("$media:icon");
expect(dataInfo.appInfo.iconId >= 0).assertTrue();
expect(dataInfo.appInfo.label).assertEqual("$string:app_name");
expect(dataInfo.appInfo.labelId >= 0).assertTrue();
expect(dataInfo.appInfo.systemApp).assertEqual(true);
expect(dataInfo.appInfo.supportedModes).assertEqual(0);
expect(dataInfo.updateTime).assertLarger(0);
expect(dataInfo.reqPermissions.length).assertEqual(0);
expect(dataInfo.reqPermissionDetails.length).assertEqual(0);
expect(dataInfo.compatibleVersion).assertEqual(5);
expect(dataInfo.targetVersion).assertEqual(5);
expect(dataInfo.isCompressNativeLibs).assertEqual(false);
for (let s = 0; s < dataInfo.hapModuleInfos; s++) {
expect(dataInfo.moduleInfos[s].name).assertEqual("com.example.myapplication1");
expect(dataInfo.moduleInfos[s].moduleName).assertEqual("entry");
}
expect(dataInfo.entryModuleName).assertEqual("entry");
expect(dataInfo.isSilentInstallation.length).assertEqual(0);
expect(dataInfo.minCompatibleVersionCode).assertEqual(0);
expect(dataInfo.entryInstallationFree).assertEqual(false);
for (let j = 0; j < dataInfo.appInfo.moduleInfos; j++) {
expect(dataInfo.appInfo.moduleInfos[j].moduleName).assertEqual("entry");
expect(dataInfo.appInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1);
}
done();
});
})
/**
* @tc.number getBundleInfo_1600
* @tc.name BUNDLEMGR::getBundleInfo
* @tc.desc Test getBundleInfo interface with other userId(by promise).
*/
it('getBundleInfo_1600', 0, async function (done) {
demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, {
userId: 1
}).then(data => {
expect().assertFail();
done();
}).catch(err => {
expect(err).assertEqual(1);
done();
});
})
/**
* @tc.number getBundleInfo_1700
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interface with other userId(by callback).
*/
it('getBundleInfo_1700', 0, async function (done) {
demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, {
userId: 1
}, (err, dataInfo) => {
expect(err).assertEqual(1);
expect(dataInfo).assertEqual(undefined);
done();
});
})
/** /**
* @tc.number queryAbilityByWant_1000 * @tc.number queryAbilityByWant_1000
* @tc.name BUNDLE::queryAbilityByWant * @tc.name BUNDLE::queryAbilityByWant
......
...@@ -80,9 +80,9 @@ describe('storageTest', function () { ...@@ -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.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) { it('testRemoveStorageFromCache002', 0, async function (done) {
let perf = storage.getStorageSync('/data/test_storage2'); let perf = storage.getStorageSync('/data/test_storage2');
...@@ -96,6 +96,27 @@ describe('storageTest', function () { ...@@ -96,6 +96,27 @@ describe('storageTest', function () {
done(); 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_storage2');
storage.removeStorageFromCache(perf, function (err) {
if (err) {
console.info("removeStorageFromCache callback interface test failed.");
expect(null).assertFail();
done();
return
}
console.info("removeStorageFromCache callback interface test successfully.");
expect(true).assertTrue();
done();
})
})
/** /**
* @tc.name deleteStorageSync interface test * @tc.name deleteStorageSync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_Helper_0050 * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_Helper_0050
......
...@@ -17,8 +17,11 @@ import factory from '@ohos.data.distributedData'; ...@@ -17,8 +17,11 @@ import factory from '@ohos.data.distributedData';
const TEST_BUNDLE_NAME = 'ohos.acts.distributeddatamgr'; const TEST_BUNDLE_NAME = 'ohos.acts.distributeddatamgr';
const TEST_STORE_ID = 'storeId'; const TEST_STORE_ID = 'storeId';
const STORE_KEY = 'key_test_string';
const STORE_VALUE = 'value-test-string';
var kvManager = null; var kvManager = null;
var kvStore = null; var kvStore = null;
var kvStoreNew = null;
describe('KVManagerCallbackTest', function () { describe('KVManagerCallbackTest', function () {
const config = { const config = {
...@@ -43,8 +46,11 @@ describe('KVManagerCallbackTest', function () { ...@@ -43,8 +46,11 @@ describe('KVManagerCallbackTest', function () {
console.log('beforeAll'); console.log('beforeAll');
await factory.createKVManager(config, function (err, manager) { await factory.createKVManager(config, function (err, manager) {
kvManager = manager; kvManager = manager;
kvManager.getKVStore(TEST_STORE_ID, options, function (err, store) {
kvStoreNew = store;
done(); done();
}); });
});
console.log('beforeAll end'); console.log('beforeAll end');
}) })
...@@ -125,9 +131,9 @@ describe('KVManagerCallbackTest', function () { ...@@ -125,9 +131,9 @@ describe('KVManagerCallbackTest', function () {
encrypt : false, encrypt : false,
backup : false, backup : false,
autoSync : true, autoSync : true,
kvStoreType : factory.KVStoreType.SINGLE_VERSION, kvStoreType : factory.KVStoreType.DEVICE_COLLABORATION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S2, securityLevel : factory.SecurityLevel.NO_LEVEL,
} }
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
...@@ -156,9 +162,9 @@ describe('KVManagerCallbackTest', function () { ...@@ -156,9 +162,9 @@ describe('KVManagerCallbackTest', function () {
encrypt : false, encrypt : false,
backup : false, backup : false,
autoSync : true, autoSync : true,
kvStoreType : factory.KVStoreType.SINGLE_VERSION, kvStoreType : factory.KVStoreType.DEVICE_COLLABORATION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S2, securityLevel : factory.SecurityLevel.S0,
} }
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
...@@ -188,9 +194,9 @@ describe('KVManagerCallbackTest', function () { ...@@ -188,9 +194,9 @@ describe('KVManagerCallbackTest', function () {
encrypt : true, encrypt : true,
backup : false, backup : false,
autoSync : true, autoSync : true,
kvStoreType : factory.KVStoreType.SINGLE_VERSION, kvStoreType : factory.KVStoreType.DEVICE_COLLABORATION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S2, securityLevel : factory.SecurityLevel.S1,
} }
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
...@@ -218,7 +224,7 @@ describe('KVManagerCallbackTest', function () { ...@@ -218,7 +224,7 @@ describe('KVManagerCallbackTest', function () {
encrypt : false, encrypt : false,
backup : false, backup : false,
autoSync : true, autoSync : true,
kvStoreType : factory.KVStoreType.SINGLE_VERSION, kvStoreType : factory.KVStoreType.DEVICE_COLLABORATION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S2, securityLevel : factory.SecurityLevel.S2,
} }
...@@ -248,9 +254,9 @@ describe('KVManagerCallbackTest', function () { ...@@ -248,9 +254,9 @@ describe('KVManagerCallbackTest', function () {
encrypt : false, encrypt : false,
backup : true, backup : true,
autoSync : true, autoSync : true,
kvStoreType : factory.KVStoreType.SINGLE_VERSION, kvStoreType : factory.KVStoreType.DEVICE_COLLABORATION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S2, securityLevel : factory.SecurityLevel.S3,
} }
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
...@@ -278,9 +284,9 @@ describe('KVManagerCallbackTest', function () { ...@@ -278,9 +284,9 @@ describe('KVManagerCallbackTest', function () {
encrypt : false, encrypt : false,
backup : false, backup : false,
autoSync : true, autoSync : true,
kvStoreType : factory.KVStoreType.SINGLE_VERSION, kvStoreType : factory.KVStoreType.DEVICE_COLLABORATION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S2, securityLevel : factory.SecurityLevel.S4,
} }
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
...@@ -310,7 +316,7 @@ describe('KVManagerCallbackTest', function () { ...@@ -310,7 +316,7 @@ describe('KVManagerCallbackTest', function () {
autoSync : true, autoSync : true,
kvStoreType : factory.KVStoreType.SINGLE_VERSION, kvStoreType : factory.KVStoreType.SINGLE_VERSION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S2, securityLevel : factory.SecurityLevel.NO_LEVEL,
} }
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
...@@ -340,7 +346,7 @@ describe('KVManagerCallbackTest', function () { ...@@ -340,7 +346,7 @@ describe('KVManagerCallbackTest', function () {
autoSync : false, autoSync : false,
kvStoreType : factory.KVStoreType.SINGLE_VERSION, kvStoreType : factory.KVStoreType.SINGLE_VERSION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S2, securityLevel : factory.SecurityLevel.S0,
} }
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
...@@ -370,7 +376,7 @@ describe('KVManagerCallbackTest', function () { ...@@ -370,7 +376,7 @@ describe('KVManagerCallbackTest', function () {
autoSync : true, autoSync : true,
kvStoreType : factory.KVStoreType.SINGLE_VERSION, kvStoreType : factory.KVStoreType.SINGLE_VERSION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S2, securityLevel : factory.SecurityLevel.S1,
} }
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
...@@ -398,7 +404,7 @@ describe('KVManagerCallbackTest', function () { ...@@ -398,7 +404,7 @@ describe('KVManagerCallbackTest', function () {
encrypt : false, encrypt : false,
backup : false, backup : false,
autoSync : true, autoSync : true,
kvStoreType : factory.KVStoreType.DEVICE_COLLABORATION, kvStoreType : factory.KVStoreType.SINGLE_VERSION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S2, securityLevel : factory.SecurityLevel.S2,
} }
...@@ -428,9 +434,9 @@ describe('KVManagerCallbackTest', function () { ...@@ -428,9 +434,9 @@ describe('KVManagerCallbackTest', function () {
encrypt : false, encrypt : false,
backup : false, backup : false,
autoSync : true, autoSync : true,
kvStoreType : factory.KVStoreType.MULTI_VERSION, kvStoreType : factory.KVStoreType.SINGLE_VERSION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S2, securityLevel : factory.SecurityLevel.S3,
} }
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
...@@ -462,7 +468,7 @@ describe('KVManagerCallbackTest', function () { ...@@ -462,7 +468,7 @@ describe('KVManagerCallbackTest', function () {
autoSync : true, autoSync : true,
kvStoreType : factory.KVStoreType.SINGLE_VERSION, kvStoreType : factory.KVStoreType.SINGLE_VERSION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.NO_LEVEL, securityLevel : factory.SecurityLevel.S4,
} }
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
...@@ -490,9 +496,9 @@ describe('KVManagerCallbackTest', function () { ...@@ -490,9 +496,9 @@ describe('KVManagerCallbackTest', function () {
encrypt : false, encrypt : false,
backup : false, backup : false,
autoSync : true, autoSync : true,
kvStoreType : factory.KVStoreType.SINGLE_VERSION, kvStoreType : factory.KVStoreType.MULTI_VERSION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S0, securityLevel : factory.SecurityLevel.NO_LEVEL,
} }
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
...@@ -520,9 +526,9 @@ describe('KVManagerCallbackTest', function () { ...@@ -520,9 +526,9 @@ describe('KVManagerCallbackTest', function () {
encrypt : false, encrypt : false,
backup : false, backup : false,
autoSync : true, autoSync : true,
kvStoreType : factory.KVStoreType.SINGLE_VERSION, kvStoreType : factory.KVStoreType.MULTI_VERSION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S1, securityLevel : factory.SecurityLevel.S0,
} }
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
...@@ -550,9 +556,9 @@ describe('KVManagerCallbackTest', function () { ...@@ -550,9 +556,9 @@ describe('KVManagerCallbackTest', function () {
encrypt : false, encrypt : false,
backup : false, backup : false,
autoSync : true, autoSync : true,
kvStoreType : factory.KVStoreType.SINGLE_VERSION, kvStoreType : factory.KVStoreType.MULTI_VERSION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S2, securityLevel : factory.SecurityLevel.S1,
} }
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
...@@ -580,9 +586,9 @@ describe('KVManagerCallbackTest', function () { ...@@ -580,9 +586,9 @@ describe('KVManagerCallbackTest', function () {
encrypt : false, encrypt : false,
backup : false, backup : false,
autoSync : true, autoSync : true,
kvStoreType : factory.KVStoreType.SINGLE_VERSION, kvStoreType : factory.KVStoreType.MULTI_VERSION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S3, securityLevel : factory.SecurityLevel.S2,
} }
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
...@@ -610,9 +616,9 @@ describe('KVManagerCallbackTest', function () { ...@@ -610,9 +616,9 @@ describe('KVManagerCallbackTest', function () {
encrypt : false, encrypt : false,
backup : false, backup : false,
autoSync : true, autoSync : true,
kvStoreType : factory.KVStoreType.SINGLE_VERSION, kvStoreType : factory.KVStoreType.MULTI_VERSION,
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S4, securityLevel : factory.SecurityLevel.S3,
} }
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
...@@ -628,6 +634,36 @@ describe('KVManagerCallbackTest', function () { ...@@ -628,6 +634,36 @@ describe('KVManagerCallbackTest', function () {
} }
}) })
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1200
* @tc.name [JS-API8]KVManager.GetKVStore.
* @tc.desc Test Js Api KVManager.GetKVStore testcase 120
*/
it('testKVManagerGetKVStore120', 0, async function (done) {
console.log('testKVManagerGetKVStore120');
const optionsInfo = {
createIfMissing : true,
encrypt : false,
backup : false,
autoSync : true,
kvStoreType : factory.KVStoreType.MULTI_VERSION,
schema : '',
securityLevel : factory.SecurityLevel.S4,
}
try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
console.log('testKVManagerGetKVStore120 getKVStore success');
expect((err == undefined) && (store != null)).assertTrue();
kvStore = store;
done();
});
} catch (e) {
console.log('testKVManagerGetKVStore119 getKVStore e ' + e);
expect(null).assertFail();
done();
}
})
/** /**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_CLOSEKVSTORE_1100 * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_CLOSEKVSTORE_1100
* @tc.name [JS-API8]KVManager.CloseKVStore. * @tc.name [JS-API8]KVManager.CloseKVStore.
...@@ -878,4 +914,111 @@ describe('KVManagerCallbackTest', function () { ...@@ -878,4 +914,111 @@ describe('KVManagerCallbackTest', function () {
done(); done();
} }
}) })
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_PUT_1000
* @tc.name [JS-API8]KVStore.Put
* @tc.desc Test Js Api KVManager.Put testcase 100
*/
it('testKVStorePut100', 0, async function (done) {
console.log('testKVStorePut100');
try {
await kvStoreNew.put(STORE_KEY, STORE_VALUE, function (err, data) {
if (err != undefined){
console.log('testKVStorePut100 put callback fail');
} else {
console.log('testKVStorePut100 put callback success');
expect(null).assertFail();
}
done();
});
} catch (e) {
console.log('testKVStorePut100 callback e ' + e);
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_DELETE_1000
* @tc.name [JS-API8]KVStore.Delete
* @tc.desc Test Js Api KVManager.Delete testcase 100
*/
it('testKVStoreDelete100', 0, async function (done) {
console.log('testKVStoreDelete100');
try {
await KVStoreNew.put(STORE_KEY, STORE_VALUE, async function (err,data) {
console.log('testKVStoreDelete100 put success');
try {
kvStore.delete(STORE_KEY, function (err, data) {
if (err == undefined) {
console.log('testKVStoreDelete100 callback delete success');
expect(null).assertFail();
} else {
console.log('testKVStoreDelete100 callback delete fail');
}
done();
});
} catch (e) {
console.log('testKVStoreDelete100 callback delete e ' + e);
done();
}
});
} catch (ee) {
console.log('testKVStoreDelete100 callback delete ee ' + ee);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_ON_1000
* @tc.name [JS-API8]KVStore.On
* @tc.desc Test Js Api KVManager.On testcase 100
*/
it('testKVStoreOn100', 0, async function (done) {
kvStoreNew.on('dataChange', 0, function (data) {
console.log("testKVStoreOn100 callback call data: " + JSON.stringify(data));
expect(true).assertTrue();
});
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_ON_1100
* @tc.name [JS-API8]KVStore.On
* @tc.desc Test Js Api KVManager.On testcase 101
*/
it('testKVStoreOn101', 0, async function (done) {
kvStoreNew.on('dataChange', 1, function (data) {
console.log("testKVStoreOn101 callback call data: " + JSON.stringify(data));
expect(true).assertTrue();
});
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_ON_1200
* @tc.name [JS-API8]KVStore.On
* @tc.desc Test Js Api KVManager.On testcase 102
*/
it('testKVStoreOn102', 0, async function (done) {
kvStoreNew.on('dataChange', 2, function (data) {
console.log("testKVStoreOn102 callback call data: " + JSON.stringify(data));
expect(true).assertTrue();
});
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_ON_1300
* @tc.name [JS-API8]KVStore.On
* @tc.desc Test Js Api KVManager.On testcase 103
*/
it('testKVStoreOn103', 0, async function (done) {
kvStoreNew.on('syncComplete', function (data) {
console.log("testKVStoreOn103 callback call data: " + data);
expect(true).assertTrue();
});
done();
})
}) })
\ No newline at end of file
...@@ -19,6 +19,9 @@ const TEST_BUNDLE_NAME = 'ohos.acts.distributeddatamgr'; ...@@ -19,6 +19,9 @@ const TEST_BUNDLE_NAME = 'ohos.acts.distributeddatamgr';
const TEST_STORE_ID = 'storeId'; const TEST_STORE_ID = 'storeId';
var kvManager = null; var kvManager = null;
var kvStore = null; var kvStore = null;
const STORE_KEY = 'key_test_string';
const STORE_VALUE = 'value-test-string';
var kvStoreNew = null;
describe('KVManagerPromiseTest', function () { describe('KVManagerPromiseTest', function () {
const config = { const config = {
...@@ -44,6 +47,12 @@ describe('KVManagerPromiseTest', function () { ...@@ -44,6 +47,12 @@ describe('KVManagerPromiseTest', function () {
await factory.createKVManager(config).then((manager) => { await factory.createKVManager(config).then((manager) => {
kvManager = manager; kvManager = manager;
console.log('beforeAll createKVManager success'); console.log('beforeAll createKVManager success');
kvManager.getKVStore(TEST_STORE_ID, options).then((store) => {
console.log("beforeAll getKVStore success");
kvStoreNew = store;
}).catch((err) => {
console.log("beforeAll getKVStore err: " + JSON.stringify(err));
});
}).catch((err) => { }).catch((err) => {
console.log('beforeAll createKVManager err ' + err); console.log('beforeAll createKVManager err ' + err);
}); });
...@@ -131,7 +140,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -131,7 +140,7 @@ describe('KVManagerPromiseTest', function () {
autoSync: true, autoSync: true,
kvStoreType: factory.KVStoreType.SINGLE_VERSION, kvStoreType: factory.KVStoreType.SINGLE_VERSION,
schema: '', schema: '',
securityLevel: factory.SecurityLevel.S2, securityLevel: factory.SecurityLevel.NO_LEVEL,
} }
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore003 getKVStore success'); console.log('testKVManagerGetKVStore003 getKVStore success');
...@@ -158,7 +167,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -158,7 +167,7 @@ describe('KVManagerPromiseTest', function () {
autoSync: true, autoSync: true,
kvStoreType: factory.KVStoreType.SINGLE_VERSION, kvStoreType: factory.KVStoreType.SINGLE_VERSION,
schema: '', schema: '',
securityLevel: factory.SecurityLevel.S2, securityLevel: factory.SecurityLevel.S1,
} }
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore004 getKVStore success'); console.log('testKVManagerGetKVStore004 getKVStore success');
...@@ -210,7 +219,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -210,7 +219,7 @@ describe('KVManagerPromiseTest', function () {
autoSync: true, autoSync: true,
kvStoreType: factory.KVStoreType.SINGLE_VERSION, kvStoreType: factory.KVStoreType.SINGLE_VERSION,
schema: '', schema: '',
securityLevel: factory.SecurityLevel.S2, securityLevel: factory.SecurityLevel.S3,
} }
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore006 getKVStore success'); console.log('testKVManagerGetKVStore006 getKVStore success');
...@@ -237,7 +246,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -237,7 +246,7 @@ describe('KVManagerPromiseTest', function () {
autoSync: true, autoSync: true,
kvStoreType: factory.KVStoreType.SINGLE_VERSION, kvStoreType: factory.KVStoreType.SINGLE_VERSION,
schema: '', schema: '',
securityLevel: factory.SecurityLevel.S2, securityLevel: factory.SecurityLevel.S4,
} }
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore007 getKVStore success'); console.log('testKVManagerGetKVStore007 getKVStore success');
...@@ -262,9 +271,9 @@ describe('KVManagerPromiseTest', function () { ...@@ -262,9 +271,9 @@ describe('KVManagerPromiseTest', function () {
encrypt: false, encrypt: false,
backup: false, backup: false,
autoSync: true, autoSync: true,
kvStoreType: factory.KVStoreType.SINGLE_VERSION, kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION,
schema: '', schema: '',
securityLevel: factory.SecurityLevel.S2, securityLevel: factory.SecurityLevel.NO_LEVEL,
} }
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore008 getKVStore success'); console.log('testKVManagerGetKVStore008 getKVStore success');
...@@ -289,9 +298,9 @@ describe('KVManagerPromiseTest', function () { ...@@ -289,9 +298,9 @@ describe('KVManagerPromiseTest', function () {
encrypt: false, encrypt: false,
backup: false, backup: false,
autoSync: true, autoSync: true,
kvStoreType: factory.KVStoreType.SINGLE_VERSION, kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION,
schema: '', schema: '',
securityLevel: factory.SecurityLevel.S2, securityLevel: factory.SecurityLevel.S0,
} }
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore009 getKVStore success'); console.log('testKVManagerGetKVStore009 getKVStore success');
...@@ -316,9 +325,9 @@ describe('KVManagerPromiseTest', function () { ...@@ -316,9 +325,9 @@ describe('KVManagerPromiseTest', function () {
encrypt: false, encrypt: false,
backup: false, backup: false,
autoSync: false, autoSync: false,
kvStoreType: factory.KVStoreType.SINGLE_VERSION, kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION,
schema: '', schema: '',
securityLevel: factory.SecurityLevel.S2, securityLevel: factory.SecurityLevel.S1,
} }
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore010 getKVStore success'); console.log('testKVManagerGetKVStore010 getKVStore success');
...@@ -343,7 +352,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -343,7 +352,7 @@ describe('KVManagerPromiseTest', function () {
encrypt: false, encrypt: false,
backup: false, backup: false,
autoSync: true, autoSync: true,
kvStoreType: factory.KVStoreType.SINGLE_VERSION, kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION,
schema: '', schema: '',
securityLevel: factory.SecurityLevel.S2, securityLevel: factory.SecurityLevel.S2,
} }
...@@ -372,7 +381,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -372,7 +381,7 @@ describe('KVManagerPromiseTest', function () {
autoSync: true, autoSync: true,
kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION, kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION,
schema: '', schema: '',
securityLevel: factory.SecurityLevel.S2, securityLevel: factory.SecurityLevel.S3,
} }
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore012 getKVStore success'); console.log('testKVManagerGetKVStore012 getKVStore success');
...@@ -397,9 +406,9 @@ describe('KVManagerPromiseTest', function () { ...@@ -397,9 +406,9 @@ describe('KVManagerPromiseTest', function () {
encrypt: false, encrypt: false,
backup: false, backup: false,
autoSync: true, autoSync: true,
kvStoreType: factory.KVStoreType.MULTI_VERSION, kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION,
schema: '', schema: '',
securityLevel: factory.SecurityLevel.S2, securityLevel: factory.SecurityLevel.S4,
} }
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
...@@ -426,7 +435,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -426,7 +435,7 @@ describe('KVManagerPromiseTest', function () {
encrypt: false, encrypt: false,
backup: false, backup: false,
autoSync: true, autoSync: true,
kvStoreType: factory.KVStoreType.SINGLE_VERSION, kvStoreType: factory.KVStoreType.MULTI_VERSION,
schema: '', schema: '',
securityLevel: factory.SecurityLevel.NO_LEVEL, securityLevel: factory.SecurityLevel.NO_LEVEL,
} }
...@@ -453,7 +462,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -453,7 +462,7 @@ describe('KVManagerPromiseTest', function () {
encrypt: false, encrypt: false,
backup: false, backup: false,
autoSync: true, autoSync: true,
kvStoreType: factory.KVStoreType.SINGLE_VERSION, kvStoreType: factory.KVStoreType.MULTI_VERSION,
schema: '', schema: '',
securityLevel: factory.SecurityLevel.S0, securityLevel: factory.SecurityLevel.S0,
} }
...@@ -480,7 +489,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -480,7 +489,7 @@ describe('KVManagerPromiseTest', function () {
encrypt: false, encrypt: false,
backup: false, backup: false,
autoSync: true, autoSync: true,
kvStoreType: factory.KVStoreType.SINGLE_VERSION, kvStoreType: factory.KVStoreType.MULTI_VERSION,
schema: '', schema: '',
securityLevel: factory.SecurityLevel.S1, securityLevel: factory.SecurityLevel.S1,
} }
...@@ -507,7 +516,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -507,7 +516,7 @@ describe('KVManagerPromiseTest', function () {
encrypt: false, encrypt: false,
backup: false, backup: false,
autoSync: true, autoSync: true,
kvStoreType: factory.KVStoreType.SINGLE_VERSION, kvStoreType: factory.KVStoreType.MULTI_VERSION,
schema: '', schema: '',
securityLevel: factory.SecurityLevel.S2, securityLevel: factory.SecurityLevel.S2,
} }
...@@ -534,7 +543,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -534,7 +543,7 @@ describe('KVManagerPromiseTest', function () {
encrypt: false, encrypt: false,
backup: false, backup: false,
autoSync: true, autoSync: true,
kvStoreType: factory.KVStoreType.SINGLE_VERSION, kvStoreType: factory.KVStoreType.MULTI_VERSION,
schema: '', schema: '',
securityLevel: factory.SecurityLevel.S3, securityLevel: factory.SecurityLevel.S3,
} }
...@@ -561,7 +570,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -561,7 +570,7 @@ describe('KVManagerPromiseTest', function () {
encrypt: false, encrypt: false,
backup: false, backup: false,
autoSync: true, autoSync: true,
kvStoreType: factory.KVStoreType.SINGLE_VERSION, kvStoreType: factory.KVStoreType.MULTI_VERSION,
schema: '', schema: '',
securityLevel: factory.SecurityLevel.S4, securityLevel: factory.SecurityLevel.S4,
} }
...@@ -915,4 +924,78 @@ describe('KVManagerPromiseTest', function () { ...@@ -915,4 +924,78 @@ describe('KVManagerPromiseTest', function () {
kvManager.off('distributedDataServiceDie'); kvManager.off('distributedDataServiceDie');
done(); done();
}) })
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_PUT_1000
* @tc.name [JS-API8]KVStore.Put
* @tc.desc Test Js Api KVManager.Put testcase 001
*/
it('testKVStorePut001', 0, async function (done) {
console.log('testKVStorePut001');
try {
await kvStoreNew.put(TEST_BUNDLE_NAME, TEST_STORE_ID).then((data) => {
if (err != undefined){
console.log('testKVStorePut001 put promise fail');
} else {
console.log('testKVStorePut001 put promise success');
expect(null).assertFail();
}
done();
});
} catch (e) {
console.log('testKVStorePut001 e ' + e);
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_DELETE_1000
* @tc.name [JS-API8]KVStore.Delete
* @tc.desc Test Js Api KVManager.Delete testcase 001
*/
it('testKVStorePut001', 0, async function (done) {
console.log('testKVStorePut001');
try {
await kvStoreNew.put(TEST_BUNDLE_NAME, TEST_STORE_ID).then((data) => {
if (err != undefined){
console.log('testKVStorePut001 put promise fail');
} else {
console.log('testKVStorePut001 put promise success');
expect(null).assertFail();
}
done();
});
} catch (e) {
console.log('testKVStorePut001 e ' + e);
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_DELETE_1000
* @tc.name [JS-API8]KVStore.Delete
* @tc.desc Test Js Api KVManager.Delete testcase 001
*/
it('testKVStoreDelete001', 0, async function (done) {
console.log('testKVStoreDelete001');
try {
kvStoreNew.put(STORE_KEY, STORE_VALUE).then((data) => {
console.log('testKVStoreDelete001 getKVStore success');
kvStoreNew.delete(STORE_KEY).then((data) => {
console.log("testKVStoreDelete001 promise delete success");
expect(null).assertFail();
}).catch((err) => {
console.log('testKVStoreDelete001 promise delete fail err' + err);
});
}).catch((err) => {
console.log('testKVStoreDelete001 promise delete fail err' + err);
});
}catch (e) {
console.log('testKVStoreDelete001 promise delete fail err' + err);
}
done();
})
}) })
\ No newline at end of file
...@@ -1005,6 +1005,595 @@ describe('geolocationTest', function () { ...@@ -1005,6 +1005,595 @@ describe('geolocationTest', function () {
done() done()
}) })
/**
* @tc.number SingleLoc_0010
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0010
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0010', 0, async function(done) {
let currentLocationRequest = { "priority": 0x0200, "scenario": 0x0300, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}
});
done()
})
/**
* @tc.number SingleLoc_0011
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0011
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0011', 0, async function(done) {
let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}
});
done()
})
/**
* @tc.number SingleLoc_0012
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0012
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0012', 0, async function(done) {
let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0301, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}
});
done()
})
/**
* @tc.number SingleLoc_0013
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0013
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0013', 0, async function(done) {
let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0302, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}
});
done()
})
/**
* @tc.number SingleLoc_0014
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0014
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0014', 0, async function(done) {
let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0303, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}
});
done()
})
/**
* @tc.number SingleLoc_0015
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0015
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0015', 0, async function(done) {
let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0304, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}
});
done()
})
/**
* @tc.number SingleLoc_0016
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0016
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0016', 0, async function(done) {
let currentLocationRequest1 = { "priority": 0x201, "scenario": 0x305, "timeoutMs": 10, "maxAccuracy": 0 };
let currentLocationRequest2= { "priority": 0x201, "scenario": 0x301, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest1,
async(err, result) => {
if (err){
console.info("getCurrentLocation callback1 err: " + err)
geolocation.getCurrentLocation(currentLocationRequest2,
async(err, result) => {
if (err){
return console.info("getCurrentLocation callback2 err: " + err)
}else{
console.info("getCurrentLocation callback, result2: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
done()
}
});
}
console.info("getCurrentLocation callback, result1: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength == 0);
});
done()
})
/**
* @tc.number SingleLoc_0017
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0017
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0017', 0, async function(done) {
let currentLocationRequest = { "priority": 0x0202, "scenario": 0x0300, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}
});
done()
})
/**
* @tc.number SingleLoc_0018
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0018
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0018', 0, async function(done) {
let currentLocationRequest = { "priority": 0x0202, "scenario": 0x0301, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}
});
done()
})
/**
* @tc.number SingleLoc_0019
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0019
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0019', 0, async function(done) {
let currentLocationRequest = { "priority": 0x0202, "scenario": 0x0302, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}
});
done()
})
/**
* @tc.number SingleLoc_0020
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0020
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0020', 0, async function(done) {
let currentLocationRequest = { "priority": 0x0202, "scenario": 0x0303, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}
});
done()
})
/**
* @tc.number SingleLoc_0021
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0021
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0021', 0, async function(done) {
let currentLocationRequest = { "priority": 0x0202, "scenario": 0x0304, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}
});
done()
})
/**
* @tc.number SingleLoc_0022
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0022
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0022', 0, async function(done) {
let currentLocationRequest1 = { "priority": 0x202, "scenario": 0x305, "timeoutMs": 10, "maxAccuracy": 0 };
let currentLocationRequest2= { "priority": 0x202, "scenario": 0x301, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest1,
async(err, result) => {
if (err){
console.info("getCurrentLocation callback1 err: " + err)
geolocation.getCurrentLocation(currentLocationRequest2,
async(err, result) => {
if (err){
return console.info("getCurrentLocation callback2 err: " + err)
}else{
console.info("getCurrentLocation callback, result2: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
done()
}
});
}
console.info("getCurrentLocation callback, result1: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength == 0);
});
done()
})
/**
* @tc.number SingleLoc_0023
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0023
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0023', 0, async function(done) {
let currentLocationRequest = { "priority": 0x0203, "scenario": 0x0300, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}
});
done()
})
/**
* @tc.number SingleLoc_0024
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0024
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0024', 0, async function(done) {
let currentLocationRequest = { "priority": 0x0203, "scenario": 0x0302, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}
});
done()
})
/**
* @tc.number SingleLoc_0025
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0025
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0025', 0, async function(done) {
let currentLocationRequest = { "priority": 0x0203, "scenario": 0x0303, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}
});
done()
})
/**
* @tc.number SingleLoc_0026
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0026
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0026', 0, async function(done) {
let currentLocationRequest = { "priority": 0x0203, "scenario": 0x0304, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => {
if (err){
return console.info("getCurrentLocation callback err: " + err)
}else{
console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
}
});
done()
})
/**
* @tc.number SingleLoc_0027
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0027
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0027', 0, async function(done) {
let currentLocationRequest1 = { "priority": 0x203, "scenario": 0x305, "timeoutMs": 10, "maxAccuracy": 0 };
let currentLocationRequest2= { "priority": 0x203, "scenario": 0x301, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest1,
async(err, result) => {
if (err){
console.info("getCurrentLocation callback1 err: " + err)
geolocation.getCurrentLocation(currentLocationRequest2,
async(err, result) => {
if (err){
return console.info("getCurrentLocation callback2 err: " + err)
}else{
console.info("getCurrentLocation callback, result2: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength >= 0);
done()
}
});
}
console.info("getCurrentLocation callback, result1: " + JSON.stringify(result));
let resultLength = Object.keys(result).length;
expect(true).assertEqual(resultLength == 0);
});
done()
})
/**
* @tc.number LastLocation_0001
* @tc.name SUB_HSS_LocationSystem_LastLocation_0001
* @tc.desc Test getLastLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_LastLocation_0001', 0, async function (done) {
geolocation.getLastLocation(async(err, data) => {
if (err) {
console.info('[lbs_js] getLastLocation callback err is : ' + err );
}else {
console.info('[lbs_js] getLastLocation callback result: ' + data);
expect(data).assertTrue();
}
done()
})
});
/**
* @tc.number LastLocation_0002
* @tc.name SUB_HSS_LocationSystem_LastLocation_0002
* @tc.desc Test getLastLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_LastLocation_0002', 0, async function (done) {
await geolocation.getLastLocation().then((result) => {
console.info('[lbs_js] getLastLocation promise result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info('[lbs_js] getLastLocation promise then err: ' + result);
expect().assertFail();
});
done();
})
/**
* @tc.number SingleLoc_0028
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0028
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0028', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0200, "scenario": 0x0300, "timeoutMs": 10, "maxAccuracy": 0 };
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info("[lbs_js] getCurrentLocation promise data is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getCurrentLocation promise then error." + error);
expect().assertFail();
});
done();
})
/**
* @tc.number SingleLoc_0029
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0029
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0029', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0200, "scenario": 0x0301, "timeoutMs": 10, "maxAccuracy": 0 };
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info("[lbs_js] getCurrentLocation promise result is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getCurrentLocation promise then error." + error);
expect().assertFail();
});
done();
})
/**
* @tc.number SingleLoc_0030
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0030
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0030', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0200, "scenario": 0x0302, "timeoutMs": 10, "maxAccuracy": 0 };
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info("[lbs_js] getCurrentLocation promise result is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getCurrentLocation promise then error." + error);
expect().assertFail();
});
done();
})
/**
* @tc.number SingleLoc_0031
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0031
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0031', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0200, "scenario": 0x0303, "timeoutMs": 10, "maxAccuracy": 0 };
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info("[lbs_js] getCurrentLocation promise result is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getCurrentLocation promise then error." + error);
expect().assertFail();
});
done();
})
/**
* @tc.number SingleLoc_0032
* @tc.name SUB_HSS_LocationSystem_SingleLoc_0032
* @tc.desc Test getCurrentLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_SingleLoc_0032', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0200, "scenario": 0x0304, "timeoutMs": 10, "maxAccuracy": 0 };
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info("[lbs_js] getCurrentLocation promise result is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) !=null);
}).catch((error) => {
console.info("[lbs_js] getCurrentLocation promise then error." + error);
expect().assertFail();
});
done();
})
}) })
......
...@@ -1301,6 +1301,38 @@ describe('fileIOTest', function () { ...@@ -1301,6 +1301,38 @@ describe('fileIOTest', function () {
} }
}); });
/**
* @tc.number SUB_STORAGE_FileIO_Access_Promise_001
* @tc.name fileio_test_access_promise_001
* @tc.desc Function of API, access(mode=4).
*/
it('fileio_test_access_promise_001', 0, async function () {
let fpath = await nextFileName('fileio_test_access_promise_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let fd = fileio.access(fpath).then(() => {
expect(fd !== null).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file access Success');
}).catch(function(err) {
console.log("file access err: " + JSON.stringify(err));
});
});
/**
* @tc.number SUB_STORAGE_FileIO_Access_Async_001
* @tc.name fileio_test_access_async_001
* @tc.desc Function of API, access(mode=4).
*/
it('fileio_test_access_async_001', 0, async function () {
let fpath = await nextFileName('fileio_test_access_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let fd = fileio.access(fpath, function (err) {
expect(fd !== null).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
});
/** /**
* @tc.number SUB_STORAGE_FileIO_UnlinkSync_0000 * @tc.number SUB_STORAGE_FileIO_UnlinkSync_0000
* @tc.name fileio_test_unlink_sync_000 * @tc.name fileio_test_unlink_sync_000
...@@ -2403,6 +2435,25 @@ describe('fileIOTest', function () { ...@@ -2403,6 +2435,25 @@ describe('fileIOTest', function () {
} }
}); });
/**
* @tc.number SUB_STORAGE_FileIO_copyFileSync_1200
* @tc.name fileio_test_copy_file_async_001
* @tc.desc Function of API, copy. fpatch is vaild, fpathTarget is vaild, same path, file not same, mode is 0.
*/
it('fileio_test_copy_file_async_001', 0, async function () {
let fpath = await nextFileName('fileio_test_copy_file_async_001');
let fpathTarget = fpath + 'tgt'
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
await fileio.copyFile(fpath, fpathTarget).then(()=> {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
expect(fileio.unlinkSync(fpathTarget) !== null).assertTrue();
console.log('fileio_test_copy_file_async_001 Success');
}).catch((err) => {
console.log("fileio_test_copy_file_async_001 err: " + JSON.stringify(err));
});
});
/** /**
* @tc.number SUB_STORAGE_FileIO_truncateSync_0000 * @tc.number SUB_STORAGE_FileIO_truncateSync_0000
* @tc.name fileio_test_truncate_sync_000 * @tc.name fileio_test_truncate_sync_000
...@@ -3826,4 +3877,65 @@ describe('fileIOTest', function () { ...@@ -3826,4 +3877,65 @@ describe('fileIOTest', function () {
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
/**
* @tc.number SUB_STORAGE_FileIO_stat_promise_000
* @tc.name fileio_test_stat_promise_000
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_000', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o660) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
expect((stat.mode & 0o777) == 0o660).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
});
});
/**
* @tc.number fileio_test_stat_async_000
* @tc.name fileio_test_stat_async_000
* @tc.desc Function of API, obtain file propertys by stat async
*/
it('fileio_test_stat_async_000', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o660) !== null).assertTrue();
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o660).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
});
/**
* @tc.number fileio_test_close_promise_000
* @tc.name fileio_test_close_promise_000
* @tc.desc Function of API close
*/
it('fileio_test_close_promise_000', 0, async function () {
let fpath = await nextFileName('fileio_test_close_promise_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let fd = fileio.openSync(fpath);
expect(fd !== null).assertTrue();
await fileio.close(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
/**
* @tc.number fileio_test_close_async_000
* @tc.name fileio_test_close_async_000
* @tc.desc Function of API close
*/
it('fileio_test_close_async_000', 0, async function () {
let fpath = await nextFileName('fileio_test_close_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let fd = fileio.openSync(fpath);
await fileio.close(fd, function (err) {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
});
}); });
\ No newline at end of file
...@@ -155,6 +155,39 @@ describe('fileIOTestDir', function () { ...@@ -155,6 +155,39 @@ describe('fileIOTestDir', function () {
} }
}); });
/**
* @tc.number SUB_STORAGE_FileIO_dir_OpenASync_001
* @tc.name fileio_test_dir_open_async_001
* @tc.desc Function of API, file name contain special character.
*/
it('fileio_test_dir_open_async_001', 0, async function () {
let dpath = await nextFileName('fileio_test_dir_open_async_001') + 'd'
expect(fileio.mkdirSync(dpath) !== null).assertTrue();
fileio.opendir(dpath, function (err, dir) {
expect(dir !== null).assertTrue();
expect(dir.closeSync() == null).assertTrue();
expect(fileio.rmdirSync(dpath) !== null).assertTrue();
});
});
/**
* @tc.number SUB_STORAGE_FileIO_dir_OpenASync_001
* @tc.name fileio_test_dir_open_async_001
* @tc.desc Function of API, file name contain special character.
*/
it('fileio_test_dir_open_async_002', 0, async function () {
let dpath = await nextFileName('fileio_test_dir_open_async_002') + 'd'
expect(fileio.mkdirSync(dpath) !== null).assertTrue();
let dir = await fileio.opendir(dpath).then(()=> {
expect(dir !== null).assertTrue();
expect(dir.closeSync() == null).assertTrue();
expect(fileio.rmdirSync(dpath) !== null).assertTrue();
console.log('fileio opendir Success');
}).catch((err) => {
console.log("fileio opendir err: " + JSON.stringify(err));
});
});
/** /**
* @tc.number SUB_STORAGE_FileIO_dir_ReadSync_0000 * @tc.number SUB_STORAGE_FileIO_dir_ReadSync_0000
* @tc.name fileio_test_dir_read_sync_000 * @tc.name fileio_test_dir_read_sync_000
......
...@@ -862,6 +862,48 @@ describe('CallManageImsCall', function () { ...@@ -862,6 +862,48 @@ describe('CallManageImsCall', function () {
} }
}); });
/**
* @tc.number Telephony_CallManager_formatPhoneNumber_Async_0120
* @tc.name PhoneNumber is 13900000000, options: CN, Call formatPhoneNumber() to format the number.
* The return value is 10 000 000 0000
* @tc.desc Function test
*/
it('Telephony_CallManager_formatPhoneNumber_Async_0120', 0, async function (done) {
let numberFormatOptions = new NumberFormatOptions('CN');
call.formatPhoneNumber('13900000000', numberFormatOptions, (err, data) => {
if (err) {
console.log(`Telephony_CallManager_formatPhoneNumber_Async_0120 err = ${err.message}`);
console.log('Telephony_CallManager_formatPhoneNumber_Async_0120 fail');
expect().assertFail();
done();
return;
}
expect(data === '139 0000 0000"').assertTrue();
console.log(`Telephony_CallManager_formatPhoneNumber_Async_0120 finish data = ${data}`);
done();
});
});
/**
* @tc.number Telephony_CallManager_formatPhoneNumber_Promise_0120
* @tc.name PhoneNumber is 13900000000, options: US, Call formatPhoneNumber() to format the number.
* The return value is 200 0000
* @tc.desc Function test
*/
it('Telephony_CallManager_formatPhoneNumber_Promise_0120', 0, async function (done) {
let numberFormatOptions = new NumberFormatOptions('US');
try {
var data = await call.formatPhoneNumber('13900000000', numberFormatOptions);
expect(data === '1 390-000-0000').assertTrue();
console.log(`Telephony_CallManager_formatPhoneNumber_Promise_0120 finish data = ${data}`);
done();
} catch (err) {
console.log('Telephony_CallManager_formatPhoneNumber_Promise_0120 fail');
expect().assertFail();
done();
}
});
/** /**
* @tc.number Telephony_CallManager_formatPhoneNumberToE164_Async_0100 * @tc.number Telephony_CallManager_formatPhoneNumberToE164_Async_0100
* @tc.name PhoneNumber is 010-0000-0000, options: CN, call formatPhoneNumberToE164() to format the number, * @tc.name PhoneNumber is 010-0000-0000, options: CN, call formatPhoneNumberToE164() to format the number,
...@@ -942,4 +984,41 @@ describe('CallManageImsCall', function () { ...@@ -942,4 +984,41 @@ describe('CallManageImsCall', function () {
done(); done();
} }
}); });
/**
* @tc.number Telephony_CallManager_isEmergencyPhoneNumber_Async_1400
* @tc.name PhoneNumber: 110, no options. Call isEmergencyPhoneNumber() to check whether it is an emergency
* number. The return value is false
* @tc.desc Function test
*/
it('Telephony_CallManager_isEmergencyPhoneNumber_Async_1400', 0, async function (done) {
call.isEmergencyPhoneNumber('110', (err) => {
if (err) {
console.log(`Telephony_CallManager_isEmergencyPhoneNumber_Async_1400 finish err = ${err}`);
done();
return;
}
expect().assertFail();
console.log('Telephony_CallManager_isEmergencyPhoneNumber_Async_1400 fail ');
done();
});
});
/**
* @tc.number Telephony_CallManager_isEmergencyPhoneNumber_Promise_1400
* @tc.name PhoneNumber: 120, no options. Call isEmergencyPhoneNumber() to check whether it is an emergency
* number. The return value is false
* @tc.desc Function test
*/
it('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1400', 0, async function (done) {
try {
var data = await call.isEmergencyPhoneNumber('120');
expect().assertFail();
console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1400 fail ');
done();
} catch (err) {
console.log(`Telephony_CallManager_isEmergencyPhoneNumber_Promise_1400 finish err = ${err}`);
done();
}
});
}); });
\ No newline at end of file
...@@ -73,7 +73,40 @@ export default function smsUiJsunit() { ...@@ -73,7 +73,40 @@ export default function smsUiJsunit() {
}); });
}); });
/*
* @tc.number Telephony_SmsMms_createMessage_Promise_0100
* @tc.name Call interface CreateMessage,
* pass in the PDU(rawArray) in line with the coding specification, the specification is 3GPP,
* shortMessage Don't empty
* @tc.desc Function test
*/
it('Telephony_SmsMms_createMessage_Promise_0100', 0, async function (done) {
if (true) {
expect(true).assertTrue();
done();
return;
}
sms.createMessage(rawArray, '3gpp').then(shortMessage => {
expect(shortMessage.visibleMessageBody === MESSAGEBODY).assertTrue();
expect(shortMessage.visibleRawAddress.length === ADDR_LENGTH).assertTrue();
expect(shortMessage.messageClass === sms.FORWARD_MESSAGE).assertTrue();
expect(shortMessage.protocolId === 0).assertTrue();
expect(shortMessage.scAddress.length === ADDR_LENGTH).assertTrue();
expect(shortMessage.scTimestamp === SC_TIMESTAMP).assertTrue();
expect(shortMessage.isReplaceMessage).assertFalse();
expect(shortMessage.hasReplyPath).assertFalse();
expect(shortMessage.pdu.length > 0).assertTrue();
expect(shortMessage.status === 0).assertTrue();
expect(shortMessage.isSmsStatusReportMessage).assertTrue();
console.log('Telephony_SmsMms_createMessage_Promise_0100 finish');
done();
}).catch(err => {
expect().assertFail();
console.log('Telephony_SmsMms_createMessage_Promise_0100 fail');
done();
return;
});
});
/* /*
......
...@@ -511,4 +511,44 @@ describe('SimManagerTest', function () { ...@@ -511,4 +511,44 @@ describe('SimManagerTest', function () {
} }
done(); done();
}); });
/**
* @tc.number Telephony_Sim_getDefaultVoiceSlotld_Async_0400
* @tc.name Test getDefaultVoiceSlotld interface,
* check the callback result
* @tc.desc Function test
*/
it('Telephony_Sim_getDefaultVoiceSlotld_Async_0400', 0, function (done) {
const CASE_NAME = 'Telephony_Sim_getDefaultVoiceSlotld_Async_0400';
sim.getDefaultVoiceSlotld((error, result) => {
if (error) {
console.log(`${CASE_NAME} getDefaultVoiceSlotld error: ${error.message}`);
expect().assertFail();
done();
return;
}
expect(result).assertFalse();
console.log(`${CASE_NAME} test finish.`);
done();
});
});
/**
* @tc.number Telephony_Sim_getDefaultVoiceSlotld_Promise_0400
* @tc.name Test getDefaultVoiceSlotld interface,
* check the returned result
* @tc.desc Function test
*/
it('Telephony_Sim_getDefaultVoiceSlotld_Promise_0400', 0, async function (done) {
const CASE_NAME = 'Telephony_Sim_getDefaultVoiceSlotld_Promise_0400';
try {
const result = await sim.getDefaultVoiceSlotld();
expect(result).assertFalse();
console.log(`${CASE_NAME} test finish.`);
} catch (error) {
console.log(`${CASE_NAME} getDefaultVoiceSlotld error: ${error.message}`);
expect().assertFail();
}
done();
});
}) })
/* /*
* Copyright (c) 2022 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -35,46 +35,411 @@ describe('userAuthTest', function () { ...@@ -35,46 +35,411 @@ describe('userAuthTest', function () {
}) })
/** /**
* @tc.name execute_authentication_callback_ALL_NO_SUPPORT * @tc.name execute_authentication_callback_failed
* @tc.number JSAPI_Function_Execute_1700 * @tc.number JSAPI_Function_Execute_0100
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type FUNC * @tc.type FUNC
* @tc.level Level2 * @tc.level Level2
*/ */
it('JSAPI_Function_Execute_1700', 0, function (done) { it('JSAPI_Function_Execute_0100', 0, function (done) {
console.log("JSAPI_Function_Execute_1700 start"); console.log("JSAPI_Function_Execute_0100 start");
index.default.fileSave('JSAPI_Function_Execute_0100','1','18 0 0 0 0 0 0 0 0 0 0')
const auth = userAuth.getAuthenticator(); const auth = userAuth.getAuthenticator();
auth.execute("ALL", "S2", function(data) { auth.execute("FACE_ONLY", "S2", function(data) {
console.log("JSAPI_Function_Execute_1700 auth.execute:" + data); console.log("JSAPI_Function_Execute_0100 auth.execute:" + data);
// NO_SUPPORT(-1) // COMPARE_FAILURE(1)
expect(data).assertEqual(-1); expect(data).assertEqual(1);
setTimeout(function() { setTimeout(function() {
done(); done();
}, 1); }, 1);
}); });
console.log("JSAPI_Function_Execute_1700 end"); console.log("JSAPI_Function_Execute_0100 end");
}) })
/**
* @tc.name execute_authentication_callback_timeout
* @tc.number JSAPI_Function_Execute_0200
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Execute_0200', 0, function (done) {
console.log("JSAPI_Function_Execute_0200 start");
index.default.fileSave('JSAPI_Function_Execute_0200','1','18 6 0 0 0 0 0 0 0 0 0')
const auth = userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S2", function(data) {
console.log("JSAPI_Function_Execute_0200 auth.execute:" + data);
// TIMEOUT (3)
expect(data).assertEqual(3);
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_Execute_0200 end");
})
/** /**
* @tc.name execute_authentication_promise_ALL_NO_SUPPORT * @tc.name execute_authentication_callback_camera_fail
* @tc.number JSAPI_Function_Execute_2000 * @tc.number JSAPI_Function_Execute_0300
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type FUNC * @tc.type FUNC
* @tc.level Level2 * @tc.level Level2
*/ */
it('JSAPI_Function_Execute_2000', 0, function (done) { it('JSAPI_Function_Execute_0300', 0, function (done) {
console.log("JSAPI_Function_Execute_2000 start"); console.log("JSAPI_Function_Execute_0300 start");
index.default.fileSaveB('JSAPI_Function_Execute_0300','903')
const auth = userAuth.getAuthenticator(); const auth = userAuth.getAuthenticator();
auth.execute("ALL", "S2").catch(function(data) { auth.execute("FACE_ONLY", "S2", function(data) {
console.log("JSAPI_Function_Execute_2000 auth.execute:" + data); console.log("JSAPI_Function_Execute_0300 auth.execute:" + data);
// CAMERA_FAIL(4)
expect(data).assertEqual(4);
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_Execute_0300 end");
})
/**
* @tc.name execute_authentication_callback_busy
* @tc.number JSAPI_Function_Execute_0400
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Execute_0400', 0, function (done) {
console.log("JSAPI_Function_Execute_0400 start");
waitFlag = true;
const auth = userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S2", function(data) {
console.log("JSAPI_Function_Execute_0400 auth.execute1:" + data);
})
auth.execute("FACE_ONLY", "S2", function(data) {
console.log("JSAPI_Function_Execute_0400 auth.execute2:" + data);
// BUSY(5)
expect(data).assertEqual(5);
setTimeout(function() {
done();
}, 3000);
})
console.log("JSAPI_Function_Execute_0400 end");
})
/**
* @tc.name execute_authentication_callback_LOCKED
* @tc.number JSAPI_Function_Execute_0500
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Execute_0500', 0, function (done) {
console.log("JSAPI_Function_Execute_0500 start");
const auth = userAuth.getAuthenticator();
// exe 1~5
index.default.fileSave('JSAPI_Function_Execute_0500','1','18 0 0 0 0 0 0 0 0 0 0')
new Promise(function(resolve, reject) {
resolve();
}).then(
auth.execute("FACE_ONLY", "S2", function(data) {
console.log("JSAPI_Function_Execute_0500 auth.execute1:" + data);
index.default.fileSave('JSAPI_Function_Execute_0500','1','18 0 0 0 0 0 0 0 0 0 0')
auth.execute("FACE_ONLY", "S2", function(data) {
console.log("JSAPI_Function_Execute_0500 auth.execute2:" + data);
index.default.fileSave('JSAPI_Function_Execute_0500','1','18 0 0 0 0 0 0 0 0 0 0')
auth.execute("FACE_ONLY", "S2", function(data) {
console.log("JSAPI_Function_Execute_0500 auth.execute3:" + data);
index.default.fileSave('JSAPI_Function_Execute_0500','1','18 0 0 0 0 0 0 0 0 0 0')
auth.execute("FACE_ONLY", "S2", function(data) {
console.log("JSAPI_Function_Execute_0500 auth.execute4:" + data);
index.default.fileSave('JSAPI_Function_Execute_0500','1','18 0 0 0 0 0 0 0 0 0 0')
auth.execute("FACE_ONLY", "S2", function(data) {
console.log("JSAPI_Function_Execute_0500 auth.execute5:" + data);
auth.execute("FACE_ONLY", "S2", function(data) {
console.log("JSAPI_Function_Execute_0500 auth.execute6:" + data);
// LOCKED(7)
expect(data).assertEqual(7);
setTimeout(function() {
console.log("JSAPI_Function_Execute_0500 end wait 30m");
done();
}, 1);
})
})
})
})
})
})
);
console.log("JSAPI_Function_Execute_0500 end");
})
/**
* @tc.name execute_authentication_callback_NOT_ENROLLED
* @tc.number JSAPI_Function_Execute_0600
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Execute_0600', 0, function (done) {
console.log("JSAPI_Function_Execute_0600 start");
waitFlag = false;
index.default.fileSave('JSAPI_Function_Execute_0800','1','18 9 0 0 0 0 0 0 0 0 0');
const auth = userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S2", function(data) {
console.log("JSAPI_Function_Execute_0600 auth.execute:" + data);
// NOT_ENROLLED(8)
expect(data).assertEqual(8);
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_Execute_0600 end");
})
/**
* @tc.name execute_authentication_callback_GENERAL_ERROR
* @tc.number JSAPI_Function_Execute_0700
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Execute_0700', 0, function (done) {
console.log("JSAPI_Function_Execute_0700 start");
index.default.fileSave('JSAPI_Function_Execute_0700','1','18 4 0 0 0 0 0 0 0 0 0')
const auth = userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S2", function(data) {
console.log("JSAPI_Function_Execute_0700 auth.execute:" + data);
// GENERAL_ERROR(100)
expect(data).assertEqual(100);
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_Execute_0700 end");
})
/**
* @tc.name execute_authentication_promise_COMPARE_FAILURE
* @tc.number JSAPI_Function_Execute_0800
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Execute_0800', 0, function (done) {
console.log("JSAPI_Function_Execute_0800 start");
index.default.fileSave('JSAPI_Function_Execute_0800','1','18 0 0 0 0 0 0 0 0 0 0')
const auth = userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S2").then(function(data) {
console.log("JSAPI_Function_Execute_0800 auth.execute:" + data);
// COMPARE_FAILURE(1)
expect(data).assertEqual(1);
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_Execute_0800 end");
})
/**
* @tc.name execute_authentication_promise_TIMEOUT
* @tc.number JSAPI_Function_Execute_0900
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Execute_0900', 0, function (done) {
console.log("JSAPI_Function_Execute_0900 start");
index.default.fileSave('JSAPI_Function_Execute_0800','1','18 6 0 0 0 0 0 0 0 0 0');
const auth = userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S2").then(function(data) {
console.log("JSAPI_Function_Execute_0900 auth.execute:" + data);
// TIMEOUT (3)
expect(data).assertEqual(3);
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_Execute_0900 end");
})
/**
* @tc.name execute_authentication_promise_CAMERA_FAIL
* @tc.number JSAPI_Function_Execute_1000
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Execute_1000', 0, function (done) {
console.log("JSAPI_Function_Execute_1000 start");
index.default.fileSaveB('JSAPI_Function_Execute_1000','903')
const auth = userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S2").then(function(data) {
console.log("JSAPI_Function_Execute_1000 auth.execute:" + data);
// CAMERA_FAIL(4)
expect(data).assertEqual(4);
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_Execute_1000 end");
})
/**
* @tc.name execute_authentication_promise_BUSY
* @tc.number JSAPI_Function_Execute_1100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Execute_1100', 0, function (done) {
console.log("JSAPI_Function_Execute_1100 start");
waitFlag = true;
const auth = userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S2").then(function(data) {
console.log("JSAPI_Function_Execute_1100 auth.execute1:" + data);
});
auth.execute("FACE_ONLY", "S2").then(function(data) {
console.log("JSAPI_Function_Execute_1100 auth.execute2:" + data);
// BUSY(5)
expect(data).assertEqual(5);
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_Execute_1100 end");
})
/**
* @tc.name execute_authentication_promise_LOCKED
* @tc.number JSAPI_Function_Execute_1200
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Execute_1200', 0, function (done) {
console.log("JSAPI_Function_Execute_1200 start");
index.default.fileSave('JSAPI_Function_Execute_0500','1','18 0 0 0 0 0 0 0 0 0 0')
const auth = userAuth.getAuthenticator();
// exe 1~5
new Promise(function(resolve, reject) {
resolve();
}).then(
auth.execute("FACE_ONLY", "S2").then(function(data) {
console.log("JSAPI_Function_Execute_1200 auth.execute1:" + data);
index.default.fileSave('JSAPI_Function_Execute_0500','1','18 0 0 0 0 0 0 0 0 0 0')
auth.execute("FACE_ONLY", "S2").then(function(data) {
console.log("JSAPI_Function_Execute_1200 auth.execute2:" + data);
index.default.fileSave('JSAPI_Function_Execute_0500','1','18 0 0 0 0 0 0 0 0 0 0')
auth.execute("FACE_ONLY", "S2").then(function(data) {
console.log("JSAPI_Function_Execute_1200 auth.execute3:" + data);
index.default.fileSave('JSAPI_Function_Execute_0500','1','18 0 0 0 0 0 0 0 0 0 0')
auth.execute("FACE_ONLY", "S2").then(function(data) {
console.log("JSAPI_Function_Execute_1200 auth.execute4:" + data);
index.default.fileSave('JSAPI_Function_Execute_0500','1','18 0 0 0 0 0 0 0 0 0 0')
auth.execute("FACE_ONLY", "S2").then(function(data) {
console.log("JSAPI_Function_Execute_1200 auth.execute5:" + data);
auth.execute("FACE_ONLY", "S2").then(function(data) {
console.log("JSAPI_Function_Execute_1200 auth.execute6:" + data);
// LOCKED(7)
expect(data).assertEqual(7);
setTimeout(function() {
done();
}, 1);
});
})
})
})
})
})
);
console.log("JSAPI_Function_Execute_1200 end");
})
/**
* @tc.name execute_authentication_promise_NOT_ENROLLED
* @tc.number JSAPI_Function_Execute_1300
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Execute_1300', 0, function (done) {
console.log("JSAPI_Function_Execute_1300 start");
waitFlag = false;
index.default.fileSave('JSAPI_Function_Execute_0800','1','18 9 0 0 0 0 0 0 0 0 0');
const auth = userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S2").then(function(data) {
console.log("JSAPI_Function_Execute_1300 auth.execute:" + data);
// NOT_ENROLLED(8)
expect(data).assertEqual(8);
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_Execute_1300 end");
})
/**
* @tc.name execute_authentication_promise_GENERAL_ERROR
* @tc.number JSAPI_Function_Execute_1400
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Execute_1400', 0, function (done) {
console.log("JSAPI_Function_Execute_1400 start");
index.default.fileSave('JSAPI_Function_Execute_1400','1','18 4 0 0 0 0 0 0 0 0 0')
const auth = userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S2").then(function(data) {
console.log("JSAPI_Function_Execute_1400 auth.execute:" + data);
// GENERAL_ERROR(100)
expect(data).assertEqual(100);
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_Execute_1400 end");
})
/**
* @tc.name execute_authentication_callback_FACE_ONLY_SUCCESS
* @tc.number JSAPI_Function_Execute_1600
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Execute_1600', 0, function (done) {
console.log("JSAPI_Function_Execute_1600 start");
const auth = userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S1", function(data) {
console.log("JSAPI_Function_Execute_1600 auth.execute:" + data);
// SUCCESS(0)
expect(data).assertEqual(0);
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_Execute_1600 end");
})
/**
* @tc.name execute_authentication_callback_ALL_NO_SUPPORT
* @tc.number JSAPI_Function_Execute_1700
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Execute_1700', 0, function (done) {
console.log("JSAPI_Function_Execute_1700 start");
const auth = userAuth.getAuthenticator();
auth.execute("ALL", "S2", function(data) {
console.log("JSAPI_Function_Execute_1700 auth.execute:" + data);
// NO_SUPPORT(-1) // NO_SUPPORT(-1)
expect(data).assertEqual(-1); expect(data).assertEqual(-1);
setTimeout(function() { setTimeout(function() {
done(); done();
}, 1); }, 1);
}); });
console.log("JSAPI_Function_Execute_2000 end"); console.log("JSAPI_Function_Execute_1700 end");
}) })
/** /**
...@@ -98,6 +463,47 @@ describe('userAuthTest', function () { ...@@ -98,6 +463,47 @@ describe('userAuthTest', function () {
console.log("JSAPI_Function_Execute_1800 end"); console.log("JSAPI_Function_Execute_1800 end");
}) })
/**
* @tc.name execute_authentication_promise_FACE_ONLY_SUCCESS
* @tc.number JSAPI_Function_Execute_1900
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Execute_1900', 0, function (done) {
console.log("JSAPI_Function_Execute_1900 start");
const auth = userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S2").then(function(data) {
console.log("JSAPI_Function_Execute_1900 auth.execute:" + data);
// SUCCESS(0)
expect(data).assertEqual(0);
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_Execute_1900 end");
})
/**
* @tc.name execute_authentication_promise_ALL_NO_SUPPORT
* @tc.number JSAPI_Function_Execute_2000
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Execute_2000', 0, function (done) {
console.log("JSAPI_Function_Execute_2000 start");
const auth = userAuth.getAuthenticator();
auth.execute("ALL", "S2").then(function(data) {
console.log("JSAPI_Function_Execute_2000 auth.execute:" + data);
// NO_SUPPORT(-1)
expect(data).assertEqual(-1);
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_Execute_2000 end");
})
/** /**
* @tc.name execute_authentication_promise_Type_is_null * @tc.name execute_authentication_promise_Type_is_null
...@@ -109,7 +515,7 @@ describe('userAuthTest', function () { ...@@ -109,7 +515,7 @@ describe('userAuthTest', function () {
it('JSAPI_Function_Execute_2100', 0, function (done) { it('JSAPI_Function_Execute_2100', 0, function (done) {
console.log("JSAPI_Function_Execute_2100 start"); console.log("JSAPI_Function_Execute_2100 start");
const auth = userAuth.getAuthenticator(); const auth = userAuth.getAuthenticator();
auth.execute("", "S2").catch(function(data) { auth.execute("", "S2").then(function(data) {
console.log("JSAPI_Function_Execute_2100 auth.execute:" + data); console.log("JSAPI_Function_Execute_2100 auth.execute:" + data);
// INVALID_PARAMETERS(6) // INVALID_PARAMETERS(6)
expect(data).assertEqual(6); expect(data).assertEqual(6);
...@@ -119,4 +525,123 @@ describe('userAuthTest', function () { ...@@ -119,4 +525,123 @@ describe('userAuthTest', function () {
}); });
console.log("JSAPI_Function_Execute_2100 end"); console.log("JSAPI_Function_Execute_2100 end");
}) })
/**
* @tc.name cancel_authentication_success
* @tc.number JSAPI_Function_Cancel_0100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Cancel_0100', 0, function (done) {
console.log("JSAPI_Function_Cancel_0100 start");
const auth = userAuth.getAuthenticator();
let cancelCode = authenticator.cancel();
if (cancelCode == userIAM_userAuth.Result.SUCCESS) {
console.info("cancel auth success");
expect(true).assertTrue();
} else {
console.error("cancel auth fail");
expect().assertFail();
}
console.log("JSAPI_Function_Cancel_0100 end");
done();
})
/**
* @tc.name checkAvailability_authentication_success
* @tc.number JSAPI_Function_CheckAvailability_0100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level0
*/
it('JSAPI_Function_CheckAvailability_0100', 0, function (done) {
console.log("JSAPI_Function_CheckAvailability_0100 start");
const auth = userAuth.getAuthenticator();
let checkCode = authenticator.checkAvailability("FACE_ONLY", "S2");
if (checkCode == 0) {
console.info("checkAvailability auth success");
expect(true).assertTrue();
} else {
console.error("checkAvailability auth fail");
expect().assertFail();
}
console.log("JSAPI_Function_CheckAvailability_0100 end");
done();
})
/**
* @tc.name on_authentication_success
* @tc.number JSAPI_Function_On_0100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_On_0100', 0, function (done) {
console.log("JSAPI_Function_On_0100 start");
const auth = userAuth.getAuthenticator();
auth.on("tip", function(tip){
if (tip.errorCode == 1) {
console.error("on auth fail");
console.error("receive tip: errorCode(" + tip.errorCode + ") code(" + tip.tipCode +") event(" +
tip.tipEvent + ") info(" + tip.tipInfo + ")");
expect().assertFail();
}else {
console.info("on auth success");
console.info("receive tip: errorCode(" + tip.errorCode + ") code(" + tip.tipCode +") event(" +
tip.tipEvent + ") info(" + tip.tipInfo + ")");
expect(true).assertTrue();
}
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_On_0100 end");
})
/**
* @tc.name off_authentication_success
* @tc.number JSAPI_Function_Off_0100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Off_0100', 0, function (done) {
console.log("JSAPI_Function_Off_0100 start");
const auth = userAuth.getAuthenticator();
auth.on("tip", function(tip){
if (tip.errorCode == 1) {
console.error("off auth fail");
console.error("receive tip: errorCode(" + tip.errorCode + ") code(" + tip.tipCode +") event(" +
tip.tipEvent + ") info(" + tip.tipInfo + ")");
expect().assertFail();
setTimeout(function() {
done();
}, 1);
}else {
console.info("on auth success");
auth.off("tip", function(tip){
if (tip.errorCode == 1) {
console.error("off auth fail");
console.error("receive tip: errorCode(" + tip.errorCode + ") code(" + tip.tipCode +") event(" +
tip.tipEvent + ") info(" + tip.tipInfo + ")");
expect().assertFail();
setTimeout(function() {
done();
}, 1);
}else {
console.info("off auth success");
console.info("receive tip: errorCode(" + tip.errorCode + ") code(" + tip.tipCode +") event(" +
tip.tipEvent + ") info(" + tip.tipInfo + ")");
expect(true).assertTrue();
setTimeout(function() {
done();
}, 1);
}
});
}
});
console.log("JSAPI_Function_On_0100 end");
})
}) })
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册