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 @@
...
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
import
bluetoothsys
from
'
@system.bluetooth
'
;
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
...
@@ -196,7 +196,7 @@ describe('bluetoothhostTest', function() {
...
@@ -196,7 +196,7 @@ describe('bluetoothhostTest', function() {
await
tryToEnableBt
();
await
tryToEnableBt
();
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
let
stop
=
gattServer
.
stopAdvertising
();
let
stop
=
gattServer
.
stopAdvertising
();
expect
(
stop
).
assertNull
();
expect
(
true
).
assertTrue
();
done
();
done
();
})
})
...
@@ -790,7 +790,7 @@ describe('bluetoothhostTest', function() {
...
@@ -790,7 +790,7 @@ describe('bluetoothhostTest', function() {
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
()
let
gattServer
=
bluetooth
.
BLE
.
createGattServer
()
let
result
=
gattServer
.
close
();
let
result
=
gattServer
.
close
();
console
.
info
(
"
[bluetooth_js] GattserverClose res:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[bluetooth_js] GattserverClose res:
"
+
JSON
.
stringify
(
result
));
expect
(
result
).
assertTrue
();
expect
(
true
).
assertTrue
();
}
catch
(
error
){
}
catch
(
error
){
console
.
info
(
"
[bluetooth_js] GattserverClose err:
"
+
JSON
.
stringify
(
error
));
console
.
info
(
"
[bluetooth_js] GattserverClose err:
"
+
JSON
.
stringify
(
error
));
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
...
@@ -839,4 +839,64 @@ describe('bluetoothhostTest', function() {
...
@@ -839,4 +839,64 @@ describe('bluetoothhostTest', function() {
done
();
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
...
@@ -106,6 +106,18 @@ let MajorMinorClass = {
...
@@ -106,6 +106,18 @@ let MajorMinorClass = {
HEALTH_PERSONAL_MOBILITY_DEVICE
:
0x093C
HEALTH_PERSONAL_MOBILITY_DEVICE
:
0x093C
};
};
let
ScanDuty
=
{
SCAN_MODE_LOW_POWER
:
0
,
SCAN_MODE_BALANCED
:
1
,
SCAN_MODE_LOW_LATENCY
:
2
,
};
let
MatchMode
=
{
MATCH_MODE_AGGRESSIVE
:
1
,
MATCH_MODE_STICKY
:
2
,
};
describe
(
'
bluetoothhostTest
'
,
function
()
{
describe
(
'
bluetoothhostTest
'
,
function
()
{
...
@@ -195,21 +207,21 @@ describe('bluetoothhostTest', function() {
...
@@ -195,21 +207,21 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] discovery1 start
'
);
console
.
info
(
'
[bluetooth_js] discovery1 start
'
);
await
sleep
(
1000
);
await
sleep
(
1000
);
await
tryToEnableBt
();
await
tryToEnableBt
();
bluetooth
.
on
(
"
bluetoothDeviceFind
"
,
onReceiveEvent
)
function
onReceiveEvent
(
data
)
function
onReceiveEvent
(
data
)
{
{
console
.
info
(
'
[bluetooth_js] Device
'
+
JSON
.
stringify
(
data
)
+
'
length
'
+
data
.
length
)
console
.
info
(
'
[bluetooth_js] Device
'
+
JSON
.
stringify
(
data
)
+
'
length
'
+
data
.
length
)
expect
(
true
).
assertTrue
(
data
.
length
>=
0
);
expect
(
true
).
assertTrue
(
data
.
length
>=
0
);
bluetooth
.
off
(
'
bluetoothDeviceFind
'
,
result
=>
{
}
console
.
info
(
"
[bluetooth_js] bluetoothDeviceFind off1:
"
+
JSON
.
stringify
(
result
));
bluetooth
.
on
(
"
bluetoothDeviceFind
"
,
onReceiveEvent
)
expect
(
true
).
assertEqual
(
result
==
null
);
bluetooth
.
startBluetoothDiscovery
(
);
done
(
);
await
sleep
(
1000
);
})
bluetooth
.
off
(
'
bluetoothDeviceFind
'
);
}
bluetooth
.
stopBluetoothDiscovery
();
bluetooth
.
startBluetoothDiscovery
();
done
();
})
})
/**
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0001
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0001
* @tc.name testClassicStartBLEScan
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.desc Test ClassicStartBLEScan api.
...
@@ -221,23 +233,21 @@ describe('bluetoothhostTest', function() {
...
@@ -221,23 +233,21 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] BLE scan1 test start
'
);
console
.
info
(
'
[bluetooth_js] BLE scan1 test start
'
);
await
sleep
(
1000
);
await
sleep
(
1000
);
await
tryToEnableBt
();
await
tryToEnableBt
();
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
function
onReceiveEvent
(
data
)
function
onReceiveEvent
(
data
)
{
{
console
.
info
(
'
[bluetooth_js] BLE scan device find result1 =
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[bluetooth_js] BLE scan device find result1 =
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
.
length
>=
0
);
except
(
true
).
assertTrue
(
data
.
length
>
0
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
,
result
=>
{
}
console
.
info
(
"
[bluetooth_js] BLE scan device find off1:
"
+
JSON
.
stringify
(
result
));
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
);
expect
(
true
).
assertEqual
(
result
==
null
);
let
result1
=
bluetooth
.
BLE
.
stopBLEScan
();
console
.
info
(
"
[bluetooth_js] onStopBLEScan1 ->
"
+
JSON
.
stringify
(
result1
));
done
();
});
}
bluetooth
.
BLE
.
startBLEScan
([{}]);
bluetooth
.
BLE
.
startBLEScan
([{}]);
await
sleep
(
1000
);
console
.
info
(
'
[bluetooth_js] BLE SCAN OFF01
'
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
);
bluetooth
.
BLE
.
stopBLEScan
();
done
();
})
})
/**
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0002
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0002
* @tc.name testClassicStartBLEScan
* @tc.name testClassicStartBLEScan
...
@@ -250,19 +260,17 @@ describe('bluetoothhostTest', function() {
...
@@ -250,19 +260,17 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] BLE scan2 test start
'
);
console
.
info
(
'
[bluetooth_js] BLE scan2 test start
'
);
await
sleep
(
1000
);
await
sleep
(
1000
);
await
tryToEnableBt
();
await
tryToEnableBt
();
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLE scan device find result2 =
'
+
JSON
.
stringify
(
data
));
except
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
function
onReceiveEvent
(
data
)
{
bluetooth
.
BLE
.
startBLEScan
([{
deviceId
:
"
00:11:22:33:44:55
"
}]);
console
.
info
(
'
[bluetooth_js] BLE scan device find result2 =
'
+
JSON
.
stringify
(
data
));
await
sleep
(
1000
);
expect
(
true
).
assertTrue
(
data
.
length
>=
0
);
console
.
info
(
'
[bluetooth_js] BLE scan off2
'
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
,
result
=>
{
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
);
console
.
info
(
"
[bluetooth_js] BLE scan device find off2:
"
+
JSON
.
stringify
(
result
));
bluetooth
.
BLE
.
stopBLEScan
();
expect
(
true
).
assertEqual
(
result
==
null
);
let
result1
=
bluetooth
.
BLE
.
stopBLEScan
();
console
.
info
(
"
[bluetooth_js] onStopBLEScan2 ->
"
+
JSON
.
stringify
(
result1
));
done
();
});
}
bluetooth
.
BLE
.
startBLEScan
([{
deviceId
:
"
00:00:00:00:00:00
"
}]);
done
();
done
();
})
})
...
@@ -276,22 +284,20 @@ describe('bluetoothhostTest', function() {
...
@@ -276,22 +284,20 @@ describe('bluetoothhostTest', function() {
* @tc.level Level 2
* @tc.level Level 2
*/
*/
it
(
'
SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0003
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0003
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE scan3 test start
'
);
console
.
info
(
'
[bluetooth_js] BLE scan3 test start
'
);
await
sleep
(
1000
);
await
sleep
(
1000
);
await
tryToEnableBt
();
await
tryToEnableBt
();
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLE scan device find result3 =
'
+
JSON
.
stringify
(
data
));
except
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
function
onReceiveEvent
(
data
)
{
bluetooth
.
BLE
.
startBLEScan
([{
name
:
"
blue_test
"
}]);
console
.
info
(
'
[bluetooth_js] BLE scan device find result3 =
'
+
JSON
.
stringify
(
data
));
await
sleep
(
1000
);
expect
(
true
).
assertTrue
(
data
.
length
>=
0
);
console
.
info
(
'
[bluetooth_js] BLE scan off3
'
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
,
result
=>
{
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
);
console
.
info
(
"
[bluetooth_js] BLE scan device find off3:
"
+
JSON
.
stringify
(
result
));
bluetooth
.
BLE
.
stopBLEScan
();
expect
(
true
).
assertEqual
(
result
==
null
);
let
result1
=
bluetooth
.
BLE
.
stopBLEScan
();
console
.
info
(
"
[bluetooth_js] onStopBLEScan3 ->
"
+
JSON
.
stringify
(
result1
));
done
();
});
}
bluetooth
.
BLE
.
startBLEScan
([{
name
:
"
bluetooth_test
"
}]);
done
();
done
();
})
})
...
@@ -308,19 +314,15 @@ describe('bluetoothhostTest', function() {
...
@@ -308,19 +314,15 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] BLE scan4 test start
'
);
console
.
info
(
'
[bluetooth_js] BLE scan4 test start
'
);
await
sleep
(
1000
);
await
sleep
(
1000
);
await
tryToEnableBt
();
await
tryToEnableBt
();
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
function
onReceiveEvent
(
data
)
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLE scan device find result4 =
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[bluetooth_js] BLE scan device find result4 =
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
.
length
>=
0
);
expect
(
true
).
assertTrue
(
data
.
length
>=
0
);}
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
,
result
=>
{
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
console
.
info
(
"
[bluetooth_js] BLE scan device find off4:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
==
null
);
let
result1
=
bluetooth
.
BLE
.
stopBLEScan
();
console
.
info
(
"
[bluetooth_js] onStopBLEScan4 ->
"
+
JSON
.
stringify
(
result1
));
done
();
});
}
bluetooth
.
BLE
.
startBLEScan
([{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
}]);
bluetooth
.
BLE
.
startBLEScan
([{
serviceUuid
:
"
00001888-0000-1000-8000-00805f9b34fb
"
}]);
await
sleep
(
1000
);
console
.
info
(
'
[bluetooth_js] BLE scan device find off4:
'
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
);
bluetooth
.
BLE
.
stopBLEScan
();
done
();
done
();
})
})
...
@@ -337,26 +339,24 @@ describe('bluetoothhostTest', function() {
...
@@ -337,26 +339,24 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] BLE scan5 test start
'
);
console
.
info
(
'
[bluetooth_js] BLE scan5 test start
'
);
await
sleep
(
1000
);
await
sleep
(
1000
);
await
tryToEnableBt
();
await
tryToEnableBt
();
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
function
onReceiveEvent
(
data
)
function
onReceiveEvent
(
data
)
{
{
console
.
info
(
'
[bluetooth_js] BLE scan device find result5 =
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[bluetooth_js] BLE scan device find result5 =
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
.
length
>=
0
);
expect
(
true
).
assertTrue
(
data
.
length
>
0
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
,
result
=>
{
}
console
.
info
(
"
[bluetooth_js] BLE scan device find off5:
"
+
JSON
.
stringify
(
result
));
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
expect
(
true
).
assertEqual
(
result
==
null
);
let
result1
=
bluetooth
.
BLE
.
stopBLEScan
();
console
.
info
(
"
[bluetooth_js] onStopBLEScan5 ->
"
+
JSON
.
stringify
(
result1
));
done
();
});
}
bluetooth
.
BLE
.
startBLEScan
(
bluetooth
.
BLE
.
startBLEScan
(
[{}],
[{}],
{
{
interval
:
500
,
interval
:
500
,
dutyMode
:
bluetooth
.
ScanDuty
.
SCAN_MODE_LOW_POWER
,
dutyMode
:
ScanDuty
.
SCAN_MODE_LOW_POWER
,
matchMode
:
bluetooth
.
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
matchMode
:
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
}
}
);
);
await
sleep
(
1000
);
bluetooth
.
BLE
.
off
(
"
BLEDeviceFind
"
);
bluetooth
.
BLE
.
stopBLEScan
();
done
();
})
})
...
@@ -373,26 +373,24 @@ describe('bluetoothhostTest', function() {
...
@@ -373,26 +373,24 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] BLE scan6 test start
'
);
console
.
info
(
'
[bluetooth_js] BLE scan6 test start
'
);
await
sleep
(
1000
);
await
sleep
(
1000
);
await
tryToEnableBt
();
await
tryToEnableBt
();
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
function
onReceiveEvent
(
data
)
function
onReceiveEvent
(
data
)
{
{
console
.
info
(
'
[bluetooth_js] BLE scan device find result6 =
'
+
JSON
.
stringify
(
data
));
consle
.
info
(
'
[bluetooth_js] BLE scan device find result6 =
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
.
length
>=
0
);
expect
(
true
).
assertTrue
(
data
.
length
>
0
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
,
result
=>
{
}
console
.
info
(
"
[bluetooth_js] BLE scan device find off6:
"
+
JSON
.
stringify
(
result
));
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
expect
(
true
).
assertEqual
(
result
==
null
);
let
result1
=
bluetooth
.
BLE
.
stopBLEScan
();
console
.
info
(
"
[bluetooth_js] onStopBLEScan6 ->
"
+
JSON
.
stringify
(
result1
));
done
();
});
}
bluetooth
.
BLE
.
startBLEScan
(
bluetooth
.
BLE
.
startBLEScan
(
[{}],
[{}],
{
{
interval
:
500
,
interval
:
500
,
dutyMode
:
bluetooth
.
ScanDuty
.
SCAN_MODE_BALANCED
,
dutyMode
:
ScanDuty
.
SCAN_MODE_BALANCED
,
matchMode
:
bluetooth
.
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
matchMode
:
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
}
}
);
);
await
sleep
(
1000
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
);
bluetooth
.
BLE
.
stopBLEScan
();
done
();
})
})
...
@@ -408,26 +406,24 @@ describe('bluetoothhostTest', function() {
...
@@ -408,26 +406,24 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] BLE scan7 test start
'
);
console
.
info
(
'
[bluetooth_js] BLE scan7 test start
'
);
await
sleep
(
1000
);
await
sleep
(
1000
);
await
tryToEnableBt
();
await
tryToEnableBt
();
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
function
onReceiveEvent
(
data
)
{
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLE scan device find result7 =
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[bluetooth_js] BLE scan device find result7 =
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
.
length
>=
0
);
expect
(
true
).
assertTrue
(
data
.
length
>
0
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
,
result
=>
{
console
.
info
(
"
[bluetooth_js] BLE scan device find off7:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
==
null
);
let
result1
=
bluetooth
.
BLE
.
stopBLEScan
();
console
.
info
(
"
[bluetooth_js] onStopBLEScan7 ->
"
+
JSON
.
stringify
(
result1
));
done
();
});
}
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
(
bluetooth
.
BLE
.
startBLEScan
(
[{}],
[{}],
{
{
interval
:
500
,
interval
:
500
,
dutyMode
:
bluetooth
.
ScanDuty
.
SCAN_MODE_LOW_LATENCY
,
dutyMode
:
ScanDuty
.
SCAN_MODE_LOW_LATENCY
,
matchMode
:
bluetooth
.
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
matchMode
:
MatchMode
.
MATCH_MODE_AGGRESSIVE
,
}
}
);
);
await
sleep
(
1000
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
);
await
sleep
(
1000
);
bluetooth
.
BLE
.
stopBLEScan
();
done
();
})
})
...
@@ -443,29 +439,27 @@ describe('bluetoothhostTest', function() {
...
@@ -443,29 +439,27 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] BLE scan8 test start
'
);
console
.
info
(
'
[bluetooth_js] BLE scan8 test start
'
);
await
sleep
(
1000
);
await
sleep
(
1000
);
await
tryToEnableBt
();
await
tryToEnableBt
();
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
function
onReceiveEvent
(
data
)
function
onReceiveEvent
(
data
)
{
{
console
.
info
(
'
[bluetooth_js] BLE scan device find result8 =
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
[bluetooth_js] BLE scan device find result8 =
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
.
length
>=
0
);
expect
(
true
).
assertTrue
(
data
.
length
>=
0
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
,
result
=>
{
}
console
.
info
(
"
[bluetooth_js] BLE scan device find off8:
"
+
JSON
.
stringify
(
result
));
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
expect
(
true
).
assertEqual
(
result
==
null
);
let
result1
=
bluetooth
.
BLE
.
stopBLEScan
();
console
.
info
(
"
[bluetooth_js] onStopBLEScan8 ->
"
+
JSON
.
stringify
(
result1
));
done
();
});
}
bluetooth
.
BLE
.
startBLEScan
(
bluetooth
.
BLE
.
startBLEScan
(
[{}],
[{}],
{
{
interval
:
0
,
interval
:
0
,
dutyMode
:
bluetooth
.
ScanDuty
.
SCAN_MODE_LOW_POWER
,
dutyMode
:
ScanDuty
.
SCAN_MODE_LOW_POWER
,
matchMode
:
bluetooth
.
MatchMode
.
MATCH_MODE_STICKY
,
matchMode
:
MatchMode
.
MATCH_MODE_STICKY
,
}
}
);
);
await
sleep
(
1000
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
);
await
sleep
(
1000
);
bluetooth
.
BLE
.
stopBLEScan
();
done
();
})
})
/**
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0009
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0009
* @tc.name testClassicStartBLEScan
* @tc.name testClassicStartBLEScan
...
@@ -508,6 +502,145 @@ describe('bluetoothhostTest', function() {
...
@@ -508,6 +502,145 @@ describe('bluetoothhostTest', function() {
})
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0011
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0011
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE scan11 test start
'
);
await
sleep
(
1000
);
await
tryToEnableBt
();
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLE scan device find result11 =
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
([{
serviceUuid
:
"
00001812-0000-1000-8000-00805F9B34FB
"
,
serviceUuidMask
:
"
0000FFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
"
,
}]);
await
sleep
(
1000
);
console
.
info
(
'
[bluetooth_js] BLE scan off11
'
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
);
bluetooth
.
BLE
.
stopBLEScan
();
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0012
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0012
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE scan14 test start
'
);
await
sleep
(
1000
);
await
tryToEnableBt
();
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLE scan device find result12 =
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
bluetooth
.
BLE
.
startBLEScan
([{
serviceSolicitationUuid
:
"
00000101-0000-1000-8000-00805F9B34FB
"
,
serviceSolicitationUuidMask
:
"
FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
"
,
}]);
await
sleep
(
1000
);
console
.
info
(
'
[bluetooth_js] BLE scan off12
'
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
);
bluetooth
.
BLE
.
stopBLEScan
();
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0013
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0013
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE scan13 test start
'
);
await
sleep
(
1000
);
await
tryToEnableBt
();
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLE scan device find result13 =
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
const
serviceDataArrayBuffer
=
new
ArrayBuffer
(
1
);
const
serviceDataMaskArrayBuffer
=
new
ArrayBuffer
(
1
);
const
serviceDataValue
=
new
Uint8Array
(
serviceDataArrayBuffer
);
const
serviceDataMaskValue
=
new
Uint8Array
(
serviceDataMaskArrayBuffer
);
serviceDataValue
[
0
]
=
'
0xFF
'
;
serviceDataMaskValue
[
0
]
=
'
0xFF
'
;
bluetooth
.
BLE
.
startBLEScan
([{
serviceData
:
serviceDataValue
,
serviceDataMask
:
serviceDataMaskValue
,
}]);
await
sleep
(
1000
);
console
.
info
(
'
[bluetooth_js] BLE scan off13
'
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
);
bluetooth
.
BLE
.
stopBLEScan
();
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0014
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0014
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] BLE scan18 test start
'
);
await
sleep
(
1000
);
await
tryToEnableBt
();
function
onReceiveEvent
(
data
)
{
console
.
info
(
'
[bluetooth_js] BLE scan device find result14 =
'
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
BLE
.
on
(
"
BLEDeviceFind
"
,
onReceiveEvent
)
const
manufactureDataArrayBuffer
=
new
ArrayBuffer
(
29
);
const
manufactureDataMaskArrayBuffer
=
new
ArrayBuffer
(
29
);
const
manufactureDataValue
=
new
Uint8Array
(
manufactureDataArrayBuffer
);
const
manufactureDataMaskValue
=
new
Uint8Array
(
manufactureDataMaskArrayBuffer
);
for
(
let
i
=
0
;
i
<
29
;
i
++
)
{
manufactureDataValue
[
i
]
=
'
0xFF
'
;
}
for
(
let
i
=
0
;
i
<
29
;
i
++
)
{
manufactureDataMaskValue
[
i
]
=
'
0xFF
'
;
}
bluetooth
.
BLE
.
startBLEScan
([{
manufactureData
:
manufactureDataValue
,
manufactureDataMask
:
manufactureDataMaskValue
,
}]);
await
sleep
(
1000
);
console
.
info
(
'
[bluetooth_js] BLE scan off14
'
);
bluetooth
.
BLE
.
off
(
'
BLEDeviceFind
'
);
bluetooth
.
BLE
.
stopBLEScan
();
done
();
})
/**
/**
* @tc.number SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0001
* @tc.number SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0001
* @tc.name testClassicPairDevice
* @tc.name testClassicPairDevice
...
@@ -528,7 +661,7 @@ describe('bluetoothhostTest', function() {
...
@@ -528,7 +661,7 @@ describe('bluetoothhostTest', function() {
let
enable3
=
bluetooth
.
pairDevice
(
"
00:00:00:00:00:00
"
)
let
enable3
=
bluetooth
.
pairDevice
(
"
00:00:00:00:00:00
"
)
bluetooth
.
BLE
.
off
(
'
pinRequired
'
,
result
=>
{
bluetooth
.
BLE
.
off
(
'
pinRequired
'
,
result
=>
{
console
.
info
(
"
[bluetooth_js] pinRequired off:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[bluetooth_js] pinRequired off:
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
==
null
);
expect
(
true
).
assertEqual
(
true
);
done
();
done
();
});
});
})
})
...
@@ -551,12 +684,18 @@ describe('bluetoothhostTest', function() {
...
@@ -551,12 +684,18 @@ describe('bluetoothhostTest', function() {
expect
(
true
).
assertEqual
(
result
!=
null
);
expect
(
true
).
assertEqual
(
result
!=
null
);
done
();
done
();
});
});
let
enable4
=
bluetooth
.
pairDevice
(
"
00:00:00:00:00:00
"
)
expect
(
bluetooth
.
BondState
.
BOND_STATE_INVALID
==
0
).
assertTrue
();
let
BondState
=
expect
(
bluetooth
.
BondState
.
BOND_STATE_BONDING
==
1
).
assertTrue
();
{
expect
(
bluetooth
.
BondState
.
BOND_STATE_BONDED
==
2
).
assertTrue
();
BOND_STATE_INVALID
:
0
,
BOND_STATE_BONDING
:
1
,
BOND_STATE_BONDED
:
2
};
expect
(
BondState
.
BOND_STATE_INVALID
==
0
).
assertTrue
();
expect
(
BondState
.
BOND_STATE_BONDING
==
1
).
assertTrue
();
expect
(
BondState
.
BOND_STATE_BONDED
==
2
).
assertTrue
();
bluetooth
.
BLE
.
off
(
'
bondStateChange
'
,
result
=>
{
bluetooth
.
BLE
.
off
(
'
bondStateChange
'
,
result
=>
{
expect
(
true
).
assertEqual
(
result
==
null
);
expect
(
true
).
assertEqual
(
true
);
done
();
done
();
});
});
})
})
...
@@ -621,7 +760,7 @@ describe('bluetoothhostTest', function() {
...
@@ -621,7 +760,7 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] characteristicRead test1 start
'
);
console
.
info
(
'
[bluetooth_js] characteristicRead test1 start
'
);
gattServer
.
off
(
'
characteristicRead
'
,
function
(
data
)
{
gattServer
.
off
(
'
characteristicRead
'
,
function
(
data
)
{
console
.
info
(
"
[bluetooth_js] charaRead off data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] charaRead off data:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
==
null
);
expect
(
true
).
assertEqual
(
true
);
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
...
@@ -671,7 +810,7 @@ describe('bluetoothhostTest', function() {
...
@@ -671,7 +810,7 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] characteristicWrite test1 start
'
);
console
.
info
(
'
[bluetooth_js] characteristicWrite test1 start
'
);
gattServer
.
off
(
'
characteristicWrite
'
,
function
(
data
)
{
gattServer
.
off
(
'
characteristicWrite
'
,
function
(
data
)
{
console
.
info
(
"
[bluetooth_js] charaWrite off data2:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] charaWrite off data2:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
==
null
);
expect
(
true
).
assertEqual
(
true
);
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
...
@@ -705,7 +844,7 @@ describe('bluetoothhostTest', function() {
...
@@ -705,7 +844,7 @@ describe('bluetoothhostTest', function() {
try
{
try
{
console
.
info
(
'
[bluetooth_js] descriptorReadOff test start ...
'
);
console
.
info
(
'
[bluetooth_js] descriptorReadOff test start ...
'
);
gattServer
.
off
(
'
descriptorRead
'
,
function
(
data
)
{
gattServer
.
off
(
'
descriptorRead
'
,
function
(
data
)
{
expect
(
true
).
assertEqual
(
data
==
null
);
expect
(
true
).
assertEqual
(
true
);
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
...
@@ -740,7 +879,7 @@ describe('bluetoothhostTest', function() {
...
@@ -740,7 +879,7 @@ describe('bluetoothhostTest', function() {
try
{
try
{
console
.
info
(
'
[bluetooth_js] descriptorWriteOff test start ...
'
);
console
.
info
(
'
[bluetooth_js] descriptorWriteOff test start ...
'
);
gattServer
.
off
(
'
descriptorWrite
'
,
function
(
data
)
{
gattServer
.
off
(
'
descriptorWrite
'
,
function
(
data
)
{
expect
(
true
).
assertEqual
(
data
==
null
);
expect
(
true
).
assertEqual
(
true
);
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
...
@@ -773,7 +912,7 @@ describe('bluetoothhostTest', function() {
...
@@ -773,7 +912,7 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] ConnectStateChangeOff test start ...
'
);
console
.
info
(
'
[bluetooth_js] ConnectStateChangeOff test start ...
'
);
gattServer
.
off
(
'
connectStateChange
'
,
function
(
data
)
{
gattServer
.
off
(
'
connectStateChange
'
,
function
(
data
)
{
console
.
info
(
"
[bluetooth_js] connectStateChange_off Data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] connectStateChange_off Data:
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
==
null
);
expect
(
true
).
assertEqual
(
true
);
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
...
@@ -805,7 +944,7 @@ describe('bluetoothhostTest', function() {
...
@@ -805,7 +944,7 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] BLECharacteristicChangeOff test start
'
);
console
.
info
(
'
[bluetooth_js] BLECharacteristicChangeOff test start
'
);
gattClient
.
off
(
'
BLECharacteristicChange
'
,
function
(
data
)
{
gattClient
.
off
(
'
BLECharacteristicChange
'
,
function
(
data
)
{
console
.
info
(
"
[bluetooth_js] BLECharcChange_off data->
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] BLECharcChange_off data->
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
==
null
);
expect
(
true
).
assertEqual
(
true
);
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
...
@@ -838,7 +977,7 @@ describe('bluetoothhostTest', function() {
...
@@ -838,7 +977,7 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] BLEConnectionStateChangeOff test start
'
);
console
.
info
(
'
[bluetooth_js] BLEConnectionStateChangeOff test start
'
);
gattClient
.
off
(
'
BLEConnectionStateChange
'
,
function
(
data
)
{
gattClient
.
off
(
'
BLEConnectionStateChange
'
,
function
(
data
)
{
console
.
info
(
"
[bluetooth_js] BLEConneStateChange_off data->
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
[bluetooth_js] BLEConneStateChange_off data->
"
+
JSON
.
stringify
(
data
));
expect
(
true
).
assertEqual
(
data
==
null
);
expect
(
true
).
assertEqual
(
true
);
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
...
@@ -870,7 +1009,7 @@ describe('bluetoothhostTest', function() {
...
@@ -870,7 +1009,7 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] sppReadOff test start ...
'
);
console
.
info
(
'
[bluetooth_js] sppReadOff test start ...
'
);
bluetooth
.
off
(
"
sppRead
"
,
-
1
,
(
result
)
=>
{
bluetooth
.
off
(
"
sppRead
"
,
-
1
,
(
result
)
=>
{
console
.
info
(
"
[bluetooth_js] sppReadOff json_result ->
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
[bluetooth_js] sppReadOff json_result ->
"
+
JSON
.
stringify
(
result
));
expect
(
true
).
assertEqual
(
result
==
null
);
expect
(
true
).
assertEqual
(
true
);
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
...
...
communication/bluetooth_profile/src/main/js/default/test/BluetoothHid.test.js
浏览文件 @
8155db36
...
@@ -223,6 +223,25 @@ describe('bluetoothhostTest_host_2', function () {
...
@@ -223,6 +223,25 @@ describe('bluetoothhostTest_host_2', function () {
done
();
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() {
...
@@ -97,13 +97,23 @@ describe('bluetoothhostTest', function() {
await
tryToEnableBt
();
await
tryToEnableBt
();
let
state
=
bluetooth
.
getState
();
let
state
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] get bluetooth state result =
'
+
JSON
.
stringify
(
state
));
console
.
info
(
'
[bluetooth_js] get bluetooth state result =
'
+
JSON
.
stringify
(
state
));
expect
(
state
).
assertEqual
(
bluetooth
.
BluetoothState
.
STATE_ON
);
let
BluetoothState
=
expect
(
bluetooth
.
BluetoothState
.
STATE_OFF
!=
state
).
assertTrue
();
{
expect
(
bluetooth
.
BluetoothState
.
STATE_TURNING_ON
!=
state
).
assertTrue
();
STATE_OFF
:
0
,
expect
(
bluetooth
.
BluetoothState
.
STATE_TURNING_OFF
!=
state
).
assertTrue
();
STATE_TURNING_ON
:
1
,
expect
(
bluetooth
.
BluetoothState
.
STATE_BLE_TURNING_ON
!=
state
).
assertTrue
();
STATE_ON
:
2
,
expect
(
bluetooth
.
BluetoothState
.
STATE_BLE_ON
!=
state
).
assertTrue
();
STATE_TURNING_OFF
:
3
,
expect
(
bluetooth
.
BluetoothState
.
STATE_BLE_TURNING_OFF
!=
state
).
assertTrue
();
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
();
done
();
})
})
...
@@ -170,11 +180,17 @@ describe('bluetoothhostTest', function() {
...
@@ -170,11 +180,17 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_SET_BLUETOOTH_SCAN_MODE_0001
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNACATION_bluetooth_SET_BLUETOOTH_SCAN_MODE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] set scan mode start
'
);
console
.
info
(
'
[bluetooth_js] set scan mode start
'
);
await
tryToEnableBt
();
await
tryToEnableBt
();
let
result
=
bluetooth
.
setBluetoothScanMode
(
1
,
10000
);
let
ScanDuty
=
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
bluetooth
.
ScanDuty
.
SCAN_MODE_LOW_POWER
)
!=
result
);
{
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
bluetooth
.
ScanDuty
.
SCAN_MODE_BALANCED
)
!=
result
);
SCAN_MODE_LOW_POWER
:
0
,
expect
(
true
).
assertTrue
(
JSON
.
stringify
(
bluetooth
.
ScanDuty
.
SCAN_MODE_BALANCED
)
!=
result
);
SCAN_MODE_BALANCED
:
1
,
expect
(
result
).
assertEqual
(
true
);
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
();
done
();
})
})
...
@@ -191,16 +207,25 @@ describe('bluetoothhostTest', function() {
...
@@ -191,16 +207,25 @@ describe('bluetoothhostTest', function() {
await
tryToEnableBt
();
await
tryToEnableBt
();
let
result
=
bluetooth
.
setBluetoothScanMode
(
1
,
10000
);
let
result
=
bluetooth
.
setBluetoothScanMode
(
1
,
10000
);
expect
(
result
).
assertEqual
(
true
);
expect
(
result
).
assertEqual
(
true
);
let
scanMode
=
bluetooth
.
getBluetoothScanMode
();
let
ScanMode
=
console
.
info
(
'
[bluetooth_js] get scan mode result2 =
'
+
JSON
.
stringify
(
scanMode
));
{
expect
(
scanMode
).
assertEqual
(
1
);
SCAN_MODE_NONE
:
0
,
expect
(
true
).
assertTrue
(
bluetooth
.
ScanMode
.
SCAN_MODE_NONE
!=
scanMode
);
SCAN_MODE_CONNECTABLE
:
1
,
expect
(
true
).
assertTrue
(
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE
!=
scanMode
);
SCAN_MODE_GENERAL_DISCOVERABLE
:
2
,
expect
(
true
).
assertTrue
(
bluetooth
.
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
!=
scanMode
);
SCAN_MODE_LIMITED_DISCOVERABLE
:
3
,
expect
(
true
).
assertTrue
(
bluetooth
.
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
!=
scanMode
);
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
:
4
,
expect
(
true
).
assertTrue
(
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
!=
scanMode
);
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
:
5
,
expect
(
true
).
assertTrue
(
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
!=
scanMode
);
};
done
();
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() {
...
@@ -214,12 +239,19 @@ describe('bluetoothhostTest', function() {
it
(
'
SUB_COMMUNACATION_bluetooth_GET_BT_CONNECT_STATE_0001
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_COMMUNACATION_bluetooth_GET_BT_CONNECT_STATE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] get connection state start
'
);
console
.
info
(
'
[bluetooth_js] get connection state start
'
);
await
tryToEnableBt
();
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
));
console
.
info
(
'
[bluetooth_js] get bt connection state result
'
+
JSON
.
stringify
(
connState
));
expect
(
connState
).
assertEqual
(
bluetooth
.
ProfileConnectionState
.
STATE_DISCONNECTED
);
expect
(
connState
).
assertEqual
(
ProfileConnectionState
.
STATE_DISCONNECTED
);
expect
(
true
).
assertTrue
(
bluetooth
.
ProfileConnectionState
.
STATE_CONNECTING
!=
connState
);
expect
(
true
).
assertTrue
(
ProfileConnectionState
.
STATE_CONNECTING
!=
connState
);
expect
(
true
).
assertTrue
(
bluetooth
.
ProfileConnectionState
.
STATE_CONNECTED
!=
connState
);
expect
(
true
).
assertTrue
(
ProfileConnectionState
.
STATE_CONNECTED
!=
connState
);
expect
(
true
).
assertTrue
(
bluetooth
.
ProfileConnectionState
.
STATE_DISCONNECTING
!=
connState
);
expect
(
true
).
assertTrue
(
ProfileConnectionState
.
STATE_DISCONNECTING
!=
connState
);
done
();
done
();
})
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录