9a9a0698ae93e89148d86403ed54da69c556c20a
[test/tct/web/api.git] /
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2015 Samsung Electronics Co., Ltd.
4
5 Licensed under the Apache License, Version 2.0 (the License);
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9     http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16
17 Authors:
18         Lei Tang <lei312.tang@samsung.com>
19
20 -->
21 <html>
22 <head>
23 <title>BluetoothLEAdapter_startAdvertise_packetType_TypeMismatch</title>
24 <meta charset="utf-8"/>
25 <script src="support/unitcommon.js"></script>
26 <script src="support/bluetooth_common.js"></script>
27 </head>
28 <body>
29 <div id="log"></div>
30 <script>
31 //==== TEST: BluetoothLEAdapter_startAdvertise_packetType_TypeMismatch
32 //==== LABEL Check whether startAdvertise() method called with invalid packetType argument throws an exception
33 //==== PRIORITY P2
34 //==== ONLOAD_DELAY 180
35 //==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothAdapter:startAdvertise M
36 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/bluetooth.html
37 //==== TEST_CRITERIA MC
38
39 setup({timeout: 180000});
40
41 var adapter = null, t = async_test(document.title, {timeout: 180000}), exceptionName, i, packetType,
42     conversionTable, errorCallback, successCallback, advertiseDataInit, advertiseData;
43
44 t.step(function () {
45
46     advertiseDataInit = {
47         includeName: true,
48         includeTxPowerLevel: true,
49         appearance: 192,
50         serviceuuids: ["180f"],
51         solicitationuuids: ["180d"]
52     };
53
54     successCallback = t.step_func(function () {
55         assert_unreached("SuccessCallback should not be invoked");
56     });
57
58     errorCallback = t.step_func(function (e) {
59         assert_unreached("errorCallback exception:" + e.message);
60     });
61
62     adapter = tizen.bluetooth.getLEAdapter();
63     advertiseData = new tizen.BluetoothLEAdvertiseData(advertiseDataInit);
64     conversionTable = getTypeConversionExceptions("enum", false);
65     for(i = 0; i < conversionTable.length; i++) {
66         packetType = conversionTable[i][0];
67         exceptionName = conversionTable[i][1];
68
69         assert_throws({name: exceptionName},
70             function () {
71                 adapter.startAdvertise(advertiseData, packetType, successCallback, errorCallback, "BALANCED", true);
72             }, "Given incorrect packetType.");
73     }
74     t.done();
75 });
76
77 </script>
78 </body>
79 </html>