3 Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
9 http://www.apache.org/licenses/LICENSE-2.0
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.
18 Xiaoyan Qian <xy.qian@samsung.com>
23 <title>BluetoothGATTDescriptor_writeValue_successCallback_TypeMismatch</title>
24 <meta charset="utf-8"/>
25 <script src="support/unitcommon.js"></script>
26 <script src="support/bluetooth_common.js"></script>
31 //==== TEST: BluetoothGATTDescriptor_writeValue_successCallback_TypeMismatch
32 //==== LABEL Check if writeValue throws exception when successCallback is incorrect
33 //==== EXECUTION_TYPE manual
34 //==== ONLOAD_DELAY 30
35 //==== SPEC Tizen Web API:TBD:Bluetooth:BluetoothGATTDescriptor:writeValue M
38 //==== PRE The bluetooth of the remote/test device MUST support BLE and be turned on and discoverable from other devices.
39 //==== TEST_CRITERIA MC
41 setup({timeout: 60000});
43 var t = async_test(document.title, {timeout: 60000}), adapter, bleScanSuccessCallback, bleScanErrorCallback, service, device = null, flag = false,
44 onconnected, onerror, characteristic, descriptor, WriteValueSuccessCallback, conversionTable, exceptionName, i, data = new Array(1, 2, 3, 4, 5, 6), j;
47 conversionTable = getTypeConversionExceptions("functionObject", true);
49 onconnected = t.step_func(function () {
50 service = device.getService(device.uuids[0]);
51 for (j = 0; j < service.characteristics.length; j++) {
52 characteristic = service.characteristics[j];
53 if (characteristic != undefined) {
54 descriptor = characteristic.descriptors[0];
55 if (descriptor != undefined) {
56 for (i = 0; i < conversionTable.length; i++) {
57 WriteValueSuccessCallback = conversionTable[i][0];
58 exceptionName = conversionTable[i][1];
59 assert_throws({name: exceptionName},
61 descriptor.writeValue(data, WriteValueSuccessCallback);
62 }, "Given incorrect success callback.");
71 onerror = t.step_func(function (error) {
72 assert_unreached("connect() error callback was invoked: " + error.name + " msg: " + error.message);
75 bleScanSuccessCallback = t.step_func(function (bledevice) {
76 if (bledevice.address == REMOTE_BLE_DEVICE_ADDRESS && device == null) {
80 device.connect(onconnected, onerror);
86 bleScanErrorCallback = t.step_func(function (error) {
87 assert_unreached("startScan() error callback was invoked: " + error.name + " msg: " + error.message);
90 adapter = tizen.bluetooth.getLEAdapter();
92 adapter.startScan(bleScanSuccessCallback, bleScanErrorCallback);