diff --git a/communication/wifi_standard/src/main/js/default/test/WifiSta.test.js b/communication/wifi_standard/src/main/js/default/test/WifiSta.test.js
index 7d67fdd7cc1f7dafc08f9084ea765403cde82062..6047a4a183bff5fcc1c40381f607a6e56a614955 100755
--- a/communication/wifi_standard/src/main/js/default/test/WifiSta.test.js
+++ b/communication/wifi_standard/src/main/js/default/test/WifiSta.test.js
@@ -35,6 +35,21 @@ var WifiSecurityType = {
WIFI_SEC_TYPE_SAE: 4,
}
+var SuppState = {
+ DISCONNECTED: 0,
+ INTERFACE_DISABLED: 1,
+ INACTIVE : 2,
+ SCANNING: 3,
+ AUTHENTICATING: 4,
+ ASSOCIATING: 5,
+ ASSOCIATED: 6,
+ FOUR_WAY_HANDSHAKE: 7,
+ GROUP_HANDSHAKE: 8,
+ COMPLETED: 9,
+ UNINITIALIZED: 10,
+ INVALID: 11,
+}
+
var wifiDeviceConfig = {
"ssid": "TEST",
"bssid": "A1:B1:C1:D1:E1:F1",
@@ -43,6 +58,17 @@ var wifiDeviceConfig = {
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
}
+var ConnState = {
+ SCANNING: 0,
+ CONNECTING: 1,
+ AUTHENTICATING: 2,
+ OBTAINING_IPADDR: 3,
+ CONNECTED: 4,
+ DISCONNECTING: 5,
+ DISCONNECTED: 6,
+ UNKNOWN: 7,
+}
+
var ipConfig = {
"ipAddress": 1284752956,
"gateway": 17017024,
@@ -352,7 +378,7 @@ describe('ACTS_WifiTest', function() {
expect(true).assertEqual(netWorkId != -1);
console.info("[wifi_test]connectdevice result: " + wifi.connectToNetwork(netWorkId));
expect(wifi.connectToNetwork(netWorkId)).assertTrue();
- console.info("[wifi_test] get empty linked information and getIpInfo.");
+ console.info("[wifi_test] disableNetwork test start.");
var disconNet = wifi.disableNetwork(netWorkId);
console.log("[wifi_test] wifi disableNetwork result: " + disconNet);
expect(disconNet).assertTrue();
@@ -382,9 +408,33 @@ describe('ACTS_WifiTest', function() {
})
/**
- * @tc.number Info_0002
- * @tc.name SUB_Communication_WiFi_Sta_Info_0002
- * @tc.desc Test get CountryCode
+ * @tc.number SUB_Communication_WiFi_Sta_info_0001
+ * @tc.name testgetMacAddress
+ * @tc.desc Test getMacAddress api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('SUB_Communication_WiFi_Sta_info_0001', 0, function () {
+ if (!wifi.isWifiActive()) {
+ var enable = wifi.enableWifi();
+ sleep(3000);
+ expect(enable).assertTrue();
+ }
+ expect(wifi.isWifiActive()).assertTrue();
+ console.info('[wifi_test] getDeviceMacAddress test start ...');
+ var result = wifi.getDeviceMacAddress();
+ console.info("[wifi_test] getDeviceMacAddress -> " + JSON.stringify(result));
+ expect(true).assertEqual(result.length >= 1)
+ })
+
+ /**
+ * @tc.number SUB_Communication_WiFi_Sta_info_0002
+ * @tc.name testgetCountryCode
+ * @tc.desc Test getCountryCode api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
*/
it('SUB_Communication_WiFi_Sta_Info_0002', 0, function() {
if (!wifi.isWifiActive()) {
@@ -398,39 +448,86 @@ describe('ACTS_WifiTest', function() {
console.info("[wifi_test] getCountryCode -> " + JSON.stringify(countryCode));
expect(JSON.stringify(countryCode)).assertEqual('"CN"');
})
+
+ /**
+ * @tc.number SUB_Communication_WiFi_Sta_info_0004
+ * @tc.name testFeatureSupported
+ * @tc.desc Test FeatureSupported api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('SUB_Communication_WiFi_Sta_info_0004', 0, function () {
+ console.info('[wifi_test]FeatureSupported test start ...');
+ var result = wifi.getSupportedFeatures();
+ console.info("[wifi_test] getFeatureSupported -> " + JSON.stringify(result));
+ console.info("[wifi_test] isFeatureSupported: " + result +"->" + wifi.isFeatureSupported(result));
+ expect(wifi.isFeatureSupported(result)).assertTrue();
+ })
+
/**
- * @tc.number Config_0002
- * @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0001
- * @tc.desc Test cnnnection a PSK SecurityType wifi deviceconfig
+ * @tc.number Conn_Info_0001
+ * @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0001
+ * @tc.desc Test reconnect wifi
+ */
+ it('SUB_Communication_WiFi_Sta_Conn_Info_0001', 0, function () {
+ console.info("[wifi_test] wifi connectToDevice test.");
+ var wifiDeviceConfigConn = {
+ "ssid": "TESTCONN",
+ "bssid": "",
+ "preSharedKey": "12345678",
+ "isHiddenSsid": false,
+ "securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
+ };
+ var active = wifi.isWifiActive();
+ sleep(3000);
+ console.log("[wifi_test] wifi active result2: " + active);
+ if(!active){
+ var enable = wifi.enableWifi();
+ expect(enable).assertTrue();
+ sleep(3000);
+ }
+ var result1 = wifi.connectToDevice(wifiDeviceConfigConn);
+ sleep(5000);
+ console.log("[wifi_test] wifi connectToDevice result: " + result1);
+ expect(result1).assertTrue();
+ console.info("[wifi_test] check isconnected wifi");
+ var isConnected= wifi.isConnected();
+ console.log("[wifi_test] wifi isConnected result: " + isConnected);
+ expect(isConnected).assertFalse();
+ console.info("[wifi_test] reconnect wifi");
+ var result= wifi.reconnect();
+ sleep(5000);
+ console.log("[wifi_test] wifi reconnect result: " + result);
+ expect(result).assertTrue();
+
+ })
+
+ /**
+ * @tc.number conn_Config_0002
+ * @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0002
+ * @tc.desc Test getLinkedInfo information
*/
- it('SUB_Communication_WiFi_Sta_Conn_Info_0001', 0, async function() {
- console.info("[wifi_test][SUB_Communication_WiFi_Sta_Config_0002]");
- console.info("[wifi_test] create a PSK SecurityType wifi device config start.");
- var wifiDeviceConfigConn = {
- "ssid": "TEST_CONN",
- "bssid": "",
- "preSharedKey": "12345678",
- "isHiddenSsid": false,
- "securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
- };
- console.info("[wifi_test] check add device configs successfully ");
- var configs = wifi.getDeviceConfigs();
- console.info("[wifi_test] wifi getDeviceConfigs result1 : " + JSON.stringify(configs));
- console.info("[wifi_test] connect wifi start.");
- var conn1 = wifi.connectToDevice(wifiDeviceConfigConn);
- sleep(5000);
- console.log("[wifi_test] wifi Connected result: " + conn1);
- console.info("[wifi_test] check isconnected wifi");
- var isConnected= wifi.isConnected();
- console.log("[wifi_test] wifi isConnected result: " + isConnected);
- expect(isConnected).assertFalse();
- wifi.getLinkedInfo((err, data) => {
+ it('SUB_Communication_WiFi_Sta_Conn_Info_0001', 0, async function(done) {
+ console.info("[wifi_test][SUB_Communication_WiFi_Sta_Conn_Info_0001]");
+ console.info(' console.info("[wifi_js] Wifi get link infos test[1]."');
+ wifi.getLinkedInfo()
+ .then((result) => {
+ console.info("[wifi_js] get wifi link [promise] -> " + JSON.stringify(result));
+ expect(JSON.stringify(result)).assertContain('band');
+ console.info("[wifi_js] get wifi link [promise].");
+ done();
+ }).catch((error) => {
+ console.info("[wifi_js] promise then error." + JSON.stringify(error));
+ expect().assertFail();
+ });
+ wifi.getLinkedInfo((err, result) => {
if (err) {
- return console.error('failed to get link infos callback because ' + JSON.stringify(err));
+ return console.error('failed to getlink infos callback because ' + JSON.stringify(err));
}else {
- console.info("[wifi_test] get wifi link [callback] -> " + JSON.stringify(data));
- for (var j = 0; j < JSON.stringify(data).length; ++j) {
+ console.info("[wifi_test] get wifi link [callback] -> " + JSON.stringify(result));
+ for (var j = 0; j < JSON.stringify(result).length; ++j) {
console.info("ssid: " + result[j].ssid);
console.info("bssid: " + result[j].bssid);
console.info("band: " + result[j].band);
@@ -447,24 +544,38 @@ describe('ACTS_WifiTest', function() {
console.info("suppState: " + result[j].suppState);
console.info("connState: " + result[j].connState);
}
-
}
+ done();
});
- console.info("[wifi_test] get empty linked information and getIpInfo.");
- var discon2 = wifi.disconnect();
- console.log("[wifi_test] wifi disconnect result: " + discon2);
- expect(discon2).assertTrue();
-
})
-
/**
- * @tc.number Conn_Info_0002
- * @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0002
+ * @tc.number Conn_Info_0003
+ * @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0003
* @tc.desc Test get IpInfo information
*/
it('SUB_Communication_WiFi_Sta_Conn_Info_0002', 0, function () {
-
+ console.info("[wifi_test] wifi connectToDevice test.");
+ var wifiDeviceConfigIp = {
+ "ssid": "TEST1",
+ "bssid": "",
+ "preSharedKey": "87654321",
+ "isHiddenSsid": "false",
+ "securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
+ };
+ var result1 = wifi.connectToDevice(wifiDeviceConfigIp);
+ sleep(5000);
+ console.log("[wifi_test] wifi connectToDevice result: " + result1);
+ expect(result1).assertTrue();
+ console.info("[wifi_test] check isconnected wifi");
+ var isConnected= wifi.isConnected();
+ console.log("[wifi_test] wifi isConnected result: " + isConnected);
+ expect(isConnected).assertFalse();
+ console.info("[wifi_test] reassociate wifi");
+ var result= wifi.reassociate();
+ sleep(5000);
+ console.log("[wifi_test] wifi reassociate result: " + result);
+ expect(result).assertTrue();
console.info("[wifi_test] get IpInfo.");
var ipInfo = wifi.getIpInfo();
console.info("[wifi_test] getIpInfo -> " + JSON.stringify(ipInfo));
@@ -478,43 +589,6 @@ describe('ACTS_WifiTest', function() {
console.info("serverIp: " + ipInfo.serverIp);
})
- /**
- * @tc.number SUB_Communication_WiFi_Sta_info_0004
- * @tc.name testFeatureSupported
- * @tc.desc Test FeatureSupported api.
- * @tc.size MEDIUM
- * @tc.type Function
- * @tc.level Level 3
- */
- it('SUB_Communication_WiFi_Sta_info_0004', 0, function () {
- console.info('[wifi_test]FeatureSupported test start ...');
- var result = wifi.getSupportedFeatures();
- console.info("[wifi_test] getFeatureSupported -> " + JSON.stringify(result));
- console.info("[wifi_test] isFeatureSupported: " + result +"->" + wifi.isFeatureSupported(result));
- expect(wifi.isFeatureSupported(result)).assertTrue();
- })
-
- /**
- * @tc.number SUB_Communication_WiFi_Sta_info_0001
- * @tc.name testgetMacAddress
- * @tc.desc Test getMacAddress api.
- * @tc.size MEDIUM
- * @tc.type Function
- * @tc.level Level 3
- */
- it('SUB_Communication_WiFi_Sta_info_0001', 0, function () {
- if (!wifi.isWifiActive()) {
- var enable = wifi.enableWifi();
- sleep(3000);
- expect(enable).assertTrue();
- }
- expect(wifi.isWifiActive()).assertTrue();
- console.info('[wifi_test] getDeviceMacAddress test start ...');
- var result = wifi.getDeviceMacAddress();
- console.info("[wifi_test] getDeviceMacAddress -> " + JSON.stringify(result));
- expect(true).assertEqual(result.length >= 1)
- })
-
/**
* @tc.number SUB_Communication_WiFi_Sta_ON_0001
* @tc.name testwifiStateChangeOn
@@ -694,3 +768,4 @@ describe('ACTS_WifiTest', function() {
console.log("*************[wifi_test] start wifi js unit test end*************");
})
+
diff --git a/location/BUILD.gn b/location/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..ac5383466bf5dba009e392f9005f36463924537d
--- /dev/null
+++ b/location/BUILD.gn
@@ -0,0 +1,22 @@
+# 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("//build/ohos_var.gni")
+group("location") {
+ testonly = true
+ if (is_standard_system) {
+ deps = [ "geolocation_standard:ActslocationJsTest" ]
+ } else {
+ deps = [ "geolocation_standard:ActslocationJsTest" ]
+ }
+}
diff --git a/location/geolocation_standard/BUILD.gn b/location/geolocation_standard/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..94a47226561adde2bed6d8ebad2084dd430cbbfd
--- /dev/null
+++ b/location/geolocation_standard/BUILD.gn
@@ -0,0 +1,38 @@
+# 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("//test/xts/tools/build/suite.gni")
+ohos_js_hap_suite("ActslocationJsTest") {
+ hap_profile = "./src/main/config.json"
+ deps = [
+ ":geolocation_js_assets",
+ ":geolocation_resources",
+ ]
+
+ # shared_libraries = [
+ # "//third_party/giflib:libgif",
+ # "//third_party/libpng:libpng",
+ # ]
+ certificate_profile = "./signature/openharmony_sx.p7b"
+ hap_name = "ActslocationJSApiTest"
+
+ # part_name = "prebuilt_hap"
+ # subsystem_name = "xts"
+}
+ohos_js_assets("geolocation_js_assets") {
+ source_dir = "./src/main/js/default"
+}
+ohos_resources("geolocation_resources") {
+ sources = [ "./src/main/resources" ]
+ hap_profile = "./src/main/config.json"
+}
diff --git a/location/geolocation_standard/Test.json b/location/geolocation_standard/Test.json
new file mode 100644
index 0000000000000000000000000000000000000000..3d555b1de4f12486c40a3f9be114a7c028dbf8a6
--- /dev/null
+++ b/location/geolocation_standard/Test.json
@@ -0,0 +1,18 @@
+{
+ "description": "Configuration for geolocation js api Tests",
+ "driver": {
+ "type": "JSUnitTest",
+ "test-timeout": "600000",
+ "package": "ohos.acts.location.geolocation.function",
+ "shell-timeout": "60000"
+ },
+ "kits": [
+ {
+ "test-file-name": [
+ "ActslocationJSApiTest.hap"
+ ],
+ "type": "AppInstallKit",
+ "cleanup-apps": true
+ }
+ ]
+}
diff --git a/location/geolocation_standard/signature/openharmony_sx.p7b b/location/geolocation_standard/signature/openharmony_sx.p7b
new file mode 100644
index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5
Binary files /dev/null and b/location/geolocation_standard/signature/openharmony_sx.p7b differ
diff --git a/location/geolocation_standard/src/main/config.json b/location/geolocation_standard/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..fefe39c0f3d721ce64ad6294e17009b3dcf62df5
--- /dev/null
+++ b/location/geolocation_standard/src/main/config.json
@@ -0,0 +1,60 @@
+{
+ "app": {
+ "bundleName": "ohos.acts.location.geolocation.function",
+ "vendor": "acts",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "ohos.acts.location.geolocation.function",
+ "name": ".MyApplication",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry"
+ },
+ "abilities": [
+ {
+ "visible": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "name": "ohos.acts.location.geolocation.function.MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ],
+ "js": [
+ {
+ "pages": [
+ "pages/index/index"
+ ],
+ "name": "default",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": false
+ }
+ }
+ ]
+ }
+}
diff --git a/location/geolocation_standard/src/main/js/default/app.js b/location/geolocation_standard/src/main/js/default/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..363f2555b1badec9fec342a93141db084083fcb8
--- /dev/null
+++ b/location/geolocation_standard/src/main/js/default/app.js
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+export default {
+ onCreate() {
+ console.info('AceApplication onCreate');
+ },
+ onDestroy() {
+ console.info('AceApplication onDestroy');
+ }
+};
diff --git a/location/geolocation_standard/src/main/js/default/i18n/en-US.json b/location/geolocation_standard/src/main/js/default/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c
--- /dev/null
+++ b/location/geolocation_standard/src/main/js/default/i18n/en-US.json
@@ -0,0 +1,6 @@
+{
+ "strings": {
+ "hello": "Hello",
+ "world": "World"
+ }
+}
\ No newline at end of file
diff --git a/location/geolocation_standard/src/main/js/default/i18n/zh-CN.json b/location/geolocation_standard/src/main/js/default/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f
--- /dev/null
+++ b/location/geolocation_standard/src/main/js/default/i18n/zh-CN.json
@@ -0,0 +1,6 @@
+{
+ "strings": {
+ "hello": "您好",
+ "world": "世界"
+ }
+}
\ No newline at end of file
diff --git a/location/geolocation_standard/src/main/js/default/pages/index/index.css b/location/geolocation_standard/src/main/js/default/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf
--- /dev/null
+++ b/location/geolocation_standard/src/main/js/default/pages/index/index.css
@@ -0,0 +1,9 @@
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+}
+
+.title {
+ font-size: 100px;
+}
diff --git a/location/geolocation_standard/src/main/js/default/pages/index/index.hml b/location/geolocation_standard/src/main/js/default/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184
--- /dev/null
+++ b/location/geolocation_standard/src/main/js/default/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
diff --git a/location/geolocation_standard/src/main/js/default/pages/index/index.js b/location/geolocation_standard/src/main/js/default/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..30f42fc041b3fa7bfb6fd987e38424ae0a0f8045
--- /dev/null
+++ b/location/geolocation_standard/src/main/js/default/pages/index/index.js
@@ -0,0 +1,43 @@
+/*
+ * 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 app from '@system.app'
+import {Core, ExpectExtend} from 'deccjsunit/index'
+
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ },
+ onShow() {
+ console.info('onShow finish')
+ const core = Core.getInstance()
+ const expectExtend = new ExpectExtend({
+ 'id': 'extend'
+ })
+ core.addService('expect', expectExtend)
+ core.init()
+
+ const configService = core.getDefaultService('config')
+ configService.setConfig(this)
+
+ require('../../test/List.test')
+ core.execute()
+ },
+ onReady() {
+ },
+}
diff --git a/location/geolocation_standard/src/main/js/default/test/Geolocation.test.js b/location/geolocation_standard/src/main/js/default/test/Geolocation.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..439811ae485adb4a77c71360636365004ba102f2
--- /dev/null
+++ b/location/geolocation_standard/src/main/js/default/test/Geolocation.test.js
@@ -0,0 +1,675 @@
+/*
+ * 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 geolocation from '@ohos.geolocation';
+import { LocationEventListener } from '@ohos.geolocation';
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+
+describe('geolocationTest', function () {
+ beforeAll(function () {
+ console.info('beforeAll called')
+ })
+ beforeEach(function () {
+ console.info('beforeEach called')
+
+ })
+ afterEach(function () {
+ console.info('afterEach called')
+ })
+ afterAll(function () {
+ console.info('afterAll called')
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_ENABLE_LOCATION_PROMISE_0001
+ * @tc.name testenableLocation promise
+ * @tc.desc Test enableLocation api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+
+ it('geolocation_enableLocation_promise_test_001', 0, async function (done) {
+ console.info('LBS enableLocation promise test start ...');
+ await geolocation.enableLocation().then((result) => {
+ console.info('[lbs_js] testenableLocation result: ' + result);
+ expect(result).assertTrue();
+ console.info("[lbs_js] enableLocation promise.");
+ }).catch((error) => {
+ console.info("[lbs_js] promise then error." + error.message);
+ expect().assertFail();
+ })
+ done()
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_LOCATION_ENABLED_PROMISE_0001
+ * @tc.name testisLocationEnabled promise
+ * @tc.desc Test isLocationEnabled api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_isLocationEnabled_promise_test_001', 0, async function (done) {
+ console.info('LBS enableLocation promise test start ...');
+ await geolocation.enableLocation().then((result) => {
+ console.info('[lbs_js] testenableLocation result: ' + result);
+ expect(result).assertTrue();
+ console.info("[lbs_js] enableLocation promise.");
+ }).catch((error) => {
+ console.info("[lbs_js] promise then error." + error.message);
+ expect().assertFail();
+ });
+
+ console.info('[lbs_js] LBS getLocationSwitchState promise test start ...');
+ await geolocation.isLocationEnabled().then((result) => {
+ console.info('[lbs_js] getLocationSwitchState result: ' + result);
+ expect(result).assertTrue();
+ console.info("[lbs_js] getLocationSwitchState promise.");
+ }).catch((error) => {
+ console.info("[lbs_js] promise then error.");
+ expect().assertFail();
+ });
+ done();
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_CALLBACK_0001
+ * @tc.name testgetAddressesFromLocationName callback
+ * @tc.desc Test getAddressesFromLocationName api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_getAddressesFromLocationName_callback_test_001', 0, async function (done) {
+ console.info('LBS enableLocation promise test start ...');
+ await geolocation.enableLocation().then((result) => {
+ console.info('[lbs_js] testenableLocation result: ' + result);
+ expect(result).assertTrue();
+ console.info("[lbs_js] enableLocation promise.");
+ }).catch((error) => {
+ console.info("[lbs_js] promise then error." + error.message);
+ expect().assertFail();
+ });
+
+ console.info('LBS getAddressesFromLocationName callback test start ...');
+ var geocodeRequest = {"description": "上海市浦东新区金穗路1800号",
+ "maxItems": 1,"locale":"zh"};
+ geolocation.getAddressesFromLocationName(geocodeRequest,
+ (err, data) => {
+ if (err) {
+ switch(err){
+ case 101:
+ console.info("INPUT_PARAMS_ERROR:" + err);
+ break;
+ case 102:
+ console.info("REVERSE_GEOCODE_ERROR:" + err);
+ break;
+ case 103:
+ console.info("GEOCODE_ERROR:" + err);
+ break;
+ case 104:
+ console.info("LOCATOR_ERROR:" + err);
+ break;
+ case 105:
+ console.info("LOCATIOR_SWITCH_ERROR:" + err);
+ break;
+ case 106:
+ console.info("LAST_KNOWN_LOCATION_ERROR:" + err);
+ break;
+ case 107:
+ console.info("LOCATION_REUEST_TIMEOUT_ERROR:" + err);
+ break;
+ default:
+ console.info('[lbs_js]LocationName callback err:' + err);
+ }
+
+ }else {
+ console.info("[lbs_js]LocationName callback data" + JSON.stringify(data));
+ expect(true).assertEqual((JSON.stringify(data)) != null);
+ console.info("[lbs_js] getAddressesFromLocationName callback exit.");
+ }
+ done();
+ });
+
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_CALLBACK_0001
+ * @tc.name testgetAddressesFromLocation callback
+ * @tc.desc Test getAddressesFromLocation api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_getAddressesFromLocation_callback_test_001', 0, async function (done) {
+ console.info('LBS enableLocation promise test start ...');
+ await geolocation.enableLocation().then((result) => {
+ console.info('[lbs_js] testenableLocation result: ' + result);
+ expect(result).assertTrue();
+ console.info("[lbs_js] enableLocation promise.");
+ }).catch((error) => {
+
+ console.info("[lbs_js] promise then error." + error.message);
+ expect().assertFail();
+ });
+
+ console.info('LBS getAddressesFromLocation callback test start ...');
+ var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11,
+ "maxItems": 1,"locale": "zh"};
+ geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => {
+ if (err) {
+ console.info('[lbs_js] getAddressesFromLocation callback err is : ' + err);
+ }else {
+ console.info("[lbs_js] Location callback data is: " + JSON.stringify(data));
+ expect(true).assertEqual((JSON.stringify(data)) !=null);
+ console.info('[lbs_js] Location addressUrl: ' + data[0].addressUrl);
+ console.info('[lbs_js] Location administrativeArea: ' + data[0].administrativeArea);
+ console.info('[lbs_js] Location countryCode: ' + data[0].countryCode);
+ console.info('[lbs_js] Location countryName: ' + data[0].countryName);
+ console.info('[lbs_js] Location descriptions: ' + data[0].descriptions);
+ console.info('[lbs_js] Location descriptionsSize: ' + data[0].descriptionsSize);
+ console.info('[lbs_js] Location latitude: ' + data[0].latitude);
+ console.info('[lbs_js] Location locale: ' + data[0].locale);
+ console.info('[lbs_js] Location locality: ' + data[0].locality);
+ console.info('[lbs_js] Location longitude: ' + data[0].longitude);
+ console.info('[lbs_js] Location phoneNumber: ' + data[0].phoneNumber);
+ console.info('[lbs_js] Location placeName: ' + data[0].placeName);
+ console.info('[lbs_js] FromLocation postalCode: ' + data[0].postalCode);
+ console.info('[lbs_js] Location premises: ' + data[0].premises);
+ console.info('[lbs_js] Location roadName: ' + data[0].roadName);
+ console.info('[lbs_js] getAddressesFromLocation subAdministrativeArea:'
+ + data[0].subAdministrativeArea);
+ console.info('[lbs_js] Location subLocality: ' + data[0].subLocality);
+ console.info('[lbs_js] Location subRoadName: ' + data[0].subRoadName);
+ console.info("[lbs_js] Location callback exit .");
+ }
+ done();
+ });
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_GEOSERVICE_AVAIL_PROMISE_0001
+ * @tc.name testisGeoServiceAvailable promise
+ * @tc.desc Test isGeoServiceAvailable api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_isGeoServiceAvailable_promise_test_001', 0, async function (done) {
+ console.info('LBS enableLocation promise test start ...');
+ await geolocation.enableLocation().then((result) => {
+ console.info('[lbs_js] testenableLocation result: ' + result);
+ expect(result).assertTrue();
+ console.info("[lbs_js] enableLocation promise.");
+ }).catch((error) => {
+ console.info("[lbs_js] promise then error." + error.message);
+ expect().assertFail();
+ });
+
+ console.info('LBS getGeoServiceState promise test start ...');
+ await geolocation.isGeoServiceAvailable().then( (result) => {
+ console.info('[lbs_js] isGeoServiceAvailable result: ' + result);
+ expect(result).assertTrue();
+ console.info("[lbs_js] getGeoServiceState promise.");
+ }).catch((error) => {
+ console.info("[lbs_js] promise then error." + error.message);
+ expect().assertFail();
+ });
+ done();
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_LOCATION_ENABLED_CALLBACK_0001
+ * @tc.name testisLocationEnabled callback
+ * @tc.desc Test isLocationEnabled api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_isLocationEnabled_callback_test_001', 0, async function (done) {
+ console.info('LBS enableLocation callback test start ...');
+ let promiseOne = new Promise((resolve, reject) => {
+ geolocation.enableLocation((err, data) => {
+ if (err) {
+ console.info('[lbs_js] enableLocation callback err is : ' + err );
+ }else {
+ console.info("[lbs_js] enableLocation callback data: " + data);
+ expect(data).assertTrue();
+ console.info("[lbs_js] enableLocation callback exit .");
+ }
+ resolve()
+ });
+ })
+
+ let promiseTwo = new Promise((resolve, reject) => {
+ console.info('LBS getLocationSwitchState callback test start ...');
+ geolocation.isLocationEnabled((err, data) => {
+ if (err) {
+ console.info('[lbs_js] getLocationSwitchState : ' + err);
+ }else {
+ console.info("[lbs_js] getLocationSwitchState data: " + data);
+ expect(data).assertTrue();
+ console.info("[lbs_js] getLocationSwitchState callback exit .");
+ }
+ resolve()
+ });
+ })
+
+ await promiseOne.then(()=>{
+ return promiseTwo
+ }).then(done)
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_NAME_PROMISE_0001
+ * @tc.name testgetAddressesFromLocationName promise
+ * @tc.desc Test getAddressesFromLocationName api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_getAddressesFromLocationName_promise_test_001', 0, async function (done) {
+ console.info('LBS enableLocation promise test start ...');
+ await geolocation.enableLocation().then((result) => {
+ console.info('[lbs_js] testenableLocation result: ' + result);
+ expect(result).assertTrue();
+ console.info("[lbs_js] enableLocation promise.");
+ }).catch((error) => {
+ console.info("[lbs_js] promise then error." + error.message);
+ expect().assertFail();
+ });
+
+ console.info('LBS getAddressesFromLocationName promise test start ...');
+ var geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 1};
+ await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => {
+ console.info("[lbs_js] getAddressesFromLocation callback data is:"
+ + JSON.stringify(result));
+ expect(true).assertEqual((JSON.stringify(result)) !=null);
+ console.info("[lbs_js] getAddressesFromLocationName promise.");
+ }).catch((error) => {
+ console.info("[lbs_js] getAddressesFromLocationName promise then error." + error);
+ expect().assertFail();
+ });
+ done();
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_REQUEST_ENABLE_LOCATION_CALLBACK_0001
+ * @tc.name testrequestEnableLocation callback
+ * @tc.desc Test requestEnableLocation api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_requestEnableLocation_callback_test_001', 0, async function (done) {
+ console.info('LBS requestEnableLocation callback test start ...');
+ geolocation.requestEnableLocation((err, data) => {
+ if (err) {
+ console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
+ }else {
+ console.info("[lbs_js] requestEnableLocation callback data: " + data);
+ expect(data).assertTrue();
+ console.info("[lbs_js] requestEnableLocation callback exit .");
+ }
+ done();
+ });
+ })
+
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_REQUEST_ENABLE_LOCATION_PROMISE_0001
+ * @tc.name testrequestEnableLocation promise
+ * @tc.desc Test requestEnableLocation api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_requestEnableLocation_promise_test_001', 0, async function (done) {
+ console.info('LBS requestEnableLocation promise test start ...');
+ await geolocation.requestEnableLocation().then((result) => {
+ console.info('[lbs_js] requestEnableLocation result: ' + result);
+ expect(result).assertTrue();
+ console.info("[lbs_js] requestEnableLocation promise.");
+ }).catch((error) => {
+ console.info("[lbs_js] promise then error." + error.message);
+ expect().assertFail();
+ });
+ done()
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_ENABLE_LOCATION_CALLBACK_0001
+ * @tc.name testEnableLocation callback
+ * @tc.desc Test enableLocation api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_enableLocation_callback_test_001', 0, async function (done) {
+ console.info('LBS enableLocation callback test start ...');
+ geolocation.enableLocation((err, data) => {
+ if (err) {
+ console.info('[lbs_js] enableLocation callback err is : ' + err );
+ }else {
+ console.info("[lbs_js] enableLocation callback data: " + data);
+ expect(data).assertTrue();
+ console.info("[lbs_js] enableLocation callback exit .");
+ }
+ done()
+ });
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_DISABLE_LOCATION_CALLBACK_0001
+ * @tc.name testdisableLocation callback
+ * @tc.desc Test disableLocation api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_disableLocation_callback_test_001', 0, async function (done) {
+ console.info('LBS disableLocation callback test start ...');
+ geolocation.disableLocation((err, data) => {
+ if (err) {
+ console.info('[lbs_js] disableLocation callback err is : ' + err );
+ }else {
+ console.info("[lbs_js] disableLocation callback data: " + data);
+ expect(data).assertTrue();
+ console.info("[lbs_js] disableLocation callback exit .");
+ }
+ done()
+ });
+ })
+
+ /** @tc.number SUB_LOCATION_geocode_DEVICE_JS_DISABLE_LOCATION_PROMISE_0001
+ * @tc.name testdisableLocation promise
+ * @tc.desc Test disableLocation api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_disableLocation_promise_test_001', 0, async function (done) {
+ console.info('[lbs_js]LBS disableLocation promise test start ...');
+ geolocation.disableLocation().then((data) => {
+ console.info('[lbs_js] disableLocation data: ' + data);
+ expect(data).assertTrue();
+ console.info("[lbs_js] disableLocation promise exit");
+ done();
+ });
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_ADDR_FROM_LOCATION_PROMISE_0001
+ * @tc.name testgetAddressesFromLocation promise
+ * @tc.desc Test getAddressesFromLocation api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_getAddressesFromLocation_promise_test_001', 0, async function (done) {
+ console.info('LBS getAddressesFromLocation promise test start ...');
+ var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1};
+ await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => {
+ console.info('[lbs_js] getAddressesFromLocation promise: ' + JSON.stringify(data));
+ expect(true).assertEqual((JSON.stringify(data)) !=null);
+ console.info("[lbs_js] getAddressesFromLocation promise exit.");
+ done();
+ }).catch(error => {
+ console.info("[lbs_js] getAddressesFromLocation promise then error." + error.message);
+ expect().assertFail();
+ done();
+ });
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_GET_CURRENT_LOCATION_CALLBACK_0001
+ * @tc.name testGetCurrentlocation callback
+ * @tc.desc Test GetCurrentlocation api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_GetCurrentlocation_callback_test_001', 0, async function(done) {
+ var locationEventListener = new LocationEventListener();
+ var requestInfo = { "priority": 0x0203, "scenario": 0x0300, "timeInterval": 5
+ , "distanceInterval": 0, "maxAccuracy": 0 };
+ locationEventListener.getCurrentLocation(requestInfo, result => {
+ console.info("getCurrentLocation callback, result: " + JSON.stringify(result));
+ expect(true).assertEqual(result != null);
+ done()
+ });
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_IS_GEOSERVICE_AVAIL_CALLBACK_0001
+ * @tc.name testisGeoServiceAvailable callback
+ * @tc.desc Test isGeoServiceAvailable api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_isGeoServiceAvailable_callback_test_001', 0, async function (done) {
+ console.info('LBS enableLocation callback test start ...');
+ let promiseOne = new Promise((resolve, reject) => {
+ geolocation.enableLocation((err, data) => {
+ if (err) {
+ console.info('[lbs_js] enableLocation callback err is : ' + err );
+ }else {
+ console.info("[lbs_js] enableLocation callback data: " + data);
+ expect(data).assertTrue();
+ console.info("[lbs_js] enableLocation callback exit .");
+ }
+ resolve()
+ });
+ })
+ console.info('LBS getGeoServiceState callback test start ...')
+ let promiseTwo = new Promise((resolve, reject) => {
+ geolocation.isGeoServiceAvailable((err, data) => {
+ if (err) {
+ console.info('[lbs_js] getGeoServiceState err is : ' + err );
+ }else {
+ console.info('[lbs_js] isGeoServiceAvailable result: ' + data);
+ expect(data).assertTrue();
+ console.info("[lbs_js] getGeoServiceState callback exit .");
+ }
+ resolve()
+ });
+ })
+ await promiseOne.then(()=>{
+ return promiseTwo
+ }).then(done)
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_CHANGE_ON_0002
+ * @tc.name testlocationChangeOn promise
+ * @tc.desc Test locationChangeOn api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_locationChange_On_test_002', 0, async function (done) {
+ var locationEventListener = new LocationEventListener();
+ console.info('LBS locationChange_On callback test start ...');
+ var requestInfo = {"priority":0x0203, "scenario":0x0300, "timeInterval":5,
+ "distanceInterval": 0, "maxAccuracy": 0};
+ await locationEventListener.on('locationChange',requestInfo, result => {
+ console.info("onLocationChange callback, result: " + JSON.stringify(result));
+ expect(true).assertEqual(result !=null);
+ done();
+ });
+ console.info('LBS enableLocation callback test start ...');
+ geolocation.enableLocation((err, data) => {
+ if (err) {
+ console.info('[lbs_js] enableLocation callback err is : ' + err );
+ }else {
+ console.info("[lbs_js] enableLocation callback data: " + data);
+ expect(data).assertTrue();
+ console.info("[lbs_js] enableLocation callback exit .");
+ }
+ done()
+ });
+
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_ON_LOCATION_SERVICE_STATE_0001
+ * @tc.name testOnLocationServiceState
+ * @tc.desc Test OnLocationServiceState api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_OnLocationServiceState_test_001', 0, async function (done) {
+ var locationEventListener = new LocationEventListener();
+ console.info('LBS OnLocationServiceState test start ...');
+ await locationEventListener.on('locationServiceState', result => {
+ console.info("onlocationServiceState callback, result: " + JSON.stringify(result));
+ expect(true).assertEqual(result !=null);
+ done();
+ });
+ console.info('LBS enableLocation callback test start ...');
+ geolocation.enableLocation((err, data) => {
+ if (err) {
+ console.info('[lbs_js] enableLocation callback err is : ' + err );
+ }else {
+ console.info("[lbs_js] enableLocation callback data: " + data);
+ expect(data).assertTrue();
+ console.info("[lbs_js] enableLocation callback exit .");
+ }
+ done()
+ });
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_ON_LOCATION_SERVICE_STATE_0001
+ * @tc.name testOnLocationServiceState
+ * @tc.desc Test offLocationServiceState api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_offLocationServiceState_test_001', 0, async function (done) {
+ var locationEventListener = new LocationEventListener();
+ console.info('LBS OnLocationServiceState test start ...');
+ await locationEventListener.on('locationServiceState', result => {
+ console.info("onlocationServiceState callback, result:" + JSON.stringify(result));
+ expect(true).assertEqual(result !=null);
+ done();
+ });
+ console.info('LBS enableLocation callback test start ...');
+ geolocation.enableLocation((err, data) => {
+ if (err) {
+ console.info('[lbs_js] enableLocation callback err is : ' + err );
+ }else {
+ console.info("[lbs_js] enableLocation callback data: " + data);
+ expect(data).assertTrue();
+ console.info("[lbs_js] enableLocation callback exit .");
+ }
+ done()
+ });
+
+ console.info('LBS disableLocation callback test start ...');
+ geolocation.disableLocation((err, data) => {
+ if (err) {
+ console.info('[lbs_js] disableLocation callback err is : ' + err );
+ }else {
+ console.info("[lbs_js] disableLocation callback data: " + data);
+ expect(data).assertTrue();
+ console.info("[lbs_js] disableLocation callback exit .");
+ }
+ done()
+ });
+
+ console.info('LBS offLocationServiceState test start ...');
+ locationEventListener.off('locationServiceState', result => {
+ console.info("offlocationServiceState callback, result: " + JSON.stringify(result));
+ expect(true).assertEqual(result !=null);
+ done();
+ });
+ })
+
+ /**
+ * @tc.number SUB_LOCATION_geocode_DEVICE_JS_LOCATION_SERVICE_OFF_0002
+ * @tc.name testlocationChangeOff promise
+ * @tc.desc Test locationChangeoff api .
+ * @tc.author wangsilu wwx1075324
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('geolocation_locationChange_Off_test_002', 0, async function(done) {
+ var locationEventListener = new LocationEventListener();
+ console.info('LBS locationChange_On callback test start ...');
+ var requestInfo = {"priority":0x0203, "scenario":0x0300, "timeInterval":5
+ , "distanceInterval": 0, "maxAccuracy": 0};
+ locationEventListener.on('locationChange',requestInfo, result => {
+ console.info("onLocationChange callback, result: " + JSON.stringify(result));
+ expect(true).assertEqual(result !=null);
+ done();
+ });
+
+ console.info('LBS enableLocation callback test start ...');
+ geolocation.enableLocation((err, data) => {
+ if (err) {
+ console.info('[lbs_js] enableLocation callback err is : ' + err );
+ }else {
+ console.info("[lbs_js] enableLocation callback data: " + data);
+ expect(data).assertTrue();
+ console.info("[lbs_js] enableLocation callback exit .");
+ }
+ done()
+ });
+
+ console.info('LBS disableLocation callback test start ...');
+ geolocation.disableLocation((err, data) => {
+ if (err) {
+ console.info('[lbs_js] disableLocation callback err is : ' + err );
+ }else {
+ console.info("[lbs_js] disableLocation callback data: " + data);
+ expect(data).assertTrue();
+ console.info("[lbs_js] disableLocation callback exit .");
+ }
+ done()
+ });
+
+ console.info('LBS locationChange_Off test2 start ...');
+ locationEventListener.off('locationChange', result => {
+ console.info("[lbs_js] offlocationChange callback result " + JSON.stringify(result));
+ expect(true).assertEqual(result != null);
+ done();
+ });
+ })
+})
+
diff --git a/location/geolocation_standard/src/main/js/default/test/List.test.js b/location/geolocation_standard/src/main/js/default/test/List.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..5a8288b002a90bf3f4f009c7dc9ea09530155779
--- /dev/null
+++ b/location/geolocation_standard/src/main/js/default/test/List.test.js
@@ -0,0 +1,16 @@
+/*
+ * 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.
+ */
+
+require('./Geolocation.test.js')
diff --git a/location/geolocation_standard/src/main/resources/base/element/string.json b/location/geolocation_standard/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..14f9c3a9210f78b12caf3b945dc2b2c0f63f7d3d
--- /dev/null
+++ b/location/geolocation_standard/src/main/resources/base/element/string.json
@@ -0,0 +1,12 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "OsAccountTest"
+ },
+ {
+ "name": "mainability_description",
+ "value": "JS_Phone_Empty Feature Ability"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/location/geolocation_standard/src/main/resources/base/media/icon.png b/location/geolocation_standard/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/location/geolocation_standard/src/main/resources/base/media/icon.png differ
diff --git a/test_packages.gni b/test_packages.gni
index 42e85ce5666a68839e59c75585aa700fcc5b6d4b..9f05960f82fd72127eb5c950c825ec5f65a1b6b4 100644
--- a/test_packages.gni
+++ b/test_packages.gni
@@ -39,6 +39,7 @@ _all_test_packages = [
"${ACTS_ROOT}/resourceschedule:resourceschedule",
"${ACTS_ROOT}/telephony:telephony",
"${ACTS_ROOT}/hiviewdfx:hiviewdfxtestacts",
+ "${ACTS_ROOT}/location:location",
]
_all_test_packages_ivi = [