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_writeValue_successCallback_invalid_cb</title>
25 <meta charset="utf-8"/>
26 <script src="support/unitcommon.js"></script>
27 <script src="support/bluetooth_common.js"></script>
32 //==== TEST: BluetoothGATTCharacteristic_writeValue_successCallback_invalid_cb
33 //==== LABEL Check if BluetoothGATTCharacteristic::writeValue method throws exception when invalid success callback is given
35 //==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothGATTCharacteristic:writeValue 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 MTCB
41 setup({timeout: 60000});
43 var t = async_test(document.title, {timeout: 60000}), adapter, bleScanSuccessCallback, bleScanRrrorCallback, flag = false, i,
44 onconnected, onerror, service, characteristic, device = null, invalidSuccessCallback, data = new Array(1, 2, 3, 4, 5, 6);
47 invalidSuccessCallback = {
48 onsuccess: t.step_func(function () {
49 assert_unreached("Invalid successCallback invoked.");
53 onconnected = t.step_func(function () {
54 service = device.getService(device.uuids[0]);
55 if (service.characteristics.length > 0) {
56 for(i = 0; i < service.characteristics.length; i++) {
57 if(service.characteristics[i].isWritable == true) {
58 characteristic = service.characteristics[i];
59 assert_throws(TYPE_MISMATCH_EXCEPTION, function () {
60 characteristic.writeValue(data, invalidSuccessCallback);
61 }, "TypeMismatchError" + " should be thrown - given invalid success callback.");
69 onerror = t.step_func(function (error) {
70 assert_unreached("connect() error callback was invoked: " + error.name + " msg: " + error.message);
73 bleScanSuccessCallback = t.step_func(function (bledevice) {
74 if (bledevice.address == REMOTE_BLE_DEVICE_ADDRESS && device == null) {
78 device.connect(onconnected, onerror);
84 bleScanRrrorCallback = t.step_func(function (error) {
85 assert_unreached("startScan() error callback was invoked: " + error.name + " msg: " + error.message);
88 adapter = tizen.bluetooth.getLEAdapter();
90 adapter.startScan(bleScanSuccessCallback, bleScanRrrorCallback);