-<!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>BluetoothDevice</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: BluetoothDevice\r
-//==== LABEL Check BluetoothDevice 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:BluetoothDeviceSuccessCallback:onsuccess M\r
-//==== TEST_CRITERIA CBT CBOA\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:address A\r
-//==== TEST_CRITERIA AE AT ARO\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:deviceClass A\r
-//==== TEST_CRITERIA AE AT ARO(loose)\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:isBonded M\r
-//==== TEST_CRITERIA AE AT ARO\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:isConnected A\r
-//==== TEST_CRITERIA AE AT ARO\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:isTrusted A\r
-//==== TEST_CRITERIA AE AT ARO\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:name A\r
-//==== TEST_CRITERIA AE AT ARO\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:uuids A\r
-//==== TEST_CRITERIA AE AT ARO\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:BluetoothDevice U\r
-//==== TEST_CRITERIA OBX\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:connectToServiceByUUID M\r
-//==== TEST_CRITERIA ME\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:connectToServiceByUUID M\r
-//==== TEST_CRITERIA MMA\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:connectToServiceByUUID M\r
-//==== TEST_CRITERIA MTCB\r
-//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:connectToServiceByUUID M\r
-//==== TEST_CRITERIA MC\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, powerOnSuccess, onBondingError, onBondingSuccess, errorCallback,\r
- successCallback, exceptionName = "TypeMismatchError", conversionTable, conversionErrorCallback, conversionSuccessCallback,\r
- incorrectSuccessCallback, incorrectErrorCallback, successCallback, errorCallback, deviceClassCP, fakeDeviceClass, devUuid, 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
- incorrectSuccessCallback = {\r
- onsuccess: t.step_func(function () {\r
- assert_unreached("Invalid successCallback invoked");\r
- })\r
- };\r
- incorrectErrorCallback = {\r
- onerror: t.step_func(function () {\r
- assert_unreached("Invalid errorCallback invoked: ");\r
- })\r
- };\r
-\r
- successCallback = t.step_func(function () {\r
- assert_unreached("successCallback exception");\r
- });\r
-\r
- errorCallback = t.step_func(function (e) {\r
- assert_unreached("errorCallback exception:" + e.message);\r
- });\r
-\r
- onBondingSuccess = t.step_func(function (device) {\r
- //BluetoothDeviceSuccessCallback CBT CBOA\r
- test(function () {\r
- assert_true("name" in device, "No name in device");\r
- assert_true("address" in device, "No address in device");\r
- assert_true("deviceClass" in device, "No deviceClass in device");\r
- assert_true("isBonded" in device, "No isBonded in device");\r
- assert_true("isTrusted" in device, "No isTrusted in device");\r
- assert_true("isConnected" in device, "No isConnected in device");\r
- assert_true("uuids" in device, "No uuids in device");\r
- assert_type(device.connectToServiceByUUID, "function", "Method connectToServiceByUUID does not exist.");\r
- }, "BluetoothDeviceSuccessCallback_onsuccess");\r
-\r
- //address AE AT ARO\r
- test(function () {\r
- check_readonly(device, "address", REMOTE_DEVICE_ADDRESS, "string", device.address + "Tizen");\r
- }, "BluetoothDevice_address_attribute");\r
-\r
- //deviceClass AE AT ARO(loose)\r
- test(function () {\r
- assert_own_property(device, "deviceClass", "device does not own deviceClass property.");\r
- assert_own_property(device.deviceClass, "major", "device.deviceClass does not own major property.");\r
- assert_own_property(device.deviceClass, "minor", "device.deviceClass does not own minor property.");\r
- assert_own_property(device.deviceClass, "services", "device.deviceClass does not own services property.");\r
-\r
- assert_type(device.deviceClass, "object", "Type of deviceClass is different.");\r
-\r
- //deviceClass is obtained by getter so I can not directly test the override\r
- deviceClassCP = device.deviceClass;\r
- fakeDeviceClass = {\r
- major: 0x01,\r
- minor: 0x01,\r
- services: []\r
- };\r
- device.deviceClass = fakeDeviceClass;\r
- assert_equals(device.deviceClass.major, deviceClassCP.major, "deviceClass can be modified.");\r
- assert_equals(device.deviceClass.minor, deviceClassCP.minor, "deviceClass can be modified.");\r
- assert_array_equals(device.deviceClass.services, deviceClassCP.services, "deviceClass can be modified.");\r
- }, "BluetoothDevice_deviceClass_attribute");\r
-\r
- //isBonded AE AT ARO\r
- test(function () {\r
- check_readonly(device, "isBonded", true, "boolean", false);\r
- }, "BluetoothDevice_isBonded_attribute");\r
-\r
- //isConnected AE AT ARO\r
- test(function () {\r
- check_readonly(device, "isConnected", device.isConnected, "boolean", !device.isConnected);\r
- }, "BluetoothDevice_isConnected_attribute");\r
-\r
- //isTrusted AE AT ARO\r
- test(function () {\r
- check_readonly(device, "isTrusted", device.isTrusted, "boolean", !device.isTrusted);\r
- }, "BluetoothDevice_isTrusted_attribute");\r
-\r
- //name AE AT ARO\r
- test(function () {\r
- check_readonly(device, "name", device.name, "string", device.name + "Tizen");\r
- }, "BluetoothDevice_name_attribute");\r
-\r
- //uuids AE AT ARO\r
- test(function () {\r
- assert_true("uuids" in device, "uuids in gotDeviceInfo");\r
- assert_type(device.uuids, "array", "wrong type of uuids in device");\r
- assert_true(device.uuids.length > 0, "bluetooth device uuids not found");\r
-\r
- devUuid = device.uuids[0];\r
- assert_type(device.uuids[0], "string", "device.uuids[0] is type string.");\r
- device.uuids = [];\r
- device.uuids[0] = "test string";\r
- assert_true(devUuid === device.uuids[0], "device.uuids[0] readonly");\r
- }, "BluetoothDevice_uuids_attribute");\r
-\r
- //BluetoothDevice OBX\r
- test(function () {\r
- check_extensibility(device);\r
- }, "BluetoothDevice_extend");\r
-\r
- //connectToServiceByUUID ME\r
- test(function () {\r
- assert_true("connectToServiceByUUID" in device, "No connectToServiceByUUID in device");\r
- check_method_exists(device, "connectToServiceByUUID");\r
- }, "BluetoothDevice_connectToServiceByUUID_exist");\r
-\r
- //connectToServiceByUUID MMA\r
- test(function () {\r
- assert_throws({ name: "TypeMismatchError" },\r
- function () {\r
- device.connectToServiceByUUID();\r
- }, "Method with non optional argument.");\r
- }, "BluetoothDevice_connectToServiceByUUID_missarg");\r
-\r
- //connectToServiceByUUID errorCallback MTCB\r
- test(function () {\r
- assert_throws({ name: exceptionName },\r
- function () {\r
- device.connectToServiceByUUID(CHAT_SERVICE_UUID, successCallback, incorrectErrorCallback);\r
- }, exceptionName + " should be thrown - given incorrect error callback.");\r
- }, "BluetoothDevice_connectToServiceByUUID_errorCallback_invalid_cb");\r
-\r
- //connectToServiceByUUID successCallback MTCB\r
- test(function () {\r
- assert_throws({ name: exceptionName },\r
- function () {\r
- device.connectToServiceByUUID(CHAT_SERVICE_UUID, incorrectSuccessCallback, errorCallback);\r
- }, exceptionName + " should be thrown - given incorrect error callback.");\r
- }, "BluetoothDevice_connectToServiceByUUID_successCallback_invalid_cb");\r
-\r
- //connectToServiceByUUID errorCallback MC\r
- test(function () {\r
- conversionTable = getTypeConversionExceptions("functionObject", true);\r
- for (i = 0; i < conversionTable.length; i++) {\r
- conversionErrorCallback = conversionTable[i][0];\r
- exceptionName = conversionTable[i][1];\r
-\r
- assert_throws({ name: exceptionName },\r
- function () {\r
- device.connectToServiceByUUID(CHAT_SERVICE_UUID, successCallback, conversionErrorCallback);\r
- }, exceptionName + " should be thrown - given incorrect errorCallback.");\r
- }\r
- }, "BluetoothDevice_connectToServiceByUUID_errorCallback_TypeMismatch");\r
-\r
- //connectToServiceByUUID successCallback MC\r
- test(function () {\r
- conversionTable = getTypeConversionExceptions("functionObject", false);\r
- for (i = 0; i < conversionTable.length; i++) {\r
- conversionSuccessCallback = conversionTable[i][0];\r
- exceptionName = conversionTable[i][1];\r
-\r
- assert_throws({ name: exceptionName },\r
- function () {\r
- device.connectToServiceByUUID(CHAT_SERVICE_UUID, conversionSuccessCallback, errorCallback);\r
- }, exceptionName + " should be thrown - given incorrect successCallback.");\r
- }\r
- }, "BluetoothDevice_connectToServiceByUUID_successCallback_TypeMismatch");\r
-\r
- t.done();\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>BluetoothDevice</title>
+<script src="support/unitcommon.js"></script>
+<script src="support/bluetooth_common.js"></script>
+</head>
+<body>
+
+<div id="log"></div>
+<script>
+//==== TEST: BluetoothDevice
+//==== LABEL Check BluetoothDevice 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:BluetoothDeviceSuccessCallback:onsuccess M
+//==== TEST_CRITERIA CBT CBOA
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:address A
+//==== TEST_CRITERIA AE AT ARO
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:deviceClass A
+//==== TEST_CRITERIA AE AT ARO(loose)
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:isBonded M
+//==== TEST_CRITERIA AE AT ARO
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:isConnected A
+//==== TEST_CRITERIA AE AT ARO
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:isTrusted A
+//==== TEST_CRITERIA AE AT ARO
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:name A
+//==== TEST_CRITERIA AE AT ARO
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:uuids A
+//==== TEST_CRITERIA AE AT ARO
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:BluetoothDevice U
+//==== TEST_CRITERIA OBX
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:connectToServiceByUUID M
+//==== TEST_CRITERIA ME
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:connectToServiceByUUID M
+//==== TEST_CRITERIA MMA
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:connectToServiceByUUID M
+//==== TEST_CRITERIA MTCB
+//==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothDevice:connectToServiceByUUID M
+//==== TEST_CRITERIA MC
+//==== 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, powerOnSuccess, onBondingError, onBondingSuccess, errorCallback,
+ successCallback, exceptionName = "TypeMismatchError", conversionTable, conversionErrorCallback, conversionSuccessCallback,
+ incorrectSuccessCallback, incorrectErrorCallback, successCallback, errorCallback, deviceClassCP, fakeDeviceClass, devUuid, i;
+t.step(function () {
+ if (BT_SUPPORT) { // network.bluetooth support
+ add_completion_callback(function () {
+ clearBonding(REMOTE_DEVICE_ADDRESS);
+ });
+
+ incorrectSuccessCallback = {
+ onsuccess: t.step_func(function () {
+ assert_unreached("Invalid successCallback invoked");
+ })
+ };
+ incorrectErrorCallback = {
+ onerror: t.step_func(function () {
+ assert_unreached("Invalid errorCallback invoked: ");
+ })
+ };
+
+ successCallback = t.step_func(function () {
+ assert_unreached("successCallback exception");
+ });
+
+ errorCallback = t.step_func(function (e) {
+ assert_unreached("errorCallback exception:" + e.message);
+ });
+
+ onBondingSuccess = t.step_func(function (device) {
+ //BluetoothDeviceSuccessCallback CBT CBOA
+ test(function () {
+ assert_true("name" in device, "No name in device");
+ assert_true("address" in device, "No address in device");
+ assert_true("deviceClass" in device, "No deviceClass in device");
+ assert_true("isBonded" in device, "No isBonded in device");
+ assert_true("isTrusted" in device, "No isTrusted in device");
+ assert_true("isConnected" in device, "No isConnected in device");
+ assert_true("uuids" in device, "No uuids in device");
+ assert_type(device.connectToServiceByUUID, "function", "Method connectToServiceByUUID does not exist.");
+ }, "BluetoothDeviceSuccessCallback_onsuccess");
+
+ //address AE AT ARO
+ test(function () {
+ check_readonly(device, "address", REMOTE_DEVICE_ADDRESS, "string", device.address + "Tizen");
+ }, "BluetoothDevice_address_attribute");
+
+ //deviceClass AE AT ARO(loose)
+ test(function () {
+ assert_own_property(device, "deviceClass", "device does not own deviceClass property.");
+ assert_own_property(device.deviceClass, "major", "device.deviceClass does not own major property.");
+ assert_own_property(device.deviceClass, "minor", "device.deviceClass does not own minor property.");
+ assert_own_property(device.deviceClass, "services", "device.deviceClass does not own services property.");
+
+ assert_type(device.deviceClass, "object", "Type of deviceClass is different.");
+
+ //deviceClass is obtained by getter so I can not directly test the override
+ deviceClassCP = device.deviceClass;
+ fakeDeviceClass = {
+ major: 0x01,
+ minor: 0x01,
+ services: []
+ };
+ device.deviceClass = fakeDeviceClass;
+ assert_equals(device.deviceClass.major, deviceClassCP.major, "deviceClass can be modified.");
+ assert_equals(device.deviceClass.minor, deviceClassCP.minor, "deviceClass can be modified.");
+ assert_array_equals(device.deviceClass.services, deviceClassCP.services, "deviceClass can be modified.");
+ }, "BluetoothDevice_deviceClass_attribute");
+
+ //isBonded AE AT ARO
+ test(function () {
+ check_readonly(device, "isBonded", true, "boolean", false);
+ }, "BluetoothDevice_isBonded_attribute");
+
+ //isConnected AE AT ARO
+ test(function () {
+ check_readonly(device, "isConnected", device.isConnected, "boolean", !device.isConnected);
+ }, "BluetoothDevice_isConnected_attribute");
+
+ //isTrusted AE AT ARO
+ test(function () {
+ check_readonly(device, "isTrusted", device.isTrusted, "boolean", !device.isTrusted);
+ }, "BluetoothDevice_isTrusted_attribute");
+
+ //name AE AT ARO
+ test(function () {
+ check_readonly(device, "name", device.name, "string", device.name + "Tizen");
+ }, "BluetoothDevice_name_attribute");
+
+ //uuids AE AT ARO
+ test(function () {
+ assert_true("uuids" in device, "uuids in gotDeviceInfo");
+ assert_type(device.uuids, "array", "wrong type of uuids in device");
+ assert_true(device.uuids.length > 0, "bluetooth device uuids not found");
+
+ devUuid = device.uuids[0];
+ assert_type(device.uuids[0], "string", "device.uuids[0] is type string.");
+ device.uuids = [];
+ device.uuids[0] = "test string";
+ assert_true(devUuid === device.uuids[0], "device.uuids[0] readonly");
+ }, "BluetoothDevice_uuids_attribute");
+
+ //BluetoothDevice OBX
+ test(function () {
+ check_extensibility(device);
+ }, "BluetoothDevice_extend");
+
+ //connectToServiceByUUID ME
+ test(function () {
+ assert_true("connectToServiceByUUID" in device, "No connectToServiceByUUID in device");
+ check_method_exists(device, "connectToServiceByUUID");
+ }, "BluetoothDevice_connectToServiceByUUID_exist");
+
+ //connectToServiceByUUID MMA
+ test(function () {
+ assert_throws({ name: "TypeMismatchError" },
+ function () {
+ device.connectToServiceByUUID();
+ }, "Method with non optional argument.");
+ }, "BluetoothDevice_connectToServiceByUUID_missarg");
+
+ //connectToServiceByUUID errorCallback MTCB
+ test(function () {
+ assert_throws({ name: exceptionName },
+ function () {
+ device.connectToServiceByUUID(CHAT_SERVICE_UUID, successCallback, incorrectErrorCallback);
+ }, exceptionName + " should be thrown - given incorrect error callback.");
+ }, "BluetoothDevice_connectToServiceByUUID_errorCallback_invalid_cb");
+
+ //connectToServiceByUUID successCallback MTCB
+ test(function () {
+ assert_throws({ name: exceptionName },
+ function () {
+ device.connectToServiceByUUID(CHAT_SERVICE_UUID, incorrectSuccessCallback, errorCallback);
+ }, exceptionName + " should be thrown - given incorrect error callback.");
+ }, "BluetoothDevice_connectToServiceByUUID_successCallback_invalid_cb");
+
+ //connectToServiceByUUID errorCallback MC
+ test(function () {
+ conversionTable = getTypeConversionExceptions("functionObject", true);
+ for (i = 0; i < conversionTable.length; i++) {
+ conversionErrorCallback = conversionTable[i][0];
+ exceptionName = conversionTable[i][1];
+
+ assert_throws({ name: exceptionName },
+ function () {
+ device.connectToServiceByUUID(CHAT_SERVICE_UUID, successCallback, conversionErrorCallback);
+ }, exceptionName + " should be thrown - given incorrect errorCallback.");
+ }
+ }, "BluetoothDevice_connectToServiceByUUID_errorCallback_TypeMismatch");
+
+ //connectToServiceByUUID successCallback MC
+ test(function () {
+ conversionTable = getTypeConversionExceptions("functionObject", false);
+ for (i = 0; i < conversionTable.length; i++) {
+ conversionSuccessCallback = conversionTable[i][0];
+ exceptionName = conversionTable[i][1];
+
+ assert_throws({ name: exceptionName },
+ function () {
+ device.connectToServiceByUUID(CHAT_SERVICE_UUID, conversionSuccessCallback, errorCallback);
+ }, exceptionName + " should be thrown - given incorrect successCallback.");
+ }
+ }, "BluetoothDevice_connectToServiceByUUID_successCallback_TypeMismatch");
+
+ t.done();
+ });
+
+ 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>