-<!DOCTYPE html>\r
-<!--\r
-\r
-Copyright (c) 2013 Samsung Electronics Co., Ltd. All Rights Reserved\r
-\r
-Licensed under the Apache License, Version 2.0 (the License);\r
-you may not use this file except in compliance with the License.\r
-You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-Unless required by applicable law or agreed to in writing, software\r
-distributed under the License is distributed on an "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-See the License for the specific language governing permissions and\r
-limitations under the License.\r
-\r
-\r
-\r
-Authors:\r
- Witold Choinkowski <w.choinkowsk@samsung.com>\r
- Arkadiusz Pietraszek <a.pietraszek@samsung.com>\r
-\r
--->\r
-<html>\r
-<head>\r
-<title>BluetoothSocket</title>\r
-<script src="support/unitcommon.js"></script>\r
-<script src="support/bluetooth_common.js"></script>\r
-</head>\r
-<body>\r
-\r
-<div id="log"></div>\r
-<script>\r
-//==== TEST: BluetoothSocket\r
-//==== LABEL Check BluetoothSocket attributes and functions\r
-//==== EXECUTION_TYPE manual\r
-//==== PRIORITY P3\r
-//==== STEP several tests executed from base test\r
-//==== EXPECT all subtests should be successful\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:close M\r
-//==== TEST_CRITERIA ME\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:close M\r
-//==== TEST_CRITERIA MNAEX\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:BluetoothSocket U\r
-//==== TEST_CRITERIA OBX\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:onclose A\r
-//==== TEST_CRITERIA AE ADV\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:onmessage A\r
-//==== TEST_CRITERIA AE ADV\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:peer A\r
-//==== TEST_CRITERIA AE AT ARO\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:readData M\r
-//==== TEST_CRITERIA ME\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:readData M\r
-//==== TEST_CRITERIA MNAEX\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:state A\r
-//==== TEST_CRITERIA AE AT ARO\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocketSuccessCallback:onsuccess M\r
-//==== TEST_CRITERIA CBT CBOA\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:uuid A\r
-//==== TEST_CRITERIA AE AT ARO\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:writeData M\r
-//==== TEST_CRITERIA ME\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:writeData M\r
-//==== TEST_CRITERIA MMA\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:writeData M\r
-//==== TEST_CRITERIA MC\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:close M\r
-//==== TEST_CRITERIA MNA MNAST\r
-//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/bluetooth.html\r
-//==== PRE The bluetooth of the remote/test device MUST be turned on and discoverable from other devices. The remote device MUST register the service by pushing [Register service] button on tct-bt-helper.\r
-\r
-setup({timeout: 180000});\r
-var t = async_test(document.title, {timeout: 180000}), adapter, onSocketConnect, onSocketError,\r
- gotDeviceInfo, gotDeviceError, onBondingSuccess, onBondingError, powerOnSuccess,\r
- peerCP, fakePeer, skState, skUuid, param, i;\r
-t.step(function () {\r
- if (BT_SUPPORT) { // network.bluetooth support\r
- add_result_callback(function () {\r
- clearBonding(REMOTE_DEVICE_ADDRESS);\r
- });\r
-\r
- onSocketConnect = t.step_func(function (socket) {\r
- //BluetoothSocket_close_exist ME\r
- test(function () {\r
- assert_true("close" in socket, "close in onSocketConnect");\r
- check_method_exists(socket, "close");\r
- }, "BluetoothSocket_close_exist");\r
-\r
- //BluetoothSocket_extend OBX\r
- test(function () {\r
- check_extensibility(socket);\r
- }, "BluetoothSocket_extend");\r
-\r
- //BluetoothSocket_onclose_property_exists AE ADV\r
- test(function () {\r
- assert_true("onclose" in socket, "onclose in onSocketConnect");\r
- assert_equals(socket.onclose, null, "onclose in BluetoothSocket has wrong default value");\r
- }, "BluetoothSocket_onclose_property_exists");\r
-\r
- //BluetoothSocket_onmessage_property_exists AE ADV\r
- test(function () {\r
- assert_true("onmessage" in socket, "onmessage in onSocketConnect");\r
- assert_equals(socket.onmessage, null, "onmessage in BluetoothSocket has wrong default value");\r
- }, "BluetoothSocket_onmessage_property_exists");\r
-\r
- //BluetoothSocket_peer_attribute AE AT ARO\r
- test(function () {\r
- assert_own_property(socket, "peer", "socket does not own peer property.");\r
- assert_own_property(socket.peer, "name", "socket.peer does not own name property.");\r
- assert_own_property(socket.peer, "address", "socket.peer does not own address property.");\r
- assert_own_property(socket.peer, "deviceClass", "socket.peer does not own deviceClass property.");\r
- assert_own_property(socket.peer, "isBonded", "socket.peer does not own isBonded property.");\r
- assert_own_property(socket.peer, "isTrusted", "socket.peer does not own isTrusted property.");\r
- assert_own_property(socket.peer, "isConnected", "socket.peer does not own isConnected property.");\r
- assert_own_property(socket.peer, "uuids", "socket.peer does not own uuids property.");\r
-\r
- assert_type(socket.peer, "object", "Type of deviceClass is different.");\r
-\r
- //peer is obtained by getter so I can not directly test the override\r
- peerCP = socket.peer;\r
- fakePeer = {\r
- name: "fakeName",\r
- address: "00:02:18:2F:78:32",\r
- deviceClass: {},\r
- isBonded: true,\r
- isTrusted: true,\r
- isConnected: true,\r
- uuids: [],\r
-\r
- connectToServiceByUUID: function () { }\r
- };\r
- socket.peer = fakePeer;\r
- assert_equals(socket.peer.name, peerCP.name, "peer can be modified.");\r
- assert_equals(socket.peer.address, peerCP.address, "peer can be modified.");\r
- assert_equals(socket.peer.isBonded, peerCP.isBonded, "peer can be modified.");\r
- assert_equals(socket.peer.isTrusted, peerCP.isTrusted, "peer can be modified.");\r
- assert_equals(socket.peer.isConnected, peerCP.isConnected, "peer can be modified.");\r
- assert_array_equals(socket.peer.uuids, peerCP.uuids, "deviceClass can be modified.");\r
- }, "BluetoothSocket_peer_attribute");\r
-\r
- //BluetoothSocket_readData_exist ME\r
- test(function () {\r
- assert_true("readData" in socket, "readData in onSocketConnect");\r
- check_method_exists(socket, "readData");\r
- }, "BluetoothSocket_readData_exist");\r
-\r
- //BluetoothSocket_readData_extra_argument MNAEX\r
- test(function () {\r
- checkExtraArgument(socket, "readData");\r
- }, "BluetoothSocket_readData_extra_argument");\r
-\r
- //BluetoothSocket_state_attribute AE AT ARO\r
- test(function () {\r
- skState = socket.state;\r
- check_readonly(socket, "state", skState, "string", "1234");\r
- }, "BluetoothSocket_state_attribute");\r
-\r
- //BluetoothSocketSuccessCallback_onsuccess CBT CBOA\r
- test(function () {\r
- assert_true("uuid" in socket, "No uuid in socket");\r
- assert_true("state" in socket, "No state in socket");\r
- assert_true("peer" in socket, "No peer in socket");\r
- assert_true("onmessage" in socket, "No onmessage in socket");\r
- assert_true("onclose" in socket, "No onclose in socket");\r
- assert_type(socket.writeData, "function", "Method writeData does not exist.");\r
- assert_type(socket.readData, "function", "Method readData does not exist.");\r
- assert_type(socket.close, "function", "Method close does not exist.");\r
- }, "BluetoothSocketSuccessCallback_onsuccess");\r
-\r
- //BluetoothSocket_uuid_attribute AE AT ARO\r
- test(function () {\r
- skUuid = socket.uuid;\r
- check_readonly(socket, "uuid", skUuid, "string", "1234");\r
- }, "BluetoothSocket_uuid_attribute");\r
-\r
- //BluetoothSocket_writeData_exist ME\r
- test(function () {\r
- assert_true("writeData" in socket, "connectToServiceByUUID does not exist.");\r
- check_method_exists(socket, "writeData");\r
- }, "BluetoothSocket_writeData_exist");\r
-\r
- //BluetoothSocket_writeData_missarg MMA\r
- /*test(function () {\r
- assert_throws ({name:"TypeMismatchError"},\r
- function () {\r
- socket.writeData();\r
- }, "Method with non optional argument.");\r
- }, "BluetoothSocket_writeData_missarg");\r
- \r
- //BluetoothSocket_writeData_TypeMismatch MC\r
- test(function () {\r
- param = [1, "aaa", {}, function () {}, true];\r
- for (i = 0; i < param.length; i++) {\r
- assert_throws(TYPE_MISMATCH_EXCEPTION,\r
- function () {\r
- socket.writeData(param[i]);\r
- }, "Method type mismatch");\r
- }\r
- }, "BluetoothSocket_writeData_TypeMismatch");*/\r
-\r
- //BluetoothSocket_close_extra_argument MNAEX\r
- test(function () {\r
- checkExtraArgument(socket, "close");\r
- }, "BluetoothSocket_close_extra_argument");\r
-\r
- //BluetoothSocketState_close_enum MNA MNAST\r
- test(function () {\r
- socket.close();\r
- assert_equals(socket.state, "CLOSED", "BluetoothSocket.state enum is no equal to 'CLOSED'");\r
- }, "BluetoothSocketState_close_enum");\r
-\r
- t.done();\r
- });\r
-\r
- onSocketError = t.step_func(function (e) {\r
- assert_unreached("onSocketError exception:" + e.message);\r
- });\r
-\r
- gotDeviceInfo = t.step_func(function (device) {\r
- device.connectToServiceByUUID(CHAT_SERVICE_UUID, onSocketConnect, onSocketError);\r
- });\r
-\r
- gotDeviceError = t.step_func(function (e) {\r
- assert_unreached("gotDeviceError exception:" + e.message);\r
- });\r
-\r
- onBondingSuccess = t.step_func(function () {\r
- adapter.getDevice(REMOTE_DEVICE_ADDRESS, gotDeviceInfo, gotDeviceError);\r
- });\r
-\r
- onBondingError = t.step_func(function (e) {\r
- assert_unreached("onBondingError exception:" + e.message);\r
- });\r
-\r
- PreBondSuccess = t.step_func(function () {\r
- adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError);\r
- });\r
-\r
- adapter = tizen.bluetooth.getDefaultAdapter();\r
- setPreBond(t, adapter, PreBondSuccess);\r
-\r
- } else {\r
- t.done();\r
- }\r
-});\r
-\r
-</script>\r
-</body>\r
-</html>\r
+<!DOCTYPE html>
+<!--
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd. All Rights Reserved
+
+Licensed under the Apache License, Version 2.0 (the License);
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+
+Authors:
+ Witold Choinkowski <w.choinkowsk@samsung.com>
+ Arkadiusz Pietraszek <a.pietraszek@samsung.com>
+
+-->
+<html>
+<head>
+<title>BluetoothSocket</title>
+<script src="support/unitcommon.js"></script>
+<script src="support/bluetooth_common.js"></script>
+</head>
+<body>
+
+<div id="log"></div>
+<script>
+//==== TEST: BluetoothSocket
+//==== LABEL Check BluetoothSocket attributes and functions
+//==== EXECUTION_TYPE manual
+//==== PRIORITY P3
+//==== STEP several tests executed from base test
+//==== EXPECT all subtests should be successful
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:close M
+//==== TEST_CRITERIA ME
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:close M
+//==== TEST_CRITERIA MNAEX
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:BluetoothSocket U
+//==== TEST_CRITERIA OBX
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:onclose A
+//==== TEST_CRITERIA AE ADV
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:onmessage A
+//==== TEST_CRITERIA AE ADV
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:peer A
+//==== TEST_CRITERIA AE AT ARO
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:readData M
+//==== TEST_CRITERIA ME
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:readData M
+//==== TEST_CRITERIA MNAEX
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:state A
+//==== TEST_CRITERIA AE AT ARO
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocketSuccessCallback:onsuccess M
+//==== TEST_CRITERIA CBT CBOA
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:uuid A
+//==== TEST_CRITERIA AE AT ARO
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:writeData M
+//==== TEST_CRITERIA ME
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:writeData M
+//==== TEST_CRITERIA MMA
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:writeData M
+//==== TEST_CRITERIA MC
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothSocket:close M
+//==== TEST_CRITERIA MNA MNAST
+//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/bluetooth.html
+//==== PRE The bluetooth of the remote/test device MUST be turned on and discoverable from other devices. The remote device MUST register the service by pushing [Register service] button on tct-bt-helper.
+
+setup({timeout: 180000});
+var t = async_test(document.title, {timeout: 180000}), adapter, onSocketConnect, onSocketError,
+ gotDeviceInfo, gotDeviceError, onBondingSuccess, onBondingError, powerOnSuccess,
+ peerCP, fakePeer, skState, skUuid, param, i;
+t.step(function () {
+ if (BT_SUPPORT) { // network.bluetooth support
+ add_completion_callback(function () {
+ clearBonding(REMOTE_DEVICE_ADDRESS);
+ });
+
+ onSocketConnect = t.step_func(function (socket) {
+ //BluetoothSocket_close_exist ME
+ test(function () {
+ assert_true("close" in socket, "close in onSocketConnect");
+ check_method_exists(socket, "close");
+ }, "BluetoothSocket_close_exist");
+
+ //BluetoothSocket_extend OBX
+ test(function () {
+ check_extensibility(socket);
+ }, "BluetoothSocket_extend");
+
+ //BluetoothSocket_onclose_property_exists AE ADV
+ test(function () {
+ assert_true("onclose" in socket, "onclose in onSocketConnect");
+ assert_equals(socket.onclose, null, "onclose in BluetoothSocket has wrong default value");
+ }, "BluetoothSocket_onclose_property_exists");
+
+ //BluetoothSocket_onmessage_property_exists AE ADV
+ test(function () {
+ assert_true("onmessage" in socket, "onmessage in onSocketConnect");
+ assert_equals(socket.onmessage, null, "onmessage in BluetoothSocket has wrong default value");
+ }, "BluetoothSocket_onmessage_property_exists");
+
+ //BluetoothSocket_peer_attribute AE AT ARO
+ test(function () {
+ assert_own_property(socket, "peer", "socket does not own peer property.");
+ assert_own_property(socket.peer, "name", "socket.peer does not own name property.");
+ assert_own_property(socket.peer, "address", "socket.peer does not own address property.");
+ assert_own_property(socket.peer, "deviceClass", "socket.peer does not own deviceClass property.");
+ assert_own_property(socket.peer, "isBonded", "socket.peer does not own isBonded property.");
+ assert_own_property(socket.peer, "isTrusted", "socket.peer does not own isTrusted property.");
+ assert_own_property(socket.peer, "isConnected", "socket.peer does not own isConnected property.");
+ assert_own_property(socket.peer, "uuids", "socket.peer does not own uuids property.");
+
+ assert_type(socket.peer, "object", "Type of deviceClass is different.");
+
+ //peer is obtained by getter so I can not directly test the override
+ peerCP = socket.peer;
+ fakePeer = {
+ name: "fakeName",
+ address: "00:02:18:2F:78:32",
+ deviceClass: {},
+ isBonded: true,
+ isTrusted: true,
+ isConnected: true,
+ uuids: [],
+
+ connectToServiceByUUID: function () { }
+ };
+ socket.peer = fakePeer;
+ assert_equals(socket.peer.name, peerCP.name, "peer can be modified.");
+ assert_equals(socket.peer.address, peerCP.address, "peer can be modified.");
+ assert_equals(socket.peer.isBonded, peerCP.isBonded, "peer can be modified.");
+ assert_equals(socket.peer.isTrusted, peerCP.isTrusted, "peer can be modified.");
+ assert_equals(socket.peer.isConnected, peerCP.isConnected, "peer can be modified.");
+ assert_array_equals(socket.peer.uuids, peerCP.uuids, "deviceClass can be modified.");
+ }, "BluetoothSocket_peer_attribute");
+
+ //BluetoothSocket_readData_exist ME
+ test(function () {
+ assert_true("readData" in socket, "readData in onSocketConnect");
+ check_method_exists(socket, "readData");
+ }, "BluetoothSocket_readData_exist");
+
+ //BluetoothSocket_readData_extra_argument MNAEX
+ test(function () {
+ checkExtraArgument(socket, "readData");
+ }, "BluetoothSocket_readData_extra_argument");
+
+ //BluetoothSocket_state_attribute AE AT ARO
+ test(function () {
+ skState = socket.state;
+ check_readonly(socket, "state", skState, "string", "1234");
+ }, "BluetoothSocket_state_attribute");
+
+ //BluetoothSocketSuccessCallback_onsuccess CBT CBOA
+ test(function () {
+ assert_true("uuid" in socket, "No uuid in socket");
+ assert_true("state" in socket, "No state in socket");
+ assert_true("peer" in socket, "No peer in socket");
+ assert_true("onmessage" in socket, "No onmessage in socket");
+ assert_true("onclose" in socket, "No onclose in socket");
+ assert_type(socket.writeData, "function", "Method writeData does not exist.");
+ assert_type(socket.readData, "function", "Method readData does not exist.");
+ assert_type(socket.close, "function", "Method close does not exist.");
+ }, "BluetoothSocketSuccessCallback_onsuccess");
+
+ //BluetoothSocket_uuid_attribute AE AT ARO
+ test(function () {
+ skUuid = socket.uuid;
+ check_readonly(socket, "uuid", skUuid, "string", "1234");
+ }, "BluetoothSocket_uuid_attribute");
+
+ //BluetoothSocket_writeData_exist ME
+ test(function () {
+ assert_true("writeData" in socket, "connectToServiceByUUID does not exist.");
+ check_method_exists(socket, "writeData");
+ }, "BluetoothSocket_writeData_exist");
+
+ //BluetoothSocket_writeData_missarg MMA
+ /*test(function () {
+ assert_throws ({name:"TypeMismatchError"},
+ function () {
+ socket.writeData();
+ }, "Method with non optional argument.");
+ }, "BluetoothSocket_writeData_missarg");
+
+ //BluetoothSocket_writeData_TypeMismatch MC
+ test(function () {
+ param = [1, "aaa", {}, function () {}, true];
+ for (i = 0; i < param.length; i++) {
+ assert_throws(TYPE_MISMATCH_EXCEPTION,
+ function () {
+ socket.writeData(param[i]);
+ }, "Method type mismatch");
+ }
+ }, "BluetoothSocket_writeData_TypeMismatch");*/
+
+ //BluetoothSocket_close_extra_argument MNAEX
+ test(function () {
+ checkExtraArgument(socket, "close");
+ }, "BluetoothSocket_close_extra_argument");
+
+ //BluetoothSocketState_close_enum MNA MNAST
+ test(function () {
+ socket.close();
+ assert_equals(socket.state, "CLOSED", "BluetoothSocket.state enum is no equal to 'CLOSED'");
+ }, "BluetoothSocketState_close_enum");
+
+ t.done();
+ });
+
+ onSocketError = t.step_func(function (e) {
+ assert_unreached("onSocketError exception:" + e.message);
+ });
+
+ gotDeviceInfo = t.step_func(function (device) {
+ device.connectToServiceByUUID(CHAT_SERVICE_UUID, onSocketConnect, onSocketError);
+ });
+
+ gotDeviceError = t.step_func(function (e) {
+ assert_unreached("gotDeviceError exception:" + e.message);
+ });
+
+ onBondingSuccess = t.step_func(function () {
+ adapter.getDevice(REMOTE_DEVICE_ADDRESS, gotDeviceInfo, gotDeviceError);
+ });
+
+ onBondingError = t.step_func(function (e) {
+ assert_unreached("onBondingError exception:" + e.message);
+ });
+
+ PreBondSuccess = t.step_func(function () {
+ adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError);
+ });
+
+ adapter = tizen.bluetooth.getDefaultAdapter();
+ setPreBond(t, adapter, PreBondSuccess);
+
+ } else {
+ t.done();
+ }
+});
+
+</script>
+</body>
+</html>