未验证 提交 566dceba 编写于 作者: B bayanxing 提交者: Gitee

!5 from banyanxing/xts_acts_20220530:feature/testsuilt to master

Merge pull request !5 from bayanxing/feature/testsuilt
...@@ -19,162 +19,234 @@ import abilityFeatureAbility from '@ohos.ability.featureAbility' ...@@ -19,162 +19,234 @@ 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_0300 * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0200
* @tc.name testContinueAbility0300 * @tc.name testContinueAbility0200
* @tc.desc T * @tc.desc T (by callback)
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 3 * @tc.level : Level 3
*/ */
it('testContinueAbility0300', 0, async function (done) { it('testContinueAbility0200', 0, async function (done) {
console.log('testContinueAbility0300 run start'); console.log('testContinueAbility0200 run start');
abilityFeatureAbility.continueAbility(undefined, (err, data) => { abilityFeatureAbility.continueAbility(undefined, (err, data) => {
console.log('testContinueAbility0300 err is :' + JSON.stringify(err) + ', value is :' console.log('testContinueAbility0200 err is :' + JSON.stringify(error));
+ JSON.stringify(data)); console.log('testContinueAbility0200 value is :' + JSON.stringify(data));
}) })
await sleep(timeSleep); await sleep(timeSleep);
console.log('testContinueAbility0300 run end'); console.log('testContinueAbility0200 run end');
done(); done();
}) })
/** /**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0400 * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0400
* @tc.name testContinueAbility0200 * @tc.name testContinueAbility0400
* @tc.desc T * @tc.desc T (by callback)
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 3 * @tc.level : Level 3
*/ */
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');
done(); done();
}) })
/** /**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0500 * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0600
* @tc.name testContinueAbility0500 * @tc.name testContinueAbility0600
* @tc.desc T * @tc.desc T (by callback)
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 3 * @tc.level : Level 3
*/ */
it('testContinueAbility0500', 0, async function (done) { it('testContinueAbility0600', 0, async function (done) {
let options = { let options = {
deviceId : undefined, deviceId: undefined,
reversible : false, reversible: false,
} }
console.log('testContinueAbility0500 run start'); console.log('testContinueAbility0600 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => { abilityFeatureAbility.continueAbility(options, (err, data) => {
console.log('testContinueAbility0500 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('testContinueAbility0500 run end'); console.log('testContinueAbility0600 run end');
done(); done();
}) })
/** /**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0600 * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0700
* @tc.name testContinueAbility0600 * @tc.name testContinueAbility0700
* @tc.desc T * @tc.desc T (by promise)
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 3 * @tc.level : Level 3
*/ */
it('testContinueAbility0600', 0, async function (done) { it('testContinueAbility0700', 0, async function (done) {
let options = { let options = {
deviceId : "", deviceId: "",
reversible : false, reversible: false,
} }
console.log('testContinueAbility0600 run start'); console.log('testContinueAbility0700 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => { abilityFeatureAbility.continueAbility(options).then((data) => {
console.log('testContinueAbility0600 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('testContinueAbility0600 run end'); console.log('testContinueAbility0700 run end');
done(); done();
}) })
/** /**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0700 * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0800
* @tc.name testContinueAbility0700 * @tc.name testContinueAbility0800
* @tc.desc T * @tc.desc T (by callback)
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 3 * @tc.level : Level 3
*/ */
it('testContinueAbility0700', 0, async function (done) { it('testContinueAbility0800', 0, async function (done) {
let options = { let options = {
reversible : false, deviceId: "",
reversible: false,
} }
console.log('testContinueAbility0700 run start'); console.log('testContinueAbility0800 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => { abilityFeatureAbility.continueAbility(options, (err, data) => {
console.log('testContinueAbility0700 err is :' + JSON.stringify(err) + ', value is :' console.log('testContinueAbility0800 err is :' + JSON.stringify(err));
+ JSON.stringify(data)); console.log('testContinueAbility0800 value is :' + JSON.stringify(data));
}) })
await sleep(timeSleep); await sleep(timeSleep);
console.log('testContinueAbility0700 run end'); console.log('testContinueAbility0800 run end');
done(); done();
}) })
/** /**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_0900 * @tc.number SUB_AA_OpenHarmony_ContinueAbility_1000
* @tc.name testContinueAbility0900 * @tc.name testContinueAbility1000
* @tc.desc T * @tc.desc T (by callback)
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 3 * @tc.level : Level 3
*/ */
it('testContinueAbility0900', 0, async function (done) { it('testContinueAbility1000', 0, async function (done) {
let options = { let options = {
deviceId : "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26", reversible: false,
reversible : false,
} }
console.log('testContinueAbility0900 run start'); console.log('testContinueAbility1000 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => { abilityFeatureAbility.continueAbility(options, (err, data) => {
console.log('testContinueAbility0900 err is :' + JSON.stringify(err) + ', value is :' console.log('testContinueAbility1000 err is :' + JSON.stringify(err));
+ JSON.stringify(data)); console.log('testContinueAbility1000 value is :' + JSON.stringify(data));
}) })
await sleep(timeSleep); await sleep(timeSleep);
console.log('testContinueAbility0900 run end'); console.log('testContinueAbility1000 run end');
done(); done();
}) })
/** /**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_1000 * @tc.number SUB_AA_OpenHarmony_ContinueAbility_1100
* @tc.name testContinueAbility0900 * @tc.name testContinueAbility1100
* @tc.desc T * @tc.desc T (by promise)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility1100', 0, async function (done) {
let options = {
deviceId: "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26",
reversible: false,
}
console.log('testContinueAbility1100 run start');
abilityFeatureAbility.continueAbility(options).then((data) => {
console.log('testContinueAbility1100 value is :' + JSON.stringify(data));
}).catch((error) => {
console.log('testContinueAbility1100 err is :' + JSON.stringify(error));
})
await sleep(timeSleep);
console.log('testContinueAbility1100 run end');
done();
})
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_1200
* @tc.name testContinueAbility1200
* @tc.desc T (by callback)
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 3 * @tc.level : Level 3
*/ */
it('testContinueAbility1000', 0, async function (done) { it('testContinueAbility1200', 0, async function (done) {
let options = {
deviceId: "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26",
reversible: false,
}
console.log('testContinueAbility1200 run start');
abilityFeatureAbility.continueAbility(options, (err, data) => {
console.log('testContinueAbility1200 err is :' + JSON.stringify(err));
console.log('testContinueAbility1200 value is :' + JSON.stringify(data));
})
await sleep(timeSleep);
console.log('testContinueAbility1200 run end');
done();
})
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_1300
* @tc.name testContinueAbility1300
* @tc.desc T (by promise)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility1300', 0, async function (done) {
let options = { let options = {
deviceId : "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26", deviceId: "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26",
reversible : false, reversible: false,
} }
for(var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
abilityFeatureAbility.continueAbility(options).then((data) => {
console.log('testContinueAbility1300 value is :' + JSON.stringify(data));
}).catch((error) => {
console.log('testContinueAbility1300 err is :' + JSON.stringify(error));
})
}
await sleep(timeSleep);
console.log('testContinueAbility1300 run end');
done();
})
/**
* @tc.number SUB_AA_OpenHarmony_ContinueAbility_1400
* @tc.name testContinueAbility1400
* @tc.desc T (by callback)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it('testContinueAbility1400', 0, async function (done) {
let options = {
deviceId: "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26",
reversible: false,
}
for (var i = 0; i < 10; i++) {
abilityFeatureAbility.continueAbility(options, (err, data) => { abilityFeatureAbility.continueAbility(options, (err, data) => {
console.log('testContinueAbility1000 err is :' + JSON.stringify(err) + ', value is :' console.log('testContinueAbility1400 err is :' + JSON.stringify(err) + ', value is :'
+ JSON.stringify(data)); + 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
...@@ -62,7 +62,7 @@ afterAll((done) => { ...@@ -62,7 +62,7 @@ afterAll((done) => {
done(); done();
}, gSetTimeout); }, gSetTimeout);
}) })
/* /*
* @tc.number: ACTS_AfeatureAbilityEnum_0100 * @tc.number: ACTS_AfeatureAbilityEnum_0100
* @tc.name: Enum the client resource of the Data ability. * @tc.name: Enum the client resource of the Data ability.
...@@ -74,7 +74,7 @@ it('ACTS_AfeatureAbilityEnum_0100', 0, async function (done) { ...@@ -74,7 +74,7 @@ it('ACTS_AfeatureAbilityEnum_0100', 0, async function (done) {
expect(featureAbility.ContinuationState.LOCAL_RUNNING).assertEqual(0); expect(featureAbility.ContinuationState.LOCAL_RUNNING).assertEqual(0);
expect(featureAbility.ContinuationState.REMOTE_RUNNING).assertEqual(1); expect(featureAbility.ContinuationState.REMOTE_RUNNING).assertEqual(1);
expect(featureAbility.ContinuationState.REPLICA_RUNNING).assertEqual(2); expect(featureAbility.ContinuationState.REPLICA_RUNNING).assertEqual(2);
expect(abilityManager.ProcessErrCode.NO_ERROR).assertEqual(0); expect(abilityManager.ProcessErrCode.NO_ERROR).assertEqual(0);
expect(abilityManager.ProcessErrCode.CRASHED).assertEqual(1); expect(abilityManager.ProcessErrCode.CRASHED).assertEqual(1);
expect(abilityManager.ProcessErrCode.NO_RESPONSE).assertEqual(2); expect(abilityManager.ProcessErrCode.NO_RESPONSE).assertEqual(2);
...@@ -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
...@@ -229,15 +229,39 @@ describe('ActsContextTest', function () { ...@@ -229,15 +229,39 @@ describe('ActsContextTest', function () {
it('ACTS_RequestPermissionForUser_0100', 0, async function (done) { it('ACTS_RequestPermissionForUser_0100', 0, async function (done) {
var ret = false var ret = false
var context = await featureAbility.getContext(); var context = await featureAbility.getContext();
console.log("RequestPermissionForUser ----------1"); console.log("ACTS_RequestPermissionForUser_0100 ----------1");
context.requestPermissionsFromUser([], 1, context.requestPermissionsFromUser([], 1,
(err, data)=>{ (err, data)=>{
console.log("====>requestdata====>" + JSON.stringify(data)); console.log("====>ACTS_RequestPermissionForUser_0100 data====>" + JSON.stringify(data));
console.log("====>requesterrcode====>" + JSON.stringify(err.code)); console.log("====>ACTS_RequestPermissionForUser_0100 err====>" + JSON.stringify(err.code));
expect(err.code).assertEqual(-104) expect(err.code).assertEqual(-104)
}); });
console.log("RequestPermissionForUser ----------2"); console.log("ACTS_RequestPermissionForUser_0100 ----------2");
ret = true
done();
setTimeout(function(){
expect(ret).assertEqual(true)
},1000)
})
// @tc.number: ACTS_RequestPermissionForUser_0200
// @tc.name: requestPermissionsFromUser : Requests certain permissions from the system.
// permission: The list of permissions to be requested.
// @tc.desc: Requests certain permissions from the system.
// process is the current process. (by promise)
it('ACTS_RequestPermissionForUser_0200', 0, async function (done) {
var ret = false
var context = await featureAbility.getContext();
console.log("ACTS_RequestPermissionForUser_0200 ----------1");
context.requestPermissionsFromUser([], 1).then((data) => {
console.log("====>ACTS_RequestPermissionForUser_0200 data====>" + JSON.stringify(data));
}).catch((err) => {
console.log("====>ACTS_RequestPermissionForUser_0200 err====>" + JSON.stringify(err.code));
expect(err.code).assertEqual(-104)
})
console.log("ACTS_RequestPermissionForUser_0200 ----------2");
ret = true ret = true
done(); done();
setTimeout(function(){ setTimeout(function(){
......
...@@ -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_Ability_0200", 0, async function (done) {
let parameter = {
'want': {}
}
featureAbility.startAbility(parameter, (error, data) => {
console.log('testAbility0200 data: ' + JSON.stringify(data))
console.log('testAbility0200 error: ' + JSON.stringify(error))
expect(errCode1).assertEqual(error.code)
done();
})
})
/*
* @tc.number: SUB_AA_JsApi_StartAbility_0300
* @tc.name: testAbility0300.
* @tc.desc: StartAbility fail with error parameter.(by promise)
*/
it("SUB_AA_JsApi_StartAbility_0300", 0, async function (done) {
let parameter = {
'StartAbilityParameter': {
'want': {}
}
}
await featureAbility.startAbility(parameter).then((data) => {
console.log('testAbility0300 data: ' + JSON.stringify(data))
expect().assertFail()
}).catch((error) => {
console.log('testAbility0300 error: ' + JSON.stringify(error))
expect(errCode).assertEqual(error.code)
})
done()
})
/*
* @tc.number: SUB_AA_JsApi_StartAbility_0400
* @tc.name: testAbility0400.
* @tc.desc: StartAbility fail with error parameter.(by callback)
*/ */
it("SUB_AA_JsApi_StartAbility_0200", 0, async function (done) { it("SUB_AA_JsApi_StartAbility_0400", 0, async function (done) {
let parameter = { 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': { 'action': 'action.ohos.acts.aafwk.jsapi.MainAbility',
'bundleName': bundleName, 'entities': 'abc123'
'abilityName': mainAbilityName
}
} }
} }
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) => { featureAbility.startAbility((parameter), (error, data) => {
console.log('testAblity0800 data: ' + JSON.stringify(data) + ',err: ' + JSON.stringify(err)) console.log('testAblity0800 data: ' + JSON.stringify(data))
expect(errCode1).assertEqual(err.code) console.log('testAblity0800 error: ' + JSON.stringify(error))
done(); 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 promise)
*/
it("SUB_AA_JsApi_Ability_1900", 0, async function (done) {
let parameter = { let parameter = {
'StartAbilityParameter': { 'StartAbilityParameter': {
'want': { 'want': {
...@@ -228,17 +377,45 @@ describe('ConnectAbilityTest', function () { ...@@ -228,17 +377,45 @@ describe('ConnectAbilityTest', function () {
} }
} }
} }
featureAbility.startAbilityForResult(parameter, (err, data) => { await featureAbility.startAbilityForResult(parameter).then((data) => {
console.log('testAblity1400' + JSON.stringify(err)); console.log('testAblity1900 data: ' + JSON.stringify(data))
expect(errCode1).assertEqual(err.code) expect.assertFail()
}).catch((error) => {
console.log('testAblity1900 err:' + JSON.stringify(error));
expect(errCode1).assertEqual(error.code)
})
done()
})
/*
* @tc.number: SUB_AA_JsApi_Ability_2000
* @tc.name: testAblity2000.
* @tc.desc: startAbilityForResult-wrong input parameter format want a layer outside.(by callback)
*/
it("SUB_AA_JsApi_Ability_2000", 0, async function (done) {
let parameter = {
'StartAbilityParameter': {
'want': {
'bundleName': bundleName,
'abilityName': mainAbilityName,
'parameters': {
'key': resultCode,
'terminate': true
}
}
}
}
featureAbility.startAbilityForResult(parameter, (error, data) => {
console.log('testAblity2000' + JSON.stringify(error));
expect(errCode1).assertEqual(error.code)
done() done()
}) })
}) })
/* /*
* @tc.number: SUB_AA_JsApi_Ability_2100 * @tc.number: SUB_AA_JsApi_Ability_2100
* @tc.name: testAblity2100. * @tc.name: testAblity2100.
* @tc.desc: startAbilityForResult-want-Set bundleName and abilityName+flag-flag to character strings. * @tc.desc: startAbilityForResult-want-Set bundleName and abilityName+flag-flag to character strings.(by promise)
*/ */
it("SUB_AA_JsApi_Ability_2100", 0, async function (done) { it("SUB_AA_JsApi_Ability_2100", 0, async function (done) {
let parameter = { let parameter = {
...@@ -255,10 +432,34 @@ describe('ConnectAbilityTest', function () { ...@@ -255,10 +432,34 @@ describe('ConnectAbilityTest', function () {
await featureAbility.startAbilityForResult(parameter).then((data) => { await featureAbility.startAbilityForResult(parameter).then((data) => {
console.log('testAblity2100 data: ' + JSON.stringify(data)) console.log('testAblity2100 data: ' + JSON.stringify(data))
expect.assertFail() expect.assertFail()
}).catch((err) => { }).catch((error) => {
console.log('testAblity2100' + JSON.stringify(err)); console.log('testAblity2100' + JSON.stringify(error));
expect(undefined).assertEqual(err.code) expect(undefined).assertEqual(error.code)
}) })
done() done()
}) })
/*
* @tc.number: SUB_AA_JsApi_Ability_2200
* @tc.name: testAblity2200.
* @tc.desc: startAbilityForResult-want-Set bundleName and abilityName+flag-flag to character strings.(by callback)
*/
it("SUB_AA_JsApi_Ability_2200", 0, async function (done) {
let parameter = {
'want': {
'bundleName': bundleName,
'abilityName': mainAbilityName,
'flages': 'abc',
'parameters': {
'key': resultCode,
'terminate': true
}
}
}
featureAbility.startAbilityForResult(parameter, (error, data) => {
console.log('testAblity2200' + JSON.stringify(error));
expect(undefined).assertEqual(error.code)
done()
})
})
}) })
...@@ -27,8 +27,57 @@ describe('ActsGetWantTest', function () { ...@@ -27,8 +27,57 @@ describe('ActsGetWantTest', function () {
// @tc.number: ACTS_GetWant_0100 // @tc.number: ACTS_GetWant_0100
// @tc.name: getWant : get want in current ability // @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult, // @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data // and then use terminateselfwithresult to return the data (by promise)
it('ACTS_GetWant_0100', 0, async function (done) { it('ACTS_GetWant_0100', 0, async function (done) {
featureAbility.startAbilityForResult({
want: {
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action1",
parameters:
{
mykey0: 1,
mykey1: [1, 2, 3],
mykey2: "[1, 2, 3]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "STR", "helloopenharmony"],
},
}
}).then((data) => {
console.info('====> ACTS_GetWant_0100 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.parameters.mykey0).assertEqual(1);
expect(data.want.parameters.mykey1[0]).assertEqual(1);
expect(data.want.parameters.mykey1[1]).assertEqual(2);
expect(data.want.parameters.mykey1[2]).assertEqual(3);
expect(data.want.parameters.mykey2).assertEqual("[1, 2, 3]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmony");
setTimeout(()=>{
done();
}, TIMEOUT_NUMBER);
}).catch((error) => {
console.log('ACTS_GetWant_0100 error: ' + JSON.stringify(error))
expect.assertFail()
done();
})
})
// @tc.number: ACTS_GetWant_0200
// @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data (by callback)
it('ACTS_GetWant_0200', 0, async function (done) {
featureAbility.startAbilityForResult({ featureAbility.startAbilityForResult({
want: { want: {
deviceId: "", deviceId: "",
...@@ -47,7 +96,7 @@ describe('ActsGetWantTest', function () { ...@@ -47,7 +96,7 @@ describe('ActsGetWantTest', function () {
} }
}, },
(err, data) => { (err, data) => {
console.info('====> ACTS_StartAbilityForResult_0100 start ability=====>' + JSON.stringify(data)) console.info('====> ACTS_GetWant_0200 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual(""); expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap"); expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility"); expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
...@@ -70,10 +119,74 @@ describe('ActsGetWantTest', function () { ...@@ -70,10 +119,74 @@ describe('ActsGetWantTest', function () {
}) })
}) })
// @tc.number: ACTS_GetWant_0300
// @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data (by promise)
it('ACTS_GetWant_0300', 0, async function (done) {
featureAbility.startAbilityForResult({
want:
{
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action2",
entities: ["entity1", "entity2"],
type: "MIMETYPE",
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_ABILITY_FORWARD_RESULT,
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.3],
mykey2: "[1, 2, 3]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "!@#$%", "helloopenharmony"],
},
},
}).then((data) => {
checkOnAbilityResult0300(data);
setTimeout(()=>{
done();
}, TIMEOUT_NUMBER);
}).catch((error) => {
console.log('ACTS_GetWant_0300 error: ' + JSON.stringify(error))
expect.assertFail()
done();
})
})
function checkOnAbilityResult0300(data) {
console.info('====> ACTS_GetWant_0300 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action2");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.entities[1]).assertEqual("entity2");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITY_FORWARD_RESULT);
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.3);
expect(data.want.parameters.mykey2).assertEqual("[1, 2, 3]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("!@#$%");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmony");
console.info('====> ACTS_GetWant_0300 before done=====>')
}
// @tc.number: ACTS_GetWant_0400 // @tc.number: ACTS_GetWant_0400
// @tc.name: getWant : get want in current ability // @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult, // @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data // and then use terminateselfwithresult to return the data (by callback)
it('ACTS_GetWant_0400', 0, async function (done) { it('ACTS_GetWant_0400', 0, async function (done) {
featureAbility.startAbilityForResult({ featureAbility.startAbilityForResult({
want: want:
...@@ -98,40 +211,103 @@ describe('ActsGetWantTest', function () { ...@@ -98,40 +211,103 @@ describe('ActsGetWantTest', function () {
}, },
}, },
(err, data) => { (err, data) => {
console.info('====> ACTS_StartAbilityForResult_0400 start ability=====>' + JSON.stringify(data)) checkOnAbilityResult0400(data);
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action2");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.entities[1]).assertEqual("entity2");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITY_FORWARD_RESULT);
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.3);
expect(data.want.parameters.mykey2).assertEqual("[1, 2, 3]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("!@#$%");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmony");
console.info('====> before done=====>')
setTimeout(()=>{ setTimeout(()=>{
done(); done();
}, TIMEOUT_NUMBER); }, TIMEOUT_NUMBER);
}) })
}) })
function checkOnAbilityResult0400(data) {
console.info('====> ACTS_GetWant_0400 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action2");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.entities[1]).assertEqual("entity2");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITY_FORWARD_RESULT);
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.3);
expect(data.want.parameters.mykey2).assertEqual("[1, 2, 3]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("!@#$%");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmony");
console.info('====> ACTS_GetWant_0400 before done=====>')
}
// @tc.number: ACTS_GetWant_0500 // @tc.number: ACTS_GetWant_0500
// @tc.name: getWant : get want in current ability // @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult, // @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data // and then use terminateselfwithresult to return the data (by promise)
it('ACTS_GetWant_0500', 0, async function (done) { it('ACTS_GetWant_0500', 0, async function (done) {
featureAbility.startAbilityForResult({
want:
{
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_ABILITY_FORM_ENABLED,
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.0000000003],
mykey2: "[a, b, c]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
},
},
}).then((data) => {
console.info('====> ACTS_GetWant_0500 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITY_FORM_ENABLED);
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> ACTS_GetWant_0500 before done=====>')
setTimeout(()=>{
done();
}, TIMEOUT_NUMBER);
}).catch((error) => {
console.log('ACTS_GetWant_0500 error: ' + JSON.stringify(error))
expect.assertFail()
done();
})
})
// @tc.number: ACTS_GetWant_0600
// @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data (by callback)
it('ACTS_GetWant_0600', 0, async function (done) {
featureAbility.startAbilityForResult({ featureAbility.startAbilityForResult({
want: want:
{ {
...@@ -155,7 +331,7 @@ describe('ActsGetWantTest', function () { ...@@ -155,7 +331,7 @@ describe('ActsGetWantTest', function () {
}, },
}, },
(err, data) => { (err, data) => {
console.info('====> ACTS_StartAbilityForResult_0500 start ability=====>' + JSON.stringify(data)) console.info('====> ACTS_GetWant_0600 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual(""); expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap"); expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility"); expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
...@@ -176,126 +352,76 @@ describe('ActsGetWantTest', function () { ...@@ -176,126 +352,76 @@ describe('ActsGetWantTest', function () {
expect(data.want.parameters.mykey5[0]).assertEqual("str"); expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR"); expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony"); expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> before done=====>') console.info('====> ACTS_GetWant_0600 before done=====>')
setTimeout(()=>{ setTimeout(()=>{
done(); done();
}, TIMEOUT_NUMBER); }, TIMEOUT_NUMBER);
}) })
}) })
// @tc.number: ACTS_GetWant_0600
// @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data
it('ACTS_GetWant_0600', 0, async function (done) {
featureAbility.startAbilityForResult({
want:
{
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION ,
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.0000000003],
mykey2: "[a, b, c]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
},
},
},
(err, data) => {
console.info('====> ACTS_StartAbilityForResult_0600 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION);
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> before done=====>')
setTimeout(()=>{
done();
}, TIMEOUT_NUMBER);
})
})
// @tc.number: ACTS_GetWant_0700 // @tc.number: ACTS_GetWant_0700
// @tc.name: getWant : get want in current ability // @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult, // @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data // and then use terminateselfwithresult to return the data (by promise)
it('ACTS_GetWant_0700', 0, async function (done) { it('ACTS_GetWant_0700', 0, async function (done) {
featureAbility.startAbilityForResult({ featureAbility.startAbilityForResult({
want: want:
{
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
parameters:
{ {
deviceId: "", mykey0: 0.1,
bundleName: "com.example.actsgetwantalltesthap", mykey1: [0.1, 0.2, 0.0000000003],
abilityName: "com.example.actsgetwantalltesthap.MainAbility", mykey2: "[a, b, c]",
action: "action1", mykey3: "str",
entities: ["entity1"], mykey4: [false, true, false],
type: "MIMETYPE", mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION ,
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.0000000003],
mykey2: "[a, b, c]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
},
}, },
}, },
(err, data) => { }).then((data) => {
console.info('====> ACTS_StartAbilityForResult_0700 start ability=====>' + JSON.stringify(data)) console.info('====> ACTS_GetWant_0700 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual(""); expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap"); expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility"); expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1"); expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1"); expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE"); expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}"); expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION); expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION);
expect(data.want.parameters.mykey0).assertEqual(0.1); expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1); expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2); expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003); expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]"); expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str"); expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false); expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true); expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false); expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str"); expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR"); expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony"); expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> before done=====>') console.info('====> ACTS_GetWant_0700 before done=====>')
setTimeout(()=>{ setTimeout(()=>{
done(); done();
}, TIMEOUT_NUMBER); }, TIMEOUT_NUMBER);
}) }).catch((error) => {
console.log('ACTS_GetWant_0700 error: ' + JSON.stringify(error))
expect.assertFail()
done();
}) })
})
// @tc.number: ACTS_GetWant_0800 // @tc.number: ACTS_GetWant_0800
// @tc.name: getWant : get want in current ability // @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult, // @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data // and then use terminateselfwithresult to return the data (by callback)
it('ACTS_GetWant_0800', 0, async function (done) { it('ACTS_GetWant_0800', 0, async function (done) {
featureAbility.startAbilityForResult({ featureAbility.startAbilityForResult({
want: want:
...@@ -307,6 +433,7 @@ describe('ActsGetWantTest', function () { ...@@ -307,6 +433,7 @@ describe('ActsGetWantTest', function () {
entities: ["entity1"], entities: ["entity1"],
type: "MIMETYPE", type: "MIMETYPE",
uri: "key={true,true,false}", uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
parameters: parameters:
{ {
mykey0: 0.1, mykey0: 0.1,
...@@ -319,36 +446,42 @@ describe('ActsGetWantTest', function () { ...@@ -319,36 +446,42 @@ describe('ActsGetWantTest', function () {
}, },
}, },
(err, data) => { (err, data) => {
console.info('====> ACTS_StartAbilityForResult_0800 start ability=====>' + JSON.stringify(data)) checkOnAbilityResult0800(data);
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> before done=====>')
setTimeout(()=>{ setTimeout(()=>{
done(); done();
}, TIMEOUT_NUMBER); }, TIMEOUT_NUMBER);
}) })
}) })
function checkOnAbilityResult0800(data) {
console.info('====> ACTS_GetWant_0800 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION);
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> ACTS_GetWant_0800 before done=====>')
}
// @tc.number: ACTS_GetWant_0900 // @tc.number: ACTS_GetWant_0900
// @tc.name: getWant : get want in current ability // @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult, // @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data // and then use terminateselfwithresult to return the data (by promise)
it('ACTS_GetWant_0900', 0, async function (done) { it('ACTS_GetWant_0900', 0, async function (done) {
featureAbility.startAbilityForResult({ featureAbility.startAbilityForResult({
want: want:
...@@ -360,7 +493,7 @@ describe('ActsGetWantTest', function () { ...@@ -360,7 +493,7 @@ describe('ActsGetWantTest', function () {
entities: ["entity1"], entities: ["entity1"],
type: "MIMETYPE", type: "MIMETYPE",
uri: "key={true,true,false}", uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_NOT_OHOS_COMPONENT , flags: wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION,
parameters: parameters:
{ {
mykey0: 0.1, mykey0: 0.1,
...@@ -371,92 +504,103 @@ describe('ActsGetWantTest', function () { ...@@ -371,92 +504,103 @@ describe('ActsGetWantTest', function () {
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"], mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
}, },
}, },
}, }).then((data) => {
(err, data) => { console.info('====> ACTS_GetWant_0900 start ability=====>' + JSON.stringify(data))
console.info('====> ACTS_StartAbilityForResult_0900 start ability=====>' + JSON.stringify(data)) expect(data.want.deviceId).assertEqual("");
expect(data.want.deviceId).assertEqual(""); expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap"); expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility"); expect(data.want.action).assertEqual("action1");
expect(data.want.action).assertEqual("action1"); expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.entities[0]).assertEqual("entity1"); expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.type).assertEqual("MIMETYPE"); expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.uri).assertEqual("key={true,true,false}"); expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION);
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_NOT_OHOS_COMPONENT); expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey0).assertEqual(0.1); expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1); expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2); expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003); expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]"); expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey3).assertEqual("str"); expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[0]).assertEqual(false); expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[1]).assertEqual(true); expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey4[2]).assertEqual(false); expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[0]).assertEqual("str"); expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[1]).assertEqual("STR"); expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony"); console.info('====> ACTS_GetWant_0900 before done=====>')
console.info('====> before done=====>') setTimeout(()=>{
setTimeout(()=>{ done();
done(); }, TIMEOUT_NUMBER);
}, TIMEOUT_NUMBER); }).catch((error) => {
}) console.log('ACTS_GetWant_0900 error: ' + JSON.stringify(error))
expect.assertFail()
done();
})
}) })
// @tc.number: ACTS_GetWant_1000 // @tc.number: ACTS_GetWant_1000
// @tc.name: getWant : get want in current ability // @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult, // @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data // and then use terminateselfwithresult to return the data (by callback)
it('ACTS_GetWant_1000', 0, async function (done) { it('ACTS_GetWant_1000', 0, async function (done) {
featureAbility.startAbilityForResult({ featureAbility.startAbilityForResult({
want: want:
{ {
deviceId: "", deviceId: "",
bundleName: "com.example.actsgetwantalltesthap", bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility", abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action1", action: "action1",
entities: ["entity1"], entities: ["entity1"],
type: "MIMETYPE", type: "MIMETYPE",
uri: "key={true,true,false}", uri: "key={true,true,false}",
parameters: flags: wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION,
{ parameters:
mykey0: 0.1, {
mykey1: [0.1, 0.2, 0.0000000003], mykey0: 0.1,
mykey2: "[a, b, c]", mykey1: [0.1, 0.2, 0.0000000003],
mykey3: "str", mykey2: "[a, b, c]",
mykey4: [false, true, false], mykey3: "str",
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"], mykey4: [false, true, false],
}, mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
}, },
}, },
(err, data) => { },
console.info('====> ACTS_StartAbilityForResult_1000 start ability=====>' + JSON.stringify(data)) (err, data) => {
expect(data.want.deviceId).assertEqual(""); checkOnAbilityResult1000(data);
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap"); setTimeout(()=>{
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility"); done();
expect(data.want.action).assertEqual("action1"); }, TIMEOUT_NUMBER);
expect(data.want.entities[0]).assertEqual("entity1"); })
expect(data.want.type).assertEqual("MIMETYPE"); })
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.parameters.mykey0).assertEqual(0.1); function checkOnAbilityResult1000(data) {
expect(data.want.parameters.mykey1[0]).assertEqual(0.1); console.info('====> ACTS_GetWant_1000 start ability=====>' + JSON.stringify(data))
expect(data.want.parameters.mykey1[1]).assertEqual(0.2); expect(data.want.deviceId).assertEqual("");
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003); expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]"); expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.parameters.mykey3).assertEqual("str"); expect(data.want.action).assertEqual("action1");
expect(data.want.parameters.mykey4[0]).assertEqual(false); expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.parameters.mykey4[1]).assertEqual(true); expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.parameters.mykey4[2]).assertEqual(false); expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.parameters.mykey5[0]).assertEqual("str"); expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION);
expect(data.want.parameters.mykey5[1]).assertEqual("STR"); expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony"); expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
console.info('====> before done=====>') expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
setTimeout(()=>{ expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
done(); expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
}, TIMEOUT_NUMBER); expect(data.want.parameters.mykey3).assertEqual("str");
}) expect(data.want.parameters.mykey4[0]).assertEqual(false);
}) expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> ACTS_GetWant_1000 before done=====>')
}
// @tc.number: ACTS_GetWant_1100 // @tc.number: ACTS_GetWant_1100
// @tc.name: getWant : get want in current ability // @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult, // @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data // and then use terminateselfwithresult to return the data (by promise)
it('ACTS_GetWant_1100', 0, async function (done) { it('ACTS_GetWant_1100', 0, async function (done) {
featureAbility.startAbilityForResult({ featureAbility.startAbilityForResult({
want: want:
...@@ -478,93 +622,100 @@ describe('ActsGetWantTest', function () { ...@@ -478,93 +622,100 @@ describe('ActsGetWantTest', function () {
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"], mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
}, },
}, },
}, }).then((data) => {
(err, data) => { checkOnAbilityResult1100(data);
console.info('====> ACTS_StartAbilityForResult_1100 start ability=====>' + JSON.stringify(data)) setTimeout(()=>{
expect(data.want.deviceId).assertEqual(""); done();
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap"); }, TIMEOUT_NUMBER);
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility"); }).catch((error) => {
expect(data.want.action).assertEqual("action1"); console.log('ACTS_GetWant_1100 error: ' + JSON.stringify(error))
expect(data.want.entities[0]).assertEqual("entity1"); expect.assertFail()
expect(data.want.type).assertEqual("MIMETYPE"); done();
expect(data.want.uri).assertEqual("key={true,true,false}"); })
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> before done.=====>')
setTimeout(()=>{
done();
}, TIMEOUT_NUMBER);
})
}) })
function checkOnAbilityResult1100(data) {
console.info('====> ACTS_GetWant_1100 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> ACTS_GetWant_1100 before done=====>')
}
// @tc.number: ACTS_GetWant_1200 // @tc.number: ACTS_GetWant_1200
// @tc.name: getWant : get want in current ability // @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult, // @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data // and then use terminateselfwithresult to return the data (by callback)
it('ACTS_GetWant_1200', 0, async function (done) { it('ACTS_GetWant_1200', 0, async function (done) {
featureAbility.startAbilityForResult({ featureAbility.startAbilityForResult({
want: want:
{
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
parameters:
{ {
deviceId: "", mykey0: 0.1,
bundleName: "com.example.actsgetwantalltesthap", mykey1: [0.1, 0.2, 0.0000000003],
abilityName: "com.example.actsgetwantalltesthap.MainAbility", mykey2: "[a, b, c]",
action: "action1", mykey3: "str",
entities: ["entity1"], mykey4: [false, true, false],
type: "MIMETYPE", mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_ABILITYSLICE_MULTI_DEVICE ,
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.0000000003],
mykey2: "[a, b, c]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
},
}, },
}, },
(err, data) => { },
console.info('====> ACTS_StartAbilityForResult_1200 start ability=====>' + JSON.stringify(data)) (err, data) => {
expect(data.want.deviceId).assertEqual(""); console.info('====> ACTS_GetWant_1200 start ability=====>' + JSON.stringify(data))
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap"); expect(data.want.deviceId).assertEqual("");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility"); expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.action).assertEqual("action1"); expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.entities[0]).assertEqual("entity1"); expect(data.want.action).assertEqual("action1");
expect(data.want.type).assertEqual("MIMETYPE"); expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.uri).assertEqual("key={true,true,false}"); expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITYSLICE_MULTI_DEVICE ); expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.parameters.mykey0).assertEqual(0.1); expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1); expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2); expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003); expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]"); expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str"); expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false); expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true); expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false); expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str"); expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR"); expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony"); expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> setTimeout before done.=====>') console.info('====> ACTS_GetWant_1200 before done=====>')
setTimeout(()=>{ setTimeout(()=>{
done(); done();
}, TIMEOUT_NUMBER); }, TIMEOUT_NUMBER);
}) })
}) })
// @tc.number: ACTS_GetWant_1300 // @tc.number: ACTS_GetWant_1300
// @tc.name: getWant : get want in current ability // @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult, // @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data // and then use terminateselfwithresult to return the data (by promise)
it('ACTS_GetWant_1300', 0, async function (done) { it('ACTS_GetWant_1300', 0, async function (done) {
featureAbility.startAbilityForResult({ featureAbility.startAbilityForResult({
want: want:
...@@ -576,7 +727,7 @@ describe('ActsGetWantTest', function () { ...@@ -576,7 +727,7 @@ describe('ActsGetWantTest', function () {
entities: ["entity1"], entities: ["entity1"],
type: "MIMETYPE", type: "MIMETYPE",
uri: "key={true,true,false}", uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_START_FOREGROUND_ABILITY , flags: wantConstant.Flags.FLAG_NOT_OHOS_COMPONENT,
parameters: parameters:
{ {
mykey0: 0.1, mykey0: 0.1,
...@@ -587,94 +738,104 @@ describe('ActsGetWantTest', function () { ...@@ -587,94 +738,104 @@ describe('ActsGetWantTest', function () {
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"], mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
}, },
}, },
}, }).then((data) => {
(err, data) => { console.info('====> ACTS_GetWant_1300 start ability=====>' + JSON.stringify(data))
console.info('====> ACTS_StartAbilityForResult_1300 start ability=====>' + JSON.stringify(data)) expect(data.want.deviceId).assertEqual("");
expect(data.want.deviceId).assertEqual(""); expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap"); expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility"); expect(data.want.action).assertEqual("action1");
expect(data.want.action).assertEqual("action1"); expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.entities[0]).assertEqual("entity1"); expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.type).assertEqual("MIMETYPE"); expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.uri).assertEqual("key={true,true,false}"); expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_NOT_OHOS_COMPONENT);
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_START_FOREGROUND_ABILITY ); expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey0).assertEqual(0.1); expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1); expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2); expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003); expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]"); expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey3).assertEqual("str"); expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[0]).assertEqual(false); expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[1]).assertEqual(true); expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey4[2]).assertEqual(false); expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[0]).assertEqual("str"); expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[1]).assertEqual("STR"); expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony"); console.info('====> ACTS_GetWant_1300 before done=====>')
console.info('====> setTimeout before done.=====>') setTimeout(()=>{
setTimeout(()=>{ done();
done(); }, TIMEOUT_NUMBER);
}, TIMEOUT_NUMBER); }).catch((error) => {
}) console.log('ACTS_GetWant_1300 error: ' + JSON.stringify(error))
expect.assertFail()
done();
})
}) })
// @tc.number: ACTS_GetWant_1400 // @tc.number: ACTS_GetWant_1400
// @tc.name: getWant : get want in current ability // @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult, // @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data // and then use terminateselfwithresult to return the data (by callback)
it('ACTS_GetWant_1400', 0, async function (done) { it('ACTS_GetWant_1400', 0, async function (done) {
featureAbility.startAbilityForResult({ featureAbility.startAbilityForResult({
want: want:
{
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_NOT_OHOS_COMPONENT,
parameters:
{ {
deviceId: "", mykey0: 0.1,
bundleName: "com.example.actsgetwantalltesthap", mykey1: [0.1, 0.2, 0.0000000003],
abilityName: "com.example.actsgetwantalltesthap.MainAbility", mykey2: "[a, b, c]",
action: "action1", mykey3: "str",
entities: ["entity1"], mykey4: [false, true, false],
type: "MIMETYPE", mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
uri: "key={true,true,false}",
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.0000000003],
mykey2: "[a, b, c]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
},
}, },
}, },
(err, data) => { },
console.info('====> ACTS_StartAbilityForResult_1400 start ability=====>' + JSON.stringify(data)) (err, data) => {
expect(data.want.deviceId).assertEqual(""); checkOnAbilityResult1400(data);
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap"); setTimeout(()=>{
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility"); done();
expect(data.want.action).assertEqual("action1"); }, TIMEOUT_NUMBER);
expect(data.want.entities[0]).assertEqual("entity1"); })
expect(data.want.type).assertEqual("MIMETYPE"); })
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> setTimeout before done.=====>')
setTimeout(()=>{
done();
}, TIMEOUT_NUMBER);
})
})
// @tc.number: ACTS_GetWant_1600 function checkOnAbilityResult1400(data) {
console.info('====> ACTS_GetWant_1400 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_NOT_OHOS_COMPONENT);
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> ACTS_GetWant_1400 before done=====>')
}
// @tc.number: ACTS_GetWant_1500
// @tc.name: getWant : get want in current ability // @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult, // @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data // and then use terminateselfwithresult to return the data (by promise)
it('ACTS_GetWant_1600', 0, async function (done) { it('ACTS_GetWant_1500', 0, async function (done) {
featureAbility.startAbilityForResult({ featureAbility.startAbilityForResult({
want: want:
{ {
...@@ -685,7 +846,7 @@ describe('ActsGetWantTest', function () { ...@@ -685,7 +846,7 @@ describe('ActsGetWantTest', function () {
entities: ["entity1"], entities: ["entity1"],
type: "MIMETYPE", type: "MIMETYPE",
uri: "key={true,true,false}", uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_INSTALL_WITH_BACKGROUND_MODE, flags: wantConstant.Flags.FLAG_ABILITYSLICE_MULTI_DEVICE,
parameters: parameters:
{ {
mykey0: 0.1, mykey0: 0.1,
...@@ -696,40 +857,465 @@ describe('ActsGetWantTest', function () { ...@@ -696,40 +857,465 @@ describe('ActsGetWantTest', function () {
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"], mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
}, },
}, },
}, }).then((data) => {
(err, data) => { checkOnAbilityResult1500(data);
console.info('====> ACTS_StartAbilityForResult_1600 start ability=====>' + JSON.stringify(data)) setTimeout(()=>{
expect(data.want.deviceId).assertEqual(""); done();
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap"); }, TIMEOUT_NUMBER);
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility"); }).catch((error) => {
expect(data.want.action).assertEqual("action1"); console.log('ACTS_GetWant_1500 error: ' + JSON.stringify(error))
expect(data.want.entities[0]).assertEqual("entity1"); expect.assertFail()
expect(data.want.type).assertEqual("MIMETYPE"); done();
expect(data.want.uri).assertEqual("key={true,true,false}"); })
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_INSTALL_WITH_BACKGROUND_MODE);
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> setTimeout before done.=====>')
setTimeout(()=>{
done();
}, TIMEOUT_NUMBER);
})
}) })
function checkOnAbilityResult1500(data) {
console.info('====> ACTS_GetWant_1500 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITYSLICE_MULTI_DEVICE );
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> ACTS_GetWant_1500 setTimeout before done.=====>')
}
// @tc.number: ACTS_GetWant_1600
// @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data (by callback)
it('ACTS_GetWant_1600', 0, async function (done) {
featureAbility.startAbilityForResult({
want:
{
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_ABILITYSLICE_MULTI_DEVICE,
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.0000000003],
mykey2: "[a, b, c]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
},
},
},
(err, data) => {
console.info('====> ACTS_GetWant_1600 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITYSLICE_MULTI_DEVICE );
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> ACTS_GetWant_1600 setTimeout before done.=====>')
setTimeout(()=>{
done();
}, TIMEOUT_NUMBER);
})
})
// @tc.number: ACTS_GetWant_1700 // @tc.number: ACTS_GetWant_1700
// @tc.name: getWant : get want in current ability // @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult, // @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data // and then use terminateselfwithresult to return the data (by promise)
it('ACTS_GetWant_1700', 0, async function (done) { it('ACTS_GetWant_1700', 0, async function (done) {
featureAbility.startAbilityForResult({
want:
{
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_START_FOREGROUND_ABILITY,
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.0000000003],
mykey2: "[a, b, c]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
},
},
}).then((data) => {
console.info('====> ACTS_GetWant_1700 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_START_FOREGROUND_ABILITY );
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> ACTS_GetWant_1700 setTimeout before done.=====>')
setTimeout(()=>{
done();
}, TIMEOUT_NUMBER);
}).catch((error) => {
console.log('ACTS_GetWant_1700 error: ' + JSON.stringify(error))
expect.assertFail()
done();
})
})
// @tc.number: ACTS_GetWant_1800
// @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data (by callback)
it('ACTS_GetWant_1800', 0, async function (done) {
featureAbility.startAbilityForResult({
want:
{
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_START_FOREGROUND_ABILITY,
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.0000000003],
mykey2: "[a, b, c]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
},
},
},
(err, data) => {
console.info('====> ACTS_GetWant_1800 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_START_FOREGROUND_ABILITY );
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> ACTS_GetWant_1800 setTimeout before done.=====>')
setTimeout(()=>{
done();
}, TIMEOUT_NUMBER);
})
})
// @tc.number: ACTS_GetWant_1900
// @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data (by promise)
it('ACTS_GetWant_1900', 0, async function (done) {
featureAbility.startAbilityForResult({
want:
{
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_INSTALL_WITH_BACKGROUND_MODE,
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.0000000003],
mykey2: "[a, b, c]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
},
},
}).then((data) => {
checkOnAbilityResult1900(data);
setTimeout(()=>{
done();
}, TIMEOUT_NUMBER);
}).catch((error) => {
console.log('ACTS_GetWant_1900 error: ' + JSON.stringify(error))
expect.assertFail()
done();
})
})
function checkOnAbilityResult1900(data) {
console.info('====> ACTS_GetWant_1900 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_INSTALL_WITH_BACKGROUND_MODE);
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> ACTS_GetWant_1900 setTimeout before done.=====>')
}
// @tc.number: ACTS_GetWant_2000
// @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data (by callback)
it('ACTS_GetWant_2000', 0, async function (done) {
featureAbility.startAbilityForResult({
want:
{
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_INSTALL_WITH_BACKGROUND_MODE,
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.0000000003],
mykey2: "[a, b, c]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
},
},
},
(err, data) => {
checkOnAbilityResult2000(data);
setTimeout(()=>{
done();
}, TIMEOUT_NUMBER);
})
})
function checkOnAbilityResult2000(data) {
console.info('====> ACTS_GetWant_2000 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_INSTALL_WITH_BACKGROUND_MODE);
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> ACTS_GetWant_2000 setTimeout before done.=====>')
}
// @tc.number: ACTS_GetWant_2100
// @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data (by promise)
it('ACTS_GetWant_2100', 0, async function (done) {
featureAbility.startAbilityForResult({
want:
{
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_ABILITY_CLEAR_MISSION,
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.0000000003],
mykey2: "[a, b, c]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
},
},
}).then((data) => {
checkOnAbilityResult2100(data);
setTimeout(()=>{
done();
}, TIMEOUT_NUMBER);
}).catch((error) => {
console.log('ACTS_GetWant_2100 error: ' + JSON.stringify(error))
expect.assertFail()
done();
})
})
function checkOnAbilityResult2100(data) {
console.info('====> ACTS_GetWant_2100 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITY_CLEAR_MISSION);
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> ACTS_GetWant_2100 setTimeout before done.=====>')
}
// @tc.number: ACTS_GetWant_2200
// @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data (by callback)
it('ACTS_GetWant_2200', 0, async function (done) {
featureAbility.startAbilityForResult({
want:
{
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_ABILITY_CLEAR_MISSION,
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.0000000003],
mykey2: "[a, b, c]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
},
},
},
(err, data) => {
checkOnAbilityResult2200(data);
setTimeout(()=>{
done();
}, TIMEOUT_NUMBER);
})
})
function checkOnAbilityResult2200(data) {
console.info('====> ACTS_GetWant_2200 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITY_CLEAR_MISSION);
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> ACTS_GetWant_2200 setTimeout before done.=====>')
}
// @tc.number: ACTS_GetWant_2300
// @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data (by promise)
it('ACTS_GetWant_2300', 0, async function (done) {
featureAbility.startAbilityForResult({ featureAbility.startAbilityForResult({
want: want:
{ {
...@@ -740,7 +1326,7 @@ describe('ActsGetWantTest', function () { ...@@ -740,7 +1326,7 @@ describe('ActsGetWantTest', function () {
entities: ["entity1"], entities: ["entity1"],
type: "MIMETYPE", type: "MIMETYPE",
uri: "key={true,true,false}", uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_ABILITY_CLEAR_MISSION, flags: wantConstant.Flags.FLAG_ABILITY_NEW_MISSION,
parameters: parameters:
{ {
mykey0: 0.1, mykey0: 0.1,
...@@ -751,135 +1337,230 @@ describe('ActsGetWantTest', function () { ...@@ -751,135 +1337,230 @@ describe('ActsGetWantTest', function () {
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"], mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
}, },
}, },
}, }).then((data) => {
(err, data) => { checkOnAbilityResult2300(data);
console.info('====> ACTS_StartAbilityForResult_1700 start ability=====>' + JSON.stringify(data)) setTimeout(()=>{
expect(data.want.deviceId).assertEqual(""); done();
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap"); }, TIMEOUT_NUMBER);
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility"); }).catch((error) => {
expect(data.want.action).assertEqual("action1"); console.log('ACTS_GetWant_2300 error: ' + JSON.stringify(error))
expect(data.want.entities[0]).assertEqual("entity1"); expect.assertFail()
expect(data.want.type).assertEqual("MIMETYPE"); done();
expect(data.want.uri).assertEqual("key={true,true,false}"); })
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITY_CLEAR_MISSION);
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> setTimeout before done.=====>')
setTimeout(()=>{
done();
}, TIMEOUT_NUMBER);
})
}) })
// @tc.number: ACTS_GetWant_1800
function checkOnAbilityResult2300(data) {
console.info('====> ACTS_GetWant_2300 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action1");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITY_NEW_MISSION);
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> ACTS_GetWant_2300 setTimeout before done.=====>')
}
// @tc.number: ACTS_GetWant_2400
// @tc.name: getWant : get want in current ability // @tc.name: getWant : get want in current ability
// @tc.desc:Start the ability through startabilityforresult, // @tc.desc:Start the ability through startabilityforresult,
// and then use terminateselfwithresult to return the data // and then use terminateselfwithresult to return the data (by callback)
it('ACTS_GetWant_1800', 0, async function (done) { it('ACTS_GetWant_2400', 0, async function (done) {
featureAbility.startAbilityForResult({ featureAbility.startAbilityForResult({
want: want:
{
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_ABILITY_NEW_MISSION,
parameters:
{ {
deviceId: "", mykey0: 0.1,
bundleName: "com.example.actsgetwantalltesthap", mykey1: [0.1, 0.2, 0.0000000003],
abilityName: "com.example.actsgetwantalltesthap.MainAbility", mykey2: "[a, b, c]",
action: "action1", mykey3: "str",
entities: ["entity1"], mykey4: [false, true, false],
type: "MIMETYPE", mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_ABILITY_NEW_MISSION,
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.0000000003],
mykey2: "[a, b, c]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"],
},
}, },
}, },
(err, data) => { },
console.info('====> ACTS_StartAbilityForResult_1800 start ability=====>' + JSON.stringify(data)) (err, data) => {
expect(data.want.deviceId).assertEqual(""); checkOnAbilityResult2400(data);
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap"); setTimeout(()=>{
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility"); done();
expect(data.want.action).assertEqual("action1"); }, TIMEOUT_NUMBER);
expect(data.want.entities[0]).assertEqual("entity1"); })
expect(data.want.type).assertEqual("MIMETYPE"); })
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITY_NEW_MISSION); function checkOnAbilityResult2400(data) {
expect(data.want.parameters.mykey0).assertEqual(0.1); console.info('====> ACTS_GetWant_2400 start ability=====>' + JSON.stringify(data))
expect(data.want.parameters.mykey1[0]).assertEqual(0.1); expect(data.want.deviceId).assertEqual("");
expect(data.want.parameters.mykey1[1]).assertEqual(0.2); expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003); expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.parameters.mykey2).assertEqual("[a, b, c]"); expect(data.want.action).assertEqual("action1");
expect(data.want.parameters.mykey3).assertEqual("str"); expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.parameters.mykey4[0]).assertEqual(false); expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.parameters.mykey4[1]).assertEqual(true); expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.parameters.mykey4[2]).assertEqual(false); expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITY_NEW_MISSION);
expect(data.want.parameters.mykey5[0]).assertEqual("str"); expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey5[1]).assertEqual("STR"); expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony"); expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
console.info('====> setTimeout before done.=====>') expect(data.want.parameters.mykey1[2]).assertEqual(0.0000000003);
setTimeout(()=>{ expect(data.want.parameters.mykey2).assertEqual("[a, b, c]");
done(); expect(data.want.parameters.mykey3).assertEqual("str");
}, TIMEOUT_NUMBER); expect(data.want.parameters.mykey4[0]).assertEqual(false);
}) expect(data.want.parameters.mykey4[1]).assertEqual(true);
}) expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("STR");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmonyhelloopenharmonyhelloopenharmony");
console.info('====> ACTS_GetWant_2400 setTimeout before done.=====>')
}
/* /*
* @tc.number ACTS_GetWant_2000 * @tc.number ACTS_GetWant_2500
* @tc.name Misconfigured bundlename validation * @tc.name Misconfigured bundlename validation
* @tc.desc Function test * @tc.desc Function test (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it("ACTS_GetWant_2000",0, async function(done){ it("ACTS_GetWant_2500",0, async function(done){
console.info("------------------start ACTS_GetWant_2000-------------------"); featureAbility.startAbilityForResult({
try{ want:
featureAbility.startAbilityForResult({ {
want: deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action2",
entities: ["entity1", "entity2"],
type: "MIMETYPE",
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_ABILITY_FORWARD_RESULT,
parameters:
{ {
deviceId: "", mykey0: 0.1,
bundleName: "com.example.actsgetwantalltesthap", mykey1: [0.1, 0.2, 0.3],
abilityName: "com.example.actsgetwantalltesthap.MainAbility", mykey2: "[1, 2, 3]",
action: "action2", mykey3: "str",
entities: ["entity1", "entity2"], mykey4: [false, true, false],
type: "MIMETYPE", mykey5: ["str", "test123", "helloopenharmony"],
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_ABILITY_FORWARD_RESULT,
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.3],
mykey2: "[1, 2, 3]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "test123", "helloopenharmony"],
},
}, },
}, },
(err, data) => { }).then((data) => {
checkOnAbilityResult(data); checkOnAbilityResult2500(data);
console.info('====> setTimeout before done.=====>') setTimeout(()=>{
setTimeout(()=>{ done();
done(); }, TIMEOUT_NUMBER);
}, TIMEOUT_NUMBER); }).catch((error) => {
}) console.log('ACTS_GetWant_2500 error: ' + JSON.stringify(error))
}catch(error){ expect.assertFail()
console.log("ACTS_GetWant_2000 : error = " + error); done();
} })
console.log('ACTS_GetWant_2000 end'); });
function checkOnAbilityResult2500(data) {
console.info('====> ACTS_GetWant_2500 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action2");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITY_FORWARD_RESULT );
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.3);
expect(data.want.parameters.mykey2).assertEqual("[1, 2, 3]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("test123");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmony");
console.info('====> ACTS_GetWant_2500 before done=====>')
}
/*
* @tc.number ACTS_GetWant_2600
* @tc.name Misconfigured bundlename validation
* @tc.desc Function test (by callback)
* @tc.level 0
*/
it("ACTS_GetWant_2600",0, async function(done){
featureAbility.startAbilityForResult({
want:
{
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action2",
entities: ["entity1", "entity2"],
type: "MIMETYPE",
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_ABILITY_FORWARD_RESULT,
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.3],
mykey2: "[1, 2, 3]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "test123", "helloopenharmony"],
},
},
},
(err, data) => {
checkOnAbilityResult2600(data);
setTimeout(()=>{
done();
}, TIMEOUT_NUMBER);
})
}); });
function checkOnAbilityResult2600(data) {
console.info('====> ACTS_GetWant_2600 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action2");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITY_FORWARD_RESULT );
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.3);
expect(data.want.parameters.mykey2).assertEqual("[1, 2, 3]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("test123");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmony");
console.info('====> ACTS_GetWant_2600 before done=====>')
}
/** /**
* @tc.number: SUB_AA_OpenHarmony_wantConstantEnumeration_0100 * @tc.number: SUB_AA_OpenHarmony_wantConstantEnumeration_0100
* @tc.name: Check the enumerated value ACTION_IMAGE_CAPTURE of wantConstant. * @tc.name: Check the enumerated value ACTION_IMAGE_CAPTURE of wantConstant.
...@@ -918,29 +1599,4 @@ describe('ActsGetWantTest', function () { ...@@ -918,29 +1599,4 @@ describe('ActsGetWantTest', function () {
console.log("SUB_AA_OpenHarmony_wantConstantEnumeration_0300 --- end") console.log("SUB_AA_OpenHarmony_wantConstantEnumeration_0300 --- end")
done() done()
}) })
function checkOnAbilityResult(data) {
console.info('====> ACTS_StartAbilityForResult_2000 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action2");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITY_FORWARD_RESULT );
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.3);
expect(data.want.parameters.mykey2).assertEqual("[1, 2, 3]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("test123");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmony");
console.info('====> before 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,165 @@ describe('ActsBundleManagerTest', function () { ...@@ -88,10 +88,165 @@ 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) {
checkBundleInfo0200(datainfo)
done();
}
})
function checkBundleInfo0200(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);
}
/**
* @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,13 +286,86 @@ describe('ActsBundleManagerTest', function () { ...@@ -131,13 +286,86 @@ 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. (by promise)
*/
it('getBundleInfo_0900', 0, async function (done) {
await 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. (by callback)
*/
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();
}
}) })
/** /**
* @tc.number getBundleInfo_1100 * @tc.number getBundleInfo_1100
* @tc.name BUNDLE::getBundleInfo * @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with one hap and different param. * @tc.desc Test getBundleInfo interfaces with one hap and different param. (by promise)
*/ */
it('getBundleInfo_1100', 0, async function (done) { it('getBundleInfo_1100', 0, async function (done) {
let datainfo = await demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_DEFAULT) let datainfo = await demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_DEFAULT)
...@@ -163,7 +391,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -163,7 +391,7 @@ describe('ActsBundleManagerTest', function () {
/** /**
* @tc.number getBundleInfo_1200 * @tc.number getBundleInfo_1200
* @tc.name BUNDLE::getBundleInfo * @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with one hap and different param. * @tc.desc Test getBundleInfo interfaces with one hap and different param. (by callback)
*/ */
it('getBundleInfo_1200', 0, async function (done) { it('getBundleInfo_1200', 0, async function (done) {
await demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_DEFAULT, OnReceiveEvent) await demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_DEFAULT, OnReceiveEvent)
...@@ -193,64 +421,232 @@ describe('ActsBundleManagerTest', function () { ...@@ -193,64 +421,232 @@ describe('ActsBundleManagerTest', function () {
}) })
/** /**
* @tc.number getApplicationInfos_0100 * @tc.number getBundleInfo_1400
* @tc.name BUNDLE::getApplicationInfos * @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getApplicationInfos interfaces with one hap. * @tc.desc Test getBundleInfo interfaces with LAUNCHER hap.(by callback)
*/
it('getApplicationInfos_0100', 0, async function (done) {
let datainfo = await demo.getAllApplicationInfo(demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID);
checkgetApplicationInfos(datainfo);
done();
})
function checkgetApplicationInfos(datainfo) {
console.log("=============datainfo.length===============" + datainfo.length);
expect(datainfo.length).assertLarger(0);
for (let i = 0; i < datainfo.length; i++) {
expect(datainfo[i].name.length).assertLarger(0);
if (datainfo[i].name == NAME1 || datainfo[i].name == NAME2
|| datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) {
expect(datainfo[i].description.length).assertLarger(0);
expect(datainfo[i].icon.length).assertLarger(0);
expect(datainfo[i].label.length).assertLarger(0);
}
expect(datainfo[i].moduleSourceDirs.length).assertLarger(0);
expect(datainfo[i].moduleInfos.length).assertLarger(0);
expect(datainfo[i].supportedModes).assertEqual(0);
expect(datainfo[i].flags).assertEqual(0);
for (let j = 0; j < datainfo[i].moduleInfos; j++) {
expect(datainfo[i].moduleInfos[j].moduleName.length).assertLarger(0);
expect(datainfo[i].moduleInfos[j].moduleSourceDir.length).assertLarger(0);
}
}
}
/**
* @tc.number getApplicationInfos_0600
* @tc.name BUNDLE::getApplicationInfos
* @tc.desc Test getApplicationInfos interfaces with one hap.
*/ */
it('getApplicationInfos_0600', 0, async function (done) { it('getBundleInfo_1400', 0, async function (done) {
await demo.getAllApplicationInfo(demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, await demo.getBundleInfo(LAUNCHER, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES,
USERID, (error, datainfo) => { bundleOptions, (err, dataInfo) => {
expect(datainfo.length).assertLarger(0); if (err) {
for (let i = 0; i < datainfo.length; i++) { console.info("getBundleInfo_1400 fail:" + JSON.stringify(err));
expect(datainfo[i].name.length).assertLarger(0); expect(err).assertFail();
expect(datainfo[i].moduleSourceDirs.length).assertLarger(0);
expect(datainfo[i].moduleInfos.length).assertLarger(0);
expect(datainfo[i].supportedModes).assertEqual(0);
expect(datainfo[i].flags).assertEqual(0);
for (let j = 0; j < datainfo[i].moduleInfos; j++) {
expect(datainfo[i].moduleInfos[j].moduleName.length).assertLarger(0);
expect(datainfo[i].moduleInfos[j].moduleSourceDir.length).assertLarger(0);
}
}
done(); 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 getBundleInfos_0100 * @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
};
await 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) {
await 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) {
await 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.name BUNDLE::getApplicationInfos
* @tc.desc Test getApplicationInfos interfaces with one hap.
*/
it('getApplicationInfos_0100', 0, async function (done) {
let datainfo = await demo.getAllApplicationInfo(demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID);
checkgetApplicationInfos(datainfo);
done();
})
function checkgetApplicationInfos(datainfo) {
console.log("=============datainfo.length===============" + datainfo.length);
expect(datainfo.length).assertLarger(0);
for (let i = 0; i < datainfo.length; i++) {
expect(datainfo[i].name.length).assertLarger(0);
if (datainfo[i].name == NAME1 || datainfo[i].name == NAME2
|| datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) {
expect(datainfo[i].description.length).assertLarger(0);
expect(datainfo[i].icon.length).assertLarger(0);
expect(datainfo[i].label.length).assertLarger(0);
}
expect(datainfo[i].moduleSourceDirs.length).assertLarger(0);
expect(datainfo[i].moduleInfos.length).assertLarger(0);
expect(datainfo[i].supportedModes).assertEqual(0);
expect(datainfo[i].flags).assertEqual(0);
for (let j = 0; j < datainfo[i].moduleInfos; j++) {
expect(datainfo[i].moduleInfos[j].moduleName.length).assertLarger(0);
expect(datainfo[i].moduleInfos[j].moduleSourceDir.length).assertLarger(0);
}
}
}
/**
* @tc.number getApplicationInfos_0600
* @tc.name BUNDLE::getApplicationInfos
* @tc.desc Test getApplicationInfos interfaces with one hap.
*/
it('getApplicationInfos_0600', 0, async function (done) {
await demo.getAllApplicationInfo(demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION,
USERID, (error, datainfo) => {
expect(datainfo.length).assertLarger(0);
for (let i = 0; i < datainfo.length; i++) {
expect(datainfo[i].name.length).assertLarger(0);
expect(datainfo[i].moduleSourceDirs.length).assertLarger(0);
expect(datainfo[i].moduleInfos.length).assertLarger(0);
expect(datainfo[i].supportedModes).assertEqual(0);
expect(datainfo[i].flags).assertEqual(0);
for (let j = 0; j < datainfo[i].moduleInfos; j++) {
expect(datainfo[i].moduleInfos[j].moduleName.length).assertLarger(0);
expect(datainfo[i].moduleInfos[j].moduleSourceDir.length).assertLarger(0);
}
}
done();
});
})
/**
* @tc.number getBundleInfos_0100
* @tc.name BUNDLE::getBundleInfos * @tc.name BUNDLE::getBundleInfos
* @tc.desc Test getBundleInfos interfaces with one hap. * @tc.desc Test getBundleInfos interfaces with one hap.
*/ */
...@@ -262,7 +658,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -262,7 +658,7 @@ describe('ActsBundleManagerTest', function () {
expect(data[i].name.length).assertLarger(0); expect(data[i].name.length).assertLarger(0);
expect(data[i].appInfo.name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0);
if (data[i].name == NAME1 || data[i].name == NAME2 if (data[i].name == NAME1 || data[i].name == NAME2
|| data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) {
expect(data[i].appInfo.description.length).assertLarger(0); expect(data[i].appInfo.description.length).assertLarger(0);
expect(data[i].appInfo.icon.length).assertLarger(0); expect(data[i].appInfo.icon.length).assertLarger(0);
expect(data[i].appInfo.label.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0);
...@@ -276,14 +672,61 @@ describe('ActsBundleManagerTest', function () { ...@@ -276,14 +672,61 @@ describe('ActsBundleManagerTest', function () {
/** /**
* @tc.number getApplicationInfo_0100 * @tc.number getApplicationInfo_0100
* @tc.name BUNDLE::getApplicationInfo * @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with one hap. * @tc.desc Test getApplicationInfo interfaces with one hap. (by promise)
*/ */
it('getApplicationInfo_0100', 0, async function (done) { it('getApplicationInfo_0100', 0, async function (done) {
await demo.getApplicationInfo(NAME1, await demo.getApplicationInfo(NAME1,
demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION | demo.BundleFlag.GET_APPLICATION_INFO_WITH_METADATA, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION | demo.BundleFlag.GET_APPLICATION_INFO_WITH_METADATA,
USERID).then(datainfo => { USERID).then(datainfo => {
expect(typeof datainfo).assertEqual(OBJECT);
console.info("getApplicationInfo success:" + JSON.stringify(datainfo));
expect(datainfo.moduleSourceDirs.length).assertLarger(0);
expect(datainfo.moduleInfos.length).assertLarger(0);
expect(datainfo.name).assertEqual(NAME1);
expect(datainfo.description).assertEqual(DESCRIPTION);
expect(datainfo.icon).assertEqual("$media:icon");
expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.systemApp).assertEqual(true);
expect(datainfo.descriptionId).assertLarger(0);
expect(parseInt(datainfo.iconId)).assertLarger(0);
expect(parseInt(datainfo.labelId)).assertLarger(0);
expect(datainfo.supportedModes).assertEqual(0);
expect(datainfo.process).assertEqual("");
expect(datainfo.enabled).assertEqual(true);
expect(datainfo.flags).assertEqual(0);
expect(datainfo.metaData.entry[0].name).assertEqual("metaDataName");
expect(datainfo.metaData.entry[0].value).assertEqual("metaDataValue");
expect(datainfo.metaData.entry[0].extra).assertEqual("$string:app_name");
expect(datainfo.moduleSourceDirs.length).assertLarger(0);
for (let j = 0; j < datainfo.moduleInfos; j++) {
expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry");
expect(datainfo.moduleInfos[j].moduleSourceDir.length).assertLarger(0);
}
done();
}).catch(err => {
console.info("getApplicationInfo fail:" + JSON.stringify(err));
expect(err).assertFail();
done();
})
})
/**
* @tc.number getApplicationInfo_0200
* @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with one hap. (by callback)
*/
it('getApplicationInfo_0200', 0, async function (done) {
await demo.getApplicationInfo(NAME1,
demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION | demo.BundleFlag.GET_APPLICATION_INFO_WITH_METADATA,
USERID, (error, datainfo) => {
if (error) {
console.info("getApplicationInfo_0200 fail:" + JSON.stringify(error));
expect(error).assertFail();
done();
return;
}
expect(typeof datainfo).assertEqual(OBJECT); expect(typeof datainfo).assertEqual(OBJECT);
console.info("getApplicationInfo success:" + JSON.stringify(datainfo)); console.info("getApplicationInfo_0200 success:" + JSON.stringify(datainfo));
expect(datainfo.moduleSourceDirs.length).assertLarger(0); expect(datainfo.moduleSourceDirs.length).assertLarger(0);
expect(datainfo.moduleInfos.length).assertLarger(0); expect(datainfo.moduleInfos.length).assertLarger(0);
expect(datainfo.name).assertEqual(NAME1); expect(datainfo.name).assertEqual(NAME1);
...@@ -307,77 +750,217 @@ describe('ActsBundleManagerTest', function () { ...@@ -307,77 +750,217 @@ describe('ActsBundleManagerTest', function () {
expect(datainfo.moduleInfos[j].moduleSourceDir.length).assertLarger(0); expect(datainfo.moduleInfos[j].moduleSourceDir.length).assertLarger(0);
} }
done(); done();
}).catch(err => {
console.info("getApplicationInfo fail:" + JSON.stringify(err));
expect(err).assertFail();
done();
}) })
}) })
/** /**
* @tc.number getBundleInfos_0600 * @tc.number getApplicationInfo_0300
* @tc.name BUNDLE::getBundleInfos * @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getBundleInfos interfaces with one hap. * @tc.desc Test getApplicationInfo interfaces with two haps. (by promise)
*/ */
it('getBundleInfos_0600', 0, async function (done) { it('getApplicationInfo_0300', 0, async function (done) {
await demo.getAllBundleInfo(demo.BundleFlag.GET_BUNDLE_DEFAULT, (error, data) => { let datainfo = await demo.getApplicationInfo(NAME2,
expect(typeof data).assertEqual(OBJECT); demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID);
for (let i = 0; i < data.length; i++) { console.info("getApplicationInfo_0300 result" + JSON.stringify(datainfo));
expect(data[i].name.length).assertLarger(0); expect(typeof datainfo).assertEqual(OBJECT);
expect(data[i].appInfo.name.length).assertLarger(0); expect(datainfo.name.length).assertLarger(0);
if (data[i].name == NAME1 || data[i].name == NAME2 expect(datainfo.description.length).assertLarger(0);
|| data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { expect(datainfo.icon.length).assertLarger(0);
expect(data[i].appInfo.description.length).assertLarger(0); expect(datainfo.label.length).assertLarger(0);
expect(data[i].appInfo.icon.length).assertLarger(0); expect(datainfo.moduleSourceDirs.length).assertLarger(0);
expect(data[i].appInfo.label.length).assertLarger(0); expect(datainfo.moduleInfos.length).assertLarger(0);
} expect(datainfo.name).assertEqual(NAME2);
expect(data[i].appInfo.supportedModes).assertEqual(0); expect(datainfo.description).assertEqual(DESCRIPTION);
expect(data[i].appInfo.moduleInfos.length).assertLarger(0); expect(datainfo.icon).assertEqual("$media:icon");
} expect(datainfo.label).assertEqual("$string:app_name");
done(); expect(datainfo.systemApp).assertEqual(true);
}); expect(datainfo.descriptionId >= 0).assertTrue();
expect(datainfo.iconId >= 0).assertTrue();
expect(datainfo.labelId >= 0).assertTrue();
expect(datainfo.supportedModes).assertEqual(0);
expect(datainfo.process).assertEqual("");
expect(datainfo.enabled).assertEqual(true);
expect(datainfo.flags).assertEqual(0);
expect(datainfo.moduleSourceDirs.length).assertLarger(0);
for (let j = 0; j < datainfo.moduleInfos; j++) {
expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry");
expect(datainfo.moduleInfos[j].moduleSourceDir.length).assertLarger(0);
}
done();
}) })
/** /**
* @tc.number getApplicationInfo_0600 * @tc.number getApplicationInfo_0400
* @tc.name BUNDLE::getApplicationInfo * @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with one hap. * @tc.desc Test getApplicationInfo interfaces with two haps. (by callback)
*/ */
it('getApplicationInfo_0600', 0, async function (done) { it('getApplicationInfo_0400', 0, async function (done) {
await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID, await demo.getApplicationInfo(NAME2,
(error, datainfo) => { demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID, (error, datainfo) => {
if (error) { console.info("getApplicationInfo_0400 result" + JSON.stringify(datainfo));
console.info("getApplicationInfo fail:" + JSON.stringify(error));
expect(error).assertFail();
}
console.info("getApplicationInfo success:" + JSON.stringify(datainfo));
expect(typeof datainfo).assertEqual(OBJECT); expect(typeof datainfo).assertEqual(OBJECT);
expect(datainfo.name).assertEqual(NAME1); expect(datainfo.name.length).assertLarger(0);
expect(datainfo.label).assertEqual("$string:app_name"); expect(datainfo.description.length).assertLarger(0);
expect(datainfo.icon.length).assertLarger(0);
expect(datainfo.label.length).assertLarger(0);
expect(datainfo.moduleSourceDirs.length).assertLarger(0);
expect(datainfo.moduleInfos.length).assertLarger(0);
expect(datainfo.name).assertEqual(NAME2);
expect(datainfo.description).assertEqual(DESCRIPTION); expect(datainfo.description).assertEqual(DESCRIPTION);
expect(datainfo.icon).assertEqual("$media:icon"); expect(datainfo.icon).assertEqual("$media:icon");
expect(datainfo.descriptionId >= 0).assertTrue(); expect(datainfo.label).assertEqual("$string:app_name");
expect(parseInt(datainfo.iconId)).assertLarger(0);
expect(parseInt(datainfo.labelId)).assertLarger(0);
expect(datainfo.systemApp).assertEqual(true); expect(datainfo.systemApp).assertEqual(true);
expect(datainfo.descriptionId >= 0).assertTrue();
expect(datainfo.iconId >= 0).assertTrue();
expect(datainfo.labelId >= 0).assertTrue();
expect(datainfo.supportedModes).assertEqual(0); expect(datainfo.supportedModes).assertEqual(0);
expect(datainfo.process).assertEqual("");
expect(datainfo.enabled).assertEqual(true); expect(datainfo.enabled).assertEqual(true);
expect(datainfo.flags).assertEqual(0);
expect(datainfo.moduleSourceDirs.length).assertLarger(0);
for (let j = 0; j < datainfo.moduleInfos; j++) { for (let j = 0; j < datainfo.moduleInfos; j++) {
expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry"); expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry");
expect(datainfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1); expect(datainfo.moduleInfos[j].moduleSourceDir.length).assertLarger(0);
}
done();
})
})
/**
* @tc.number getApplicationInfo_0500
* @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with three haps. (by promise)
*/
it('getApplicationInfo_0500', 0, async function (done) {
let datainfo = await demo.getApplicationInfo(NAME3, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION,
demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES);
console.info("getApplicationInfo_0500 result" + JSON.stringify(datainfo));
expect(datainfo.name).assertEqual(NAME3);
expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.description).assertEqual(DESCRIPTION);
expect(datainfo.icon).assertEqual("$media:icon");
expect(datainfo.name).assertEqual(NAME3);
expect(datainfo.description).assertEqual(DESCRIPTION);
expect(datainfo.descriptionId >= 0).assertTrue();
expect(datainfo.icon).assertEqual("$media:icon");
expect(datainfo.iconId >= 0).assertTrue();
expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.labelId >= 0).assertTrue();
expect(datainfo.systemApp).assertEqual(true);
expect(datainfo.supportedModes).assertEqual(0);
done();
})
/**
* @tc.number getApplicationInfo_0600
* @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with three haps. (by callback)
*/
it('getApplicationInfo_0600', 0, async function (done) {
await demo.getApplicationInfo(NAME3, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION,
demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, (error, datainfo) => {
console.info("getApplicationInfo_0600 result" + JSON.stringify(datainfo));
expect(datainfo.name).assertEqual(NAME3);
expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.description).assertEqual(DESCRIPTION);
expect(datainfo.icon).assertEqual("$media:icon");
expect(datainfo.name).assertEqual(NAME3);
expect(datainfo.description).assertEqual(DESCRIPTION);
expect(datainfo.descriptionId >= 0).assertTrue();
expect(datainfo.icon).assertEqual("$media:icon");
expect(datainfo.iconId >= 0).assertTrue();
expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.labelId >= 0).assertTrue();
expect(datainfo.systemApp).assertEqual(true);
expect(datainfo.supportedModes).assertEqual(0);
done();
})
})
/**
* @tc.number getApplicationInfo_0700
* @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with error hap. (by promise)
*/
it('getApplicationInfo_0700', 0, async function (done) {
await demo.getApplicationInfo(ERROR, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION,
USERID).then(datainfo => {
console.info("getApplicationInfo_0700 success" + JSON.stringify(datainfo));
expect(datainfo).assertFail();
done();
}).catch(err => {
console.info("getApplicationInfo_0700 err" + JSON.stringify(err));
expect(err).assertEqual(1);
done();
});
})
/**
* @tc.number getApplicationInfo_0800
* @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with error hap. (by callback)
*/
it('getApplicationInfo_0800', 0, async function (done) {
await demo.getApplicationInfo(ERROR, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION,
USERID, (error, datainfo) => {
if (error) {
console.info("getApplicationInfo_0800 fail" + JSON.stringify(error));
expect(error).assertEqual(1);
done();
return;
} }
console.info("getApplicationInfo_0800 success" + JSON.stringify(datainfo));
expect(datainfo).assertFail();
done(); done();
}) })
}) })
/**
* @tc.number getApplicationInfo_0900
* @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with none hap. (by promise)
*/
it('getApplicationInfo_0900', 0, async function (done) {
await demo.getApplicationInfo('', demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION,
USERID).then(datainfo => {
console.info("getApplicationInfo_0900 success" + JSON.stringify(datainfo));
expect(datainfo).assertFail();
done();
}).catch(error => {
console.info("getApplicationInfo_0900 err" + JSON.stringify(error));
expect(error).assertEqual(1);
done();
});
})
/**
* @tc.number getApplicationInfo_1000
* @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with none hap. (by callback)
*/
it('getApplicationInfo_1000', 0, async function (done) {
await demo.getApplicationInfo('', demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION,
USERID, (error, datainfo) => {
if (error) {
console.info("getApplicationInfo_1000 fail" + JSON.stringify(error));
expect(error).assertEqual(1);
done();
return;
}
console.info("getApplicationInfo_1000 success" + JSON.stringify(datainfo));
expect(datainfo).assertFail();
done();
});
})
/** /**
* @tc.number getApplicationInfo_1100 * @tc.number getApplicationInfo_1100
* @tc.name BUNDLE::getApplicationInfo * @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with one hap and different param. * @tc.desc Test getApplicationInfo interfaces with one hap and different param. (by promise)
*/ */
it('getApplicationInfo_1100', 0, async function (done) { it('getApplicationInfo_1100', 0, async function (done) {
await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_BUNDLE_DEFAULT, USERID).then(datainfo => { await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_BUNDLE_DEFAULT, USERID).then(datainfo => {
console.info("getApplicationInfo success" + JSON.stringify(datainfo)); console.info("getApplicationInfo_1100 success" + JSON.stringify(datainfo));
expect(typeof datainfo).assertEqual(OBJECT); expect(typeof datainfo).assertEqual(OBJECT);
expect(datainfo.name).assertEqual(NAME1); expect(datainfo.name).assertEqual(NAME1);
expect(datainfo.label).assertEqual("$string:app_name"); expect(datainfo.label).assertEqual("$string:app_name");
...@@ -388,25 +971,28 @@ describe('ActsBundleManagerTest', function () { ...@@ -388,25 +971,28 @@ describe('ActsBundleManagerTest', function () {
expect(parseInt(datainfo.labelId)).assertLarger(0); expect(parseInt(datainfo.labelId)).assertLarger(0);
expect(datainfo.systemApp).assertEqual(true); expect(datainfo.systemApp).assertEqual(true);
expect(datainfo.supportedModes).assertEqual(0); expect(datainfo.supportedModes).assertEqual(0);
done();
}).catch(err => { }).catch(err => {
console.info("getApplicationInfo fail" + JSON.stringify(err)); console.info("getApplicationInfo_1100 fail" + JSON.stringify(err));
expect(err).assertFail(); expect(err).assertFail();
done();
}) })
done();
}) })
/** /**
* @tc.number getApplicationInfo_1200 * @tc.number getApplicationInfo_1200
* @tc.name BUNDLE::getApplicationInfo * @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with one hap and different param. * @tc.desc Test getApplicationInfo interfaces with one hap and different param. (by callback)
*/ */
it('getApplicationInfo_1200', 0, async function (done) { it('getApplicationInfo_1200', 0, async function (done) {
await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_BUNDLE_DEFAULT, USERID, (error, datainfo) => { await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_BUNDLE_DEFAULT, USERID, (error, datainfo) => {
if (error) { if (error) {
console.info("getApplicationInfo fail" + JSON.stringify(error)); console.info("getApplicationInfo_1200 fail" + JSON.stringify(error));
expect(error).assertFail(); expect(error).assertFail();
done();
return;
} }
console.info("getApplicationInfo success" + JSON.stringify(datainfo)); console.info("getApplicationInfo_1200 success" + JSON.stringify(datainfo));
expect(typeof datainfo).assertEqual(OBJECT); expect(typeof datainfo).assertEqual(OBJECT);
expect(datainfo.name).assertEqual(NAME1); expect(datainfo.name).assertEqual(NAME1);
expect(datainfo.label).assertEqual("$string:app_name"); expect(datainfo.label).assertEqual("$string:app_name");
...@@ -422,51 +1008,93 @@ describe('ActsBundleManagerTest', function () { ...@@ -422,51 +1008,93 @@ describe('ActsBundleManagerTest', function () {
}) })
/** /**
* @tc.number getBundleInfo_0200 * @tc.number getApplicationInfo_1300
* @tc.name BUNDLE::getBundleInfo * @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getBundleInfo interfaces with two haps. * @tc.desc Test getApplicationInfo interfaces with one hap. (by promise)
*/ */
it('getBundleInfo_0200', 0, async function (done) { it('getApplicationInfo_1300', 0, async function (done) {
let datainfo = await demo.getBundleInfo(NAME2, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES); await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION,
expect(datainfo.name).assertEqual(NAME2); USERID).then(datainfo => {
expect(datainfo.vendor).assertEqual("example"); console.info("getApplicationInfo_1300 success:" + JSON.stringify(datainfo));
expect(datainfo.versionCode).assertEqual(1); expect(typeof datainfo).assertEqual(OBJECT);
expect(datainfo.versionName).assertLarger(0); expect(datainfo.name).assertEqual(NAME1);
expect(datainfo.entryModuleName).assertEqual("entry"); expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.appInfo.name).assertEqual(NAME2); expect(datainfo.description).assertEqual(DESCRIPTION);
expect(datainfo.appInfo.description).assertEqual(DESCRIPTION); expect(datainfo.icon).assertEqual("$media:icon");
expect(datainfo.appInfo.descriptionId >= 0).assertTrue(); expect(datainfo.descriptionId >= 0).assertTrue();
expect(datainfo.appInfo.icon).assertEqual("$media:icon"); expect(parseInt(datainfo.iconId)).assertLarger(0);
expect(datainfo.appInfo.iconId >= 0).assertTrue(); expect(parseInt(datainfo.labelId)).assertLarger(0);
expect(datainfo.appInfo.label).assertEqual("$string:app_name"); expect(datainfo.systemApp).assertEqual(true);
expect(datainfo.appInfo.labelId >= 0).assertTrue(); expect(datainfo.supportedModes).assertEqual(0);
expect(datainfo.appInfo.systemApp).assertEqual(true); expect(datainfo.enabled).assertEqual(true);
done(); for (let j = 0; j < datainfo.moduleInfos; j++) {
expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry");
expect(datainfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1);
}
done();
}).catch(error => {
console.info("getApplicationInfo_1300 fail:" + JSON.stringify(error));
expect(error).assertFail();
done();
})
})
/**
* @tc.number getApplicationInfo_1400
* @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with one hap. (by callback)
*/
it('getApplicationInfo_1400', 0, async function (done) {
await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID,
(error, datainfo) => {
if (error) {
console.info("getApplicationInfo_1400 fail:" + JSON.stringify(error));
expect(error).assertFail();
done();
return;
}
console.info("getApplicationInfo_1400 success:" + JSON.stringify(datainfo));
expect(typeof datainfo).assertEqual(OBJECT);
expect(datainfo.name).assertEqual(NAME1);
expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.description).assertEqual(DESCRIPTION);
expect(datainfo.icon).assertEqual("$media:icon");
expect(datainfo.descriptionId >= 0).assertTrue();
expect(parseInt(datainfo.iconId)).assertLarger(0);
expect(parseInt(datainfo.labelId)).assertLarger(0);
expect(datainfo.systemApp).assertEqual(true);
expect(datainfo.supportedModes).assertEqual(0);
expect(datainfo.enabled).assertEqual(true);
for (let j = 0; j < datainfo.moduleInfos; j++) {
expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry");
expect(datainfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1);
}
done();
})
}) })
/** /**
* @tc.number getBundleInfo_0700 * @tc.number getBundleInfos_0600
* @tc.name BUNDLE::getBundleInfo * @tc.name BUNDLE::getBundleInfos
* @tc.desc Test getBundleInfo interfaces with two haps. * @tc.desc Test getBundleInfos interfaces with one hap.
*/ */
it('getBundleInfo_0700', 0, async function (done) { it('getBundleInfos_0600', 0, async function (done) {
await demo.getBundleInfo(NAME2, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent); await demo.getAllBundleInfo(demo.BundleFlag.GET_BUNDLE_DEFAULT, (error, data) => {
function OnReceiveEvent(err, datainfo) { expect(typeof data).assertEqual(OBJECT);
expect(datainfo.name).assertEqual(NAME2); for (let i = 0; i < data.length; i++) {
expect(datainfo.vendor).assertEqual("example"); expect(data[i].name.length).assertLarger(0);
expect(datainfo.versionCode).assertEqual(1); expect(data[i].appInfo.name.length).assertLarger(0);
expect(datainfo.versionName).assertLarger(0); if (data[i].name == NAME1 || data[i].name == NAME2
expect(datainfo.entryModuleName).assertEqual("entry"); || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) {
expect(datainfo.appInfo.name).assertEqual(NAME2); expect(data[i].appInfo.description.length).assertLarger(0);
expect(datainfo.appInfo.description).assertEqual(DESCRIPTION); expect(data[i].appInfo.icon.length).assertLarger(0);
expect(datainfo.appInfo.descriptionId >= 0).assertTrue(); expect(data[i].appInfo.label.length).assertLarger(0);
expect(datainfo.appInfo.icon).assertEqual("$media:icon"); }
expect(datainfo.appInfo.iconId >= 0).assertTrue(); expect(data[i].appInfo.supportedModes).assertEqual(0);
expect(datainfo.appInfo.label).assertEqual("$string:app_name"); expect(data[i].appInfo.moduleInfos.length).assertLarger(0);
expect(datainfo.appInfo.labelId >= 0).assertTrue(); }
expect(datainfo.appInfo.systemApp).assertEqual(true);
done(); done();
} });
}) })
/** /**
...@@ -504,7 +1132,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -504,7 +1132,7 @@ describe('ActsBundleManagerTest', function () {
for (let i = 0; i < datainfo.length; i++) { for (let i = 0; i < datainfo.length; i++) {
expect(datainfo[i].name.length).assertLarger(0); expect(datainfo[i].name.length).assertLarger(0);
if (datainfo[i].name == NAME1 || datainfo[i].name == NAME2 if (datainfo[i].name == NAME1 || datainfo[i].name == NAME2
|| datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) { || datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) {
expect(datainfo[i].description.length).assertLarger(0); expect(datainfo[i].description.length).assertLarger(0);
expect(datainfo[i].icon.length).assertLarger(0); expect(datainfo[i].icon.length).assertLarger(0);
expect(datainfo[i].label.length).assertLarger(0); expect(datainfo[i].label.length).assertLarger(0);
...@@ -532,7 +1160,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -532,7 +1160,7 @@ describe('ActsBundleManagerTest', function () {
for (let i = 0; i < datainfo.length; i++) { for (let i = 0; i < datainfo.length; i++) {
expect(datainfo[i].name.length).assertLarger(0); expect(datainfo[i].name.length).assertLarger(0);
if (datainfo[i].name == NAME1 || datainfo[i].name == NAME2 if (datainfo[i].name == NAME1 || datainfo[i].name == NAME2
|| datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) { || datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) {
expect(datainfo[i].description.length).assertLarger(0); expect(datainfo[i].description.length).assertLarger(0);
expect(datainfo[i].icon.length).assertLarger(0); expect(datainfo[i].icon.length).assertLarger(0);
expect(datainfo[i].label.length).assertLarger(0); expect(datainfo[i].label.length).assertLarger(0);
...@@ -560,7 +1188,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -560,7 +1188,7 @@ describe('ActsBundleManagerTest', function () {
for (let i = 0; i < datainfo.length; i++) { for (let i = 0; i < datainfo.length; i++) {
expect(datainfo[i].name.length).assertLarger(0); expect(datainfo[i].name.length).assertLarger(0);
if (datainfo[i].name == NAME1 || datainfo[i].name == NAME2 if (datainfo[i].name == NAME1 || datainfo[i].name == NAME2
|| datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) { || datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) {
expect(datainfo[i].description.length).assertLarger(0); expect(datainfo[i].description.length).assertLarger(0);
expect(datainfo[i].icon.length).assertLarger(0); expect(datainfo[i].icon.length).assertLarger(0);
expect(datainfo[i].label.length).assertLarger(0); expect(datainfo[i].label.length).assertLarger(0);
...@@ -590,7 +1218,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -590,7 +1218,7 @@ describe('ActsBundleManagerTest', function () {
expect(data[i].name.length).assertLarger(0); expect(data[i].name.length).assertLarger(0);
expect(data[i].appInfo.name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0);
if (data[i].name == NAME1 || data[i].name == NAME2 if (data[i].name == NAME1 || data[i].name == NAME2
|| data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) {
expect(data[i].appInfo.description.length).assertLarger(0); expect(data[i].appInfo.description.length).assertLarger(0);
expect(data[i].appInfo.icon.length).assertLarger(0); expect(data[i].appInfo.icon.length).assertLarger(0);
expect(data[i].appInfo.label.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0);
...@@ -613,7 +1241,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -613,7 +1241,7 @@ describe('ActsBundleManagerTest', function () {
expect(data[i].name.length).assertLarger(0); expect(data[i].name.length).assertLarger(0);
expect(data[i].appInfo.name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0);
if (data[i].name == NAME1 || data[i].name == NAME2 if (data[i].name == NAME1 || data[i].name == NAME2
|| data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) {
expect(data[i].appInfo.description.length).assertLarger(0); expect(data[i].appInfo.description.length).assertLarger(0);
expect(data[i].appInfo.icon.length).assertLarger(0); expect(data[i].appInfo.icon.length).assertLarger(0);
expect(data[i].appInfo.label.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0);
...@@ -624,41 +1252,6 @@ describe('ActsBundleManagerTest', function () { ...@@ -624,41 +1252,6 @@ describe('ActsBundleManagerTest', function () {
done(); done();
}) })
/**
* @tc.number getApplicationInfo_0200
* @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with two haps.
*/
it('getApplicationInfo_0200', 0, async function (done) {
let datainfo = await demo.getApplicationInfo(NAME2,
demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID);
console.info("getApplicationInfo result" + JSON.stringify(datainfo));
expect(typeof datainfo).assertEqual(OBJECT);
expect(datainfo.name.length).assertLarger(0);
expect(datainfo.description.length).assertLarger(0);
expect(datainfo.icon.length).assertLarger(0);
expect(datainfo.label.length).assertLarger(0);
expect(datainfo.moduleSourceDirs.length).assertLarger(0);
expect(datainfo.moduleInfos.length).assertLarger(0);
expect(datainfo.name).assertEqual(NAME2);
expect(datainfo.description).assertEqual(DESCRIPTION);
expect(datainfo.icon).assertEqual("$media:icon");
expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.systemApp).assertEqual(true);
expect(datainfo.descriptionId >= 0).assertTrue();
expect(datainfo.iconId >= 0).assertTrue();
expect(datainfo.labelId >= 0).assertTrue();
expect(datainfo.supportedModes).assertEqual(0);
expect(datainfo.process).assertEqual("");
expect(datainfo.enabled).assertEqual(true);
expect(datainfo.flags).assertEqual(0);
expect(datainfo.moduleSourceDirs.length).assertLarger(0);
for (let j = 0; j < datainfo.moduleInfos; j++) {
expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry");
expect(datainfo.moduleInfos[j].moduleSourceDir.length).assertLarger(0);
}
done();
})
/** /**
* @tc.number getBundleInfos_0700 * @tc.number getBundleInfos_0700
...@@ -672,7 +1265,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -672,7 +1265,7 @@ describe('ActsBundleManagerTest', function () {
expect(data[i].name.length).assertLarger(0); expect(data[i].name.length).assertLarger(0);
expect(data[i].appInfo.name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0);
if (data[i].name == NAME1 || data[i].name == NAME2 if (data[i].name == NAME1 || data[i].name == NAME2
|| data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) {
expect(data[i].appInfo.description.length).assertLarger(0); expect(data[i].appInfo.description.length).assertLarger(0);
expect(data[i].appInfo.icon.length).assertLarger(0); expect(data[i].appInfo.icon.length).assertLarger(0);
expect(data[i].appInfo.label.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0);
...@@ -696,7 +1289,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -696,7 +1289,7 @@ describe('ActsBundleManagerTest', function () {
expect(data[i].name.length).assertLarger(0); expect(data[i].name.length).assertLarger(0);
expect(data[i].appInfo.name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0);
if (data[i].name == NAME1 || data[i].name == NAME2 if (data[i].name == NAME1 || data[i].name == NAME2
|| data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) {
expect(data[i].appInfo.description.length).assertLarger(0); expect(data[i].appInfo.description.length).assertLarger(0);
expect(data[i].appInfo.icon.length).assertLarger(0); expect(data[i].appInfo.icon.length).assertLarger(0);
expect(data[i].appInfo.label.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0);
...@@ -708,38 +1301,6 @@ describe('ActsBundleManagerTest', function () { ...@@ -708,38 +1301,6 @@ describe('ActsBundleManagerTest', function () {
}) })
}) })
/**
* @tc.number getApplicationInfo_0700
* @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with two haps.
*/
it('getApplicationInfo_0700', 0, async function (done) {
await demo.getApplicationInfo(NAME2,
demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID, (error, datainfo) => {
if (error) {
console.info("getApplicationInfo error" + JSON.stringify(error));
expect(error).assertFail();
}
console.info("getApplicationInfo success" + JSON.stringify(datainfo));
expect(typeof datainfo).assertEqual(OBJECT);
expect(datainfo.name).assertEqual(NAME2);
expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.description).assertEqual(DESCRIPTION);
expect(datainfo.icon).assertEqual("$media:icon");
expect(datainfo.name).assertEqual(NAME2);
expect(datainfo.description).assertEqual(DESCRIPTION);
expect(datainfo.descriptionId >= 0).assertTrue();
expect(datainfo.icon).assertEqual("$media:icon");
expect(datainfo.iconId >= 0).assertTrue();
expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.labelId >= 0).assertTrue();
expect(datainfo.systemApp).assertEqual(true);
expect(datainfo.supportedModes).assertEqual(0);
done();
})
})
/** /**
* @tc.number getBundleInfos_0300 * @tc.number getBundleInfos_0300
* @tc.name BUNDLE::getBundleInfos * @tc.name BUNDLE::getBundleInfos
...@@ -751,7 +1312,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -751,7 +1312,7 @@ describe('ActsBundleManagerTest', function () {
expect(data[i].name.length).assertLarger(0); expect(data[i].name.length).assertLarger(0);
expect(data[i].appInfo.name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0);
if (data[i].name == NAME1 || data[i].name == NAME2 if (data[i].name == NAME1 || data[i].name == NAME2
|| data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) {
expect(data[i].appInfo.description.length).assertLarger(0); expect(data[i].appInfo.description.length).assertLarger(0);
expect(data[i].appInfo.icon.length).assertLarger(0); expect(data[i].appInfo.icon.length).assertLarger(0);
expect(data[i].appInfo.label.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0);
...@@ -773,7 +1334,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -773,7 +1334,7 @@ describe('ActsBundleManagerTest', function () {
expect(data[i].name.length).assertLarger(0); expect(data[i].name.length).assertLarger(0);
expect(data[i].appInfo.name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0);
if (data[i].name == NAME1 || data[i].name == NAME2 if (data[i].name == NAME1 || data[i].name == NAME2
|| data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) {
expect(data[i].appInfo.description.length).assertLarger(0); expect(data[i].appInfo.description.length).assertLarger(0);
expect(data[i].appInfo.icon.length).assertLarger(0); expect(data[i].appInfo.icon.length).assertLarger(0);
expect(data[i].appInfo.label.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0);
...@@ -795,7 +1356,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -795,7 +1356,7 @@ describe('ActsBundleManagerTest', function () {
expect(data[i].name.length).assertLarger(0); expect(data[i].name.length).assertLarger(0);
expect(data[i].appInfo.name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0);
if (data[i].name == NAME1 || data[i].name == NAME2 if (data[i].name == NAME1 || data[i].name == NAME2
|| data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) {
expect(data[i].appInfo.description.length).assertLarger(0); expect(data[i].appInfo.description.length).assertLarger(0);
expect(data[i].appInfo.icon.length).assertLarger(0); expect(data[i].appInfo.icon.length).assertLarger(0);
expect(data[i].appInfo.label.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0);
...@@ -809,202 +1370,82 @@ describe('ActsBundleManagerTest', function () { ...@@ -809,202 +1370,82 @@ describe('ActsBundleManagerTest', function () {
}) })
/** /**
* @tc.number getApplicationInfo_0300 * @tc.number queryAbilityByWant_0100
* @tc.name BUNDLE::getApplicationInfo * @tc.name BUNDLE::queryAbilityByWant
* @tc.desc Test getApplicationInfo interfaces with three haps. * @tc.desc Test queryAbilityByWant interfaces with none hap. (by promise)
*/
it('getApplicationInfo_0300', 0, async function (done) {
demo.getApplicationInfo(NAME3, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION,
demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES).then(datainfo => {
expect(datainfo.name).assertEqual(NAME3);
expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.description).assertEqual(DESCRIPTION);
expect(datainfo.icon).assertEqual("$media:icon");
expect(datainfo.name).assertEqual(NAME3);
expect(datainfo.description).assertEqual(DESCRIPTION);
expect(datainfo.descriptionId >= 0).assertTrue();
expect(datainfo.icon).assertEqual("$media:icon");
expect(datainfo.iconId >= 0).assertTrue();
expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.labelId >= 0).assertTrue();
expect(datainfo.systemApp).assertEqual(true);
expect(datainfo.supportedModes).assertEqual(0);
});
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.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with error hap.
*/
it('getApplicationInfo_0400', 0, async function (done) {
demo.getApplicationInfo(ERROR, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION,
USERID).then(datainfo => {
checkgetApplicationInfoe(datainfo);
}).catch(err => {
console.info("getApplicationInfo err" + JSON.stringify(err));
expect(err).assertEqual(1);
done();
});
})
function checkgetApplicationInfoe(datainfo) {
console.info("getApplicationInfo success" + JSON.stringify(datainfo));
expect(datainfo).assertFail();
done();
}
/**
* @tc.number getApplicationInfo_0900
* @tc.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with error hap.
*/
it('getApplicationInfo_0900', 0, async function (done) {
demo.getApplicationInfo(ERROR, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION,
USERID, (error, datainfo) => {
if (error) {
console.info("getApplicationInfo fail" + JSON.stringify(error));
expect(error).assertEqual(1);
done();
return;
}
console.info("getApplicationInfo success" + JSON.stringify(datainfo));
expect(datainfo).assertFail();
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 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.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with none hap.
*/
it('getApplicationInfo_0500', 0, async function (done) {
demo.getApplicationInfo('', demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION,
USERID, (error, datainfo) => {
if (error) {
console.info("getApplicationInfo err" + JSON.stringify(error));
expect(error).assertEqual(1);
done();
return;
}
console.info("getApplicationInfo success" + JSON.stringify(datainfo));
expect(datainfo).assertFail();
done();
})
})
/**
* @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.name BUNDLE::getApplicationInfo
* @tc.desc Test getApplicationInfo interfaces with none hap.
*/ */
it('getApplicationInfo_1000', 0, async function (done) { it('queryAbilityByWant_0100', 0, async function (done) {
demo.getApplicationInfo('', demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, await demo.queryAbilityByWant(
USERID, (error, datainfo) => { {
if (error) { "bundleName": "com.example.myapplication1",
console.info("getApplicationInfo fail" + JSON.stringify(error)); "abilityName": "com.example.myapplication1.MainAbility",
expect(error).assertEqual(1); }, demo.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION |
done(); demo.BundleFlag.GET_ABILITY_INFO_WITH_PERMISSION |
return; demo.BundleFlag.GET_ABILITY_INFO_WITH_METADATA,
USERID).then(data => {
expect(data.length).assertLarger(0);
for (let i = 0, len = data.length; i < len; i++) {
let datainfo = data[i];
console.info("queryAbilityByWant_0100 success:" + JSON.stringify(datainfo));
expect(datainfo.name).assertEqual("com.example.myapplication1.MainAbility");
expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.description).assertEqual(DESCRIPTION);
expect(datainfo.icon).assertEqual("$media:icon");
expect(datainfo.moduleName).assertEqual("entry");
expect(datainfo.bundleName).assertEqual(NAME1);
expect(datainfo.type).assertEqual(demo.AbilityType.PAGE);
expect(datainfo.subType).assertEqual(demo.AbilitySubType.UNSPECIFIED);
expect(datainfo.orientation).assertEqual(demo.DisplayOrientation.UNSPECIFIED);
expect(datainfo.launchMode).assertEqual(demo.LaunchMode.STANDARD);
expect(datainfo.permissions[0]).assertEqual("com.permission.BMS_PERMISSION_CAMERA");
expect(datainfo.applicationInfo.name).assertEqual(NAME1);
expect(datainfo.applicationInfo.description).assertEqual(DESCRIPTION);
expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue();
expect(datainfo.applicationInfo.icon).assertEqual("$media:icon");
expect(datainfo.applicationInfo.iconId >= 0).assertTrue();
expect(datainfo.applicationInfo.label).assertEqual("$string:app_name");
expect(datainfo.applicationInfo.labelId >= 0).assertTrue();
expect(datainfo.applicationInfo.systemApp).assertEqual(true);
expect(datainfo.applicationInfo.supportedModes).assertEqual(0);
expect(datainfo.applicationInfo.enabled).assertEqual(true);
expect(datainfo.metaData.length).assertLarger(0);
for (let j = 0; j < datainfo.applicationInfo.moduleInfos; j++) {
expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry");
expect(datainfo.applicationInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1);
} }
console.info("getApplicationInfo success" + JSON.stringify(datainfo)); }
expect(datainfo).assertFail(); done();
done(); }).catch(err => {
}); console.info("queryAbilityByWant_0100 err" + JSON.stringify(err));
expect(err).assertFail();
done();
})
}) })
/** /**
* @tc.number queryAbilityByWant_0100 * @tc.number queryAbilityByWant_0200
* @tc.name BUNDLE::queryAbilityByWant * @tc.name BUNDLE::queryAbilityByWant
* @tc.desc Test queryAbilityByWant interfaces with none hap. * @tc.desc Test queryAbilityByWant interfaces with none hap. (by callback)
*/ */
it('queryAbilityByWant_0100', 0, async function (done) { it('queryAbilityByWant_0200', 0, async function (done) {
await demo.queryAbilityByWant( await demo.queryAbilityByWant(
{ {
"bundleName": "com.example.myapplication1", "bundleName": "com.example.myapplication1",
"abilityName": "com.example.myapplication1.MainAbility", "abilityName": "com.example.myapplication1.MainAbility",
}, demo.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION | }, demo.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION |
demo.BundleFlag.GET_ABILITY_INFO_WITH_PERMISSION | demo.BundleFlag.GET_ABILITY_INFO_WITH_PERMISSION |
demo.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, demo.BundleFlag.GET_ABILITY_INFO_WITH_METADATA,
USERID).then(data => { USERID, (error, data) => {
if (err) {
console.info("queryAbilityByWant_0200 err" + JSON.stringify(err));
expect(err).assertFail();
done();
return;
}
expect(data.length).assertLarger(0); expect(data.length).assertLarger(0);
for (let i = 0, len = data.length; i < len; i++) { for (let i = 0, len = data.length; i < len; i++) {
let datainfo = data[i]; let datainfo = data[i];
console.info("queryAbilityByWant_0200 success:" + JSON.stringify(datainfo));
expect(datainfo.name).assertEqual("com.example.myapplication1.MainAbility"); expect(datainfo.name).assertEqual("com.example.myapplication1.MainAbility");
expect(datainfo.label).assertEqual("$string:app_name"); expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.description).assertEqual(DESCRIPTION); expect(datainfo.description).assertEqual(DESCRIPTION);
...@@ -1033,18 +1474,15 @@ describe('ActsBundleManagerTest', function () { ...@@ -1033,18 +1474,15 @@ describe('ActsBundleManagerTest', function () {
} }
} }
done(); done();
}).catch(err => {
expect(err).assertFail();
done();
}) })
}) })
/** /**
* @tc.number queryAbilityByWant_0200 * @tc.number queryAbilityByWant_0300
* @tc.name BUNDLE::queryAbilityByWant * @tc.name BUNDLE::queryAbilityByWant
* @tc.desc Test queryAbilityByWant interfaces with two haps. * @tc.desc Test queryAbilityByWant interfaces with two haps. (by promise)
*/ */
it('queryAbilityByWant_0200', 0, async function (done) { it('queryAbilityByWant_0300', 0, async function (done) {
let data = await demo.queryAbilityByWant( let data = await demo.queryAbilityByWant(
{ {
"bundleName": "com.example.myapplication2", "bundleName": "com.example.myapplication2",
...@@ -1053,6 +1491,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -1053,6 +1491,7 @@ describe('ActsBundleManagerTest', function () {
expect(data.length).assertLarger(0); expect(data.length).assertLarger(0);
for (let i = 0, len = data.length; i < len; i++) { for (let i = 0, len = data.length; i < len; i++) {
let datainfo = data[i]; let datainfo = data[i];
console.info("queryAbilityByWant_0300 success:" + JSON.stringify(datainfo));
expect(datainfo.name.length).assertLarger(0); expect(datainfo.name.length).assertLarger(0);
expect(datainfo.label).assertEqual("$string:app_name"); expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.description).assertEqual(DESCRIPTION); expect(datainfo.description).assertEqual(DESCRIPTION);
...@@ -1080,238 +1519,243 @@ describe('ActsBundleManagerTest', function () { ...@@ -1080,238 +1519,243 @@ describe('ActsBundleManagerTest', function () {
}) })
/** /**
* @tc.number queryAbilityByWant_0300 * @tc.number queryAbilityByWant_0400
* @tc.name BUNDLE::queryAbilityByWant * @tc.name BUNDLE::queryAbilityByWant
* @tc.desc Test queryAbilityByWant interfaces with three haps. * @tc.desc Test queryAbilityByWant interfaces with two haps. (by callback)
*/ */
it('queryAbilityByWant_0300', 0, async function (done) { it('queryAbilityByWant_0400', 0, async function (done) {
await demo.queryAbilityByWant({ await demo.queryAbilityByWant(
entities: ['entity.system.home', 'entitiesentities'] {
}, 4, USERID).then(data => { "bundleName": "com.example.myapplication2",
let queryResultCount = 0; "abilityName": "com.example.myapplication1.MainAbility",
}, demo.BundleFlag.GET_ALL_APPLICATION_INFO, USERID, (error, data) => {
expect(data.length).assertLarger(0);
for (let i = 0, len = data.length; i < len; i++) { for (let i = 0, len = data.length; i < len; i++) {
let datainfo = data[i]; let datainfo = data[i];
if (datainfo.bundleName == NAME3) { console.info("queryAbilityByWant_0400 success:" + JSON.stringify(datainfo));
expect(datainfo.name).assertEqual("com.example.myapplication.MainAbility"); expect(datainfo.name.length).assertLarger(0);
expect(datainfo.label).assertEqual("$string:app_name"); expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.description).assertEqual(DESCRIPTION); expect(datainfo.description).assertEqual(DESCRIPTION);
expect(datainfo.icon).assertEqual("$media:icon"); expect(datainfo.icon).assertEqual("$media:icon");
expect(datainfo.moduleName).assertEqual("entry"); expect(datainfo.moduleName).assertEqual("entry");
expect(datainfo.bundleName).assertEqual(NAME3); expect(datainfo.bundleName).assertEqual(NAME2);
expect(datainfo.applicationInfo.name).assertEqual(NAME3); expect(datainfo.orientation).assertEqual(1);
expect(datainfo.applicationInfo.description).assertEqual(DESCRIPTION); expect(datainfo.launchMode).assertEqual(demo.LaunchMode.SINGLETON);
expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue(); expect(datainfo.applicationInfo.name).assertEqual(NAME2);
expect(datainfo.applicationInfo.icon).assertEqual("$media:icon"); expect(datainfo.applicationInfo.description).assertEqual(DESCRIPTION);
expect(datainfo.applicationInfo.iconId >= 0).assertTrue(); expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue();
expect(datainfo.applicationInfo.label).assertEqual("$string:app_name"); expect(datainfo.applicationInfo.icon).assertEqual("$media:icon");
expect(datainfo.applicationInfo.labelId >= 0).assertTrue(); expect(datainfo.applicationInfo.iconId >= 0).assertTrue();
expect(datainfo.applicationInfo.systemApp).assertEqual(true); expect(datainfo.applicationInfo.label).assertEqual("$string:app_name");
expect(datainfo.applicationInfo.supportedModes).assertEqual(0); expect(datainfo.applicationInfo.labelId >= 0).assertTrue();
expect(datainfo.orientation).assertEqual(2); expect(datainfo.applicationInfo.systemApp).assertEqual(true);
expect(datainfo.applicationInfo.enabled).assertEqual(true); expect(datainfo.applicationInfo.supportedModes).assertEqual(0);
for (let j = 0; j < datainfo.applicationInfo.moduleInfos; j++) { expect(datainfo.applicationInfo.enabled).assertEqual(true);
expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry"); for (let j = 0; j < datainfo.applicationInfo.moduleInfos; j++) {
} expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry");
queryResultCount++; expect(datainfo.applicationInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR2);
}
if (datainfo.bundleName == NAME4) {
expect(datainfo.name).assertEqual("com.example.myapplication.MainAbility");
expect(datainfo.bundleName).assertEqual(NAME4);
expect(datainfo.orientation).assertEqual(3);
queryResultCount++;
}
if (datainfo.bundleName == NAME5) {
expect(datainfo.name).assertEqual("com.example.myapplication.MainAbility");
expect(datainfo.bundleName).assertEqual(NAME5);
expect(datainfo.orientation).assertEqual(0);
queryResultCount++;
} }
} }
expect(queryResultCount).assertEqual(3);
done();
}).catch(err => {
expect(err).assertFail();
done(); done();
}) })
}) })
/** /**
* @tc.number queryAbilityByWant_0400 * @tc.number queryAbilityByWant_0500
* @tc.name BUNDLE::queryAbilityByWant * @tc.name BUNDLE::queryAbilityByWant
* @tc.desc Test queryAbilityByWant interfaces with one hap. * @tc.desc Test queryAbilityByWant interfaces with three haps. (by promise)
*/
it('queryAbilityByWant_0400', 0, async function (done) {
await demo.queryAbilityByWant(
{
"bundleName": "wrong name",
"abilityName": "com.example.myapplication1.MainAbility"
}, demo.BundleFlag.GET_BUNDLE_DEFAULT, USERID).then(datainfo => {
console.info("queryAbilityByWant_0400 dataInfo : ===========" + datainfo);
expect(datainfo).assertFail();
}).catch(err => {
console.info("queryAbilityByWant_0400 err : ===========" + err);
expect(err).assertEqual(1);
done();
})
})
/**
* @tc.number getBundleInfo_1300
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with LAUNCHER hap.
*/ */
it('getBundleInfo_1300', 0, async function (done) { it('queryAbilityByWant_0500', 0, async function (done) {
demo.getBundleInfo(LAUNCHER, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES).then(datainfo => { await demo.queryAbilityByWant({
console.info("getBundleInfo success:" + JSON.stringify(datainfo)); entities: ['entity.system.home', 'entitiesentities']
expect(datainfo.name).assertEqual(LAUNCHER); }, 4, USERID).then(data => {
expect(datainfo.vendor).assertEqual("ohos"); checkAbilityInfo0500(data)
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(); done();
}).catch(err => { }).catch(err => {
console.info("getBundleInfo fail:" + JSON.stringify(err)); console.info("queryAbilityByWant_0500 err" + JSON.stringify(err));
expect(err).assertFail(); expect(err).assertFail();
done(); done();
}) })
}) })
/** function checkAbilityInfo0500(data) {
* @tc.number getBundleInfo_1400 let queryResultCount = 0;
* @tc.name BUNDLEMGR::getBundleInfo for (let i = 0, len = data.length; i < len; i++) {
* @tc.desc Test getBundleInfo interface with current userId(by promise). let datainfo = data[i];
*/ console.info("queryAbilityByWant_0500 success:" + JSON.stringify(datainfo));
it('getBundleInfo_1400', 0, async function (done) { if (datainfo.bundleName == NAME3) {
let bundleOptions = { expect(datainfo.name).assertEqual("com.example.myapplication.MainAbility");
userId: USERID expect(datainfo.label).assertEqual("$string:app_name");
}; expect(datainfo.description).assertEqual(DESCRIPTION);
let dataInfo = await demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, bundleOptions); expect(datainfo.icon).assertEqual("$media:icon");
console.info("getBundleInfo_1400 start --------"); expect(datainfo.moduleName).assertEqual("entry");
expect(dataInfo.name).assertEqual(NAME1); expect(datainfo.bundleName).assertEqual(NAME3);
expect(dataInfo.vendor).assertEqual("example"); expect(datainfo.applicationInfo.name).assertEqual(NAME3);
expect(dataInfo.versionCode).assertEqual(VERSIONCODE1); expect(datainfo.applicationInfo.description).assertEqual(DESCRIPTION);
expect(dataInfo.versionName).assertLarger(0); expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue();
expect(dataInfo.entryModuleName).assertEqual("entry"); expect(datainfo.applicationInfo.icon).assertEqual("$media:icon");
expect(dataInfo.appInfo.name).assertEqual(NAME1); expect(datainfo.applicationInfo.iconId >= 0).assertTrue();
expect(dataInfo.appInfo.description).assertEqual(DESCRIPTION); expect(datainfo.applicationInfo.label).assertEqual("$string:app_name");
expect(dataInfo.appInfo.descriptionId >= 0).assertTrue(); expect(datainfo.applicationInfo.labelId >= 0).assertTrue();
expect(dataInfo.appInfo.icon).assertEqual("$media:icon"); expect(datainfo.applicationInfo.systemApp).assertEqual(true);
expect(dataInfo.appInfo.iconId >= 0).assertTrue(); expect(datainfo.applicationInfo.supportedModes).assertEqual(0);
expect(dataInfo.appInfo.label).assertEqual("$string:app_name"); expect(datainfo.orientation).assertEqual(2);
expect(dataInfo.appInfo.labelId >= 0).assertTrue(); expect(datainfo.applicationInfo.enabled).assertEqual(true);
expect(dataInfo.appInfo.systemApp).assertEqual(true); for (let j = 0; j < datainfo.applicationInfo.moduleInfos; j++) {
expect(dataInfo.appInfo.supportedModes).assertEqual(0); expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry");
expect(dataInfo.updateTime).assertLarger(0); }
expect(dataInfo.reqPermissions.length).assertEqual(0); queryResultCount++;
expect(dataInfo.reqPermissionDetails.length).assertEqual(0); }
expect(dataInfo.compatibleVersion).assertEqual(5); if (datainfo.bundleName == NAME4) {
expect(dataInfo.targetVersion).assertEqual(5); expect(datainfo.name).assertEqual("com.example.myapplication.MainAbility");
expect(dataInfo.isCompressNativeLibs).assertEqual(false); expect(datainfo.bundleName).assertEqual(NAME4);
for (let s = 0; s < dataInfo.hapModuleInfos; s++) { expect(datainfo.orientation).assertEqual(3);
expect(dataInfo.moduleInfos[s].name).assertEqual("com.example.myapplication1"); queryResultCount++;
expect(dataInfo.moduleInfos[s].moduleName).assertEqual("entry"); }
} if (datainfo.bundleName == NAME5) {
expect(dataInfo.entryModuleName).assertEqual("entry"); expect(datainfo.name).assertEqual("com.example.myapplication.MainAbility");
expect(dataInfo.isSilentInstallation.length).assertEqual(0); expect(datainfo.bundleName).assertEqual(NAME5);
expect(dataInfo.minCompatibleVersionCode).assertEqual(0); expect(datainfo.orientation).assertEqual(0);
expect(dataInfo.entryInstallationFree).assertEqual(false); queryResultCount++;
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); expect(queryResultCount).assertEqual(3);
console.info("getBundleInfo_1400 end --------"); }
done();
})
/** /**
* @tc.number getBundleInfo_1500 * @tc.number queryAbilityByWant_0600
* @tc.name BUNDLE::getBundleInfo * @tc.name BUNDLE::queryAbilityByWant
* @tc.desc Test getBundleInfo interface with current userId(by callback). * @tc.desc Test queryAbilityByWant interfaces with three haps. (by callback)
*/ */
it('getBundleInfo_1500', 0, async function (done) { it('queryAbilityByWant_0600', 0, async function (done) {
let bundleOptions = { await demo.queryAbilityByWant(
userId: USERID {
}; entities: ['entity.system.home', 'entitiesentities']
demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, bundleOptions, (err, dataInfo) => { }, 4, USERID, (err, data) => {
expect(dataInfo.name).assertEqual(NAME1); if (err) {
expect(dataInfo.vendor).assertEqual("example"); console.info("queryAbilityByWant_0600 err" + JSON.stringify(err));
expect(dataInfo.versionCode).assertEqual(VERSIONCODE1); expect(err).assertFail();
expect(dataInfo.versionName).assertLarger(0); done();
expect(dataInfo.entryModuleName).assertEqual("entry"); return;
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);
} }
checkAbilityInfo0600(data);
done(); done();
}); })
}) })
function checkAbilityInfo0600(data) {
let queryResultCount = 0;
for (let i = 0, len = data.length; i < len; i++) {
let datainfo = data[i];
console.info("queryAbilityByWant_0600 success:" + JSON.stringify(datainfo));
if (datainfo.bundleName == NAME3) {
expect(datainfo.name).assertEqual("com.example.myapplication.MainAbility");
expect(datainfo.label).assertEqual("$string:app_name");
expect(datainfo.description).assertEqual(DESCRIPTION);
expect(datainfo.icon).assertEqual("$media:icon");
expect(datainfo.moduleName).assertEqual("entry");
expect(datainfo.bundleName).assertEqual(NAME3);
expect(datainfo.applicationInfo.name).assertEqual(NAME3);
expect(datainfo.applicationInfo.description).assertEqual(DESCRIPTION);
expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue();
expect(datainfo.applicationInfo.icon).assertEqual("$media:icon");
expect(datainfo.applicationInfo.iconId >= 0).assertTrue();
expect(datainfo.applicationInfo.label).assertEqual("$string:app_name");
expect(datainfo.applicationInfo.labelId >= 0).assertTrue();
expect(datainfo.applicationInfo.systemApp).assertEqual(true);
expect(datainfo.applicationInfo.supportedModes).assertEqual(0);
expect(datainfo.orientation).assertEqual(2);
expect(datainfo.applicationInfo.enabled).assertEqual(true);
for (let j = 0; j < datainfo.applicationInfo.moduleInfos; j++) {
expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry");
}
queryResultCount++;
}
if (datainfo.bundleName == NAME4) {
expect(datainfo.name).assertEqual("com.example.myapplication.MainAbility");
expect(datainfo.bundleName).assertEqual(NAME4);
expect(datainfo.orientation).assertEqual(3);
queryResultCount++;
}
if (datainfo.bundleName == NAME5) {
expect(datainfo.name).assertEqual("com.example.myapplication.MainAbility");
expect(datainfo.bundleName).assertEqual(NAME5);
expect(datainfo.orientation).assertEqual(0);
queryResultCount++;
}
}
expect(queryResultCount).assertEqual(3);
}
/** /**
* @tc.number getBundleInfo_1600 * @tc.number queryAbilityByWant_0700
* @tc.name BUNDLEMGR::getBundleInfo * @tc.name BUNDLE::queryAbilityByWant
* @tc.desc Test getBundleInfo interface with other userId(by promise). * @tc.desc Test queryAbilityByWant interfaces with one hap. (by promise)
*/ */
it('getBundleInfo_1600', 0, async function (done) { it('queryAbilityByWant_0700', 0, async function (done) {
demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, { await demo.queryAbilityByWant(
userId: 1 {
}).then(data => { "bundleName": "wrong name",
expect().assertFail(); "abilityName": "com.example.myapplication1.MainAbility"
}, demo.BundleFlag.GET_BUNDLE_DEFAULT, USERID).then(datainfo => {
console.info("queryAbilityByWant_0700 dataInfo : ===========" + datainfo);
expect(datainfo).assertFail();
done(); done();
}).catch(err => { }).catch(err => {
console.info("queryAbilityByWant_0700 err : ===========" + err);
expect(err).assertEqual(1); expect(err).assertEqual(1);
done(); done();
}); })
}) })
/** /**
* @tc.number getBundleInfo_1700 * @tc.number queryAbilityByWant_0800
* @tc.name BUNDLE::getBundleInfo * @tc.name BUNDLE::queryAbilityByWant
* @tc.desc Test getBundleInfo interface with other userId(by callback). * @tc.desc Test queryAbilityByWant interfaces with one hap. (by callback)
*/ */
it('getBundleInfo_1700', 0, async function (done) { it('queryAbilityByWant_0800', 0, async function (done) {
demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, { await demo.queryAbilityByWant(
userId: 1 {
}, (err, dataInfo) => { "bundleName": "wrong name",
"abilityName": "com.example.myapplication1.MainAbility"
}, demo.BundleFlag.GET_BUNDLE_DEFAULT, USERID, (err, datainfo) => {
if (err) {
console.info("queryAbilityByWant_0800 err : ===========" + err);
expect(err).assertEqual(1);
done();
return;
}
console.info("queryAbilityByWant_0800 dataInfo : ===========" + datainfo);
expect(datainfo).assertFail();
done();
})
})
/**
* @tc.number queryAbilityByWant_0900
* @tc.name BUNDLE::queryAbilityByWant
* @tc.desc Test queryAbilityByWant interfaces with system hap. (by callback)
*/
it('queryAbilityByWant_0900', 0, async function (done) {
await demo.queryAbilityByWant(
{
bundleName: "wrong name",
abilityName: "wrong name",
}, 0, USERID).then(datainfo => {
console.info("queryAbilityByWant_0900 dataInfo : ===========" + datainfo);
expect(datainfo.length).assertLarger(0);
done();
}).catch(err => {
console.info("queryAbilityByWant_0900 err : ===========" + err);
expect(err).assertEqual(1); expect(err).assertEqual(1);
expect(dataInfo).assertEqual(undefined);
done(); done();
}); })
}) })
/** /**
* @tc.number queryAbilityByWant_1000 * @tc.number queryAbilityByWant_1000
* @tc.name BUNDLE::queryAbilityByWant * @tc.name BUNDLE::queryAbilityByWant
* @tc.desc Test queryAbilityByWant interfaces with system hap. * @tc.desc Test queryAbilityByWant interfaces with system hap. (by callback)
*/ */
it('queryAbilityByWant_1000', 0, async function (done) { it('queryAbilityByWant_1000', 0, async function (done) {
demo.queryAbilityByWant( demo.queryAbilityByWant(
...@@ -1319,7 +1763,10 @@ describe('ActsBundleManagerTest', function () { ...@@ -1319,7 +1763,10 @@ describe('ActsBundleManagerTest', function () {
bundleName: "wrong name", bundleName: "wrong name",
abilityName: "wrong name", abilityName: "wrong name",
}, 0, USERID, OnReceiveEvent); }, 0, USERID, OnReceiveEvent);
function OnReceiveEvent(err, datainfo) { function OnReceiveEvent(err, datainfo) {
console.info("queryAbilityByWant_1000 err : ===========" + err);
console.info("queryAbilityByWant_1000 dataInfo : ===========" + datainfo);
expect(err).assertEqual(1); expect(err).assertEqual(1);
expect(datainfo.length).assertLarger(0); expect(datainfo.length).assertLarger(0);
done(); done();
......
...@@ -316,6 +316,30 @@ describe('bluetoothhostTest', function() { ...@@ -316,6 +316,30 @@ describe('bluetoothhostTest', function() {
done(); done();
}) })
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GET_DEVICE_NAME_CALLBACK_0001
* @tc.name testGetDeviceName
* @tc.desc Test GetDeviceName api by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GET_DEVICE_NAME_CALLBACK_0001', 0, async function (done) {
console.info('[bluetooth_js] BLE get device name callback start');
await tryToEnableBt();
let promise = new Promise((resolve) => {
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.getDeviceName((err, data)=> {
console.info('[bluetooth_js] device name' + JSON.stringify(data))
expect(data).assertNull();
done();
})
resolve()
})
await promise.then(done)
done();
})
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_CALLBACK_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_CALLBACK_0001
* @tc.name testGetServices * @tc.name testGetServices
...@@ -381,7 +405,7 @@ describe('bluetoothhostTest', function() { ...@@ -381,7 +405,7 @@ describe('bluetoothhostTest', function() {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_GATT_READ_CHARA_VALUE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GATT_READ_CHARA_VALUE_0001', 0, async function (done) {
console.info('[bluetooth_js] readCharacteristicValue start'); console.info('[bluetooth_js] readCharacteristicValue promise start');
await tryToEnableBt(); await tryToEnableBt();
let promise = new Promise((resolve) => { let promise = new Promise((resolve) => {
let descriptors = []; let descriptors = [];
...@@ -402,12 +426,12 @@ describe('bluetoothhostTest', function() { ...@@ -402,12 +426,12 @@ describe('bluetoothhostTest', function() {
if (object != null) { if (object != null) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
} else { } else {
console.info('[bluetooth_js] readCharacValue data:' + JSON.stringify(data)); console.info('[bluetooth_js] readCharacValue promise data:' + JSON.stringify(data));
expect(null).assertFail(); expect(null).assertFail();
} }
done(); done();
}).catch(err => { }).catch(err => {
console.error(`bluetooth readCharacteristicValue has error: ${err}`); console.error(`bluetooth readCharacteristicValue promise has error: ${err}`);
expect(true).assertEqual(true); expect(true).assertEqual(true);
done(); done();
}); });
...@@ -417,6 +441,53 @@ describe('bluetoothhostTest', function() { ...@@ -417,6 +441,53 @@ describe('bluetoothhostTest', function() {
done(); done();
}) })
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_READ_CHARA_VALUE_0002
* @tc.name testReadCharacteristicValue
* @tc.desc Test ReadCharacteristicValue api by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GATT_READ_CHARA_VALUE_0002', 0, async function (done) {
console.info('[bluetooth_js] readCharacteristicValue callback start');
await tryToEnableBt();
let promise = new Promise((resolve) => {
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 32;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferCCC, descriptors:descriptors};
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.readCharacteristicValue(characteristic,(err, data)=> {
if (err) {
console.error(`bluetooth readCharacteristicValue callback has error: ${err}`);
expect(true).assertEqual(true);
done();
return;
}
if (object != null) {
expect(true).assertEqual(true);
} else {
console.info('[bluetooth_js] readCharacValue callback data:' + JSON.stringify(data));
expect(null).assertFail();
}
done();
})
resolve()
})
await promise.then(done)
done();
})
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0001
* @tc.name testReadDescriptorValue * @tc.name testReadDescriptorValue
...@@ -426,7 +497,7 @@ describe('bluetoothhostTest', function() { ...@@ -426,7 +497,7 @@ describe('bluetoothhostTest', function() {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0001', 0, async function (done) {
console.info('[bluetooth_js] readDescriptorValue start'); console.info('[bluetooth_js] readDescriptorValue promise start');
await tryToEnableBt(); await tryToEnableBt();
let promise = new Promise((resolve) => { let promise = new Promise((resolve) => {
let arrayBuffer = new ArrayBuffer(8); let arrayBuffer = new ArrayBuffer(8);
...@@ -439,12 +510,12 @@ describe('bluetoothhostTest', function() { ...@@ -439,12 +510,12 @@ describe('bluetoothhostTest', function() {
if (object != null) { if (object != null) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
} else { } else {
console.info('[bluetooth_js] BLEDescriptor data:' + JSON.stringify(object)); console.info('[bluetooth_js] BLEDescriptor promise data:' + JSON.stringify(object));
expect(null).assertFail(); expect(null).assertFail();
} }
done(); done();
}).catch(err => { }).catch(err => {
console.error(`bluetooth readDescriptorValue has error: ${err}`); console.error(`bluetooth readDescriptorValue promise has error: ${err}`);
expect(true).assertEqual(true); expect(true).assertEqual(true);
done(); done();
}); });
...@@ -454,6 +525,44 @@ describe('bluetoothhostTest', function() { ...@@ -454,6 +525,44 @@ describe('bluetoothhostTest', function() {
done(); done();
}) })
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0002
* @tc.name testReadDescriptorValue
* @tc.desc Test ReadDescriptorValue api by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GATT_READ_DESCRI_VALUE_0002', 0, async function (done) {
console.info('[bluetooth_js] readDescriptorValue callback start');
await tryToEnableBt();
let promise = new Promise((resolve) => {
let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.readDescriptorValue(descriptor,(err, data)=> {
if (err) {
console.error(`bluetooth readDescriptorValue callback has error: ${err}`);
expect(true).assertEqual(true);
done();
return;
}
if (object != null) {
expect(true).assertEqual(true);
} else {
console.info('[bluetooth_js] BLEDescriptor callback data:' + JSON.stringify(object));
expect(null).assertFail();
}
done();
})
resolve()
})
await promise.then(done)
done();
})
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_WRITE_CHARACT_VALUE_0001 * @tc.number SUB_COMMUNACATION_bluetooth_GATT_WRITE_CHARACT_VALUE_0001
......
...@@ -120,11 +120,15 @@ describe('rdbStoreTest', function () { ...@@ -120,11 +120,15 @@ describe('rdbStoreTest', function () {
*/ */
it('testRdbStore0004', 0, async function (done) { it('testRdbStore0004', 0, async function (done) {
console.log(TAG + "************* testRdbStore0004 start *************"); console.log(TAG + "************* testRdbStore0004 start *************");
let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 1);
let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 6);
storePromise.then(async (store) => { storePromise.then(async (store) => {
try { try {
await store.executeSql(CREATE_TABLE_TEST); await store.executeSql(CREATE_TABLE_TEST);
let deletePromise = dataRdb.deleteRdbStore("rdbstore.db")
deletePromise.then(()=>{
console.log(TAG + "deleteRdbStore promise done" + store);
expect(true).assertTrue();
})
} catch (e) { } catch (e) {
expect(null).assertFail(); expect(null).assertFail();
} }
...@@ -137,5 +141,91 @@ describe('rdbStoreTest', function () { ...@@ -137,5 +141,91 @@ describe('rdbStoreTest', function () {
console.log(TAG + "************* testRdbStore0004 end *************"); console.log(TAG + "************* testRdbStore0004 end *************");
}) })
/**
* @tc.name rdb store deleteRdbStore
* @tc.number SUB_DDM_AppDataFWK_JSRDB_RdbStore_0050
* @tc.desc rdb store deleteRdbStore
*/
it('testRdbStore0005', 0, async function (done) {
console.log(TAG + "************* testRdbStore0005 start *************");
let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 2);
storePromise.then(async (store) => {
try {
await store.executeSql(CREATE_TABLE_TEST);
let deletePromise = dataRdb.deleteRdbStore("rdbstore.db")
deletePromise.then(()=>{
console.log(TAG + "deleteRdbStore promise done" + store);
expect(true).assertTrue();
})
} catch (e) {
expect(null).assertFail();
}
}).catch((err) => {
expect(null).assertFail();
})
await storePromise
storePromise = null
done();
console.log(TAG + "************* testRdbStore0005 end *************");
})
/**
* @tc.name rdb store deleteRdbStore
* @tc.number SUB_DDM_AppDataFWK_JSRDB_RdbStore_0060
* @tc.desc rdb store deleteRdbStore
*/
// it('testRdbStore0006', 0, async function (done) {
// console.log(TAG + "************* testRdbStore0006 start *************");
//
// let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 4);
// storePromise.then(async (store) => {
// try {
// await store.executeSql(CREATE_TABLE_TEST);
// let deletePromise = dataRdb.deleteRdbStore("rdbstore.db")
// deletePromise.then(()=>{
// console.log(TAG + "deleteRdbStore promise done" + store);
// expect(true).assertTrue();
// })
// } catch (e) {
// expect(null).assertFail();
// }
// }).catch((err) => {
// expect(null).assertFail();
// })
// await storePromise
// storePromise = null
// done();
// console.log(TAG + "************* testRdbStore0006 end *************");
// })
/**
* @tc.name rdb store deleteRdbStore
* @tc.number SUB_DDM_AppDataFWK_JSRDB_RdbStore_0070
* @tc.desc rdb store deleteRdbStore
*/
it('testRdbStore0007', 0, async function (done) {
console.log(TAG + "************* testRdbStore0007 start *************");
let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 6);
storePromise.then(async (store) => {
try {
await store.executeSql(CREATE_TABLE_TEST);
let deletePromise = dataRdb.deleteRdbStore("rdbstore.db")
deletePromise.then(()=>{
console.log(TAG + "deleteRdbStore promise done" + store);
expect(true).assertTrue();
})
} catch (e) {
expect(null).assertFail();
}
}).catch((err) => {
expect(null).assertFail();
})
await storePromise
storePromise = null
done();
console.log(TAG + "************* testRdbStore0007 end *************");
})
console.log(TAG + "*************Unit Test End*************"); console.log(TAG + "*************Unit Test End*************");
}) })
\ No newline at end of file
...@@ -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_storage3');
// storage.removeStorageFromCache(perf, function (err) {
// if (err) {
// console.info("removeStorageFromCache callback interface test failed" + err);
// expect(null).assertFail();
// done();
// return
// }
// console.info("removeStorageFromCache callback interface test successfully.");
// expect(true).assertTrue();
// done();
// })
//
// })
/** /**
* @tc.name deleteStorageSync interface test * @tc.name deleteStorageSync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_Helper_0050 * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_Helper_0050
......
...@@ -17,6 +17,8 @@ import factory from '@ohos.data.distributedData'; ...@@ -17,6 +17,8 @@ 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;
...@@ -125,9 +127,9 @@ describe('KVManagerCallbackTest', function () { ...@@ -125,9 +127,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 +158,9 @@ describe('KVManagerCallbackTest', function () { ...@@ -156,9 +158,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 +190,9 @@ describe('KVManagerCallbackTest', function () { ...@@ -188,9 +190,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 +220,7 @@ describe('KVManagerCallbackTest', function () { ...@@ -218,7 +220,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 +250,9 @@ describe('KVManagerCallbackTest', function () { ...@@ -248,9 +250,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 +280,9 @@ describe('KVManagerCallbackTest', function () { ...@@ -278,9 +280,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 +312,7 @@ describe('KVManagerCallbackTest', function () { ...@@ -310,7 +312,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 +342,7 @@ describe('KVManagerCallbackTest', function () { ...@@ -340,7 +342,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 +372,7 @@ describe('KVManagerCallbackTest', function () { ...@@ -370,7 +372,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 +400,7 @@ describe('KVManagerCallbackTest', function () { ...@@ -398,7 +400,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,17 +430,18 @@ describe('KVManagerCallbackTest', function () { ...@@ -428,17 +430,18 @@ 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) {
if (err == undefined) { if (err == undefined) {
console.log('testKVManagerGetKVStore113 getKVStore success'); console.log('testKVManagerGetKVStore113 getKVStore success');
expect(null).assertFail(); expect((err == undefined) && (store != null)).assertTrue();
} else { } else {
console.log('testKVManagerGetKVStore113 getKVStore fail'); console.log('testKVManagerGetKVStore113 getKVStore fail');
expect(null).assertFail();
} }
done(); done();
}); });
...@@ -462,7 +465,7 @@ describe('KVManagerCallbackTest', function () { ...@@ -462,7 +465,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,15 +493,14 @@ describe('KVManagerCallbackTest', function () { ...@@ -490,15 +493,14 @@ 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) {
console.log('testKVManagerGetKVStore115 getKVStore success'); console.log('testKVManagerGetKVStore115 getKVStore success');
expect((err == undefined) && (store != null)).assertTrue(); expect(true).assertTrue();
kvStore = store;
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -520,15 +522,14 @@ describe('KVManagerCallbackTest', function () { ...@@ -520,15 +522,14 @@ 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) {
console.log('testKVManagerGetKVStore116 getKVStore success'); console.log('testKVManagerGetKVStore116 getKVStore success');
expect((err == undefined) && (store != null)).assertTrue(); expect(true).assertTrue();
kvStore = store;
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -550,15 +551,14 @@ describe('KVManagerCallbackTest', function () { ...@@ -550,15 +551,14 @@ 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) {
console.log('testKVManagerGetKVStore117 getKVStore success'); console.log('testKVManagerGetKVStore117 getKVStore success');
expect((err == undefined) && (store != null)).assertTrue(); expect(true).assertTrue();
kvStore = store;
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -580,15 +580,14 @@ describe('KVManagerCallbackTest', function () { ...@@ -580,15 +580,14 @@ 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) {
console.log('testKVManagerGetKVStore118 getKVStore success'); console.log('testKVManagerGetKVStore118 getKVStore success');
expect((err == undefined) && (store != null)).assertTrue(); expect(true).assertTrue();
kvStore = store;
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -610,15 +609,43 @@ describe('KVManagerCallbackTest', function () { ...@@ -610,15 +609,43 @@ 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) {
console.log('testKVManagerGetKVStore119 getKVStore success'); console.log('testKVManagerGetKVStore119 getKVStore success');
expect((err == undefined) && (store != null)).assertTrue(); expect(true).assertTrue();
kvStore = store; done();
});
} catch (e) {
console.log('testKVManagerGetKVStore119 getKVStore e ' + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1210
* @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(true).assertTrue();
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -878,4 +905,47 @@ describe('KVManagerCallbackTest', function () { ...@@ -878,4 +905,47 @@ 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 kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
console.log('testKVStorePut100 getKVStore success');
kvStore = store;
await kvStore.put(STORE_KEY, STORE_VALUE, function (err, data) {
if (err != undefined){
console.log('testKVStorePut100 put callback fail');
expect(null).assertFail();
} else {
console.log('testKVStorePut100 put callback success');
expect(true).assertTrue();
}
done();
});
});
} catch (e) {
console.log('testKVStorePut100 callback e ' + e);
expect(null).assertFail();
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('syncComplete', function (data) {
// console.log("testKVStoreOn101 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');
...@@ -305,7 +314,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -305,7 +314,7 @@ describe('KVManagerPromiseTest', function () {
}) })
/** /**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_PROMISE_1000 * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1000
* @tc.name [JS-API8]KVManager.GetKVStore. * @tc.name [JS-API8]KVManager.GetKVStore.
* @tc.desc Test Js Api KVManager.GetKVStore testcase 010 * @tc.desc Test Js Api KVManager.GetKVStore testcase 010
*/ */
...@@ -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');
...@@ -332,7 +341,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -332,7 +341,7 @@ describe('KVManagerPromiseTest', function () {
}) })
/** /**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_PROMISE_1100 * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1100
* @tc.name [JS-API8]KVManager.GetKVStore. * @tc.name [JS-API8]KVManager.GetKVStore.
* @tc.desc Test Js Api KVManager.GetKVStore testcase 011 * @tc.desc Test Js Api KVManager.GetKVStore testcase 011
*/ */
...@@ -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,
} }
...@@ -359,7 +368,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -359,7 +368,7 @@ describe('KVManagerPromiseTest', function () {
}) })
/** /**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_PROMISE_1200 * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1200
* @tc.name [JS-API8]KVManager.GetKVStore. * @tc.name [JS-API8]KVManager.GetKVStore.
* @tc.desc Test Js Api KVManager.GetKVStore testcase 012 * @tc.desc Test Js Api KVManager.GetKVStore testcase 012
*/ */
...@@ -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');
...@@ -386,7 +395,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -386,7 +395,7 @@ describe('KVManagerPromiseTest', function () {
}) })
/** /**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_PROMISE_1300 * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1300
* @tc.name [JS-API8]KVManager.GetKVStore. * @tc.name [JS-API8]KVManager.GetKVStore.
* @tc.desc Test Js Api KVManager.GetKVStore testcase 013 * @tc.desc Test Js Api KVManager.GetKVStore testcase 013
*/ */
...@@ -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) => {
...@@ -415,7 +424,7 @@ describe('KVManagerPromiseTest', function () { ...@@ -415,7 +424,7 @@ describe('KVManagerPromiseTest', function () {
}) })
/** /**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_PROMISE_1400 * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1400
* @tc.name [JS-API8]KVManager.GetKVStore. * @tc.name [JS-API8]KVManager.GetKVStore.
* @tc.desc Test Js Api KVManager.GetKVStore testcase 014 * @tc.desc Test Js Api KVManager.GetKVStore testcase 014
*/ */
...@@ -426,23 +435,22 @@ describe('KVManagerPromiseTest', function () { ...@@ -426,23 +435,22 @@ 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,
} }
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore014 getKVStore success'); console.log('testKVManagerGetKVStore014 getKVStore success');
kvStore = store; expect(null).assertFail();
expect(store != null).assertTrue();
}).catch((err) => { }).catch((err) => {
console.log('testKVManagerGetKVStore014 getKVStore err ' + err); console.log('testKVManagerGetKVStore014 getKVStore err ' + err);
expect(null).assertFail(); expect(true).assertTrue();
}); });
done(); done();
}) })
/** /**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_PROMISE_1500 * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1500
* @tc.name [JS-API8]KVManager.GetKVStore. * @tc.name [JS-API8]KVManager.GetKVStore.
* @tc.desc Test Js Api KVManager.GetKVStore testcase 015 * @tc.desc Test Js Api KVManager.GetKVStore testcase 015
*/ */
...@@ -453,23 +461,22 @@ describe('KVManagerPromiseTest', function () { ...@@ -453,23 +461,22 @@ 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,
} }
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore015 getKVStore success'); console.log('testKVManagerGetKVStore015 getKVStore success');
kvStore = store; expect(null).assertFail();
expect(store != null).assertTrue();
}).catch((err) => { }).catch((err) => {
console.log('testKVManagerGetKVStore015 getKVStore err ' + err); console.log('testKVManagerGetKVStore015 getKVStore err ' + err);
expect(null).assertFail(); expect(true).assertTrue();
}); });
done(); done();
}) })
/** /**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_PROMISE_1600 * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1600
* @tc.name [JS-API8]KVManager.GetKVStore. * @tc.name [JS-API8]KVManager.GetKVStore.
* @tc.desc Test Js Api KVManager.GetKVStore testcase 016 * @tc.desc Test Js Api KVManager.GetKVStore testcase 016
*/ */
...@@ -480,23 +487,22 @@ describe('KVManagerPromiseTest', function () { ...@@ -480,23 +487,22 @@ 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,
} }
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore016 getKVStore success'); console.log('testKVManagerGetKVStore016 getKVStore success');
kvStore = store; expect(null).assertFail();
expect(store != null).assertTrue();
}).catch((err) => { }).catch((err) => {
console.log('testKVManagerGetKVStore016 getKVStore err ' + err); console.log('testKVManagerGetKVStore016 getKVStore err ' + err);
expect(null).assertFail(); expect(true).assertTrue();
}); });
done(); done();
}) })
/** /**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_PROMISE_1700 * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1700
* @tc.name [JS-API8]KVManager.GetKVStore. * @tc.name [JS-API8]KVManager.GetKVStore.
* @tc.desc Test Js Api KVManager.GetKVStore testcase 017 * @tc.desc Test Js Api KVManager.GetKVStore testcase 017
*/ */
...@@ -507,23 +513,22 @@ describe('KVManagerPromiseTest', function () { ...@@ -507,23 +513,22 @@ 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,
} }
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore017 getKVStore success'); console.log('testKVManagerGetKVStore017 getKVStore success');
kvStore = store; expect(null).assertFail();
expect(store != null).assertTrue();
}).catch((err) => { }).catch((err) => {
console.log('testKVManagerGetKVStore017 getKVStore err ' + err); console.log('testKVManagerGetKVStore017 getKVStore err ' + err);
expect(null).assertFail(); expect(true).assertTrue();
}); });
done(); done();
}) })
/** /**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_PROMISE_1800 * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1800
* @tc.name [JS-API8]KVManager.GetKVStore. * @tc.name [JS-API8]KVManager.GetKVStore.
* @tc.desc Test Js Api KVManager.GetKVStore testcase 018 * @tc.desc Test Js Api KVManager.GetKVStore testcase 018
*/ */
...@@ -534,23 +539,22 @@ describe('KVManagerPromiseTest', function () { ...@@ -534,23 +539,22 @@ 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,
} }
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore018 getKVStore success'); console.log('testKVManagerGetKVStore018 getKVStore success');
kvStore = store; expect(null).assertFail();
expect(store != null).assertTrue();
}).catch((err) => { }).catch((err) => {
console.log('testKVManagerGetKVStore018 getKVStore err ' + err); console.log('testKVManagerGetKVStore018 getKVStore err ' + err);
expect(null).assertFail(); expect(true).assertTrue();
}); });
done(); done();
}) })
/** /**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_PROMISE_1900 * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1900
* @tc.name [JS-API8]KVManager.GetKVStore. * @tc.name [JS-API8]KVManager.GetKVStore.
* @tc.desc Test Js Api KVManager.GetKVStore testcase 019 * @tc.desc Test Js Api KVManager.GetKVStore testcase 019
*/ */
...@@ -561,17 +565,16 @@ describe('KVManagerPromiseTest', function () { ...@@ -561,17 +565,16 @@ 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,
} }
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore019 getKVStore success'); console.log('testKVManagerGetKVStore019 getKVStore success');
kvStore = store; expect(null).assertFail();
expect(store != null).assertTrue();
}).catch((err) => { }).catch((err) => {
console.log('testKVManagerGetKVStore019 getKVStore err ' + err); console.log('testKVManagerGetKVStore019 getKVStore err ' + err);
expect(null).assertFail(); expect(true).assertTrue();
}); });
done(); done();
}) })
...@@ -582,95 +585,18 @@ describe('KVManagerPromiseTest', function () { ...@@ -582,95 +585,18 @@ describe('KVManagerPromiseTest', function () {
* @tc.desc Test Js Api KVManager.CloseKVStore testcase 001 * @tc.desc Test Js Api KVManager.CloseKVStore testcase 001
*/ */
it('testKVManagerCloseKVStore001', 0, async function (done) { it('testKVManagerCloseKVStore001', 0, async function (done) {
console.log('testKVManagerCloseKVStore001');
await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.log('testKVManagerCloseKVStore001 getKVStore success');
kvStore = store;
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore).then(() => {
console.log('testKVManagerCloseKVStore001 closeKVStore success');
}).catch((err) => {
console.log('testKVManagerCloseKVStore001 closeKVStore err ' + err);
expect(null).assertFail();
});
}).catch((err) => {
console.log('testKVManagerCloseKVStore001 getKVStore err ' + err);
expect(null).assertFail();
});
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_CLOSEKVSTORE_0200
* @tc.name [JS-API8]KVManager.CloseKVStore.
* @tc.desc Test Js Api KVManager.CloseKVStore testcase 002
*/
it('testKVManagerCloseKVStore002', 0, async function (done) {
console.log('testKVManagerCloseKVStore002');
await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.log('testKVManagerCloseKVStore002 getKVStore success');
kvStore = store;
try {
await kvManager.closeKVStore(TEST_BUNDLE_NAME).then(() => {
console.log('testKVManagerCloseKVStore002 closeKVStore success');
expect(null).assertFail();
}).catch((err) => {
console.log('testKVManagerCloseKVStore002 closeKVStore err ' + err);
});
} catch (e) {
console.log('testKVManagerCloseKVStore002 closeKVStore e ' + e);
}
}).catch((err) => {
console.log('testKVManagerCloseKVStore002 getKVStore err ' + err);
expect(null).assertFail();
});
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_CLOSEKVSTORE_0300
* @tc.name [JS-API8]KVManager.CloseKVStore.
* @tc.desc Test Js Api KVManager.CloseKVStore testcase 003
*/
it('testKVManagerCloseKVStore003', 0, async function (done) {
console.log('testKVManagerCloseKVStore003');
await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.log('testKVManagerCloseKVStore003 getKVStore success');
kvStore = store;
try {
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
console.log('testKVManagerCloseKVStore003 closeKVStore success');
expect(null).assertFail();
}).catch((err) => {
console.log('testKVManagerCloseKVStore003 closeKVStore err ' + err);
});
} catch (e) {
console.log('testKVManagerCloseKVStore003 closeKVStore e ' + e);
}
}).catch((err) => {
console.log('testKVManagerCloseKVStore003 getKVStore err ' + err);
expect(null).assertFail();
});
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_CLOSEKVSTORE_0400
* @tc.name [JS-API8]KVManager.CloseKVStore.
* @tc.desc Test Js Api KVManager.CloseKVStore testcase 004
*/
it('testKVManagerCloseKVStore004', 0, async function (done) {
console.log('testKVManagerCloseKVStore004'); console.log('testKVManagerCloseKVStore004');
await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
console.log('testKVManagerCloseKVStore004 getKVStore success'); console.log('testKVManagerCloseKVStore001 getKVStore success');
kvStore = store; kvStore = store;
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore); await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore);
}); });
console.log('testKVManagerCloseKVStore104 closeKVStore redo.'); console.log('testKVManagerCloseKVStore001 closeKVStore redo.');
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore).then(() => { await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore).then(() => {
console.log('testKVManagerCloseKVStore004 closeKVStore twice'); console.log('testKVManagerCloseKVStore001 closeKVStore twice');
expect(null).assertFail(); expect(null).assertFail();
}).catch((err) => { }).catch((err) => {
console.log('testKVManagerCloseKVStore004 closeKVStore twice err ' + err); console.log('testKVManagerCloseKVStore001 closeKVStore twice err ' + err);
}); });
done(); done();
}) })
...@@ -682,61 +608,11 @@ describe('KVManagerPromiseTest', function () { ...@@ -682,61 +608,11 @@ describe('KVManagerPromiseTest', function () {
*/ */
it('testKVManagerDeleteKVStore001', 0, async function (done) { it('testKVManagerDeleteKVStore001', 0, async function (done) {
console.log('testKVManagerDeleteKVStore001'); console.log('testKVManagerDeleteKVStore001');
await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.log('testKVManagerDeleteKVStore001 getKVStore success');
kvStore = store;
await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
console.log('testKVManagerDeleteKVStore001 deleteKVStore success');
}).catch((err) => {
console.log('testKVManagerDeleteKVStore001 deleteKVStore err ' + err);
expect(null).assertFail();
});
}).catch((err) => {
console.log('testKVManagerDeleteKVStore001 getKVStore err ' + err);
expect(null).assertFail();
});
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_DELETEKVSTORE_0200
* @tc.name [JS-API8]KVManager.DeleteKVStore.
* @tc.desc Test Js Api KVManager.DeleteKVStore testcase 002
*/
it('testKVManagerDeleteKVStore002', 0, async function (done) {
console.log('testKVManagerDeleteKVStore002');
await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.log('testKVManagerDeleteKVStore002 getKVStore success');
kvStore = store;
try {
await kvManager.deleteKVStore(TEST_BUNDLE_NAME).then(() => {
console.log('testKVManagerDeleteKVStore002 deleteKVStore success');
expect(null).assertFail();
}).catch((err) => {
console.log('testKVManagerDeleteKVStore002 deleteKVStore err ' + err);
});
} catch (e) {
console.log('testKVManagerDeleteKVStore002 deleteKVStore e ' + e);
}
}).catch((err) => {
console.log('testKVManagerDeleteKVStore002 getKVStore err ' + err);
expect(null).assertFail();
});
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_DELETEKVSTORE_0300
* @tc.name [JS-API8]KVManager.DeleteKVStore.
* @tc.desc Test Js Api KVManager.DeleteKVStore testcase 003
*/
it('testKVManagerDeleteKVStore003', 0, async function (done) {
console.log('testKVManagerDeleteKVStore003');
await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => { await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
console.log('testKVManagerDeleteKVStore003 deleteKVStore success'); console.log('testKVManagerDeleteKVStore001 deleteKVStore success');
expect(null).assertFail(); expect(null).assertFail();
}).catch((err) => { }).catch((err) => {
console.log('testKVManagerDeleteKVStore003 deleteKVStore err ' + err); console.log('testKVManagerDeleteKVStore001 deleteKVStore err ' + err);
}); });
done(); done();
}) })
...@@ -915,4 +791,78 @@ describe('KVManagerPromiseTest', function () { ...@@ -915,4 +791,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();
})
}) })
......
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 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
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, it, expect} from 'hypium/index'; import {describe, it, expect} from "deccjsunit/index.ets";
import request from '@ohos.request'; import request from '@ohos.request';
export default function requestDownloadJsunit() { export default function requestDownloadJsunit() {
describe('requestDownloadTest', function () { describe('requestDownloadTest', function () {
let downloadConfig = { let downloadConfig = {
url: "www.baidu.com" url: "www.baidu.com"
}; };
let file = { let file = {
filename: 'text.txt', filename: 'text.txt',
name: 'text.txt', name: 'text.txt',
uri: 'C:\\Program Files', uri: 'C:\\Program Files',
type: 'text' type: 'text'
}; };
let uploadConfig = { let uploadConfig = {
url: "www.baidu.com", url: "www.baidu.com",
header: 'HTTP', header: 'HTTP',
method: 'post', method: 'post',
files: file, files: file,
data: 'jason/xml' data: 'jason/xml'
}; };
var receivedSize; var receivedSize;
var totalSize; var totalSize;
console.log("************* settings Test start*************"); console.log("************* settings Test start*************");
/** /**
* @tc.number requestDownload_test_001 * @tc.number requestDownload_test_001
* @tc.name Test The request DownloadTask * @tc.name Test The request DownloadTask
* @tc.desc Function test * @tc.desc Function test
*/ */
it('requestDownload_test_001', 0, async function (done) { it('requestDownload_test_001', 0, async function (done) {
try { try {
request.download(downloadConfig, (downloadTask) => { request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask)) console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.on('progress', (receivedSize, totalSize) => { downloadTask.on('progress', (receivedSize, totalSize) => {
console.log("downloadTask on_progress:" + JSON.stringify(receivedSize)); console.log("downloadTask on_progress:" + JSON.stringify(receivedSize));
console.log("downloadTask on_progress:" + JSON.stringify(totalSize)); console.log("downloadTask on_progress:" + JSON.stringify(totalSize));
this.receivedSize = receivedSize; this.receivedSize = receivedSize;
this.totalSize = totalSize; this.totalSize = totalSize;
expect(true).assertTrue(); expect(true).assertTrue();
}) })
}); });
} catch (exception) { } catch (exception) {
console.log("requestDownload_test_001 failed due to execute timeout 5s"); console.log("requestDownload_test_001 failed due to execute timeout 5s");
expect(true).assertTrue(); expect(true).assertTrue();
} }
done(); done();
}); });
/** /**
* @tc.number requestDownload_test_002 * @tc.number requestDownload_test_002
* @tc.name Test The request DownloadTask * @tc.name Test The request DownloadTask
* @tc.desc Function test * @tc.desc Function test
*/ */
it('requestDownload_test_002', 0, async function (done) { it('requestDownload_test_002', 0, async function (done) {
try { try {
request.download(downloadConfig, (downloadTask) => { request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask)) console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.off('progress', (receivedSize, totalSize) => { downloadTask.off('progress', (receivedSize, totalSize) => {
console.log("downloadTask off_progress:" + JSON.stringify(receivedSize)); console.log("downloadTask off_progress:" + JSON.stringify(receivedSize));
console.log("downloadTask off_progress:" + JSON.stringify(totalSize)); console.log("downloadTask off_progress:" + JSON.stringify(totalSize));
this.receivedSize = receivedSize; this.receivedSize = receivedSize;
this.totalSize = totalSize; this.totalSize = totalSize;
expect(true).assertTrue(); expect(true).assertTrue();
}) })
}); });
} catch (exception) { } catch (exception) {
console.log("requestDownload_test_002 failed due to execute timeout 5s"); console.log("requestDownload_test_002 failed due to execute timeout 5s");
expect(true).assertTrue(); expect(true).assertTrue();
} }
done(); done();
}); });
/** /**
* @tc.number requestDownload_test_003 * @tc.number requestDownload_test_003
* @tc.name Test The request DownloadTask * @tc.name Test The request DownloadTask
* @tc.desc Function test * @tc.desc Function test
*/ */
it('requestDownload_test_003', 0, async function (done) { it('requestDownload_test_003', 0, async function (done) {
try { try {
request.download(downloadConfig, (downloadTask) => { request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask)) console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.on('complete', (err) => { downloadTask.on('complete', (err) => {
console.log("downloadTask on_complete err:" + err); console.log("downloadTask on_complete err:" + err);
expect(true).assertTrue(); expect(true).assertTrue();
}); });
}); });
} catch (exception) { } catch (exception) {
console.log("requestDownload_test_003 failed due to execute timeout 5s"); console.log("requestDownload_test_003 failed due to execute timeout 5s");
expect(true).assertTrue(); expect(true).assertTrue();
} }
done(); done();
}); });
/** /**
* @tc.number requestDownload_test_004 * @tc.number requestDownload_test_004
* @tc.name Test The request DownloadTask * @tc.name Test The request DownloadTask
* @tc.desc Function test * @tc.desc Function test
*/ */
it('requestDownload_test_004', 0, async function (done) { it('requestDownload_test_004', 0, async function (done) {
try { try {
request.download(downloadConfig, (downloadTask) => { request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask)) console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.on('pause', (err) => { downloadTask.on('pause', (err) => {
console.log("downloadTask on_pause err:" + err); console.log("downloadTask on_pause err:" + err);
expect(true).assertTrue(); expect(true).assertTrue();
}); });
}); });
} catch (exception) { } catch (exception) {
console.log("requestDownload_test_004 failed due to execute timeout 5s"); console.log("requestDownload_test_004 failed due to execute timeout 5s");
expect(true).assertTrue(); expect(true).assertTrue();
} }
done(); done();
}); });
/** /**
* @tc.number requestDownload_test_005 * @tc.number requestDownload_test_005
* @tc.name Test The request DownloadTask * @tc.name Test The request DownloadTask
* @tc.desc Function test * @tc.desc Function test
*/ */
it('requestDownload_test_005', 0, async function (done) { it('requestDownload_test_005', 0, async function (done) {
try { try {
request.download(downloadConfig, (downloadTask) => { request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask)) console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.on('remove', (err) => { downloadTask.on('remove', (err) => {
console.log("downloadTask on_remove err:" + err); console.log("downloadTask on_remove err:" + err);
expect(true).assertTrue(); expect(true).assertTrue();
}); });
}); });
} catch (exception) { } catch (exception) {
console.log("requestDownload_test_005 failed due to execute timeout 5s"); console.log("requestDownload_test_005 failed due to execute timeout 5s");
expect(true).assertTrue(); expect(true).assertTrue();
} }
done(); done();
}); });
/** /**
* @tc.number requestDownload_test_006 * @tc.number requestDownload_test_006
* @tc.name Test The request DownloadTask * @tc.name Test The request DownloadTask
* @tc.desc Function test * @tc.desc Function test
*/ */
it('requestDownload_test_006', 0, async function (done) { it('requestDownload_test_006', 0, async function (done) {
try { try {
request.download(downloadConfig, (downloadTask) => { request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask)); console.log("downloadConfig result:" + JSON.stringify(downloadTask));
downloadTask.off('complete', (err) => { downloadTask.off('complete', (err) => {
console.log("downloadTask off_complete err:" + err); console.log("downloadTask off_complete err:" + err);
expect(true).assertTrue(); expect(true).assertTrue();
}); });
}); });
} catch (exception) { } catch (exception) {
console.log("requestDownload_test_006 failed due to execute timeout 5s"); console.log("requestDownload_test_006 failed due to execute timeout 5s");
expect(true).assertTrue(); expect(true).assertTrue();
} }
done(); done();
}); });
/** /**
* @tc.number requestDownload_test_007 * @tc.number requestDownload_test_007
* @tc.name Test The request DownloadTask * @tc.name Test The request DownloadTask
* @tc.desc Function test * @tc.desc Function test
*/ */
it('requestDownload_test_007', 0, async function (done) { it('requestDownload_test_007', 0, async function (done) {
try { try {
request.download(downloadConfig, (downloadTask) => { request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask)) console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.off('pause', (err) => { downloadTask.off('pause', (err) => {
console.log("downloadTask off_pause err:" + err); console.log("downloadTask off_pause err:" + err);
expect(true).assertTrue(); expect(true).assertTrue();
}); });
}); });
} catch (exception) { } catch (exception) {
console.log("requestDownload_test_007 failed due to execute timeout 5s"); console.log("requestDownload_test_007 failed due to execute timeout 5s");
expect(true).assertTrue(); expect(true).assertTrue();
} }
done(); done();
}); });
/** /**
* @tc.number requestDownload_test_007 * @tc.number requestDownload_test_007
* @tc.name Test The request DownloadTask * @tc.name Test The request DownloadTask
* @tc.desc Function test * @tc.desc Function test
*/ */
it('requestDownload_test_008', 0, async function (done) { it('requestDownload_test_008', 0, async function (done) {
try { try {
request.download(downloadConfig, (downloadTask) => { request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask)) console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.off('remove', (err) => { downloadTask.off('remove', (err) => {
console.log("downloadTask off_remove err:" + err); console.log("downloadTask off_remove err:" + err);
expect(true).assertTrue(); expect(true).assertTrue();
}); });
}); });
} catch (exception) { } catch (exception) {
console.log("requestDownload_test_008 failed due to execute timeout 5s"); console.log("requestDownload_test_008 failed due to execute timeout 5s");
expect(true).assertTrue(); expect(true).assertTrue();
} }
done(); done();
}); });
/** /**
* @tc.number requestDownload_test_009 * @tc.number requestDownload_test_009
* @tc.name Test The request DownloadTask * @tc.name Test The request DownloadTask
* @tc.desc Function test * @tc.desc Function test
*/ */
it('requestDownload_test_009', 0, async function (done) { it('requestDownload_test_009', 0, async function (done) {
try { try {
request.download(downloadConfig, (downloadTask) => { request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask)) console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.on('fail', (err) => { downloadTask.on('fail', (err) => {
console.log("downloadTask on_fail err:" + err); console.log("downloadTask on_fail err:" + err);
expect(true).assertTrue(); expect(true).assertTrue();
}); });
}); });
} catch (exception) { } catch (exception) {
console.log("requestDownload_test_009 failed due to execute timeout 5s"); console.log("requestDownload_test_009 failed due to execute timeout 5s");
expect(true).assertTrue(); expect(true).assertTrue();
} }
done(); done();
}); });
/** /**
* @tc.number requestDownload_test_010 * @tc.number requestDownload_test_010
* @tc.name Test The request DownloadTask * @tc.name Test The request DownloadTask
* @tc.desc Function test * @tc.desc Function test
*/ */
it('requestDownload_test_010', 0, async function (done) { it('requestDownload_test_010', 0, async function (done) {
try { try {
request.download(downloadConfig, (downloadTask) => { request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask)) console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.off('fail', (err) => { downloadTask.off('fail', (err) => {
console.log("downloadTask off_fail err:" + err); console.log("downloadTask off_fail err:" + err);
expect(true).assertTrue(); expect(true).assertTrue();
}); });
}); });
} catch (exception) { } catch (exception) {
console.log("requestDownload_test_010 failed due to execute timeout 5s"); console.log("requestDownload_test_010 failed due to execute timeout 5s");
expect(true).assertTrue(); expect(true).assertTrue();
} }
done(); done();
}); });
/** /**
* @tc.number requestDownload_test_011 * @tc.number requestDownload_test_011
* @tc.name Test The request DownloadTask * @tc.name Test The request DownloadTask
* @tc.desc Function test * @tc.desc Function test
*/ */
it('requestDownload_test_011', 0, async function (done) { it('requestDownload_test_011', 0, async function (done) {
try { try {
request.download(downloadConfig, (downloadTask) => { request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask)) console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.remove((err) => { downloadTask.remove((err) => {
console.log("downloadTask remove err:" + err); console.log("downloadTask remove err:" + err);
expect(true).assertTrue(); expect(true).assertTrue();
}); });
}); });
} catch (exception) { } catch (exception) {
console.log("requestDownload_test_011 failed due to execute timeout 5s"); console.log("requestDownload_test_011 failed due to execute timeout 5s");
expect(true).assertTrue(); expect(true).assertTrue();
} }
done(); done();
}); });
/** /**
* @tc.number requestDownload_test_012 * @tc.number requestDownload_test_012
* @tc.name Test The request DownloadTask * @tc.name Test The request DownloadTask
* @tc.desc Function test * @tc.desc Function test
*/ */
it('requestDownload_test_012', 0, async function (done) { it('requestDownload_test_012', 0, async function (done) {
try { try {
request.download(downloadConfig, (downloadTask) => { request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask)) console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.query((err) => { downloadTask.query((err) => {
console.log("downloadTask query err:" + err); console.log("downloadTask query err:" + err);
expect(true).assertTrue(); expect(true).assertTrue();
}); });
}); });
} catch (err) { } catch (err) {
console.log("requestDownload_test_012 invoke download error : " + JSON.stringify(err)); console.log("requestDownload_test_012 invoke download error : " + JSON.stringify(err));
expect(true).assertTrue(); expect(true).assertTrue();
} }
done(); done();
}); });
/** /**
* @tc.number requestDownload_test_013 * @tc.number requestDownload_test_013
* @tc.name Test The request DownloadTask * @tc.name Test The request DownloadTask
* @tc.desc Function test * @tc.desc Function test
*/ */
it('requestDownload_test_013', 0, async function (done) { it('requestDownload_test_013', 0, async function (done) {
try { try {
request.download(downloadConfig, (downloadTask) => { request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask)) console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.queryMimeType((err) => { downloadTask.queryMimeType((err) => {
console.log("downloadTask queryMimeType err:" + err); console.log("downloadTask queryMimeType err:" + err);
expect(true).assertTrue(); expect(true).assertTrue();
}); });
}); });
} catch (exception) { } catch (exception) {
console.log("requestDownload_test_013 failed due to execute timeout 5s"); console.log("requestDownload_test_013 failed due to execute timeout 5s");
expect(true).assertTrue(); expect(true).assertTrue();
} }
done(); done();
}); });
/** /**
* @tc.number requestDownload_test_007 * @tc.number requestDownload_test_007
* @tc.name Test The request UploadTask * @tc.name Test The request UploadTask
* @tc.desc Function test * @tc.desc Function test
*/ */
it('requestDownload_test_014', 0, async function (done) { it('requestDownload_test_014', 0, async function (done) {
try { try {
request.upload(uploadConfig, (uploadTask) => { request.upload(uploadConfig, (uploadTask) => {
console.log("downloadConfig result:" + JSON.stringify(uploadTask)) console.log("downloadConfig result:" + JSON.stringify(uploadTask))
expect(true).assertTrue(); expect(true).assertTrue();
}); });
} catch (exception) { } catch (exception) {
console.log("requestDownload_test_014 failed due to execute timeout 5s"); console.log("requestDownload_test_014 failed due to execute timeout 5s");
expect(true).assertTrue(); expect(true).assertTrue();
} }
done(); done();
}); });
}) /**
} * @tc.number requestDownload_test_015
* @tc.name testRequestDownloadTask_015
* @tc.desc Function test
*/
it('requestDownload_test_015', 0, async function (done) {
try {
request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.remove().then((result) => {
console.info('requestDownload_test_015 Download task removed result=' + result);
expect(true).assertTrue();
}).catch ((err) => {
console.log("requestDownload_test_015 downloadTask remove err:" + err);
expect(true).assertTrue();
});
});
} catch (exception) {
console.log("requestDownload_test_015 failed due to execute timeout 5s");
expect(true).assertTrue();
}
done();
});
/**
* @tc.number requestDownload_test_016
* @tc.name testRequestDownloadTask_016
* @tc.desc Function test
*/
it('requestDownload_test_016', 0, async function (done) {
try {
request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.query().then((downloadInfo) => {
console.info('requestDownload_test_016 Data:' + JSON.stringify(downloadInfo));
expect(true).assertTrue();
}) .catch((err) => {
console.log("downloadTask query err:" + err);
expect(true).assertTrue();
});
});
} catch (err) {
console.log("requestDownload_test_016 invoke download error : " + JSON.stringify(err));
expect(true).assertTrue();
}
done();
});
/**
* @tc.number requestDownload_test_017
* @tc.name testRequestDownloadTask_017
* @tc.desc Function test
*/
it('requestDownload_test_017', 0, async function (done) {
try {
request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.queryMimeType().then((data) => {
console.info('requestDownload_test_017. Data:' + JSON.stringify(data));
expect(true).assertTrue();
}).catch((err) => {
console.log("downloadTask queryMimeType err:" + err);
expect(true).assertTrue();
});
});
} catch (exception) {
console.log("requestDownload_test_017 failed due to execute timeout 5s");
expect(true).assertTrue();
}
done();
});
/**
* @tc.number requestDownload_test_018
* @tc.name testRequestDownloadTask_018
* @tc.desc Function test
*/
it('requestDownload_test_018', 0, async function (done) {
try {
request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.pause().then((data) => {
console.info('requestDownload_test_018. Data:' + JSON.stringify(data));
expect(true).assertTrue();
}).catch((err) => {
console.log("requestDownload_test_018 err:" + err);
expect(true).assertTrue();
});
});
} catch (exception) {
console.log("requestDownload_test_018 failed due to execute timeout 5s");
expect(true).assertTrue();
}
done();
});
/**
* @tc.number requestDownload_test_019
* @tc.name testRequestDownloadTask_019
* @tc.desc Function test
*/
it('requestDownload_test_019', 0, async function (done) {
try {
request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.pause((err, result)=>{
if(err) {
console.error('requestDownload_test_019 error:' + JSON.stringify(err));
expect(true).assertTrue();
} else {
console.info('requestDownload_test_019. result:' + JSON.stringify(result));
expect(true).assertTrue();
}
});
});
} catch (exception) {
console.log("requestDownload_test_019 failed due to execute timeout 5s");
expect(true).assertTrue();
}
done();
});
/**
* @tc.number requestDownload_test_020
* @tc.name testRequestDownloadTask_020
* @tc.desc Function test
*/
it('requestDownload_test_020', 0, async function (done) {
try {
request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.resume().then((data) => {
console.info('requestDownload_test_020. Data:' + JSON.stringify(data));
expect(true).assertTrue();
}).catch((err) => {
console.log("requestDownload_test_020 err:" + err);
expect(true).assertTrue();
});
});
} catch (exception) {
console.log("requestDownload_test_020 failed due to execute timeout 5s");
expect(true).assertTrue();
}
done();
});
/**
* @tc.number requestDownload_test_021
* @tc.name testRequestDownloadTask_021
* @tc.desc Function test
*/
it('requestDownload_test_021', 0, async function (done) {
try {
request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.resume((err, result)=>{
if(err) {
console.error('requestDownload_test_021 error:' + JSON.stringify(err));
expect(true).assertTrue();
} else {
console.info('requestDownload_test_021. result:' + JSON.stringify(result));
expect(true).assertTrue();
}
});
});
} catch (exception) {
console.log("requestDownload_test_021 failed due to execute timeout 5s");
expect(true).assertTrue();
}
done();
});
})
}
}
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 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
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, it, expect} from 'hypium/index'; import {describe, it, expect} from "deccjsunit/index.ets";
import request from '@ohos.request'; import request from '@ohos.request';
export default function requestJsunit() { export default function requestJsunit() {
describe('requestTest', function () { describe('requestTest', function () {
/** /**
* @tc.name: ohos.request_request_0001 * @tc.name: ohos.request_request_0001
* @tc.desc: NETWORK_MOBILE NETWORK_WIFI ERROR_CANNOT_RESUME ERROR_DEVICE_NOT_FOUND Values detection * @tc.desc: NETWORK_MOBILE NETWORK_WIFI ERROR_CANNOT_RESUME ERROR_DEVICE_NOT_FOUND Values detection
* *
* @tc.author: kangyuntao * @tc.author: kangyuntao
*/ */
it('request_test_0001', 0, async function (done) { it('request_test_0001', 0, async function (done) {
console.log("-----------------------Request_test_0001 is starting-----------------------"); console.log("-----------------------Request_test_0001 is starting-----------------------");
try { try {
request.NETWORK_MOBILE = 1; request.NETWORK_MOBILE = 1;
console.log("request_test_0001 request.NETWORK_MOBILE:" + request.NETWORK_MOBILE); console.log("request_test_0001 request.NETWORK_MOBILE:" + request.NETWORK_MOBILE);
expect(request.NETWORK_MOBILE).assertEqual(1); expect(request.NETWORK_MOBILE).assertEqual(1);
request.NETWORK_WIFI = 2; request.NETWORK_WIFI = 2;
console.log("request_test_0001 request.NETWORK_WIFI:" + request.NETWORK_WIFI); console.log("request_test_0001 request.NETWORK_WIFI:" + request.NETWORK_WIFI);
expect(request.NETWORK_WIFI).assertEqual(2); expect(request.NETWORK_WIFI).assertEqual(2);
request.ERROR_CANNOT_RESUME = 3; request.ERROR_CANNOT_RESUME = 3;
console.log("request_test_0001 request.ERROR_CANNOT_RESUME:" + request.ERROR_CANNOT_RESUME); console.log("request_test_0001 request.ERROR_CANNOT_RESUME:" + request.ERROR_CANNOT_RESUME);
expect(request.ERROR_CANNOT_RESUME).assertEqual(3); expect(request.ERROR_CANNOT_RESUME).assertEqual(3);
request.ERROR_DEVICE_NOT_FOUND = 4; request.ERROR_DEVICE_NOT_FOUND = 4;
console.log("request_test_0001 request.ERROR_DEVICE_NOT_FOUND:" + request.ERROR_DEVICE_NOT_FOUND); console.log("request_test_0001 request.ERROR_DEVICE_NOT_FOUND:" + request.ERROR_DEVICE_NOT_FOUND);
expect(request.ERROR_DEVICE_NOT_FOUND).assertEqual(4); expect(request.ERROR_DEVICE_NOT_FOUND).assertEqual(4);
} catch (err) { } catch (err) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
console.error("request_test_0001 error: " + err); console.error("request_test_0001 error: " + err);
} }
console.log("-----------------------Request_test_0001 end-----------------------"); console.log("-----------------------Request_test_0001 end-----------------------");
done(); done();
}); });
/** /**
* @tc.name: ohos.request_request_0002 * @tc.name: ohos.request_request_0002
* @tc.desc: ERROR_FILE_ALREADY_EXISTS ERROR_FILE_ERROR ERROR_HTTP_DATA_ERROR * @tc.desc: ERROR_FILE_ALREADY_EXISTS ERROR_FILE_ERROR ERROR_HTTP_DATA_ERROR
* ERROR_INSUFFICIENT_SPACE Values detection * ERROR_INSUFFICIENT_SPACE Values detection
* @tc.author: kangyuntao * @tc.author: kangyuntao
*/ */
it('request_test_0002', 0, async function (done) { it('request_test_0002', 0, async function (done) {
console.log("-----------------------Request_test_0002 is starting-----------------------"); console.log("-----------------------Request_test_0002 is starting-----------------------");
try { try {
request.ERROR_FILE_ALREADY_EXISTS = 5; request.ERROR_FILE_ALREADY_EXISTS = 5;
console.log("request_test_0002 request.ERROR_FILE_ALREADY_EXISTS:" + request.ERROR_FILE_ALREADY_EXISTS); console.log("request_test_0002 request.ERROR_FILE_ALREADY_EXISTS:" + request.ERROR_FILE_ALREADY_EXISTS);
expect(request.ERROR_FILE_ALREADY_EXISTS).assertEqual(5); expect(request.ERROR_FILE_ALREADY_EXISTS).assertEqual(5);
request.ERROR_FILE_ERROR = 6; request.ERROR_FILE_ERROR = 6;
console.log("request_test_0002 request.ERROR_FILE_ERROR:" + request.ERROR_FILE_ERROR); console.log("request_test_0002 request.ERROR_FILE_ERROR:" + request.ERROR_FILE_ERROR);
expect(request.ERROR_FILE_ERROR).assertEqual(6); expect(request.ERROR_FILE_ERROR).assertEqual(6);
request.ERROR_HTTP_DATA_ERROR = 7; request.ERROR_HTTP_DATA_ERROR = 7;
console.log("request_test_0002 request.ERROR_HTTP_DATA_ERROR:" + request.ERROR_HTTP_DATA_ERROR); console.log("request_test_0002 request.ERROR_HTTP_DATA_ERROR:" + request.ERROR_HTTP_DATA_ERROR);
expect(request.ERROR_HTTP_DATA_ERROR).assertEqual(7); expect(request.ERROR_HTTP_DATA_ERROR).assertEqual(7);
request.ERROR_INSUFFICIENT_SPACE = 8; request.ERROR_INSUFFICIENT_SPACE = 8;
console.log("request_test_0002 request.ERROR_INSUFFICIENT_SPACE:" + request.ERROR_INSUFFICIENT_SPACE); console.log("request_test_0002 request.ERROR_INSUFFICIENT_SPACE:" + request.ERROR_INSUFFICIENT_SPACE);
expect(request.ERROR_INSUFFICIENT_SPACE).assertEqual(8); expect(request.ERROR_INSUFFICIENT_SPACE).assertEqual(8);
} catch (err) { } catch (err) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
console.error("request_test_0002 error: " + err); console.error("request_test_0002 error: " + err);
} }
console.log("-----------------------Request_test_0002 end-----------------------"); console.log("-----------------------Request_test_0002 end-----------------------");
done(); done();
}); });
/** /**
* @tc.name: ohos.request_request_0003 * @tc.name: ohos.request_request_0003
* @tc.desc: ERROR_TOO_MANY_REDIRECTS ERROR_UNHANDLED_HTTP_CODE ERROR_UNHANDLED_HTTP_CODE * @tc.desc: ERROR_TOO_MANY_REDIRECTS ERROR_UNHANDLED_HTTP_CODE ERROR_UNHANDLED_HTTP_CODE
* PAUSED_QUEUED_FOR_WIFI Values detection * PAUSED_QUEUED_FOR_WIFI Values detection
* @tc.author: kangyuntao * @tc.author: kangyuntao
*/ */
it('request_test_0003', 0, async function (done) { it('request_test_0003', 0, async function (done) {
console.log("-----------------------Request_test_0003 is starting-----------------------"); console.log("-----------------------Request_test_0003 is starting-----------------------");
try { try {
request.ERROR_TOO_MANY_REDIRECTS = 9; request.ERROR_TOO_MANY_REDIRECTS = 9;
console.log("request_test_0003 request.ERROR_TOO_MANY_REDIRECTS:" + request.ERROR_TOO_MANY_REDIRECTS); console.log("request_test_0003 request.ERROR_TOO_MANY_REDIRECTS:" + request.ERROR_TOO_MANY_REDIRECTS);
expect(request.ERROR_TOO_MANY_REDIRECTS).assertEqual(9); expect(request.ERROR_TOO_MANY_REDIRECTS).assertEqual(9);
request.ERROR_UNHANDLED_HTTP_CODE = 10; request.ERROR_UNHANDLED_HTTP_CODE = 10;
console.log("request_test_0003 request.ERROR_UNHANDLED_HTTP_CODE:" + request.ERROR_UNHANDLED_HTTP_CODE); console.log("request_test_0003 request.ERROR_UNHANDLED_HTTP_CODE:" + request.ERROR_UNHANDLED_HTTP_CODE);
expect(request.ERROR_UNHANDLED_HTTP_CODE).assertEqual(10); expect(request.ERROR_UNHANDLED_HTTP_CODE).assertEqual(10);
request.ERROR_UNKNOWN = 11; request.ERROR_UNKNOWN = 11;
console.log("request_test_0003 request.ERROR_UNKNOWN:" + request.ERROR_UNKNOWN); console.log("request_test_0003 request.ERROR_UNKNOWN:" + request.ERROR_UNKNOWN);
expect(request.ERROR_UNKNOWN).assertEqual(11); expect(request.ERROR_UNKNOWN).assertEqual(11);
request.PAUSED_QUEUED_FOR_WIFI = 12; request.PAUSED_QUEUED_FOR_WIFI = 12;
console.log("request_test_0003 request.PAUSED_QUEUED_FOR_WIFI:" + request.PAUSED_QUEUED_FOR_WIFI); console.log("request_test_0003 request.PAUSED_QUEUED_FOR_WIFI:" + request.PAUSED_QUEUED_FOR_WIFI);
expect(request.PAUSED_QUEUED_FOR_WIFI).assertEqual(12); expect(request.PAUSED_QUEUED_FOR_WIFI).assertEqual(12);
} catch (err) { } catch (err) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
console.error("request_test_0003 error: " + err); console.error("request_test_0003 error: " + err);
} }
console.log("-----------------------Request_test_0003 end-----------------------"); console.log("-----------------------Request_test_0003 end-----------------------");
done(); done();
}); });
/** /**
* @tc.name: ohos.request_request_0004 * @tc.name: ohos.request_request_0004
* @tc.desc: PAUSED_UNKNOWN PAUSED_WAITING_FOR_NETWORK PAUSED_WAITING_TO_RETRY ESSION_FAILED Values detection * @tc.desc: PAUSED_UNKNOWN PAUSED_WAITING_FOR_NETWORK PAUSED_WAITING_TO_RETRY ESSION_FAILED Values detection
* @tc.author: kangyuntao * @tc.author: kangyuntao
*/ */
it('request_test_0004', 0, async function (done) { it('request_test_0004', 0, async function (done) {
console.log("-----------------------Request_test_0004 is starting-----------------------"); console.log("-----------------------Request_test_0004 is starting-----------------------");
try { try {
request.PAUSED_UNKNOWN = 13; request.PAUSED_UNKNOWN = 13;
console.log("request_test_0004 request.PAUSED_UNKNOWN:" + request.PAUSED_UNKNOWN); console.log("request_test_0004 request.PAUSED_UNKNOWN:" + request.PAUSED_UNKNOWN);
expect(request.PAUSED_UNKNOWN).assertEqual(13); expect(request.PAUSED_UNKNOWN).assertEqual(13);
request.PAUSED_WAITING_FOR_NETWORK = 14; request.PAUSED_WAITING_FOR_NETWORK = 14;
console.log("request_test_0004 request.PAUSED_WAITING_FOR_NETWORK:" + request.PAUSED_WAITING_FOR_NETWORK); console.log("request_test_0004 request.PAUSED_WAITING_FOR_NETWORK:" + request.PAUSED_WAITING_FOR_NETWORK);
expect(request.PAUSED_WAITING_FOR_NETWORK).assertEqual(14); expect(request.PAUSED_WAITING_FOR_NETWORK).assertEqual(14);
request.PAUSED_WAITING_TO_RETRY = 15; request.PAUSED_WAITING_TO_RETRY = 15;
console.log("request_test_0004 request.PAUSED_WAITING_TO_RETRY:" + request.PAUSED_WAITING_TO_RETRY); console.log("request_test_0004 request.PAUSED_WAITING_TO_RETRY:" + request.PAUSED_WAITING_TO_RETRY);
expect(request.PAUSED_WAITING_TO_RETRY).assertEqual(15); expect(request.PAUSED_WAITING_TO_RETRY).assertEqual(15);
request.SESSION_FAILED = 16; request.SESSION_FAILED = 16;
console.log("request_test_0004 request.SESSION_FAILED:" + request.SESSION_FAILED); console.log("request_test_0004 request.SESSION_FAILED:" + request.SESSION_FAILED);
expect(request.SESSION_FAILED).assertEqual(16); expect(request.SESSION_FAILED).assertEqual(16);
} catch (err) { } catch (err) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
console.error("request_test_0004 error: " + err); console.error("request_test_0004 error: " + err);
} }
console.log("-----------------------Request_test_0004 end-----------------------"); console.log("-----------------------Request_test_0004 end-----------------------");
done(); done();
}); });
/** /**
* @tc.name: ohos.request_request_0005 * @tc.name: ohos.request_request_0005
* @tc.desc: SESSION_PAUSED SESSION_PENDING SESSION_RUNNING SESSION_SUCCESSFUL Values detection * @tc.desc: SESSION_PAUSED SESSION_PENDING SESSION_RUNNING SESSION_SUCCESSFUL Values detection
* @tc.author: kangyuntao * @tc.author: kangyuntao
*/ */
it('request_test_0005', 0, async function (done) { it('request_test_0005', 0, async function (done) {
console.log("-----------------------Request_test_0005 is starting-----------------------"); console.log("-----------------------Request_test_0005 is starting-----------------------");
try { try {
request.SESSION_PAUSED = 17; request.SESSION_PAUSED = 17;
console.log("request_test_0004 request.SESSION_PAUSED:" + request.SESSION_PAUSED); console.log("request_test_0004 request.SESSION_PAUSED:" + request.SESSION_PAUSED);
expect(request.SESSION_PAUSED).assertEqual(17); expect(request.SESSION_PAUSED).assertEqual(17);
request.SESSION_PENDING = 18; request.SESSION_PENDING = 18;
console.log("request_test_0004 request.SESSION_PENDING:" + request.SESSION_PENDING); console.log("request_test_0004 request.SESSION_PENDING:" + request.SESSION_PENDING);
expect(request.SESSION_PENDING).assertEqual(18); expect(request.SESSION_PENDING).assertEqual(18);
request.SESSION_RUNNING = 19; request.SESSION_RUNNING = 19;
console.log("request_test_0004 request.SESSION_RUNNING:" + request.SESSION_RUNNING); console.log("request_test_0004 request.SESSION_RUNNING:" + request.SESSION_RUNNING);
expect(request.SESSION_RUNNING).assertEqual(19); expect(request.SESSION_RUNNING).assertEqual(19);
request.SESSION_SUCCESSFUL = 20; request.SESSION_SUCCESSFUL = 20;
console.log("request_test_0004 request.SESSION_SUCCESSFUL:" + request.SESSION_SUCCESSFUL); console.log("request_test_0004 request.SESSION_SUCCESSFUL:" + request.SESSION_SUCCESSFUL);
expect(request.SESSION_SUCCESSFUL).assertEqual(20); expect(request.SESSION_SUCCESSFUL).assertEqual(20);
} catch (err) { } catch (err) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
console.error("request_test_0005 error: " + err); console.error("request_test_0005 error: " + err);
} }
console.log("-----------------------Request_test_0005 end-----------------------"); console.log("-----------------------Request_test_0005 end-----------------------");
done(); done();
}); });
/** /**
* @tc.name: ohos.request_request_upload * @tc.name: ohos.request_request_upload
* @tc.desc: request_upload Method detection * @tc.desc: request_upload Method detection
* @tc.author: kangyuntao * @tc.author: kangyuntao
*/ */
it('request_upload_0006', 0, async function (done) { it('request_upload_0006', 0, async function (done) {
console.log("-----------------------Request_test_0006 is starting-----------------------"); console.log("-----------------------Request_test_0006 is starting-----------------------");
try { try {
console.log("request_upload_0006 getUploadConfig() " + getUploadConfig()); console.log("request_upload_0006 getUploadConfig() " + getUploadConfig());
request.upload(getUploadConfig(), (err, uploadTask) => { request.upload(getUploadConfig(), (err, uploadTask) => {
if (err) { if (err) {
expect().assertFail(); expect().assertFail();
} else { } else {
console.log("request_upload_0006 progress uploadTask =" + JSON.stringify(uploadTask)); console.log("request_upload_0006 progress uploadTask =" + JSON.stringify(uploadTask));
uploadTask.on('progress', function (data1, data2) { uploadTask.on('progress', function (data1, data2) {
console.log("request_upload_0006 on data1 =" + data1); console.log("request_upload_0006 on data1 =" + data1);
console.log("request_upload_0006 on data2 =" + data2); console.log("request_upload_0006 on data2 =" + data2);
}) })
uploadTask.off('progress', function (data1, data2) { uploadTask.off('progress', function (data1, data2) {
console.log("request_upload_0006 off data1 =" + data1); console.log("request_upload_0006 off data1 =" + data1);
console.log("request_upload_0006 off data2 =" + data2); console.log("request_upload_0006 off data2 =" + data2);
}) })
uploadTask.remove((err, data) => { uploadTask.remove((err, data) => {
console.log("request_upload_0006 remove =" + data); console.log("request_upload_0006 remove =" + data);
}) })
} }
}) })
} catch (err) { } catch (err) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
console.error("request_upload_0006 error: " + err); console.error("request_upload_0006 error: " + err);
} }
console.log("-----------------------request_upload_0006 end-----------------------"); console.log("-----------------------request_upload_0006 end-----------------------");
done(); done();
}) })
}) });
function getUploadConfig() { /**
let file = { * @tc.number request_upload_0007
filename: 'test', * @tc.name: test_request_upload_0007
name: 'test', * @tc.desc: request_upload Method detection
uri: 'internal://cache/test.txt', */
type: 'txt' it('request_upload_0007', 0, async function (done) {
} console.log("-----------------------request_upload_0007 is starting-----------------------");
let requestData = [{ try {
name: 'name', value: '123' console.log("request_upload_0007 getUploadConfig() " + getUploadConfig());
}] request.upload(getUploadConfig(), (err, uploadTask) => {
let fileArray = new Array(); if (err) {
fileArray[0] = file; expect().assertFail();
let headerHttp = { } else {
headers: 'http' console.log("request_upload_0007 progress uploadTask =" + JSON.stringify(uploadTask));
} uploadTask.on('headerReceive', function (data1, data2) {
let uploadConfig = { console.log("request_upload_0007 headerReceive on data1 =" + data1);
url: 'http://192.168.112.124/upload_test/', console.log("request_upload_0007 headerReceive on data2 =" + data2);
header: headerHttp, })
method: 'POST', uploadTask.off('headerReceive', function (data1, data2) {
files: fileArray, console.log("request_upload_0007 headerReceive off data1 =" + data1);
data: requestData console.log("request_upload_0007 headerReceive off data2 =" + data2);
} })
return uploadConfig uploadTask.remove().then((result) => {
} console.log("request_upload_0006 remove =" + result);
} }).catch((err) => {
console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
});
}
})
} catch (err) {
expect(true).assertEqual(true);
console.error("request_upload_0007 error: " + err);
}
console.log("-----------------------request_upload_0007 end-----------------------");
done();
})
});
function getUploadConfig() {
let file = {
filename: 'test',
name: 'test',
uri: 'internal://cache/test.txt',
type: 'txt'
}
let requestData = [{
name: 'name', value: '123'
}]
let fileArray = new Array();
fileArray[0] = file;
let headerHttp = {
headers: 'http'
}
let uploadConfig = {
url: 'http://192.168.112.124/upload_test/',
header: headerHttp,
method: 'POST',
files: fileArray,
data: requestData
}
return uploadConfig
}
}
...@@ -29,6 +29,7 @@ describe('audioManger', function () { ...@@ -29,6 +29,7 @@ describe('audioManger', function () {
var maxVol = 15; var maxVol = 15;
var lowVol = 5; var lowVol = 5;
var highVol = 14; var highVol = 14;
var newVol = 20;
var outOfRangeVol = 28; var outOfRangeVol = 28;
var longValue = '28374837458743875804735081439085918459801437584738967509184509813904850914375904790589104801843'; var longValue = '28374837458743875804735081439085918459801437584738967509184509813904850914375904790589104801843';
...@@ -882,6 +883,32 @@ describe('audioManger', function () { ...@@ -882,6 +883,32 @@ describe('audioManger', function () {
done(); done();
}) })
/* *
* @tc.number : SUB_AUDIO_MANAGER_SetVolume_030
* @tc.name : setVolume - Media - Promise - Change Ringtone vol
* @tc.desc : Setvol to 20
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_SetVolume_030', 0, async function (done) {
const promise = audioManager.setVolume(audio.AudioVolumeType.MEDIA,newVol);
promise.then(function () {
audioManager.setVolume(audio.AudioVolumeType.RINGTONE,maxVol);
audioManager.getVolume(audio.AudioVolumeType.MEDIA).then(function (data) {
if(data == lowVol){
console.info('AudioFrameworkTest: Media getVolume Promise: ENAME : PASS :' + data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Media getVolume Promise: ENAME : FAIL :' + data);
expect(false).assertTrue();
}
});
});
await promise;
done();
})
/* * /* *
* @tc.number : SUB_AUDIO_MANAGER_SetVolume_026 * @tc.number : SUB_AUDIO_MANAGER_SetVolume_026
* @tc.name : setVolume - Media - Callback - Change Ringtone vol * @tc.name : setVolume - Media - Callback - Change Ringtone vol
...@@ -946,6 +973,35 @@ describe('audioManger', function () { ...@@ -946,6 +973,35 @@ describe('audioManger', function () {
await promise; await promise;
done(); done();
}) })
/* *
* @tc.number : SUB_AUDIO_MANAGER_SetVolume_029
* @tc.name : setVolume - Ringtone - Promise - Change Media vol
* @tc.desc : Setvol to 20
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_SetVolume_029', 0, async function (done) {
const promise = audioManager.setVolume(audio.AudioVolumeType.RINGTONE,newVol);
promise.then(function () {
console.info('AudioFrameworkTest: Ringtone setVolume promise: ENAME: successful');
audioManager.setVolume(audio.AudioVolumeType.MEDIA,lowVol);
audioManager.getVolume(audio.AudioVolumeType.RINGTONE).then(function (data) {
if(data == highVol){
console.info('AudioFrameworkTest: Ringtone getVolume Promise: ENAME: PASS :' + data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Ringtone getVolume Promise: ENAME: FAIL :' + data);
expect(false).assertTrue();
}
});
});
await promise;
done();
})
/* * /* *
* @tc.number : SUB_AUDIO_MANAGER_SetVolume_028 * @tc.number : SUB_AUDIO_MANAGER_SetVolume_028
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent'; import { OperationType, WantAgentFlags } from '@ohos.wantagent';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
var WantAgenta; var WantAgenta;
......
...@@ -67,8 +67,7 @@ describe('bundlestate', function() { ...@@ -67,8 +67,7 @@ describe('bundlestate', function() {
console.info('queryAppUsagePriorityGroup_001 start'); console.info('queryAppUsagePriorityGroup_001 start');
bundlestate.queryAppUsagePriorityGroup((err, data) => { bundlestate.queryAppUsagePriorityGroup((err, data) => {
if(err) { if(err) {
console.info('queryAppUsagePriorityGroup_001 callback fail result = ' + JSON.stringify(err.code)); console.info('queryAppUsagePriorityGroup_001 callback fail result = ' + err);
expect(err.code).assertLarger(0);
} else { } else {
console.info('queryAppUsagePriorityGroup_001 callback success result = ' + JSON.stringify(data)); console.info('queryAppUsagePriorityGroup_001 callback success result = ' + JSON.stringify(data));
expect(true).assertEqual(true) expect(true).assertEqual(true)
...@@ -243,8 +242,15 @@ describe('bundlestate', function() { ...@@ -243,8 +242,15 @@ describe('bundlestate', function() {
*/ */
it('queryCurrentBundleActiveStates_041', 0, async function(done) { it('queryCurrentBundleActiveStates_041', 0, async function(done) {
console.info('queryCurrentBundleActiveStates_041 start'); console.info('queryCurrentBundleActiveStates_041 start');
let timer = onInit(); let time = { 'begin': 0, 'end': 0};
bundlestate.queryCurrentBundleActiveStates(timer.startTime, timer.endTime, (err, data) => { let initTime = function ()
{
var now = new Date().getTime();
time.begin = now - 86400000;
time.end = now;
};
initTime();
bundlestate.queryCurrentBundleActiveStates(time.begin, time.end, (err, data) => {
if(err) { if(err) {
console.info('queryCurrentBundleActiveStates_041 callback fail result = ' + err); console.info('queryCurrentBundleActiveStates_041 callback fail result = ' + err);
expect(data).assertFail(); expect(data).assertFail();
...@@ -301,6 +307,29 @@ describe('bundlestate', function() { ...@@ -301,6 +307,29 @@ describe('bundlestate', function() {
}); });
console.info('queryCurrentBundleActiveStates_043 end'); console.info('queryCurrentBundleActiveStates_043 end');
}) })
/*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0066
* @tc.name: queryCurrentBundleActiveStates_066.
* @tc.desc: Execute queryCurrentBundleActiveStates with promise.
* @tc.size: MEDIUM
* @tc.type: Function
* @tc.level: level 0
*/
it('queryCurrentBundleActiveStates_066', 0, async function(done) {
console.info('queryCurrentBundleActiveStates_066 start');
bundlestate.queryCurrentBundleActiveStates(true, false).then((res) => {
console.info('queryCurrentBundleActiveStates_066 promise success result = ' + JSON.stringify(res));
expect(res).assertFail();
}).catch((err) => {
console.info('queryCurrentBundleActiveStates_066 promise fail result = ' + JSON.stringify(err));
expect(err.code).assertLarger(0);
})
done();
console.info('queryCurrentBundleActiveStates_066 end');
})
/* /*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0044 * @tc.number: SUB_INTELLITV_JS_BUNDLE_0044
...@@ -325,6 +354,28 @@ describe('bundlestate', function() { ...@@ -325,6 +354,28 @@ describe('bundlestate', function() {
}); });
console.info('queryCurrentBundleActiveStates_044 end'); console.info('queryCurrentBundleActiveStates_044 end');
}) })
/*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0067
* @tc.name: queryCurrentBundleActiveStates_067.
* @tc.desc: Execute queryCurrentBundleActiveStates with promise.
* @tc.size: MEDIUM
* @tc.type: Function
* @tc.level: level 0
*/
it('queryCurrentBundleActiveStates_067', 0, async function(done) {
console.info('queryCurrentBundleActiveStates_067 start');
let timer = onInit();
bundlestate.queryCurrentBundleActiveStates(timer.startTime, '').then((data) => {
console.info('queryCurrentBundleActiveStates_067 promise success result = ' + JSON.stringify(data));
expect(data).assertFail();
}).catch((err) => {
console.info('queryCurrentBundleActiveStates_067 promise fail result = ' + JSON.stringify(err.code));
expect(err.code).assertLarger(0);
});
done();
console.info('queryCurrentBundleActiveStates_067 end');
})
/* /*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0045 * @tc.number: SUB_INTELLITV_JS_BUNDLE_0045
...@@ -348,6 +399,27 @@ describe('bundlestate', function() { ...@@ -348,6 +399,27 @@ describe('bundlestate', function() {
}); });
console.info('queryCurrentBundleActiveStates_045 end'); console.info('queryCurrentBundleActiveStates_045 end');
}) })
/*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0068
* @tc.name: queryCurrentBundleActiveStates_068.
* @tc.desc: Execute queryCurrentBundleActiveStates with promise.
* @tc.size: MEDIUM
* @tc.type: Function
* @tc.level: level 0
*/
it('queryCurrentBundleActiveStates_068', 0, async function(done) {
console.info('queryCurrentBundleActiveStates_068 start');
bundlestate.queryCurrentBundleActiveStates(true, -1).then((data) => {
console.info('queryCurrentBundleActiveStates_068 promise success result = ' + JSON.stringify(data));
expect(data).assertFail();
}).catch((err) => {
console.info('queryCurrentBundleActiveStates_068 promise fail result = ' + err.code);
expect(err.code).assertLarger(0);
});
done();
console.info('queryCurrentBundleActiveStates_068 end');
})
/* /*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0046 * @tc.number: SUB_INTELLITV_JS_BUNDLE_0046
...@@ -371,6 +443,27 @@ describe('bundlestate', function() { ...@@ -371,6 +443,27 @@ describe('bundlestate', function() {
}); });
console.info('queryCurrentBundleActiveStates_046 end'); console.info('queryCurrentBundleActiveStates_046 end');
}) })
/*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0069
* @tc.name: queryCurrentBundleActiveStates_069.
* @tc.desc: Execute queryCurrentBundleActiveStates with promise.
* @tc.size: MEDIUM
* @tc.type: Function
* @tc.level: level 0
*/
it('queryCurrentBundleActiveStates_069', 0, async function(done) {
console.info('queryCurrentBundleActiveStates_069 start');
bundlestate.queryCurrentBundleActiveStates(10001, 'timer.endTime').then((data) => {
console.info('queryCurrentBundleActiveStates_069 promise success result = ' + JSON.stringify(data));
expect(data).assertFail()
}).catch((err) => {
console.info('queryCurrentBundleActiveStates_069 promise fail result = ' + JSON.stringify(err.code));
expect(err.code).assertLarger(0);
});
done();
console.info('queryCurrentBundleActiveStates_069 end');
})
/* /*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0047 * @tc.number: SUB_INTELLITV_JS_BUNDLE_0047
...@@ -395,6 +488,28 @@ describe('bundlestate', function() { ...@@ -395,6 +488,28 @@ describe('bundlestate', function() {
}); });
console.info('queryCurrentBundleActiveStates_047 end'); console.info('queryCurrentBundleActiveStates_047 end');
}) })
/*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0070
* @tc.name: queryCurrentBundleActiveStates_070.
* @tc.desc: Execute queryCurrentBundleActiveStates with promise.
* @tc.size: MEDIUM
* @tc.type: Function
* @tc.level: level 0
*/
it('queryCurrentBundleActiveStates_070', 0, async function(done) {
console.info('queryCurrentBundleActiveStates_070 start');
let timer = onInit();
bundlestate.queryCurrentBundleActiveStates(timer.startTime, timer.startTime).then((data) => {
console.info('queryCurrentBundleActiveStates_070 promise success result = ' + JSON.stringify(data));
expect(data).assertFail();
}).catch((err) => {
console.info('queryCurrentBundleActiveStates_070 promise fail result = ' + JSON.stringify(err.code));
expect(err.code).assertLarger(0);
});
done();
console.info('queryCurrentBundleActiveStates_070 end');
})
/* /*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0048 * @tc.number: SUB_INTELLITV_JS_BUNDLE_0048
...@@ -419,6 +534,28 @@ describe('bundlestate', function() { ...@@ -419,6 +534,28 @@ describe('bundlestate', function() {
}); });
console.info('queryCurrentBundleActiveStates_048 end'); console.info('queryCurrentBundleActiveStates_048 end');
}) })
/*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0071
* @tc.name: queryCurrentBundleActiveStates_071.
* @tc.desc: Execute queryCurrentBundleActiveStates with promise.
* @tc.size: MEDIUM
* @tc.type: Function
* @tc.level: level 0
*/
it('queryCurrentBundleActiveStates_071', 0, async function(done) {
console.info('queryCurrentBundleActiveStates_071 start');
let timer = onInit();
bundlestate.queryCurrentBundleActiveStates(timer.endTime, timer.startTime).then((data) => {
console.info('queryCurrentBundleActiveStates_071 promise success result = ' + JSON.stringify(data));
expect(data).assertFail();
}).catch((err) => {
console.info('queryCurrentBundleActiveStates_071 promise fail result = ' + JSON.stringify(err.code));
expect(err.code).assertLarger(0);
});
done();
console.info('queryCurrentBundleActiveStates_071 end');
})
/* /*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0049 * @tc.number: SUB_INTELLITV_JS_BUNDLE_0049
...@@ -443,6 +580,28 @@ describe('bundlestate', function() { ...@@ -443,6 +580,28 @@ describe('bundlestate', function() {
}); });
console.info('queryCurrentBundleActiveStates_049 end'); console.info('queryCurrentBundleActiveStates_049 end');
}) })
/*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0072
* @tc.name: queryCurrentBundleActiveStates_072.
* @tc.desc: Execute queryCurrentBundleActiveStates with promise.
* @tc.size: MEDIUM
* @tc.type: Function
* @tc.level: level 0
*/
it('queryCurrentBundleActiveStates_072', 0, async function(done) {
console.info('queryCurrentBundleActiveStates_072 start');
let timer = onInit();
bundlestate.queryCurrentBundleActiveStates(3.145, timer.startTime).then((data) => {
console.info('queryCurrentBundleActiveStates_072 promise success result = ' + JSON.stringify(data));
expect(data).assertInstanceOf('Array');
}).catch((err) => {
console.info('queryCurrentBundleActiveStates_072 promise fail result = ' + JSON.stringify(err.code));
expect(err.code).assertLarger(0);
});
done();
console.info('queryCurrentBundleActiveStates_072 end');
})
/* /*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0050 * @tc.number: SUB_INTELLITV_JS_BUNDLE_0050
...@@ -467,6 +626,28 @@ describe('bundlestate', function() { ...@@ -467,6 +626,28 @@ describe('bundlestate', function() {
}); });
console.info('queryCurrentBundleActiveStates_050 end'); console.info('queryCurrentBundleActiveStates_050 end');
}) })
/*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0073
* @tc.name: queryCurrentBundleActiveStates_073.
* @tc.desc: Execute queryCurrentBundleActiveStates with promise.
* @tc.size: MEDIUM
* @tc.type: Function
* @tc.level: level 0
*/
it('queryCurrentBundleActiveStates_073', 0, async function(done) {
console.info('queryCurrentBundleActiveStates_073 start');
let timer = onInit();
bundlestate.queryCurrentBundleActiveStates('', '').then((data) => {
console.info('queryCurrentBundleActiveStates_073 promise success result = ' + JSON.stringify(data));
expect(data).assertFail();
}).catch((err) => {
console.info('queryCurrentBundleActiveStates_073 promise fail result = ' + JSON.stringify(err.code));
expect(err.code).assertLarger(0);
});
done();
console.info('queryCurrentBundleActiveStates_073 end');
})
/* /*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0051 * @tc.number: SUB_INTELLITV_JS_BUNDLE_0051
...@@ -491,6 +672,28 @@ describe('bundlestate', function() { ...@@ -491,6 +672,28 @@ describe('bundlestate', function() {
}); });
console.info('queryCurrentBundleActiveStates_051 end'); console.info('queryCurrentBundleActiveStates_051 end');
}) })
/*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0074
* @tc.name: queryCurrentBundleActiveStates_074.
* @tc.desc: Execute queryCurrentBundleActiveStates with promise.
* @tc.size: MEDIUM
* @tc.type: Function
* @tc.level: level 0
*/
it('queryCurrentBundleActiveStates_074', 0, async function(done) {
console.info('queryCurrentBundleActiveStates_074 start');
let timer = onInit();
bundlestate.queryCurrentBundleActiveStates(null, null).then((data) => {
console.info('queryCurrentBundleActiveStates_074 promise success result = ' + JSON.stringify(data));
expect(data).assertFail();
}).catch((err) => {
console.info('queryCurrentBundleActiveStates_074 promise fail result = ' + JSON.stringify(err.code));
expect(err.code).assertLarger(0);
});
done();
console.info('queryCurrentBundleActiveStates_074 end');
})
/* /*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0052 * @tc.number: SUB_INTELLITV_JS_BUNDLE_0052
...@@ -504,8 +707,7 @@ describe('bundlestate', function() { ...@@ -504,8 +707,7 @@ describe('bundlestate', function() {
console.info('isIdleState_052 start'); console.info('isIdleState_052 start');
bundlestate.isIdleState(bundleName, (err, res) => { bundlestate.isIdleState(bundleName, (err, res) => {
if(err) { if(err) {
console.info('isIdleState_052 callback fail result = ' + JSON.stringify(err.code)); console.info('isIdleState_052 callback fail result = ' + err);
expect(err.code).assertLarger(0);
} else { } else {
console.info('isIdleState_052 callback success result = ' + JSON.stringify(res)); console.info('isIdleState_052 callback success result = ' + JSON.stringify(res));
expect(res).assertTrue(); expect(res).assertTrue();
...@@ -528,8 +730,7 @@ describe('bundlestate', function() { ...@@ -528,8 +730,7 @@ describe('bundlestate', function() {
let bundleName02 = 'ohos.plrdtest.resourceschedule' let bundleName02 = 'ohos.plrdtest.resourceschedule'
bundlestate.isIdleState(bundleName02, (err, res) => { bundlestate.isIdleState(bundleName02, (err, res) => {
if(err) { if(err) {
console.info('isIdleState_053 callback fail result = ' + JSON.stringify(err.code)); console.info('isIdleState_053 callback fail result = ' + err);
expect(err.code).assertLarger(0);
} else { } else {
console.info('isIdleState_053 callback success result = ' + JSON.stringify(res)); console.info('isIdleState_053 callback success result = ' + JSON.stringify(res));
expect(res).assertInstanceOf('Boolean'); expect(res).assertInstanceOf('Boolean');
...@@ -605,6 +806,27 @@ describe('bundlestate', function() { ...@@ -605,6 +806,27 @@ describe('bundlestate', function() {
}); });
console.info('isIdleState_056 end'); console.info('isIdleState_056 end');
}) })
/*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0062
* @tc.name: isIdleState_062.
* @tc.desc: Execute isIdleState with Promise.
* @tc.size: MEDIUM
* @tc.type: Function
* @tc.level: level 0
*/
it('isIdleState_062', 0, async function(done) {
console.info('isIdleState_062 start');
bundlestate.isIdleState(123).then((res) => {
console.info('isIdleState_062 promise success result = ' + JSON.stringify(res));
expect(res).assertFail();
}).catch((err) => {
console.info('isIdleState_062 promise fail result = ' + JSON.stringify(err));
expect(err.code).assertLarger(0);
})
done();
console.info('isIdleState_062 end');
})
/* /*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0057 * @tc.number: SUB_INTELLITV_JS_BUNDLE_0057
...@@ -628,6 +850,27 @@ describe('bundlestate', function() { ...@@ -628,6 +850,27 @@ describe('bundlestate', function() {
}); });
console.info('isIdleState_057 end'); console.info('isIdleState_057 end');
}) })
/*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0063
* @tc.name: isIdleState_063.
* @tc.desc: Execute isIdleState with Promise.
* @tc.size: MEDIUM
* @tc.type: Function
* @tc.level: level 0
*/
it('isIdleState_063', 0, async function(done) {
console.info('isIdleState_063 start');
bundlestate.isIdleState(null).then((res) => {
console.info('isIdleState_063 promise success result = ' + JSON.stringify(res));
expect(res).assertFail();
}).catch((err) => {
console.info('isIdleState_063 promise fail result = ' + JSON.stringify(err));
expect(err.code).assertLarger(0);
})
done();
console.info('isIdleState_063 end');
})
/* /*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0058 * @tc.number: SUB_INTELLITV_JS_BUNDLE_0058
...@@ -674,6 +917,27 @@ describe('bundlestate', function() { ...@@ -674,6 +917,27 @@ describe('bundlestate', function() {
}); });
console.info('isIdleState_059 end'); console.info('isIdleState_059 end');
}) })
/*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0064
* @tc.name: isIdleState_064.
* @tc.desc: Execute isIdleState with Promise.
* @tc.size: MEDIUM
* @tc.type: Function
* @tc.level: level 0
*/
it('isIdleState_064', 0, async function(done) {
console.info('isIdleState_064 start');
bundlestate.isIdleState(false).then((res) => {
console.info('isIdleState_064 promise success result = ' + JSON.stringify(res));
expect(res).assertFail();
}).catch((err) => {
console.info('isIdleState_064 promise fail result = ' + JSON.stringify(err));
expect(err.code).assertLarger(0);
})
done();
console.info('isIdleState_064 end');
})
/* /*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0060 * @tc.number: SUB_INTELLITV_JS_BUNDLE_0060
...@@ -697,4 +961,47 @@ describe('bundlestate', function() { ...@@ -697,4 +961,47 @@ describe('bundlestate', function() {
}); });
console.info('isIdleState_060 end'); console.info('isIdleState_060 end');
}) })
/*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_0061
* @tc.name: isIdleState_061.
* @tc.desc: Execute isIdleState with Promise.
* @tc.size: MEDIUM
* @tc.type: Function
* @tc.level: level 0
*/
it('isIdleState_061', 0, async function(done) {
console.info('isIdleState_061 start');
bundlestate.isIdleState('').then((res) => {
console.info('isIdleState_061 promise success result = ' + JSON.stringify(res));
expect(res).assertFail();
}).catch((err) => {
console.info('isIdleState_061 promise fail result = ' + JSON.stringify(err));
expect(err.code).assertLarger(0);
})
done();
console.info('isIdleState_061 end');
})
/*
* @tc.number: SUB_INTELLITV_JS_BUNDLE_065
* @tc.name: isIdleState_065.
* @tc.desc: Execute isIdleState with Promise.
* @tc.size: MEDIUM
* @tc.type: Function
* @tc.level: level 0
*/
it('isIdleState_065', 0, async function(done) {
console.info('isIdleState_065 start');
bundlestate.isIdleState(true).then((res) => {
console.info('isIdleState_065 promise success result = ' + JSON.stringify(res));
expect(res).assertFail();
}).catch((err) => {
console.info('isIdleState_065 promise fail result = ' + JSON.stringify(err));
expect(err.code).assertLarger(0);
})
done();
console.info('isIdleState_065 end');
})
}) })
\ No newline at end of file
...@@ -1283,6 +1283,38 @@ describe('fileIOTest', function () { ...@@ -1283,6 +1283,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
...@@ -2373,6 +2405,25 @@ describe('fileIOTest', function () { ...@@ -2373,6 +2405,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
...@@ -3778,4 +3829,476 @@ describe('fileIOTest', function () { ...@@ -3778,4 +3829,476 @@ describe('fileIOTest', function () {
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
/**
* @tc.number SUB_STORAGE_FileIO_stat_async_000
* @tc.name fileio_test_stat_async_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 SUB_STORAGE_FileIO_stat_async_001
* @tc.name fileio_test_stat_async_001
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_001', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o777) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
expect((stat.mode & 0o777) == 0o777).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
});
});
/**
* @tc.number SUB_STORAGE_FileIO_stat_async_002
* @tc.name fileio_test_stat_async_002
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_002', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o774) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
expect((stat.mode & 0o777) == 0o774).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
});
});
/**
* @tc.number SUB_STORAGE_FileIO_stat_async_003
* @tc.name fileio_test_stat_async_003
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_003', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o772) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
expect((stat.mode & 0o777) == 0o772).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
});
});
/**
* @tc.number SUB_STORAGE_FileIO_stat_async_004
* @tc.name fileio_test_stat_async_004
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_004', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o771) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
expect((stat.mode & 0o777) == 0o771).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
});
});
/**
* @tc.number SUB_STORAGE_FileIO_stat_async_005
* @tc.name fileio_test_stat_async_005
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_005', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o770) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
expect((stat.mode & 0o777) == 0o770).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
});
});
/**
* @tc.number SUB_STORAGE_FileIO_stat_async_006
* @tc.name fileio_test_stat_async_006
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_006', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o666) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
expect((stat.mode & 0o777) == 0o666).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
});
});
/**
* @tc.number SUB_STORAGE_FileIO_stat_async_007
* @tc.name fileio_test_stat_async_007
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_007', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_007');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o664) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
expect((stat.mode & 0o777) == 0o664).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
});
});
/**
* @tc.number SUB_STORAGE_FileIO_stat_async_008
* @tc.name fileio_test_stat_async_008
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_008', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_008');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o662) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
expect((stat.mode & 0o777) == 0o662).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
});
});
/**
* @tc.number SUB_STORAGE_FileIO_stat_async_009
* @tc.name fileio_test_stat_async_009
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_009', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_009');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o661) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
expect((stat.mode & 0o777) == 0o661).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
});
});
/**
* @tc.number SUB_STORAGE_FileIO_stat_async_010
* @tc.name fileio_test_stat_async_010
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_010', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_010');
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 SUB_STORAGE_FileIO_stat_async_011
* @tc.name fileio_test_stat_async_011
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_011', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_011');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o640) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
expect((stat.mode & 0o777) == 0o640).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
});
});
/**
* @tc.number SUB_STORAGE_FileIO_stat_async_012
* @tc.name fileio_test_stat_async_012
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_012', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_012');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o600) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
expect((stat.mode & 0o777) == 0o600).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_013
* @tc.name fileio_test_stat_async_013
* @tc.desc Function of API, obtain file propertys by stat async
*/
it('fileio_test_stat_async_013', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_013');
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_stat_async_014
* @tc.name fileio_test_stat_async_014
* @tc.desc Function of API, obtain file propertys by stat async
*/
it('fileio_test_stat_async_014', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_014');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o777) !== null).assertTrue();
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o777).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
});
/**
* @tc.number fileio_test_stat_async_015
* @tc.name fileio_test_stat_async_015
* @tc.desc Function of API, obtain file propertys by stat async
*/
it('fileio_test_stat_async_015', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_015');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o776) !== null).assertTrue();
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o776).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
});
/**
* @tc.number fileio_test_stat_async_016
* @tc.name fileio_test_stat_async_016
* @tc.desc Function of API, obtain file propertys by stat async
*/
it('fileio_test_stat_async_016', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_016');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o774) !== null).assertTrue();
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o774).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
});
/**
* @tc.number fileio_test_stat_async_017
* @tc.name fileio_test_stat_async_017
* @tc.desc Function of API, obtain file propertys by stat async
*/
it('fileio_test_stat_async_017', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_017');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o772) !== null).assertTrue();
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o772).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
});
/**
* @tc.number fileio_test_stat_async_018
* @tc.name fileio_test_stat_async_018
* @tc.desc Function of API, obtain file propertys by stat async
*/
it('fileio_test_stat_async_018', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_018');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o771) !== null).assertTrue();
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o771).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
});
/**
* @tc.number fileio_test_stat_async_019
* @tc.name fileio_test_stat_async_019
* @tc.desc Function of API, obtain file propertys by stat async
*/
it('fileio_test_stat_async_019', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_019');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o770) !== null).assertTrue();
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o770).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
});
/**
* @tc.number fileio_test_stat_async_020
* @tc.name fileio_test_stat_async_020
* @tc.desc Function of API, obtain file propertys by stat async
*/
it('fileio_test_stat_async_020', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_020');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o666) !== null).assertTrue();
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o666).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
});
/**
* @tc.number fileio_test_stat_async_021
* @tc.name fileio_test_stat_async_021
* @tc.desc Function of API, obtain file propertys by stat async
*/
it('fileio_test_stat_async_021', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_021');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o664) !== null).assertTrue();
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o664).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
});
/**
* @tc.number fileio_test_stat_async_022
* @tc.name fileio_test_stat_async_022
* @tc.desc Function of API, obtain file propertys by stat async
*/
it('fileio_test_stat_async_022', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_022');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o662) !== null).assertTrue();
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o662).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
});
/**
* @tc.number fileio_test_stat_async_023
* @tc.name fileio_test_stat_async_023
* @tc.desc Function of API, obtain file propertys by stat async
*/
it('fileio_test_stat_async_023', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_023');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o640) !== null).assertTrue();
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o640).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
});
/**
* @tc.number fileio_test_stat_async_024
* @tc.name fileio_test_stat_async_024
* @tc.desc Function of API, obtain file propertys by stat async
*/
it('fileio_test_stat_async_024', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_024');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o600) !== null).assertTrue();
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o600).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
});
/**
* @tc.number fileio_test_stat_async_025
* @tc.name fileio_test_stat_async_025
* @tc.desc Function of API, obtain file propertys by stat async
*/
it('fileio_test_stat_async_025', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_025');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o400) !== null).assertTrue();
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o400).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
});
/**
* @tc.number fileio_test_stat_async_026
* @tc.name fileio_test_stat_async_026
* @tc.desc Function of API, obtain file propertys by stat async
*/
it('fileio_test_stat_async_026', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_026');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o200) !== null).assertTrue();
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o200).assertTrue();
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 promise
*/
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);
expect(fd !== null).assertTrue();
await fileio.close(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
});
/**
* @tc.number fileio_test_close_async_001
* @tc.name fileio_test_close_async_001
* @tc.desc Function of API close
*/
it('fileio_test_close_async_001', 0, async function () {
let fpath = await nextFileName('fileio_test_close_async_001');
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
...@@ -152,6 +152,39 @@ describe('fileIOTestDir', function () { ...@@ -152,6 +152,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_0200
* @tc.name testFormatPhoneNumber_0200
* @tc.desc PhoneNumber is 13900000000, options: CN, test formatPhoneNumber() api by callback.
* The return value is 139 0000 0000
*/
it('Telephony_CallManager_formatPhoneNumber_Async_0200', 0, async function (done) {
let numberFormatOptions = new NumberFormatOptions('CN');
call.formatPhoneNumber('13900000000', numberFormatOptions, (err, data) => {
if (err) {
console.log(`Telephony_CallManager_formatPhoneNumber_Async_0200 err = ${err.message}`);
console.log('Telephony_CallManager_formatPhoneNumber_Async_0200 fail');
expect().assertFail();
done();
return;
}
expect(data === '139 0000 0000').assertTrue();
console.log(`Telephony_CallManager_formatPhoneNumber_Async_0200 finish data = ${data}`);
done();
});
});
/**
* @tc.number Telephony_CallManager_formatPhoneNumber_Async_0300
* @tc.name testFormatPhoneNumber_0300
* @tc.desc PhoneNumber is 13900000000, options: US, test formatPhoneNumber() api by promise.
* The return value is '1 390-000-0000'
*/
it('Telephony_CallManager_formatPhoneNumber_Promise_0200', 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_0200 finish data = ${data}`);
done();
} catch (err) {
console.log('Telephony_CallManager_formatPhoneNumber_Promise_0200 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,43 @@ describe('CallManageImsCall', function () { ...@@ -942,4 +984,43 @@ describe('CallManageImsCall', function () {
done(); done();
} }
}); });
/**
* @tc.number Telephony_CallManager_isEmergencyPhoneNumber_Async_1400
* @tc.name testIsEmergencyPhoneNumber_1400
* @tc.desc PhoneNumber: 110, no options. Call isEmergencyPhoneNumber() api by callback.
* The return value is true
*/
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}`);
expect().assertFail();
done();
return;
}
expect(true).assertTrue();
console.log('Telephony_CallManager_isEmergencyPhoneNumber_Async_1400 PASSED ');
done();
});
});
/**
* @tc.number Telephony_CallManager_isEmergencyPhoneNumber_Async_1500
* @tc.name testIsEmergencyPhoneNumber_1500
* @tc.desc PhoneNumber: 120, no options. Call isEmergencyPhoneNumber() api by promise.
* The return value is true
*/
it('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1400', 0, async function (done) {
try {
var data = await call.isEmergencyPhoneNumber('120');
expect(true).assertTrue();
console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1400 PASSED ');
done();
} catch (err) {
console.log(`Telephony_CallManager_isEmergencyPhoneNumber_Promise_1400 finish err = ${err}`);
expect().assertFail();
done();
}
});
}); });
\ No newline at end of file
/* /*
* Copyright (C) 2021 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
* *
* http:www.apache.org/licenses/LICENSE-2.0 * http:www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS, * distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, afterAll, it, expect, afterEach} from 'hypium/index'; import {describe, beforeAll, afterAll, it, expect, afterEach} from 'deccjsunit/index.ets';
import http from '@ohos.net.http'; import http from '@ohos.net.http';
import utils from './Utils.ets' import utils from './Utils.ets'
export default function httpRequestJsunit() { export default function httpRequestJsunit() {
describe("HttpRequestJsunitTest", function () { describe("HttpRequestJsunitTest", function () {
/** /**
* @tc.number Telephony_http_HttpRequest_request_0100 * @tc.number Telephony_http_HttpRequest_request_0100
* @tc.name httprequest::request * @tc.name httprequest::request
* @tc.desc Test Test httprequest property. * @tc.desc Test Test httprequest property.
*/ */
it("Telephony_http_HttpRequest_request_0100", 0, async function (done) { it("Telephony_http_HttpRequest_request_0100", 0, async function (done) {
var casename = "Telephony_http_HttpRequest_0100" var casename = "Telephony_http_HttpRequest_0100"
console.log("-----------------------HttpRequest_request Test is starting-----------------------"); console.log("-----------------------HttpRequest_request Test is starting-----------------------");
try { try {
let httpRequestOptions = { let httpRequestOptions = {
method: 'GET', method: 'GET',
extraData: null, extraData: null,
header: "content-type': 'application/json", header: "content-type': 'application/json",
readTimeout: 60, readTimeout: 60,
connectTimeout: 60 connectTimeout: 60
} }
var httpRequest = http.createHttp(); var httpRequest = http.createHttp();
if (utils.notCheck) { if (utils.notCheck) {
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
return; return;
} }
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.getResponseCode = 200).assertTrue(); expect(data.getResponseCode = 200).assertTrue();
console.log("-----------------------HttpRequest_request Test end-----------------------"); console.log("-----------------------HttpRequest_request Test end-----------------------");
done(); done();
}); });
} catch (error) { } catch (error) {
console.log("Telephony_http_HttpRequest_request_0100 : error = " + error); console.log("Telephony_http_HttpRequest_request_0100 : error = " + error);
done(); done();
} }
}); });
/** /**
* @tc.number Telephony_http_HttpRequest_request_0200 * @tc.number Telephony_http_HttpRequest_request_0200
* @tc.name httprequest::request * @tc.name httprequest::request
* @tc.desc Test Test httprequest property. * @tc.desc Test Test httprequest property.
*/ */
it("Telephony_http_HttpRequest_request_0200", 0, async function (done) { it("Telephony_http_HttpRequest_request_0200", 0, async function (done) {
var casename = "Telephony_http_HttpRequest_0100" var casename = "Telephony_http_HttpRequest_0100"
console.log("-----------------------HttpRequest_request_01 Test is starting-----------------------"); console.log("-----------------------HttpRequest_request_01 Test is starting-----------------------");
try { try {
var httpRequest = http.createHttp(); var httpRequest = http.createHttp();
if (utils.notCheck) { if (utils.notCheck) {
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
return; return;
} }
httpRequest.request("https://www.baidu.com/", (err, data) => { httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.getResponseCode = 200).assertTrue(); expect(data.getResponseCode = 200).assertTrue();
console.log("-----------------------HttpRequest_request_01 Test end-----------------------"); console.log("-----------------------HttpRequest_request_01 Test end-----------------------");
done(); done();
}); });
} catch (error) { } catch (error) {
console.log("Telephony_http_HttpRequest_request_0200 : error = " + error); console.log("Telephony_http_HttpRequest_request_0200 : error = " + error);
done(); done();
} }
}); });
/** /**
* @tc.number Telephony_http_HttpRequest_request_0300 * @tc.number Telephony_http_HttpRequest_request_0300
* @tc.name httprequest::request * @tc.name httprequest::request
* @tc.desc Test Test httprequest property. * @tc.desc Test Test httprequest property.
*/ */
it("Telephony_http_HttpRequest_request_0300", 0, async function (done) { it("Telephony_http_HttpRequest_request_0300", 0, async function (done) {
var casename = "Telephony_http_HttpRequest_0100" var casename = "Telephony_http_HttpRequest_0100"
console.log("-----------------------HttpRequest_request_02 Test is starting-----------------------"); console.log("-----------------------HttpRequest_request_02 Test is starting-----------------------");
try { try {
let httpRequestOptions = { let httpRequestOptions = {
method: 'GET', method: 'GET',
extraData: null, extraData: null,
header: "content-type': 'application/json", header: "content-type': 'application/json",
readTimeout: 60, readTimeout: 60,
connectTimeout: 60 connectTimeout: 60
} }
var httpRequest = http.createHttp(); var httpRequest = http.createHttp();
if (utils.notCheck) { if (utils.notCheck) {
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
return; return;
} }
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => { httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data)); console.log(casename + JSON.stringify(data));
expect(data.getResponseCode = 200).assertTrue(); expect(data.getResponseCode = 200).assertTrue();
console.log("-----------------------HttpRequest_request_02 Test end-----------------------"); console.log("-----------------------HttpRequest_request_02 Test end-----------------------");
done(); done();
}).catch(error => { }).catch(error => {
console.info('HttpRequest_request_0300 asyncCallback error : ' + JSON.stringify(error)); console.info('HttpRequest_request_0300 asyncCallback error : ' + JSON.stringify(error));
done(); done();
}); });
} catch (error) { } catch (error) {
console.log("Telephony_http_HttpRequest_request_0300 : error = " + error); console.log("Telephony_http_HttpRequest_request_0300 : error = " + error);
done(); done();
} }
}); });
/** /**
* @tc.number Telephony_http_HttpRequest_destroy_0100 * @tc.number Telephony_http_HttpRequest_destroy_0100
* @tc.name httprequest::destroy * @tc.name httprequest::destroy
* @tc.desc Test Test httprequest property. * @tc.desc Test Test httprequest property.
*/ */
it("Telephony_http_HttpRequest_destroy_0100", 0, async function (done) { it("Telephony_http_HttpRequest_destroy_0100", 0, async function (done) {
var casename = "Telephony_http_HttpRequest_0200" var casename = "Telephony_http_HttpRequest_0200"
console.log("-----------------------HttpRequest_destroy Test is starting-----------------------"); console.log("-----------------------HttpRequest_destroy Test is starting-----------------------");
try { try {
let httpRequestOptions = { let httpRequestOptions = {
method: 'GET', method: 'GET',
extraData: null, extraData: null,
header: "content-type': 'application/json", header: "content-type': 'application/json",
readTimeout: 60, readTimeout: 60,
connectTimeout: 60 connectTimeout: 60
} }
var httpRequest = http.createHttp(); var httpRequest = http.createHttp();
if (utils.notCheck) { if (utils.notCheck) {
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
return; return;
} }
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
try{ try{
httpRequest.destroy(); httpRequest.destroy();
expect(true).assertTrue(); expect(true).assertTrue();
console.log("-----------------------HttpRequest_destroy Test end-----------------------"); console.log("-----------------------HttpRequest_destroy Test end-----------------------");
done(); done();
}catch(error){ }catch(error){
expect().assertFail(); expect().assertFail();
done(); done();
} }
}); });
} catch (error) { } catch (error) {
console.log("Telephony_http_HttpRequest_destroy_0100 : error = " + error); console.log("Telephony_http_HttpRequest_destroy_0100 : error = " + error);
done(); done();
} }
}); });
/** /**
* @tc.number Telephony_http_HttpRequest_on_headerReceive_0100 * @tc.number Telephony_http_HttpRequest_on_headerReceive_0100
* @tc.name httprequest::on_headerReceive * @tc.name httprequest::on_headerReceive
* @tc.desc Test Test httprequest property. * @tc.desc Test Test httprequest property.
*/ */
it("Telephony_http_HttpRequest_on_headerReceive_0100", 0, async function (done) { it("Telephony_http_HttpRequest_on_headerReceive_0100", 0, async function (done) {
var casename = "Telephony_http_HttpRequest_0300" var casename = "Telephony_http_HttpRequest_0300"
console.log("-----------------------HttpRequest_on_headerReceive Test is starting-----------------------"); console.log("-----------------------HttpRequest_on_headerReceive Test is starting-----------------------");
try { try {
var httpRequest = http.createHttp(); var httpRequest = http.createHttp();
if (utils.notCheck) { if (utils.notCheck) {
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
return; return;
} }
httpRequest.on_headerReceive((data) => { httpRequest.on_headerReceive((data) => {
console.log(casename + " data: " + JSON.stringify(data)); console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue(); expect(true).assertTrue();
console.log("-----------------------HttpRequest_on_headerReceive Test end-----------------------"); console.log("-----------------------HttpRequest_on_headerReceive Test end-----------------------");
done(); done();
}); });
} catch (error) { } catch (error) {
console.log("Telephony_http_HttpRequest_on_headerReceive_0100 : error = " + error); console.log("Telephony_http_HttpRequest_on_headerReceive_0100 : error = " + error);
done(); done();
} }
}); });
/** /**
* @tc.number Telephony_http_HttpRequest_off_headerReceive_0100 * @tc.number Telephony_http_HttpRequest_off_headerReceive_0100
* @tc.name httprequest::off_headerReceive * @tc.name httprequest::off_headerReceive
* @tc.desc Test Test httprequest property. * @tc.desc Test Test httprequest property.
*/ */
it("Telephony_http_HttpRequest_off_headerReceive_0100", 0, async function (done) { it("Telephony_http_HttpRequest_off_headerReceive_0100", 0, async function (done) {
var casename = "Telephony_http_HttpRequest_0400" var casename = "Telephony_http_HttpRequest_0400"
console.log("-----------------------HttpRequest_off_headerReceive Test is starting-----------------------"); console.log("-----------------------HttpRequest_off_headerReceive Test is starting-----------------------");
try { try {
var httpRequest = http.createHttp(); var httpRequest = http.createHttp();
if (utils.notCheck) { if (utils.notCheck) {
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
return; return;
} }
httpRequest.off_headerReceive((data) => { httpRequest.off_headerReceive((data) => {
console.log(casename + " data: " + JSON.stringify(data)); console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue(); expect(true).assertTrue();
console.log("-----------------------HttpRequest_off_headerReceive Test end-----------------------"); console.log("-----------------------HttpRequest_off_headerReceive Test end-----------------------");
done(); done();
}); });
} catch (error) { } catch (error) {
console.log("Telephony_http_HttpRequest_off_headerReceive_0100 : error = " + error); console.log("Telephony_http_HttpRequest_off_headerReceive_0100 : error = " + error);
done(); done();
} }
}); });
/** /**
* @tc.number Telephony_http_HttpRequest_on_headersReceive_0100 * @tc.number Telephony_http_HttpRequest_on_headersReceive_0100
* @tc.name httprequest::on_headersReceive * @tc.name httprequest::on_headersReceive
* @tc.desc Test Test httprequest property. * @tc.desc Test Test httprequest property.
*/ */
it("Telephony_http_HttpRequest_on_headersReceive_0100", 0, function (done) { it("Telephony_http_HttpRequest_on_headersReceive_0100", 0, function (done) {
var casename = "Telephony_http_HttpRequest_0500" var casename = "Telephony_http_HttpRequest_0500"
console.log("-----------------------HttpRequest_on_headersReceive Test is starting-----------------------"); console.log("-----------------------HttpRequest_on_headersReceive Test is starting-----------------------");
try { try {
var httpRequest = http.createHttp(); var httpRequest = http.createHttp();
if (utils.notCheck) { if (utils.notCheck) {
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
return; return;
} }
httpRequest.on("headersReceive", (data) => { httpRequest.on("headersReceive", (data) => {
console.log(casename + " data: " + JSON.stringify(data)); console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue(); expect(true).assertTrue();
console.log("-----------------------HttpRequest_on_headersReceive Test end-----------------------"); console.log("-----------------------HttpRequest_on_headersReceive Test end-----------------------");
done(); done();
}); });
} catch (error) { } catch (error) {
console.log("Telephony_http_HttpRequest_on_headersReceive_0100 : error = " + error); console.log("Telephony_http_HttpRequest_on_headersReceive_0100 : error = " + error);
done(); done();
} }
}); });
/** /**
* @tc.number Telephony_http_HttpRequest_off_headersReceive_0100 * @tc.number Telephony_http_HttpRequest_off_headersReceive_0100
* @tc.name httprequest::off_headersReceive * @tc.name httprequest::off_headersReceive
* @tc.desc Test Test httprequest property. * @tc.desc Test Test httprequest property.
*/ */
it("Telephony_http_HttpRequest_off_headersReceive_0100", 0, function (done) { it("Telephony_http_HttpRequest_off_headersReceive_0100", 0, function (done) {
var casename = "Telephony_http_HttpRequest_0600" var casename = "Telephony_http_HttpRequest_0600"
console.log("-----------------------HttpRequest_off_headersReceive Test is starting-----------------------"); console.log("-----------------------HttpRequest_off_headersReceive Test is starting-----------------------");
try { try {
var httpRequest = http.createHttp(); var httpRequest = http.createHttp();
if (utils.notCheck) { if (utils.notCheck) {
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
return; return;
} }
httpRequest.off("headersReceive", (data) => { httpRequest.off("headersReceive", (data) => {
console.log(casename + " data: " + JSON.stringify(data)); console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue(); expect(true).assertTrue();
console.log("-----------------------HttpRequest_off_headersReceive Test end-----------------------"); console.log("-----------------------HttpRequest_off_headersReceive Test end-----------------------");
done(); done();
}); });
} catch (error) { } catch (error) {
console.log("Telephony_http_HttpRequest_off_headersReceive_0100 : error = " + error); console.log("Telephony_http_HttpRequest_off_headersReceive_0100 : error = " + error);
done(); done();
} }
}); });
/**
}) * @tc.number Telephony_http_HttpRequest_off_headersReceive_0200
* @tc.name httprequest::off_headersReceive_0200
}; * @tc.desc Test Test httprequest property.
*/
it("Telephony_http_HttpRequest_off_headersReceive_0200", 0, function (done) {
var casename = "Telephony_http_HttpRequest_off_headersReceive_0200"
console.log("-----------------------HttpRequest_off_headersReceive Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.off('headersReceive');
expect(true).assertTrue();
console.log("-----------------------HttpRequest_off_headersReceive_0200 Test end-----------------------");
done();
} catch (error) {
console.log("Telephony_http_HttpRequest_off_headersReceive_0200 : error = " + error);
done();
}
});
/**
* @tc.number Telephony_http_HttpRequest_once_headersReceive_0100
* @tc.name httprequest::once_headersReceive_0100
* @tc.desc Test Test httprequest property.
*/
it("Telephony_http_HttpRequest_once_headersReceive_0100", 0, function (done) {
var casename = "Telephony_http_HttpRequest_once_headersReceive_0100"
console.log("-----------------------HttpRequest_once_headersReceive Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.once('headersReceive', (data) => {
console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue();
console.log("-----------------------HttpRequest_on_headersReceive Test end-----------------------");
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequest_once_headersReceive_010 : error = " + error);
done();
}
});
})
};
...@@ -337,7 +337,43 @@ describe('ActsNetworkSearchTest', function () { ...@@ -337,7 +337,43 @@ describe('ActsNetworkSearchTest', function () {
} }
}) })
/**
* @tc.number Telephony_NetworkSearch_getOperatorName_Async_0500
* @tc.name testGetOperatorName_0500
* @tc.desc Test getOperatorName api by callback.
*/
it('Telephony_NetworkSearch_getOperatorName_Async_0500', 0, async function (done) {
radio.getOperatorName(0, (err, data) => {
if (err) {
console.log(`Telephony_NetworkSearch_getOperatorName_Async_0500 fail err: ${err}`);
expect().assertFail();
done();
return;
}
console.log(`Telephony_NetworkSearch_getOperatorName_Async_0500 finish data: ${data}`);
expect(true).assertTrue();
done();
})
})
/**
* @tc.number Telephony_NetworkSearch_getOperatorName_Async_0600
* @tc.name testGetOperatorName_0600
* @tc.desc Test getOperatorName api by promise.
*/
it('Telephony_NetworkSearch_getOperatorName_Promise_0500', 0, async function (done) {
try {
let data = await radio.getOperatorName(0);
console.log(`Telephony_NetworkSearch_getOperatorName_Promise_0500 finish data: ${data}`);
expect(true).assertTrue();
done();
} catch (err) {
console.log(`Telephony_NetworkSearch_getOperatorName_Promise_0500 fail err: ${err}`);
expect().assertFail();
done();
}
})
/** /**
* @tc.number Telephony_NetworkSearch_isRadioOn_Async_0200 * @tc.number Telephony_NetworkSearch_isRadioOn_Async_0200
* @tc.name Test The function isRadioOn * @tc.name Test The function isRadioOn
...@@ -371,6 +407,39 @@ describe('ActsNetworkSearchTest', function () { ...@@ -371,6 +407,39 @@ describe('ActsNetworkSearchTest', function () {
} }
}); });
/**
* @tc.number Telephony_NetworkSearch_isRadioOn_Async_0300
* @tc.name testIsRadioOn_0300
* @tc.desc Test isRadioOn api by callback.
*/
it('Telephony_NetworkSearch_isRadioOn_Async_0300', 0, async function (done) {
radio.isRadioOn(0, (err) => {
if (err) {
console.log(`Telephony_NetworkSearch_isRadioOn_Async_0300 fail: ${err}`);
done();
return;
}
console.log('Telephony_NetworkSearch_isRadioOn_Async_0300 finish');
done();
});
});
/**
* @tc.number Telephony_NetworkSearch_isRadioOn_Async_0400
* @tc.name testIsRadioOn_0400
* @tc.desc Test isRadioOn api by promise.
*/
it('Telephony_NetworkSearch_isRadioOn_Promise_0300', 0, async function (done) {
try {
await radio.isRadioOn(0);
console.log('Telephony_NetworkSearch_isRadioOn_Promise_0300 success');
done();
} catch (err) {
console.log(`Telephony_NetworkSearch_isRadioOn_Promise_0300 fail ${err}`);
done();
}
});
/** /**
* @tc.number Telephony_StateRegistry_on_0200 * @tc.number Telephony_StateRegistry_on_0200
* @tc.name Add a networkStatus change listen and test observer.on({slotId:0}) to view the callback results * @tc.name Add a networkStatus change listen and test observer.on({slotId:0}) to view the callback results
......
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 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
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'hypium/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import radio from '@ohos.telephony.radio'; import radio from '@ohos.telephony.radio';
import utils from './Utils.ets' import utils from './Utils.ets'
export default function radioJsunit() { export default function radioJsunit() {
describe('ActsNetworkSearchTest',function () { describe('ActsNetworkSearchTest',function () {
const SLOT_2 = -1; const SLOT_2 = -1;
const SLOT_0 = 0; const SLOT_0 = 0;
/** /**
* @tc.number Telephony_NetworkSearch_getPrimarySlotId_Async_0200 * @tc.number Telephony_NetworkSearch_getPrimarySlotId_Async_0200
* @tc.name Test getPrimarySlotId(-1) to check the callback result * @tc.name Test getPrimarySlotId(-1) to check the callback result
* @tc.desc Function test * @tc.desc Function test
*/ */
it('Telephony_NetworkSearch_getPrimarySlotId_Async_0200', 0, async function (done) { it('Telephony_NetworkSearch_getPrimarySlotId_Async_0200', 0, async function (done) {
if(utils.notCheck){ if(utils.notCheck){
done(); done();
return; return;
} }
radio.getPrimarySlotId((err, data) => { radio.getPrimarySlotId((err, data) => {
if (err) { if (err) {
console.log(`Telephony_NetworkSearch_getPrimarySlotId_Async_0200 fail: ${err}`); console.log(`Telephony_NetworkSearch_getPrimarySlotId_Async_0200 fail: ${err}`);
expect(data === undefined).assertTrue(); expect(data === undefined).assertTrue();
done(); done();
return; return;
} }
console.log(`Telephony_NetworkSearch_getPrimarySlotId_Async_0200 end data: ${data}`); console.log(`Telephony_NetworkSearch_getPrimarySlotId_Async_0200 end data: ${data}`);
expect(data === '').assertTrue(); expect(data === '').assertTrue();
done(); done();
}); });
}); });
/**
/** * @tc.number Telephony_NetworkSearch_getPrimarySlotId_Async_0300
* @tc.number Telephony_NetworkSearch_isNrSupported_Promise_0400 * @tc.name testGetPrimarySlotId_0300
* @tc.name Test The function setPrimarySlotId(0) * @tc.desc Test getPrimarySlotId api by promise.
* @tc.desc Function test */
*/ it('Telephony_NetworkSearch_getPrimarySlotId_Promise_0200', 0, async function (done) {
it('Telephony_NetworkSearch_isNrSupported_Promise_0400', 0, async function (done) { if(utils.notCheck){
if(utils.notCheck){ done();
done(); return;
return; }
}
try { try {
await radio.isNrSupported(SLOT_0); let data = await radio.getPrimarySlotId();
console.log('radio.isNrSupported(SLOT_0) = ' + radio.isNrSupported(SLOT_0)); console.log(`Telephony_NetworkSearch_getPrimarySlotId_Promise_0200 pass data: ${data}`);
console.log('Telephony_NetworkSearch_isNrSupported_Promise_0400 success'); expect(true).assertTrue();
done(); } catch (err) {
} catch (err) { console.log(`Telephony_NetworkSearch_getPrimarySlotId_Promise_0200 fail err: ${err}`);
console.log(`Telephony_NetworkSearch_isNrSupported_Promise_0400 fail ${err}`); expect().assertFail();
done(); done();
} return;
}); }
done();
/** });
* @tc.number Telephony_radio_PreferredNetworkMode_0500
* @tc.name Test The PreferredNetworkMode enum /**
* @tc.desc Function test * @tc.number Telephony_NetworkSearch_isNrSupported_Promise_0400
*/ * @tc.name Test The function setPrimarySlotId(0)
it('Telephony_radio_PreferredNetworkMode_0500', 0, async function (done) { * @tc.desc Function test
console.info("Telephony_radio_PreferredNetworkMode_0500 start") */
if(utils.notCheck){ it('Telephony_NetworkSearch_isNrSupported_Promise_0400', 0, async function (done) {
done(); if(utils.notCheck){
return; done();
} return;
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_WCDMA === 2).assertTrue(); }
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE === 3).assertTrue(); try {
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA === 4).assertTrue(); await radio.isNrSupported(SLOT_0);
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM === 5).assertTrue(); console.log('radio.isNrSupported(SLOT_0) = ' + radio.isNrSupported(SLOT_0));
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_WCDMA_GSM === 6).assertTrue(); console.log('Telephony_NetworkSearch_isNrSupported_Promise_0400 success');
console.info("Telephony_radio_PreferredNetworkMode_0500 end") done();
done(); } catch (err) {
}); console.log(`Telephony_NetworkSearch_isNrSupported_Promise_0400 fail ${err}`);
done();
/** }
* @tc.number Telephony_radio_PreferredNetworkMode_0600 });
* @tc.name Test The PreferredNetworkMode enum
* @tc.desc Function test /**
*/ * @tc.number Telephony_radio_PreferredNetworkMode_0500
it('Telephony_radio_PreferredNetworkMode_0600', 0, async function (done) { * @tc.name Test The PreferredNetworkMode enum
if(utils.notCheck){ * @tc.desc Function test
done(); */
return; it('Telephony_radio_PreferredNetworkMode_0500', 0, async function (done) {
} console.info("Telephony_radio_PreferredNetworkMode_0500 start")
console.info("Telephony_radio_PreferredNetworkMode_0600 start") if(utils.notCheck){
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_CDMA === 7).assertTrue(); done();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_EVDO === 8).assertTrue(); return;
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_EVDO_CDMA === 9).assertTrue(); }
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_WCDMA_GSM_EVDO_CDMA === 10).assertTrue(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_WCDMA === 2).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_EVDO_CDMA === 11).assertTrue(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE === 3).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_0600 end") expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA === 4).assertTrue();
done(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM === 5).assertTrue();
}); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_WCDMA_GSM === 6).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_0500 end")
/** done();
* @tc.number Telephony_radio_PreferredNetworkMode_0700 });
* @tc.name Test The PreferredNetworkMode enum
* @tc.desc Function test /**
*/ * @tc.number Telephony_radio_PreferredNetworkMode_0600
it('Telephony_radio_PreferredNetworkMode_0700', 0, async function (done) { * @tc.name Test The PreferredNetworkMode enum
if(utils.notCheck){ * @tc.desc Function test
done(); */
return; it('Telephony_radio_PreferredNetworkMode_0600', 0, async function (done) {
} if(utils.notCheck){
console.info("Telephony_radio_PreferredNetworkMode_0700 start") done();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM_EVDO_CDMA === 12).assertTrue(); return;
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA === 13).assertTrue(); }
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_GSM === 14).assertTrue(); console.info("Telephony_radio_PreferredNetworkMode_0600 start")
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA === 15).assertTrue(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_CDMA === 7).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM === 16).assertTrue(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_EVDO === 8).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_0700 end") expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_EVDO_CDMA === 9).assertTrue();
done(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_WCDMA_GSM_EVDO_CDMA === 10).assertTrue();
}); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_EVDO_CDMA === 11).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_0600 end")
/** done();
* @tc.number Telephony_radio_PreferredNetworkMode_0800 });
* @tc.name Test The PreferredNetworkMode enum
* @tc.desc Function test /**
*/ * @tc.number Telephony_radio_PreferredNetworkMode_0700
it('Telephony_radio_PreferredNetworkMode_0800', 0, async function (done) { * @tc.name Test The PreferredNetworkMode enum
if(utils.notCheck){ * @tc.desc Function test
done(); */
return; it('Telephony_radio_PreferredNetworkMode_0700', 0, async function (done) {
} if(utils.notCheck){
console.info("Telephony_radio_PreferredNetworkMode_0800 start") done();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA === 17).assertTrue(); return;
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_GSM === 18).assertTrue(); }
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA === 19).assertTrue(); console.info("Telephony_radio_PreferredNetworkMode_0700 start")
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM === 20).assertTrue(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM_EVDO_CDMA === 12).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM_EVDO_CDMA ===21).assertTrue(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA === 13).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_0800 end") expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_GSM === 14).assertTrue();
done(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA === 15).assertTrue();
}); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM === 16).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_0700 end")
/** done();
* @tc.number Telephony_radio_PreferredNetworkMode_0900 });
* @tc.name Test The PreferredNetworkMode enum
* @tc.desc Function test /**
*/ * @tc.number Telephony_radio_PreferredNetworkMode_0800
it('Telephony_radio_PreferredNetworkMode_0900', 0, async function (done) { * @tc.name Test The PreferredNetworkMode enum
if(utils.notCheck){ * @tc.desc Function test
done(); */
return; it('Telephony_radio_PreferredNetworkMode_0800', 0, async function (done) {
} if(utils.notCheck){
console.info("Telephony_radio_PreferredNetworkMode_0900 start") done();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA === 17).assertTrue(); return;
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_GSM === 18).assertTrue(); }
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA === 19).assertTrue(); console.info("Telephony_radio_PreferredNetworkMode_0800 start")
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM === 20).assertTrue(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA === 17).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM_EVDO_CDMA ===21).assertTrue(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_GSM === 18).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_0900 end") expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA === 19).assertTrue();
done(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM === 20).assertTrue();
}); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM_EVDO_CDMA ===21).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_0800 end")
/** done();
* @tc.number Telephony_radio_PreferredNetworkMode_1000 });
* @tc.name Test The PreferredNetworkMode enum
* @tc.desc Function test /**
*/ * @tc.number Telephony_radio_PreferredNetworkMode_0900
it('Telephony_radio_PreferredNetworkMode_1000', 0, async function (done) { * @tc.name Test The PreferredNetworkMode enum
if(utils.notCheck){ * @tc.desc Function test
done(); */
return; it('Telephony_radio_PreferredNetworkMode_0900', 0, async function (done) {
} if(utils.notCheck){
console.info("Telephony_radio_PreferredNetworkMode_1000 start") done();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA === 22).assertTrue(); return;
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR === 31).assertTrue(); }
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE === 32).assertTrue(); console.info("Telephony_radio_PreferredNetworkMode_0900 start")
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA === 33).assertTrue(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA === 17).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM ===34).assertTrue(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_GSM === 18).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_1000 end") expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA === 19).assertTrue();
done(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM === 20).assertTrue();
}); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM_EVDO_CDMA ===21).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_0900 end")
/** done();
* @tc.number Telephony_radio_PreferredNetworkMode_1100 });
* @tc.name Test The PreferredNetworkMode enum
* @tc.desc Function test /**
*/ * @tc.number Telephony_radio_PreferredNetworkMode_1000
it('Telephony_radio_PreferredNetworkMode_1100', 0, async function (done) { * @tc.name Test The PreferredNetworkMode enum
if(utils.notCheck){ * @tc.desc Function test
done(); */
return; it('Telephony_radio_PreferredNetworkMode_1000', 0, async function (done) {
} if(utils.notCheck){
console.info("Telephony_radio_PreferredNetworkMode_1100 start") done();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_EVDO_CDMA === 35).assertTrue(); return;
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM_EVDO_CDMA === 36).assertTrue(); }
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA === 37).assertTrue(); console.info("Telephony_radio_PreferredNetworkMode_1000 start")
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_GSM === 38).assertTrue(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA === 22).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA ===39).assertTrue(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR === 31).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM === 40).assertTrue(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE === 32).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA === 41).assertTrue(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA === 33).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_MAX_VALUE === 99).assertTrue(); expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM ===34).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_1100 end") console.info("Telephony_radio_PreferredNetworkMode_1000 end")
done(); done();
}); });
}) /**
} * @tc.number Telephony_radio_PreferredNetworkMode_1100
\ No newline at end of file * @tc.name Test The PreferredNetworkMode enum
* @tc.desc Function test
*/
it('Telephony_radio_PreferredNetworkMode_1100', 0, async function (done) {
if(utils.notCheck){
done();
return;
}
console.info("Telephony_radio_PreferredNetworkMode_1100 start")
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_EVDO_CDMA === 35).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM_EVDO_CDMA === 36).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA === 37).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_GSM === 38).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA ===39).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM === 40).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA === 41).assertTrue();
expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_MAX_VALUE === 99).assertTrue();
console.info("Telephony_radio_PreferredNetworkMode_1100 end")
done();
});
})
}
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 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
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'hypium/index'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets";
import radio from '@ohos.telephony.radio'; import radio from '@ohos.telephony.radio';
import utils from './Utils.ets' import utils from './Utils.ets'
export default function radioSecondJsunit() { export default function radioSecondJsunit() {
describe('radioSecondTest', function () { describe('radioSecondTest', function () {
const NROPTION_MODE = [ const NROPTION_MODE = [
radio.NR_OPTION_UNKNOWN, radio.NR_OPTION_UNKNOWN,
radio.NR_OPTION_NSA_ONLY, radio.NR_OPTION_NSA_ONLY,
radio.NR_OPTION_SA_ONLY, radio.NR_OPTION_SA_ONLY,
radio.NR_OPTION_NSA_AND_SA radio.NR_OPTION_NSA_AND_SA
]; ];
//Network status //Network status
let garrNetworkState = [ let garrNetworkState = [
radio.NETWORK_UNKNOWN, radio.NETWORK_UNKNOWN,
radio.NETWORK_AVAILABLE, radio.NETWORK_AVAILABLE,
radio.NETWORK_CURRENT, radio.NETWORK_CURRENT,
radio.NETWORK_FORBIDDEN, radio.NETWORK_FORBIDDEN,
]; ];
//NetworkRadioTech //NetworkRadioTech
let garrNetworkRadioTech = [ let garrNetworkRadioTech = [
'UNKNOWN', 'GSM', '1XRTT', 'WCDMA', 'UNKNOWN', 'GSM', '1XRTT', 'WCDMA',
'HSPA', 'HSPAP', 'TD_SCDMA', 'EVDO', 'HSPA', 'HSPAP', 'TD_SCDMA', 'EVDO',
'EHRPD', 'LTE', 'LTE_CA', 'IWLAN', 'NR']; 'EHRPD', 'LTE', 'LTE_CA', 'IWLAN', 'NR'];
const SLOT_0 = 0; const SLOT_0 = 0;
const SLOT_1 = 5; const SLOT_1 = 5;
const SLOT_2 = 2; const SLOT_2 = 2;
const SLOT_3 = -1; const SLOT_3 = -1;
const NETWORK_TYPES = [ const NETWORK_TYPES = [
radio.NETWORK_TYPE_UNKNOWN, radio.NETWORK_TYPE_UNKNOWN,
radio.NETWORK_TYPE_GSM, radio.NETWORK_TYPE_GSM,
radio.NETWORK_TYPE_CDMA, radio.NETWORK_TYPE_CDMA,
radio.NETWORK_TYPE_WCDMA, radio.NETWORK_TYPE_WCDMA,
radio.NETWORK_TYPE_TDSCDMA, radio.NETWORK_TYPE_TDSCDMA,
radio.NETWORK_TYPE_LTE, radio.NETWORK_TYPE_LTE,
radio.NETWORK_TYPE_NR, radio.NETWORK_TYPE_NR,
]; ];
const NETWORK_SIGNAL = [0, 1, 2, 3, 4, 5]; const NETWORK_SIGNAL = [0, 1, 2, 3, 4, 5];
const CELL_LAC_TAC_MAX = 0xffff; const CELL_LAC_TAC_MAX = 0xffff;
const CELL_CELLID_MAX = 0xfffffff; const CELL_CELLID_MAX = 0xfffffff;
const CELL_GSM_CELLID_MAX = 0xffff; const CELL_GSM_CELLID_MAX = 0xffff;
const CELL_ARFCN_MAX = 1023; const CELL_ARFCN_MAX = 1023;
const CELL_EARFCN_MAX = 41589; const CELL_EARFCN_MAX = 41589;
const CELL_BSIC_MAX = 63; const CELL_BSIC_MAX = 63;
const CELL_PSC_MAX = 511; const CELL_PSC_MAX = 511;
const CELL_PCI_MAX = 503; const CELL_PCI_MAX = 503;
const CELL_MCC = 460; const CELL_MCC = 460;
const CELL_MNC_MAX = 20; const CELL_MNC_MAX = 20;
const CELL_INFO_MIN = 0; const CELL_INFO_MIN = 0;
const TIME_RADIO_TURNON = 10000; const TIME_RADIO_TURNON = 10000;
console.log("************* radio Test start*************"); console.log("************* radio Test start*************");
/** /**
* @tc.number Telephony_NetworkSearch_NetworkState_Async_0100 * @tc.number Telephony_NetworkSearch_NetworkState_Async_0100
* @tc.name Test getNrOptionMode() to check the callback result * @tc.name Test getNrOptionMode() to check the callback result
* @tc.desc Function test * @tc.desc Function test
*/ */
it('Telephony_NetworkSearch_NetworkState_Async_0100', 0, async function (done) { it('Telephony_NetworkSearch_NetworkState_Async_0100', 0, async function (done) {
if (utils.notCheck) { if (utils.notCheck) {
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
return; return;
} }
radio.getNetworkState((err, data) => { radio.getNetworkState((err, data) => {
if (err) { if (err) {
console.log(`Telephony_NetworkSearch_NetworkState_Async_0100 get fail err: ${err}`); console.log(`Telephony_NetworkSearch_NetworkState_Async_0100 get fail err: ${err}`);
expect().assertFail(); expect().assertFail();
done(); done();
return; return;
} }
console.log(`Telephony_NetworkSearch_NetworkState_Async_0100 end data: ${JSON.stringify(data)}`); console.log(`Telephony_NetworkSearch_NetworkState_Async_0100 end data: ${JSON.stringify(data)}`);
if (true) { if (true) {
console.log(`Telephony_NetworkSearch_getNrOptionMode_Async_0100 1`); console.log(`Telephony_NetworkSearch_getNrOptionMode_Async_0100 1`);
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
return; return;
} else { } else {
expect(NROPTION_MODE).assertContain(data); expect(NROPTION_MODE).assertContain(data);
expect(NROPTION_MODE).assertContain(data.cfgTech); expect(NROPTION_MODE).assertContain(data.cfgTech);
done(); done();
} }
}); });
}) })
/** /**
* @tc.number Telephony_Radio_CdmaCellInformation_sid_0100 * @tc.number Telephony_NetworkSearch_NetworkState_Async_0300
* @tc.name sid * @tc.name testGetNetworkState_0300
* @tc.desc sid test * @tc.desc Test getNetworkState api by promise.
*/ */
it('Telephony_Radio_CdmaCellInformation_sid_0100', 0, async function (done) { it('Telephony_NetworkSearch_NetworkState_Promise_0100', 0, async function (done) {
console.log("-----------------------Telephony_Radio_CdmaCellInformation_sid_0100 start-----------------------"); if (utils.notCheck) {
if (utils.notCheck) { expect(true).assertTrue();
expect(true).assertTrue(); done();
done(); return;
return; }
} try {
let cdmaCellInformatio = { const result = await radio.getNetworkState();
baseId: 1, expect(true).assertTrue();
latitude: 39, console.log(`Telephony_NetworkSearch_NetworkState_Promise_0100 test finish.`);
longitude: 116, } catch (error) {
nid: 101, console.log(`Telephony_NetworkSearch_NetworkState_Promise_0100 error: ${error.message}`);
sid: 102 expect().assertFail();
} }
expect(101).assertEqual(cdmaCellInformatio.nid); done();
expect(102).assertEqual(cdmaCellInformatio.sid); })
console.log("-----------------------Telephony_Radio_CdmaCellInformation_sid_0100 end-----------------------");
}) /**
* @tc.number Telephony_NetworkSearch_NetworkState_Async_0200
* @tc.name testGetNetworkState_0200
* @tc.desc Test getNetworkState() api by callback, slotId is 0, to check the callback result
console.log("************* radio Test end*************"); */
function assertCellInformation(data) { it('Telephony_NetworkSearch_NetworkState_Async_0200', 0, async function (done) {
expect(data !== '' && data != undefined && data != null).assertTrue(); if (utils.notCheck) {
expect(data.length).assertLarger(0); expect(true).assertTrue();
for (let i = 0; i < data.length; i++) { done();
expect(NETWORK_TYPES).assertContain(data[i].networkType); return;
expect(data[i].isCamped).assertTrue(); }
expect(data[i].timeStamp).assertLarger(0); radio.getNetworkState(0, (err, data) => {
expect(NETWORK_TYPES).assertContain(data[i].signalInformation.signalType); if (err) {
expect(NETWORK_SIGNAL).assertContain(data[i].signalInformation.signalLevel); console.log(`Telephony_NetworkSearch_NetworkState_Async_0200 get fail err: ${err}`);
expect(data[i].data != undefined && data[i].data != '' && data[i].data != null).assertTrue(); expect().assertFail();
if (data[0].networkType === radio.NETWORK_TYPE_LTE) { done();
expect(data[i].data.tac >= CELL_INFO_MIN && data[i].data.tac <= CELL_LAC_TAC_MAX).assertTrue(); return;
expect(data[i].data.cgi >= CELL_INFO_MIN && data[i].data.cgi <= CELL_CELLID_MAX).assertTrue(); }
expect(data[i].data.earfcn >= CELL_INFO_MIN && data[i].data.earfcn <= CELL_EARFCN_MAX).assertTrue(); console.log(`Telephony_NetworkSearch_NetworkState_Async_0200 end data: ${JSON.stringify(data)}`);
expect(data[i].data.pci >= CELL_INFO_MIN && data[i].data.pci <= CELL_PCI_MAX).assertTrue(); expect(true).assertTrue();
expect(data[i].data.mnc >= CELL_INFO_MIN && data[i].data.mnc <= CELL_MNC_MAX).assertTrue(); done();
expect(data[i].data.bandwidth >= CELL_INFO_MIN && data[i].data.bandwidth <= CELL_MNC_MAX).assertTrue(); return;
expect(data[i].data.isSupportEndc >= CELL_INFO_MIN && data[i].data.isSupportEndc <= CELL_MNC_MAX).assertTrue(); });
expect(data[i].data.mcc).assertEqual(CELL_MCC); })
} else if (data[i].networkType === radio.NETWORK_TYPE_WCDMA) {
expect(data[i].data.lac >= CELL_INFO_MIN && data[i].data.lac <= CELL_LAC_TAC_MAX).assertTrue(); /**
expect(data[i].data.cellId >= CELL_INFO_MIN && data[i].data.cellId <= CELL_CELLID_MAX).assertTrue(); * @tc.number Telephony_NetworkSearch_NetworkState_Async_0400
expect(data[i].data.uarfcn >= CELL_INFO_MIN && data[i].data.uarfcn <= CELL_ARFCN_MAX).assertTrue(); * @tc.name testGetNetworkState_0400
expect(data[i].data.psc >= CELL_INFO_MIN && data[i].data.psc <= CELL_PSC_MAX).assertTrue(); * @tc.desc Test getNetworkState() api by promise, slotId is 0, to check the callback result
expect(data[i].data.mnc >= CELL_INFO_MIN && data[i].data.mnc <= CELL_MNC_MAX).assertTrue(); */
expect(data[i].data.cpid >= CELL_INFO_MIN && data[i].data.cpid <= CELL_MNC_MAX).assertTrue(); it('Telephony_NetworkSearch_NetworkState_Promise_0200', 0, async function (done) {
expect(data[i].data.mcc).assertEqual(CELL_MCC); if (utils.notCheck) {
} else if (data[i].networkType === radio.NETWORK_TYPE_GSM) { expect(true).assertTrue();
expect(data[i].data.lac >= CELL_INFO_MIN && data[i].data.lac <= CELL_LAC_TAC_MAX).assertTrue(); done();
expect(data[i].data.cellId >= CELL_INFO_MIN && data[i].data.cellId <= CELL_GSM_CELLID_MAX).assertTrue(); return;
expect(data[i].data.arfcn >= CELL_INFO_MIN && data[i].data.arfcn <= CELL_ARFCN_MAX).assertTrue(); }
expect(data[i].data.bsic >= CELL_INFO_MIN && data[i].data.bsic <= CELL_BSIC_MAX).assertTrue(); try {
expect(data[i].data.mnc >= CELL_INFO_MIN && data[i].data.mnc <= CELL_MNC_MAX).assertTrue(); const result = await radio.getNetworkState(0);
expect(data[i].data.mcc).assertEqual(CELL_MCC); expect(true).assertTrue();
} else if (data[i].networkType === radio.NETWORK_TYPE_TDSCDMA) { console.log(`Telephony_NetworkSearch_NetworkState_Promise_0200 test finish.`);
expect(data[i].data.baseId >= CELL_INFO_MIN && data[i].data.baseId <= CELL_LAC_TAC_MAX).assertTrue(); } catch (error) {
expect(data[i].data.latitude >= CELL_INFO_MIN && data[i].data.latitude <= CELL_GSM_CELLID_MAX).assertTrue(); console.log(`Telephony_NetworkSearch_NetworkState_Promise_0200 error: ${error.message}`);
expect(data[i].data.longitude >= CELL_INFO_MIN && data[i].data.longitude <= CELL_ARFCN_MAX).assertTrue(); expect().assertFail();
expect(data[i].data.bsic >= CELL_INFO_MIN && data[i].data.bsic <= CELL_BSIC_MAX).assertTrue(); }
expect(data[i].data.nid >= CELL_INFO_MIN && data[i].data.nid <= CELL_MNC_MAX).assertTrue(); done();
expect(data[i].data.mcc).assertEqual(CELL_MCC); })
} else if (data[i].networkType === radio.NETWORK_TYPE_NR) {
expect(data[i].data.nrArfcn >= CELL_INFO_MIN && data[i].data.nrArfcn <= CELL_LAC_TAC_MAX).assertTrue();
expect(data[i].data.tac >= CELL_INFO_MIN && data[i].data.tac <= CELL_GSM_CELLID_MAX).assertTrue(); /**
expect(data[i].data.nci >= CELL_INFO_MIN && data[i].data.nci <= CELL_ARFCN_MAX).assertTrue(); * @tc.number Telephony_Radio_CdmaCellInformation_sid_0100
expect(data[i].data.mcc).assertEqual(CELL_MCC); * @tc.name sid
} else { * @tc.desc sid test
expect().assertFail(); */
} it('Telephony_Radio_CdmaCellInformation_sid_0100', 0, async function (done) {
console.log("-----------------------Telephony_Radio_CdmaCellInformation_sid_0100 start-----------------------");
} if (utils.notCheck) {
} expect(true).assertTrue();
}) done();
} return;
}
let cdmaCellInformatio = {
baseId: 1,
latitude: 39,
longitude: 116,
nid: 101,
sid: 102
}
expect(101).assertEqual(cdmaCellInformatio.nid);
expect(102).assertEqual(cdmaCellInformatio.sid);
console.log("-----------------------Telephony_Radio_CdmaCellInformation_sid_0100 end-----------------------");
})
/**
* @tc.number Telephony_NetworkSearch_getRadioTech_Async_0500
* @tc.name TestGetRadioTech_500
* @tc.desc Test getRadioTech() api by callback, SlotId parameter input is 0
*/
it('Telephony_NetworkSearch_getRadioTech_Async_0500', 0, async function (done) {
radio.getRadioTech(0, (err, data) => {
if (err) {
console.log(`Telephony_NetworkSearch_getRadioTech_Async_0500 fail err: ${err}`);
expect().assertFail();
done();
return;
}
console.log(`Telephony_NetworkSearch_getRadioTech_Async_0500 success ${data}`);
expect(true).assertTrue();
done();
});
});
/**
* @tc.number Telephony_NetworkSearch_getRadioTech_Async_0600
* @tc.name testGetRadioTech_0600
* @tc.desc SlotId parameter input is 0, test getRadioTech() api by promise.
*/
it('Telephony_NetworkSearch_getRadioTech_Promise_0500', 0, async function (done) {
try {
let data = await radio.getRadioTech(0);
console.log('Telephony_NetworkSearch_getRadioTech_Promise_0500 success');
expect(true).assertTrue();
} catch (err) {
console.log(`Telephony_NetworkSearch_getRadioTech_Promise_0500 fail err: ${err}`);
expect().assertFail();
done();
return;
}
done();
});
/**
* @tc.number Telephony_NetworkSearch_getNetworkSelectionMode_Async_0600
* @tc.name testGetNetworkSelectionMode_0600
* @tc.desc SlotId parameter input is 0, test getNetworkSelectionMode() api by callback.
*/
it('Telephony_NetworkSearch_getNetworkSelectionMode_Async_0600', 0, async function (done) {
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
radio.getNetworkSelectionMode(0, (err, res) => {
if (err) {
console.log(`Telephony_NetworkSearch_getNetworkSelectionMode_Async_0600 err: ${err}`);
expect().assertFail();
done();
} else {
console.log('Telephony_NetworkSearch_getNetworkSelectionMode_Async_0600 pass ${res}');
expect(true).assertTrue();
done();
}
});
});
/**
* @tc.number Telephony_NetworkSearch_getNetworkSelectionMode_Async_0700
* @tc.name testGetNetworkSelectionMode_0700
* @tc.desc SlotId parameter input is 0, test getNetworkSelectionMode() api by promise.
*/
it('Telephony_NetworkSearch_getNetworkSelectionMode_Promise_0600', 0, async function (done) {
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
try {
await radio.getNetworkSelectionMode(0);
console.log('Telephony_NetworkSearch_getNetworkSelectionMode_Promise_0600 pass');
expect(true).assertTrue();
} catch (err) {
console.log('Telephony_NetworkSearch_getNetworkSelectionMode_Promise_0600 fail: ${err}');
expect().assertFail();
done();
return;
}
done();
});
/**
* @tc.number Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500
* @tc.name testGetISOCountryCodeForNetwork_0500
* @tc.desc SlotId parameter input is 0, test getISOCountryCodeForNetwork() api by callback.
*/
it('Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500', 0, async function (done) {
radio.getISOCountryCodeForNetwork(0, (err, data) => {
if (err) {
console.log(`Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500 fail err: ${err}`);
expect().assertFail();
done();
return;
}
console.log(
`Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500 finish data: ${JSON.stringify(data)}`);
expect(true).assertTrue();
done();
});
});
/**
* @tc.number Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0600
* @tc.name testGetISOCountryCodeForNetwork_0600
* @tc.desc SlotId parameter input is 0, test getISOCountryCodeForNetwork() api by promise.
*/
it('Telephony_NetworkSearch_getISOCountryCodeForNetwork_Promise_0500', 0, async function (done) {
try {
let data = await radio.getISOCountryCodeForNetwork(0);
console.log(
`Telephony_NetworkSearch_getISOCountryCodeForNetwork_Promise_0500 finish data:${JSON.stringify(data)}`);
expect(true).assertTrue();
} catch (err) {
console.log(`Telephony_NetworkSearch_getISOCountryCodeForNetwork_Promise_0500 fail err: ${err}`);
expect().assertFail();
done();
return;
}
done();
});
/**
* @tc.number Telephony_NetworkSearch_getSignalInformation_Async_0500
* @tc.name testGetSignalInformation_0500
* @tc.desc SlotId parameter input is 0, test getSignalInformation() api by callback.
*/
it('Telephony_NetworkSearch_getSignalInformation_Async_0500', 0, async function (done) {
radio.getSignalInformation(0, (err, data) => {
if (err) {
console.log(`Telephony_NetworkSearch_getSignalInformation_Async_0500 fail err: ${err}`);
expect().assertFail();
done();
return;
}
console.log(`Telephony_NetworkSearch_getSignalInformation_Async_0500 finish data: ${JSON.stringify(data)}`);
expect(true).assertTrue();
done();
});
});
/**
* @tc.number Telephony_NetworkSearch_getSignalInformation_Async_0600
* @tc.name testGetSignalInformation_0600
* @tc.desc SlotId parameter input is 0, test getSignalInformation() api by promise.
*/
it('Telephony_NetworkSearch_getSignalInformation_Promise_0500', 0, async function (done) {
try {
let data = await radio.getSignalInformation(0);
console.log(
`Telephony_NetworkSearch_getSignalInformation_Promise_0500 pass data: ${JSON.stringify(data)}`);
expect(true).assertTrue();
} catch (err) {
console.log(`Telephony_NetworkSearch_getSignalInformation_Promise_0500 fail err: ${err}`);
expect().assertFail();
done();
return;
}
done();
});
console.log("************* radio Test end*************");
function assertCellInformation(data) {
expect(data !== '' && data != undefined && data != null).assertTrue();
expect(data.length).assertLarger(0);
for (let i = 0; i < data.length; i++) {
expect(NETWORK_TYPES).assertContain(data[i].networkType);
expect(data[i].isCamped).assertTrue();
expect(data[i].timeStamp).assertLarger(0);
expect(NETWORK_TYPES).assertContain(data[i].signalInformation.signalType);
expect(NETWORK_SIGNAL).assertContain(data[i].signalInformation.signalLevel);
expect(data[i].data != undefined && data[i].data != '' && data[i].data != null).assertTrue();
if (data[0].networkType === radio.NETWORK_TYPE_LTE) {
expect(data[i].data.tac >= CELL_INFO_MIN && data[i].data.tac <= CELL_LAC_TAC_MAX).assertTrue();
expect(data[i].data.cgi >= CELL_INFO_MIN && data[i].data.cgi <= CELL_CELLID_MAX).assertTrue();
expect(data[i].data.earfcn >= CELL_INFO_MIN && data[i].data.earfcn <= CELL_EARFCN_MAX).assertTrue();
expect(data[i].data.pci >= CELL_INFO_MIN && data[i].data.pci <= CELL_PCI_MAX).assertTrue();
expect(data[i].data.mnc >= CELL_INFO_MIN && data[i].data.mnc <= CELL_MNC_MAX).assertTrue();
expect(data[i].data.bandwidth >= CELL_INFO_MIN && data[i].data.bandwidth <= CELL_MNC_MAX).assertTrue();
expect(data[i].data.isSupportEndc >= CELL_INFO_MIN && data[i].data.isSupportEndc <= CELL_MNC_MAX).assertTrue();
expect(data[i].data.mcc).assertEqual(CELL_MCC);
} else if (data[i].networkType === radio.NETWORK_TYPE_WCDMA) {
expect(data[i].data.lac >= CELL_INFO_MIN && data[i].data.lac <= CELL_LAC_TAC_MAX).assertTrue();
expect(data[i].data.cellId >= CELL_INFO_MIN && data[i].data.cellId <= CELL_CELLID_MAX).assertTrue();
expect(data[i].data.uarfcn >= CELL_INFO_MIN && data[i].data.uarfcn <= CELL_ARFCN_MAX).assertTrue();
expect(data[i].data.psc >= CELL_INFO_MIN && data[i].data.psc <= CELL_PSC_MAX).assertTrue();
expect(data[i].data.mnc >= CELL_INFO_MIN && data[i].data.mnc <= CELL_MNC_MAX).assertTrue();
expect(data[i].data.cpid >= CELL_INFO_MIN && data[i].data.cpid <= CELL_MNC_MAX).assertTrue();
expect(data[i].data.mcc).assertEqual(CELL_MCC);
} else if (data[i].networkType === radio.NETWORK_TYPE_GSM) {
expect(data[i].data.lac >= CELL_INFO_MIN && data[i].data.lac <= CELL_LAC_TAC_MAX).assertTrue();
expect(data[i].data.cellId >= CELL_INFO_MIN && data[i].data.cellId <= CELL_GSM_CELLID_MAX).assertTrue();
expect(data[i].data.arfcn >= CELL_INFO_MIN && data[i].data.arfcn <= CELL_ARFCN_MAX).assertTrue();
expect(data[i].data.bsic >= CELL_INFO_MIN && data[i].data.bsic <= CELL_BSIC_MAX).assertTrue();
expect(data[i].data.mnc >= CELL_INFO_MIN && data[i].data.mnc <= CELL_MNC_MAX).assertTrue();
expect(data[i].data.mcc).assertEqual(CELL_MCC);
} else if (data[i].networkType === radio.NETWORK_TYPE_TDSCDMA) {
expect(data[i].data.baseId >= CELL_INFO_MIN && data[i].data.baseId <= CELL_LAC_TAC_MAX).assertTrue();
expect(data[i].data.latitude >= CELL_INFO_MIN && data[i].data.latitude <= CELL_GSM_CELLID_MAX).assertTrue();
expect(data[i].data.longitude >= CELL_INFO_MIN && data[i].data.longitude <= CELL_ARFCN_MAX).assertTrue();
expect(data[i].data.bsic >= CELL_INFO_MIN && data[i].data.bsic <= CELL_BSIC_MAX).assertTrue();
expect(data[i].data.nid >= CELL_INFO_MIN && data[i].data.nid <= CELL_MNC_MAX).assertTrue();
expect(data[i].data.mcc).assertEqual(CELL_MCC);
} else if (data[i].networkType === radio.NETWORK_TYPE_NR) {
expect(data[i].data.nrArfcn >= CELL_INFO_MIN && data[i].data.nrArfcn <= CELL_LAC_TAC_MAX).assertTrue();
expect(data[i].data.tac >= CELL_INFO_MIN && data[i].data.tac <= CELL_GSM_CELLID_MAX).assertTrue();
expect(data[i].data.nci >= CELL_INFO_MIN && data[i].data.nci <= CELL_ARFCN_MAX).assertTrue();
expect(data[i].data.mcc).assertEqual(CELL_MCC);
} else {
expect().assertFail();
}
}
}
})
}
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 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
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'hypium/index'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets";
import mms from '@ohos.telephony.sms'; import mms from '@ohos.telephony.sms';
import utils from './Utils.ets' import utils from './Utils.ets'
export default function smsUiJsunit() { export default function smsUiJsunit() {
describe('appInfoTest', function () { describe('appInfoTest', function () {
const SMS_SEND_DST_NUMBER = ''; const SMS_SEND_DST_NUMBER = '';
const TRUE_SLOT_ID = 0; const TRUE_SLOT_ID = 0;
const FALSE_SLOT_ID = 9; const FALSE_SLOT_ID = 9;
const OTHER_SLOT_ID = 1; const OTHER_SLOT_ID = 1;
const SECOND_SLOT_ID = 2; const SECOND_SLOT_ID = 2;
const IDENTIFIER_MIN = 0; const IDENTIFIER_MIN = 0;
const IDENTIFIER_MAX = 0xFFFF; const IDENTIFIER_MAX = 0xFFFF;
const RANTYPE_GSM = 1; const RANTYPE_GSM = 1;
const RANTYPE_CDMA = 2; const RANTYPE_CDMA = 2;
const RANTYPE_ERROR = 3; const RANTYPE_ERROR = 3;
var rawArray = [ var rawArray = [
0x08, 0x91, 0x68, 0x31, 0x08, 0x20, 0x00, 0x75, 0xF4, 0x24, 0x0D, 0x91, 0x08, 0x91, 0x68, 0x31, 0x08, 0x20, 0x00, 0x75, 0xF4, 0x24, 0x0D, 0x91,
0x68, 0x81, 0x29, 0x56, 0x29, 0x83, 0xF6, 0x00, 0x00, 0x12, 0x40, 0x80, 0x68, 0x81, 0x29, 0x56, 0x29, 0x83, 0xF6, 0x00, 0x00, 0x12, 0x40, 0x80,
0x01, 0x02, 0x14, 0x23, 0x02, 0xC1, 0x30 0x01, 0x02, 0x14, 0x23, 0x02, 0xC1, 0x30
] ]
/* /*
* @tc.number Telephony_SmsMms_createMessage_Async_0100 * @tc.number Telephony_SmsMms_createMessage_Async_0100
* @tc.name Call interface CreateMessage, * @tc.name Call interface CreateMessage,
* pass in the PDU(rawArray) in line with the coding specification, the specification is 3GPP, * pass in the PDU(rawArray) in line with the coding specification, the specification is 3GPP,
* shortMessage Don't empty * shortMessage Don't empty
* @tc.desc Function test * @tc.desc Function test
*/ */
it('Telephony_SmsMms_createMessage_Async_0100', 0, async function (done) { it('Telephony_SmsMms_createMessage_Async_0100', 0, async function (done) {
if (true) { if (true) {
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
return; return;
} }
sms.createMessage(rawArray, '3gpp', (err, shortMessage) => { sms.createMessage(rawArray, '3gpp', (err, shortMessage) => {
if (err) { if (err) {
expect().assertFail(); expect().assertFail();
console.log('Telephony_SmsMms_createMessage_Async_0100 fail'); console.log('Telephony_SmsMms_createMessage_Async_0100 fail');
done(); done();
return; return;
} }
expect(shortMessage.visibleMessageBody === MESSAGEBODY).assertTrue(); expect(shortMessage.visibleMessageBody === MESSAGEBODY).assertTrue();
expect(shortMessage.visibleRawAddress.length === ADDR_LENGTH).assertTrue(); expect(shortMessage.visibleRawAddress.length === ADDR_LENGTH).assertTrue();
expect(shortMessage.messageClass === sms.FORWARD_MESSAGE).assertTrue(); expect(shortMessage.messageClass === sms.FORWARD_MESSAGE).assertTrue();
expect(shortMessage.protocolId === 0).assertTrue(); expect(shortMessage.protocolId === 0).assertTrue();
expect(shortMessage.scAddress.length === ADDR_LENGTH).assertTrue(); expect(shortMessage.scAddress.length === ADDR_LENGTH).assertTrue();
expect(shortMessage.scTimestamp === SC_TIMESTAMP).assertTrue(); expect(shortMessage.scTimestamp === SC_TIMESTAMP).assertTrue();
expect(shortMessage.isReplaceMessage).assertFalse(); expect(shortMessage.isReplaceMessage).assertFalse();
expect(shortMessage.hasReplyPath).assertFalse(); expect(shortMessage.hasReplyPath).assertFalse();
expect(shortMessage.pdu.length > 0).assertTrue(); expect(shortMessage.pdu.length > 0).assertTrue();
expect(shortMessage.status === 0).assertTrue(); expect(shortMessage.status === 0).assertTrue();
expect(shortMessage.isSmsStatusReportMessage).assertTrue(); expect(shortMessage.isSmsStatusReportMessage).assertTrue();
console.log('Telephony_SmsMms_createMessage_Async_0100 finish'); console.log('Telephony_SmsMms_createMessage_Async_0100 finish');
done(); done();
}); });
}); });
/*
* @tc.number Telephony_SmsMms_createMessage_Async_0300
* @tc.name testCreateMessage_0300
/* * @tc.desc Call interface CreateMessage,
* @tc.number Telephony_SmsMms_getSmsEncodingScheme_Async_0100 * pass in the PDU(rawArray) in line with the coding specification, the specification is 3GPP,
* @tc.name * shortMessage Don't empty
* @tc.desc Function test */
*/ it('Telephony_SmsMms_createMessage_Promise_0100', 0, async function (done) {
it('Telephony_SmsMms_getSmsEncodingScheme_Async_0100', 0, async function (done) { if (true) {
if (true) { expect(true).assertTrue();
expect(true).assertTrue(); done();
done(); return;
return; }
} sms.createMessage(rawArray, '3gpp').then(shortMessage => {
expect(sms.SMS_ENCODING_UNKNOWN == 0).assertTrue(); expect(shortMessage.visibleMessageBody === MESSAGEBODY).assertTrue();
expect(sms.SMS_ENCODING_7BIT == 1).assertTrue(); expect(shortMessage.visibleRawAddress.length === ADDR_LENGTH).assertTrue();
expect(sms.SMS_ENCODING_8BIT == 2).assertTrue(); expect(shortMessage.messageClass === sms.FORWARD_MESSAGE).assertTrue();
expect(sms.SMS_ENCODING_16BIT == 3).assertTrue(); expect(shortMessage.protocolId === 0).assertTrue();
done(); expect(shortMessage.scAddress.length === ADDR_LENGTH).assertTrue();
}); expect(shortMessage.scTimestamp === SC_TIMESTAMP).assertTrue();
expect(shortMessage.isReplaceMessage).assertFalse();
/* expect(shortMessage.hasReplyPath).assertFalse();
* @tc.number Telephony_SmsMms_getSendSmsResult_Async_0100 expect(shortMessage.pdu.length > 0).assertTrue();
* @tc.name expect(shortMessage.status === 0).assertTrue();
* @tc.desc Function test expect(shortMessage.isSmsStatusReportMessage).assertTrue();
*/ console.log('Telephony_SmsMms_createMessage_Promise_0100 finish');
it('Telephony_SmsMms_getSendSmsResult_Async_0100', 0, async function (done) { done();
if (true) { }).catch(err => {
expect(true).assertTrue(); expect().assertFail();
done(); console.log('Telephony_SmsMms_createMessage_Promise_0100 fail');
return; done();
} return;
expect(sms.SEND_SMS_FAILURE_RADIO_OFF == 0).assertTrue(); });
expect(sms.SEND_SMS_FAILURE_SERVICE_UNAVAILABLE == 1).assertTrue(); });
expect(sms.SIM_MESSAGE_STATUS_FREE == 0).assertTrue();
expect(sms.INSTANT_MESSAGE == 1).assertTrue();
expect(sms.OPTIONAL_MESSAGE == 2).assertTrue(); /*
done(); * @tc.number Telephony_SmsMms_getSmsEncodingScheme_Async_0100
}); * @tc.name
* @tc.desc Function test
/* */
* @tc.number Telephony_SmsMms_ShortMessageClass_Async_0100 it('Telephony_SmsMms_getSmsEncodingScheme_Async_0100', 0, async function (done) {
* @tc.name if (true) {
* @tc.desc Function test expect(true).assertTrue();
*/ done();
it('Telephony_SmsMms_ShortMessageClass_Async_0100', 0, async function (done) { return;
if (true) { }
expect(true).assertTrue(); expect(sms.SMS_ENCODING_UNKNOWN == 0).assertTrue();
done(); expect(sms.SMS_ENCODING_7BIT == 1).assertTrue();
return; expect(sms.SMS_ENCODING_8BIT == 2).assertTrue();
} expect(sms.SMS_ENCODING_16BIT == 3).assertTrue();
expect(sms.SIM_MESSAGE_STATUS_FREE == 0).assertTrue(); done();
expect(sms.INSTANT_MESSAGE == 1).assertTrue(); });
expect(sms.OPTIONAL_MESSAGE == 2).assertTrue();
done(); /*
}); * @tc.number Telephony_SmsMms_getSendSmsResult_Async_0100
/* * @tc.name
* @tc.number Telephony_SmsMms_getMmsCharSets_Async_0100 * @tc.desc Function test
* @tc.name */
* @tc.desc Function test it('Telephony_SmsMms_getSendSmsResult_Async_0100', 0, async function (done) {
*/ if (true) {
it('Telephony_SmsMms_getMmsCharSets_Async_0100', 0, async function (done) { expect(true).assertTrue();
if (true) { done();
expect(true).assertTrue(); return;
done(); }
return; expect(sms.SEND_SMS_FAILURE_RADIO_OFF == 0).assertTrue();
} expect(sms.SEND_SMS_FAILURE_SERVICE_UNAVAILABLE == 1).assertTrue();
expect(sms.BIG5 == 0X07EA).assertTrue(); expect(sms.SIM_MESSAGE_STATUS_FREE == 0).assertTrue();
expect(sms.ISO_10646_UCS_2 == 0X03E8).assertTrue(); expect(sms.INSTANT_MESSAGE == 1).assertTrue();
expect(sms.ISO_8859_1 == 0X04).assertTrue(); expect(sms.OPTIONAL_MESSAGE == 2).assertTrue();
expect(sms.ISO_8859_2 == 0X05).assertTrue(); done();
expect(sms.ISO_8859_3 == 0X06).assertTrue(); });
expect(sms.ISO_8859_4 == 0X07).assertTrue();
expect(sms.ISO_8859_5 == 0X08).assertTrue(); /*
expect(sms.ISO_8859_6 == 0X09).assertTrue(); * @tc.number Telephony_SmsMms_ShortMessageClass_Async_0100
expect(sms.ISO_8859_7 == 0X10).assertTrue(); * @tc.name
expect(sms.ISO_8859_8 == 0X12).assertTrue(); * @tc.desc Function test
expect(sms.ISO_8859_9 == 0X13).assertTrue(); */
expect(sms.SHIFT_JIS == 0X11).assertTrue(); it('Telephony_SmsMms_ShortMessageClass_Async_0100', 0, async function (done) {
expect(sms.US_ASCII == 0X03).assertTrue(); if (true) {
expect(sms.UTF_8 == 0X6A).assertTrue(); expect(true).assertTrue();
done(); done();
}); return;
}) }
} expect(sms.SIM_MESSAGE_STATUS_FREE == 0).assertTrue();
expect(sms.INSTANT_MESSAGE == 1).assertTrue();
expect(sms.OPTIONAL_MESSAGE == 2).assertTrue();
done();
});
/*
* @tc.number Telephony_SmsMms_getMmsCharSets_Async_0100
* @tc.name
* @tc.desc Function test
*/
it('Telephony_SmsMms_getMmsCharSets_Async_0100', 0, async function (done) {
if (true) {
expect(true).assertTrue();
done();
return;
}
expect(sms.BIG5 == 0X07EA).assertTrue();
expect(sms.ISO_10646_UCS_2 == 0X03E8).assertTrue();
expect(sms.ISO_8859_1 == 0X04).assertTrue();
expect(sms.ISO_8859_2 == 0X05).assertTrue();
expect(sms.ISO_8859_3 == 0X06).assertTrue();
expect(sms.ISO_8859_4 == 0X07).assertTrue();
expect(sms.ISO_8859_5 == 0X08).assertTrue();
expect(sms.ISO_8859_6 == 0X09).assertTrue();
expect(sms.ISO_8859_7 == 0X10).assertTrue();
expect(sms.ISO_8859_8 == 0X12).assertTrue();
expect(sms.ISO_8859_9 == 0X13).assertTrue();
expect(sms.SHIFT_JIS == 0X11).assertTrue();
expect(sms.US_ASCII == 0X03).assertTrue();
expect(sms.UTF_8 == 0X6A).assertTrue();
done();
});
})
}
...@@ -511,4 +511,5 @@ describe('SimManagerTest', function () { ...@@ -511,4 +511,5 @@ describe('SimManagerTest', function () {
} }
done(); 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,48 +35,413 @@ describe('userAuthTest', function () { ...@@ -35,48 +35,413 @@ 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");
}) })
/** /**
* @tc.name execute_authentication_callback_Type_is_null * @tc.name execute_authentication_callback_Type_is_null
* @tc.number JSAPI_Function_Execute_1800 * @tc.number JSAPI_Function_Execute_1800
...@@ -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 == 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.
先完成此消息的编辑!
想要评论请 注册