diff --git a/aafwk/aafwk_standard/actsabilitydistributetest/src/main/js/default/test/FeatureAbilityDistribute.test.js b/aafwk/aafwk_standard/actsabilitydistributetest/src/main/js/default/test/FeatureAbilityDistribute.test.js index 0de076cda0aa3f0ae3489c0a78f2d2478815b5b5..c5e0a48335a83c408383495e188b89ccb0decce6 100644 --- a/aafwk/aafwk_standard/actsabilitydistributetest/src/main/js/default/test/FeatureAbilityDistribute.test.js +++ b/aafwk/aafwk_standard/actsabilitydistributetest/src/main/js/default/test/FeatureAbilityDistribute.test.js @@ -19,162 +19,234 @@ import abilityFeatureAbility from '@ohos.ability.featureAbility' var timeSleep = 3000; -describe('DistributedTest', function(){ +describe('DistributedTest', function () { function sleep(time) { return new Promise((resolve) => setTimeout(resolve, time)); } - /** - * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0300 - * @tc.name testContinueAbility0300 - * @tc.desc T + * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0200 + * @tc.name testContinueAbility0200 + * @tc.desc T (by callback) * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 3 */ - it('testContinueAbility0300', 0, async function (done) { - console.log('testContinueAbility0300 run start'); + it('testContinueAbility0200', 0, async function (done) { + console.log('testContinueAbility0200 run start'); abilityFeatureAbility.continueAbility(undefined, (err, data) => { - console.log('testContinueAbility0300 err is :' + JSON.stringify(err) + ', value is :' - + JSON.stringify(data)); + console.log('testContinueAbility0200 err is :' + JSON.stringify(error)); + console.log('testContinueAbility0200 value is :' + JSON.stringify(data)); }) await sleep(timeSleep); - console.log('testContinueAbility0300 run end'); + console.log('testContinueAbility0200 run end'); done(); - }) + }) /** * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0400 - * @tc.name testContinueAbility0200 - * @tc.desc T + * @tc.name testContinueAbility0400 + * @tc.desc T (by callback) * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 3 */ - it('testContinueAbility0400', 0, async function (done) { + it('testContinueAbility0400', 0, async function (done) { console.log('testContinueAbility0400 run start'); abilityFeatureAbility.continueAbility("", (err, data) => { - console.log('testContinueAbility0400 err is :' + JSON.stringify(err) + ', value is :' - + JSON.stringify(data)); + console.log('testContinueAbility0400 err is :' + JSON.stringify(err)); + console.log('testContinueAbility0400 value is :' + JSON.stringify(data)); }) await sleep(timeSleep); console.log('testContinueAbility0400 run end'); done(); - }) + }) /** - * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0500 - * @tc.name testContinueAbility0500 - * @tc.desc T + * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0600 + * @tc.name testContinueAbility0600 + * @tc.desc T (by callback) * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 3 */ - it('testContinueAbility0500', 0, async function (done) { + it('testContinueAbility0600', 0, async function (done) { let options = { - deviceId : undefined, - reversible : false, + deviceId: undefined, + reversible: false, } - console.log('testContinueAbility0500 run start'); + console.log('testContinueAbility0600 run start'); abilityFeatureAbility.continueAbility(options, (err, data) => { - console.log('testContinueAbility0500 err is :' + JSON.stringify(err) + ', value is :' - + JSON.stringify(data)); + console.log('testContinueAbility0600 err is :' + JSON.stringify(err)); + console.log('testContinueAbility0600 value is :' + JSON.stringify(data)); }) await sleep(timeSleep); - console.log('testContinueAbility0500 run end'); + console.log('testContinueAbility0600 run end'); done(); - }) + }) /** - * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0600 - * @tc.name testContinueAbility0600 - * @tc.desc T + * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0700 + * @tc.name testContinueAbility0700 + * @tc.desc T (by promise) * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 3 */ - it('testContinueAbility0600', 0, async function (done) { + it('testContinueAbility0700', 0, async function (done) { let options = { - deviceId : "", - reversible : false, + deviceId: "", + reversible: false, } - console.log('testContinueAbility0600 run start'); - abilityFeatureAbility.continueAbility(options, (err, data) => { - console.log('testContinueAbility0600 err is :' + JSON.stringify(err) + ', value is :' - + JSON.stringify(data)); + console.log('testContinueAbility0700 run start'); + abilityFeatureAbility.continueAbility(options).then((data) => { + console.log('testContinueAbility0700 value is :' + JSON.stringify(data)); + }).catch((error) => { + console.log('testContinueAbility0700 err is :' + JSON.stringify(error)); }) await sleep(timeSleep); - console.log('testContinueAbility0600 run end'); + console.log('testContinueAbility0700 run end'); done(); - }) + }) /** - * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0700 - * @tc.name testContinueAbility0700 - * @tc.desc T + * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0800 + * @tc.name testContinueAbility0800 + * @tc.desc T (by callback) * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 3 */ - it('testContinueAbility0700', 0, async function (done) { + it('testContinueAbility0800', 0, async function (done) { let options = { - reversible : false, + deviceId: "", + reversible: false, } - console.log('testContinueAbility0700 run start'); + console.log('testContinueAbility0800 run start'); abilityFeatureAbility.continueAbility(options, (err, data) => { - console.log('testContinueAbility0700 err is :' + JSON.stringify(err) + ', value is :' - + JSON.stringify(data)); + console.log('testContinueAbility0800 err is :' + JSON.stringify(err)); + console.log('testContinueAbility0800 value is :' + JSON.stringify(data)); }) await sleep(timeSleep); - console.log('testContinueAbility0700 run end'); + console.log('testContinueAbility0800 run end'); done(); - }) + }) /** - * @tc.number SUB_AA_OpenHarmony_ContinueAbility_0900 - * @tc.name testContinueAbility0900 - * @tc.desc T + * @tc.number SUB_AA_OpenHarmony_ContinueAbility_1000 + * @tc.name testContinueAbility1000 + * @tc.desc T (by callback) * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 3 */ - it('testContinueAbility0900', 0, async function (done) { + it('testContinueAbility1000', 0, async function (done) { let options = { - deviceId : "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26", - reversible : false, + reversible: false, } - console.log('testContinueAbility0900 run start'); + console.log('testContinueAbility1000 run start'); abilityFeatureAbility.continueAbility(options, (err, data) => { - console.log('testContinueAbility0900 err is :' + JSON.stringify(err) + ', value is :' - + JSON.stringify(data)); + console.log('testContinueAbility1000 err is :' + JSON.stringify(err)); + console.log('testContinueAbility1000 value is :' + JSON.stringify(data)); }) await sleep(timeSleep); - console.log('testContinueAbility0900 run end'); + console.log('testContinueAbility1000 run end'); done(); - }) + }) - /** - * @tc.number SUB_AA_OpenHarmony_ContinueAbility_1000 - * @tc.name testContinueAbility0900 - * @tc.desc T + /** + * @tc.number SUB_AA_OpenHarmony_ContinueAbility_1100 + * @tc.name testContinueAbility1100 + * @tc.desc T (by promise) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('testContinueAbility1100', 0, async function (done) { + let options = { + deviceId: "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26", + reversible: false, + } + console.log('testContinueAbility1100 run start'); + abilityFeatureAbility.continueAbility(options).then((data) => { + console.log('testContinueAbility1100 value is :' + JSON.stringify(data)); + }).catch((error) => { + console.log('testContinueAbility1100 err is :' + JSON.stringify(error)); + }) + await sleep(timeSleep); + console.log('testContinueAbility1100 run end'); + done(); + }) + + /** + * @tc.number SUB_AA_OpenHarmony_ContinueAbility_1200 + * @tc.name testContinueAbility1200 + * @tc.desc T (by callback) * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 3 */ - it('testContinueAbility1000', 0, async function (done) { + it('testContinueAbility1200', 0, async function (done) { + let options = { + deviceId: "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26", + reversible: false, + } + console.log('testContinueAbility1200 run start'); + abilityFeatureAbility.continueAbility(options, (err, data) => { + console.log('testContinueAbility1200 err is :' + JSON.stringify(err)); + console.log('testContinueAbility1200 value is :' + JSON.stringify(data)); + }) + await sleep(timeSleep); + console.log('testContinueAbility1200 run end'); + done(); + }) + + /** + * @tc.number SUB_AA_OpenHarmony_ContinueAbility_1300 + * @tc.name testContinueAbility1300 + * @tc.desc T (by promise) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('testContinueAbility1300', 0, async function (done) { let options = { - deviceId : "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26", - reversible : false, + deviceId: "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26", + reversible: false, } - for(var i = 0; i < 10; i++) { + for (var i = 0; i < 10; i++) { + abilityFeatureAbility.continueAbility(options).then((data) => { + console.log('testContinueAbility1300 value is :' + JSON.stringify(data)); + }).catch((error) => { + console.log('testContinueAbility1300 err is :' + JSON.stringify(error)); + }) + } + await sleep(timeSleep); + console.log('testContinueAbility1300 run end'); + done(); + }) + + /** + * @tc.number SUB_AA_OpenHarmony_ContinueAbility_1400 + * @tc.name testContinueAbility1400 + * @tc.desc T (by callback) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('testContinueAbility1400', 0, async function (done) { + let options = { + deviceId: "2BB6F91131F74C1174904195FE72B6068F8F82280F6CE93BDFE0EFF9B37F9DD26", + reversible: false, + } + for (var i = 0; i < 10; i++) { abilityFeatureAbility.continueAbility(options, (err, data) => { - console.log('testContinueAbility1000 err is :' + JSON.stringify(err) + ', value is :' + console.log('testContinueAbility1400 err is :' + JSON.stringify(err) + ', value is :' + JSON.stringify(data)); }) } await sleep(timeSleep); - console.log('testContinueAbility1000 run end'); + console.log('testContinueAbility1400 run end'); done(); - }) + }) }) \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsdataabilityjs/entry/src/main/js/test/ActsDataAbilityJsTest.test.js b/aafwk/aafwk_standard/actsdataabilityjs/entry/src/main/js/test/ActsDataAbilityJsTest.test.js index 9f6241a458312f1d3ded4ea11294580889df8d40..de8adfb92abdfe4783971fbd7ccc828b5bc7b244 100644 --- a/aafwk/aafwk_standard/actsdataabilityjs/entry/src/main/js/test/ActsDataAbilityJsTest.test.js +++ b/aafwk/aafwk_standard/actsdataabilityjs/entry/src/main/js/test/ActsDataAbilityJsTest.test.js @@ -62,7 +62,7 @@ afterAll((done) => { done(); }, gSetTimeout); }) - + /* * @tc.number: ACTS_AfeatureAbilityEnum_0100 * @tc.name: Enum the client resource of the Data ability. @@ -74,7 +74,7 @@ it('ACTS_AfeatureAbilityEnum_0100', 0, async function (done) { expect(featureAbility.ContinuationState.LOCAL_RUNNING).assertEqual(0); expect(featureAbility.ContinuationState.REMOTE_RUNNING).assertEqual(1); expect(featureAbility.ContinuationState.REPLICA_RUNNING).assertEqual(2); - + expect(abilityManager.ProcessErrCode.NO_ERROR).assertEqual(0); expect(abilityManager.ProcessErrCode.CRASHED).assertEqual(1); expect(abilityManager.ProcessErrCode.NO_RESPONSE).assertEqual(2); @@ -750,11 +750,10 @@ it("ACTS_Call_0100", 0, async function (done) { console.log('ACTS_Call_0100 end......'); }) - /* * @tc.number: ACTS_Call_0200 * @tc.name: call : Queries data in the database. - * @tc.desc: Check the return value of the interface + * @tc.desc: Check the return value of the interface (by promise) * @tc.level 0 */ it("ACTS_Call_0200", 0, async function (done) { @@ -768,13 +767,12 @@ it("ACTS_Call_0200", 0, async function (done) { try { rDAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri); console.debug('ACTS_AbeforeAll rDAHelper ====>: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper)); - rDAHelper.call(dataAbilityUri, 'query', arg, pacMap, (err, data) => { - if (err) { - console.error('ACTS_Call_0200 error: ' + JSON.stringify(err)); - } else { - console.info('ACTS_Call_0200 succeeded: ' + JSON.stringify(data)); - } + rDAHelper.call(dataAbilityUri, 'query', arg, pacMap).then((data) => { + console.info('ACTS_Call_0200 succeeded data: ' + JSON.stringify(data)); + }).catch((error) => { + console.error('ACTS_Call_0200 error: ' + JSON.stringify(error)); }); + done(); } catch (err) { console.error('ACTS_Call_0200 catch(err)====>:' + err); console.log('ACTS_Call_0200====: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper)); - rDAHelper.call(dataAbilityUri, 'update', arg, pacMap, (err, data) => { - if (err) { - console.error('ACTS_Call_0300 error: ' + JSON.stringify(err)); - } else { - console.info('ACTS_Call_0300 succeeded: ' + JSON.stringify(data)); - } + rDAHelper.call(dataAbilityUri, 'update', arg, pacMap).then((data) => { + console.info('ACTS_Call_0300 succeeded data: ' + JSON.stringify(data)); + }).catch((error) => { + console.error('ACTS_Call_0300 error: ' + JSON.stringify(error)); }); + done(); } catch (err) { console.error('ACTS_Call_0300 catch(err)====>:' + err); console.log('ACTS_Call_0300====: ' + 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====: ' + 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====: ' + 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====: ' + 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====: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper)); rDAHelper.call(dataAbilityUri, 'delete', arg, pacMap, (err, data) => { if (err) { - console.error('ACTS_Call_0400 error: ' + JSON.stringify(err)); + console.error('ACTS_Call_0800 error: ' + JSON.stringify(err)); } else { - console.info('ACTS_Call_0400 succeeded: ' + JSON.stringify(data)); + console.info('ACTS_Call_0800 succeeded: ' + JSON.stringify(data)); } }); done(); } catch (err) { - console.error('ACTS_Call_0400 catch(err)====>:' + err); - console.log('ACTS_Call_0400====:' + err); + console.log('ACTS_Call_0800===={ - console.log("====>requestdata====>" + JSON.stringify(data)); - console.log("====>requesterrcode====>" + JSON.stringify(err.code)); + console.log("====>ACTS_RequestPermissionForUser_0100 data====>" + JSON.stringify(data)); + console.log("====>ACTS_RequestPermissionForUser_0100 err====>" + JSON.stringify(err.code)); expect(err.code).assertEqual(-104) }); - console.log("RequestPermissionForUser ----------2"); + console.log("ACTS_RequestPermissionForUser_0100 ----------2"); + ret = true + done(); + setTimeout(function(){ + expect(ret).assertEqual(true) + },1000) + }) + + // @tc.number: ACTS_RequestPermissionForUser_0200 + // @tc.name: requestPermissionsFromUser : Requests certain permissions from the system. + // permission: The list of permissions to be requested. + // @tc.desc: Requests certain permissions from the system. + // process is the current process. (by promise) + it('ACTS_RequestPermissionForUser_0200', 0, async function (done) { + var ret = false + var context = await featureAbility.getContext(); + console.log("ACTS_RequestPermissionForUser_0200 ----------1"); + + context.requestPermissionsFromUser([], 1).then((data) => { + console.log("====>ACTS_RequestPermissionForUser_0200 data====>" + JSON.stringify(data)); + }).catch((err) => { + console.log("====>ACTS_RequestPermissionForUser_0200 err====>" + JSON.stringify(err.code)); + expect(err.code).assertEqual(-104) + }) + console.log("ACTS_RequestPermissionForUser_0200 ----------2"); ret = true done(); setTimeout(function(){ diff --git a/aafwk/aafwk_standard/featureability/actsfeatureabilitytest/entry/src/main/js/test/StartAbilityJsunit.test.js b/aafwk/aafwk_standard/featureability/actsfeatureabilitytest/entry/src/main/js/test/StartAbilityJsunit.test.js index 45da41200a921650d041bbcde69f32c5c7a6cce8..8d2da70e98ff0446be75854721bfdb3322174fe9 100644 --- a/aafwk/aafwk_standard/featureability/actsfeatureabilitytest/entry/src/main/js/test/StartAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/featureability/actsfeatureabilitytest/entry/src/main/js/test/StartAbilityJsunit.test.js @@ -27,7 +27,7 @@ describe('ConnectAbilityTest', function () { /* * @tc.number: SUB_AA_JsApi_StartAbility_0100 * @tc.name: testAbility0100. - * @tc.desc: StartAbility fail with want nothing. + * @tc.desc: StartAbility fail with want nothing.(by promise) */ it("SUB_AA_JsApi_StartAbility_0100", 0, async function (done) { let parameter = { @@ -44,19 +44,57 @@ describe('ConnectAbilityTest', function () { }) /* - * @tc.number: SUB_AA_JsApi_StartAbility_0200 - * @tc.name: testAbility0200. - * @tc.desc: StartAbility fail with error parameter. + * @tc.number: SUB_AA_JsApi_Ability_0200 + * @tc.name: testAblity0200. + * @tc.desc: StartAbility fail with want nothing.(by callback) + */ + it("SUB_AA_JsApi_Ability_0200", 0, async function (done) { + let parameter = { + 'want': {} + } + featureAbility.startAbility(parameter, (error, data) => { + console.log('testAbility0200 data: ' + JSON.stringify(data)) + console.log('testAbility0200 error: ' + JSON.stringify(error)) + expect(errCode1).assertEqual(error.code) + done(); + }) + }) + + /* + * @tc.number: SUB_AA_JsApi_StartAbility_0300 + * @tc.name: testAbility0300. + * @tc.desc: StartAbility fail with error parameter.(by promise) + */ + it("SUB_AA_JsApi_StartAbility_0300", 0, async function (done) { + let parameter = { + 'StartAbilityParameter': { + 'want': {} + } + } + await featureAbility.startAbility(parameter).then((data) => { + console.log('testAbility0300 data: ' + JSON.stringify(data)) + expect().assertFail() + }).catch((error) => { + console.log('testAbility0300 error: ' + JSON.stringify(error)) + expect(errCode).assertEqual(error.code) + }) + done() + }) + + /* + * @tc.number: SUB_AA_JsApi_StartAbility_0400 + * @tc.name: testAbility0400. + * @tc.desc: StartAbility fail with error parameter.(by callback) */ - it("SUB_AA_JsApi_StartAbility_0200", 0, async function (done) { + it("SUB_AA_JsApi_StartAbility_0400", 0, async function (done) { let parameter = { 'StartAbilityParameter': { 'want': {} } } featureAbility.startAbility((parameter), (error, data) => { - console.log('testAbility0200 data: ' + JSON.stringify(data)) - console.log('testAbility0200 error: ' + JSON.stringify(error)) + console.log('testAbility0400 data: ' + JSON.stringify(data)) + console.log('testAbility0400 error: ' + JSON.stringify(error)) expect(errCode).assertEqual(error.code) done() }) @@ -65,7 +103,7 @@ describe('ConnectAbilityTest', function () { /* * @tc.number: SUB_AA_JsApi_Ability_0500 * @tc.name: testAblity0500. - * @tc.desc: startAbility-want configure action+entities- there is no Ability corresponding to entities. + * @tc.desc: startAbility-want configure action+entities- there is no Ability corresponding to entities.(by promise) */ it("SUB_AA_JsApi_Ability_0500", 0, async function (done) { let parameter = { @@ -89,38 +127,35 @@ describe('ConnectAbilityTest', function () { /* * @tc.number: SUB_AA_JsApi_Ability_0600 * @tc.name: testAblity0600. - * @tc.desc: startAbility-want-configuration action+entities-entities is configured as a string. + * @tc.desc: startAbility-want configure action+entities- there is no Ability corresponding to entities.(by callback) */ it("SUB_AA_JsApi_Ability_0600", 0, async function (done) { let parameter = { 'want': { 'action': 'action.ohos.acts.aafwk.jsapi.MainAbility', - 'entities': 'abc123' + 'entities': [ + 'entity.com.example.mytestw.ENITIES22' + ] } } - await featureAbility.startAbility(parameter).then((data) => { - console.log('testAblity0600 data: ' + JSON.stringify(data)) - expect().assertFail() - }).catch((error) => { - console.log('testAblity0600 error: ' + JSON.stringify(error)) + featureAbility.startAbility((parameter), (error, data) => { + console.log('testAbility0600 data: ' + JSON.stringify(data)) + console.log('testAbility0600 error: ' + JSON.stringify(error)) expect(errCode1).assertEqual(error.code) + done() }) - done() }) /* * @tc.number: SUB_AA_JsApi_Ability_0700 * @tc.name: testAblity0700. - * @tc.desc: startAbility-want configure action+entities- entities is configurd as a string. + * @tc.desc: startAbility-want-configuration action+entities-entities is configured as a string.(by promise) */ it("SUB_AA_JsApi_Ability_0700", 0, async function (done) { let parameter = { - 'startAbilityParameter': { - 'want': { - 'bundleName': bundleName, - 'abilityName': mainAbilityName - } - + 'want': { + 'action': 'action.ohos.acts.aafwk.jsapi.MainAbility', + 'entities': 'abc123' } } await featureAbility.startAbility(parameter).then((data) => { @@ -128,7 +163,7 @@ describe('ConnectAbilityTest', function () { expect().assertFail() }).catch((error) => { console.log('testAblity0700 error: ' + JSON.stringify(error)) - expect(errCode).assertEqual(error.code) + expect(errCode1).assertEqual(error.code) }) done() }) @@ -136,86 +171,200 @@ describe('ConnectAbilityTest', function () { /* * @tc.number: SUB_AA_JsApi_Ability_0800 * @tc.name: testAblity0800. - * @tc.desc: startAbility-want configure action+entities- entities is configurd as a string. + * @tc.desc: startAbility-want-configuration action+entities-entities is configured as a string.(by callback) */ it("SUB_AA_JsApi_Ability_0800", 0, async function (done) { let parameter = { - 'want': {} + 'want': { + 'action': 'action.ohos.acts.aafwk.jsapi.MainAbility', + 'entities': 'abc123' + } } - featureAbility.startAbility(parameter, (err, data) => { - console.log('testAblity0800 data: ' + JSON.stringify(data) + ',err: ' + JSON.stringify(err)) - expect(errCode1).assertEqual(err.code) - done(); + featureAbility.startAbility((parameter), (error, data) => { + console.log('testAblity0800 data: ' + JSON.stringify(data)) + console.log('testAblity0800 error: ' + JSON.stringify(error)) + expect(errCode1).assertEqual(error.code) + done() }) }) /* * @tc.number: SUB_AA_JsApi_Ability_0900 * @tc.name: testAblity0900. - * @tc.desc: startAbility: The input parameter want is not configured (the value is {}). + * @tc.desc: startAbility-want configure action+entities- entities is configurd as a string.(by promise) */ it("SUB_AA_JsApi_Ability_0900", 0, async function (done) { - let parameter = {} - featureAbility.startAbility(parameter, (err, data) => { - console.log('testAblity0900 data: ' + JSON.stringify(data) + ',err: ' + JSON.stringify(err)) - expect(errCode).assertEqual(err.code) - done(); + let parameter = { + 'startAbilityParameter': { + 'want': { + 'bundleName': bundleName, + 'abilityName': mainAbilityName + } + + } + } + await featureAbility.startAbility(parameter).then((data) => { + console.log('testAblity0900 data: ' + JSON.stringify(data)) + expect().assertFail() + }).catch((error) => { + console.log('testAblity0900 error: ' + JSON.stringify(error)) + expect(errCode).assertEqual(error.code) }) + done() }) /* * @tc.number: SUB_AA_JsApi_Ability_1000 * @tc.name: testAblity1000. - * @tc.desc: startAbility: The input parameter is uddefined. + * @tc.desc: startAbility-want configure action+entities- entities is configurd as a string.(by callback) */ it("SUB_AA_JsApi_Ability_1000", 0, async function (done) { - await featureAbility.startAbility(undefined).then((data) => { + let parameter = { + 'startAbilityParameter': { + 'want': { + 'bundleName': bundleName, + 'abilityName': mainAbilityName + } + + } + } + featureAbility.startAbility((parameter), (error, data) => { console.log('testAblity1000 data: ' + JSON.stringify(data)) + console.log('testAblity1000 error: ' + JSON.stringify(error)) + expect(errCode).assertEqual(error.code) + done() + }) + }) + + /* + * @tc.number: SUB_AA_JsApi_Ability_1100 + * @tc.name: testAblity1100. + * @tc.desc: startAbility: The input parameter want is not configured (the value is {}).(by promise) + */ + it("SUB_AA_JsApi_Ability_1100", 0, async function (done) { + let parameter = {} + await featureAbility.startAbility(parameter).then((data) => { + console.log('testAblity1100 data: ' + JSON.stringify(data)) expect().assertFail() }).catch((error) => { - console.log('testAblity1000 error: ' + JSON.stringify(error)) + console.log('testAblity1100 error: ' + JSON.stringify(error)) expect(errCode).assertEqual(error.code) }) done() }) - /* * @tc.number: SUB_AA_JsApi_Ability_1200 * @tc.name: testAblity1200. - * @tc.desc: startAbilityForResult: The input parameter want is not configured (the value is {}). + * @tc.desc: startAbility: The input parameter want is not configured (the value is {}).(by callback) */ it("SUB_AA_JsApi_Ability_1200", 0, async function (done) { let parameter = {} - await featureAbility.startAbilityForResult(parameter).then((data) => { - console.log('testAblity2900 data: ' + JSON.stringify(data) + ',err: ' + JSON.stringify(err)) - expect.assertFail() - }).catch((err) => { - console.log('testAblity1200' + JSON.stringify(err)); - expect().assertEqual(err.code) + featureAbility.startAbility(parameter, (error, data) => { + console.log('testAblity1200 data: ' + JSON.stringify(data)) + console.log('testAblity1200 error: ' + JSON.stringify(error)) + expect(errCode).assertEqual(error.code) + done(); }) - done() }) /* * @tc.number: SUB_AA_JsApi_Ability_1300 * @tc.name: testAblity1300. - * @tc.desc: startAbilityForResult: The input parameter optParam is undefined. + * @tc.desc: startAbility: The input parameter is uddefined.(by promise) */ it("SUB_AA_JsApi_Ability_1300", 0, async function (done) { - featureAbility.startAbilityForResult(undefined, (err) => { - console.log('testAblity1300' + JSON.stringify(err)); - expect(errCode1).assertEqual(err.code) - done() + await featureAbility.startAbility(undefined).then((data) => { + console.log('testAblity1300 data: ' + JSON.stringify(data)) + expect().assertFail() + }).catch((error) => { + console.log('testAblity1300 error: ' + JSON.stringify(error)) + expect(errCode).assertEqual(error.code) }) + done() }) /* * @tc.number: SUB_AA_JsApi_Ability_1400 * @tc.name: testAblity1400. - * @tc.desc: startAbilityForResult-wrong input parameter format want a layer outside. + * @tc.desc: startAbility: The input parameter is uddefined.(by callback) */ it("SUB_AA_JsApi_Ability_1400", 0, async function (done) { + featureAbility.startAbility(undefined, (error, data) => { + console.log('testAblity1400 data: ' + JSON.stringify(data)) + console.log('testAblity1400 error: ' + JSON.stringify(error)) + expect(errCode).assertEqual(error.code) + done(); + }) + }) + + /* + * @tc.number: SUB_AA_JsApi_Ability_1500 + * @tc.name: testAblity1500. + * @tc.desc: startAbilityForResult: The input parameter want is not configured (the value is {}).(by promise) + */ + it("SUB_AA_JsApi_Ability_1500", 0, async function (done) { + let parameter = {} + await featureAbility.startAbilityForResult(parameter).then((data) => { + console.log('testAblity1500 data: ' + JSON.stringify(data)) + expect.assertFail() + }).catch((error) => { + console.log('testAblity1500' + JSON.stringify(error)); + expect().assertEqual(error.code) + }) + done() + }) + + /* + * @tc.number: SUB_AA_JsApi_Ability_1600 + * @tc.name: testAblity1600. + * @tc.desc: startAbilityForResult: The input parameter want is not configured (the value is {}).(by callback) + */ + it("SUB_AA_JsApi_Ability_1600", 0, async function (done) { + let parameter = {} + featureAbility.startAbilityForResult(parameter, (error, data) => { + console.log('testAblity1600 data: ' + JSON.stringify(data)) + console.log('testAblity1600 error: ' + JSON.stringify(error)) + expect().assertEqual(error.code) + done(); + }) + }) + + /* + * @tc.number: SUB_AA_JsApi_Ability_1700 + * @tc.name: testAblity1700. + * @tc.desc: startAbilityForResult: The input parameter optParam is undefined.(by promise) + */ + it("SUB_AA_JsApi_Ability_1700", 0, async function (done) { + await featureAbility.startAbilityForResult(undefined).then((data) => { + console.log('testAblity1700 data: ' + JSON.stringify(data)) + expect.assertFail() + }).catch((error) => { + console.log('testAblity1700' + JSON.stringify(error)); + expect(errCode1).assertEqual(error.code) + }) + done() + }) + + /* + * @tc.number: SUB_AA_JsApi_Ability_1800 + * @tc.name: testAblity1800. + * @tc.desc: startAbilityForResult: The input parameter optParam is undefined.(by callback) + */ + it("SUB_AA_JsApi_Ability_1800", 0, async function (done) { + featureAbility.startAbilityForResult(undefined, (error) => { + console.log('testAblity1800' + JSON.stringify(error)); + expect(errCode1).assertEqual(error.code) + done() + }) + }) + + /* + * @tc.number: SUB_AA_JsApi_Ability_1900 + * @tc.name: testAblity1900. + * @tc.desc: startAbilityForResult-wrong input parameter format want a layer outside.(by promise) + */ + it("SUB_AA_JsApi_Ability_1900", 0, async function (done) { let parameter = { 'StartAbilityParameter': { 'want': { @@ -228,17 +377,45 @@ describe('ConnectAbilityTest', function () { } } } - featureAbility.startAbilityForResult(parameter, (err, data) => { - console.log('testAblity1400' + JSON.stringify(err)); - expect(errCode1).assertEqual(err.code) + await featureAbility.startAbilityForResult(parameter).then((data) => { + console.log('testAblity1900 data: ' + JSON.stringify(data)) + expect.assertFail() + }).catch((error) => { + console.log('testAblity1900 err:' + JSON.stringify(error)); + expect(errCode1).assertEqual(error.code) + }) + done() + }) + + /* + * @tc.number: SUB_AA_JsApi_Ability_2000 + * @tc.name: testAblity2000. + * @tc.desc: startAbilityForResult-wrong input parameter format want a layer outside.(by callback) + */ + it("SUB_AA_JsApi_Ability_2000", 0, async function (done) { + let parameter = { + 'StartAbilityParameter': { + 'want': { + 'bundleName': bundleName, + 'abilityName': mainAbilityName, + 'parameters': { + 'key': resultCode, + 'terminate': true + } + } + } + } + featureAbility.startAbilityForResult(parameter, (error, data) => { + console.log('testAblity2000' + JSON.stringify(error)); + expect(errCode1).assertEqual(error.code) done() - }) + }) }) /* * @tc.number: SUB_AA_JsApi_Ability_2100 * @tc.name: testAblity2100. - * @tc.desc: startAbilityForResult-want-Set bundleName and abilityName+flag-flag to character strings. + * @tc.desc: startAbilityForResult-want-Set bundleName and abilityName+flag-flag to character strings.(by promise) */ it("SUB_AA_JsApi_Ability_2100", 0, async function (done) { let parameter = { @@ -255,10 +432,34 @@ describe('ConnectAbilityTest', function () { await featureAbility.startAbilityForResult(parameter).then((data) => { console.log('testAblity2100 data: ' + JSON.stringify(data)) expect.assertFail() - }).catch((err) => { - console.log('testAblity2100' + JSON.stringify(err)); - expect(undefined).assertEqual(err.code) + }).catch((error) => { + console.log('testAblity2100' + JSON.stringify(error)); + expect(undefined).assertEqual(error.code) }) done() }) + + /* + * @tc.number: SUB_AA_JsApi_Ability_2200 + * @tc.name: testAblity2200. + * @tc.desc: startAbilityForResult-want-Set bundleName and abilityName+flag-flag to character strings.(by callback) + */ + it("SUB_AA_JsApi_Ability_2200", 0, async function (done) { + let parameter = { + 'want': { + 'bundleName': bundleName, + 'abilityName': mainAbilityName, + 'flages': 'abc', + 'parameters': { + 'key': resultCode, + 'terminate': true + } + } + } + featureAbility.startAbilityForResult(parameter, (error, data) => { + console.log('testAblity2200' + JSON.stringify(error)); + expect(undefined).assertEqual(error.code) + done() + }) + }) }) diff --git a/aafwk/aafwk_standard/want/actsgetwantalltest/entry/src/main/js/test/ActsGetWantAllTest.js b/aafwk/aafwk_standard/want/actsgetwantalltest/entry/src/main/js/test/ActsGetWantAllTest.js index 22364ce4a8295232777645b3af8fd3893f55d9c8..35e245da161bb63acd8bb2c87a7cb8f832582b7c 100755 --- a/aafwk/aafwk_standard/want/actsgetwantalltest/entry/src/main/js/test/ActsGetWantAllTest.js +++ b/aafwk/aafwk_standard/want/actsgetwantalltest/entry/src/main/js/test/ActsGetWantAllTest.js @@ -27,8 +27,57 @@ describe('ActsGetWantTest', function () { // @tc.number: ACTS_GetWant_0100 // @tc.name: getWant : get want in current ability // @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) { + 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({ want: { deviceId: "", @@ -47,7 +96,7 @@ describe('ActsGetWantTest', function () { } }, (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.bundleName).assertEqual("com.example.actsgetwantalltesthap"); expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility"); @@ -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.name: getWant : get want in current ability // @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) { featureAbility.startAbilityForResult({ want: @@ -98,40 +211,103 @@ describe('ActsGetWantTest', function () { }, }, (err, data) => { - console.info('====> ACTS_StartAbilityForResult_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('====> before done=====>') + checkOnAbilityResult0400(data); setTimeout(()=>{ done(); }, 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.name: getWant : get want in current ability // @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) { + 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({ want: { @@ -155,7 +331,7 @@ describe('ActsGetWantTest', function () { }, }, (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.bundleName).assertEqual("com.example.actsgetwantalltesthap"); expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility"); @@ -176,126 +352,76 @@ describe('ActsGetWantTest', function () { 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=====>') + console.info('====> ACTS_GetWant_0600 before done=====>') setTimeout(()=>{ done(); }, 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.name: getWant : get want in current ability // @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) { - featureAbility.startAbilityForResult({ - want: + 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: { - 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_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"], - }, + 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_0700 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_WRITE_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); - }) + }).then((data) => { + console.info('====> ACTS_GetWant_0700 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_0700 before done=====>') + setTimeout(()=>{ + done(); + }, TIMEOUT_NUMBER); + }).catch((error) => { + console.log('ACTS_GetWant_0700 error: ' + JSON.stringify(error)) + expect.assertFail() + done(); }) + }) + // @tc.number: ACTS_GetWant_0800 // @tc.name: getWant : get want in current ability // @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) { featureAbility.startAbilityForResult({ want: @@ -307,6 +433,7 @@ describe('ActsGetWantTest', function () { entities: ["entity1"], type: "MIMETYPE", uri: "key={true,true,false}", + flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, parameters: { mykey0: 0.1, @@ -319,36 +446,42 @@ describe('ActsGetWantTest', function () { }, }, (err, data) => { - console.info('====> ACTS_StartAbilityForResult_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.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=====>') + checkOnAbilityResult0800(data); setTimeout(()=>{ done(); }, 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.name: getWant : get want in current ability // @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) { featureAbility.startAbilityForResult({ want: @@ -360,7 +493,7 @@ describe('ActsGetWantTest', function () { entities: ["entity1"], type: "MIMETYPE", uri: "key={true,true,false}", - flags: wantConstant.Flags.FLAG_NOT_OHOS_COMPONENT , + flags: wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION, parameters: { mykey0: 0.1, @@ -371,92 +504,103 @@ describe('ActsGetWantTest', function () { mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"], }, }, - }, - (err, data) => { - console.info('====> ACTS_StartAbilityForResult_0900 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('====> before done=====>') - setTimeout(()=>{ - done(); - }, TIMEOUT_NUMBER); - }) + }).then((data) => { + console.info('====> ACTS_GetWant_0900 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_WRITE_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_0900 before done=====>') + setTimeout(()=>{ + done(); + }, TIMEOUT_NUMBER); + }).catch((error) => { + console.log('ACTS_GetWant_0900 error: ' + JSON.stringify(error)) + expect.assertFail() + done(); + }) }) + // @tc.number: ACTS_GetWant_1000 // @tc.name: getWant : get want in current ability // @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) { - featureAbility.startAbilityForResult({ - want: - { - deviceId: "", - bundleName: "com.example.actsgetwantalltesthap", - abilityName: "com.example.actsgetwantalltesthap.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - 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"], - }, + 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_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) => { - console.info('====> ACTS_StartAbilityForResult_1000 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('====> before done=====>') - setTimeout(()=>{ - done(); - }, TIMEOUT_NUMBER); - }) - }) + }, + (err, data) => { + checkOnAbilityResult1000(data); + setTimeout(()=>{ + done(); + }, TIMEOUT_NUMBER); + }) + }) + + function checkOnAbilityResult1000(data) { + console.info('====> ACTS_GetWant_1000 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_WRITE_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_1000 before done=====>') + } + // @tc.number: ACTS_GetWant_1100 // @tc.name: getWant : get want in current ability // @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) { featureAbility.startAbilityForResult({ want: @@ -478,93 +622,100 @@ describe('ActsGetWantTest', function () { mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"], }, }, - }, - (err, data) => { - console.info('====> ACTS_StartAbilityForResult_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('====> before done.=====>') - setTimeout(()=>{ - done(); - }, TIMEOUT_NUMBER); - }) + }).then((data) => { + checkOnAbilityResult1100(data); + setTimeout(()=>{ + done(); + }, TIMEOUT_NUMBER); + }).catch((error) => { + console.log('ACTS_GetWant_1100 error: ' + JSON.stringify(error)) + expect.assertFail() + done(); + }) }) + + 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.name: getWant : get want in current ability // @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) { - featureAbility.startAbilityForResult({ - want: + featureAbility.startAbilityForResult({ + want: + { + deviceId: "", + bundleName: "com.example.actsgetwantalltesthap", + abilityName: "com.example.actsgetwantalltesthap.MainAbility", + action: "action1", + entities: ["entity1"], + type: "MIMETYPE", + uri: "key={true,true,false}", + parameters: { - 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"], - }, + 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)) - 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('====> setTimeout before done.=====>') - setTimeout(()=>{ - done(); - }, TIMEOUT_NUMBER); - }) - }) + }, + (err, data) => { + console.info('====> ACTS_GetWant_1200 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_1200 before done=====>') + setTimeout(()=>{ + done(); + }, TIMEOUT_NUMBER); + }) + }) + // @tc.number: ACTS_GetWant_1300 // @tc.name: getWant : get want in current ability // @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) { featureAbility.startAbilityForResult({ want: @@ -576,7 +727,7 @@ describe('ActsGetWantTest', function () { entities: ["entity1"], type: "MIMETYPE", uri: "key={true,true,false}", - flags: wantConstant.Flags.FLAG_START_FOREGROUND_ABILITY , + flags: wantConstant.Flags.FLAG_NOT_OHOS_COMPONENT, parameters: { mykey0: 0.1, @@ -587,94 +738,104 @@ describe('ActsGetWantTest', function () { mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"], }, }, - }, - (err, data) => { - console.info('====> ACTS_StartAbilityForResult_1300 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('====> setTimeout before done.=====>') - setTimeout(()=>{ - done(); - }, TIMEOUT_NUMBER); - }) + }).then((data) => { + console.info('====> ACTS_GetWant_1300 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_1300 before done=====>') + setTimeout(()=>{ + done(); + }, TIMEOUT_NUMBER); + }).catch((error) => { + console.log('ACTS_GetWant_1300 error: ' + JSON.stringify(error)) + expect.assertFail() + done(); + }) }) + // @tc.number: ACTS_GetWant_1400 // @tc.name: getWant : get want in current ability // @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) { - featureAbility.startAbilityForResult({ - want: + 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_NOT_OHOS_COMPONENT, + parameters: { - deviceId: "", - bundleName: "com.example.actsgetwantalltesthap", - abilityName: "com.example.actsgetwantalltesthap.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - 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"], - }, + 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)) - 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('====> setTimeout before done.=====>') - setTimeout(()=>{ - done(); - }, TIMEOUT_NUMBER); - }) - }) + }, + (err, data) => { + checkOnAbilityResult1400(data); + 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.desc:Start the ability through startabilityforresult, - // and then use terminateselfwithresult to return the data - it('ACTS_GetWant_1600', 0, async function (done) { + // and then use terminateselfwithresult to return the data (by promise) + it('ACTS_GetWant_1500', 0, async function (done) { featureAbility.startAbilityForResult({ want: { @@ -685,7 +846,7 @@ describe('ActsGetWantTest', function () { entities: ["entity1"], type: "MIMETYPE", uri: "key={true,true,false}", - flags: wantConstant.Flags.FLAG_INSTALL_WITH_BACKGROUND_MODE, + flags: wantConstant.Flags.FLAG_ABILITYSLICE_MULTI_DEVICE, parameters: { mykey0: 0.1, @@ -696,40 +857,465 @@ describe('ActsGetWantTest', function () { mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"], }, }, - }, - (err, data) => { - console.info('====> ACTS_StartAbilityForResult_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_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); - }) + }).then((data) => { + checkOnAbilityResult1500(data); + setTimeout(()=>{ + done(); + }, TIMEOUT_NUMBER); + }).catch((error) => { + console.log('ACTS_GetWant_1500 error: ' + JSON.stringify(error)) + expect.assertFail() + done(); + }) }) + + 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.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_1700', 0, async function (done) { + // and then use terminateselfwithresult to return the data (by promise) + 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({ want: { @@ -740,7 +1326,7 @@ describe('ActsGetWantTest', function () { entities: ["entity1"], type: "MIMETYPE", uri: "key={true,true,false}", - flags: wantConstant.Flags.FLAG_ABILITY_CLEAR_MISSION, + flags: wantConstant.Flags.FLAG_ABILITY_NEW_MISSION, parameters: { mykey0: 0.1, @@ -751,135 +1337,230 @@ describe('ActsGetWantTest', function () { mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"], }, }, - }, - (err, data) => { - console.info('====> ACTS_StartAbilityForResult_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_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); - }) + }).then((data) => { + checkOnAbilityResult2300(data); + setTimeout(()=>{ + done(); + }, TIMEOUT_NUMBER); + }).catch((error) => { + console.log('ACTS_GetWant_2300 error: ' + JSON.stringify(error)) + expect.assertFail() + done(); + }) }) - // @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.desc:Start the ability through startabilityforresult, - // and then use terminateselfwithresult to return the data - it('ACTS_GetWant_1800', 0, async function (done) { - featureAbility.startAbilityForResult({ - want: + // and then use terminateselfwithresult to return the data (by callback) + it('ACTS_GetWant_2400', 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_NEW_MISSION, + parameters: { - 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: - { - mykey0: 0.1, - mykey1: [0.1, 0.2, 0.0000000003], - mykey2: "[a, b, c]", - mykey3: "str", - mykey4: [false, true, false], - mykey5: ["str", "STR", "helloopenharmonyhelloopenharmonyhelloopenharmony"], - }, + 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)) - 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('====> setTimeout before done.=====>') - setTimeout(()=>{ - done(); - }, TIMEOUT_NUMBER); - }) - }) + }, + (err, data) => { + checkOnAbilityResult2400(data); + setTimeout(()=>{ + done(); + }, TIMEOUT_NUMBER); + }) + }) + + function checkOnAbilityResult2400(data) { + console.info('====> ACTS_GetWant_2400 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_2400 setTimeout before done.=====>') + } /* - * @tc.number ACTS_GetWant_2000 + * @tc.number ACTS_GetWant_2500 * @tc.name Misconfigured bundlename validation - * @tc.desc Function test + * @tc.desc Function test (by promise) * @tc.level 0 */ - it("ACTS_GetWant_2000",0, async function(done){ - console.info("------------------start ACTS_GetWant_2000-------------------"); - try{ - featureAbility.startAbilityForResult({ - want: + it("ACTS_GetWant_2500",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: { - 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"], - }, + 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) => { - checkOnAbilityResult(data); - console.info('====> setTimeout before done.=====>') - setTimeout(()=>{ - done(); - }, TIMEOUT_NUMBER); - }) - }catch(error){ - console.log("ACTS_GetWant_2000 : error = " + error); - } - console.log('ACTS_GetWant_2000 end'); + }).then((data) => { + checkOnAbilityResult2500(data); + setTimeout(()=>{ + done(); + }, TIMEOUT_NUMBER); + }).catch((error) => { + console.log('ACTS_GetWant_2500 error: ' + JSON.stringify(error)) + expect.assertFail() + done(); + }) + }); + + 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.name: Check the enumerated value ACTION_IMAGE_CAPTURE of wantConstant. @@ -918,29 +1599,4 @@ describe('ActsGetWantTest', function () { console.log("SUB_AA_OpenHarmony_wantConstantEnumeration_0300 --- end") 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=====>') - } }) diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js index 87f23fb954bc3538f67f26910ced667a7158c741..12d17fd0a283d5b7cb3c96d3ac394d3ffd6b659e 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js @@ -36,7 +36,7 @@ describe('ActsBundleManagerTest', function () { /** * @tc.number getBundleInfo_0100 * @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) { let datainfo = await demo.getBundleInfo(NAME1, @@ -88,10 +88,165 @@ describe('ActsBundleManagerTest', function () { 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.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) { await demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent); @@ -131,13 +286,86 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.appInfo.enabled).assertEqual(true); 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.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) { let datainfo = await demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_DEFAULT) @@ -163,7 +391,7 @@ describe('ActsBundleManagerTest', function () { /** * @tc.number getBundleInfo_1200 * @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) { await demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_DEFAULT, OnReceiveEvent) @@ -193,64 +421,232 @@ describe('ActsBundleManagerTest', function () { }) /** - * @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. + * @tc.number getBundleInfo_1400 + * @tc.name BUNDLE::getBundleInfo + * @tc.desc Test getBundleInfo interfaces with LAUNCHER hap.(by callback) */ - 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); - } - } + it('getBundleInfo_1400', 0, async function (done) { + await demo.getBundleInfo(LAUNCHER, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, + bundleOptions, (err, dataInfo) => { + if (err) { + console.info("getBundleInfo_1400 fail:" + JSON.stringify(err)); + expect(err).assertFail(); done(); - }); + return; + } + console.info("getBundleInfo_1400 success:" + JSON.stringify(datainfo)); + expect(datainfo.name).assertEqual(LAUNCHER); + expect(datainfo.vendor).assertEqual("ohos"); + expect(datainfo.versionCode).assertEqual(1000000); + expect(datainfo.versionName.length).assertLarger(0); + expect(datainfo.uid).assertLarger(2099); + expect(datainfo.appInfo.name).assertEqual(LAUNCHER); + expect(datainfo.appInfo.systemApp).assertEqual(true); + expect(datainfo.appInfo.supportedModes).assertEqual(0); + expect(datainfo.appInfo.moduleInfos.length).assertLarger(0); + expect(datainfo.appInfo.enabled).assertEqual(true); + done(); + }) }) /** - * @tc.number 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.desc Test getBundleInfos interfaces with one hap. */ @@ -262,7 +658,7 @@ describe('ActsBundleManagerTest', function () { expect(data[i].name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0); 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.icon.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0); @@ -276,14 +672,61 @@ describe('ActsBundleManagerTest', function () { /** * @tc.number getApplicationInfo_0100 * @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) { await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION | demo.BundleFlag.GET_APPLICATION_INFO_WITH_METADATA, 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); - console.info("getApplicationInfo success:" + JSON.stringify(datainfo)); + console.info("getApplicationInfo_0200 success:" + JSON.stringify(datainfo)); expect(datainfo.moduleSourceDirs.length).assertLarger(0); expect(datainfo.moduleInfos.length).assertLarger(0); expect(datainfo.name).assertEqual(NAME1); @@ -307,77 +750,217 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.moduleInfos[j].moduleSourceDir.length).assertLarger(0); } done(); - }).catch(err => { - console.info("getApplicationInfo fail:" + JSON.stringify(err)); - expect(err).assertFail(); - done(); }) }) /** - * @tc.number getBundleInfos_0600 - * @tc.name BUNDLE::getBundleInfos - * @tc.desc Test getBundleInfos interfaces with one hap. + * @tc.number getApplicationInfo_0300 + * @tc.name BUNDLE::getApplicationInfo + * @tc.desc Test getApplicationInfo interfaces with two haps. (by promise) */ - it('getBundleInfos_0600', 0, async function (done) { - await demo.getAllBundleInfo(demo.BundleFlag.GET_BUNDLE_DEFAULT, (error, data) => { - expect(typeof data).assertEqual(OBJECT); - for (let i = 0; i < data.length; i++) { - expect(data[i].name.length).assertLarger(0); - expect(data[i].appInfo.name.length).assertLarger(0); - if (data[i].name == NAME1 || data[i].name == NAME2 - || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { - expect(data[i].appInfo.description.length).assertLarger(0); - expect(data[i].appInfo.icon.length).assertLarger(0); - expect(data[i].appInfo.label.length).assertLarger(0); - } - expect(data[i].appInfo.supportedModes).assertEqual(0); - expect(data[i].appInfo.moduleInfos.length).assertLarger(0); - } - done(); - }); + it('getApplicationInfo_0300', 0, async function (done) { + let datainfo = await demo.getApplicationInfo(NAME2, + demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID); + console.info("getApplicationInfo_0300 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 getApplicationInfo_0600 + * @tc.number getApplicationInfo_0400 * @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) { - await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID, - (error, datainfo) => { - if (error) { - console.info("getApplicationInfo fail:" + JSON.stringify(error)); - expect(error).assertFail(); - } - console.info("getApplicationInfo success:" + JSON.stringify(datainfo)); + it('getApplicationInfo_0400', 0, async function (done) { + await demo.getApplicationInfo(NAME2, + demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID, (error, datainfo) => { + console.info("getApplicationInfo_0400 result" + JSON.stringify(datainfo)); expect(typeof datainfo).assertEqual(OBJECT); - expect(datainfo.name).assertEqual(NAME1); - expect(datainfo.label).assertEqual("$string:app_name"); + 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.descriptionId >= 0).assertTrue(); - expect(parseInt(datainfo.iconId)).assertLarger(0); - expect(parseInt(datainfo.labelId)).assertLarger(0); + 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).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(); }) }) + /** + * @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.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) { 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(datainfo.name).assertEqual(NAME1); expect(datainfo.label).assertEqual("$string:app_name"); @@ -388,25 +971,28 @@ describe('ActsBundleManagerTest', function () { expect(parseInt(datainfo.labelId)).assertLarger(0); expect(datainfo.systemApp).assertEqual(true); expect(datainfo.supportedModes).assertEqual(0); + done(); }).catch(err => { - console.info("getApplicationInfo fail" + JSON.stringify(err)); + console.info("getApplicationInfo_1100 fail" + JSON.stringify(err)); expect(err).assertFail(); + done(); }) - done(); }) /** * @tc.number getApplicationInfo_1200 * @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) { await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_BUNDLE_DEFAULT, USERID, (error, datainfo) => { if (error) { - console.info("getApplicationInfo fail" + JSON.stringify(error)); + console.info("getApplicationInfo_1200 fail" + JSON.stringify(error)); 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(datainfo.name).assertEqual(NAME1); expect(datainfo.label).assertEqual("$string:app_name"); @@ -422,51 +1008,93 @@ describe('ActsBundleManagerTest', function () { }) /** - * @tc.number getBundleInfo_0200 - * @tc.name BUNDLE::getBundleInfo - * @tc.desc Test getBundleInfo interfaces with two haps. + * @tc.number getApplicationInfo_1300 + * @tc.name BUNDLE::getApplicationInfo + * @tc.desc Test getApplicationInfo interfaces with one hap. (by promise) */ - it('getBundleInfo_0200', 0, async function (done) { - let datainfo = await demo.getBundleInfo(NAME2, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES); - expect(datainfo.name).assertEqual(NAME2); - expect(datainfo.vendor).assertEqual("example"); - expect(datainfo.versionCode).assertEqual(1); - expect(datainfo.versionName).assertLarger(0); - expect(datainfo.entryModuleName).assertEqual("entry"); - expect(datainfo.appInfo.name).assertEqual(NAME2); - expect(datainfo.appInfo.description).assertEqual(DESCRIPTION); - expect(datainfo.appInfo.descriptionId >= 0).assertTrue(); - expect(datainfo.appInfo.icon).assertEqual("$media:icon"); - expect(datainfo.appInfo.iconId >= 0).assertTrue(); - expect(datainfo.appInfo.label).assertEqual("$string:app_name"); - expect(datainfo.appInfo.labelId >= 0).assertTrue(); - expect(datainfo.appInfo.systemApp).assertEqual(true); - done(); + it('getApplicationInfo_1300', 0, async function (done) { + await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + USERID).then(datainfo => { + console.info("getApplicationInfo_1300 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(); + }).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.name BUNDLE::getBundleInfo - * @tc.desc Test getBundleInfo interfaces with two haps. + * @tc.number getBundleInfos_0600 + * @tc.name BUNDLE::getBundleInfos + * @tc.desc Test getBundleInfos interfaces with one hap. */ - it('getBundleInfo_0700', 0, async function (done) { - await demo.getBundleInfo(NAME2, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent); - function OnReceiveEvent(err, datainfo) { - expect(datainfo.name).assertEqual(NAME2); - expect(datainfo.vendor).assertEqual("example"); - expect(datainfo.versionCode).assertEqual(1); - expect(datainfo.versionName).assertLarger(0); - expect(datainfo.entryModuleName).assertEqual("entry"); - expect(datainfo.appInfo.name).assertEqual(NAME2); - expect(datainfo.appInfo.description).assertEqual(DESCRIPTION); - expect(datainfo.appInfo.descriptionId >= 0).assertTrue(); - expect(datainfo.appInfo.icon).assertEqual("$media:icon"); - expect(datainfo.appInfo.iconId >= 0).assertTrue(); - expect(datainfo.appInfo.label).assertEqual("$string:app_name"); - expect(datainfo.appInfo.labelId >= 0).assertTrue(); - expect(datainfo.appInfo.systemApp).assertEqual(true); + it('getBundleInfos_0600', 0, async function (done) { + await demo.getAllBundleInfo(demo.BundleFlag.GET_BUNDLE_DEFAULT, (error, data) => { + expect(typeof data).assertEqual(OBJECT); + for (let i = 0; i < data.length; i++) { + expect(data[i].name.length).assertLarger(0); + expect(data[i].appInfo.name.length).assertLarger(0); + if (data[i].name == NAME1 || data[i].name == NAME2 + || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { + expect(data[i].appInfo.description.length).assertLarger(0); + expect(data[i].appInfo.icon.length).assertLarger(0); + expect(data[i].appInfo.label.length).assertLarger(0); + } + expect(data[i].appInfo.supportedModes).assertEqual(0); + expect(data[i].appInfo.moduleInfos.length).assertLarger(0); + } done(); - } + }); }) /** @@ -504,7 +1132,7 @@ describe('ActsBundleManagerTest', function () { 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) { + || 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); @@ -532,7 +1160,7 @@ describe('ActsBundleManagerTest', function () { 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) { + || 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); @@ -560,7 +1188,7 @@ describe('ActsBundleManagerTest', function () { 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) { + || 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); @@ -590,7 +1218,7 @@ describe('ActsBundleManagerTest', function () { expect(data[i].name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0); 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.icon.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0); @@ -613,7 +1241,7 @@ describe('ActsBundleManagerTest', function () { expect(data[i].name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0); 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.icon.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0); @@ -624,41 +1252,6 @@ describe('ActsBundleManagerTest', function () { 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 @@ -672,7 +1265,7 @@ describe('ActsBundleManagerTest', function () { expect(data[i].name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0); 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.icon.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0); @@ -696,7 +1289,7 @@ describe('ActsBundleManagerTest', function () { expect(data[i].name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0); 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.icon.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0); @@ -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.name BUNDLE::getBundleInfos @@ -751,7 +1312,7 @@ describe('ActsBundleManagerTest', function () { expect(data[i].name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0); 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.icon.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0); @@ -773,7 +1334,7 @@ describe('ActsBundleManagerTest', function () { expect(data[i].name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0); 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.icon.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0); @@ -795,7 +1356,7 @@ describe('ActsBundleManagerTest', function () { expect(data[i].name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0); 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.icon.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0); @@ -809,202 +1370,82 @@ describe('ActsBundleManagerTest', function () { }) /** - * @tc.number getApplicationInfo_0300 - * @tc.name BUNDLE::getApplicationInfo - * @tc.desc Test getApplicationInfo interfaces with three haps. - */ - 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. + * @tc.number queryAbilityByWant_0100 + * @tc.name BUNDLE::queryAbilityByWant + * @tc.desc Test queryAbilityByWant interfaces with none hap. (by promise) */ - it('getApplicationInfo_1000', 0, async function (done) { - demo.getApplicationInfo('', 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; + it('queryAbilityByWant_0100', 0, async function (done) { + await demo.queryAbilityByWant( + { + "bundleName": "com.example.myapplication1", + "abilityName": "com.example.myapplication1.MainAbility", + }, demo.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION | + demo.BundleFlag.GET_ABILITY_INFO_WITH_PERMISSION | + 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.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( { "bundleName": "com.example.myapplication1", "abilityName": "com.example.myapplication1.MainAbility", }, 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, - 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); for (let i = 0, len = data.length; i < len; i++) { let datainfo = data[i]; + console.info("queryAbilityByWant_0200 success:" + JSON.stringify(datainfo)); expect(datainfo.name).assertEqual("com.example.myapplication1.MainAbility"); expect(datainfo.label).assertEqual("$string:app_name"); expect(datainfo.description).assertEqual(DESCRIPTION); @@ -1033,18 +1474,15 @@ describe('ActsBundleManagerTest', function () { } } done(); - }).catch(err => { - expect(err).assertFail(); - done(); }) }) /** - * @tc.number queryAbilityByWant_0200 + * @tc.number queryAbilityByWant_0300 * @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( { "bundleName": "com.example.myapplication2", @@ -1053,6 +1491,7 @@ describe('ActsBundleManagerTest', function () { expect(data.length).assertLarger(0); for (let i = 0, len = data.length; i < len; i++) { let datainfo = data[i]; + console.info("queryAbilityByWant_0300 success:" + JSON.stringify(datainfo)); expect(datainfo.name.length).assertLarger(0); expect(datainfo.label).assertEqual("$string:app_name"); expect(datainfo.description).assertEqual(DESCRIPTION); @@ -1080,238 +1519,243 @@ describe('ActsBundleManagerTest', function () { }) /** - * @tc.number queryAbilityByWant_0300 + * @tc.number queryAbilityByWant_0400 * @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) { - await demo.queryAbilityByWant({ - entities: ['entity.system.home', 'entitiesentities'] - }, 4, USERID).then(data => { - let queryResultCount = 0; + it('queryAbilityByWant_0400', 0, async function (done) { + await demo.queryAbilityByWant( + { + "bundleName": "com.example.myapplication2", + "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++) { let datainfo = data[i]; - 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++; + console.info("queryAbilityByWant_0400 success:" + JSON.stringify(datainfo)); + expect(datainfo.name.length).assertLarger(0); + 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(NAME2); + expect(datainfo.orientation).assertEqual(1); + expect(datainfo.launchMode).assertEqual(demo.LaunchMode.SINGLETON); + expect(datainfo.applicationInfo.name).assertEqual(NAME2); + 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); + for (let j = 0; j < datainfo.applicationInfo.moduleInfos; j++) { + expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry"); + expect(datainfo.applicationInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR2); } } - expect(queryResultCount).assertEqual(3); - done(); - }).catch(err => { - expect(err).assertFail(); done(); }) }) /** - * @tc.number queryAbilityByWant_0400 + * @tc.number queryAbilityByWant_0500 * @tc.name BUNDLE::queryAbilityByWant - * @tc.desc Test queryAbilityByWant interfaces with one hap. - */ - 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. + * @tc.desc Test queryAbilityByWant interfaces with three haps. (by promise) */ - it('getBundleInfo_1300', 0, async function (done) { - demo.getBundleInfo(LAUNCHER, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES).then(datainfo => { - console.info("getBundleInfo success:" + JSON.stringify(datainfo)); - expect(datainfo.name).assertEqual(LAUNCHER); - expect(datainfo.vendor).assertEqual("ohos"); - expect(datainfo.versionCode).assertEqual(1000000); - expect(datainfo.versionName.length).assertLarger(0); - expect(datainfo.uid).assertLarger(2099); - expect(datainfo.appInfo.name).assertEqual(LAUNCHER); - expect(datainfo.appInfo.systemApp).assertEqual(true); - expect(datainfo.appInfo.supportedModes).assertEqual(0); - expect(datainfo.appInfo.moduleInfos.length).assertLarger(0); - expect(datainfo.appInfo.enabled).assertEqual(true); + it('queryAbilityByWant_0500', 0, async function (done) { + await demo.queryAbilityByWant({ + entities: ['entity.system.home', 'entitiesentities'] + }, 4, USERID).then(data => { + checkAbilityInfo0500(data) done(); }).catch(err => { - console.info("getBundleInfo fail:" + JSON.stringify(err)); + console.info("queryAbilityByWant_0500 err" + JSON.stringify(err)); expect(err).assertFail(); done(); }) - }) - /** - * @tc.number getBundleInfo_1400 - * @tc.name BUNDLEMGR::getBundleInfo - * @tc.desc Test getBundleInfo interface with current userId(by promise). - */ - it('getBundleInfo_1400', 0, async function (done) { - let bundleOptions = { - userId: USERID - }; - let dataInfo = await demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, bundleOptions); - console.info("getBundleInfo_1400 start --------"); - expect(dataInfo.name).assertEqual(NAME1); - expect(dataInfo.vendor).assertEqual("example"); - expect(dataInfo.versionCode).assertEqual(VERSIONCODE1); - expect(dataInfo.versionName).assertLarger(0); - expect(dataInfo.entryModuleName).assertEqual("entry"); - expect(dataInfo.appInfo.name).assertEqual(NAME1); - expect(dataInfo.appInfo.description).assertEqual(DESCRIPTION); - expect(dataInfo.appInfo.descriptionId >= 0).assertTrue(); - expect(dataInfo.appInfo.icon).assertEqual("$media:icon"); - expect(dataInfo.appInfo.iconId >= 0).assertTrue(); - expect(dataInfo.appInfo.label).assertEqual("$string:app_name"); - expect(dataInfo.appInfo.labelId >= 0).assertTrue(); - expect(dataInfo.appInfo.systemApp).assertEqual(true); - expect(dataInfo.appInfo.supportedModes).assertEqual(0); - expect(dataInfo.updateTime).assertLarger(0); - expect(dataInfo.reqPermissions.length).assertEqual(0); - expect(dataInfo.reqPermissionDetails.length).assertEqual(0); - expect(dataInfo.compatibleVersion).assertEqual(5); - expect(dataInfo.targetVersion).assertEqual(5); - expect(dataInfo.isCompressNativeLibs).assertEqual(false); - for (let s = 0; s < dataInfo.hapModuleInfos; s++) { - expect(dataInfo.moduleInfos[s].name).assertEqual("com.example.myapplication1"); - expect(dataInfo.moduleInfos[s].moduleName).assertEqual("entry"); - } - expect(dataInfo.entryModuleName).assertEqual("entry"); - expect(dataInfo.isSilentInstallation.length).assertEqual(0); - expect(dataInfo.minCompatibleVersionCode).assertEqual(0); - expect(dataInfo.entryInstallationFree).assertEqual(false); - for (let j = 0; j < dataInfo.appInfo.moduleInfos; j++) { - expect(dataInfo.appInfo.moduleInfos[j].moduleName).assertEqual("entry"); - expect(dataInfo.appInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1); + function checkAbilityInfo0500(data) { + let queryResultCount = 0; + for (let i = 0, len = data.length; i < len; i++) { + let datainfo = data[i]; + console.info("queryAbilityByWant_0500 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(dataInfo.appInfo.enabled).assertEqual(true); - console.info("getBundleInfo_1400 end --------"); - done(); - }) + expect(queryResultCount).assertEqual(3); + } /** - * @tc.number getBundleInfo_1500 - * @tc.name BUNDLE::getBundleInfo - * @tc.desc Test getBundleInfo interface with current userId(by callback). - */ - it('getBundleInfo_1500', 0, async function (done) { - let bundleOptions = { - userId: USERID - }; - demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, bundleOptions, (err, dataInfo) => { - expect(dataInfo.name).assertEqual(NAME1); - expect(dataInfo.vendor).assertEqual("example"); - expect(dataInfo.versionCode).assertEqual(VERSIONCODE1); - expect(dataInfo.versionName).assertLarger(0); - expect(dataInfo.entryModuleName).assertEqual("entry"); - expect(dataInfo.appInfo.name).assertEqual(NAME1); - expect(dataInfo.appInfo.description).assertEqual(DESCRIPTION); - expect(dataInfo.appInfo.descriptionId >= 0).assertTrue(); - expect(dataInfo.appInfo.icon).assertEqual("$media:icon"); - expect(dataInfo.appInfo.iconId >= 0).assertTrue(); - expect(dataInfo.appInfo.label).assertEqual("$string:app_name"); - expect(dataInfo.appInfo.labelId >= 0).assertTrue(); - expect(dataInfo.appInfo.systemApp).assertEqual(true); - expect(dataInfo.appInfo.supportedModes).assertEqual(0); - expect(dataInfo.updateTime).assertLarger(0); - expect(dataInfo.reqPermissions.length).assertEqual(0); - expect(dataInfo.reqPermissionDetails.length).assertEqual(0); - expect(dataInfo.compatibleVersion).assertEqual(5); - expect(dataInfo.targetVersion).assertEqual(5); - expect(dataInfo.isCompressNativeLibs).assertEqual(false); - for (let s = 0; s < dataInfo.hapModuleInfos; s++) { - expect(dataInfo.moduleInfos[s].name).assertEqual("com.example.myapplication1"); - expect(dataInfo.moduleInfos[s].moduleName).assertEqual("entry"); - } - expect(dataInfo.entryModuleName).assertEqual("entry"); - expect(dataInfo.isSilentInstallation.length).assertEqual(0); - expect(dataInfo.minCompatibleVersionCode).assertEqual(0); - expect(dataInfo.entryInstallationFree).assertEqual(false); - for (let j = 0; j < dataInfo.appInfo.moduleInfos; j++) { - expect(dataInfo.appInfo.moduleInfos[j].moduleName).assertEqual("entry"); - expect(dataInfo.appInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1); + * @tc.number queryAbilityByWant_0600 + * @tc.name BUNDLE::queryAbilityByWant + * @tc.desc Test queryAbilityByWant interfaces with three haps. (by callback) + */ + it('queryAbilityByWant_0600', 0, async function (done) { + await demo.queryAbilityByWant( + { + entities: ['entity.system.home', 'entitiesentities'] + }, 4, USERID, (err, data) => { + if (err) { + console.info("queryAbilityByWant_0600 err" + JSON.stringify(err)); + expect(err).assertFail(); + done(); + return; } + checkAbilityInfo0600(data); 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.name BUNDLEMGR::getBundleInfo - * @tc.desc Test getBundleInfo interface with other userId(by promise). + * @tc.number queryAbilityByWant_0700 + * @tc.name BUNDLE::queryAbilityByWant + * @tc.desc Test queryAbilityByWant interfaces with one hap. (by promise) */ - it('getBundleInfo_1600', 0, async function (done) { - demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, { - userId: 1 - }).then(data => { - expect().assertFail(); + it('queryAbilityByWant_0700', 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_0700 dataInfo : ===========" + datainfo); + expect(datainfo).assertFail(); done(); }).catch(err => { + console.info("queryAbilityByWant_0700 err : ===========" + err); expect(err).assertEqual(1); done(); - }); + }) }) /** - * @tc.number getBundleInfo_1700 - * @tc.name BUNDLE::getBundleInfo - * @tc.desc Test getBundleInfo interface with other userId(by callback). + * @tc.number queryAbilityByWant_0800 + * @tc.name BUNDLE::queryAbilityByWant + * @tc.desc Test queryAbilityByWant interfaces with one hap. (by callback) */ - it('getBundleInfo_1700', 0, async function (done) { - demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, { - userId: 1 - }, (err, dataInfo) => { + it('queryAbilityByWant_0800', 0, async function (done) { + await demo.queryAbilityByWant( + { + "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(dataInfo).assertEqual(undefined); done(); - }); + }) }) /** * @tc.number queryAbilityByWant_1000 * @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) { demo.queryAbilityByWant( @@ -1319,7 +1763,10 @@ describe('ActsBundleManagerTest', function () { bundleName: "wrong name", abilityName: "wrong name", }, 0, USERID, OnReceiveEvent); + function OnReceiveEvent(err, datainfo) { + console.info("queryAbilityByWant_1000 err : ===========" + err); + console.info("queryAbilityByWant_1000 dataInfo : ===========" + datainfo); expect(err).assertEqual(1); expect(datainfo.length).assertLarger(0); done(); diff --git a/communication/bluetooth_ble/src/main/js/default/test/BluetoothBle.test.js b/communication/bluetooth_ble/src/main/js/default/test/BluetoothBle.test.js index 2bac077d439d2f0861deb79dcb50893fab952cee..f1da475d7509745dd772b0bf55e8004b7aaddb02 100644 --- a/communication/bluetooth_ble/src/main/js/default/test/BluetoothBle.test.js +++ b/communication/bluetooth_ble/src/main/js/default/test/BluetoothBle.test.js @@ -316,6 +316,30 @@ describe('bluetoothhostTest', function() { 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.name testGetServices @@ -381,7 +405,7 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ 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(); let promise = new Promise((resolve) => { let descriptors = []; @@ -402,12 +426,12 @@ describe('bluetoothhostTest', function() { if (object != null) { expect(true).assertEqual(true); } else { - console.info('[bluetooth_js] readCharacValue data:' + JSON.stringify(data)); + console.info('[bluetooth_js] readCharacValue promise data:' + JSON.stringify(data)); expect(null).assertFail(); } done(); }).catch(err => { - console.error(`bluetooth readCharacteristicValue has error: ${err}`); + console.error(`bluetooth readCharacteristicValue promise has error: ${err}`); expect(true).assertEqual(true); done(); }); @@ -417,6 +441,53 @@ describe('bluetoothhostTest', function() { 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.name testReadDescriptorValue @@ -426,7 +497,7 @@ describe('bluetoothhostTest', function() { * @tc.level Level 2 */ 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(); let promise = new Promise((resolve) => { let arrayBuffer = new ArrayBuffer(8); @@ -439,12 +510,12 @@ describe('bluetoothhostTest', function() { if (object != null) { expect(true).assertEqual(true); } else { - console.info('[bluetooth_js] BLEDescriptor data:' + JSON.stringify(object)); + console.info('[bluetooth_js] BLEDescriptor promise data:' + JSON.stringify(object)); expect(null).assertFail(); } done(); }).catch(err => { - console.error(`bluetooth readDescriptorValue has error: ${err}`); + console.error(`bluetooth readDescriptorValue promise has error: ${err}`); expect(true).assertEqual(true); done(); }); @@ -454,6 +525,44 @@ describe('bluetoothhostTest', function() { 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 diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreRdbstoreJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreRdbstoreJsunit.test.js index f180a1b9ddea655797569204def26335e5fe18c4..e2632dc9bc7fe62b3a7b23da3d424da44bbc11dd 100755 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreRdbstoreJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreRdbstoreJsunit.test.js @@ -120,11 +120,15 @@ describe('rdbStoreTest', function () { */ it('testRdbStore0004', 0, async function (done) { console.log(TAG + "************* testRdbStore0004 start *************"); - - let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 6); + let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 1); 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(); } @@ -137,5 +141,91 @@ describe('rdbStoreTest', function () { 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*************"); }) \ No newline at end of file diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StorageHelperJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StorageHelperJsunit.test.js index b10044ac16436064b9eafd2189229a03720297be..48aa2954380e9f30fa43b84d5ecbbe6895f18f76 100755 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StorageHelperJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StorageHelperJsunit.test.js @@ -80,9 +80,9 @@ describe('storageTest', function () { }) /** - * @tc.name removeStorageFromCache interface test + * @tc.name removeStorageFromCache promise interface test * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_Helper_0040 - * @tc.desc removeStorageFromCache interface test + * @tc.desc removeStorageFromCache promise interface test */ it('testRemoveStorageFromCache002', 0, async function (done) { let perf = storage.getStorageSync('/data/test_storage2'); @@ -96,6 +96,27 @@ describe('storageTest', function () { done(); }) + /** + * @tc.name removeStorageFromCache callback interface test + * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_Helper_0041 + * @tc.desc removeStorageFromCache callback interface test + */ +// it('testRemoveStorageFromCache003', 0, function (done) { +// let perf = storage.getStorageSync('/data/test_storage3'); +// storage.removeStorageFromCache(perf, function (err) { +// if (err) { +// console.info("removeStorageFromCache callback interface test failed" + err); +// expect(null).assertFail(); +// done(); +// return +// } +// console.info("removeStorageFromCache callback interface test successfully."); +// expect(true).assertTrue(); +// done(); +// }) +// +// }) + /** * @tc.name deleteStorageSync interface test * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_Helper_0050 diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerCallbackJsunit.test.js b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerCallbackJsunit.test.js index 11d88c720edfe04969fe65ca18bcc3b9f17db05a..a5d4ae72c889fcd43f15b684169101af1bd4ab3d 100644 --- a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerCallbackJsunit.test.js +++ b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerCallbackJsunit.test.js @@ -17,6 +17,8 @@ import factory from '@ohos.data.distributedData'; const TEST_BUNDLE_NAME = 'ohos.acts.distributeddatamgr'; const TEST_STORE_ID = 'storeId'; +const STORE_KEY = 'key_test_string'; +const STORE_VALUE = 'value-test-string'; var kvManager = null; var kvStore = null; @@ -125,9 +127,9 @@ describe('KVManagerCallbackTest', function () { encrypt : false, backup : false, autoSync : true, - kvStoreType : factory.KVStoreType.SINGLE_VERSION, + kvStoreType : factory.KVStoreType.DEVICE_COLLABORATION, schema : '', - securityLevel : factory.SecurityLevel.S2, + securityLevel : factory.SecurityLevel.NO_LEVEL, } try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { @@ -156,9 +158,9 @@ describe('KVManagerCallbackTest', function () { encrypt : false, backup : false, autoSync : true, - kvStoreType : factory.KVStoreType.SINGLE_VERSION, + kvStoreType : factory.KVStoreType.DEVICE_COLLABORATION, schema : '', - securityLevel : factory.SecurityLevel.S2, + securityLevel : factory.SecurityLevel.S0, } try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { @@ -188,9 +190,9 @@ describe('KVManagerCallbackTest', function () { encrypt : true, backup : false, autoSync : true, - kvStoreType : factory.KVStoreType.SINGLE_VERSION, + kvStoreType : factory.KVStoreType.DEVICE_COLLABORATION, schema : '', - securityLevel : factory.SecurityLevel.S2, + securityLevel : factory.SecurityLevel.S1, } try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { @@ -218,7 +220,7 @@ describe('KVManagerCallbackTest', function () { encrypt : false, backup : false, autoSync : true, - kvStoreType : factory.KVStoreType.SINGLE_VERSION, + kvStoreType : factory.KVStoreType.DEVICE_COLLABORATION, schema : '', securityLevel : factory.SecurityLevel.S2, } @@ -248,9 +250,9 @@ describe('KVManagerCallbackTest', function () { encrypt : false, backup : true, autoSync : true, - kvStoreType : factory.KVStoreType.SINGLE_VERSION, + kvStoreType : factory.KVStoreType.DEVICE_COLLABORATION, schema : '', - securityLevel : factory.SecurityLevel.S2, + securityLevel : factory.SecurityLevel.S3, } try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { @@ -278,9 +280,9 @@ describe('KVManagerCallbackTest', function () { encrypt : false, backup : false, autoSync : true, - kvStoreType : factory.KVStoreType.SINGLE_VERSION, + kvStoreType : factory.KVStoreType.DEVICE_COLLABORATION, schema : '', - securityLevel : factory.SecurityLevel.S2, + securityLevel : factory.SecurityLevel.S4, } try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { @@ -310,7 +312,7 @@ describe('KVManagerCallbackTest', function () { autoSync : true, kvStoreType : factory.KVStoreType.SINGLE_VERSION, schema : '', - securityLevel : factory.SecurityLevel.S2, + securityLevel : factory.SecurityLevel.NO_LEVEL, } try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { @@ -340,7 +342,7 @@ describe('KVManagerCallbackTest', function () { autoSync : false, kvStoreType : factory.KVStoreType.SINGLE_VERSION, schema : '', - securityLevel : factory.SecurityLevel.S2, + securityLevel : factory.SecurityLevel.S0, } try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { @@ -370,7 +372,7 @@ describe('KVManagerCallbackTest', function () { autoSync : true, kvStoreType : factory.KVStoreType.SINGLE_VERSION, schema : '', - securityLevel : factory.SecurityLevel.S2, + securityLevel : factory.SecurityLevel.S1, } try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { @@ -398,7 +400,7 @@ describe('KVManagerCallbackTest', function () { encrypt : false, backup : false, autoSync : true, - kvStoreType : factory.KVStoreType.DEVICE_COLLABORATION, + kvStoreType : factory.KVStoreType.SINGLE_VERSION, schema : '', securityLevel : factory.SecurityLevel.S2, } @@ -428,17 +430,18 @@ describe('KVManagerCallbackTest', function () { encrypt : false, backup : false, autoSync : true, - kvStoreType : factory.KVStoreType.MULTI_VERSION, + kvStoreType : factory.KVStoreType.SINGLE_VERSION, schema : '', - securityLevel : factory.SecurityLevel.S2, + securityLevel : factory.SecurityLevel.S3, } try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { if (err == undefined) { console.log('testKVManagerGetKVStore113 getKVStore success'); - expect(null).assertFail(); + expect((err == undefined) && (store != null)).assertTrue(); } else { console.log('testKVManagerGetKVStore113 getKVStore fail'); + expect(null).assertFail(); } done(); }); @@ -462,7 +465,7 @@ describe('KVManagerCallbackTest', function () { autoSync : true, kvStoreType : factory.KVStoreType.SINGLE_VERSION, schema : '', - securityLevel : factory.SecurityLevel.NO_LEVEL, + securityLevel : factory.SecurityLevel.S4, } try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { @@ -490,15 +493,14 @@ describe('KVManagerCallbackTest', function () { encrypt : false, backup : false, autoSync : true, - kvStoreType : factory.KVStoreType.SINGLE_VERSION, + kvStoreType : factory.KVStoreType.MULTI_VERSION, schema : '', - securityLevel : factory.SecurityLevel.S0, + securityLevel : factory.SecurityLevel.NO_LEVEL, } try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { console.log('testKVManagerGetKVStore115 getKVStore success'); - expect((err == undefined) && (store != null)).assertTrue(); - kvStore = store; + expect(true).assertTrue(); done(); }); } catch (e) { @@ -520,15 +522,14 @@ describe('KVManagerCallbackTest', function () { encrypt : false, backup : false, autoSync : true, - kvStoreType : factory.KVStoreType.SINGLE_VERSION, + kvStoreType : factory.KVStoreType.MULTI_VERSION, schema : '', - securityLevel : factory.SecurityLevel.S1, + securityLevel : factory.SecurityLevel.S0, } try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { console.log('testKVManagerGetKVStore116 getKVStore success'); - expect((err == undefined) && (store != null)).assertTrue(); - kvStore = store; + expect(true).assertTrue(); done(); }); } catch (e) { @@ -550,15 +551,14 @@ describe('KVManagerCallbackTest', function () { encrypt : false, backup : false, autoSync : true, - kvStoreType : factory.KVStoreType.SINGLE_VERSION, + kvStoreType : factory.KVStoreType.MULTI_VERSION, schema : '', - securityLevel : factory.SecurityLevel.S2, + securityLevel : factory.SecurityLevel.S1, } try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { console.log('testKVManagerGetKVStore117 getKVStore success'); - expect((err == undefined) && (store != null)).assertTrue(); - kvStore = store; + expect(true).assertTrue(); done(); }); } catch (e) { @@ -580,15 +580,14 @@ describe('KVManagerCallbackTest', function () { encrypt : false, backup : false, autoSync : true, - kvStoreType : factory.KVStoreType.SINGLE_VERSION, + kvStoreType : factory.KVStoreType.MULTI_VERSION, schema : '', - securityLevel : factory.SecurityLevel.S3, + securityLevel : factory.SecurityLevel.S2, } try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { console.log('testKVManagerGetKVStore118 getKVStore success'); - expect((err == undefined) && (store != null)).assertTrue(); - kvStore = store; + expect(true).assertTrue(); done(); }); } catch (e) { @@ -610,15 +609,43 @@ describe('KVManagerCallbackTest', function () { encrypt : false, backup : false, autoSync : true, - kvStoreType : factory.KVStoreType.SINGLE_VERSION, + kvStoreType : factory.KVStoreType.MULTI_VERSION, schema : '', - securityLevel : factory.SecurityLevel.S4, + securityLevel : factory.SecurityLevel.S3, } try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { console.log('testKVManagerGetKVStore119 getKVStore success'); - expect((err == undefined) && (store != null)).assertTrue(); - kvStore = store; + expect(true).assertTrue(); + 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(); }); } catch (e) { @@ -878,4 +905,47 @@ describe('KVManagerCallbackTest', function () { 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 diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerPromiseJsunit.test.js b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerPromiseJsunit.test.js index 6d04938daedfb36fbec5fcc6c9e9e7cdde0c3e10..94c26f9824bdea79928c40cfacfc0428522a8289 100644 --- a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerPromiseJsunit.test.js +++ b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerPromiseJsunit.test.js @@ -19,6 +19,9 @@ const TEST_BUNDLE_NAME = 'ohos.acts.distributeddatamgr'; const TEST_STORE_ID = 'storeId'; var kvManager = null; var kvStore = null; +const STORE_KEY = 'key_test_string'; +const STORE_VALUE = 'value-test-string'; +var kvStoreNew = null; describe('KVManagerPromiseTest', function () { const config = { @@ -44,6 +47,12 @@ describe('KVManagerPromiseTest', function () { await factory.createKVManager(config).then((manager) => { kvManager = manager; 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) => { console.log('beforeAll createKVManager err ' + err); }); @@ -131,7 +140,7 @@ describe('KVManagerPromiseTest', function () { autoSync: true, kvStoreType: factory.KVStoreType.SINGLE_VERSION, schema: '', - securityLevel: factory.SecurityLevel.S2, + securityLevel: factory.SecurityLevel.NO_LEVEL, } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore003 getKVStore success'); @@ -158,7 +167,7 @@ describe('KVManagerPromiseTest', function () { autoSync: true, kvStoreType: factory.KVStoreType.SINGLE_VERSION, schema: '', - securityLevel: factory.SecurityLevel.S2, + securityLevel: factory.SecurityLevel.S1, } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore004 getKVStore success'); @@ -210,7 +219,7 @@ describe('KVManagerPromiseTest', function () { autoSync: true, kvStoreType: factory.KVStoreType.SINGLE_VERSION, schema: '', - securityLevel: factory.SecurityLevel.S2, + securityLevel: factory.SecurityLevel.S3, } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore006 getKVStore success'); @@ -237,7 +246,7 @@ describe('KVManagerPromiseTest', function () { autoSync: true, kvStoreType: factory.KVStoreType.SINGLE_VERSION, schema: '', - securityLevel: factory.SecurityLevel.S2, + securityLevel: factory.SecurityLevel.S4, } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore007 getKVStore success'); @@ -262,9 +271,9 @@ describe('KVManagerPromiseTest', function () { encrypt: false, backup: false, autoSync: true, - kvStoreType: factory.KVStoreType.SINGLE_VERSION, + kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION, schema: '', - securityLevel: factory.SecurityLevel.S2, + securityLevel: factory.SecurityLevel.NO_LEVEL, } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore008 getKVStore success'); @@ -289,9 +298,9 @@ describe('KVManagerPromiseTest', function () { encrypt: false, backup: false, autoSync: true, - kvStoreType: factory.KVStoreType.SINGLE_VERSION, + kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION, schema: '', - securityLevel: factory.SecurityLevel.S2, + securityLevel: factory.SecurityLevel.S0, } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore009 getKVStore success'); @@ -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.desc Test Js Api KVManager.GetKVStore testcase 010 */ @@ -316,9 +325,9 @@ describe('KVManagerPromiseTest', function () { encrypt: false, backup: false, autoSync: false, - kvStoreType: factory.KVStoreType.SINGLE_VERSION, + kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION, schema: '', - securityLevel: factory.SecurityLevel.S2, + securityLevel: factory.SecurityLevel.S1, } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore010 getKVStore success'); @@ -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.desc Test Js Api KVManager.GetKVStore testcase 011 */ @@ -343,7 +352,7 @@ describe('KVManagerPromiseTest', function () { encrypt: false, backup: false, autoSync: true, - kvStoreType: factory.KVStoreType.SINGLE_VERSION, + kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION, schema: '', securityLevel: factory.SecurityLevel.S2, } @@ -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.desc Test Js Api KVManager.GetKVStore testcase 012 */ @@ -372,7 +381,7 @@ describe('KVManagerPromiseTest', function () { autoSync: true, kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION, schema: '', - securityLevel: factory.SecurityLevel.S2, + securityLevel: factory.SecurityLevel.S3, } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore012 getKVStore success'); @@ -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.desc Test Js Api KVManager.GetKVStore testcase 013 */ @@ -397,9 +406,9 @@ describe('KVManagerPromiseTest', function () { encrypt: false, backup: false, autoSync: true, - kvStoreType: factory.KVStoreType.MULTI_VERSION, + kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION, schema: '', - securityLevel: factory.SecurityLevel.S2, + securityLevel: factory.SecurityLevel.S4, } try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { @@ -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.desc Test Js Api KVManager.GetKVStore testcase 014 */ @@ -426,23 +435,22 @@ describe('KVManagerPromiseTest', function () { encrypt: false, backup: false, autoSync: true, - kvStoreType: factory.KVStoreType.SINGLE_VERSION, + kvStoreType: factory.KVStoreType.MULTI_VERSION, schema: '', securityLevel: factory.SecurityLevel.NO_LEVEL, } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore014 getKVStore success'); - kvStore = store; - expect(store != null).assertTrue(); + expect(null).assertFail(); }).catch((err) => { console.log('testKVManagerGetKVStore014 getKVStore err ' + err); - expect(null).assertFail(); + expect(true).assertTrue(); }); done(); }) /** - * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_PROMISE_1500 + * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1500 * @tc.name [JS-API8]KVManager.GetKVStore. * @tc.desc Test Js Api KVManager.GetKVStore testcase 015 */ @@ -453,23 +461,22 @@ describe('KVManagerPromiseTest', function () { encrypt: false, backup: false, autoSync: true, - kvStoreType: factory.KVStoreType.SINGLE_VERSION, + kvStoreType: factory.KVStoreType.MULTI_VERSION, schema: '', securityLevel: factory.SecurityLevel.S0, } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore015 getKVStore success'); - kvStore = store; - expect(store != null).assertTrue(); + expect(null).assertFail(); }).catch((err) => { console.log('testKVManagerGetKVStore015 getKVStore err ' + err); - expect(null).assertFail(); + expect(true).assertTrue(); }); done(); }) /** - * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_PROMISE_1600 + * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1600 * @tc.name [JS-API8]KVManager.GetKVStore. * @tc.desc Test Js Api KVManager.GetKVStore testcase 016 */ @@ -480,23 +487,22 @@ describe('KVManagerPromiseTest', function () { encrypt: false, backup: false, autoSync: true, - kvStoreType: factory.KVStoreType.SINGLE_VERSION, + kvStoreType: factory.KVStoreType.MULTI_VERSION, schema: '', securityLevel: factory.SecurityLevel.S1, } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore016 getKVStore success'); - kvStore = store; - expect(store != null).assertTrue(); + expect(null).assertFail(); }).catch((err) => { console.log('testKVManagerGetKVStore016 getKVStore err ' + err); - expect(null).assertFail(); + expect(true).assertTrue(); }); done(); }) /** - * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_PROMISE_1700 + * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1700 * @tc.name [JS-API8]KVManager.GetKVStore. * @tc.desc Test Js Api KVManager.GetKVStore testcase 017 */ @@ -507,23 +513,22 @@ describe('KVManagerPromiseTest', function () { encrypt: false, backup: false, autoSync: true, - kvStoreType: factory.KVStoreType.SINGLE_VERSION, + kvStoreType: factory.KVStoreType.MULTI_VERSION, schema: '', securityLevel: factory.SecurityLevel.S2, } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore017 getKVStore success'); - kvStore = store; - expect(store != null).assertTrue(); + expect(null).assertFail(); }).catch((err) => { console.log('testKVManagerGetKVStore017 getKVStore err ' + err); - expect(null).assertFail(); + expect(true).assertTrue(); }); done(); }) /** - * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_PROMISE_1800 + * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1800 * @tc.name [JS-API8]KVManager.GetKVStore. * @tc.desc Test Js Api KVManager.GetKVStore testcase 018 */ @@ -534,23 +539,22 @@ describe('KVManagerPromiseTest', function () { encrypt: false, backup: false, autoSync: true, - kvStoreType: factory.KVStoreType.SINGLE_VERSION, + kvStoreType: factory.KVStoreType.MULTI_VERSION, schema: '', securityLevel: factory.SecurityLevel.S3, } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore018 getKVStore success'); - kvStore = store; - expect(store != null).assertTrue(); + expect(null).assertFail(); }).catch((err) => { console.log('testKVManagerGetKVStore018 getKVStore err ' + err); - expect(null).assertFail(); + expect(true).assertTrue(); }); done(); }) /** - * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_PROMISE_1900 + * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1900 * @tc.name [JS-API8]KVManager.GetKVStore. * @tc.desc Test Js Api KVManager.GetKVStore testcase 019 */ @@ -561,17 +565,16 @@ describe('KVManagerPromiseTest', function () { encrypt: false, backup: false, autoSync: true, - kvStoreType: factory.KVStoreType.SINGLE_VERSION, + kvStoreType: factory.KVStoreType.MULTI_VERSION, schema: '', securityLevel: factory.SecurityLevel.S4, } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore019 getKVStore success'); - kvStore = store; - expect(store != null).assertTrue(); + expect(null).assertFail(); }).catch((err) => { console.log('testKVManagerGetKVStore019 getKVStore err ' + err); - expect(null).assertFail(); + expect(true).assertTrue(); }); done(); }) @@ -582,95 +585,18 @@ describe('KVManagerPromiseTest', function () { * @tc.desc Test Js Api KVManager.CloseKVStore testcase 001 */ 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'); await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) { - console.log('testKVManagerCloseKVStore004 getKVStore success'); + console.log('testKVManagerCloseKVStore001 getKVStore success'); kvStore = store; 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(() => { - console.log('testKVManagerCloseKVStore004 closeKVStore twice'); + console.log('testKVManagerCloseKVStore001 closeKVStore twice'); expect(null).assertFail(); }).catch((err) => { - console.log('testKVManagerCloseKVStore004 closeKVStore twice err ' + err); + console.log('testKVManagerCloseKVStore001 closeKVStore twice err ' + err); }); done(); }) @@ -682,61 +608,11 @@ describe('KVManagerPromiseTest', function () { */ it('testKVManagerDeleteKVStore001', 0, async function (done) { 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(() => { - console.log('testKVManagerDeleteKVStore003 deleteKVStore success'); + console.log('testKVManagerDeleteKVStore001 deleteKVStore success'); expect(null).assertFail(); }).catch((err) => { - console.log('testKVManagerDeleteKVStore003 deleteKVStore err ' + err); + console.log('testKVManagerDeleteKVStore001 deleteKVStore err ' + err); }); done(); }) @@ -915,4 +791,78 @@ describe('KVManagerPromiseTest', function () { kvManager.off('distributedDataServiceDie'); 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 diff --git a/location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js b/location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js index 5ef1a4d0ce570e953db9eeeaccddab3644f820cb..43744798100e5dfb0a1cfd8ce82b3043dcca5a25 100644 --- a/location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js +++ b/location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js @@ -1005,6 +1005,595 @@ describe('geolocationTest', function () { 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(); + }) + }) diff --git a/miscservices/InputMethodTest_ets/entry/src/main/ets/test/RequestDownloadTaskJsunit.test.ets b/miscservices/InputMethodTest_ets/entry/src/main/ets/test/RequestDownloadTaskJsunit.test.ets index 783fddd6701814c7d5facbe2fcc95a8564edd3b5..f198c93f1cdbead0f62a2abe01979d1db51468b1 100644 --- a/miscservices/InputMethodTest_ets/entry/src/main/ets/test/RequestDownloadTaskJsunit.test.ets +++ b/miscservices/InputMethodTest_ets/entry/src/main/ets/test/RequestDownloadTaskJsunit.test.ets @@ -1,339 +1,512 @@ -// @ts-nocheck -/** - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import {describe, it, expect} from 'hypium/index'; -import request from '@ohos.request'; - -export default function requestDownloadJsunit() { - describe('requestDownloadTest', function () { - let downloadConfig = { - url: "www.baidu.com" - }; - let file = { - filename: 'text.txt', - name: 'text.txt', - uri: 'C:\\Program Files', - type: 'text' - }; - let uploadConfig = { - url: "www.baidu.com", - header: 'HTTP', - method: 'post', - files: file, - data: 'jason/xml' - }; - var receivedSize; - var totalSize; - console.log("************* settings Test start*************"); - - /** - * @tc.number requestDownload_test_001 - * @tc.name Test The request DownloadTask - * @tc.desc Function test - */ - it('requestDownload_test_001', 0, async function (done) { - try { - request.download(downloadConfig, (downloadTask) => { - console.log("downloadConfig result:" + JSON.stringify(downloadTask)) - downloadTask.on('progress', (receivedSize, totalSize) => { - console.log("downloadTask on_progress:" + JSON.stringify(receivedSize)); - console.log("downloadTask on_progress:" + JSON.stringify(totalSize)); - this.receivedSize = receivedSize; - this.totalSize = totalSize; - expect(true).assertTrue(); - }) - }); - } catch (exception) { - console.log("requestDownload_test_001 failed due to execute timeout 5s"); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number requestDownload_test_002 - * @tc.name Test The request DownloadTask - * @tc.desc Function test - */ - it('requestDownload_test_002', 0, async function (done) { - try { - request.download(downloadConfig, (downloadTask) => { - console.log("downloadConfig result:" + JSON.stringify(downloadTask)) - downloadTask.off('progress', (receivedSize, totalSize) => { - console.log("downloadTask off_progress:" + JSON.stringify(receivedSize)); - console.log("downloadTask off_progress:" + JSON.stringify(totalSize)); - this.receivedSize = receivedSize; - this.totalSize = totalSize; - expect(true).assertTrue(); - }) - }); - } catch (exception) { - console.log("requestDownload_test_002 failed due to execute timeout 5s"); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number requestDownload_test_003 - * @tc.name Test The request DownloadTask - * @tc.desc Function test - */ - it('requestDownload_test_003', 0, async function (done) { - try { - request.download(downloadConfig, (downloadTask) => { - console.log("downloadConfig result:" + JSON.stringify(downloadTask)) - downloadTask.on('complete', (err) => { - console.log("downloadTask on_complete err:" + err); - expect(true).assertTrue(); - }); - }); - } catch (exception) { - console.log("requestDownload_test_003 failed due to execute timeout 5s"); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number requestDownload_test_004 - * @tc.name Test The request DownloadTask - * @tc.desc Function test - */ - it('requestDownload_test_004', 0, async function (done) { - try { - request.download(downloadConfig, (downloadTask) => { - console.log("downloadConfig result:" + JSON.stringify(downloadTask)) - downloadTask.on('pause', (err) => { - console.log("downloadTask on_pause err:" + err); - expect(true).assertTrue(); - }); - }); - } catch (exception) { - console.log("requestDownload_test_004 failed due to execute timeout 5s"); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number requestDownload_test_005 - * @tc.name Test The request DownloadTask - * @tc.desc Function test - */ - it('requestDownload_test_005', 0, async function (done) { - try { - request.download(downloadConfig, (downloadTask) => { - console.log("downloadConfig result:" + JSON.stringify(downloadTask)) - downloadTask.on('remove', (err) => { - console.log("downloadTask on_remove err:" + err); - expect(true).assertTrue(); - }); - }); - } catch (exception) { - console.log("requestDownload_test_005 failed due to execute timeout 5s"); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number requestDownload_test_006 - * @tc.name Test The request DownloadTask - * @tc.desc Function test - */ - it('requestDownload_test_006', 0, async function (done) { - try { - request.download(downloadConfig, (downloadTask) => { - console.log("downloadConfig result:" + JSON.stringify(downloadTask)); - downloadTask.off('complete', (err) => { - console.log("downloadTask off_complete err:" + err); - expect(true).assertTrue(); - }); - }); - } catch (exception) { - console.log("requestDownload_test_006 failed due to execute timeout 5s"); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number requestDownload_test_007 - * @tc.name Test The request DownloadTask - * @tc.desc Function test - */ - it('requestDownload_test_007', 0, async function (done) { - try { - request.download(downloadConfig, (downloadTask) => { - console.log("downloadConfig result:" + JSON.stringify(downloadTask)) - downloadTask.off('pause', (err) => { - console.log("downloadTask off_pause err:" + err); - expect(true).assertTrue(); - }); - }); - } catch (exception) { - console.log("requestDownload_test_007 failed due to execute timeout 5s"); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number requestDownload_test_007 - * @tc.name Test The request DownloadTask - * @tc.desc Function test - */ - it('requestDownload_test_008', 0, async function (done) { - try { - request.download(downloadConfig, (downloadTask) => { - console.log("downloadConfig result:" + JSON.stringify(downloadTask)) - downloadTask.off('remove', (err) => { - console.log("downloadTask off_remove err:" + err); - expect(true).assertTrue(); - }); - }); - } catch (exception) { - console.log("requestDownload_test_008 failed due to execute timeout 5s"); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number requestDownload_test_009 - * @tc.name Test The request DownloadTask - * @tc.desc Function test - */ - it('requestDownload_test_009', 0, async function (done) { - try { - request.download(downloadConfig, (downloadTask) => { - console.log("downloadConfig result:" + JSON.stringify(downloadTask)) - downloadTask.on('fail', (err) => { - console.log("downloadTask on_fail err:" + err); - expect(true).assertTrue(); - }); - }); - } catch (exception) { - console.log("requestDownload_test_009 failed due to execute timeout 5s"); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number requestDownload_test_010 - * @tc.name Test The request DownloadTask - * @tc.desc Function test - */ - it('requestDownload_test_010', 0, async function (done) { - try { - request.download(downloadConfig, (downloadTask) => { - console.log("downloadConfig result:" + JSON.stringify(downloadTask)) - downloadTask.off('fail', (err) => { - console.log("downloadTask off_fail err:" + err); - expect(true).assertTrue(); - }); - }); - } catch (exception) { - console.log("requestDownload_test_010 failed due to execute timeout 5s"); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number requestDownload_test_011 - * @tc.name Test The request DownloadTask - * @tc.desc Function test - */ - it('requestDownload_test_011', 0, async function (done) { - try { - request.download(downloadConfig, (downloadTask) => { - console.log("downloadConfig result:" + JSON.stringify(downloadTask)) - downloadTask.remove((err) => { - console.log("downloadTask remove err:" + err); - expect(true).assertTrue(); - }); - }); - } catch (exception) { - console.log("requestDownload_test_011 failed due to execute timeout 5s"); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number requestDownload_test_012 - * @tc.name Test The request DownloadTask - * @tc.desc Function test - */ - it('requestDownload_test_012', 0, async function (done) { - try { - request.download(downloadConfig, (downloadTask) => { - console.log("downloadConfig result:" + JSON.stringify(downloadTask)) - downloadTask.query((err) => { - console.log("downloadTask query err:" + err); - expect(true).assertTrue(); - }); - }); - } catch (err) { - console.log("requestDownload_test_012 invoke download error : " + JSON.stringify(err)); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number requestDownload_test_013 - * @tc.name Test The request DownloadTask - * @tc.desc Function test - */ - it('requestDownload_test_013', 0, async function (done) { - try { - request.download(downloadConfig, (downloadTask) => { - console.log("downloadConfig result:" + JSON.stringify(downloadTask)) - downloadTask.queryMimeType((err) => { - console.log("downloadTask queryMimeType err:" + err); - expect(true).assertTrue(); - }); - }); - } catch (exception) { - console.log("requestDownload_test_013 failed due to execute timeout 5s"); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number requestDownload_test_007 - * @tc.name Test The request UploadTask - * @tc.desc Function test - */ - it('requestDownload_test_014', 0, async function (done) { - try { - request.upload(uploadConfig, (uploadTask) => { - console.log("downloadConfig result:" + JSON.stringify(uploadTask)) - expect(true).assertTrue(); - }); - } catch (exception) { - console.log("requestDownload_test_014 failed due to execute timeout 5s"); - expect(true).assertTrue(); - } - done(); - }); - - }) -} +// @ts-nocheck +/** + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, it, expect} from "deccjsunit/index.ets"; +import request from '@ohos.request'; + +export default function requestDownloadJsunit() { + describe('requestDownloadTest', function () { + let downloadConfig = { + url: "www.baidu.com" + }; + let file = { + filename: 'text.txt', + name: 'text.txt', + uri: 'C:\\Program Files', + type: 'text' + }; + let uploadConfig = { + url: "www.baidu.com", + header: 'HTTP', + method: 'post', + files: file, + data: 'jason/xml' + }; + var receivedSize; + var totalSize; + console.log("************* settings Test start*************"); + + /** + * @tc.number requestDownload_test_001 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_001', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.on('progress', (receivedSize, totalSize) => { + console.log("downloadTask on_progress:" + JSON.stringify(receivedSize)); + console.log("downloadTask on_progress:" + JSON.stringify(totalSize)); + this.receivedSize = receivedSize; + this.totalSize = totalSize; + expect(true).assertTrue(); + }) + }); + } catch (exception) { + console.log("requestDownload_test_001 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_002 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_002', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.off('progress', (receivedSize, totalSize) => { + console.log("downloadTask off_progress:" + JSON.stringify(receivedSize)); + console.log("downloadTask off_progress:" + JSON.stringify(totalSize)); + this.receivedSize = receivedSize; + this.totalSize = totalSize; + expect(true).assertTrue(); + }) + }); + } catch (exception) { + console.log("requestDownload_test_002 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_003 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_003', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.on('complete', (err) => { + console.log("downloadTask on_complete err:" + err); + expect(true).assertTrue(); + }); + }); + } catch (exception) { + console.log("requestDownload_test_003 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_004 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_004', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.on('pause', (err) => { + console.log("downloadTask on_pause err:" + err); + expect(true).assertTrue(); + }); + }); + } catch (exception) { + console.log("requestDownload_test_004 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_005 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_005', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.on('remove', (err) => { + console.log("downloadTask on_remove err:" + err); + expect(true).assertTrue(); + }); + }); + } catch (exception) { + console.log("requestDownload_test_005 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_006 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_006', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)); + downloadTask.off('complete', (err) => { + console.log("downloadTask off_complete err:" + err); + expect(true).assertTrue(); + }); + }); + } catch (exception) { + console.log("requestDownload_test_006 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_007 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_007', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.off('pause', (err) => { + console.log("downloadTask off_pause err:" + err); + expect(true).assertTrue(); + }); + }); + } catch (exception) { + console.log("requestDownload_test_007 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_007 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_008', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.off('remove', (err) => { + console.log("downloadTask off_remove err:" + err); + expect(true).assertTrue(); + }); + }); + } catch (exception) { + console.log("requestDownload_test_008 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_009 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_009', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.on('fail', (err) => { + console.log("downloadTask on_fail err:" + err); + expect(true).assertTrue(); + }); + }); + } catch (exception) { + console.log("requestDownload_test_009 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_010 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_010', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.off('fail', (err) => { + console.log("downloadTask off_fail err:" + err); + expect(true).assertTrue(); + }); + }); + } catch (exception) { + console.log("requestDownload_test_010 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_011 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_011', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.remove((err) => { + console.log("downloadTask remove err:" + err); + expect(true).assertTrue(); + }); + }); + } catch (exception) { + console.log("requestDownload_test_011 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_012 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_012', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.query((err) => { + console.log("downloadTask query err:" + err); + expect(true).assertTrue(); + }); + }); + } catch (err) { + console.log("requestDownload_test_012 invoke download error : " + JSON.stringify(err)); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_013 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_013', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.queryMimeType((err) => { + console.log("downloadTask queryMimeType err:" + err); + expect(true).assertTrue(); + }); + }); + } catch (exception) { + console.log("requestDownload_test_013 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_007 + * @tc.name Test The request UploadTask + * @tc.desc Function test + */ + it('requestDownload_test_014', 0, async function (done) { + try { + request.upload(uploadConfig, (uploadTask) => { + console.log("downloadConfig result:" + JSON.stringify(uploadTask)) + expect(true).assertTrue(); + }); + } catch (exception) { + console.log("requestDownload_test_014 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + 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(); + }); + + }) +} +} diff --git a/miscservices/InputMethodTest_ets/entry/src/main/ets/test/RequestJsunit.test.ets b/miscservices/InputMethodTest_ets/entry/src/main/ets/test/RequestJsunit.test.ets index 4e67731be3be5e8435c58d5f5d5497628a9b4e1e..599ae27bab636657d4e5f36a10a4b7b8b6681304 100644 --- a/miscservices/InputMethodTest_ets/entry/src/main/ets/test/RequestJsunit.test.ets +++ b/miscservices/InputMethodTest_ets/entry/src/main/ets/test/RequestJsunit.test.ets @@ -1,225 +1,263 @@ -// @ts-nocheck -/** - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import {describe, it, expect} from 'hypium/index'; -import request from '@ohos.request'; - -export default function requestJsunit() { - describe('requestTest', function () { - - /** - * @tc.name: ohos.request_request_0001 - * @tc.desc: NETWORK_MOBILE NETWORK_WIFI ERROR_CANNOT_RESUME ERROR_DEVICE_NOT_FOUND Values detection - * - * @tc.author: kangyuntao - */ - it('request_test_0001', 0, async function (done) { - console.log("-----------------------Request_test_0001 is starting-----------------------"); - try { - request.NETWORK_MOBILE = 1; - console.log("request_test_0001 request.NETWORK_MOBILE:" + request.NETWORK_MOBILE); - expect(request.NETWORK_MOBILE).assertEqual(1); - request.NETWORK_WIFI = 2; - console.log("request_test_0001 request.NETWORK_WIFI:" + request.NETWORK_WIFI); - expect(request.NETWORK_WIFI).assertEqual(2); - request.ERROR_CANNOT_RESUME = 3; - console.log("request_test_0001 request.ERROR_CANNOT_RESUME:" + request.ERROR_CANNOT_RESUME); - expect(request.ERROR_CANNOT_RESUME).assertEqual(3); - request.ERROR_DEVICE_NOT_FOUND = 4; - console.log("request_test_0001 request.ERROR_DEVICE_NOT_FOUND:" + request.ERROR_DEVICE_NOT_FOUND); - expect(request.ERROR_DEVICE_NOT_FOUND).assertEqual(4); - } catch (err) { - expect(true).assertEqual(true); - console.error("request_test_0001 error: " + err); - } - console.log("-----------------------Request_test_0001 end-----------------------"); - done(); - }); - - /** - * @tc.name: ohos.request_request_0002 - * @tc.desc: ERROR_FILE_ALREADY_EXISTS ERROR_FILE_ERROR ERROR_HTTP_DATA_ERROR - * ERROR_INSUFFICIENT_SPACE Values detection - * @tc.author: kangyuntao - */ - it('request_test_0002', 0, async function (done) { - console.log("-----------------------Request_test_0002 is starting-----------------------"); - try { - request.ERROR_FILE_ALREADY_EXISTS = 5; - console.log("request_test_0002 request.ERROR_FILE_ALREADY_EXISTS:" + request.ERROR_FILE_ALREADY_EXISTS); - expect(request.ERROR_FILE_ALREADY_EXISTS).assertEqual(5); - request.ERROR_FILE_ERROR = 6; - console.log("request_test_0002 request.ERROR_FILE_ERROR:" + request.ERROR_FILE_ERROR); - expect(request.ERROR_FILE_ERROR).assertEqual(6); - request.ERROR_HTTP_DATA_ERROR = 7; - console.log("request_test_0002 request.ERROR_HTTP_DATA_ERROR:" + request.ERROR_HTTP_DATA_ERROR); - expect(request.ERROR_HTTP_DATA_ERROR).assertEqual(7); - request.ERROR_INSUFFICIENT_SPACE = 8; - console.log("request_test_0002 request.ERROR_INSUFFICIENT_SPACE:" + request.ERROR_INSUFFICIENT_SPACE); - expect(request.ERROR_INSUFFICIENT_SPACE).assertEqual(8); - } catch (err) { - expect(true).assertEqual(true); - console.error("request_test_0002 error: " + err); - } - console.log("-----------------------Request_test_0002 end-----------------------"); - done(); - }); - - /** - * @tc.name: ohos.request_request_0003 - * @tc.desc: ERROR_TOO_MANY_REDIRECTS ERROR_UNHANDLED_HTTP_CODE ERROR_UNHANDLED_HTTP_CODE - * PAUSED_QUEUED_FOR_WIFI Values detection - * @tc.author: kangyuntao - */ - it('request_test_0003', 0, async function (done) { - console.log("-----------------------Request_test_0003 is starting-----------------------"); - try { - request.ERROR_TOO_MANY_REDIRECTS = 9; - console.log("request_test_0003 request.ERROR_TOO_MANY_REDIRECTS:" + request.ERROR_TOO_MANY_REDIRECTS); - expect(request.ERROR_TOO_MANY_REDIRECTS).assertEqual(9); - request.ERROR_UNHANDLED_HTTP_CODE = 10; - console.log("request_test_0003 request.ERROR_UNHANDLED_HTTP_CODE:" + request.ERROR_UNHANDLED_HTTP_CODE); - expect(request.ERROR_UNHANDLED_HTTP_CODE).assertEqual(10); - request.ERROR_UNKNOWN = 11; - console.log("request_test_0003 request.ERROR_UNKNOWN:" + request.ERROR_UNKNOWN); - expect(request.ERROR_UNKNOWN).assertEqual(11); - request.PAUSED_QUEUED_FOR_WIFI = 12; - console.log("request_test_0003 request.PAUSED_QUEUED_FOR_WIFI:" + request.PAUSED_QUEUED_FOR_WIFI); - expect(request.PAUSED_QUEUED_FOR_WIFI).assertEqual(12); - } catch (err) { - expect(true).assertEqual(true); - console.error("request_test_0003 error: " + err); - } - console.log("-----------------------Request_test_0003 end-----------------------"); - done(); - }); - - /** - * @tc.name: ohos.request_request_0004 - * @tc.desc: PAUSED_UNKNOWN PAUSED_WAITING_FOR_NETWORK PAUSED_WAITING_TO_RETRY ESSION_FAILED Values detection - * @tc.author: kangyuntao - */ - it('request_test_0004', 0, async function (done) { - console.log("-----------------------Request_test_0004 is starting-----------------------"); - try { - request.PAUSED_UNKNOWN = 13; - console.log("request_test_0004 request.PAUSED_UNKNOWN:" + request.PAUSED_UNKNOWN); - expect(request.PAUSED_UNKNOWN).assertEqual(13); - request.PAUSED_WAITING_FOR_NETWORK = 14; - console.log("request_test_0004 request.PAUSED_WAITING_FOR_NETWORK:" + request.PAUSED_WAITING_FOR_NETWORK); - expect(request.PAUSED_WAITING_FOR_NETWORK).assertEqual(14); - request.PAUSED_WAITING_TO_RETRY = 15; - console.log("request_test_0004 request.PAUSED_WAITING_TO_RETRY:" + request.PAUSED_WAITING_TO_RETRY); - expect(request.PAUSED_WAITING_TO_RETRY).assertEqual(15); - request.SESSION_FAILED = 16; - console.log("request_test_0004 request.SESSION_FAILED:" + request.SESSION_FAILED); - expect(request.SESSION_FAILED).assertEqual(16); - } catch (err) { - expect(true).assertEqual(true); - console.error("request_test_0004 error: " + err); - } - console.log("-----------------------Request_test_0004 end-----------------------"); - done(); - }); - - /** - * @tc.name: ohos.request_request_0005 - * @tc.desc: SESSION_PAUSED SESSION_PENDING SESSION_RUNNING SESSION_SUCCESSFUL Values detection - * @tc.author: kangyuntao - */ - it('request_test_0005', 0, async function (done) { - console.log("-----------------------Request_test_0005 is starting-----------------------"); - try { - request.SESSION_PAUSED = 17; - console.log("request_test_0004 request.SESSION_PAUSED:" + request.SESSION_PAUSED); - expect(request.SESSION_PAUSED).assertEqual(17); - request.SESSION_PENDING = 18; - console.log("request_test_0004 request.SESSION_PENDING:" + request.SESSION_PENDING); - expect(request.SESSION_PENDING).assertEqual(18); - request.SESSION_RUNNING = 19; - console.log("request_test_0004 request.SESSION_RUNNING:" + request.SESSION_RUNNING); - expect(request.SESSION_RUNNING).assertEqual(19); - request.SESSION_SUCCESSFUL = 20; - console.log("request_test_0004 request.SESSION_SUCCESSFUL:" + request.SESSION_SUCCESSFUL); - expect(request.SESSION_SUCCESSFUL).assertEqual(20); - } catch (err) { - expect(true).assertEqual(true); - console.error("request_test_0005 error: " + err); - } - console.log("-----------------------Request_test_0005 end-----------------------"); - done(); - }); - - /** - * @tc.name: ohos.request_request_upload - * @tc.desc: request_upload Method detection - * @tc.author: kangyuntao - */ - it('request_upload_0006', 0, async function (done) { - console.log("-----------------------Request_test_0006 is starting-----------------------"); - try { - console.log("request_upload_0006 getUploadConfig() " + getUploadConfig()); - request.upload(getUploadConfig(), (err, uploadTask) => { - if (err) { - expect().assertFail(); - } else { - console.log("request_upload_0006 progress uploadTask =" + JSON.stringify(uploadTask)); - uploadTask.on('progress', function (data1, data2) { - console.log("request_upload_0006 on data1 =" + data1); - console.log("request_upload_0006 on data2 =" + data2); - }) - uploadTask.off('progress', function (data1, data2) { - console.log("request_upload_0006 off data1 =" + data1); - console.log("request_upload_0006 off data2 =" + data2); - }) - uploadTask.remove((err, data) => { - console.log("request_upload_0006 remove =" + data); - }) - } - }) - } catch (err) { - expect(true).assertEqual(true); - console.error("request_upload_0006 error: " + err); - } - console.log("-----------------------request_upload_0006 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 - } -} +// @ts-nocheck +/** + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, it, expect} from "deccjsunit/index.ets"; +import request from '@ohos.request'; + +export default function requestJsunit() { + describe('requestTest', function () { + + /** + * @tc.name: ohos.request_request_0001 + * @tc.desc: NETWORK_MOBILE NETWORK_WIFI ERROR_CANNOT_RESUME ERROR_DEVICE_NOT_FOUND Values detection + * + * @tc.author: kangyuntao + */ + it('request_test_0001', 0, async function (done) { + console.log("-----------------------Request_test_0001 is starting-----------------------"); + try { + request.NETWORK_MOBILE = 1; + console.log("request_test_0001 request.NETWORK_MOBILE:" + request.NETWORK_MOBILE); + expect(request.NETWORK_MOBILE).assertEqual(1); + request.NETWORK_WIFI = 2; + console.log("request_test_0001 request.NETWORK_WIFI:" + request.NETWORK_WIFI); + expect(request.NETWORK_WIFI).assertEqual(2); + request.ERROR_CANNOT_RESUME = 3; + console.log("request_test_0001 request.ERROR_CANNOT_RESUME:" + request.ERROR_CANNOT_RESUME); + expect(request.ERROR_CANNOT_RESUME).assertEqual(3); + request.ERROR_DEVICE_NOT_FOUND = 4; + console.log("request_test_0001 request.ERROR_DEVICE_NOT_FOUND:" + request.ERROR_DEVICE_NOT_FOUND); + expect(request.ERROR_DEVICE_NOT_FOUND).assertEqual(4); + } catch (err) { + expect(true).assertEqual(true); + console.error("request_test_0001 error: " + err); + } + console.log("-----------------------Request_test_0001 end-----------------------"); + done(); + }); + + /** + * @tc.name: ohos.request_request_0002 + * @tc.desc: ERROR_FILE_ALREADY_EXISTS ERROR_FILE_ERROR ERROR_HTTP_DATA_ERROR + * ERROR_INSUFFICIENT_SPACE Values detection + * @tc.author: kangyuntao + */ + it('request_test_0002', 0, async function (done) { + console.log("-----------------------Request_test_0002 is starting-----------------------"); + try { + request.ERROR_FILE_ALREADY_EXISTS = 5; + console.log("request_test_0002 request.ERROR_FILE_ALREADY_EXISTS:" + request.ERROR_FILE_ALREADY_EXISTS); + expect(request.ERROR_FILE_ALREADY_EXISTS).assertEqual(5); + request.ERROR_FILE_ERROR = 6; + console.log("request_test_0002 request.ERROR_FILE_ERROR:" + request.ERROR_FILE_ERROR); + expect(request.ERROR_FILE_ERROR).assertEqual(6); + request.ERROR_HTTP_DATA_ERROR = 7; + console.log("request_test_0002 request.ERROR_HTTP_DATA_ERROR:" + request.ERROR_HTTP_DATA_ERROR); + expect(request.ERROR_HTTP_DATA_ERROR).assertEqual(7); + request.ERROR_INSUFFICIENT_SPACE = 8; + console.log("request_test_0002 request.ERROR_INSUFFICIENT_SPACE:" + request.ERROR_INSUFFICIENT_SPACE); + expect(request.ERROR_INSUFFICIENT_SPACE).assertEqual(8); + } catch (err) { + expect(true).assertEqual(true); + console.error("request_test_0002 error: " + err); + } + console.log("-----------------------Request_test_0002 end-----------------------"); + done(); + }); + + /** + * @tc.name: ohos.request_request_0003 + * @tc.desc: ERROR_TOO_MANY_REDIRECTS ERROR_UNHANDLED_HTTP_CODE ERROR_UNHANDLED_HTTP_CODE + * PAUSED_QUEUED_FOR_WIFI Values detection + * @tc.author: kangyuntao + */ + it('request_test_0003', 0, async function (done) { + console.log("-----------------------Request_test_0003 is starting-----------------------"); + try { + request.ERROR_TOO_MANY_REDIRECTS = 9; + console.log("request_test_0003 request.ERROR_TOO_MANY_REDIRECTS:" + request.ERROR_TOO_MANY_REDIRECTS); + expect(request.ERROR_TOO_MANY_REDIRECTS).assertEqual(9); + request.ERROR_UNHANDLED_HTTP_CODE = 10; + console.log("request_test_0003 request.ERROR_UNHANDLED_HTTP_CODE:" + request.ERROR_UNHANDLED_HTTP_CODE); + expect(request.ERROR_UNHANDLED_HTTP_CODE).assertEqual(10); + request.ERROR_UNKNOWN = 11; + console.log("request_test_0003 request.ERROR_UNKNOWN:" + request.ERROR_UNKNOWN); + expect(request.ERROR_UNKNOWN).assertEqual(11); + request.PAUSED_QUEUED_FOR_WIFI = 12; + console.log("request_test_0003 request.PAUSED_QUEUED_FOR_WIFI:" + request.PAUSED_QUEUED_FOR_WIFI); + expect(request.PAUSED_QUEUED_FOR_WIFI).assertEqual(12); + } catch (err) { + expect(true).assertEqual(true); + console.error("request_test_0003 error: " + err); + } + console.log("-----------------------Request_test_0003 end-----------------------"); + done(); + }); + + /** + * @tc.name: ohos.request_request_0004 + * @tc.desc: PAUSED_UNKNOWN PAUSED_WAITING_FOR_NETWORK PAUSED_WAITING_TO_RETRY ESSION_FAILED Values detection + * @tc.author: kangyuntao + */ + it('request_test_0004', 0, async function (done) { + console.log("-----------------------Request_test_0004 is starting-----------------------"); + try { + request.PAUSED_UNKNOWN = 13; + console.log("request_test_0004 request.PAUSED_UNKNOWN:" + request.PAUSED_UNKNOWN); + expect(request.PAUSED_UNKNOWN).assertEqual(13); + request.PAUSED_WAITING_FOR_NETWORK = 14; + console.log("request_test_0004 request.PAUSED_WAITING_FOR_NETWORK:" + request.PAUSED_WAITING_FOR_NETWORK); + expect(request.PAUSED_WAITING_FOR_NETWORK).assertEqual(14); + request.PAUSED_WAITING_TO_RETRY = 15; + console.log("request_test_0004 request.PAUSED_WAITING_TO_RETRY:" + request.PAUSED_WAITING_TO_RETRY); + expect(request.PAUSED_WAITING_TO_RETRY).assertEqual(15); + request.SESSION_FAILED = 16; + console.log("request_test_0004 request.SESSION_FAILED:" + request.SESSION_FAILED); + expect(request.SESSION_FAILED).assertEqual(16); + } catch (err) { + expect(true).assertEqual(true); + console.error("request_test_0004 error: " + err); + } + console.log("-----------------------Request_test_0004 end-----------------------"); + done(); + }); + + /** + * @tc.name: ohos.request_request_0005 + * @tc.desc: SESSION_PAUSED SESSION_PENDING SESSION_RUNNING SESSION_SUCCESSFUL Values detection + * @tc.author: kangyuntao + */ + it('request_test_0005', 0, async function (done) { + console.log("-----------------------Request_test_0005 is starting-----------------------"); + try { + request.SESSION_PAUSED = 17; + console.log("request_test_0004 request.SESSION_PAUSED:" + request.SESSION_PAUSED); + expect(request.SESSION_PAUSED).assertEqual(17); + request.SESSION_PENDING = 18; + console.log("request_test_0004 request.SESSION_PENDING:" + request.SESSION_PENDING); + expect(request.SESSION_PENDING).assertEqual(18); + request.SESSION_RUNNING = 19; + console.log("request_test_0004 request.SESSION_RUNNING:" + request.SESSION_RUNNING); + expect(request.SESSION_RUNNING).assertEqual(19); + request.SESSION_SUCCESSFUL = 20; + console.log("request_test_0004 request.SESSION_SUCCESSFUL:" + request.SESSION_SUCCESSFUL); + expect(request.SESSION_SUCCESSFUL).assertEqual(20); + } catch (err) { + expect(true).assertEqual(true); + console.error("request_test_0005 error: " + err); + } + console.log("-----------------------Request_test_0005 end-----------------------"); + done(); + }); + + /** + * @tc.name: ohos.request_request_upload + * @tc.desc: request_upload Method detection + * @tc.author: kangyuntao + */ + it('request_upload_0006', 0, async function (done) { + console.log("-----------------------Request_test_0006 is starting-----------------------"); + try { + console.log("request_upload_0006 getUploadConfig() " + getUploadConfig()); + request.upload(getUploadConfig(), (err, uploadTask) => { + if (err) { + expect().assertFail(); + } else { + console.log("request_upload_0006 progress uploadTask =" + JSON.stringify(uploadTask)); + uploadTask.on('progress', function (data1, data2) { + console.log("request_upload_0006 on data1 =" + data1); + console.log("request_upload_0006 on data2 =" + data2); + }) + uploadTask.off('progress', function (data1, data2) { + console.log("request_upload_0006 off data1 =" + data1); + console.log("request_upload_0006 off data2 =" + data2); + }) + uploadTask.remove((err, data) => { + console.log("request_upload_0006 remove =" + data); + }) + } + }) + } catch (err) { + expect(true).assertEqual(true); + console.error("request_upload_0006 error: " + err); + } + console.log("-----------------------request_upload_0006 end-----------------------"); + done(); + }) + }); + + /** + * @tc.number request_upload_0007 + * @tc.name: test_request_upload_0007 + * @tc.desc: request_upload Method detection + */ + it('request_upload_0007', 0, async function (done) { + console.log("-----------------------request_upload_0007 is starting-----------------------"); + try { + console.log("request_upload_0007 getUploadConfig() " + getUploadConfig()); + request.upload(getUploadConfig(), (err, uploadTask) => { + if (err) { + expect().assertFail(); + } else { + console.log("request_upload_0007 progress uploadTask =" + JSON.stringify(uploadTask)); + uploadTask.on('headerReceive', function (data1, data2) { + console.log("request_upload_0007 headerReceive on data1 =" + data1); + console.log("request_upload_0007 headerReceive on data2 =" + data2); + }) + uploadTask.off('headerReceive', function (data1, data2) { + console.log("request_upload_0007 headerReceive off data1 =" + data1); + console.log("request_upload_0007 headerReceive off data2 =" + data2); + }) + 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 + } +} diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioFramework.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioFramework.test.js index 3e41042123e6399db23917e4c66c965521b9436b..b299e918653a65e9dea6645fabbc15be62f0cb22 100755 --- a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioFramework.test.js +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioFramework.test.js @@ -29,6 +29,7 @@ describe('audioManger', function () { var maxVol = 15; var lowVol = 5; var highVol = 14; + var newVol = 20; var outOfRangeVol = 28; var longValue = '28374837458743875804735081439085918459801437584738967509184509813904850914375904790589104801843'; @@ -882,6 +883,32 @@ describe('audioManger', function () { 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.name : setVolume - Media - Callback - Change Ringtone vol @@ -946,6 +973,35 @@ describe('audioManger', function () { await promise; 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 diff --git a/notification/ans_standard/publish_test/getwantagentinfo/entry/src/main/js/test/WantAgent.test.js b/notification/ans_standard/publish_test/getwantagentinfo/entry/src/main/js/test/WantAgent.test.js index 4fcfb52a8385a916fdb930c5d60686415e6ac4ad..908564e7d99075fc90229d6f42c2cea18b893c5f 100644 --- a/notification/ans_standard/publish_test/getwantagentinfo/entry/src/main/js/test/WantAgent.test.js +++ b/notification/ans_standard/publish_test/getwantagentinfo/entry/src/main/js/test/WantAgent.test.js @@ -15,6 +15,7 @@ import wantAgent from '@ohos.wantAgent'; import { OperationType, WantAgentFlags } from '@ohos.wantagent'; + import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; var WantAgenta; diff --git a/powermgr/powermgrbattery/src/main/js/default/test/battery_common_event.test.js b/powermgr/powermgrbattery/src/main/js/default/test/battery_common_event.test.js index 7aedacee4f254052e4fbf1e98c6265b3c1a1aba0..40f183ae7e50d4284983803b3031b652c3d3efc3 100644 --- a/powermgr/powermgrbattery/src/main/js/default/test/battery_common_event.test.js +++ b/powermgr/powermgrbattery/src/main/js/default/test/battery_common_event.test.js @@ -87,9 +87,7059 @@ describe('appInfoTest', function () { done(); }) + /** + * @tc.number BatteryCommonEventTest_008 + * @tc.name subscribe boot completed common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_008', 0, function (done) { + createBootCompletedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_009 + * @tc.name subscribe locked boot completed common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_009', 0, function (done) { + createLockedBootCompletedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_010 + * @tc.name subscribe shutdown common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_010', 0, function (done) { + createShutdownSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_011 + * @tc.name subscribe screen on common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_011', 0, function (done) { + createScreenOnSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_012 + * @tc.name subscribe user present common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_012', 0, function (done) { + createUserPresentSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_013 + * @tc.name subscribe time tick common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_013', 0, function (done) { + createTimeTickSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_014 + * @tc.name subscribe screen off common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_014', 0, function (done) { + createScreenOffSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_015 + * @tc.name subscribe time changed common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_015', 0, function (done) { + createTimeChangedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_016 + * @tc.name subscribe date changed common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_016', 0, function (done) { + createDateChangedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_017 + * @tc.name subscribe timezone changed common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_017', 0, function (done) { + createTimezoneChangedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_018 + * @tc.name subscribe close system dialogs common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_018', 0, function (done) { + createCloseSystemDialogsSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_019 + * @tc.name subscribe package added common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_019', 0, function (done) { + createPackageAddedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_020 + * @tc.name subscribe package replaced common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_020', 0, function (done) { + createPackageReplacedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_021 + * @tc.name subscribe my package replaced common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_021', 0, function (done) { + createMyPackageReplacedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_022 + * @tc.name subscribe package removed common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_022', 0, function (done) { + createPackageRemovedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_023 + * @tc.name subscribe bundle removed common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_023', 0, function (done) { + createBundleRemovedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_024 + * @tc.name subscribe PackageFullyRemoved common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_024', 0, function (done) { + createPackageFullyRemovedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_025 + * @tc.name subscribe PackageChanged common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_025', 0, function (done) { + createPackageChangedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_026 + * @tc.name subscribe PackageRestarted common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_026', 0, function (done) { + createPackageRestartedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_027 + * @tc.name subscribe PackageDataCleared common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_027', 0, function (done) { + createPackageDataClearedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_028 + * @tc.name subscribe PackageSuspended common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_028', 0, function (done) { + createPackageSuspendedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_029 + * @tc.name subscribe PackagesUnsuspended common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_029', 0, function (done) { + createPackagesUnsuspendedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_030 + * @tc.name subscribe MyPackageSuspended common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_030', 0, function (done) { + createMyPackageSuspendedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_031 + * @tc.name subscribe MyPackageUnsuspended common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_031', 0, function (done) { + createMyPackageUnsuspendedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_032 + * @tc.name subscribe MyPackageFirstLaunch common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_032', 0, function (done) { + createMyPackageFirstLaunchSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_033 + * @tc.name subscribe MyPackageNeedsVerification common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_033', 0, function (done) { + createMyPackageNeedsVerificationSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_034 + * @tc.name subscribe ExternalApplicationsAvailable common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_034', 0, function (done) { + createExternalApplicationsAvailableSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_035 + * @tc.name subscribe ExternalApplicationsUnAvailable common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_035', 0, function (done) { + createExternalApplicationsUnAvailableSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_036 + * @tc.name subscribe ConfigurationChanged common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_036', 0, function (done) { + createConfigurationChangedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_037 + * @tc.name subscribe LocateChanged common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_037', 0, function (done) { + createLocateChangedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_038 + * @tc.name subscribe ManagePackageStorage common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_038', 0, function (done) { + createManagePackageStorageSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_039 + * @tc.name subscribe DriveMode common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_039', 0, function (done) { + createDriveModeSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_040 + * @tc.name subscribe HomeMode common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_040', 0, function (done) { + createHomeModeSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_041 + * @tc.name subscribe OfficeMode common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_041', 0, function (done) { + createOfficeModeSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_042 + * @tc.name subscribe UserStarted common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_042', 0, function (done) { + createUserStartedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_043 + * @tc.name subscribe UserBackground common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_043', 0, function (done) { + createUserBackgroundSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_044 + * @tc.name subscribe UserForground common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_044', 0, function (done) { + createUserForgroundSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_045 + * @tc.name subscribe UserSwitched common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_045', 0, function (done) { + createUserSwitchedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_046 + * @tc.name subscribe UserStarting common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_046', 0, function (done) { + createUserStartingSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_047 + * @tc.name subscribe UserUnlocked common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_047', 0, function (done) { + createUserUnlockedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_048 + * @tc.name subscribe UserStopping common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_048', 0, function (done) { + createUserStoppingSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_049 + * @tc.name subscribe UserStopped common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_049', 0, function (done) { + createUserStoppedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_050 + * @tc.name subscribe HwidLogin common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_050', 0, function (done) { + createHwidLoginSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_051 + * @tc.name subscribe HwidLogout common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_051', 0, function (done) { + createHwidLogoutSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_052 + * @tc.name subscribe HwidTokenInvalid common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_052', 0, function (done) { + createHwidTokenInvalidSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_053 + * @tc.name subscribe HwidLogOff common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_053', 0, function (done) { + createHwidLogOffSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_054 + * @tc.name subscribe WifiPowerState common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_054', 0, function (done) { + createWifiPowerStateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_055 + * @tc.name subscribe WifiScanFinished common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_055', 0, function (done) { + createWifiScanFinishedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_056 + * @tc.name subscribe WifiRssiValue common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_056', 0, function (done) { + createWifiRssiValueSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_057 + * @tc.name subscribe WifiConnState common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_057', 0, function (done) { + createWifiConnStateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_058 + * @tc.name subscribe WifiHostpotState common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_058', 0, function (done) { + createWifiHostpotStateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_059 + * @tc.name subscribe WifiApStaJoin common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_059', 0, function (done) { + createWifiApStaJoinSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_060 + * @tc.name subscribe WifiApStaLeave common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_060', 0, function (done) { + createWifiApStaLeaveSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_061 + * @tc.name subscribe WifiMplinkStateChange common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_061', 0, function (done) { + createWifiMplinkStateChangeSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_062 + * @tc.name subscribe WifiP2PConnState common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_062', 0, function (done) { + createWifiP2PConnStateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_063 + * @tc.name subscribe WifiP2PStateChanged common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_063', 0, function (done) { + createWifiP2PStateChangedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_064 + * @tc.name subscribe WifiP2PPeersStateChanged common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_064', 0, function (done) { + createWifiP2PPeersStateChangedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_065 + * @tc.name subscribe WifiP2PPeersDiscoveryStateChanged common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_065', 0, function (done) { + createWifiP2PPeersDiscoveryStateChangedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_066 + * @tc.name subscribe WifiP2PCurrentDeviceStateChanged common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_066', 0, function (done) { + createWifiP2PCurrentDeviceStateChangedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_067 + * @tc.name subscribe WifiP2PGroupStateChanged common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_067', 0, function (done) { + createWifiP2PGroupStateChangedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_068 + * @tc.name subscribe BluetoothHandsfreeAgConntectStateUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_068', 0, function (done) { + createBluetoothHandsfreeAgConntectStateUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_069 + * @tc.name subscribe BluetoothHandsfreeAgConntectDeviceUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_069', 0, function (done) { + createBluetoothHandsfreeAgConntectDeviceUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_070 + * @tc.name subscribe BluetoothHandsfreeAgAudioStateUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_070', 0, function (done) { + createBluetoothHandsfreeAgAudioStateUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_071 + * @tc.name subscribe BluetoothA2DPsourceConnectStateUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_071', 0, function (done) { + createBluetoothA2DPsourceConnectStateUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_072 + * @tc.name subscribe BluetoothA2DPsourceCurrentDeviceUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_072', 0, function (done) { + createBluetoothA2DPsourceCurrentDeviceUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_073 + * @tc.name subscribe BluetoothA2DPsourcePlayingStateUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_073', 0, function (done) { + createBluetoothA2DPsourcePlayingStateUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_074 + * @tc.name subscribe BluetoothA2DPsourceAvrcpConntectStateUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_074', 0, function (done) { + createBluetoothA2DPsourceAvrcpConntectStateUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_075 + * @tc.name subscribe BluetoothA2DPsourceCodecValueUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_075', 0, function (done) { + createBluetoothA2DPsourceCodecValueUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_076 + * @tc.name subscribe BluetoothRemotedeviceDiscovered common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_076', 0, function (done) { + createBluetoothRemotedeviceDiscoveredSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_077 + * @tc.name subscribe BluetoothRemotedeviceClassValueUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_077', 0, function (done) { + createBluetoothRemotedeviceClassValueUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_078 + * @tc.name subscribe BluetoothRemotedeviceAclConnected common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_078', 0, function (done) { + createBluetoothRemotedeviceAclConnectedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_079 + * @tc.name subscribe BluetoothRemotedeviceAclDisconnected common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_079', 0, function (done) { + createBluetoothRemotedeviceAclDisconnectedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_080 + * @tc.name subscribe BluetoothRemotedeviceNameUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_080', 0, function (done) { + createBluetoothRemotedeviceNameUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_081 + * @tc.name subscribe BluetoothRemotedevicePairState common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_081', 0, function (done) { + createBluetoothRemotedevicePairStateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_082 + * @tc.name subscribe BluetoothRemotedeviceBateryValueUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_082', 0, function (done) { + createBluetoothRemotedeviceBateryValueUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_083 + * @tc.name subscribe BluetoothRemotedeviceSdpResult common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_083', 0, function (done) { + createBluetoothRemotedeviceSdpResultSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_084 + * @tc.name subscribe BluetoothRemotedeviceUuidValue common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_084', 0, function (done) { + createBluetoothRemotedeviceUuidValueSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_085 + * @tc.name subscribe BluetoothPairingReq common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_085', 0, function (done) { + createBluetoothPairingReqSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_086 + * @tc.name subscribe BluetoothRemotedevicePairingCancel common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_086', 0, function (done) { + createBluetoothRemotedevicePairingCancelSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_087 + * @tc.name subscribe BluetoothRemotedeviceConntectReq common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_087', 0, function (done) { + createBluetoothRemotedeviceConntectReqSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_088 + * @tc.name subscribe BluetoothRemotedeviceConntectReply common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_088', 0, function (done) { + createBluetoothRemotedeviceConntectReplySubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_089 + * @tc.name subscribe BluetoothRemotedeviceConntectCancel common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_089', 0, function (done) { + createBluetoothRemotedeviceConntectCancelSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_090 + * @tc.name subscribe BluetoothHandsfreeunitConntectStateUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_090', 0, function (done) { + createBluetoothHandsfreeunitConntectStateUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_091 + * @tc.name subscribe BluetoothHandsfreeunitAudioStateUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_091', 0, function (done) { + createBluetoothHandsfreeunitAudioStateUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_092 + * @tc.name subscribe BluetoothHandsfreeunitAgCommonEvent common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_092', 0, function (done) { + createBluetoothHandsfreeunitAgCommonEventSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_093 + * @tc.name subscribe BluetoothHandsfreeunitAgCallStateUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_093', 0, function (done) { + createBluetoothHandsfreeunitAgCallStateUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_094 + * @tc.name subscribe BluetoothHostStateUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_094', 0, function (done) { + createBluetoothHostStateUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_095 + * @tc.name subscribe BluetoothHostReqDiscoverable common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_095', 0, function (done) { + createBluetoothHostReqDiscoverableSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_096 + * @tc.name subscribe CommonEventHostReqEnable common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_096', 0, function (done) { + createCommonEventHostReqEnableSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_097 + * @tc.name subscribe CommonEventHostReqDisable common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_097', 0, function (done) { + createCommonEventHostReqDisableSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_098 + * @tc.name subscribe CommonEventHostScanModeUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_098', 0, function (done) { + createCommonEventHostScanModeUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_099 + * @tc.name subscribe CommonEventHostDiscovetyStarted common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_099', 0, function (done) { + createCommonEventHostDiscovetyStartedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_100 + * @tc.name subscribe CommonEventHostDiscovetyFinished common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_100', 0, function (done) { + createCommonEventHostDiscovetyFinishedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_101 + * @tc.name subscribe CommonEventHostNameUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_101', 0, function (done) { + createCommonEventHostNameUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_102 + * @tc.name subscribe CommonEventHostStateUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_102', 0, function (done) { + createCommonEventHostStateUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_103 + * @tc.name subscribe CommonEventA2DPsinkPlayingStateUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_103', 0, function (done) { + createCommonEventA2DPsinkPlayingStateUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_104 + * @tc.name subscribe CommonEventA2DPsinkAudioStateUpdate common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_104', 0, function (done) { + createCommonEventA2DPsinkAudioStateUpdateSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_105 + * @tc.name subscribe CommonEventNFCActionAdapterStateChanged common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_105', 0, function (done) { + createCommonEventNFCActionAdapterStateChangedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_106 + * @tc.name subscribe CommonEventNFCActionRFFieldOnDetected common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_106', 0, function (done) { + createCommonEventNFCActionRFFieldOnDetectedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_107 + * @tc.name subscribe CommonEventNFCActionRFFieldOffDetected common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_107', 0, function (done) { + createCommonEventNFCActionRFFieldOffDetectedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_108 + * @tc.name subscribe CommonEventDeviceIdleModeChanged common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_108', 0, function (done) { + createCommonEventDeviceIdleModeChangedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_109 + * @tc.name subscribe CommonEventPowerSaveModeChanged common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_109', 0, function (done) { + createCommonEventPowerSaveModeChangedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_110 + * @tc.name subscribe CommonEventUserAdded common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_110', 0, function (done) { + createCommonEventUserAddedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_111 + * @tc.name subscribe CommonEventUserRemoved common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_111', 0, function (done) { + createCommonEventUserRemovedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_112 + * @tc.name subscribe CommonEventAbilityAdded common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_112', 0, function (done) { + createCommonEventAbilityAddedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_113 + * @tc.name subscribe CommonEventAbilityRemoved common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_113', 0, function (done) { + createCommonEventAbilityRemovedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_114 + * @tc.name subscribe CommonEventAbilityUpdated common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_114', 0, function (done) { + createCommonEventAbilityUpdatedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_115 + * @tc.name subscribe CommonEventLocationModeStateChanged common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_115', 0, function (done) { + createCommonEventLocationModeStateChangedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_116 + * @tc.name subscribe CommonEventIVISleep common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_116', 0, function (done) { + createCommonEventIVISleepSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_117 + * @tc.name subscribe CommonEventIVIPause common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_117', 0, function (done) { + createCommonEventIVIPauseSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_118 + * @tc.name subscribe CommonEventIVIStandBy common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_118', 0, function (done) { + createCommonEventIVIStandBySubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_119 + * @tc.name subscribe CommonEventIVILastmodeSave common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_119', 0, function (done) { + createCommonEventIVILastmodeSaveSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_120 + * @tc.name subscribe CommonEventIVIVoltageAbnormal common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_120', 0, function (done) { + createCommonEventIVIVoltageAbnormalSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_121 + * @tc.name subscribe CommonEventIVIHightTemperature common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_121', 0, function (done) { + createCommonEventIVIHightTemperatureSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_122 + * @tc.name subscribe CommonEventIVIExtremeTemperature common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_122', 0, function (done) { + createCommonEventIVIExtremeTemperatureSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_123 + * @tc.name subscribe CommonEventIVITemperatureAbnormal common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_123', 0, function (done) { + createCommonEventIVITemperatureAbnormalSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_124 + * @tc.name subscribe CommonEventIVIVoltageRecovery common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_124', 0, function (done) { + createCommonEventIVIVoltageRecoverySubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_125 + * @tc.name subscribe CommonEventIVITempratureRecovery common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_125', 0, function (done) { + createCommonEventIVITempratureRecoverySubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_126 + * @tc.name subscribe CommonEventIVIActive common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_126', 0, function (done) { + createCommonEventIVIActiveSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_127 + * @tc.name subscribe CommonEventUSBDevidceAttached common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_127', 0, function (done) { + createCommonEventUSBDevidceAttachedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_128 + * @tc.name subscribe CommonEventUSBDevidceDetached common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_128', 0, function (done) { + createCommonEventUSBDevidceDetachedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_129 + * @tc.name subscribe CommonEventUSBAccessoryAttached common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_129', 0, function (done) { + createCommonEventUSBAccessoryAttachedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_130 + * @tc.name subscribe CommonEventUSBAccessoryDetached common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_130', 0, function (done) { + createCommonEventUSBAccessoryDetachedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_131 + * @tc.name subscribe CommonEventDickRemoved common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_131', 0, function (done) { + createCommonEventDickRemovedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_132 + * @tc.name subscribe CommonEventDickUnmounted common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_132', 0, function (done) { + createCommonEventDickUnmountedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_133 + * @tc.name subscribe CommonEventDickMounted common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_133', 0, function (done) { + createCommonEventDickMountedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_134 + * @tc.name subscribe CommonEventDickNadRemoval common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_134', 0, function (done) { + createCommonEventDickNadRemovalSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_135 + * @tc.name subscribe CommonEventDickUnmoutable common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_135', 0, function (done) { + createCommonEventDickUnmoutableSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_136 + * @tc.name subscribe CommonEventDickEject common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_136', 0, function (done) { + createCommonEventDickEjectSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_137 + * @tc.name subscribe CommonEventVisibleAccountsUpdated common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_137', 0, function (done) { + createCommonEventVisibleAccountsUpdatedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_138 + * @tc.name subscribe CommonEventAccountDeleted common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_138', 0, function (done) { + createCommonEventAccountDeletedSubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_139 + * @tc.name subscribe CommonEventFoundationReady common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_139', 0, function (done) { + createCommonEventFoundationReadySubscriber(); + done(); + }) + + /** + * @tc.number BatteryCommonEventTest_140 + * @tc.name subscribe CommonEventAirplaneModeChanged common event + * @tc.desc Battery acquisition kit + */ + it('BatteryCommonEventTest_140', 0, function (done) { + createCommonEventAirplaneModeChangedSubscriber(); + done(); + }) + console.log("*************Battery commonEvent Test End*************"); }) +function createCommonEventAirplaneModeChangedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_AIRPLANE_MODE_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventAirplaneModeChangedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Airplane_Mode_Changed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + + +function createCommonEventFoundationReadySubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_FOUNDATION_READY], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventFoundationReadySubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Foundation_Ready begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventAccountDeletedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_ACCOUNT_DELETED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventAccountDeletedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_AccountDeleted begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventVisibleAccountsUpdatedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_VISIBLE_ACCOUNTS_UPDATED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventVisibleAccountsUpdatedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Visible_Accounts_Updated begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventDickEjectSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_DISK_EJECT], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventDickEjectSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Dick_Eject begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventDickUnmoutableSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_DISK_UNMOUNTABLE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventDickUnmoutableSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Dick_Unmountable begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventDickNadRemovalSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_DISK_BAD_REMOVAL], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventDickNadRemovalSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Dick_Nad_Removal begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventDickMountedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_DISK_MOUNTED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventDickMountedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Dick_Mounted begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventDickUnmountedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_DISK_UNMOUNTED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventDickUnmountedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Dick_Unmounted begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventDickRemovedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_DISK_REMOVED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventDickRemovedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Dick_Removed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventUSBAccessoryDetachedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_USB_ACCESSORY_DETACHED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventUSBAccessoryDetachedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_USB_Accessory_Detached begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventUSBAccessoryAttachedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_USB_ACCESSORY_ATTACHED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventUSBAccessoryAttachedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_USB_Accessory_Attached begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventUSBDevidceDetachedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_USB_DEVICE_DETACHED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventUSBDevidceDetachedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_USB_Devidce_Detached begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventUSBDevidceAttachedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_USB_DEVICE_ATTACHED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventUSBDevidceAttachedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_USB_Devidce_Attached begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventIVIActiveSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_IVI_ACTIVE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventIVIActiveSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_IVI_Active begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventIVITempratureRecoverySubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_IVI_TEMPERATURE_RECOVERY], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventIVITempratureRecoverySubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_IVI_Temprature_Recovery begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventIVIVoltageRecoverySubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_IVI_VOLTAGE_RECOVERY], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventIVIVoltageRecoverySubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_IVI_Voltage_Recovery begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventIVITemperatureAbnormalSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_IVI_TEMPERATURE_ABNORMAL], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventIVITemperatureAbnormalSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_IVI_Temperature_Abnormal begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventIVIExtremeTemperatureSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_IVI_EXTREME_TEMPERATURE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventIVIExtremeTemperatureSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_IVI_Extreme_Temperature begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventIVIHightTemperatureSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_IVI_HIGH_TEMPERATURE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventIVIHightTemperatureSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_IVI_Hight_Temperature begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventIVIVoltageAbnormalSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_IVI_VOLTAGE_ABNORMAL], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventIVIVoltageAbnormalSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Voltage_Abnormal begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventIVILastmodeSaveSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_IVI_LASTMODE_SAVE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventIVILastmodeSaveSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Last_modeSave begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventIVIStandBySubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_IVI_STANDBY], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventIVIStandBySubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_IVI_StandBy begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventIVIPauseSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_IVI_PAUSE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventIVIPauseSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_IVI_Pause begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventIVISleepSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_IVI_SLEEP], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventIVISleepSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_IVI_Sleep begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventLocationModeStateChangedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_LOCATION_MODE_STATE_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventLocationModeStateChangedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Location_Mode_State_Changed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventAbilityUpdatedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_ABILITY_UPDATED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventAbilityUpdatedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Ability_Updated begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventAbilityRemovedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_ABILITY_REMOVED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventAbilityRemovedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Ability_Removed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventAbilityAddedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_ABILITY_ADDED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventAbilityAddedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Ability_Added begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventUserRemovedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_USER_REMOVED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventUserRemovedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_User_Removed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventUserAddedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_USER_ADDED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventUserAddedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_User_Added begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventPowerSaveModeChangedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_POWER_SAVE_MODE_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventPowerSaveModeChangedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Power_Save_Mode_Changed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventDeviceIdleModeChangedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventDeviceIdleModeChangedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_DeviceIdle_Mode_Changed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventNFCActionRFFieldOffDetectedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventNFCActionRFFieldOffDetectedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_NFC_Action_RF_Field_Off_Detected begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventNFCActionRFFieldOnDetectedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventNFCActionRFFieldOnDetectedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_NFC_Action_RF_Field_On_Detected begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventNFCActionAdapterStateChangedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventNFCActionAdapterStateChangedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_NFCA_ction_Adapter_State_Changed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventA2DPsinkAudioStateUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_A2DPSINK_AUDIO_STATE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventA2DPsinkAudioStateUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_A2DPsink_Audio_State_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventA2DPsinkPlayingStateUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_A2DPSINK_PLAYING_STATE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventA2DPsinkPlayingStateUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_A2DPsink_Playing_State_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventHostStateUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_A2DPSINK_CONNECT_STATE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventHostStateUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Host_State_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventHostNameUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_HOST_NAME_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventHostNameUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Host_Name_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventHostDiscovetyFinishedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_HOST_DISCOVERY_FINISHED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventHostDiscovetyFinishedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_HostDiscovery_Finished begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventHostDiscovetyStartedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_HOST_DISCOVERY_STARTED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventHostDiscovetyStartedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_HostDiscovery_Started begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventHostScanModeUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_HOST_SCAN_MODE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventHostScanModeUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Host_Scan_Mode_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventHostReqDisableSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_HOST_REQ_DISABLE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventHostReqDisableSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Host_Req_Disable begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCommonEventHostReqEnableSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_HOST_REQ_ENABLE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCommonEventHostReqEnableSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Common_Event_Host_Req_Enable begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothHostReqDiscoverableSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_HOST_REQ_DISCOVERABLE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothHostReqDiscoverableSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Host_Req_Discoverable begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothHostStateUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_HOST_STATE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothHostStateUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_HostState_State_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothHandsfreeunitAgCallStateUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_CALL_STATE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothHandsfreeunitAgCallStateUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Handsfreeunit_Ag_CallStateUpdate begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothHandsfreeunitAgCommonEventSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_COMMON_EVENT], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothHandsfreeunitAgCommonEventSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Handsfreeunit_Ag_Common_Event begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothHandsfreeunitAudioStateUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AUDIO_STATE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothHandsfreeunitAudioStateUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Handsfreeunit_Audio_State_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothHandsfreeunitConntectStateUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_CONNECT_STATE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothHandsfreeunitConntectStateUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Handsfreeunit_Conntect_State_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothRemotedeviceConntectCancelSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_CANCEL], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothRemotedeviceConntectCancelSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Remotedevice_Conntect_Cancel begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothRemotedeviceConntectReplySubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REPLY], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothRemotedeviceConntectReplySubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Remotedevice_Conntect_Reply begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothRemotedeviceConntectReqSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REQ], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothRemotedeviceConntectReqSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Remotedevice_ConntectReq begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothRemotedevicePairingCancelSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_CANCEL], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothRemotedevicePairingCancelSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Remotedevice_Pairing_Cancel begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothPairingReqSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_REQ], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothPairingReqSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Pairing_Req begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothRemotedeviceUuidValueSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_UUID_VALUE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothRemotedeviceUuidValueSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Remotedevice_Uuid_Value begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothRemotedeviceSdpResultSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_SDP_RESULT], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothRemotedeviceSdpResultSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Remote_device_Sdp_Result begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothRemotedeviceBateryValueUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_BATTERY_VALUE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothRemotedeviceBateryValueUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Batery_Value_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothRemotedevicePairStateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIR_STATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothRemotedevicePairStateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Remotedevice_Pair_State begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothRemotedeviceNameUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_NAME_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothRemotedeviceNameUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Remotedevice_Name_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothRemotedeviceAclDisconnectedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_DISCONNECTED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothRemotedeviceAclDisconnectedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Remotedevice_Scl_Disconntected begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothRemotedeviceAclConnectedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_CONNECTED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothRemotedeviceAclConnectedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Remotedevice_Scl_Conntected begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothRemotedeviceClassValueUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CLASS_VALUE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothRemotedeviceClassValueUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Remotedevice_Class_Value_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothRemotedeviceDiscoveredSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_DISCOVERED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothRemotedeviceDiscoveredSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Remotedevice_Discovered begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothA2DPsourceCodecValueUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CODEC_VALUE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothA2DPsourceCodecValueUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_A2DPsource_Codec_Value_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothA2DPsourceAvrcpConntectStateUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_A2DPSOURCE_AVRCP_CONNECT_STATE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothA2DPsourceAvrcpConntectStateUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_A2DPsource_Avrcp_Connect_State_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothA2DPsourcePlayingStateUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_A2DPSOURCE_PLAYING_STATE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothA2DPsourcePlayingStateUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_A2DPsource_Playing_State_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothA2DPsourceCurrentDeviceUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CURRENT_DEVICE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothA2DPsourceCurrentDeviceUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_A2DPsource_Connect_Device_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothA2DPsourceConnectStateUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CONNECT_STATE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothA2DPsourceConnectStateUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_A2DPsource_Connect_State_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothHandsfreeAgAudioStateUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_AUDIO_STATE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothHandsfreeAgAudioStateUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Hands_free_Ag_Audio_State_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothHandsfreeAgConntectDeviceUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_CURRENT_DEVICE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothHandsfreeAgConntectDeviceUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Hands_free_Ag_Conntect_Device_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBluetoothHandsfreeAgConntectStateUpdateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_CONNECT_STATE_UPDATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBluetoothHandsfreeAgConntectStateUpdateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Bluetooth_Hands_free_Ag_Conntect_State_Update begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createWifiP2PGroupStateChangedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createWifiP2PGroupStateChangedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Wifi_P2P_Group_State_Change begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createWifiP2PCurrentDeviceStateChangedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createWifiP2PCurrentDeviceStateChangedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Wifi_P2P_Current_Device_State_Change begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createWifiP2PPeersDiscoveryStateChangedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createWifiP2PPeersDiscoveryStateChangedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Wifi_P2P_Peers_Discovery_State_Change begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createWifiP2PPeersStateChangedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createWifiP2PPeersStateChangedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Wifi_P2P_—Peers—State_Change begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createWifiP2PStateChangedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_WIFI_P2P_STATE_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createWifiP2PStateChangedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Wifi_P2P_State_Change begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createWifiP2PConnStateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_WIFI_P2P_CONN_STATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createWifiP2PConnStateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Wifi_P2P_COnn_State begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createWifiMplinkStateChangeSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createWifiMplinkStateChangeSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Wifi_Mplink_State_Change begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createWifiApStaLeaveSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_WIFI_AP_STA_LEAVE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createWifiApStaLeaveSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Wifi_Ap_Sta_Leave begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createWifiApStaJoinSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_WIFI_AP_STA_JOIN], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createWifiApStaJoinSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Wifi_Ap_Sta_Join begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createWifiHostpotStateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_WIFI_HOTSPOT_STATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createWifiHostpotStateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Wifi_Hostpot_State begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createWifiConnStateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_WIFI_CONN_STATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createWifiConnStateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Wifi_Conn_State begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createWifiRssiValueSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_WIFI_RSSI_VALUE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createWifiRssiValueSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Wifi_Rssi_Value begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createWifiScanFinishedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_WIFI_SCAN_FINISHED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createWifiScanFinishedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Wifi_Scan_Finished begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createWifiPowerStateSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_WIFI_POWER_STATE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createWifiPowerStateSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Wifi_Power_State begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createHwidLogOffSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_HWID_LOGOFF], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createHwidLogOffSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Hwid_Logoff begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createHwidTokenInvalidSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_HWID_TOKEN_INVALID], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createHwidTokenInvalidSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Hwid_Token_Invalid begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createHwidLogoutSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_HWID_LOGOUT], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createHwidLogoutSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Hwid_loguot begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createHwidLoginSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_HWID_LOGIN], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createHwidLoginSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Hwid_Login begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createUserStoppedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_USER_STOPPED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createUserStoppedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe User_Stopped begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createUserStoppingSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_USER_STOPPING], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createUserStoppingSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe User_Stopping begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createUserUnlockedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_USER_UNLOCKED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createUserUnlockedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe User_Unlocked begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createUserStartingSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_USER_STARTING], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createUserStartingSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe User_Starting begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createUserSwitchedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_USER_SWITCHED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createUserSwitchedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe User_Switched begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createUserForgroundSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_USER_FOREGROUND], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createUserForgroundSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe User_Forground begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createUserBackgroundSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_USER_BACKGROUND], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createUserBackgroundSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe User_Background begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createUserStartedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_USER_STARTED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createUserStartedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe User_Started begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createOfficeModeSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_OFFICE_MODE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createOfficeModeSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Office_Mode begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createHomeModeSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_HOME_MODE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createHomeModeSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Home_Mode begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createDriveModeSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_DRIVE_MODE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createDriveModeSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Drive_Mode begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createManagePackageStorageSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_MANAGE_PACKAGE_STORAGE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createManagePackageStorageSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Manage_Package_Storage begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createLocateChangedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_LOCALE_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createLocateChangedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Locate_Changed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createConfigurationChangedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_CONFIGURATION_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createConfigurationChangedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Configuration_Changed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createExternalApplicationsUnAvailableSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_EXTERNAL_APPLICATIONS_UNAVAILABLE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createExternalApplicationsUnAvailableSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe External_Applications_UnAvailable begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createExternalApplicationsAvailableSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_EXTERNAL_APPLICATIONS_AVAILABLE], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createExternalApplicationsAvailableSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe External_Applications_Available begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createMyPackageNeedsVerificationSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_PACKAGE_NEEDS_VERIFICATION], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createMyPackageNeedsVerificationSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Package_Needs_Verification begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createMyPackageFirstLaunchSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_PACKAGE_FIRST_LAUNCH], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createMyPackageFirstLaunchSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Package_Firsh_Launch begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createMyPackageUnsuspendedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_MY_PACKAGE_SUSPENDED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createMyPackageUnsuspendedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe My_Packages_UnSuspended begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createMyPackageSuspendedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_MY_PACKAGE_SUSPENDED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createMyPackageSuspendedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe My_Packages_Suspended begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createPackagesUnsuspendedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_PACKAGES_UNSUSPENDED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createPackagesUnsuspendedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Packages_Unsuspended begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createPackageSuspendedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_PACKAGES_SUSPENDED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createPackageSuspendedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Package_Suspended begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createPackageDataClearedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_PACKAGE_DATA_CLEARED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createPackageDataClearedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Package_Data_Cleared begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createPackageRestartedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_PACKAGE_RESTARTED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createPackageRestartedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Package_Restarted begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createPackageChangedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_PACKAGE_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createPackageFullyRemovedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Package_Fully_Removed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createPackageFullyRemovedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_PACKAGE_FULLY_REMOVED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createPackageFullyRemovedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Package_Fully_Removed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBundleRemovedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BUNDLE_REMOVED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBundleRemovedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe BundleRemoved begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createPackageRemovedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_PACKAGE_REMOVED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createPackageRemovedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe PackageRemoved begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createMyPackageReplacedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_MY_PACKAGE_REPLACED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createMyPackageReplacedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe My_Package_Replaced begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createPackageReplacedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_PACKAGE_REPLACED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createPackageReplacedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Package_Replaced begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createPackageAddedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_PACKAGE_ADDED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createPackageAddedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Close_System_Dialogs begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createCloseSystemDialogsSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_CLOSE_SYSTEM_DIALOGS], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createCloseSystemDialogsSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Close_System_Dialogs begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createTimezoneChangedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_TIMEZONE_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createTimezoneChangedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Timezone_Changed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createDateChangedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_DATE_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createDateChangedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Date_Changed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createTimeChangedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_TIME_CHANGED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createTimeChangedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Time_Changed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createTimeTickSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_TIME_TICK], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createTimeTickSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Time_Tick begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createUserPresentSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_USER_PRESENT], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createUserPresentSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe User_Present begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createScreenOnSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_SCREEN_ON], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createScreenOnSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Screen_On begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createScreenOffSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_SCREEN_OFF], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createScreenOffSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe Screen_Off begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createShutdownSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_SHUTDOWN], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createShutdownSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe shutdown begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createLockedBootCompletedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_LOCKED_BOOT_COMPLETED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createLockedBootCompletedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe locked_boot_completed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + +function createBootCompletedSubscriber() { + var commonEventSubscribeInfo = { + events: [commonEvent.Support.COMMON_EVENT_BOOT_COMPLETED], + }; + commonEvent.createSubscriber(commonEventSubscribeInfo) + .then(subscriber => { + console.info('createBootCompletedSubscriber success'); + var mySubscriber = subscriber; + console.log(subscriber); + + if (subscriber == "" || subscriber == undefined || subscriber == null) { + console.info("createSubscriber failed"); + } + mySubscriber.getCode() + .then((data) => { + console.info('Subscriber getCode success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getCode error because: ' + JSON.stringify(error)); + }) + mySubscriber.getData() + .then((data) => { + console.info('Subscriber getData success : ' + JSON.stringify(data)); + }).catch((error) => { + console.error('Subscriber getData error because: ' + JSON.stringify(error)); + }) + console.info('subscribe boot_completed begin '); + + commonEvent.subscribe(mySubscriber, (error, commonEventData) => { + console.error('err code: ' + JSON.stringify(error)); + console.info('subscribe callback: ' + JSON.stringify(commonEventData)); + console.info("commonEventData event: " + commonEventData.event); + console.info("commonEventData bundleName: " + commonEventData.bundleName); + console.info("commonEventData data: " + commonEventData.data); + console.info("commonEventData parameter: " + commonEventData.parameters[0]); + var capacity = commonEventData.parameters['0']; + console.info("capacity is:" + capacity); + expect(capacity >= 0 && capacity <= 100).assertTrue(); + }); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }); +} + function createBatteryChangedSubscriber() { var commonEventSubscribeInfo = { events: [commonEvent.Support.COMMON_EVENT_BATTERY_CHANGED], diff --git a/resourceschedule/resourceschedule_standard/deviceusagestatisticsjsunit/src/main/js/default/test/BundleState.test.js b/resourceschedule/resourceschedule_standard/deviceusagestatisticsjsunit/src/main/js/default/test/BundleState.test.js index 40ee259ac04dc02c1dd4514aa38da964afaa7be2..14f2a9c048116855009ddbc5f4553ec406567a53 100644 --- a/resourceschedule/resourceschedule_standard/deviceusagestatisticsjsunit/src/main/js/default/test/BundleState.test.js +++ b/resourceschedule/resourceschedule_standard/deviceusagestatisticsjsunit/src/main/js/default/test/BundleState.test.js @@ -67,8 +67,7 @@ describe('bundlestate', function() { console.info('queryAppUsagePriorityGroup_001 start'); bundlestate.queryAppUsagePriorityGroup((err, data) => { if(err) { - console.info('queryAppUsagePriorityGroup_001 callback fail result = ' + JSON.stringify(err.code)); - expect(err.code).assertLarger(0); + console.info('queryAppUsagePriorityGroup_001 callback fail result = ' + err); } else { console.info('queryAppUsagePriorityGroup_001 callback success result = ' + JSON.stringify(data)); expect(true).assertEqual(true) @@ -243,8 +242,15 @@ describe('bundlestate', function() { */ it('queryCurrentBundleActiveStates_041', 0, async function(done) { console.info('queryCurrentBundleActiveStates_041 start'); - let timer = onInit(); - bundlestate.queryCurrentBundleActiveStates(timer.startTime, timer.endTime, (err, data) => { + let time = { 'begin': 0, 'end': 0}; + 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) { console.info('queryCurrentBundleActiveStates_041 callback fail result = ' + err); expect(data).assertFail(); @@ -301,6 +307,29 @@ describe('bundlestate', function() { }); 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 @@ -325,6 +354,28 @@ describe('bundlestate', function() { }); 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 @@ -348,6 +399,27 @@ describe('bundlestate', function() { }); 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 @@ -371,6 +443,27 @@ describe('bundlestate', function() { }); 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 @@ -395,6 +488,28 @@ describe('bundlestate', function() { }); 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 @@ -419,6 +534,28 @@ describe('bundlestate', function() { }); 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 @@ -443,6 +580,28 @@ describe('bundlestate', function() { }); 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 @@ -467,6 +626,28 @@ describe('bundlestate', function() { }); 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 @@ -491,6 +672,28 @@ describe('bundlestate', function() { }); 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 @@ -504,8 +707,7 @@ describe('bundlestate', function() { console.info('isIdleState_052 start'); bundlestate.isIdleState(bundleName, (err, res) => { if(err) { - console.info('isIdleState_052 callback fail result = ' + JSON.stringify(err.code)); - expect(err.code).assertLarger(0); + console.info('isIdleState_052 callback fail result = ' + err); } else { console.info('isIdleState_052 callback success result = ' + JSON.stringify(res)); expect(res).assertTrue(); @@ -528,8 +730,7 @@ describe('bundlestate', function() { let bundleName02 = 'ohos.plrdtest.resourceschedule' bundlestate.isIdleState(bundleName02, (err, res) => { if(err) { - console.info('isIdleState_053 callback fail result = ' + JSON.stringify(err.code)); - expect(err.code).assertLarger(0); + console.info('isIdleState_053 callback fail result = ' + err); } else { console.info('isIdleState_053 callback success result = ' + JSON.stringify(res)); expect(res).assertInstanceOf('Boolean'); @@ -605,6 +806,27 @@ describe('bundlestate', function() { }); 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 @@ -628,6 +850,27 @@ describe('bundlestate', function() { }); 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 @@ -674,6 +917,27 @@ describe('bundlestate', function() { }); 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 @@ -697,4 +961,47 @@ describe('bundlestate', function() { }); 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 diff --git a/storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js b/storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js index 307995844dd6b1f194ba4e6b3dcb0be6bd3c8ac6..f28d9c6ff2de44df77d7f36a828fa034127a185a 100644 --- a/storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js +++ b/storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js @@ -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.name fileio_test_unlink_sync_000 @@ -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.name fileio_test_truncate_sync_000 @@ -3778,4 +3829,476 @@ describe('fileIOTest', function () { 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 diff --git a/storage/storagefileiojstest/src/main/js/default/test/FileIODir.test.js b/storage/storagefileiojstest/src/main/js/default/test/FileIODir.test.js index 98ba614defb3ee1947f191bbb13269f5e17cc3ad..bd4bde6596cf401c44492c95a745bf3f0ca093f9 100644 --- a/storage/storagefileiojstest/src/main/js/default/test/FileIODir.test.js +++ b/storage/storagefileiojstest/src/main/js/default/test/FileIODir.test.js @@ -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.name fileio_test_dir_read_sync_000 diff --git a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/CallManageAll.test.js b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/CallManageAll.test.js index 294c2584535bde87cf47110e93d70b824babb59d..5bb0d22f1b95db7c652597b328edc80b947ff724 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/CallManageAll.test.js +++ b/telephony/telephonyjstest/call_manager/call_manager_ims2_call/entry/src/main/js/test/CallManageAll.test.js @@ -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.name PhoneNumber is 010-0000-0000, options: CN, call formatPhoneNumberToE164() to format the number, @@ -942,4 +984,43 @@ describe('CallManageImsCall', function () { 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 diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpRequestJsunit.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpRequestJsunit.test.ets index 350ab9805bbce9797a4e2f37e9c66cf2ea5e2108..2bfd70ad1da3ba015c5b24fe52c5892bf3cbfc43 100644 --- a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpRequestJsunit.test.ets +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpRequestJsunit.test.ets @@ -1,277 +1,329 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License') - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http:www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import {describe, beforeAll, afterAll, it, expect, afterEach} from 'hypium/index'; -import http from '@ohos.net.http'; -import utils from './Utils.ets' - -export default function httpRequestJsunit() { - describe("HttpRequestJsunitTest", function () { - /** - * @tc.number Telephony_http_HttpRequest_request_0100 - * @tc.name httprequest::request - * @tc.desc Test Test httprequest property. - */ - it("Telephony_http_HttpRequest_request_0100", 0, async function (done) { - var casename = "Telephony_http_HttpRequest_0100" - console.log("-----------------------HttpRequest_request Test is starting-----------------------"); - try { - let httpRequestOptions = { - method: 'GET', - extraData: null, - header: "content-type': 'application/json", - readTimeout: 60, - connectTimeout: 60 - } - var httpRequest = http.createHttp(); - if (utils.notCheck) { - expect(true).assertTrue(); - done(); - return; - } - httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { - console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); - expect(data.getResponseCode = 200).assertTrue(); - console.log("-----------------------HttpRequest_request Test end-----------------------"); - done(); - }); - } catch (error) { - console.log("Telephony_http_HttpRequest_request_0100 : error = " + error); - done(); - } - }); - - /** - * @tc.number Telephony_http_HttpRequest_request_0200 - * @tc.name httprequest::request - * @tc.desc Test Test httprequest property. - */ - it("Telephony_http_HttpRequest_request_0200", 0, async function (done) { - var casename = "Telephony_http_HttpRequest_0100" - console.log("-----------------------HttpRequest_request_01 Test is starting-----------------------"); - try { - var httpRequest = http.createHttp(); - if (utils.notCheck) { - expect(true).assertTrue(); - done(); - return; - } - httpRequest.request("https://www.baidu.com/", (err, data) => { - console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); - expect(data.getResponseCode = 200).assertTrue(); - console.log("-----------------------HttpRequest_request_01 Test end-----------------------"); - done(); - }); - } catch (error) { - console.log("Telephony_http_HttpRequest_request_0200 : error = " + error); - done(); - } - }); - - /** - * @tc.number Telephony_http_HttpRequest_request_0300 - * @tc.name httprequest::request - * @tc.desc Test Test httprequest property. - */ - it("Telephony_http_HttpRequest_request_0300", 0, async function (done) { - var casename = "Telephony_http_HttpRequest_0100" - console.log("-----------------------HttpRequest_request_02 Test is starting-----------------------"); - try { - let httpRequestOptions = { - method: 'GET', - extraData: null, - header: "content-type': 'application/json", - readTimeout: 60, - connectTimeout: 60 - } - var httpRequest = http.createHttp(); - if (utils.notCheck) { - expect(true).assertTrue(); - done(); - return; - } - httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => { - console.log(casename + JSON.stringify(data)); - expect(data.getResponseCode = 200).assertTrue(); - console.log("-----------------------HttpRequest_request_02 Test end-----------------------"); - done(); - }).catch(error => { - console.info('HttpRequest_request_0300 asyncCallback error : ' + JSON.stringify(error)); - done(); - }); - } catch (error) { - console.log("Telephony_http_HttpRequest_request_0300 : error = " + error); - done(); - } - }); - - /** - * @tc.number Telephony_http_HttpRequest_destroy_0100 - * @tc.name httprequest::destroy - * @tc.desc Test Test httprequest property. - */ - it("Telephony_http_HttpRequest_destroy_0100", 0, async function (done) { - var casename = "Telephony_http_HttpRequest_0200" - console.log("-----------------------HttpRequest_destroy Test is starting-----------------------"); - try { - let httpRequestOptions = { - method: 'GET', - extraData: null, - header: "content-type': 'application/json", - readTimeout: 60, - connectTimeout: 60 - } - var httpRequest = http.createHttp(); - if (utils.notCheck) { - expect(true).assertTrue(); - done(); - return; - } - httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { - console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); - try{ - httpRequest.destroy(); - expect(true).assertTrue(); - console.log("-----------------------HttpRequest_destroy Test end-----------------------"); - done(); - }catch(error){ - expect().assertFail(); - done(); - } - }); - } catch (error) { - console.log("Telephony_http_HttpRequest_destroy_0100 : error = " + error); - done(); - } - }); - - /** - * @tc.number Telephony_http_HttpRequest_on_headerReceive_0100 - * @tc.name httprequest::on_headerReceive - * @tc.desc Test Test httprequest property. - */ - it("Telephony_http_HttpRequest_on_headerReceive_0100", 0, async function (done) { - var casename = "Telephony_http_HttpRequest_0300" - console.log("-----------------------HttpRequest_on_headerReceive Test is starting-----------------------"); - try { - var httpRequest = http.createHttp(); - if (utils.notCheck) { - expect(true).assertTrue(); - done(); - return; - } - httpRequest.on_headerReceive((data) => { - console.log(casename + " data: " + JSON.stringify(data)); - expect(true).assertTrue(); - console.log("-----------------------HttpRequest_on_headerReceive Test end-----------------------"); - done(); - }); - - } catch (error) { - console.log("Telephony_http_HttpRequest_on_headerReceive_0100 : error = " + error); - done(); - } - }); - - /** - * @tc.number Telephony_http_HttpRequest_off_headerReceive_0100 - * @tc.name httprequest::off_headerReceive - * @tc.desc Test Test httprequest property. - */ - it("Telephony_http_HttpRequest_off_headerReceive_0100", 0, async function (done) { - var casename = "Telephony_http_HttpRequest_0400" - console.log("-----------------------HttpRequest_off_headerReceive Test is starting-----------------------"); - try { - var httpRequest = http.createHttp(); - if (utils.notCheck) { - expect(true).assertTrue(); - done(); - return; - } - httpRequest.off_headerReceive((data) => { - console.log(casename + " data: " + JSON.stringify(data)); - expect(true).assertTrue(); - console.log("-----------------------HttpRequest_off_headerReceive Test end-----------------------"); - done(); - }); - - } catch (error) { - console.log("Telephony_http_HttpRequest_off_headerReceive_0100 : error = " + error); - done(); - } - }); - - - /** - * @tc.number Telephony_http_HttpRequest_on_headersReceive_0100 - * @tc.name httprequest::on_headersReceive - * @tc.desc Test Test httprequest property. - */ - - it("Telephony_http_HttpRequest_on_headersReceive_0100", 0, function (done) { - var casename = "Telephony_http_HttpRequest_0500" - console.log("-----------------------HttpRequest_on_headersReceive Test is starting-----------------------"); - try { - var httpRequest = http.createHttp(); - if (utils.notCheck) { - expect(true).assertTrue(); - done(); - return; - } - httpRequest.on("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_on_headersReceive_0100 : error = " + error); - done(); - } - }); - - /** - * @tc.number Telephony_http_HttpRequest_off_headersReceive_0100 - * @tc.name httprequest::off_headersReceive - * @tc.desc Test Test httprequest property. - */ - it("Telephony_http_HttpRequest_off_headersReceive_0100", 0, function (done) { - var casename = "Telephony_http_HttpRequest_0600" - console.log("-----------------------HttpRequest_off_headersReceive Test is starting-----------------------"); - try { - var httpRequest = http.createHttp(); - if (utils.notCheck) { - expect(true).assertTrue(); - done(); - return; - } - httpRequest.off("headersReceive", (data) => { - console.log(casename + " data: " + JSON.stringify(data)); - expect(true).assertTrue(); - console.log("-----------------------HttpRequest_off_headersReceive Test end-----------------------"); - done(); - }); - - } catch (error) { - console.log("Telephony_http_HttpRequest_off_headersReceive_0100 : error = " + error); - done(); - } - }); - - - }) - -}; - +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http:www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeAll, afterAll, it, expect, afterEach} from 'deccjsunit/index.ets'; +import http from '@ohos.net.http'; +import utils from './Utils.ets' + +export default function httpRequestJsunit() { + describe("HttpRequestJsunitTest", function () { + /** + * @tc.number Telephony_http_HttpRequest_request_0100 + * @tc.name httprequest::request + * @tc.desc Test Test httprequest property. + */ + it("Telephony_http_HttpRequest_request_0100", 0, async function (done) { + var casename = "Telephony_http_HttpRequest_0100" + console.log("-----------------------HttpRequest_request Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequest_request Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_http_HttpRequest_request_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequest_request_0200 + * @tc.name httprequest::request + * @tc.desc Test Test httprequest property. + */ + it("Telephony_http_HttpRequest_request_0200", 0, async function (done) { + var casename = "Telephony_http_HttpRequest_0100" + console.log("-----------------------HttpRequest_request_01 Test is starting-----------------------"); + try { + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequest_request_01 Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_http_HttpRequest_request_0200 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequest_request_0300 + * @tc.name httprequest::request + * @tc.desc Test Test httprequest property. + */ + it("Telephony_http_HttpRequest_request_0300", 0, async function (done) { + var casename = "Telephony_http_HttpRequest_0100" + console.log("-----------------------HttpRequest_request_02 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => { + console.log(casename + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequest_request_02 Test end-----------------------"); + done(); + }).catch(error => { + console.info('HttpRequest_request_0300 asyncCallback error : ' + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_http_HttpRequest_request_0300 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequest_destroy_0100 + * @tc.name httprequest::destroy + * @tc.desc Test Test httprequest property. + */ + it("Telephony_http_HttpRequest_destroy_0100", 0, async function (done) { + var casename = "Telephony_http_HttpRequest_0200" + console.log("-----------------------HttpRequest_destroy Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + try{ + httpRequest.destroy(); + expect(true).assertTrue(); + console.log("-----------------------HttpRequest_destroy Test end-----------------------"); + done(); + }catch(error){ + expect().assertFail(); + done(); + } + }); + } catch (error) { + console.log("Telephony_http_HttpRequest_destroy_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequest_on_headerReceive_0100 + * @tc.name httprequest::on_headerReceive + * @tc.desc Test Test httprequest property. + */ + it("Telephony_http_HttpRequest_on_headerReceive_0100", 0, async function (done) { + var casename = "Telephony_http_HttpRequest_0300" + console.log("-----------------------HttpRequest_on_headerReceive Test is starting-----------------------"); + try { + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.on_headerReceive((data) => { + console.log(casename + " data: " + JSON.stringify(data)); + expect(true).assertTrue(); + console.log("-----------------------HttpRequest_on_headerReceive Test end-----------------------"); + done(); + }); + + } catch (error) { + console.log("Telephony_http_HttpRequest_on_headerReceive_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequest_off_headerReceive_0100 + * @tc.name httprequest::off_headerReceive + * @tc.desc Test Test httprequest property. + */ + it("Telephony_http_HttpRequest_off_headerReceive_0100", 0, async function (done) { + var casename = "Telephony_http_HttpRequest_0400" + console.log("-----------------------HttpRequest_off_headerReceive Test is starting-----------------------"); + try { + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.off_headerReceive((data) => { + console.log(casename + " data: " + JSON.stringify(data)); + expect(true).assertTrue(); + console.log("-----------------------HttpRequest_off_headerReceive Test end-----------------------"); + done(); + }); + + } catch (error) { + console.log("Telephony_http_HttpRequest_off_headerReceive_0100 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_http_HttpRequest_on_headersReceive_0100 + * @tc.name httprequest::on_headersReceive + * @tc.desc Test Test httprequest property. + */ + + it("Telephony_http_HttpRequest_on_headersReceive_0100", 0, function (done) { + var casename = "Telephony_http_HttpRequest_0500" + console.log("-----------------------HttpRequest_on_headersReceive Test is starting-----------------------"); + try { + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.on("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_on_headersReceive_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequest_off_headersReceive_0100 + * @tc.name httprequest::off_headersReceive + * @tc.desc Test Test httprequest property. + */ + it("Telephony_http_HttpRequest_off_headersReceive_0100", 0, function (done) { + var casename = "Telephony_http_HttpRequest_0600" + console.log("-----------------------HttpRequest_off_headersReceive Test is starting-----------------------"); + try { + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.off("headersReceive", (data) => { + console.log(casename + " data: " + JSON.stringify(data)); + expect(true).assertTrue(); + console.log("-----------------------HttpRequest_off_headersReceive Test end-----------------------"); + done(); + }); + + } catch (error) { + console.log("Telephony_http_HttpRequest_off_headersReceive_0100 : error = " + error); + 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(); + } + }); + + }) + +}; + diff --git a/telephony/telephonyjstest/network_search/network_search_errors/entry/src/main/js/test/NetworkSearchErrors.test.js b/telephony/telephonyjstest/network_search/network_search_errors/entry/src/main/js/test/NetworkSearchErrors.test.js index acb46b815cdac3d875c7261c1994f19e45532261..b5f4d9049c581b080e6d8f6cc5644a5f9b7801fe 100644 --- a/telephony/telephonyjstest/network_search/network_search_errors/entry/src/main/js/test/NetworkSearchErrors.test.js +++ b/telephony/telephonyjstest/network_search/network_search_errors/entry/src/main/js/test/NetworkSearchErrors.test.js @@ -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.name Test The function isRadioOn @@ -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.name Add a networkStatus change listen and test observer.on({slotId:0}) to view the callback results diff --git a/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/RadioJsunit.test.ets b/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/RadioJsunit.test.ets index c6ee73490aa8056e3fc536751b232466e60369e0..80e58c8b56a68583da8e52b0bca33f1f9f6c6672 100644 --- a/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/RadioJsunit.test.ets +++ b/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/RadioJsunit.test.ets @@ -1,218 +1,241 @@ -// @ts-nocheck -/** - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'hypium/index' -import radio from '@ohos.telephony.radio'; -import utils from './Utils.ets' - -export default function radioJsunit() { - describe('ActsNetworkSearchTest',function () { - - const SLOT_2 = -1; - const SLOT_0 = 0; - - - - /** - * @tc.number Telephony_NetworkSearch_getPrimarySlotId_Async_0200 - * @tc.name Test getPrimarySlotId(-1) to check the callback result - * @tc.desc Function test - */ - it('Telephony_NetworkSearch_getPrimarySlotId_Async_0200', 0, async function (done) { - if(utils.notCheck){ - done(); - return; - } - radio.getPrimarySlotId((err, data) => { - if (err) { - console.log(`Telephony_NetworkSearch_getPrimarySlotId_Async_0200 fail: ${err}`); - expect(data === undefined).assertTrue(); - done(); - return; - } - console.log(`Telephony_NetworkSearch_getPrimarySlotId_Async_0200 end data: ${data}`); - expect(data === '').assertTrue(); - done(); - }); - }); - - - /** - * @tc.number Telephony_NetworkSearch_isNrSupported_Promise_0400 - * @tc.name Test The function setPrimarySlotId(0) - * @tc.desc Function test - */ - it('Telephony_NetworkSearch_isNrSupported_Promise_0400', 0, async function (done) { - if(utils.notCheck){ - done(); - return; - } - try { - await radio.isNrSupported(SLOT_0); - console.log('radio.isNrSupported(SLOT_0) = ' + radio.isNrSupported(SLOT_0)); - console.log('Telephony_NetworkSearch_isNrSupported_Promise_0400 success'); - done(); - } catch (err) { - console.log(`Telephony_NetworkSearch_isNrSupported_Promise_0400 fail ${err}`); - done(); - } - }); - - /** - * @tc.number Telephony_radio_PreferredNetworkMode_0500 - * @tc.name Test The PreferredNetworkMode enum - * @tc.desc Function test - */ - it('Telephony_radio_PreferredNetworkMode_0500', 0, async function (done) { - console.info("Telephony_radio_PreferredNetworkMode_0500 start") - if(utils.notCheck){ - done(); - return; - } - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_WCDMA === 2).assertTrue(); - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE === 3).assertTrue(); - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA === 4).assertTrue(); - 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_0600 - * @tc.name Test The PreferredNetworkMode enum - * @tc.desc Function test - */ - it('Telephony_radio_PreferredNetworkMode_0600', 0, async function (done) { - if(utils.notCheck){ - done(); - return; - } - console.info("Telephony_radio_PreferredNetworkMode_0600 start") - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_CDMA === 7).assertTrue(); - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_EVDO === 8).assertTrue(); - 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_LTE_EVDO_CDMA === 11).assertTrue(); - console.info("Telephony_radio_PreferredNetworkMode_0600 end") - done(); - }); - - /** - * @tc.number Telephony_radio_PreferredNetworkMode_0700 - * @tc.name Test The PreferredNetworkMode enum - * @tc.desc Function test - */ - it('Telephony_radio_PreferredNetworkMode_0700', 0, async function (done) { - if(utils.notCheck){ - done(); - return; - } - console.info("Telephony_radio_PreferredNetworkMode_0700 start") - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM_EVDO_CDMA === 12).assertTrue(); - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA === 13).assertTrue(); - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_GSM === 14).assertTrue(); - 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_0800 - * @tc.name Test The PreferredNetworkMode enum - * @tc.desc Function test - */ - it('Telephony_radio_PreferredNetworkMode_0800', 0, async function (done) { - if(utils.notCheck){ - done(); - return; - } - console.info("Telephony_radio_PreferredNetworkMode_0800 start") - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA === 17).assertTrue(); - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_GSM === 18).assertTrue(); - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA === 19).assertTrue(); - 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_0900 - * @tc.name Test The PreferredNetworkMode enum - * @tc.desc Function test - */ - it('Telephony_radio_PreferredNetworkMode_0900', 0, async function (done) { - if(utils.notCheck){ - done(); - return; - } - console.info("Telephony_radio_PreferredNetworkMode_0900 start") - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA === 17).assertTrue(); - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_GSM === 18).assertTrue(); - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA === 19).assertTrue(); - 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_1000 - * @tc.name Test The PreferredNetworkMode enum - * @tc.desc Function test - */ - it('Telephony_radio_PreferredNetworkMode_1000', 0, async function (done) { - if(utils.notCheck){ - done(); - return; - } - console.info("Telephony_radio_PreferredNetworkMode_1000 start") - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA === 22).assertTrue(); - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR === 31).assertTrue(); - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE === 32).assertTrue(); - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA === 33).assertTrue(); - expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM ===34).assertTrue(); - console.info("Telephony_radio_PreferredNetworkMode_1000 end") - done(); - }); - - /** - * @tc.number Telephony_radio_PreferredNetworkMode_1100 - * @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(); - }); - - }) -} \ No newline at end of file +// @ts-nocheck +/** + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import radio from '@ohos.telephony.radio'; +import utils from './Utils.ets' + +export default function radioJsunit() { + describe('ActsNetworkSearchTest',function () { + + const SLOT_2 = -1; + const SLOT_0 = 0; + + + + /** + * @tc.number Telephony_NetworkSearch_getPrimarySlotId_Async_0200 + * @tc.name Test getPrimarySlotId(-1) to check the callback result + * @tc.desc Function test + */ + it('Telephony_NetworkSearch_getPrimarySlotId_Async_0200', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + radio.getPrimarySlotId((err, data) => { + if (err) { + console.log(`Telephony_NetworkSearch_getPrimarySlotId_Async_0200 fail: ${err}`); + expect(data === undefined).assertTrue(); + done(); + return; + } + console.log(`Telephony_NetworkSearch_getPrimarySlotId_Async_0200 end data: ${data}`); + expect(data === '').assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_NetworkSearch_getPrimarySlotId_Async_0300 + * @tc.name testGetPrimarySlotId_0300 + * @tc.desc Test getPrimarySlotId api by promise. + */ + it('Telephony_NetworkSearch_getPrimarySlotId_Promise_0200', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + + try { + let data = await radio.getPrimarySlotId(); + console.log(`Telephony_NetworkSearch_getPrimarySlotId_Promise_0200 pass data: ${data}`); + expect(true).assertTrue(); + } catch (err) { + console.log(`Telephony_NetworkSearch_getPrimarySlotId_Promise_0200 fail err: ${err}`); + expect().assertFail(); + done(); + return; + } + done(); + }); + + /** + * @tc.number Telephony_NetworkSearch_isNrSupported_Promise_0400 + * @tc.name Test The function setPrimarySlotId(0) + * @tc.desc Function test + */ + it('Telephony_NetworkSearch_isNrSupported_Promise_0400', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + try { + await radio.isNrSupported(SLOT_0); + console.log('radio.isNrSupported(SLOT_0) = ' + radio.isNrSupported(SLOT_0)); + console.log('Telephony_NetworkSearch_isNrSupported_Promise_0400 success'); + done(); + } catch (err) { + console.log(`Telephony_NetworkSearch_isNrSupported_Promise_0400 fail ${err}`); + done(); + } + }); + + /** + * @tc.number Telephony_radio_PreferredNetworkMode_0500 + * @tc.name Test The PreferredNetworkMode enum + * @tc.desc Function test + */ + it('Telephony_radio_PreferredNetworkMode_0500', 0, async function (done) { + console.info("Telephony_radio_PreferredNetworkMode_0500 start") + if(utils.notCheck){ + done(); + return; + } + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_WCDMA === 2).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE === 3).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA === 4).assertTrue(); + 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_0600 + * @tc.name Test The PreferredNetworkMode enum + * @tc.desc Function test + */ + it('Telephony_radio_PreferredNetworkMode_0600', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + console.info("Telephony_radio_PreferredNetworkMode_0600 start") + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_CDMA === 7).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_EVDO === 8).assertTrue(); + 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_LTE_EVDO_CDMA === 11).assertTrue(); + console.info("Telephony_radio_PreferredNetworkMode_0600 end") + done(); + }); + + /** + * @tc.number Telephony_radio_PreferredNetworkMode_0700 + * @tc.name Test The PreferredNetworkMode enum + * @tc.desc Function test + */ + it('Telephony_radio_PreferredNetworkMode_0700', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + console.info("Telephony_radio_PreferredNetworkMode_0700 start") + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM_EVDO_CDMA === 12).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA === 13).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_GSM === 14).assertTrue(); + 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_0800 + * @tc.name Test The PreferredNetworkMode enum + * @tc.desc Function test + */ + it('Telephony_radio_PreferredNetworkMode_0800', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + console.info("Telephony_radio_PreferredNetworkMode_0800 start") + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA === 17).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_GSM === 18).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA === 19).assertTrue(); + 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_0900 + * @tc.name Test The PreferredNetworkMode enum + * @tc.desc Function test + */ + it('Telephony_radio_PreferredNetworkMode_0900', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + console.info("Telephony_radio_PreferredNetworkMode_0900 start") + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA === 17).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_GSM === 18).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA === 19).assertTrue(); + 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_1000 + * @tc.name Test The PreferredNetworkMode enum + * @tc.desc Function test + */ + it('Telephony_radio_PreferredNetworkMode_1000', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + console.info("Telephony_radio_PreferredNetworkMode_1000 start") + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA === 22).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR === 31).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE === 32).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA === 33).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM ===34).assertTrue(); + console.info("Telephony_radio_PreferredNetworkMode_1000 end") + done(); + }); + + /** + * @tc.number Telephony_radio_PreferredNetworkMode_1100 + * @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(); + }); + + }) +} diff --git a/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/RadioSecondJsunit.test.ets b/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/RadioSecondJsunit.test.ets index 6bdc4661f197828147d1c0911b1705bf95865f19..94742ef436123dba6aaa44a400a745dac2973d7f 100644 --- a/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/RadioSecondJsunit.test.ets +++ b/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/RadioSecondJsunit.test.ets @@ -1,183 +1,417 @@ -// @ts-nocheck -/** - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'hypium/index'; -import radio from '@ohos.telephony.radio'; -import utils from './Utils.ets' - -export default function radioSecondJsunit() { - describe('radioSecondTest', function () { - const NROPTION_MODE = [ - radio.NR_OPTION_UNKNOWN, - radio.NR_OPTION_NSA_ONLY, - radio.NR_OPTION_SA_ONLY, - radio.NR_OPTION_NSA_AND_SA - ]; - //Network status - let garrNetworkState = [ - radio.NETWORK_UNKNOWN, - radio.NETWORK_AVAILABLE, - radio.NETWORK_CURRENT, - radio.NETWORK_FORBIDDEN, - ]; - //NetworkRadioTech - let garrNetworkRadioTech = [ - 'UNKNOWN', 'GSM', '1XRTT', 'WCDMA', - 'HSPA', 'HSPAP', 'TD_SCDMA', 'EVDO', - 'EHRPD', 'LTE', 'LTE_CA', 'IWLAN', 'NR']; - - const SLOT_0 = 0; - const SLOT_1 = 5; - const SLOT_2 = 2; - const SLOT_3 = -1; - const NETWORK_TYPES = [ - radio.NETWORK_TYPE_UNKNOWN, - radio.NETWORK_TYPE_GSM, - radio.NETWORK_TYPE_CDMA, - radio.NETWORK_TYPE_WCDMA, - radio.NETWORK_TYPE_TDSCDMA, - radio.NETWORK_TYPE_LTE, - radio.NETWORK_TYPE_NR, - ]; - const NETWORK_SIGNAL = [0, 1, 2, 3, 4, 5]; - const CELL_LAC_TAC_MAX = 0xffff; - const CELL_CELLID_MAX = 0xfffffff; - const CELL_GSM_CELLID_MAX = 0xffff; - const CELL_ARFCN_MAX = 1023; - const CELL_EARFCN_MAX = 41589; - const CELL_BSIC_MAX = 63; - const CELL_PSC_MAX = 511; - const CELL_PCI_MAX = 503; - const CELL_MCC = 460; - const CELL_MNC_MAX = 20; - const CELL_INFO_MIN = 0; - const TIME_RADIO_TURNON = 10000; - console.log("************* radio Test start*************"); - - - - /** - * @tc.number Telephony_NetworkSearch_NetworkState_Async_0100 - * @tc.name Test getNrOptionMode() to check the callback result - * @tc.desc Function test - */ - it('Telephony_NetworkSearch_NetworkState_Async_0100', 0, async function (done) { - if (utils.notCheck) { - expect(true).assertTrue(); - done(); - return; - } - radio.getNetworkState((err, data) => { - if (err) { - console.log(`Telephony_NetworkSearch_NetworkState_Async_0100 get fail err: ${err}`); - expect().assertFail(); - done(); - return; - } - console.log(`Telephony_NetworkSearch_NetworkState_Async_0100 end data: ${JSON.stringify(data)}`); - if (true) { - console.log(`Telephony_NetworkSearch_getNrOptionMode_Async_0100 1`); - expect(true).assertTrue(); - done(); - return; - } else { - expect(NROPTION_MODE).assertContain(data); - expect(NROPTION_MODE).assertContain(data.cfgTech); - done(); - } - }); - }) - - /** - * @tc.number Telephony_Radio_CdmaCellInformation_sid_0100 - * @tc.name sid - * @tc.desc sid test - */ - 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-----------------------"); - }) - - - - 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 +/** + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import radio from '@ohos.telephony.radio'; +import utils from './Utils.ets' + +export default function radioSecondJsunit() { + describe('radioSecondTest', function () { + const NROPTION_MODE = [ + radio.NR_OPTION_UNKNOWN, + radio.NR_OPTION_NSA_ONLY, + radio.NR_OPTION_SA_ONLY, + radio.NR_OPTION_NSA_AND_SA + ]; + //Network status + let garrNetworkState = [ + radio.NETWORK_UNKNOWN, + radio.NETWORK_AVAILABLE, + radio.NETWORK_CURRENT, + radio.NETWORK_FORBIDDEN, + ]; + //NetworkRadioTech + let garrNetworkRadioTech = [ + 'UNKNOWN', 'GSM', '1XRTT', 'WCDMA', + 'HSPA', 'HSPAP', 'TD_SCDMA', 'EVDO', + 'EHRPD', 'LTE', 'LTE_CA', 'IWLAN', 'NR']; + + const SLOT_0 = 0; + const SLOT_1 = 5; + const SLOT_2 = 2; + const SLOT_3 = -1; + const NETWORK_TYPES = [ + radio.NETWORK_TYPE_UNKNOWN, + radio.NETWORK_TYPE_GSM, + radio.NETWORK_TYPE_CDMA, + radio.NETWORK_TYPE_WCDMA, + radio.NETWORK_TYPE_TDSCDMA, + radio.NETWORK_TYPE_LTE, + radio.NETWORK_TYPE_NR, + ]; + const NETWORK_SIGNAL = [0, 1, 2, 3, 4, 5]; + const CELL_LAC_TAC_MAX = 0xffff; + const CELL_CELLID_MAX = 0xfffffff; + const CELL_GSM_CELLID_MAX = 0xffff; + const CELL_ARFCN_MAX = 1023; + const CELL_EARFCN_MAX = 41589; + const CELL_BSIC_MAX = 63; + const CELL_PSC_MAX = 511; + const CELL_PCI_MAX = 503; + const CELL_MCC = 460; + const CELL_MNC_MAX = 20; + const CELL_INFO_MIN = 0; + const TIME_RADIO_TURNON = 10000; + console.log("************* radio Test start*************"); + + + + /** + * @tc.number Telephony_NetworkSearch_NetworkState_Async_0100 + * @tc.name Test getNrOptionMode() to check the callback result + * @tc.desc Function test + */ + it('Telephony_NetworkSearch_NetworkState_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + radio.getNetworkState((err, data) => { + if (err) { + console.log(`Telephony_NetworkSearch_NetworkState_Async_0100 get fail err: ${err}`); + expect().assertFail(); + done(); + return; + } + console.log(`Telephony_NetworkSearch_NetworkState_Async_0100 end data: ${JSON.stringify(data)}`); + if (true) { + console.log(`Telephony_NetworkSearch_getNrOptionMode_Async_0100 1`); + expect(true).assertTrue(); + done(); + return; + } else { + expect(NROPTION_MODE).assertContain(data); + expect(NROPTION_MODE).assertContain(data.cfgTech); + done(); + } + }); + }) + + /** + * @tc.number Telephony_NetworkSearch_NetworkState_Async_0300 + * @tc.name testGetNetworkState_0300 + * @tc.desc Test getNetworkState api by promise. + */ + it('Telephony_NetworkSearch_NetworkState_Promise_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + try { + const result = await radio.getNetworkState(); + expect(true).assertTrue(); + console.log(`Telephony_NetworkSearch_NetworkState_Promise_0100 test finish.`); + } catch (error) { + console.log(`Telephony_NetworkSearch_NetworkState_Promise_0100 error: ${error.message}`); + expect().assertFail(); + } + done(); + }) + + /** + * @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 + */ + it('Telephony_NetworkSearch_NetworkState_Async_0200', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + radio.getNetworkState(0, (err, data) => { + if (err) { + console.log(`Telephony_NetworkSearch_NetworkState_Async_0200 get fail err: ${err}`); + expect().assertFail(); + done(); + return; + } + console.log(`Telephony_NetworkSearch_NetworkState_Async_0200 end data: ${JSON.stringify(data)}`); + expect(true).assertTrue(); + done(); + return; + }); + }) + + /** + * @tc.number Telephony_NetworkSearch_NetworkState_Async_0400 + * @tc.name testGetNetworkState_0400 + * @tc.desc Test getNetworkState() api by promise, slotId is 0, to check the callback result + */ + it('Telephony_NetworkSearch_NetworkState_Promise_0200', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + try { + const result = await radio.getNetworkState(0); + expect(true).assertTrue(); + console.log(`Telephony_NetworkSearch_NetworkState_Promise_0200 test finish.`); + } catch (error) { + console.log(`Telephony_NetworkSearch_NetworkState_Promise_0200 error: ${error.message}`); + expect().assertFail(); + } + done(); + }) + + + /** + * @tc.number Telephony_Radio_CdmaCellInformation_sid_0100 + * @tc.name sid + * @tc.desc sid test + */ + 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(); + } + + } + } + }) +} diff --git a/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/SmsMmsJsunit.test.ets b/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/SmsMmsJsunit.test.ets index 4616792af53a8e6ef75a74f0fb4259ec94315f9d..420697737bbe3c11c220411e0dbafcd2b9ba68b8 100644 --- a/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/SmsMmsJsunit.test.ets +++ b/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/SmsMmsJsunit.test.ets @@ -1,160 +1,193 @@ -// @ts-nocheck -/** - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'hypium/index'; -import mms from '@ohos.telephony.sms'; -import utils from './Utils.ets' -export default function smsUiJsunit() { - describe('appInfoTest', function () { - - const SMS_SEND_DST_NUMBER = ''; - const TRUE_SLOT_ID = 0; - const FALSE_SLOT_ID = 9; - const OTHER_SLOT_ID = 1; - const SECOND_SLOT_ID = 2; - const IDENTIFIER_MIN = 0; - const IDENTIFIER_MAX = 0xFFFF; - const RANTYPE_GSM = 1; - const RANTYPE_CDMA = 2; - const RANTYPE_ERROR = 3; - var rawArray = [ - 0x08, 0x91, 0x68, 0x31, 0x08, 0x20, 0x00, 0x75, 0xF4, 0x24, 0x0D, 0x91, - 0x68, 0x81, 0x29, 0x56, 0x29, 0x83, 0xF6, 0x00, 0x00, 0x12, 0x40, 0x80, - 0x01, 0x02, 0x14, 0x23, 0x02, 0xC1, 0x30 - ] - - - - /* - * @tc.number Telephony_SmsMms_createMessage_Async_0100 - * @tc.name Call interface CreateMessage, - * pass in the PDU(rawArray) in line with the coding specification, the specification is 3GPP, - * shortMessage Don't empty - * @tc.desc Function test - */ - it('Telephony_SmsMms_createMessage_Async_0100', 0, async function (done) { - if (true) { - expect(true).assertTrue(); - done(); - return; - } - sms.createMessage(rawArray, '3gpp', (err, shortMessage) => { - if (err) { - expect().assertFail(); - console.log('Telephony_SmsMms_createMessage_Async_0100 fail'); - done(); - return; - } - expect(shortMessage.visibleMessageBody === MESSAGEBODY).assertTrue(); - expect(shortMessage.visibleRawAddress.length === ADDR_LENGTH).assertTrue(); - expect(shortMessage.messageClass === sms.FORWARD_MESSAGE).assertTrue(); - expect(shortMessage.protocolId === 0).assertTrue(); - expect(shortMessage.scAddress.length === ADDR_LENGTH).assertTrue(); - expect(shortMessage.scTimestamp === SC_TIMESTAMP).assertTrue(); - expect(shortMessage.isReplaceMessage).assertFalse(); - expect(shortMessage.hasReplyPath).assertFalse(); - expect(shortMessage.pdu.length > 0).assertTrue(); - expect(shortMessage.status === 0).assertTrue(); - expect(shortMessage.isSmsStatusReportMessage).assertTrue(); - console.log('Telephony_SmsMms_createMessage_Async_0100 finish'); - done(); - }); - }); - - - - - /* - * @tc.number Telephony_SmsMms_getSmsEncodingScheme_Async_0100 - * @tc.name - * @tc.desc Function test - */ - it('Telephony_SmsMms_getSmsEncodingScheme_Async_0100', 0, async function (done) { - if (true) { - expect(true).assertTrue(); - done(); - return; - } - expect(sms.SMS_ENCODING_UNKNOWN == 0).assertTrue(); - expect(sms.SMS_ENCODING_7BIT == 1).assertTrue(); - expect(sms.SMS_ENCODING_8BIT == 2).assertTrue(); - expect(sms.SMS_ENCODING_16BIT == 3).assertTrue(); - done(); - }); - - /* - * @tc.number Telephony_SmsMms_getSendSmsResult_Async_0100 - * @tc.name - * @tc.desc Function test - */ - it('Telephony_SmsMms_getSendSmsResult_Async_0100', 0, async function (done) { - if (true) { - expect(true).assertTrue(); - 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_ShortMessageClass_Async_0100 - * @tc.name - * @tc.desc Function test - */ - it('Telephony_SmsMms_ShortMessageClass_Async_0100', 0, async function (done) { - if (true) { - expect(true).assertTrue(); - 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(); - }); - }) -} +// @ts-nocheck +/** + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import mms from '@ohos.telephony.sms'; +import utils from './Utils.ets' +export default function smsUiJsunit() { + describe('appInfoTest', function () { + + const SMS_SEND_DST_NUMBER = ''; + const TRUE_SLOT_ID = 0; + const FALSE_SLOT_ID = 9; + const OTHER_SLOT_ID = 1; + const SECOND_SLOT_ID = 2; + const IDENTIFIER_MIN = 0; + const IDENTIFIER_MAX = 0xFFFF; + const RANTYPE_GSM = 1; + const RANTYPE_CDMA = 2; + const RANTYPE_ERROR = 3; + var rawArray = [ + 0x08, 0x91, 0x68, 0x31, 0x08, 0x20, 0x00, 0x75, 0xF4, 0x24, 0x0D, 0x91, + 0x68, 0x81, 0x29, 0x56, 0x29, 0x83, 0xF6, 0x00, 0x00, 0x12, 0x40, 0x80, + 0x01, 0x02, 0x14, 0x23, 0x02, 0xC1, 0x30 + ] + + + + /* + * @tc.number Telephony_SmsMms_createMessage_Async_0100 + * @tc.name Call interface CreateMessage, + * pass in the PDU(rawArray) in line with the coding specification, the specification is 3GPP, + * shortMessage Don't empty + * @tc.desc Function test + */ + it('Telephony_SmsMms_createMessage_Async_0100', 0, async function (done) { + if (true) { + expect(true).assertTrue(); + done(); + return; + } + sms.createMessage(rawArray, '3gpp', (err, shortMessage) => { + if (err) { + expect().assertFail(); + console.log('Telephony_SmsMms_createMessage_Async_0100 fail'); + done(); + return; + } + expect(shortMessage.visibleMessageBody === MESSAGEBODY).assertTrue(); + expect(shortMessage.visibleRawAddress.length === ADDR_LENGTH).assertTrue(); + expect(shortMessage.messageClass === sms.FORWARD_MESSAGE).assertTrue(); + expect(shortMessage.protocolId === 0).assertTrue(); + expect(shortMessage.scAddress.length === ADDR_LENGTH).assertTrue(); + expect(shortMessage.scTimestamp === SC_TIMESTAMP).assertTrue(); + expect(shortMessage.isReplaceMessage).assertFalse(); + expect(shortMessage.hasReplyPath).assertFalse(); + expect(shortMessage.pdu.length > 0).assertTrue(); + expect(shortMessage.status === 0).assertTrue(); + expect(shortMessage.isSmsStatusReportMessage).assertTrue(); + console.log('Telephony_SmsMms_createMessage_Async_0100 finish'); + done(); + }); + }); + + /* + * @tc.number Telephony_SmsMms_createMessage_Async_0300 + * @tc.name testCreateMessage_0300 + * @tc.desc Call interface CreateMessage, + * pass in the PDU(rawArray) in line with the coding specification, the specification is 3GPP, + * shortMessage Don't empty + */ + it('Telephony_SmsMms_createMessage_Promise_0100', 0, async function (done) { + if (true) { + expect(true).assertTrue(); + done(); + return; + } + sms.createMessage(rawArray, '3gpp').then(shortMessage => { + expect(shortMessage.visibleMessageBody === MESSAGEBODY).assertTrue(); + expect(shortMessage.visibleRawAddress.length === ADDR_LENGTH).assertTrue(); + expect(shortMessage.messageClass === sms.FORWARD_MESSAGE).assertTrue(); + expect(shortMessage.protocolId === 0).assertTrue(); + expect(shortMessage.scAddress.length === ADDR_LENGTH).assertTrue(); + expect(shortMessage.scTimestamp === SC_TIMESTAMP).assertTrue(); + expect(shortMessage.isReplaceMessage).assertFalse(); + expect(shortMessage.hasReplyPath).assertFalse(); + expect(shortMessage.pdu.length > 0).assertTrue(); + expect(shortMessage.status === 0).assertTrue(); + expect(shortMessage.isSmsStatusReportMessage).assertTrue(); + console.log('Telephony_SmsMms_createMessage_Promise_0100 finish'); + done(); + }).catch(err => { + expect().assertFail(); + console.log('Telephony_SmsMms_createMessage_Promise_0100 fail'); + done(); + return; + }); + }); + + + /* + * @tc.number Telephony_SmsMms_getSmsEncodingScheme_Async_0100 + * @tc.name + * @tc.desc Function test + */ + it('Telephony_SmsMms_getSmsEncodingScheme_Async_0100', 0, async function (done) { + if (true) { + expect(true).assertTrue(); + done(); + return; + } + expect(sms.SMS_ENCODING_UNKNOWN == 0).assertTrue(); + expect(sms.SMS_ENCODING_7BIT == 1).assertTrue(); + expect(sms.SMS_ENCODING_8BIT == 2).assertTrue(); + expect(sms.SMS_ENCODING_16BIT == 3).assertTrue(); + done(); + }); + + /* + * @tc.number Telephony_SmsMms_getSendSmsResult_Async_0100 + * @tc.name + * @tc.desc Function test + */ + it('Telephony_SmsMms_getSendSmsResult_Async_0100', 0, async function (done) { + if (true) { + expect(true).assertTrue(); + 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_ShortMessageClass_Async_0100 + * @tc.name + * @tc.desc Function test + */ + it('Telephony_SmsMms_ShortMessageClass_Async_0100', 0, async function (done) { + if (true) { + expect(true).assertTrue(); + 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(); + }); + }) +} diff --git a/telephony/telephonyjstest/sim/sim_manager_function_test/entry/src/main/js/test/SimManager.test.js b/telephony/telephonyjstest/sim/sim_manager_function_test/entry/src/main/js/test/SimManager.test.js index 6b8d6a20256d10f01a9d2f1c7f3b3c0afa9dd3eb..200e47b5bd52e91df51d2ce107eec18a8ecdb6d6 100644 --- a/telephony/telephonyjstest/sim/sim_manager_function_test/entry/src/main/js/test/SimManager.test.js +++ b/telephony/telephonyjstest/sim/sim_manager_function_test/entry/src/main/js/test/SimManager.test.js @@ -511,4 +511,5 @@ describe('SimManagerTest', function () { } done(); }); + }) diff --git a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/execute.js b/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/execute.js index 301b4c3b6ad3923f8014190f1b5e0bed272069fc..432e802d4838d6d9b651eae6e730e483af59b611 100644 --- a/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/execute.js +++ b/useriam/face_auth/js_api_test/function_test/userauth/entry/src/main/js/test/execute.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -35,48 +35,413 @@ describe('userAuthTest', function () { }) /** - * @tc.name execute_authentication_callback_ALL_NO_SUPPORT - * @tc.number JSAPI_Function_Execute_1700 + * @tc.name execute_authentication_callback_failed + * @tc.number JSAPI_Function_Execute_0100 * @tc.size MEDIUM * @tc.type FUNC * @tc.level Level2 */ - it('JSAPI_Function_Execute_1700', 0, function (done) { - console.log("JSAPI_Function_Execute_1700 start"); + it('JSAPI_Function_Execute_0100', 0, function (done) { + 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(); - auth.execute("ALL", "S2", function(data) { - console.log("JSAPI_Function_Execute_1700 auth.execute:" + data); - // NO_SUPPORT(-1) - expect(data).assertEqual(-1); + auth.execute("FACE_ONLY", "S2", function(data) { + console.log("JSAPI_Function_Execute_0100 auth.execute:" + data); + // COMPARE_FAILURE(1) + expect(data).assertEqual(1); setTimeout(function() { done(); }, 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.number JSAPI_Function_Execute_2000 + * @tc.name execute_authentication_callback_camera_fail + * @tc.number JSAPI_Function_Execute_0300 * @tc.size MEDIUM * @tc.type FUNC * @tc.level Level2 */ - it('JSAPI_Function_Execute_2000', 0, function (done) { - console.log("JSAPI_Function_Execute_2000 start"); + it('JSAPI_Function_Execute_0300', 0, function (done) { + console.log("JSAPI_Function_Execute_0300 start"); + index.default.fileSaveB('JSAPI_Function_Execute_0300','903') const auth = userAuth.getAuthenticator(); - auth.execute("ALL", "S2").catch(function(data) { - console.log("JSAPI_Function_Execute_2000 auth.execute:" + data); + auth.execute("FACE_ONLY", "S2", function(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) expect(data).assertEqual(-1); setTimeout(function() { done(); }, 1); }); - console.log("JSAPI_Function_Execute_2000 end"); + console.log("JSAPI_Function_Execute_1700 end"); }) - + /** * @tc.name execute_authentication_callback_Type_is_null * @tc.number JSAPI_Function_Execute_1800 @@ -98,6 +463,47 @@ describe('userAuthTest', function () { 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 @@ -109,7 +515,7 @@ describe('userAuthTest', function () { it('JSAPI_Function_Execute_2100', 0, function (done) { console.log("JSAPI_Function_Execute_2100 start"); 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); // INVALID_PARAMETERS(6) expect(data).assertEqual(6); @@ -119,4 +525,123 @@ describe('userAuthTest', function () { }); 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