Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
8155db36
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看板
提交
8155db36
编写于
7月 27, 2022
作者:
Q
quanli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
master--beta2
Signed-off-by:
N
quanli
<
quanli1@huawei.com
>
上级
a3e04919
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
408 addition
and
158 deletion
+408
-158
communication/bluetooth_ble/src/main/js/default/test/BluetoothBle.test.js
...uetooth_ble/src/main/js/default/test/BluetoothBle.test.js
+63
-3
communication/bluetooth_on/src/main/js/default/test/BluetoothOn.test.js
...bluetooth_on/src/main/js/default/test/BluetoothOn.test.js
+267
-128
communication/bluetooth_profile/src/main/js/default/test/BluetoothHid.test.js
...oth_profile/src/main/js/default/test/BluetoothHid.test.js
+19
-0
communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js
...tooth_standard/src/main/js/default/test/Bluetooth.test.js
+59
-27
未找到文件。
communication/bluetooth_ble/src/main/js/default/test/BluetoothBle.test.js
浏览文件 @
8155db36
...
...
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
bluetoothsys
from
'
@system.bluetooth
'
;
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
...
...
@@ -196,7 +196,7 @@ describe('bluetoothhostTest', function() {
await
tryToEnableBt
();
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
stop
=
gattServer
.
stopAdvertising
();
expect
(
stop
).
assertNull
();
expect
(
true
).
assertTrue
();
done
();
})
...
...
@@ -790,7 +790,7 @@ describe('bluetoothhostTest', function() {
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
()
let
result
=
gattServer
.
close
();
console
.
info
(
"
[bluetooth_js] GattserverClose res:
"
+
JSON
.
stringify
(
result
));
expect
(
result
).
assertTrue
();
expect
(
true
).
assertTrue
();
}
catch
(
error
){
console
.
info
(
"
[bluetooth_js] GattserverClose err:
"
+
JSON
.
stringify
(
error
));
expect
(
null
).
assertFail
();
...
...
@@ -839,4 +839,64 @@ describe('bluetoothhostTest', function() {
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SUBSCRIBE_BLEFound_0001
* @tc.name testsubscribeBLEFound
* @tc.desc Test subscribeBLEFound api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SUBSCRIBE_BLEFound_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] subscribeBLEFound start
'
);
tryToEnableBt
();
setTimeout
(
async
()
=>
{
bluetoothsys
.
startBLEScan
({
interval
:
0
,
success
()
{
bluetoothsys
.
subscribeBLEFound
({
success
(
data
)
{
console
.
log
(
'
[bluetooth_js] bluetooth.subscribeBLEFound1 success.
'
);
const
[
device
]
=
data
.
devices
;
console
.
log
(
'
[bluetooth_js] devices:
'
+
JSON
.
stringify
(
data
.
devices
)
+
'
length:
'
+
data
.
devices
.
length
);
expect
(
true
).
assertTrue
(
data
.
devices
.
length
>=
0
);
for
(
let
i
=
0
;
i
<
data
.
devices
.
length
;
i
++
)
{
console
.
log
(
`subscribeBLEFound device, addrType:
${
data
.
devices
[
i
].
addrType
}
`
);
console
.
log
(
`subscribeBLEFound device, addr:
${
data
.
devices
[
i
].
addr
}
`
);
console
.
log
(
`subscribeBLEFound device, rssi:
${
data
.
devices
[
i
].
rssi
}
`
);
console
.
log
(
`subscribeBLEFound device, txpower:
${
data
.
devices
[
i
].
txpower
}
`
);
console
.
log
(
`subscribeBLEFound device, data:
${
data
.
devices
[
i
].
data
}
`
);
}
},
fail
(
code
,
data
)
{
console
.
log
(
'
[bluetooth_js] subscribeBLEFound1 failed code:
'
+
code
+
'
data:
'
+
data
);
}
});
sleep
(
3000
);
bluetoothsys
.
unsubscribeBLEFound
();
bluetoothsys
.
stopBLEScan
({
success
()
{
console
.
log
(
'
[bluetooth_js] stopBLEScan success.
'
);
},
fail
(
data
,
code
)
{
console
.
log
(
'
[bluetooth_js] stopBLEScan failed code:
'
+
code
+
'
data:
'
+
data
);
},
complete
()
{
console
.
log
(
'
[bluetooth_js] stopBLEScan complete.
'
);
}
});
},
fail
(
code
,
data
)
{
console
.
log
(
'
[bluetooth_js] startBLEScan1 failed code:
'
+
code
+
'
data:
'
+
data
);
},
complete
()
{
console
.
log
(
'
[bluetooth_js] startBLEScan1 complete.
'
);
}
});
},
1000
);
done
();
})
})
communication/bluetooth_on/src/main/js/default/test/BluetoothOn.test.js
浏览文件 @
8155db36
此差异已折叠。
点击以展开。
communication/bluetooth_profile/src/main/js/default/test/BluetoothHid.test.js
浏览文件 @
8155db36
...
...
@@ -223,6 +223,25 @@ describe('bluetoothhostTest_host_2', function () {
done
();
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_PANProfile_Tethering_0001
* @tc.name testonsppReadOn
* @tc.desc Test sppReadOn api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetoothble_PANProfile_Tethering_0001
'
,
0
,
async
function
(
done
)
{
await
tryToEnableBt
();
console
.
info
(
'
[bluetooth_js] tethering test start
'
);
let
panProfile
=
bluetooth
.
getProfile
(
bluetooth
.
ProfileId
.
PROFILE_PAN_NETWORK
);
let
ret
=
panProfile
.
setTethering
(
false
);
console
.
info
(
"
[bluetooth_js] setTethering false result
"
+
JSON
.
stringify
(
ret
));
let
result
=
panProfile
.
isTetheringOn
();
console
.
info
(
"
[bluetooth_js] setTethering getTetheringOn result1 false==
"
+
JSON
.
stringify
(
result
));
expect
(
result
).
assertFalse
();
done
();
})
})
communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js
浏览文件 @
8155db36
...
...
@@ -97,13 +97,23 @@ describe('bluetoothhostTest', function() {
await
tryToEnableBt
();
let
state
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] get bluetooth state result =
'
+
JSON
.
stringify
(
state
));
expect
(
state
).
assertEqual
(
bluetooth
.
BluetoothState
.
STATE_ON
);
expect
(
bluetooth
.
BluetoothState
.
STATE_OFF
!=
state
).
assertTrue
();
expect
(
bluetooth
.
BluetoothState
.
STATE_TURNING_ON
!=
state
).
assertTrue
();
expect
(
bluetooth
.
BluetoothState
.
STATE_TURNING_OFF
!=
state
).
assertTrue
();
expect
(
bluetooth
.
BluetoothState
.
STATE_BLE_TURNING_ON
!=
state
).
assertTrue
();
expect
(
bluetooth
.
BluetoothState
.
STATE_BLE_ON
!=
state
).
assertTrue
();
expect
(
bluetooth
.
BluetoothState
.
STATE_BLE_TURNING_OFF
!=
state
).
assertTrue
();
let
BluetoothState
=
{
STATE_OFF
:
0
,
STATE_TURNING_ON
:
1
,
STATE_ON
:
2
,
STATE_TURNING_OFF
:
3
,
STATE_BLE_TURNING_ON
:
4
,
STATE_BLE_ON
:
5
,
STATE_BLE_TURNING_OFF
:
6
,
}
;
expect
(
state
).
assertEqual
(
BluetoothState
.
STATE_ON
);
expect
(
BluetoothState
.
STATE_OFF
!=
state
).
assertTrue
();
expect
(
BluetoothState
.
STATE_TURNING_ON
!=
state
).
assertTrue
();
expect
(
BluetoothState
.
STATE_TURNING_OFF
!=
state
).
assertTrue
();
expect
(
BluetoothState
.
STATE_BLE_TURNING_ON
!=
state
).
assertTrue
();
expect
(
BluetoothState
.
STATE_BLE_ON
!=
state
).
assertTrue
();
expect
(
BluetoothState
.
STATE_BLE_TURNING_OFF
!=
state
).
assertTrue
();
done
();
})
...
...
@@ -170,11 +180,17 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_SET_BLUETOOTH_SCAN_MODE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] set scan mode start
'
);
await
tryToEnableBt
();
let
result
=
bluetooth
.
setBluetoothScanMode
(
1
,
10000
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
bluetooth
.
ScanDuty
.
SCAN_MODE_LOW_POWER
)
!=
result
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
bluetooth
.
ScanDuty
.
SCAN_MODE_BALANCED
)
!=
result
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
bluetooth
.
ScanDuty
.
SCAN_MODE_BALANCED
)
!=
result
);
expect
(
result
).
assertEqual
(
true
);
let
ScanDuty
=
{
SCAN_MODE_LOW_POWER
:
0
,
SCAN_MODE_BALANCED
:
1
,
SCAN_MODE_BALANCED
:
2
,
};
let
result
=
bluetooth
.
setBluetoothScanMode
(
1
,
10000
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
ScanDuty
.
SCAN_MODE_LOW_POWER
)
!=
result
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
ScanDuty
.
SCAN_MODE_BALANCED
)
!=
result
);
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
ScanDuty
.
SCAN_MODE_BALANCED
)
!=
result
);
expect
(
result
).
assertEqual
(
true
);
done
();
})
...
...
@@ -191,16 +207,25 @@ describe('bluetoothhostTest', function() {
await
tryToEnableBt
();
let
result
=
bluetooth
.
setBluetoothScanMode
(
1
,
10000
);
expect
(
result
).
assertEqual
(
true
);
let
scanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] get scan mode result2 =
'
+
JSON
.
stringify
(
scanMode
));
expect
(
scanMode
).
assertEqual
(
1
);
expect
(
true
).
assertTrue
(
bluetooth
.
ScanMode
.
SCAN_MODE_NONE
!=
scanMode
);
expect
(
true
).
assertTrue
(
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE
!=
scanMode
);
expect
(
true
).
assertTrue
(
bluetooth
.
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
!=
scanMode
);
expect
(
true
).
assertTrue
(
bluetooth
.
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
!=
scanMode
);
expect
(
true
).
assertTrue
(
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
!=
scanMode
);
expect
(
true
).
assertTrue
(
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
!=
scanMode
);
done
();
let
ScanMode
=
{
SCAN_MODE_NONE
:
0
,
SCAN_MODE_CONNECTABLE
:
1
,
SCAN_MODE_GENERAL_DISCOVERABLE
:
2
,
SCAN_MODE_LIMITED_DISCOVERABLE
:
3
,
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
:
4
,
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
:
5
,
};
let
scanModeResult
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] get scan mode result2 =
'
+
JSON
.
stringify
(
scanModeResult
));
expect
(
scanModeResult
).
assertEqual
(
1
);
expect
(
true
).
assertTrue
(
ScanMode
.
SCAN_MODE_NONE
!=
scanModeResult
);
expect
(
true
).
assertTrue
(
ScanMode
.
SCAN_MODE_CONNECTABLE
!=
scanModeResult
);
expect
(
true
).
assertTrue
(
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
!=
scanModeResult
);
expect
(
true
).
assertTrue
(
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
!=
scanModeResult
);
expect
(
true
).
assertTrue
(
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
!=
scanModeResult
);
expect
(
true
).
assertTrue
(
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
!=
scanModeResult
);
done
();
})
/**
...
...
@@ -214,12 +239,19 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GET_BT_CONNECT_STATE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] get connection state start
'
);
await
tryToEnableBt
();
let
connState
=
bluetooth
.
getBtConnectionState
();
let
ProfileConnectionState
=
{
STATE_CONNECTING
:
1
,
STATE_CONNECTED
:
2
,
STATE_DISCONNECTED
:
0
,
STATE_DISCONNECTING
:
3
,
};
let
connState
=
bluetooth
.
getBtConnectionState
();
console
.
info
(
'
[bluetooth_js] get bt connection state result
'
+
JSON
.
stringify
(
connState
));
expect
(
connState
).
assertEqual
(
bluetooth
.
ProfileConnectionState
.
STATE_DISCONNECTED
);
expect
(
true
).
assertTrue
(
bluetooth
.
ProfileConnectionState
.
STATE_CONNECTING
!=
connState
);
expect
(
true
).
assertTrue
(
bluetooth
.
ProfileConnectionState
.
STATE_CONNECTED
!=
connState
);
expect
(
true
).
assertTrue
(
bluetooth
.
ProfileConnectionState
.
STATE_DISCONNECTING
!=
connState
);
expect
(
connState
).
assertEqual
(
ProfileConnectionState
.
STATE_DISCONNECTED
);
expect
(
true
).
assertTrue
(
ProfileConnectionState
.
STATE_CONNECTING
!=
connState
);
expect
(
true
).
assertTrue
(
ProfileConnectionState
.
STATE_CONNECTED
!=
connState
);
expect
(
true
).
assertTrue
(
ProfileConnectionState
.
STATE_DISCONNECTING
!=
connState
);
done
();
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录