Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
fe530e18
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
fe530e18
编写于
11月 25, 2022
作者:
O
openharmony_ci
提交者:
Gitee
11月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
!6688 【location】d.ts整改用例适配
Merge pull request !6688 from 权力/myfeature
上级
7d3957e3
39705b4e
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
2602 addition
and
224 deletion
+2602
-224
location/geolocation_standard/src/main/config.json
location/geolocation_standard/src/main/config.json
+129
-118
location/geolocation_standard/src/main/js/default/test/GeocoderMTest.test.js
...n_standard/src/main/js/default/test/GeocoderMTest.test.js
+959
-0
location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js
...on_standard/src/main/js/default/test/GeocoderTest.test.js
+124
-76
location/geolocation_standard/src/main/js/default/test/GetCountryCode.test.js
..._standard/src/main/js/default/test/GetCountryCode.test.js
+3
-7
location/geolocation_standard/src/main/js/default/test/GetCountryCodeM.test.js
...standard/src/main/js/default/test/GetCountryCodeM.test.js
+164
-0
location/geolocation_standard/src/main/js/default/test/List.test.js
...eolocation_standard/src/main/js/default/test/List.test.js
+4
-1
location/geolocation_standard/src/main/js/default/test/LocationMTest.test.js
...n_standard/src/main/js/default/test/LocationMTest.test.js
+1183
-0
location/geolocation_standard/src/main/js/default/test/LocationTest.test.js
...on_standard/src/main/js/default/test/LocationTest.test.js
+34
-21
location/geolocation_standard/src/main/js/default/test/SystemLocation.test.js
..._standard/src/main/js/default/test/SystemLocation.test.js
+2
-1
未找到文件。
location/geolocation_standard/src/main/config.json
浏览文件 @
fe530e18
{
"app"
:
{
"bundleName"
:
"ohos.acts.location.geolocation.function"
,
"vendor"
:
"acts"
,
"version"
:
{
"code"
:
1000000
,
"name"
:
"1.0"
},
"apiVersion"
:
{
"compatible"
:
4
,
"target"
:
5
,
"releaseType"
:
"Beta1"
}
},
"deviceConfig"
:
{},
"module"
:
{
"package"
:
"ohos.acts.location.geolocation.function"
,
"name"
:
".MyApplication"
,
"mainAbility"
:
"ohos.acts.location.geolocation.function.MainAbility"
,
"deviceType"
:
[
{
"app"
:
{
"bundleName"
:
"ohos.acts.location.geolocation.function"
,
"vendor"
:
"acts"
,
"version"
:
{
"code"
:
1000000
,
"name"
:
"1.0"
},
"apiVersion"
:
{
"compatible"
:
4
,
"target"
:
5
,
"releaseType"
:
"Beta1"
}
},
"deviceConfig"
:
{},
"module"
:
{
"package"
:
"ohos.acts.location.geolocation.function"
,
"name"
:
".MyApplication"
,
"mainAbility"
:
"ohos.acts.location.geolocation.function.MainAbility"
,
"deviceType"
:
[
"tablet"
,
"default"
,
"phone"
],
"distro"
:
{
"deliveryWithInstall"
:
true
,
"moduleName"
:
"entry"
,
"moduleType"
:
"entry"
},
"abilities"
:
[
{
"skills"
:
[
{
"entities"
:
[
"entity.system.home"
],
"actions"
:
[
"action.system.home"
]
}
],
"visible"
:
true
,
"name"
:
"ohos.acts.location.geolocation.function.MainAbility"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:mainability_description"
,
"label"
:
"$string:app_name"
,
"type"
:
"page"
,
"launchType"
:
"standard"
}
],
"reqPermissions"
:
[
{
"name"
:
"ohos.permission.LOCATION"
,
"reason"
:
"need use ohos.permission.LOCATION"
,
"usedScene"
:
{
"ability"
:
[
"ohos.acts.location.geolocation.function.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.ACCESS_LOCATION"
,
"reason"
:
"need use ohos.permission.ACCESS_LOCATION"
,
"usedScene"
:
{
"ability"
:
[
"ohos.acts.location.geolocation.function.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.LOCATION_IN_BACKGROUND"
,
"reason"
:
"need use ohos.permission.LOCATION_IN_BACKGROUND"
,
"usedScene"
:
{
"ability"
:
[
"ohos.acts.location.geolocation.function.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.MANAGE_SECURE_SETTINGS"
,
"reason"
:
"need use ohos.permission.MANAGE_SECURE_SETTINGS"
,
"usedScene"
:
{
"ability"
:
[
"ohos.acts.location.geolocation.function.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
,
"reason"
:
"use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name"
:
"ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
,
"reason"
:
"use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
},
{
"name"
:
"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name"
:
"ohos.permission.GET_BUNDLE_INFO"
}
],
"js"
:
[
{
"pages"
:
[
"pages/index/index"
],
"name"
:
"default"
,
"window"
:
{
"designWidth"
:
720
,
"autoDesignWidth"
:
false
}
}
]
}
}
"phone"
],
"distro"
:
{
"deliveryWithInstall"
:
true
,
"moduleName"
:
"entry"
,
"moduleType"
:
"entry"
},
"abilities"
:
[
{
"skills"
:
[
{
"entities"
:
[
"entity.system.home"
],
"actions"
:
[
"action.system.home"
]
}
],
"visible"
:
true
,
"name"
:
"ohos.acts.location.geolocation.function.MainAbility"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:mainability_description"
,
"label"
:
"$string:app_name"
,
"type"
:
"page"
,
"launchType"
:
"standard"
}
],
"reqPermissions"
:
[
{
"name"
:
"ohos.permission.LOCATION"
,
"reason"
:
"need use ohos.permission.LOCATION"
,
"usedScene"
:
{
"ability"
:
[
"ohos.acts.location.geolocation.function.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.ACCESS_LOCATION"
,
"reason"
:
"need use ohos.permission.ACCESS_LOCATION"
,
"usedScene"
:
{
"ability"
:
[
"ohos.acts.location.geolocation.function.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.APPROXIMATELY_LOCATION"
,
"reason"
:
"need use ohos.permission.APPROXIMATELY_LOCATION"
,
"usedScene"
:
{
"ability"
:
[
"ohos.acts.location.geolocation.function.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.LOCATION_IN_BACKGROUND"
,
"reason"
:
"need use ohos.permission.LOCATION_IN_BACKGROUND"
,
"usedScene"
:
{
"ability"
:
[
"ohos.acts.location.geolocation.function.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.MANAGE_SECURE_SETTINGS"
,
"reason"
:
"need use ohos.permission.MANAGE_SECURE_SETTINGS"
,
"usedScene"
:
{
"ability"
:
[
"ohos.acts.location.geolocation.function.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
,
"reason"
:
"use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name"
:
"ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
,
"reason"
:
"use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
},
{
"name"
:
"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name"
:
"ohos.permission.GET_BUNDLE_INFO"
}
],
"js"
:
[
{
"pages"
:
[
"pages/index/index"
],
"name"
:
"default"
,
"window"
:
{
"designWidth"
:
720
,
"autoDesignWidth"
:
false
}
}
]
}
}
location/geolocation_standard/src/main/js/default/test/GeocoderMTest.test.js
0 → 100644
浏览文件 @
fe530e18
此差异已折叠。
点击以展开。
location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js
浏览文件 @
fe530e18
...
...
@@ -119,7 +119,7 @@ describe('geolocationTest_geo1', function () {
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
data
)
!=
null
);
done
();
}
done
()
done
()
;
})
});
...
...
@@ -132,14 +132,18 @@ describe('geolocationTest_geo1', function () {
* @tc.level Level 2
*/
it
(
'
SUB_HSS_LocationSystem_Geo_0200
'
,
0
,
async
function
(
done
)
{
await
geolocation
.
isGeoServiceAvailable
().
then
((
result
)
=>
{
console
.
info
(
'
[lbs_js] isGeoServiceAvailable1 promise result:
'
+
JSON
.
stringify
(
result
));
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
result
)
!=
null
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
try
{
await
geolocation
.
isGeoServiceAvailable
().
then
((
result
)
=>
{
console
.
info
(
'
[lbs_js] isGeoServiceAvailable promise result:
'
+
JSON
.
stringify
(
result
));
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
result
)
!=
null
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
}
catch
(
error
)
{
console
.
info
(
"
[lbs_js] isGeoServiceAvailable error.
"
+
JSON
.
stringify
(
error
));
}
done
();
})
...
...
@@ -161,7 +165,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js] getAddressesFromLocation callback data is:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
}
resolve
()
resolve
()
;
});
})
await
promise
.
then
(
done
)
...
...
@@ -231,40 +235,63 @@ describe('geolocationTest_geo1', function () {
*/
it
(
'
SUB_HSS_LocationSystem_Geo_0600
'
,
0
,
async
function
(
done
)
{
let
reverseGeocodeRequest1
=
{
"
latitude
"
:
90
,
"
longitude
"
:
121.62771
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest1
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0601 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0601 promise then error.
"
+
JSON
.
stringify
(
error
));
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
try
{
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest1
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0601 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0601 promise then error.
"
+
JSON
.
stringify
(
error
));
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
console
.
info
(
'
[lbs_js] not support now
'
);
});
}
catch
(
error
)
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation message.
"
+
JSON
.
stringify
(
error
.
message
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
.
message
))
!=
null
);
}
let
reverseGeocodeRequest2
=
{
"
latitude
"
:
90.1
,
"
longitude
"
:
121.62771
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest2
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation promise:
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
length
).
assertEqual
(
0
);
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0602 promise then error.
"
+
JSON
.
stringify
(
error
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
try
{
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest2
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation promise:
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
length
).
assertEqual
(
0
);
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0602 promise then error.
"
+
JSON
.
stringify
(
error
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
}
catch
(
error
)
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation message.
"
+
JSON
.
stringify
(
error
.
message
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
.
message
))
!=
null
);
}
let
reverseGeocodeRequest3
=
{
"
latitude
"
:
-
90
,
"
longitude
"
:
121.62771
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest3
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0603 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0603 promise then error.
"
+
JSON
.
stringify
(
error
));
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
try
{
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest3
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0603 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0603 promise then error.
"
+
JSON
.
stringify
(
error
));
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
}
catch
(
error
)
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation message.
"
+
JSON
.
stringify
(
error
.
message
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
.
message
))
!=
null
);
}
let
reverseGeocodeRequest4
=
{
"
latitude
"
:
-
90.1
,
"
longitude
"
:
121.62771
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest4
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0604 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
length
).
assertEqual
(
0
);
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0604 promise then error.
"
+
JSON
.
stringify
(
error
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
done
()
try
{
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest4
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0604 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
length
).
assertEqual
(
0
);
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0604 promise then error.
"
+
JSON
.
stringify
(
error
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
}
catch
(
error
)
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation message.
"
+
JSON
.
stringify
(
error
.
message
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
.
message
))
!=
null
);
}
done
();
})
/**
...
...
@@ -277,40 +304,60 @@ describe('geolocationTest_geo1', function () {
*/
it
(
'
SUB_HSS_LocationSystem_Geo_0700
'
,
0
,
async
function
(
done
)
{
let
reverseGeocodeRequest
=
{
"
latitude
"
:
31.265496
,
"
longitude
"
:
180
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0701 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0701 promise then error.
"
+
JSON
.
stringify
(
error
));
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
try
{
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0701 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0701 promise then error.
"
+
JSON
.
stringify
(
error
));
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
}
catch
(
error
)
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation message.
"
+
JSON
.
stringify
(
error
.
message
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
.
message
))
!=
null
);
}
let
reverseGeocodeRequest1
=
{
"
latitude
"
:
31.265496
,
"
longitude
"
:
-
180.1
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest1
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0702 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
length
).
assertEqual
(
0
);
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0702 promise then error.
"
+
JSON
.
stringify
(
error
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
try
{
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest1
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0702 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
length
).
assertEqual
(
0
);
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0702 promise then error.
"
+
JSON
.
stringify
(
error
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
}
catch
(
error
)
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation message.
"
+
JSON
.
stringify
(
error
.
message
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
.
message
))
!=
null
);
}
let
reverseGeocodeRequest2
=
{
"
latitude
"
:
31.265496
,
"
longitude
"
:
180
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest2
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0703 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0703 promise then error.
"
+
JSON
.
stringify
(
error
));
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
try
{
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest2
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0703 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
data
))
!=
null
);
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0703 promise then error.
"
+
JSON
.
stringify
(
error
));
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
}
catch
(
error
)
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation message.
"
+
JSON
.
stringify
(
error
.
message
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
.
message
))
!=
null
);
}
let
reverseGeocodeRequest3
=
{
"
latitude
"
:
31.265496
,
"
longitude
"
:
180.1
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest3
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0704 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
length
).
assertEqual
(
0
);
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0704 promise then error.
"
+
JSON
.
stringify
(
error
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
done
()
try
{
await
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest3
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation0704 promise:
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
length
).
assertEqual
(
0
);
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation0704 promise then error.
"
+
JSON
.
stringify
(
error
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
))
!=
null
);
});
}
catch
(
error
)
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation message.
"
+
JSON
.
stringify
(
error
.
message
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
.
message
))
!=
null
);
}
done
();
})
/**
...
...
@@ -429,7 +476,6 @@ describe('geolocationTest_geo1', function () {
*/
it
(
'
SUB_HSS_LocationSystem_Geo_1100
'
,
0
,
async
function
(
done
)
{
try
{
let
geocodeRequest
=
{
"
description
"
:
""
,
"
maxItems
"
:
1
};
await
geolocation
.
getAddressesFromLocationName
(
geocodeRequest
).
then
((
result
)
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation promise data is:
"
+
JSON
.
stringify
(
result
));
...
...
@@ -566,7 +612,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
done
()
done
()
;
})
/**
...
...
@@ -595,7 +641,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
});
done
()
done
()
;
})
/**
...
...
@@ -772,7 +818,7 @@ describe('geolocationTest_geo1', function () {
console
.
info
(
"
[lbs_js] getAddressesFromLocationName message.
"
+
JSON
.
stringify
(
error
.
message
));
expect
(
true
).
assertEqual
((
JSON
.
stringify
(
error
.
message
))
!=
null
);
}
done
()
done
()
;
})
/**
...
...
@@ -949,3 +995,5 @@ describe('geolocationTest_geo1', function () {
})
})
location/geolocation_standard/src/main/js/default/test/GetCountryCode.test.js
浏览文件 @
fe530e18
...
...
@@ -14,7 +14,6 @@
*/
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
geolocations
from
'
@system.geolocation
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
osaccount
from
'
@ohos.account.osAccount
'
...
...
@@ -120,7 +119,7 @@ describe('geolocationTest_4', function () {
* @tc.type Function
* @tc.level since 9
*/
it
(
'
SUB_HSS_LocationSystem_CountryCode_0200
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_HSS_LocationSystem_CountryCode_0200
'
,
0
,
async
function
(
done
)
{
function
getCountryCodeCallback
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
geolocationm
.
getCountryCode
((
err
,
data
)
=>
{
...
...
@@ -128,7 +127,7 @@ describe('geolocationTest_4', function () {
return
console
.
info
(
"
getCountryCode callback err:
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
getCountryCode callback success
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
!=
null
);
expect
(
true
).
assertEqual
(
data
!=
null
);
}
resolve
();
})
...
...
@@ -146,7 +145,7 @@ describe('geolocationTest_4', function () {
* @tc.level since 9
*/
it
(
'
SUB_HSS_LocationSystem_CountryCode_0300
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[lbs_js]countryCodeChange
"
);
console
.
info
(
"
[lbs_js]
countryCodeChange
"
);
geolocationm
.
on
(
'
countryCodeChange
'
,
function
(
data
)
{
console
.
info
(
'
[lbs_js] countryCodeChange
'
+
JSON
.
stringify
(
data
)
);
});
...
...
@@ -165,6 +164,3 @@ describe('geolocationTest_4', function () {
})
})
location/geolocation_standard/src/main/js/default/test/GetCountryCodeM.test.js
0 → 100644
浏览文件 @
fe530e18
/*
* Copyright (C) 2022 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
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
function
sleep
(
ms
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
console
.
info
(
'
[lbs_js]sleep function
'
);
}
async
function
changedLocationMode
(){
let
result1
=
geolocationm
.
isLocationEnabled
();
console
.
info
(
'
[lbs_js] getLocationSwitchState result:
'
+
JSON
.
stringify
(
result1
));
if
(
!
result1
){
await
geolocationm
.
requestEnableLocation
().
then
(
async
(
result
)
=>
{
await
sleep
(
3000
);
console
.
info
(
'
[lbs_js] test requestEnableLocation promise result:
'
+
JSON
.
stringify
(
result
));
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
}
let
result2
=
geolocationm
.
isLocationEnabled
();
console
.
info
(
'
[lbs_js] check LocationSwitchState result:
'
+
JSON
.
stringify
(
result2
));
}
async
function
applyPermission
()
{
let
osAccountManager
=
osaccount
.
getAccountManager
();
console
.
info
(
"
====>testgetuserid get AccountManager finish====
"
);
let
localId
=
await
osAccountManager
.
getOsAccountLocalIdFromProcess
();
console
.
info
(
"
====>testgetuserid localId obtained by process:
"
+
localId
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName1
=
'
ohos.permission.LOCATION
'
;
let
permissionName2
=
'
ohos.permission.LOCATION_IN_BACKGROUND
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName2
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
result
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission failed :
'
+
err
);
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
let
CountryCodeType
=
{
COUNTRY_CODE_FROM_LOCALE
:
1
,
COUNTRY_CODE_FROM_SIM
:
2
,
COUNTRY_CODE_FROM_LOCATION
:
3
,
COUNTRY_CODE_FROM_NETWORK
:
4
,
}
describe
(
'
geolocationTest_6
'
,
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll case
'
);
await
applyPermission
();
done
();
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach case
'
);
await
changedLocationMode
();
done
();
})
/**
* @tc.number SUB_HSS_LocationSystem_CountryCode_0400
* @tc.name Test getCountryCode
* @tc.desc Obtaining Country Code Information
* @tc.type Function
* @tc.level since 9
*/
it
(
'
SUB_HSS_LocationSystem_CountryCode_0400
'
,
0
,
async
function
(
done
)
{
await
geolocationm
.
getCountryCode
().
then
((
result
)
=>
{
console
.
info
(
"
[lbs_js] getCountryCode promise result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[lbs_js] country :
"
+
result
.
country
);
console
.
info
(
"
[lbs_js] type:
"
+
result
.
type
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
result
)
==
CountryCodeType
.
COUNTRY_CODE_FROM_LOCALE
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
result
)
!=
CountryCodeType
.
COUNTRY_CODE_FROM_SIM
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
result
)
!=
CountryCodeType
.
COUNTRY_CODE_FROM_LOCATION
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
result
)
!=
CountryCodeType
.
COUNTRY_CODE_FROM_NETWORK
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getCountryCode promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
done
();
})
/**
* @tc.number SUB_HSS_LocationSystem_CountryCode_0500
* @tc.name Test getCountryCode
* @tc.desc Obtaining Country Code Information
* @tc.type Function
* @tc.level since 9
*/
it
(
'
SUB_HSS_LocationSystem_CountryCode_0500
'
,
0
,
async
function
(
done
)
{
function
getCountryCodeCallback
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
geolocationm
.
getCountryCode
((
err
,
data
)
=>
{
if
(
err
)
{
return
console
.
info
(
"
[lbs_js] getCountryCode callback err:
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
[lbs_js] getCountryCode callback success
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
!=
null
);
}
resolve
();
})
})
}
await
getCountryCodeCallback
();
done
();
})
/**
* @tc.number SUB_HSS_LocationSystem_CountryCode_0600
* @tc.name getCountryCode_on_off
* @tc.desc The interception country code is changed.
* @tc.type Function
* @tc.level since 9
*/
it
(
'
SUB_HSS_LocationSystem_CountryCode_0600
'
,
0
,
async
function
(
done
)
{
console
.
info
(
"
[lbs_js] countryCodeChange
"
);
geolocationm
.
on
(
'
countryCodeChange
'
,
function
(
data
)
{
console
.
info
(
'
[lbs_js] countryCodeChange
'
+
JSON
.
stringify
(
data
)
);
});
await
geolocationm
.
getCountryCode
().
then
((
result
)
=>
{
console
.
info
(
"
[lbs_js] getCountryCode promise result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
result
)
!=
null
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] getCountryCode promise then error.
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
});
geolocationm
.
off
(
'
countryCodeChange
'
,
function
(
data
)
{
console
.
info
(
'
[lbs_js] countryCodeChange
'
+
JSON
.
stringify
(
data
));
done
();
})
done
();
})
})
location/geolocation_standard/src/main/js/default/test/List.test.js
浏览文件 @
fe530e18
...
...
@@ -14,6 +14,9 @@
*/
require
(
'
./GeocoderTest.test.js
'
)
require
(
'
./GeocoderMTest.test.js
'
)
require
(
'
./GetCountryCode.test.js
'
)
require
(
'
./
SystemLocation
.test.js
'
)
require
(
'
./
GetCountryCodeM
.test.js
'
)
require
(
'
./LocationTest.test.js
'
)
require
(
'
./LocationMTest.test.js
'
)
require
(
'
./SystemLocation.test.js
'
)
location/geolocation_standard/src/main/js/default/test/LocationMTest.test.js
0 → 100644
浏览文件 @
fe530e18
此差异已折叠。
点击以展开。
location/geolocation_standard/src/main/js/default/test/LocationTest.test.js
浏览文件 @
fe530e18
...
...
@@ -127,12 +127,12 @@ describe('geolocationTest_geo3', function () {
console
.
info
(
"
[lbs_js] getLocationSwitchState callback data:
"
+
JSON
.
stringify
(
data
));
expect
(
data
).
assertTrue
();
}
done
()
})
done
();
});
/**
* @tc.number LocSwitch_0400
* @tc.number
SUB_HSS_LocationSystem_
LocSwitch_0400
* @tc.name Test requestrequestEnableLocation api.
* @tc.desc Enabling the Location Service Function for a Third-Party Application -Promise Mode
* @tc.size MEDIUM
...
...
@@ -164,7 +164,7 @@ describe('geolocationTest_geo3', function () {
}
geolocation
.
on
(
'
locationServiceState
'
,
locationServiceState
);
geolocation
.
off
(
'
locationServiceState
'
,
locationServiceState
);
expect
(
true
).
assertTrue
();
expect
(
true
).
assertTrue
();
done
();
})
...
...
@@ -193,7 +193,7 @@ describe('geolocationTest_geo3', function () {
});
})
}
console
.
info
(
'
getCurrentLocationCallback
start
'
);
console
.
info
(
'
getCurrentLocationCallback start
'
);
await
geolocation
.
getCurrentLocation
(
currentLocationRequest
).
then
((
result
)
=>
{
console
.
info
(
"
getCurrentLocation callback_0003, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
...
...
@@ -493,11 +493,9 @@ describe('geolocationTest_geo3', function () {
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
done
();
})
done
()
done
()
;
})
/**
* @tc.number SUB_HSS_SendCommand_0100
* @tc.name Test sendCommand
...
...
@@ -508,14 +506,20 @@ describe('geolocationTest_geo3', function () {
*/
it
(
'
SUB_HSS_SendCommand_0100
'
,
0
,
async
function
(
done
)
{
let
requestInfo
=
{
'
scenairo
'
:
0x301
,
'
command
'
:
"
command_1
"
};
await
geolocation
.
sendCommand
(
requestInfo
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
info
(
'
sendcommand callback err:
'
+
JSON
.
stringify
(
err
));
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
err
)
!=
null
);
done
();
}
console
.
info
(
'
sendcommand callback result:
'
+
JSON
.
stringify
(
result
));
});
try
{
await
geolocation
.
sendCommand
(
requestInfo
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
info
(
'
sendcommand callback err:
'
+
JSON
.
stringify
(
err
));
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
err
)
!=
null
);
done
();
}
console
.
info
(
'
sendcommand callback result:
'
+
JSON
.
stringify
(
result
));
});
}
catch
(
error
)
{
console
.
info
(
'
sendcommand callback err:
'
+
JSON
.
stringify
(
error
));
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
}
done
();
})
/**
...
...
@@ -528,14 +532,21 @@ describe('geolocationTest_geo3', function () {
*/
it
(
'
SUB_HSS_SendCommand_0200
'
,
0
,
async
function
(
done
)
{
let
requestInfo
=
{
'
scenairo
'
:
0x301
,
'
command
'
:
"
command_1
"
};
geolocation
.
sendCommand
(
requestInfo
).
then
((
result
)
=>
{
console
.
info
(
'
sendCommand promise result:
'
+
result
);
done
();
}).
catch
(
error
=>
{
try
{
geolocation
.
sendCommand
(
requestInfo
).
then
((
result
)
=>
{
console
.
info
(
'
sendCommand promise result:
'
+
result
);
done
();
}).
catch
(
error
=>
{
console
.
info
(
'
sendcommand promise err:
'
+
JSON
.
stringify
(
error
));
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
done
();
})
}
catch
(
error
)
{
console
.
info
(
'
sendcommand promise err:
'
+
JSON
.
stringify
(
error
));
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
error
)
!=
null
);
done
();
})
}
done
();
})
/**
...
...
@@ -1249,3 +1260,5 @@ describe('geolocationTest_geo3', function () {
})
})
location/geolocation_standard/src/main/js/default/test/SystemLocation.test.js
浏览文件 @
fe530e18
...
...
@@ -146,7 +146,7 @@ describe('geolocationTest_geo2', function () {
expect
().
assertFail
();
},
});
geolocation
.
unsubscribe
();
geolocation
s
.
unsubscribe
();
console
.
info
(
"
[lbs_js] unsubscribe called
"
)
done
();
})
...
...
@@ -196,3 +196,4 @@ describe('geolocationTest_geo2', function () {
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录