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 Qunfang Lin <qunfang.lin@samsung.com>
24 <title>BluetoothGATTCharacteristic_readValue_errorCallback_TypeMismatch</title>
25 <meta charset="utf-8"/>
26 <script src="support/unitcommon.js"></script>
27 <script src="support/bluetooth_common.js"></script>
32 //==== TEST: BluetoothGATTCharacteristic_readValue_errorCallback_TypeMismatch
33 //==== LABEL Check if BluetoothGATTCharacteristic::readValue method called with invalid errorCallback argument throws an exception
35 //==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothGATTCharacteristic:readValue M
37 //==== EXECUTION_TYPE manual
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, bleScanRrrorCallback, flag = false, j,
44 onconnected, onerror, service, characteristic, device = null, conversionTable, i, exceptionName, ReadValueSuccessCallback, errorCallback;
47 ReadValueSuccessCallback = t.step_func(function (value) {
48 assert_unreached("Method readValue shouldn't end successfully. Given incorrect errorCallback.");
51 onconnected = t.step_func(function () {
52 service = device.getService(device.uuids[0]);
53 if (service.characteristics.length > 0) {
54 for(j = 0; j < service.characteristics.length; j++) {
55 if(service.characteristics[j].isReadable == true) {
56 characteristic = service.characteristics[j];
57 conversionTable = getTypeConversionExceptions("functionObject", true);
58 for (i = 0; i < conversionTable.length; i++) {
59 errorCallback = conversionTable[i][0];
60 exceptionName = conversionTable[i][1];
62 assert_throws({name: exceptionName},
64 characteristic.readValue(ReadValueSuccessCallback, errorCallback);
65 }, "Given incorrect errorCallback.");
74 onerror = t.step_func(function (error) {
75 assert_unreached("connect() error callback was invoked: " + error.name + " msg: " + error.message);
78 bleScanSuccessCallback = t.step_func(function (bledevice) {
79 if (bledevice.address == REMOTE_BLE_DEVICE_ADDRESS && device == null) {
83 device.connect(onconnected, onerror);
89 bleScanRrrorCallback = t.step_func(function (error) {
90 assert_unreached("startScan() error callback was invoked: " + error.name + " msg: " + error.message);
93 adapter = tizen.bluetooth.getLEAdapter();
95 adapter.startScan(bleScanSuccessCallback, bleScanRrrorCallback);