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 4e8afec46431811e2698c865c880f9a3359db4b3..468b241987620746452bb961e4931f7f04f2b873 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 @@ -298,6 +298,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 @@ -363,7 +387,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 = []; @@ -384,12 +408,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(); }); @@ -399,6 +423,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 @@ -408,7 +479,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); @@ -421,12 +492,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(); }); @@ -436,6 +507,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 @@ -743,3 +852,4 @@ describe('bluetoothhostTest', function() { }) }) + 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 dbf6dc864820d0cedce78020532c4f1196327a76..b596a6b354e4cce0d8e28cee7d0c7885b8e83ac0 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 @@ -17,8 +17,6 @@ import geolocation from '@ohos.geolocation'; import { LocationEventListener } from '@ohos.geolocation'; import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import bundle from '@ohos.bundle' -import osaccount from '@ohos.account.osAccount' - import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' let LocationRequestScenario = {UNSET : 0x300 ,NAVIGATION : 0x301 , TRAJECTORY_TRACKING : 0x302 ,CAR_HAILING : 0x303, @@ -34,7 +32,7 @@ function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function changedLocationMode(){ - await geolocation.isLocationEnabled().then(async(result) => { + await geolocation.isLocationEnabled().then(async(result) => { console.info('[lbs_js] getLocationSwitchState result: ' + result); if(!result){ await geolocation.requestEnableLocation().then(async(result) => { @@ -53,11 +51,7 @@ async function changedLocationMode(){ } async function applyPermission() { - let osAccountManager = osaccount.getAccountManager(); - console.info('[permission] getAccountManager call end'); - let localId = await osAccountManager.getOsAccountLocalIdFromProcess(); - console.info('[permission] getOsAccountLocalIdFromProcess localId' + localId); - let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, localId); + let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, 100); let atManager = abilityAccessCtrl.createAtManager(); if (atManager != null) { let tokenID = appInfo.accessTokenId; @@ -119,7 +113,7 @@ describe('geolocationTest', function () { geolocation.isGeoServiceAvailable(async(err, data) => { if (err) { console.info('[lbs_js] getGeoServiceState err is : ' + err ); - + }else { console.info('[lbs_js] isGeoServiceAvailable callback result: ' + data); expect(data).assertTrue(); @@ -135,7 +129,7 @@ describe('geolocationTest', function () { * @tc.size MEDIUM * @tc.type Function * @tc.level Level 2 - */ + */ it('SUB_HSS_LocationSystem_Geo_0002', 0, async function (done) { await geolocation.isGeoServiceAvailable().then( (result) => { console.info('[lbs_js] isGeoServiceAvailable1 promise result: ' + result); @@ -154,8 +148,8 @@ describe('geolocationTest', function () { * @tc.size MEDIUM * @tc.type Function * @tc.level Level 2 - */ - it('SUB_HSS_LocationSystem_Geo_0003', 0, async function (done) { + */ + it('SUB_HSS_LocationSystem_Geo_0003', 0, async function (done) { let reverseGeocodeRequest = {"latitude": 31.265496, "longitude": 121.62771, "maxItems": 1,"locale": "zh"}; let promise = new Promise((resolve,reject) => { geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { @@ -204,7 +198,7 @@ describe('geolocationTest', function () { * @tc.type Function * @tc.level Level 2 */ - it('SUB_HSS_LocationSystem_Geo_0005', 0, async function (done) { + it('SUB_HSS_LocationSystem_Geo_0005', 0, async function (done) { let reverseGeocodeRequest = {"latitude": 31.265496, "longitude": 121.62771, "maxItems": 5}; await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { console.info('[lbs_js] getAddressesFromLocation05 promise: ' + JSON.stringify(data)); @@ -224,7 +218,7 @@ describe('geolocationTest', function () { * @tc.size MEDIUM * @tc.type Function * @tc.level Level 2 - */ + */ it('SUB_HSS_LocationSystem_Geo_0006', 0, async function (done) { let reverseGeocodeRequest1 = {"latitude": 90, "longitude": 121.62771, "maxItems": 1}; await geolocation.getAddressesFromLocation(reverseGeocodeRequest1).then((data) => { @@ -268,7 +262,7 @@ describe('geolocationTest', function () { * @tc.size MEDIUM * @tc.type Function * @tc.level Level 2 - */ + */ it('SUB_HSS_LocationSystem_Geo_0007', 0, async function (done) { let reverseGeocodeRequest = {"latitude": 31.265496, "longitude": 180, "maxItems": 1}; await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { @@ -312,8 +306,8 @@ describe('geolocationTest', function () { * @tc.size MEDIUM * @tc.type Function * @tc.level Level 2 - */ - it('SUB_HSS_LocationSystem_Geo_0008', 0, async function (done) { + */ + it('SUB_HSS_LocationSystem_Geo_0008', 0, async function (done) { let geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 1,"locale": "zh","minLatitude":"" , "minLongitude":"" ,"maxLatitude":"" ,"maxLongitude": ""}; geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => { @@ -341,7 +335,7 @@ describe('geolocationTest', function () { console.info("LOCATION_REQUEST_TIMEOUT_ERROR: "+ err); break; default: - console.info('[lbs_js] getAddressesFromLocationName callback err is : ' + err); + console.info('[lbs_js] getAddressesFromLocationName callback err is : ' + err); } }else { console.info("[lbs_js] getAddressesFromLocationName08 callback data is: " + JSON.stringify(data)); @@ -358,7 +352,7 @@ describe('geolocationTest', function () { * @tc.size MEDIUM * @tc.type Function * @tc.level Level 2 - */ + */ it('SUB_HSS_LocationSystem_Geo_0009', 0, async function (done) { let geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 1}; await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { @@ -378,7 +372,7 @@ describe('geolocationTest', function () { * @tc.size MEDIUM * @tc.type Function * @tc.level Level 2 - */ + */ it('SUB_HSS_LocationSystem_Geo_0010', 0, async function (done) { let geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 5}; await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { @@ -391,14 +385,14 @@ describe('geolocationTest', function () { done(); }) - /** + /** * @tc.number Geo_0011 * @tc.name SUB_HSS_LocationSystem_Geo_0011 * @tc.desc Test getAddressesFromLocationName api . * @tc.size MEDIUM * @tc.type Function * @tc.level Level 2 - */ + */ it('SUB_HSS_LocationSystem_Geo_0011', 0, async function (done) { let geocodeRequest = {"description": "", "maxItems": 1}; await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { @@ -419,7 +413,7 @@ describe('geolocationTest', function () { done(); }) - /** + /** * @tc.number Geo_0012 * @tc.name SUB_HSS_LocationSystem_Geo_0012 * @tc.desc Test getAddressesFromLocationName api . @@ -519,7 +513,7 @@ describe('geolocationTest', function () { * @tc.size MEDIUM * @tc.type Function * @tc.level Level 2 - */ + */ it('SUB_HSS_LocationSystem_Geo_0016', 0, async function (done) { let geocodeRequest1 = {"description": "上海金穗路1800号", "maxItems": 1, "minLatitude":-90 , "minLongitude":121.5782001832,"maxLatitude":31.1537977881,"maxLongitude":121.8026736943}; @@ -603,7 +597,7 @@ describe('geolocationTest', function () { * @tc.size MEDIUM * @tc.type Function * @tc.level Level 2 - */ + */ it('SUB_HSS_LocationSystem_Geo_0017', 0, async function (done) { let geocodeRequest1 = {"description": "北京天安门", "maxItems": 1, "minLatitude":39.85 , "minLongitude":-180,"maxLatitude":39.95,"maxLongitude":116.45}; @@ -692,7 +686,7 @@ describe('geolocationTest', function () { geolocation.isLocationEnabled(async(err, data) => { if (err) { console.info('[lbs_js] getLocationSwitchState err is : ' + err ); - + }else { console.info('[lbs_js] getLocationSwitchState callback data1: ' + data); expect(data).assertTrue(); @@ -731,7 +725,7 @@ describe('geolocationTest', function () { geolocation.isLocationEnabled(async(err, data) => { if (err) { console.info('[lbs_js] getLocationSwitchState callback err is : ' + err ); - + }else { console.info("[lbs_js] getLocationSwitchState callback data: " + data); expect(data).assertTrue(); @@ -967,7 +961,7 @@ describe('geolocationTest', function () { }); done() }) - + /** * @tc.number SingleLoc_0008 * @tc.name SUB_HSS_LocationSystem_SingleLoc_0008 @@ -1014,6 +1008,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(); + }) + })