3 Copyright (c) 2012 Intel Corporation.
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
8 * Redistributions of works must retain the original copyright notice, this list
9 of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the original copyright notice,
11 this list of conditions and the following disclaimer in the documentation
12 and/or other materials provided with the distribution.
13 * Neither the name of Intel Corporation nor the names of its contributors
14 may be used to endorse or promote products derived from this work without
15 specific prior written permission.
17 THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
21 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 Lei, ZhanX <zhanx.lei@intel.com>
30 Lukasz Bardeli <l.bardeli@samsung.com>
36 <title>bluetooth.adapter.registerRFCOMMServiceByUUID() - on connect successful</title>
37 <script src="../resources/unitcommon.js"></script>
38 <script src="support/bluetooth_common.js"></script>
43 //==== TEST: BluetoothAdapter_registerRFCOMMServiceByUUID_onconnect_successful
44 //==== LABEL check whether a service record is registered and onconnect is called
46 //==== EXECUTION_TYPE manual
47 //==== STEP Push [Search] button on the remote device after pop-up is launched.
48 //==== EXPECT The test device is found by the remote device.
49 //==== STEP Push [Connect to service] button on the remote device after selecting test device among found devices.
50 //==== EXPECT onconnect is called.
51 //==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothAdapter:registerRFCOMMServiceByUUID M
52 //==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/bluetooth.html
53 //==== PRE tct-bt-helper MUST be launched on the remote device.
54 //==== TEST_CRITERIA MOA MAST
55 setup({timeout:90000});
56 var adapter = null,t = async_test("BluetoothAdapter_registerRFCOMMServiceByUUID_onconnect_successful",{timeout:90000}),
57 registerRFCOMMServiceByUUIDSuccess, registerRFCOMMServiceByUUIDError, powerOnSuccess, powerOnError, serviceHandler,
58 visibleSuccess, visibleError;
61 add_result_callback(function (res) {
62 serviceHandler.unregister();
65 registerRFCOMMServiceByUUIDSuccess = t.step_func(function (recordHandler) {
66 serviceHandler = recordHandler;
67 recordHandler.onconnect = t.step_func(function (socket) {
68 if(recordHandler !== null) {
69 recordHandler.unregister(function() {
75 alert("1. Push \"Search\" button on the remote device.\n" +
76 "2. Select this device among found devices after discovering is finished.\n" +
77 "3. Push \"Connect to service\" button on the remote device.");
80 registerRFCOMMServiceByUUIDError = t.step_func(function (e) {
81 assert_unreached("registerRFCOMMServiceByUUIDError exception:" + e.message);
84 visibleSuccess = t.step_func(function () {
85 adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", registerRFCOMMServiceByUUIDSuccess, registerRFCOMMServiceByUUIDError);
88 visibleError = t.step_func(function (e) {
89 assert_unreached("setVisible exception:" + e.message);
92 powerOnSuccess = t.step_func(function () {
93 adapter.setVisible(true, visibleSuccess, visibleError);
96 powerOnError = t.step_func(function (e) {
97 assert_unreached("powerOnError exception:" + e.message);
100 adapter = tizen.bluetooth.getDefaultAdapter();
102 adapter.setPowered(true,powerOnSuccess,powerOnError);