• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import btAccess from '@ohos.bluetooth.access';
17import a2dp from '@ohos.bluetooth.a2dp';
18import hid from '@ohos.bluetooth.hid';
19import hfp from '@ohos.bluetooth.hfp';
20import pan from '@ohos.bluetooth.pan';
21import map from '@ohos.bluetooth.map';
22import pbap from '@ohos.bluetooth.pbap';
23import bluetooth from '@ohos.bluetooth.baseProfile';
24import opp from '@ohos.bluetooth.opp';
25import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Level, Size } from '@ohos/hypium'
26import { UiComponent, UiDriver, BY, Component, Driver, UiWindow, ON, MatchPattern, DisplayRotation, ResizeDirection, UiDirection, MouseButton, WindowMode, PointerMatrix, UIElementInfo, UIEventObserver } from '@ohos.UiTest'
27
28    function sleep(delay : number) : Promise<void> {
29        return new Promise(resovle => setTimeout(resovle, delay))
30    }
31    async function openPhone() {
32        try{
33            let drivers = Driver.create();
34            console.info('[bluetooth_js] bt driver create:'+ drivers);
35            await drivers.delayMs(1000);
36            await drivers.wakeUpDisplay();
37            await drivers.delayMs(5000);
38            await drivers.swipe(1500, 1000, 1500, 100);
39            await drivers.delayMs(10000);
40        } catch (error) {
41            console.info('[bluetooth_js] driver error info:'+ error);
42        }
43    }
44
45    async function tryToEnableBt() {
46        let sta = btAccess.getState();
47        switch (sta) {
48            case 0:
49                btAccess.enableBluetooth();
50                await clickRequestPermission(OPEN_BT_TEXT);
51                await sleep(10000);
52                let sta1 = btAccess.getState();
53                console.info('[bluetooth_js] bt turn off:' + JSON.stringify(sta1));
54                break;
55            case 1:
56                console.info('[bluetooth_js] bt turning on:' + JSON.stringify(sta));
57                await sleep(3000);
58                break;
59            case 2:
60                console.info('[bluetooth_js] bt turn on:' + JSON.stringify(sta));
61                break;
62            case 3:
63                btAccess.enableBluetooth();
64                await clickRequestPermission(OPEN_BT_TEXT);
65                await sleep(10000);
66                let sta2 = btAccess.getState();
67                console.info('[bluetooth_js] bt turning off:' + JSON.stringify(sta2));
68                break;
69            default:
70                console.info('[bluetooth_js] enable success');
71        }
72    }
73
74    let PERMISSION_TEXT:string = "允许";
75    let OPEN_BT_TEXT:string = "开启";
76
77    async function clickRequestPermission(text:string) {
78        console.info('[bluetooth_js] clickRequestPermission start');
79        let driver = Driver.create();
80        await driver.delayMs(3000);
81        try {
82            let button = await driver.findComponent(ON.text(text));
83            await button.click();
84            await driver.delayMs(3000);
85            console.info('[bluetooth_js] clickRequestPermission end');
86        } catch (err) {
87            console.info('[bluetooth_js] clickRequestPermission failed. ' + err);
88        }
89        try {
90            let button1 = await driver.findComponent(ON.text("允许"));
91            await button1.click();
92            await driver.delayMs(3000);
93            console.info('[bluetooth_js] click 允许 end');
94        } catch (err) {
95            console.info('[bluetooth_js] click 允许 failed. ' + err);
96        }
97    }
98
99    function onReceiveEvent(data : bluetooth.StateChangeParam) {
100            console.info('connection state change:'+ JSON.stringify(data));
101        }
102    function onReceiveEvent1(data : bluetooth.StateChangeParam) {
103            console.info('connection StateChangeParam:'+ JSON.stringify(data));
104            console.info('connection StateChangeParam deviceId:'+ data.deviceId);
105            console.info('connection StateChangeParam state:'+ data.state);
106            console.info('connection StateChangeParam cause:'+ data.cause);
107        }
108    let A2dpSourceProfile : a2dp.A2dpSourceProfile = a2dp.createA2dpSrcProfile();
109    let HandsFreeAudioGatewayProfile : hfp.HandsFreeAudioGatewayProfile = hfp.createHfpAgProfile();
110    let HidHostProfile : hid.HidHostProfile = hid.createHidHostProfile();
111    let PanProfile : pan.PanProfile = pan.createPanProfile();
112
113export default function btBaseProfileTest() {
114describe('btBaseProfileTest', () => {
115
116
117    beforeAll(async (done : Function) =>  {
118        console.info('beforeAll called')
119        await clickRequestPermission(PERMISSION_TEXT);
120        await openPhone();
121        await tryToEnableBt();
122        expect(true).assertEqual(A2dpSourceProfile != null && HandsFreeAudioGatewayProfile != null && HidHostProfile != null && PanProfile != null);
123        done();
124    })
125    beforeEach(async (done : Function) =>  {
126        console.info('beforeEach called')
127        await tryToEnableBt()
128        done()
129    })
130    afterEach(() => {
131        console.info('afterEach called')
132    })
133    afterAll(() => {
134        console.info('afterAll called')
135    })
136
137    /**
138     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0100
139     * @tc.name testGetConnectedDevices
140     * @tc.desc Test getConnectedDevices api10.
141     * @tc.type Function
142     * @tc.size MediumTest
143     * @tc.level Level 1
144     */
145    it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
146        try {
147            let devices : Array<string> = A2dpSourceProfile.getConnectedDevices();
148            console.info("address of connected devices list:" + devices);
149            expect(true).assertEqual(devices != null);
150        } catch (err) {
151            console.error("bluetooth getConnectedDevices errCode:" + err.code + ",errMessage:" + err.message);
152            if (err.code == 801 || err.code == 2900004) {
153                console.info('[bluetooth_js]getConnectedDevices is not support or profile not support');
154                expect(true).assertTrue();
155            } else {
156                expect().assertFail();
157            }
158        }
159        done();
160    })
161
162    /**
163     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0200
164     * @tc.name testGetConnectionState
165     * @tc.desc Test getConnectionState api10.
166     * @tc.type Function
167     * @tc.size MediumTest
168     * @tc.level Level 1
169     */
170    it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
171        try {
172            let state : bluetooth.ProfileConnectionState = A2dpSourceProfile.getConnectionState("11:22:33:AA:BB:FF");
173            console.info("the connection state:" + state);
174            expect(true).assertEqual(state == 0 || state == 1 || state == 2);
175        } catch (err) {
176            console.error("bluetooth getConnectionState errCode:" + err.code + ",errMessage:" + err.message);
177            if (err.code == 801 || err.code == 2900004) {
178                console.info('[bluetooth_js]getConnectionState is not support or profile not support');
179                expect(true).assertTrue();
180            } else {
181                expect(Number(err.code)).assertEqual(2900099);
182            }
183        }
184        done();
185    })
186
187    /**
188     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0300
189     * @tc.name testOnConnectionStateChange
190     * @tc.desc Test on type: 'connectionStateChange' api10.
191     * @tc.type Function
192     * @tc.size MediumTest
193     * @tc.level Level 1
194     */
195     it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0300', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
196        try {
197            A2dpSourceProfile.on('connectionStateChange', onReceiveEvent);
198        } catch (err) {
199            console.error("bluetooth connectionStateChange errCode:" + err.code + ",errMessage:" + err.message);
200            if (err.code == 801) {
201                console.info('[bluetooth_js]connectionStateChange is not support');
202                expect(true).assertTrue();
203            } else {
204                expect().assertFail();
205            }
206        }
207        A2dpSourceProfile.off('connectionStateChange', onReceiveEvent);
208        done();
209    })
210
211    /**
212     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0400
213     * @tc.name testOnConnectionStateChange
214     * @tc.desc Test off type: 'connectionStateChange' api10.
215     * @tc.type Function
216     * @tc.size MediumTest
217     * @tc.level Level 1
218     */
219     it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0400', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
220        A2dpSourceProfile.on('connectionStateChange', onReceiveEvent);
221        try {
222            A2dpSourceProfile.off('connectionStateChange', onReceiveEvent);
223        } catch (err) {
224            console.error("bluetooth connectionStateChange errCode:" + err.code + ",errMessage:" + err.message);
225            if (err.code == 801) {
226                console.info('[bluetooth_js]connectionStateChange is not support');
227                expect(true).assertTrue();
228            } else {
229                expect().assertFail();
230            }
231        }
232        done();
233    })
234
235    /**
236     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1800
237     * @tc.name testOnConnectionStateChange
238     * @tc.desc Test on type: 'connectionStateChange' api10.
239     * @tc.type Function
240     * @tc.size MediumTest
241     * @tc.level Level 2
242     */
243     it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1800', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
244        try {
245            A2dpSourceProfile.on('connectionStateChange', null);
246        } catch (err) {
247            console.info("connectionStateChange errCode:" + err.code + ",errMessage:" + err.message);
248            expect(Number(err.code)).assertEqual(401);
249        }
250        done();
251    })
252
253    /**
254     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1900
255     * @tc.name testOnConnectionStateChange
256     * @tc.desc Test on type: 'connectionStateChange' api10.
257     * @tc.type Function
258     * @tc.size MediumTest
259     * @tc.level Level 2
260     */
261     it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1900', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
262        try {
263            A2dpSourceProfile.off('connectionStateChange', null);
264        } catch (err) {
265            console.info("connectionStateChange errCode:" + err.code + ",errMessage:" + err.message);
266            expect(Number(err.code)).assertEqual(401);
267        }
268        done();
269    })
270
271    /**
272     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0500
273     * @tc.name testGetConnectedDevices
274     * @tc.desc Test getConnectedDevices api10.
275     * @tc.type Function
276     * @tc.size MediumTest
277     * @tc.level Level 1
278     */
279     it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0500', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
280        try {
281            let devices : Array<string> = HandsFreeAudioGatewayProfile.getConnectedDevices();
282            console.info("address of connected devices list:" + devices);
283            expect(true).assertEqual(devices != null);
284        } catch (err) {
285            console.error("bluetooth getConnectedDevices errCode:" + err.code + ",errMessage:" + err.message);
286            expect(true).assertFalse();
287        }
288        done();
289    })
290
291    /**
292     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0600
293     * @tc.name testGetConnectionState
294     * @tc.desc Test getConnectionState api10.
295     * @tc.type Function
296     * @tc.size MediumTest
297     * @tc.level Level 1
298     */
299    it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0600', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
300        try {
301            let state : bluetooth.ProfileConnectionState = HandsFreeAudioGatewayProfile.getConnectionState("11:22:33:AA:BB:FF");
302            console.info("the connection state:" + state);
303            expect(true).assertEqual(state == 0 || state == 1 || state == 2);
304        } catch (err) {
305            console.error("bluetooth getConnectionState errCode:" + err.code + ",errMessage:" + err.message);
306            expect(Number(err.code)).assertEqual(2900099);
307        }
308        done();
309    })
310
311    /**
312     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0700
313     * @tc.name testOnConnectionStateChange
314     * @tc.desc Test on type: 'connectionStateChange' api10.
315     * @tc.type Function
316     * @tc.size MediumTest
317     * @tc.level Level 1
318     */
319     it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0700', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
320        try {
321            HandsFreeAudioGatewayProfile.on('connectionStateChange', onReceiveEvent1);
322        } catch (err) {
323            console.error("bluetooth connectionStateChange errCode:" + err.code + ",errMessage:" + err.message);
324            expect(true).assertFalse();
325        }
326        HandsFreeAudioGatewayProfile.off('connectionStateChange', onReceiveEvent1);
327        done();
328    })
329
330    /**
331     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0800
332     * @tc.name testOnConnectionStateChange
333     * @tc.desc Test off type: 'connectionStateChange' api10.
334     * @tc.type Function
335     * @tc.size MediumTest
336     * @tc.level Level 1
337     */
338     it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0800', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
339        HandsFreeAudioGatewayProfile.on('connectionStateChange', onReceiveEvent);
340        try {
341            HandsFreeAudioGatewayProfile.off('connectionStateChange', onReceiveEvent);
342        } catch (err) {
343            console.error("bluetooth connectionStateChange errCode:" + err.code + ",errMessage:" + err.message);
344            expect(true).assertFalse();
345        }
346        done();
347    })
348
349    /**
350     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0900
351     * @tc.name testGetConnectedDevices
352     * @tc.desc Test getConnectedDevices api10.
353     * @tc.type Function
354     * @tc.size MediumTest
355     * @tc.level Level 1
356     */
357     it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_0900', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
358        try {
359            let devices : Array<string> = HidHostProfile.getConnectedDevices();
360            console.info("address of connected devices list:" + devices);
361            expect(true).assertEqual(devices != null);
362        } catch (err) {
363            console.error("bluetooth getConnectedDevices errCode:" + err.code + ",errMessage:" + err.message);
364            expect(true).assertFalse();
365        }
366        done();
367    })
368
369    /**
370     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1000
371     * @tc.name testGetConnectionState
372     * @tc.desc Test getConnectionState api10.
373     * @tc.type Function
374     * @tc.size MediumTest
375     * @tc.level Level 1
376     */
377    it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1000', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
378        try {
379            let state : bluetooth.ProfileConnectionState = HidHostProfile.getConnectionState("11:22:33:AA:BB:FF");
380            console.info("the connection state:" + state);
381            expect(true).assertEqual(state == 0 || state == 1 || state == 2);
382        } catch (err) {
383            console.error("bluetooth getConnectionState errCode:" + err.code + ",errMessage:" + err.message);
384            expect(Number(err.code)).assertEqual(2900099);
385        }
386        done();
387    })
388
389    /**
390     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1100
391     * @tc.name testOnConnectionStateChange
392     * @tc.desc Test on type: 'connectionStateChange' api10.
393     * @tc.type Function
394     * @tc.size MediumTest
395     * @tc.level Level 1
396     */
397     it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
398        try {
399            HidHostProfile.on('connectionStateChange', onReceiveEvent);
400        } catch (err) {
401            console.error("bluetooth connectionStateChange errCode:" + err.code + ",errMessage:" + err.message);
402            expect(true).assertFalse();
403        }
404        HidHostProfile.off('connectionStateChange', onReceiveEvent);
405        done();
406    })
407
408    /**
409     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1200
410     * @tc.name testOnConnectionStateChange
411     * @tc.desc Test off type: 'connectionStateChange' api10.
412     * @tc.type Function
413     * @tc.size MediumTest
414     * @tc.level Level 1
415     */
416     it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1200', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
417        HidHostProfile.on('connectionStateChange', onReceiveEvent);
418        try {
419            HidHostProfile.off('connectionStateChange', onReceiveEvent);
420        } catch (err) {
421            console.error("bluetooth connectionStateChange errCode:" + err.code + ",errMessage:" + err.message);
422            expect(true).assertFalse();
423        }
424        done();
425    })
426
427    /**
428     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1300
429     * @tc.name testGetConnectedDevices
430     * @tc.desc Test getConnectedDevices api10.
431     * @tc.type Function
432     * @tc.size MediumTest
433     * @tc.level Level 1
434     */
435     it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1300', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
436        try {
437            let devices : Array<string> = PanProfile.getConnectedDevices();
438            console.info("address of connected devices list:" + devices);
439            expect(true).assertEqual(devices != null);
440        } catch (err) {
441            console.error("bluetooth getConnectedDevices errCode:" + err.code + ",errMessage:" + err.message);
442            expect(Number(err.code)).assertEqual(2900008);
443        }
444        done();
445    })
446
447    /**
448     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1400
449     * @tc.name testGetConnectionState
450     * @tc.desc Test getConnectionState api10.
451     * @tc.type Function
452     * @tc.size MediumTest
453     * @tc.level Level 1
454     */
455    it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1400', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
456        try {
457            let state : bluetooth.ProfileConnectionState= PanProfile.getConnectionState("11:22:33:AA:BB:FF");
458            console.info("the connection state:" + state);
459            expect(true).assertEqual(state == 0 || state == 1 || state == 2);
460        } catch (err) {
461            console.error("bluetooth getConnectionState errCode:" + err.code + ",errMessage:" + err.message);
462            expect(Number(err.code)).assertEqual(2900008);
463        }
464        done();
465    })
466
467    /**
468     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1500
469     * @tc.name testOnConnectionStateChange
470     * @tc.desc Test on type: 'connectionStateChange' api10.
471     * @tc.type Function
472     * @tc.size MediumTest
473     * @tc.level Level 1
474     */
475     it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1500', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
476        try {
477            PanProfile.on('connectionStateChange', onReceiveEvent);
478        } catch (err) {
479            console.error("bluetooth connectionStateChange errCode:" + err.code + ",errMessage:" + err.message);
480            expect(true).assertFalse();
481        }
482        PanProfile.off('connectionStateChange', onReceiveEvent);
483        done();
484    })
485
486    /**
487     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1600
488     * @tc.name testOnConnectionStateChange
489     * @tc.desc Test off type: 'connectionStateChange' api10.
490     * @tc.type Function
491     * @tc.size MediumTest
492     * @tc.level Level 1
493     */
494     it('SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1600', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
495        PanProfile.on('connectionStateChange', onReceiveEvent);
496        try {
497            PanProfile.off('connectionStateChange', onReceiveEvent);
498        } catch (err) {
499            console.error("bluetooth connectionStateChange errCode:" + err.code + ",errMessage:" + err.message);
500            expect(true).assertFalse();
501        }
502        done();
503    })
504
505    /**
506     * @tc.number SUB_COMMUNICATION_BLUETOOTH_BASEPROFILE_1700
507     * @tc.name testcreateSrcProfile
508     * @tc.desc Test createA2dpSrcProfile/createHfpAgProfile/createHidHostProfile/createPanProfile api10.
509     * @tc.type Function
510     * @tc.size MediumTest
511     * @tc.level Level 1
512     */
513     it('SUB_COMMUNICATION_BLUETOOTHA2DP_STATE_1700', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
514        try {
515            let asp = a2dp.createA2dpSrcProfile();
516            expect(true).assertEqual(asp != null);
517        } catch  (err) {
518            console.error("bluetooth createA2dpSrcProfile errCode:" + err.code + ",errMessage:" + err.message);
519            if (err.code == 801) {
520                console.info('[bluetooth_js]createA2dpSrcProfile is not support');
521                expect(true).assertTrue();
522            } else {
523                expect().assertFail();
524            }
525        }
526
527        try {
528            let hp = hfp.createHfpAgProfile();
529            expect(true).assertEqual(hp != null);
530        } catch  (err) {
531            console.error("bluetooth createHfpAgProfile errCode:" + err.code + ",errMessage:" + err.message);
532            if (err.code == 801) {
533                console.info('[bluetooth_js]createHfpAgProfile is not support');
534                expect(true).assertTrue();
535            } else {
536                expect().assertFail();
537            }
538        }
539
540        try {
541            let hhp = hid.createHidHostProfile();
542            expect(true).assertEqual(hhp != null);
543        } catch  (err) {
544            console.error("bluetooth createHidHostProfile errCode:" + err.code + ",errMessage:" + err.message);
545            if (err.code == 801) {
546                console.info('[bluetooth_js]createHidHostProfile is not support');
547                expect(true).assertTrue();
548            } else {
549                expect().assertFail();
550            }
551        }
552
553        try {
554            let pp = pan.createPanProfile();
555            expect(true).assertEqual(pp != null);
556        } catch  (err) {
557            console.error("bluetooth createPanProfile errCode:" + err.code + ",errMessage:" + err.message);
558            if (err.code == 801) {
559                console.info('[bluetooth_js]createPanProfile is not support');
560                expect(true).assertTrue();
561            } else {
562                expect().assertFail();
563            }
564        }
565        done();
566    })
567
568    /**
569     * @tc.number SUB_COMMUNICATION_BLUETOOTH_MAP_0100
570     * @tc.name testCreateMapMseProfile
571     * @tc.desc Test createMapMseProfile api11.
572     * @tc.type Function
573     * @tc.size MediumTest
574     * @tc.level Level 1
575     */
576     it('SUB_COMMUNICATION_BLUETOOTH_MAP_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
577        try {
578            let mapMseProfile = map.createMapMseProfile();
579            console.info('MapMse success' + mapMseProfile);
580            expect(true).assertEqual(mapMseProfile != null);
581        } catch (err) {
582            console.error("bluetooth map createMapMseProfile errCode:" + err.code + ",errMessage:" + err.message);
583            if (err.code == 801) {
584                console.info('[bluetooth_js]createMapMseProfile is not support');
585                expect(true).assertTrue();
586            } else {
587                expect().assertFail();
588            }
589        }
590        done();
591    })
592
593    /**
594     * @tc.number SUB_COMMUNICATION_BLUETOOTH_PBAP_0100
595     * @tc.name testCreatePbapServerProfile
596     * @tc.desc Test createPbapServerProfile api11.
597     * @tc.type Function
598     * @tc.size MediumTest
599     * @tc.level Level 1
600     */
601     it('SUB_COMMUNICATION_BLUETOOTH_PBAP_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
602        try {
603            let pbapServerProfile = pbap.createPbapServerProfile();
604            console.info('pbapServer success' + pbapServerProfile);
605            expect(true).assertEqual(pbapServerProfile != null);
606        } catch (err) {
607            console.error("bluetooth pbap pbapServerProfile errCode:" + err.code + ",errMessage:" + err.message);
608            if (err.code == 801) {
609                console.info('[bluetooth_js]createPbapServerProfile is not support');
610                expect(true).assertTrue();
611            } else {
612                expect().assertFail();
613            }
614        }
615        done();
616    })
617
618    /**
619     * @tc.number SUB_COMMUNICATION_BLUETOOTHPROFILE_CONSTANT_0100
620     * @tc.name testDisconnectCause
621     * @tc.desc Test DisconnectCause api12.
622     * @tc.type Function
623     * @tc.size MediumTest
624     * @tc.level Level 1
625     */
626     it('SUB_COMMUNICATION_BLUETOOTHPROFILE_CONSTANT_0100', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL2, async (done : Function) =>  {
627        try {
628            let userDisconnect = bluetooth.DisconnectCause.USER_DISCONNECT;
629            let connectFromKeyboard = bluetooth.DisconnectCause.CONNECT_FROM_KEYBOARD;
630            let connectFromMouse = bluetooth.DisconnectCause.CONNECT_FROM_MOUSE;
631            let connectFromCar = bluetooth.DisconnectCause.CONNECT_FROM_CAR;
632            let tooManyConnectedDevices = bluetooth.DisconnectCause.TOO_MANY_CONNECTED_DEVICES;
633            let connectFailInternal = bluetooth.DisconnectCause.CONNECT_FAIL_INTERNAL;
634
635            expect(userDisconnect).assertEqual(0);
636            expect(connectFromKeyboard).assertEqual(1);
637            expect(connectFromMouse).assertEqual(2);
638            expect(connectFromCar).assertEqual(3);
639            expect(tooManyConnectedDevices).assertEqual(4);
640            expect(connectFailInternal).assertEqual(5);
641        } catch (err) {
642            console.info("DisconnectCause errCode:" + err.code + ",errMessage:" + err.message);
643            expect().assertFail();
644        }
645        done();
646    })
647})
648}