Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
eb6baccb
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看板
未验证
提交
eb6baccb
编写于
5月 11, 2022
作者:
O
openharmony_ci
提交者:
Gitee
5月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3159 【communication】系统权限修改
Merge pull request !3159 from 权力/master
上级
f2fa1911
3235ed3f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
239 addition
and
50 deletion
+239
-50
communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js
...tooth_standard/src/main/js/default/test/Bluetooth.test.js
+3
-4
communication/wifi_standard/src/main/js/default/test/WifiSta.test.js
...on/wifi_standard/src/main/js/default/test/WifiSta.test.js
+27
-46
location/geolocation_standard/src/main/js/default/test/Geolocation.test.js
...ion_standard/src/main/js/default/test/Geolocation.test.js
+208
-0
location/geolocation_standard/src/main/js/default/test/List.test.js
...eolocation_standard/src/main/js/default/test/List.test.js
+1
-0
未找到文件。
communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js
浏览文件 @
eb6baccb
...
@@ -429,10 +429,9 @@ describe('bluetoothhostTest', function() {
...
@@ -429,10 +429,9 @@ describe('bluetoothhostTest', function() {
*/
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0001
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0001
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
await
tryToEnableBt
();
let
state
=
bluetooth
.
getState
();
let
name
=
bluetooth
.
getLocalName
();
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
bluetooth
.
BluetoothState
.
STATE_ON
)
==
state
);
let
set
=
bluetooth
.
setLocalName
(
''
);
let
name
=
bluetooth
.
setLocalName
(
''
);
expect
(
set
).
assertFalse
();
expect
(
name
).
assertFalse
();
let
localName
=
bluetooth
.
getLocalName
();
let
localName
=
bluetooth
.
getLocalName
();
expect
(
true
).
assertTrue
(
localName
==
name
);
expect
(
true
).
assertTrue
(
localName
==
name
);
console
.
info
(
'
[bluetooth_js] getLocalName result1 =
'
+
JSON
.
stringify
(
localName
));
console
.
info
(
'
[bluetooth_js] getLocalName result1 =
'
+
JSON
.
stringify
(
localName
));
...
...
communication/wifi_standard/src/main/js/default/test/WifiSta.test.js
浏览文件 @
eb6baccb
...
@@ -34,7 +34,13 @@ function checkWifiPowerOn(){
...
@@ -34,7 +34,13 @@ function checkWifiPowerOn(){
console
.
info
(
"
wifi_test/wifi status:
"
+
wifi
.
isWifiActive
());
console
.
info
(
"
wifi_test/wifi status:
"
+
wifi
.
isWifiActive
());
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
}
}
let
WifiDeviceConfig
=
{
"
ssid
"
:
"
TEST
"
,
"
bssid
"
:
""
,
"
preSharedKey
"
:
""
,
"
isHiddenSsid
"
:
false
,
"
securityType
"
:
WifiSecurityType
.
WIFI_SEC_TYPE_OPEN
,
}
let
ConnState
=
{
let
ConnState
=
{
SCANNING
:
0
,
SCANNING
:
0
,
CONNECTING
:
1
,
CONNECTING
:
1
,
...
@@ -46,13 +52,6 @@ let ConnState = {
...
@@ -46,13 +52,6 @@ let ConnState = {
UNKNOWN
:
7
,
UNKNOWN
:
7
,
}
}
let
ipConfig
=
{
"
ipAddress
"
:
1284752956
,
"
gateway
"
:
17017024
,
"
dnsServers
"
:
12345678
,
"
domains
"
:
[
"
aaa
"
],
}
describe
(
'
ACTS_WifiTest
'
,
function
()
{
describe
(
'
ACTS_WifiTest
'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
checkWifiPowerOn
();
checkWifiPowerOn
();
...
@@ -211,25 +210,7 @@ describe('ACTS_WifiTest', function() {
...
@@ -211,25 +210,7 @@ describe('ACTS_WifiTest', function() {
let
isSupport
=
wifi
.
isFeatureSupported
(
WifiUtils
.
WIFI_FEATURE_OWE
);
let
isSupport
=
wifi
.
isFeatureSupported
(
WifiUtils
.
WIFI_FEATURE_OWE
);
expect
(
isSupport
).
assertFalse
();
expect
(
isSupport
).
assertFalse
();
})
})
/**
* @tc.number SUB_Communication_WiFi_Sta_info_0005
* @tc.name testHotspotDualBandSupported
* @tc.desc Test HotspotDualBandSupported api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_Communication_WiFi_Sta_Info_0005
'
,
0
,
function
()
{
console
.
info
(
"
[wifi_test] isHotspotDualBandSupported start ...
"
);
expect
(
wifi
.
isWifiActive
()).
assertTrue
();
let
DualBand
=
wifi
.
isHotspotDualBandSupported
();
console
.
info
(
"
[wifi_test] isHotspotDualBandSupported ->
"
+
JSON
.
stringify
(
DualBand
));
expect
(
DualBand
).
assertFalse
();
})
/**
/**
* @tc.number conn_Config_0002
* @tc.number conn_Config_0002
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0002
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0002
...
@@ -267,11 +248,11 @@ describe('ACTS_WifiTest', function() {
...
@@ -267,11 +248,11 @@ describe('ACTS_WifiTest', function() {
console
.
info
(
"
[wifi_test] getLinkedInfo callback result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[wifi_test] getLinkedInfo callback result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
ssid:
"
+
result
.
ssid
+
"
bssid:
"
+
result
.
bssid
+
"
band:
"
+
result
.
band
+
console
.
info
(
"
ssid:
"
+
result
.
ssid
+
"
bssid:
"
+
result
.
bssid
+
"
band:
"
+
result
.
band
+
"
isHidden:
"
+
result
.
isHidden
+
"
isRestricted:
"
+
result
.
isRestricted
+
"
isHidden:
"
+
result
.
isHidden
+
"
isRestricted:
"
+
result
.
isRestricted
+
"
chload:
"
+
result
.
chload
+
"
rssi
"
+
result
.
rssi
+
"
netWorkId:
"
+
result
.
netWorkId
+
"
rssi
"
+
result
.
rssi
+
"
linkSpeed:
"
+
result
.
linkSpeed
+
"
frequency:
"
"
linkSpeed:
"
+
result
.
linkSpeed
+
"
frequency:
"
+
result
.
frequency
+
"
snr:
"
+
result
.
snr
+
+
result
.
frequency
+
"
macAddress:
"
+
result
.
macAddress
+
"
ipAddress:
"
+
result
.
ipAddress
+
"
macAddress:
"
+
result
.
macAddress
+
"
ipAddress:
"
+
result
.
ipAddress
+
"
suppState:
"
+
result
.
suppState
+
"
connState:
"
+
result
.
connState
);
"
connState:
"
+
result
.
connState
);
done
();
done
();
});
});
})
})
...
@@ -366,23 +347,23 @@ describe('ACTS_WifiTest', function() {
...
@@ -366,23 +347,23 @@ describe('ACTS_WifiTest', function() {
* @tc.name SUB_Communication_WiFi_Sta_wifiRssiChange_0004
* @tc.name SUB_Communication_WiFi_Sta_wifiRssiChange_0004
* @tc.desc Test wifiRssiChange callback
* @tc.desc Test wifiRssiChange callback
*/
*/
it
(
'
SUB_Communication_WiFi_Sta_wifiRssiChange_0004
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_Communication_WiFi_Sta_wifiRssiChange_0004
'
,
0
,
async
function
(
done
)
{
wifi
.
on
(
'
wifiRssiChange
'
,
async
result
=>
{
wifi
.
on
(
'
wifiRssiChange
'
,
async
result
=>
{
console
.
info
(
"
wifiRssiChange callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
wifiRssiChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
expect
(
true
).
assertEqual
(
result
!=
null
);
let
promise
=
new
Promise
((
resolve
)
=>
{
let
promise
=
new
Promise
((
resolve
)
=>
{
console
.
info
(
'
[wifi_test] offwifiRssiChange test start ...
'
);
console
.
info
(
'
[wifi_test] offwifiRssiChange test start ...
'
);
wifi
.
off
(
'
wifiRssiChange
'
,
result
=>
{
wifi
.
off
(
'
wifiRssiChange
'
,
result
=>
{
console
.
info
(
"
offwifiRssiChange callback, result:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
offwifiRssiChange callback, result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
expect
(
true
).
assertEqual
(
result
!=
null
);
resolve
()
resolve
()
});
});
})
})
await
promise
.
then
(
done
)
await
promise
.
then
(
done
)
});
});
done
();
done
();
})
})
/**
/**
* @tc.number SUB_Communication_WiFi_Hotspot_ON_0001
* @tc.number SUB_Communication_WiFi_Hotspot_ON_0001
...
...
location/geolocation_standard/src/main/js/default/test/Geolocation.test.js
0 → 100644
浏览文件 @
eb6baccb
/*
* 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
geolocation
from
'
@ohos.geolocation
'
;
import
geolocations
from
'
@system.geolocation
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
function
sleep
(
ms
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
}
async
function
changedLocationMode
(){
await
geolocation
.
isLocationEnabled
().
then
(
async
(
result
)
=>
{
console
.
info
(
'
[lbs_js] getLocationSwitchState result:
'
+
result
);
if
(
!
result
){
await
geolocation
.
requestEnableLocation
().
then
(
async
(
result
)
=>
{
await
sleep
(
3000
);
console
.
info
(
'
[lbs_js] test requestEnableLocation promise result:
'
+
result
);
expect
(
result
).
assertTrue
();
}).
catch
((
error
)
=>
{
console
.
info
(
"
[lbs_js] promise then error.
"
+
error
.
message
);
expect
().
assertFail
();
});
}
})
}
async
function
applyPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.location.geolocation.function
'
,
0
,
100
);
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
'
);
}
}
describe
(
'
geolocationTest
'
,
function
()
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll case
'
);
await
applyPermission
();
done
();
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach case
'
);
await
changedLocationMode
();
done
()
})
afterEach
(
function
()
{
})
/**
* @tc.number LocationSystem_0001
* @tc.name SUB_HSS_LocationSystem_0001
* @tc.desc Test getSupportedCoordTypes api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_LocationSystem_0001
'
,
0
,
function
()
{
let
types
=
geolocations
.
getSupportedCoordTypes
();
console
.
info
(
'
[lbs_js] getSupportedCoordTypes result:
'
+
JSON
.
stringify
(
types
));
expect
(
true
).
assertEqual
(
types
.
length
!=
0
);
})
/**
* @tc.number LocationSystem_0002
* @tc.name SUB_HSS_LocationSystem_0002
* @tc.desc Test getLocationType api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_LocationSystem_0002
'
,
0
,
async
function
(
done
)
{
geolocations
.
getLocationType
({
success
:
function
(
data
)
{
console
.
log
(
'
success get location type:
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
.
types
.
length
!=
0
);
done
()
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
fail to get location. code:
'
+
code
+
'
, data:
'
+
JSON
.
stringify
(
data
));
expect
().
assertFail
();
done
()
},
complete
:
function
(
result
)
{
console
.
log
(
'
get location end
'
+
JSON
.
stringify
(
result
));
},
});
})
/**
* @tc.number LocationSystem_0003
* @tc.name SUB_HSS_LocationSystem_0003
* @tc.desc Test getLocation api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_LocationSystem_0003
'
,
0
,
async
function
(
done
)
{
geolocations
.
getLocation
({
timeout
:
30000
,
coordType
:
'
wgs84
'
,
success
:
function
(
geolocationResponse
)
{
console
.
log
(
'
lbs_js [GetLocation-success], result
'
+
JSON
.
stringify
(
geolocationResponse
));
expect
(
true
).
assertEqual
(
geolocationResponse
.
length
!=
0
);
console
.
info
(
'
[lbs_js] getLocation latitude:
'
+
geolocationResponse
.
latitude
+
'
longitude:
'
+
geolocationResponse
.
longitude
+
'
altitude:
'
+
geolocationResponse
.
altitude
+
'
accuracy:
'
+
geolocationResponse
.
accuracy
+
'
time:
'
+
geolocationResponse
.
time
);
},
fail
:
function
(
data
,
code
)
{
switch
(
code
){
case
601
:
console
.
info
(
"
获取定位权限失败/失败原因/用户拒绝:
"
+
err
);
break
;
case
602
:
console
.
info
(
"
权限未声明:
"
+
err
);
break
;
case
800
:
console
.
info
(
"
超时失败原因/网络状况不佳或GPS不可用:
"
+
err
);
break
;
case
801
:
console
.
info
(
"
系统位置开关未打开:
"
+
err
);
break
;
case
802
:
console
.
info
(
"
该次调用结果未返回前接口又被重新调用/该次调用失败返回错误码:
"
+
err
);
break
;
default
:
console
.
log
(
'
lbs_js [GetLocation-fail] data:
'
+
data
+
'
, code:
'
+
code
);
}
},
});
done
();
})
/**
* @tc.number LocationSystem_0004
* @tc.name SUB_HSS_LocationSystem_0004
* @tc.desc Test subscribe api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_LocationSystem_0004
'
,
0
,
async
function
(
done
)
{
geolocations
.
subscribe
({
coordType
:
'
wgs84
'
,
success
:
function
(
data
)
{
console
.
log
(
'
lbs_js [GetLocation-success], result
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
!=
null
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
lbs_js [Subscribe-fail] code:
'
+
code
+
'
, data:
'
+
data
);
expect
().
assertFail
();
},
});
done
();
})
/**
* @tc.number LocationSystem_0005
* @tc.name SUB_HSS_LocationSystem_0005
* @tc.desc Test unsubscribe api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_HSS_LocationSystem_0005
'
,
0
,
async
function
(
done
)
{
geolocation
.
unsubscribe
(
(
result
)
=>
{
if
(
err
){
return
console
.
info
(
"
unsubscribe err:
"
+
err
);
}
console
.
info
(
"
unsubscribe result:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
!=
null
);
});
done
();
})
})
location/geolocation_standard/src/main/js/default/test/List.test.js
浏览文件 @
eb6baccb
...
@@ -15,3 +15,4 @@
...
@@ -15,3 +15,4 @@
require
(
'
./GeocoderTest.test.js
'
)
require
(
'
./GeocoderTest.test.js
'
)
require
(
'
./LocationTest.test.js
'
)
require
(
'
./LocationTest.test.js
'
)
require
(
'
./Geolocation.test.js
'
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录