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_InvalidStateError</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_InvalidStateError
33 //==== LABEL Check if BluetoothGATTCharacteristic::readValue method called when device is not connected 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,
44 service, characteristic, ReadValueSuccessCallback;
47 ReadValueSuccessCallback = t.step_func(function (value) {
48 assert_unreached("Method readValue shouldn't end successfully.");
51 bleScanSuccessCallback = {
52 onstarted: t.step_func(function () {
54 ondevicefound: t.step_func(function (device) {
55 if(device.address == REMOTE_BLE_DEVICE_ADDRESS){
57 service = device.getService(device.uuids[0]);
58 if (service.characteristics.length > 0) {
59 characteristic = service.characteristics[0];
60 assert_throws(INVALID_STATE_ERR, function () {
61 characteristic.readValue(ReadValueSuccessCallback);
62 }, INVALID_STATE_ERR + " should be thrown - if device is not connected.");
67 onfinished: t.step_func(function (devices) {
71 bleScanRrrorCallback = t.step_func(function (error) {
72 assert_unreached("startScan() error callback was invoked: " + error.name + " msg: " + error.message);
75 adapter = tizen.bluetooth.getLEAdapter();
76 adapter.startScan(bleScanSuccessCallback, bleScanRrrorCallback);